Search in sources :

Example 41 with Viewport

use of org.eclipse.draw2d.Viewport in project archi by archimatetool.

the class ViewportHelper method findViewport.

protected Viewport findViewport(GraphicalEditPart part) {
    IFigure figure = null;
    Viewport port = null;
    do {
        if (figure == null)
            figure = part.getContentPane();
        else
            figure = figure.getParent();
        if (figure instanceof Viewport) {
            port = (Viewport) figure;
            break;
        }
    } while (figure != part.getFigure() && figure != null);
    return port;
}
Also used : Viewport(org.eclipse.draw2d.Viewport) IFigure(org.eclipse.draw2d.IFigure)

Example 42 with Viewport

use of org.eclipse.draw2d.Viewport in project archi by archimatetool.

the class ScrollingGraphicalViewer method reveal.

/**
 * Extends the superclass implementation to scroll the native Canvas control
 * after the super's implementation has completed.
 *
 * @see org.eclipse.gef.EditPartViewer#reveal(org.eclipse.gef.EditPart)
 */
@Override
public void reveal(EditPart part) {
    super.reveal(part);
    Viewport port = getFigureCanvas().getViewport();
    IFigure target = ((GraphicalEditPart) part).getFigure();
    Rectangle exposeRegion = target.getBounds().getCopy();
    target = target.getParent();
    while (target != null && target != port) {
        target.translateToParent(exposeRegion);
        target = target.getParent();
    }
    exposeRegion.expand(5, 5);
    Dimension viewportSize = port.getClientArea().getSize();
    Point topLeft = exposeRegion.getTopLeft();
    Point bottomRight = exposeRegion.getBottomRight().translate(viewportSize.getNegated());
    Point finalLocation = new Point();
    if (viewportSize.width < exposeRegion.width)
        finalLocation.x = Math.min(bottomRight.x, Math.max(topLeft.x, port.getViewLocation().x));
    else
        finalLocation.x = Math.min(topLeft.x, Math.max(bottomRight.x, port.getViewLocation().x));
    if (viewportSize.height < exposeRegion.height)
        finalLocation.y = Math.min(bottomRight.y, Math.max(topLeft.y, port.getViewLocation().y));
    else
        finalLocation.y = Math.min(topLeft.y, Math.max(bottomRight.y, port.getViewLocation().y));
    getFigureCanvas().scrollSmoothTo(finalLocation.x, finalLocation.y);
}
Also used : Viewport(org.eclipse.draw2d.Viewport) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Dimension(org.eclipse.draw2d.geometry.Dimension) Point(org.eclipse.draw2d.geometry.Point) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) IFigure(org.eclipse.draw2d.IFigure)

Example 43 with Viewport

use of org.eclipse.draw2d.Viewport in project archi by archimatetool.

the class ScrollableSelectionFeedbackEditPolicy method activate.

/**
 * @see org.eclipse.gef.editpolicies.SelectionEditPolicy#activate()
 */
@Override
public void activate() {
    super.activate();
    // unregistered within hideFeedback()
    for (Iterator iterator = ViewportUtilities.getViewportsPath(getHostFigureViewport(), ViewportUtilities.getRootViewport(getHostFigure())).iterator(); iterator.hasNext(); ) {
        Viewport viewport = (Viewport) iterator.next();
        viewport.addPropertyChangeListener(viewportViewLocationChangeListener);
    }
}
Also used : Iterator(java.util.Iterator) Viewport(org.eclipse.draw2d.Viewport)

Example 44 with Viewport

use of org.eclipse.draw2d.Viewport in project jbosstools-hibernate by jbosstools.

the class DiagramContentOutlinePage method initializeOverview.

/**
 */
protected void initializeOverview() {
    LightweightSystem lws = new LightweightSystem(overview);
    RootEditPart rep = getGraphicalViewer().getRootEditPart();
    if (rep instanceof ScalableFreeformRootEditPart) {
        ScalableFreeformRootEditPart root = (ScalableFreeformRootEditPart) rep;
        if (this.thumbnail != null) {
            this.thumbnail.deactivate();
        }
        thumbnail = new ScrollableThumbnail((Viewport) root.getFigure());
        thumbnail.setBorder(new MarginBorder(3));
        thumbnail.setSource(root.getLayer(LayerConstants.PRINTABLE_LAYERS));
        lws.setContents(thumbnail);
    }
}
Also used : ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) MarginBorder(org.eclipse.draw2d.MarginBorder) Viewport(org.eclipse.draw2d.Viewport) LightweightSystem(org.eclipse.draw2d.LightweightSystem) RootEditPart(org.eclipse.gef.RootEditPart) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) ScrollableThumbnail(org.eclipse.draw2d.parts.ScrollableThumbnail)

Aggregations

Viewport (org.eclipse.draw2d.Viewport)44 Point (org.eclipse.draw2d.geometry.Point)16 Rectangle (org.eclipse.draw2d.geometry.Rectangle)16 IFigure (org.eclipse.draw2d.IFigure)9 LightweightSystem (org.eclipse.draw2d.LightweightSystem)9 MarginBorder (org.eclipse.draw2d.MarginBorder)9 ScrollableThumbnail (org.eclipse.draw2d.parts.ScrollableThumbnail)9 Canvas (org.eclipse.swt.widgets.Canvas)9 Dimension (org.eclipse.draw2d.geometry.Dimension)7 ScalableFreeformRootEditPart (org.eclipse.gef.editparts.ScalableFreeformRootEditPart)6 Iterator (java.util.Iterator)4 FigureCanvas (org.eclipse.draw2d.FigureCanvas)4 ScrollPane (org.eclipse.draw2d.ScrollPane)4 LayeredPane (org.eclipse.draw2d.LayeredPane)3 RangeModel (org.eclipse.draw2d.RangeModel)3 PrecisionPoint (org.eclipse.draw2d.geometry.PrecisionPoint)3 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)3 RootEditPart (org.eclipse.gef.RootEditPart)3 Insets (org.eclipse.draw2d.geometry.Insets)2 EditPart (org.eclipse.gef.EditPart)2