use of org.eclipse.draw2d.IScrollableFigure in project archi by archimatetool.
the class ScrollableSelectionFeedbackEditPolicy method showFeedback.
/**
* Creates feedback figures for all node figures nested within the host
* figure's viewport, as well as for all incoming and outgoing connections
* of these nodes. Feedback figures are only created in case there are
* children or connections, which are not fully visible.
*/
protected void showFeedback() {
// ensure primary and connection layer are revalidated,
// so the bounds of all their child figures, which are
// used to calculate the feedback figure constraints,
// are valid
getLayer(LayerConstants.PRIMARY_LAYER).validate();
getLayer(LayerConstants.CONNECTION_LAYER).validate();
// check if there is a node child exceeding the client are
Rectangle clientArea = getAbsoluteClientArea(getHostFigure());
boolean primaryLayerChildExceedsViewport = !clientArea.equals(getAbsoluteViewportArea(((IScrollableFigure) getHostFigure()).getScrollPane().getViewport()));
// check if there is a connection exceeding the client area
boolean connectionLayerChildExceedsClientArea = false;
List connectionLayerChildren = getLayer(LayerConstants.CONNECTION_LAYER).getChildren();
for (Iterator iterator = connectionLayerChildren.iterator(); iterator.hasNext() && !connectionLayerChildExceedsClientArea; ) {
IFigure connectionLayerChild = (IFigure) iterator.next();
connectionLayerChildExceedsClientArea = (ViewportUtilities.getNearestEnclosingViewport(connectionLayerChild) == ((IScrollableFigure) getHostFigure()).getScrollPane().getViewport() && !clientArea.getExpanded(new Insets(1, 1, 1, 1)).contains(getAbsoluteBounds(connectionLayerChild)));
}
// bounds exceed the client area
if (primaryLayerChildExceedsViewport || connectionLayerChildExceedsClientArea) {
createNodeFeedbackFigures();
createConnectionFeedbackFigures();
}
}