Search in sources :

Example 1 with ZestRootLayer

use of org.eclipse.zest.core.widgets.internal.ZestRootLayer in project archi by archimatetool.

the class Graph method removeNode.

void removeNode(GraphNode node) {
    IFigure figure = node.getNodeFigure();
    if (figure.getParent() != null) {
        if (figure.getParent() instanceof ZestRootLayer) {
            ((ZestRootLayer) figure.getParent()).removeNode(figure);
        } else {
            figure.getParent().remove(figure);
        }
    }
    this.getNodes().remove(node);
    if (this.getSelection() != null) {
        this.getSelection().remove(node);
    }
    figure2ItemMap.remove(figure);
}
Also used : ZestRootLayer(org.eclipse.zest.core.widgets.internal.ZestRootLayer) IFigure(org.eclipse.draw2d.IFigure)

Example 2 with ZestRootLayer

use of org.eclipse.zest.core.widgets.internal.ZestRootLayer 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 3 with ZestRootLayer

use of org.eclipse.zest.core.widgets.internal.ZestRootLayer in project archi by archimatetool.

the class Graph method createLayers.

private ScalableFigure createLayers() {
    rootlayer = new ScalableFreeformLayeredPane();
    rootlayer.setLayoutManager(new FreeformLayout());
    zestRootLayer = new ZestRootLayer();
    zestRootLayer.setLayoutManager(new FreeformLayout());
    fishEyeLayer = new ScalableFreeformLayeredPane();
    fishEyeLayer.setLayoutManager(new FreeformLayout());
    rootlayer.add(zestRootLayer);
    rootlayer.add(fishEyeLayer);
    zestRootLayer.addLayoutListener(LayoutAnimator.getDefault());
    fishEyeLayer.addLayoutListener(LayoutAnimator.getDefault());
    return rootlayer;
}
Also used : FreeformLayout(org.eclipse.draw2d.FreeformLayout) ScalableFreeformLayeredPane(org.eclipse.draw2d.ScalableFreeformLayeredPane) ZestRootLayer(org.eclipse.zest.core.widgets.internal.ZestRootLayer)

Aggregations

ZestRootLayer (org.eclipse.zest.core.widgets.internal.ZestRootLayer)3 FreeformLayout (org.eclipse.draw2d.FreeformLayout)2 IFigure (org.eclipse.draw2d.IFigure)2 FreeformViewport (org.eclipse.draw2d.FreeformViewport)1 LineBorder (org.eclipse.draw2d.LineBorder)1 ScalableFreeformLayeredPane (org.eclipse.draw2d.ScalableFreeformLayeredPane)1 ScrollPane (org.eclipse.draw2d.ScrollPane)1 Viewport (org.eclipse.draw2d.Viewport)1 Point (org.eclipse.draw2d.geometry.Point)1 AspectRatioFreeformLayer (org.eclipse.zest.core.widgets.internal.AspectRatioFreeformLayer)1 ContainerFigure (org.eclipse.zest.core.widgets.internal.ContainerFigure)1 ExpandGraphLabel (org.eclipse.zest.core.widgets.internal.ExpandGraphLabel)1