Java Reference
In-Depth Information
Table 9-1
Draw2d Coordinate System
Task
Absolute Coordinates
Relative Coordinates
Translate or move
The figure and all its children
Only the figure's bounds must be
a figure
must be translated, which can
updated. The children move for
be expensive in extreme cases.
free.
Hit-test/determine
No adjustments to coordinates
Some simple math is used to
repaint regions
are needed.
adjust coordinates and rectangles
to and from the coordinate
system's origin.
Observe the figure's
A FigureListener can be used
A FigureListener and
“location” on the
if the entire parent chain is using CoordinateListener must be
Canvas
absolute coordinates, but this
used. You must call
guarantee is rare.
translateToAbsolute on the
figure being observed to get its
canvas coordinates.
Determine the
Easy—after the children have
Extremely hard—updating the
bounds of a parent
been positioned, the parent can
parent's bounds causes the
based on the bounds
figure out what its bounds
children to “move.”
of the children
should be.
9.2 GEF
Whereas Draw2d provides painting and layout on an SWT canvas, GEF provides
the required functionality to edit a model with figures using workbench and
peripheral devices. It does this by implementing the well-known MVC architec-
ture, as seen in Figure 9-8.
Although GEF has its own independent notion of model, EMF often is used to
manage the underlying model. In fact, the GMF project was created precisely to
combine the model aspect of GEF with GMF and build additional capabilities upon
them. The view is largely provided by Draw2d Figure s and SWT TreeItem s,
which leaves the controller as the main discussion item for this chapter.
NOTE
When discussing GMF, it gets a bit confusing when considering the termi-
nology of GEF. In GMF,View is the main class in a diagram's notation model;
it holds a reference to the domain model element it represents. Both are
EMF models—together they represent the “model” discussed in the con-
text of GEF.
 
 
Search WWH ::




Custom Search