Search in sources :

Example 1 with ExpandGraphLabel

use of org.eclipse.zest.core.widgets.internal.ExpandGraphLabel 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)

Aggregations

FreeformLayout (org.eclipse.draw2d.FreeformLayout)1 FreeformViewport (org.eclipse.draw2d.FreeformViewport)1 IFigure (org.eclipse.draw2d.IFigure)1 LineBorder (org.eclipse.draw2d.LineBorder)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 ZestRootLayer (org.eclipse.zest.core.widgets.internal.ZestRootLayer)1