Search in sources :

Example 21 with Viewport

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

the class ViewportMouseWheelHelper method handleMouseWheelScrolled.

/**
 * Finds the viewport of the given EditPart and scrolls it as requested. If
 * it can't be scrolled then leaves doit to be true so that the given
 * EditPart's ancestors might have a chance to scroll.
 *
 * @see org.eclipse.gef.MouseWheelHelper#handleMouseWheelScrolled(org.eclipse.swt.widgets.Event)
 */
@Override
public void handleMouseWheelScrolled(Event event) {
    Viewport viewport = findViewport(owner);
    if (viewport == null || !viewport.isShowing())
        return;
    RangeModel rModel = viewport.getVerticalRangeModel();
    if (rModel.getExtent() < (rModel.getMaximum() - rModel.getMinimum())) {
        int currentPos = rModel.getValue();
        int scrollHeight = lineHeight;
        if (event.detail == SWT.SCROLL_PAGE)
            scrollHeight = pageHeight > lineHeight ? pageHeight : Math.max(lineHeight, viewport.getClientArea(Rectangle.SINGLETON).height - 26);
        scrollHeight *= event.count;
        viewport.setVerticalLocation(currentPos - scrollHeight);
        if (rModel.getValue() != currentPos)
            event.doit = false;
    }
}
Also used : Viewport(org.eclipse.draw2d.Viewport) RangeModel(org.eclipse.draw2d.RangeModel)

Example 22 with Viewport

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

the class ScrollableSelectionFeedbackEditPolicy method deactivate.

/**
 * @see org.eclipse.gef.editpolicies.SelectionEditPolicy#deactivate()
 */
@Override
public void deactivate() {
    // hideSelection(), so they do not have to be unregistered here
    for (Iterator iterator = ViewportUtilities.getViewportsPath(getHostFigureViewport(), ViewportUtilities.getRootViewport(getHostFigure())).iterator(); iterator.hasNext(); ) {
        Viewport viewport = (Viewport) iterator.next();
        viewport.removePropertyChangeListener(viewportViewLocationChangeListener);
    }
    super.deactivate();
}
Also used : Iterator(java.util.Iterator) Viewport(org.eclipse.draw2d.Viewport)

Example 23 with Viewport

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

the class ViewportAutoexposeHelper method detect.

/**
 * Returns <code>true</code> if the given point is inside the viewport, but
 * near its edge.
 *
 * @see org.eclipse.gef.AutoexposeHelper#detect(org.eclipse.draw2d.geometry.Point)
 */
@Override
public boolean detect(Point where) {
    lastStepTime = 0;
    Viewport port = findViewport(owner);
    Rectangle rect = Rectangle.SINGLETON;
    port.getClientArea(rect);
    port.translateToParent(rect);
    port.translateToAbsolute(rect);
    return rect.contains(where) && !rect.shrink(threshold).contains(where);
}
Also used : Viewport(org.eclipse.draw2d.Viewport) Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Example 24 with Viewport

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

the class GraphContainer method createContainerFigure.

