Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "GEF/GEF4/Graphics"

< GEF‎ | GEF4
m
(Removed outdated documentation, as initial GEF4 Graphics component was discontinued.)
 
(103 intermediate revisions by the same user not shown)
Line 1: Line 1:
''Note to non-wiki readers: This documentation is generated from the Eclipse wiki - if you have corrections or additions it would be awesome if you added them in [http://wiki.eclipse.org/GEF/GEF4/Graphics the original wiki page]''.
+
The GEF4 Graphics component became obsolete and was replaced by the [[GEF/GEF4/FX|GEF4 FX]] component.
 
+
__NOTOC__
+
 
+
== Introduction ==
+
 
+
The GEF 4 Graphics component provides a level of abstraction over different drawing toolkits. At the moment, SWT and AWT backends are in development. Its goal is to be as complete as possible, i.e. you should have access to all the functionality that you have access to when working directly with one of the underlying drawing toolkits. Of course, this is not always viable, but rather the greatest common divisor of the underlying drawing toolkits is accessible via the abstraction layer.
+
 
+
== IGraphics ==
+
 
+
The heart of the GEF 4 Graphics component is the IGraphics interface. Normally, you will be handed over an IGraphics to accomplish your displaying tasks by a surrounding framework, but it can be used stand-alone, too. Therefore, you have to create an IGraphics implementation for either AWT or SWT. Let us consider the following SWT example:
+
 
+
<source lang="java">
+
import org.eclipse.gef4.graphics.swt.DisplayGraphics;
+
import org.eclipse.swt.SWT;
+
import org.eclipse.swt.events.PaintEvent;
+
import org.eclipse.swt.events.PaintListener;
+
import org.eclipse.swt.widgets.Display;
+
import org.eclipse.swt.widgets.Shell;
+
 
+
public class SWTGraphicsExample implements PaintListener {
+
public static void main(String[] args) {
+
new SWTGraphicsExample("GEF 4 Graphics - SWT");
+
}
+
 
+
public SWTGraphicsExample(String title) {
+
Display display = new Display();
+
 
+
Shell shell = new Shell(display, SWT.SHELL_TRIM | SWT.DOUBLE_BUFFERED);
+
shell.setText(title);
+
shell.setBounds(0, 0, 640, 480);
+
shell.open();
+
 
+
shell.addPaintListener(this);
+
 
+
while (!shell.isDisposed())
+
if (!display.readAndDispatch())
+
display.sleep();
+
}
+
 
+
public void paintControl(PaintEvent e) {
+
DisplayGraphics g = new DisplayGraphics(e.gc);
+
                // do your drawings here
+
}
+
}
+
</source>
+
 
+
The different geometric objects provided by the GEF 4 Geometry component can be easily displayed via the GEF 4 Graphics component. Additionally, the
+

Latest revision as of 04:57, 23 May 2015

The GEF4 Graphics component became obsolete and was replaced by the GEF4 FX component.

Copyright © Eclipse Foundation, Inc. All Rights Reserved.