Java Reference
In-Depth Information
public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart
connEditPart) {
Wire wire = (Wire) connEditPart.getModel();
return getNodeFigure().getConnectionAnchor(wire.getSourceTerminal());
}
The refreshVisuals() of the logic diagram's WireEditPart looks like
the following.
/**
* Refreshes the visual aspects of this, based upon the model (Wire).
* It changes the wire color depending on the state of Wire.
*/
protected void refreshVisuals() {
refreshBendpoints();
if (getWire().getValue()) {
getWireFigure().setForegroundColor(alive);
} else {
getWireFigure().setForegroundColor(dead);
}
}
At this point, we've discussed how a model element can be displayed on a
diagram using Draw2d Figure s that are managed by extending GEF's
AbstractGraphicalEditPart and overriding behavior appropriate for the
element. Next, we look at how to edit model elements through interaction with
the diagram.
9.2.3 Editing
Rendering visual elements related to an underlying model is the easy part.
Providing editing support is more complicated and requires several new concepts
used in GEF. Although EditPart s remain the center of this functionality, we dis-
cuss Requests, Commands, and EditPolicies in the context of the discussion.
Requests
You can interact with the underlying model in many ways, so GEF provides an
abstraction of all interaction with the Request class. As stated in its API docu-
mentation, a Request is an object used to communicate with EditPart s that
encapsulate the information EditPart s need to perform various functions.
Request s are used to obtain commands, show feedback, and perform generic
operations.
Search WWH ::




Custom Search