private IFigure createContainerFigure() {
    GraphContainer node = this;
    IFigure containerFigure = new ContainerFigure();
    containerFigure.setOpaque(true);
    containerFigure.addLayoutListener(LayoutAnimator.getDefault());
    containerFigure.setLayoutManager(new FreeformLayout());
    expandGraphLabel = new ExpandGraphLabel(this, node.getText(), node.getImage(), false);
    expandGraphLabel.setText(getText());
    expandGraphLabel.setImage(getImage());
    ContainerDimension containerDimension = computeContainerSize();
    scrollPane = new ScrollPane();
    scrollPane.addLayoutListener(LayoutAnimator.getDefault());
    Viewport viewport = new FreeformViewport();
    /*
         * This is the code that helps remove the scroll bars moving when the
         * nodes are dragged.
         * 
         * viewport.setHorizontalRangeModel(new DefaultRangeModel() { public
         * void setAll(int min, int ext, int max) { System.out.println("Max: " +
         * max + " : current Max:  " + getMaximum()); if (max < getMaximum()) {
         * max = getMaximum(); } super.setAll(min, ext, max); }
         * 
         * public void setMaximum(int maximum) { // TODO Auto-generated method
         * stub System.out.println("Max: " + maximum + " : current Max:  " +
         * getMaximum()); if (maximum < getMaximum()) { return; }
         * super.setMaximum(maximum); } });
         */
    scrollPane.setViewport(viewport);
    viewport.addLayoutListener(LayoutAnimator.getDefault());
    scrollPane.setScrollBarVisibility(ScrollPane.AUTOMATIC);
    // scalledLayer = new ScalableFreeformLayeredPane();
    // $NON-NLS-1$
    scalledLayer = new AspectRatioFreeformLayer("debug label");
    scalledLayer.addLayoutListener(LayoutAnimator.getDefault());
    // scalledLayer.setScale(computeChildScale());
    scalledLayer.setScale(computeWidthScale(), computeHeightScale());
    // container = new FreeformLayer();
    // edgeLayer = new FreeformLayer();
    zestLayer = new ZestRootLayer();
    zestLayer.addLayoutListener(LayoutAnimator.getDefault());
    // container.addLayoutListener(LayoutAnimator.getDefault());
    // edgeLayer.addLayoutListener(LayoutAnimator.getDefault());
    // scalledLayer.add(edgeLayer);
    // scalledLayer.add(container);
    scalledLayer.add(zestLayer);
    // container.setLayoutManager(new FreeformLayout());
    zestLayer.setLayoutManager(new FreeformLayout());
    scrollPane.setSize(computeChildArea());
    scrollPane.setLocation(new Point(0, containerDimension.labelHeight - SUBLAYER_OFFSET));
    scrollPane.setForegroundColor(ColorConstants.gray);
    expandGraphLabel.setBackgroundColor(getBackgroundColor());
    expandGraphLabel.setForegroundColor(getForegroundColor());
    expandGraphLabel.setLocation(new Point(0, 0));
    containerFigure.add(scrollPane);
    containerFigure.add(expandGraphLabel);
    scrollPane.getViewport().setContents(scalledLayer);
    scrollPane.setBorder(new LineBorder());
    return containerFigure;
}
Also used : LineBorder(org.eclipse.draw2d.LineBorder) FreeformViewport(org.eclipse.draw2d.FreeformViewport) Viewport(org.eclipse.draw2d.Viewport) Point(org.eclipse.draw2d.geometry.Point) FreeformLayout(org.eclipse.draw2d.FreeformLayout) ScrollPane(org.eclipse.draw2d.ScrollPane) AspectRatioFreeformLayer(org.eclipse.zest.core.widgets.internal.AspectRatioFreeformLayer) FreeformViewport(org.eclipse.draw2d.FreeformViewport) ZestRootLayer(org.eclipse.zest.core.widgets.internal.ZestRootLayer) ExpandGraphLabel(org.eclipse.zest.core.widgets.internal.ExpandGraphLabel) IFigure(org.eclipse.draw2d.IFigure) ContainerFigure(org.eclipse.zest.core.widgets.internal.ContainerFigure)

Example 25 with Viewport

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

the class RulerComposite method disposeRulerViewer.

private void disposeRulerViewer(GraphicalViewer viewer) {
    if (viewer == null)
        return;
    /*
         * There's a tie from the editor's range model to the RulerViewport (via
         * a listener) to the RulerRootEditPart to the RulerViewer. Break this
         * tie so that the viewer doesn't leak and can be garbage collected.
         */
    RangeModel rModel = new DefaultRangeModel();
    Viewport port = ((FigureCanvas) viewer.getControl()).getViewport();
    port.setHorizontalRangeModel(rModel);
    port.setVerticalRangeModel(rModel);
    rulerEditDomain.removeViewer(viewer);
    viewer.getControl().dispose();
}
Also used : FigureCanvas(org.eclipse.draw2d.FigureCanvas) Viewport(org.eclipse.draw2d.Viewport) DefaultRangeModel(org.eclipse.draw2d.DefaultRangeModel) DefaultRangeModel(org.eclipse.draw2d.DefaultRangeModel) RangeModel(org.eclipse.draw2d.RangeModel)

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