Search in sources :

Example 1 with IScrollableFigure

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();
    }
}
Also used : Insets(org.eclipse.draw2d.geometry.Insets) Rectangle(org.eclipse.draw2d.geometry.Rectangle) IScrollableFigure(org.eclipse.draw2d.IScrollableFigure) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) IFigure(org.eclipse.draw2d.IFigure)

Aggregations

ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 IFigure (org.eclipse.draw2d.IFigure)1 IScrollableFigure (org.eclipse.draw2d.IScrollableFigure)1 Insets (org.eclipse.draw2d.geometry.Insets)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1