Java Reference
In-Depth Information
As the viewer is populated, each EditPart has its refreshVisuals()
method invoked to update the display of its model information. This method is
also invoked when we start listening to model changes, to reflect changes in the
underlying model in the diagram. Following is the refreshVisuals() method
for our LogicDiagramEditPart . Note the use of the Animation class in the
logic diagram.
protected void refreshVisuals() {
Animation.markBegin();
ConnectionLayer cLayer = (ConnectionLayer)
getLayer(CONNECTION_LAYER);
if ((getViewer().getControl().getStyle() & SWT.MIRRORED ) == 0)
cLayer.setAntialias(SWT.ON);
if (getLogicDiagram().getConnectionRouter()
.equals(LogicDiagram.ROUTER_MANUAL)) {
AutomaticRouter router = new FanRouter();
router.setNextRouter( new BendpointConnectionRouter());
cLayer.setConnectionRouter(router);
} else if (getLogicDiagram().getConnectionRouter()
.equals(LogicDiagram.ROUTER_MANHATTAN)) {
cLayer.setConnectionRouter( new
ManhattanConnectionRouter());
} else {
cLayer.setConnectionRouter( new
ShortestPathConnectionRouter(getFigure()));
Animation.run(400);
}
The bulk of the content in the refreshVisuals() method of the diagram
relates to connections on the diagram. This is because children of the diagram
are represented by Figure s of their own (typically called nodes ) and have asso-
ciated EditPart s that are managed through calls to getModelChildren() , as
mentioned earlier. Connection s are special EditPart s that require some addi-
tional explanation; the next section covers them.
The remaining EditPart s in the logic diagram extend from an abstract
LogicEditPart class that provides this general refreshVisuals() method
implementation.
protected void refreshVisuals() {
Point loc = getLogicSubpart().getLocation();
Dimension size= getLogicSubpart().getSize();
Rectangle r = new Rectangle(loc ,size);
((GraphicalEditPart) getParent()).setLayoutConstraint( this ,
getFigure(), r);
}
Search WWH ::




Custom Search