Java 类org.eclipse.draw2d.ConnectionLayer 实例源码

项目:seg.jUCMNav    文件:AndForkJoinEditPart.java   
/**
 * Refreshes all outgoing or incoming connections if the super classes's anchors are moved.
 */
public void anchorMoved(ConnectionAnchor anchor) {

    ConnectionLayer cLayer = (ConnectionLayer) getLayer(LayerConstants.CONNECTION_LAYER);

    // jk (later): I'm not sure why we are refreshing all the connections; might want to try to reduce the scope.
    if (cLayer.getConnectionRouter() instanceof UCMConnectionRouter)
        ((UCMConnectionRouter) cLayer.getConnectionRouter()).refreshConnections();

    List toRefresh;
    // and forks have their outputs rearranged; therefore the connection's source are rearranged.
    if (getModel() instanceof AndFork)
        toRefresh = getModelSourceConnections();
    else
        toRefresh = getModelTargetConnections();

    // when one anchor is moved, we must inform the others as we are using mutually exclusive locations.
    for (Iterator iter = toRefresh.iterator(); iter.hasNext();) {
        NodeConnection element = (NodeConnection) iter.next();
        AndForkJoinConnectionAnchor anch = (getAnchor(element));
        if (anch != anchor)
            anch.ancestorMoved(getFigure());
    }

}
项目:neoscada    文件:GenericLevelPresets.java   
@Override
protected IFigure createMain ()
{
    final Figure baseFigure = new LayeredPane ();

    final Layer rootFigure = new Layer ();

    this.connLayer = new ConnectionLayer ();
    this.connLayer.setAntialias ( 1 );
    this.connLayer.setConnectionRouter ( ConnectionRouter.NULL );

    baseFigure.add ( this.connLayer );
    baseFigure.add ( rootFigure );

    rootFigure.setLayoutManager ( new BorderLayout () );
    rootFigure.setBackgroundColor ( ColorConstants.white );

    rootFigure.add ( createArrowFigure (), BorderLayout.RIGHT );
    rootFigure.add ( createEntryGrid ( this.connLayer ), BorderLayout.CENTER );

    return baseFigure;
}
项目:statecharts    文件:TreeLayoutUtil.java   
private static int getDeepestTreeLevel(ConnectionLayer connectionLayer,
        IFigure figure) {
    final List<Connection> connectionList = getOutgoingConnections(
            connectionLayer, figure);
    if (connectionList.size() > 0) {
        final int[] ret = new int[connectionList.size()];
        for (int i = 0; i < connectionList.size(); i++) {
            ret[i] = 1 + getDeepestTreeLevel(connectionLayer,
                    connectionList.get(i).getTargetAnchor().getOwner());
        }
        int maxLevel = ret[0];
        if (ret.length > 1) {
            for (int i = 1; i < ret.length; i++) {
                if (ret[i] > maxLevel) {
                    maxLevel = ret[i];
                }
            }
        }
        return maxLevel;
    }
    return 0;
}
项目:statecharts    文件:TreeLayoutUtil.java   
/**
 * Returns incoming connection figures of the figure parameter.
 * 
 * @param connectionLayer
 * @param figure
 * @return
 */
public static List<Connection> getIncomingConnections(
        ConnectionLayer connectionLayer, IFigure figure) {

    final List<Connection> incomingConnectionList = new ArrayList<Connection>();

    for (final Object object : connectionLayer.getChildren()) {
        if (object instanceof Connection) {
            final Connection connection = (Connection) object;
            if (connection.getTargetAnchor().getOwner() == figure) {
                incomingConnectionList.add(connection);
            }
        }
    }
    return incomingConnectionList;
}
项目:statecharts    文件:TreeLayoutUtil.java   
/**
 * Returns outgoing connection figures of the figure parameter.
 * 
 * @param connectionLayer
 * @param figure
 * @return
 */
public static List<Connection> getOutgoingConnections(
        ConnectionLayer connectionLayer, IFigure figure) {

    final List<Connection> outgoingConnectionList = new ArrayList<Connection>();

    for (final Object object : connectionLayer.getChildren()) {
        if (object instanceof Connection) {
            final Connection connection = (Connection) object;
            if (connection.getSourceAnchor().getOwner() == figure) {
                outgoingConnectionList.add(connection);
            }
        }
    }
    return outgoingConnectionList;
}
项目:gw4e.project    文件:GraphPart.java   
public void activate() {
    super.activate();
    ScalableRootEditPart root = (ScalableRootEditPart) getViewer().getRootEditPart();
    ConnectionLayer connLayer = (ConnectionLayer) root.getLayer(LayerConstants.CONNECTION_LAYER);
    GraphicalEditPart contentEditPart = (GraphicalEditPart) root.getContents();
    FanRouter router = new FanRouter();
    router.setSeparation(100);
    ShortestPathConnectionRouter spRouter = new ShortestPathConnectionRouter(contentEditPart.getFigure());
    router.setNextRouter(spRouter);
    connLayer.setConnectionRouter(router);
    GraphSelectionManager.ME.selectionPartChanged(this);
}
项目:Hydrograph    文件:ContainerEditPart.java   
@Override
protected IFigure createFigure() {
    Figure f = new FreeformLayer();
    f.setBorder(new MarginBorder(3));
    f.setLayoutManager(new FreeformLayout());

    // Create the static router for the connection layer
    ConnectionLayer connLayer = (ConnectionLayer) getLayer(LayerConstants.CONNECTION_LAYER);
    connLayer.setConnectionRouter(new ManhattanConnectionRouter());
    return f;
}
项目:Hydrograph    文件:ELTGraphicalEditor.java   
private void prepareZoomContributions(GraphicalViewer viewer) {

        ScalableFreeformRootEditPart root = new ScalableFreeformRootEditPart();

        // set clipping strategy for connection layer
        ConnectionLayer connectionLayer = (ConnectionLayer) root
                .getLayer(LayerConstants.CONNECTION_LAYER);
        connectionLayer
        .setClippingStrategy(new ViewportAwareConnectionLayerClippingStrategy(
                connectionLayer));

        List<String> zoomLevels = new ArrayList<String>(3);
        zoomLevels.add(ZoomManager.FIT_ALL);
        zoomLevels.add(ZoomManager.FIT_WIDTH);
        zoomLevels.add(ZoomManager.FIT_HEIGHT);
        root.getZoomManager().setZoomLevelContributions(zoomLevels);

        IAction zoomIn = new ZoomInAction(root.getZoomManager());
        IAction zoomOut = new ZoomOutAction(root.getZoomManager());
        viewer.setRootEditPart(root);
        getActionRegistry().registerAction(zoomIn);
        getActionRegistry().registerAction(zoomOut);

        //zoom on key strokes: ctrl++ and ctrl--
        IHandlerService service = 
                (IHandlerService)getEditorSite().getService(IHandlerService. class);

        service.activateHandler(zoomIn.getActionDefinitionId(),
                new ActionHandler(zoomIn));

        service.activateHandler(zoomOut.getActionDefinitionId(),
                new ActionHandler(zoomOut));

        // Scroll-wheel Zoom
        getGraphicalViewer().setProperty(
                MouseWheelHandler.KeyGenerator.getKey(SWT.MOD1),
                MouseWheelZoomHandler.SINGLETON);
    }
项目:bdf2    文件:SchemaEditPart.java   
protected void refreshVisuals() {
    super.refreshVisuals();
    ConnectionLayer connectionLayer = (ConnectionLayer) getLayer(LayerConstants.CONNECTION_LAYER);
    connectionLayer.setConnectionRouter(new ShortestPathConnectionRouter(figure));
    if ((getViewer().getControl().getStyle() & SWT.MIRRORED) == 0) {
        connectionLayer.setAntialias(SWT.ON);
    }
    Animation.run(400);
}
项目:NEXCORE-UML-Modeler    文件:ActivityDiagramEditor.java   
/**
 * @see nexcore.tool.uml.ui.core.diagram.editor.AbstractDiagramEditor#initializeGraphicalViewer()
 */
@Override
protected void initializeGraphicalViewer() {
    super.initializeGraphicalViewer();
    GraphicalViewer viewer = getGraphicalViewer();
    // ManhattanConnectionRouter 설정
    if ("true".equals(PreferenceUtil.INSTANCE.getValueOfStringFieldEditor(ManagerConstant.PREFERENCE_ACTIVITYDIAGRAM_CONNECTION_ROUTER_USE))) {
        ScalableFreeformRootEditPart root = (ScalableFreeformRootEditPart) viewer.getRootEditPart();
        ConnectionLayer connLayer = (ConnectionLayer) root.getLayer(LayerConstants.CONNECTION_LAYER);
        connLayer.setConnectionRouter(new ManhattanConnectionRouter());
    }
}
项目:statecharts    文件:TreeLayout.java   
public TreeLayout(int rankSpacing, ConnectionLayer connectionLayer) {
    super();
    this.rankSpacing = rankSpacing;
    this.connectionLayer = connectionLayer;
    isVertical = true;
    isTopLeftAlignment = true;
    leafSpacing = 5;
    maxTreeLevel = 0;
    graphSize = new Dimension();
}
项目:gef-gwt    文件:FreeformGraphicalRootEditPart.java   
/**
 * Creates a layered pane and the layers that should be printed.
 * 
 * @see org.eclipse.gef.print.PrintGraphicalViewerOperation
 * @return a new LayeredPane containing the printable layers
 */
protected LayeredPane createPrintableLayers() {
    FreeformLayeredPane layeredPane = new FreeformLayeredPane();
    layeredPane.add(new FreeformLayer(), PRIMARY_LAYER);
    layeredPane.add(new ConnectionLayer(), CONNECTION_LAYER);
    return layeredPane;
}
项目:seg.jUCMNav    文件:UCMMapEditPart.java   
/**
 * 
 * Setup the connection router
 * 
 * @see org.eclipse.gef.editparts.AbstractEditPart#registerVisuals()
 */
protected void registerVisuals() {
    ConnectionLayer cLayer = (ConnectionLayer) getLayer(LayerConstants.CONNECTION_LAYER);
    cLayer.setConnectionRouter(new UCMConnectionRouter(getViewer().getEditPartRegistry(), (UCMmap) getDiagram()));

    super.registerVisuals();
}
项目:seg.jUCMNav    文件:UCMMapEditPart.java   
public void disconnectRouter() {
    ConnectionLayer cLayer = (ConnectionLayer) getLayer(LayerConstants.CONNECTION_LAYER);
    if (cLayer != null) {
        if (cLayer.getConnectionRouter() instanceof UCMConnectionRouter) {
            UCMConnectionRouter router = (UCMConnectionRouter) cLayer.getConnectionRouter();
            router.dispose();

        }
        cLayer.setConnectionRouter(null);
    }
}
项目:seg.jUCMNav    文件:GrlGraphEditPart.java   
/**
 * (non-Javadoc)
 * 
 * @see org.eclipse.gef.editparts.AbstractEditPart#registerVisuals()
 */
protected void registerVisuals() {
    ConnectionLayer cLayer = (ConnectionLayer) getLayer(LayerConstants.CONNECTION_LAYER);
    cLayer.setConnectionRouter(new BendpointConnectionRouter());

    super.registerVisuals();
}
项目:seg.jUCMNav    文件:GrlConnectionOnBottomRootEditPart.java   
/**
 * Overwrite this function and add the connection layer before the primary layer. This will make the nodes display on top of the connections.
 */
protected LayeredPane createPrintableLayers() {
    FreeformLayeredPane layeredPane = new FreeformLayeredPane();

    FreeformLayer comp = new FreeformLayer();
    comp.setLayoutManager(new FreeformLayout());

    layeredPane.add(comp, COMPONENT_LAYER);

    layeredPane.add(new FreeformLayer(), PRIMARY_LAYER);
    layeredPane.add(new ConnectionLayer(), CONNECTION_LAYER);
    return layeredPane;

}
项目:seg.jUCMNav    文件:URNRootEditPart.java   
public void setScenarioView(boolean view) {
    scenarioView = view;
    for (Iterator iter = getChildren().iterator(); iter.hasNext();) {
        URNDiagramEditPart element = (URNDiagramEditPart) iter.next();
        if (element instanceof UCMMapEditPart) {
            UCMMapEditPart map = (UCMMapEditPart) element;
            element.refreshVisuals();

            ConnectionLayer cLayer = (ConnectionLayer) getLayer(LayerConstants.CONNECTION_LAYER);

            if (cLayer.getConnectionRouter() instanceof UCMConnectionRouter) {
                ((UCMConnectionRouter) cLayer.getConnectionRouter()).refreshConnections();

                PathNodeEditPart child = null;

                for (Iterator iterator = map.getChildren().iterator(); iterator.hasNext();) {
                    EditPart part = (EditPart) iterator.next();

                    if (part instanceof PathNodeEditPart) {
                        child = (PathNodeEditPart) part;
                        break;
                    }
                }

                // using a method already in the code to refresh all node connections.
                if (child != null) {
                    for (Iterator iterator = ((UCMmap) map.getModel()).getConnections().iterator(); iterator.hasNext();) {
                        NodeConnection nc = (NodeConnection) iterator.next();
                        child.refreshNodeConnection(nc);
                    }
                }
            }
        }
    }

}
项目:seg.jUCMNav    文件:UCMConnectionOnBottomRootEditPart.java   
/**
 * Overwrite this function and add the connection layer before the primary layer. This will make the nodes display on top of the connections.
 */
protected LayeredPane createPrintableLayers() {
    FreeformLayeredPane layeredPane = new FreeformLayeredPane();

    FreeformLayer comp = new FreeformLayer();
    comp.setLayoutManager(new FreeformLayout());

    layeredPane.add(comp, COMPONENT_LAYER);
    layeredPane.add(new ConnectionLayer(), CONNECTION_LAYER);
    layeredPane.add(new FreeformLayer(), PRIMARY_LAYER);
    return layeredPane;
}
项目:relations    文件:RelationsRootEditPart.java   
@Override
protected LayeredPane createPrintableLayers() {
    final FreeformLayeredPane layeredPane = new FreeformLayeredPane();
    layeredPane.add(new ConnectionLayer(), CONNECTION_LAYER);
    layeredPane.add(new FreeformLayer(), PRIMARY_LAYER);
    return layeredPane;
}
项目:lunifera-sharky-m2m    文件:DiagramEditPart.java   
protected IFigure createFigure() {
    Figure f = new FreeformLayer();
    f.setBorder(new MarginBorder(3));
    f.setLayoutManager(new FreeformLayout());

    // Create the static router for the connection layer
    ConnectionLayer connLayer = (ConnectionLayer) getLayer(LayerConstants.CONNECTION_LAYER);
    connLayer.setConnectionRouter(new ShortestPathConnectionRouter(f));

    return f;
}
项目:lunifera-sharky-m2m    文件:DiagramEditPart.java   
protected IFigure createFigure() {
    Figure f = new FreeformLayer();
    f.setBorder(new MarginBorder(3));
    f.setLayoutManager(new FreeformLayout());

    // Create the static router for the connection layer
    ConnectionLayer connLayer = (ConnectionLayer) getLayer(LayerConstants.CONNECTION_LAYER);
    connLayer.setConnectionRouter(new ShortestPathConnectionRouter(f));

    return f;
}
项目:neoscada    文件:ManualOverride.java   
@Override
public IFigure createMain ()
{
    final LayeredPane root = new LayeredPane ();

    final Layer figureLayer = new Layer ();
    figureLayer.setLayoutManager ( new FlowLayout () );

    final ConnectionLayer connectionLayer = new ConnectionLayer ();
    connectionLayer.setAntialias ( SWT.ON );

    final Figure figure = new Figure ();
    figureLayer.add ( figure );

    final GridLayout gridLayout = new GridLayout ( 3, true );
    gridLayout.horizontalSpacing = 50;
    gridLayout.verticalSpacing = 50;
    figure.setLayoutManager ( gridLayout );

    final Figure rpvFigure = createRPV ();
    final Figure pvFigure = createPV ();
    final Figure rmvFigure = createRMV ();
    final Figure mvFigure = createMV ();
    final Figure rvFigure = createRV ();

    figure.add ( rpvFigure, new GridData ( GridData.CENTER, GridData.CENTER, true, true, 1, 1 ) );
    figure.add ( pvFigure, new GridData ( GridData.CENTER, GridData.CENTER, true, true, 1, 2 ) );
    figure.add ( rvFigure, new GridData ( GridData.CENTER, GridData.CENTER, true, true, 1, 3 ) );

    figure.add ( rmvFigure, new GridData ( GridData.CENTER, GridData.CENTER, true, true, 1, 1 ) );

    figure.add ( mvFigure, new GridData ( GridData.CENTER, GridData.CENTER, true, true, 1, 1 ) );
    figure.add ( new Figure (), new GridData ( GridData.CENTER, GridData.CENTER, true, true, 1, 1 ) ); // placeholder

    connectionLayer.add ( this.p2rConnection = createConnection ( this.pvRect, this.rvRect ) );
    connectionLayer.add ( this.m2rConnection = createConnection ( this.mvRect, this.rvRect ) );

    connectionLayer.add ( this.rp2pConnection = createConnection ( this.rpvRect, this.pvRect ) );
    connectionLayer.add ( this.rm2pConnection = createConnection ( this.rmvRect, this.pvRect ) );

    root.add ( figureLayer );
    root.add ( connectionLayer );

    return root;
}
项目:statecharts    文件:TreeLayoutUtil.java   
/**
 * Returns only elements parent figure is a direct parent. Indirect
 * connections are filtered out. Use if children can have many parents.
 * 
 * @param connectionLayer
 * @param parentFigure
 * @return
 */
public static List<Connection> getTreeFigureIncomingConnections(
        ConnectionLayer connectionLayer, IFigure parentFigure) {

    final List<Connection> connectionList = getIncomingConnections(
            connectionLayer, parentFigure);
    final List<Connection> indirectChildren = new ArrayList<Connection>();

    final int parentFigureTreeLevel = getDeepestTreeLevel(connectionLayer,
            parentFigure);
    for (final Connection connection : connectionList) {
        final IFigure childFigure = connection.getSourceAnchor().getOwner();

        final int childTreeLevel = getDeepestTreeLevel(connectionLayer,
                childFigure);

        if (childTreeLevel == parentFigureTreeLevel + 1) {

            //get LayoutConstraint of child Figure;
            Object object = parentFigure.getParent().getLayoutManager()
                    .getConstraint(childFigure);
            if (object instanceof TreeLayoutConstraint) {
                TreeLayoutConstraint childConstraint = (TreeLayoutConstraint) object;

                final IFigure constrainedParentFig = childConstraint
                        .getTreeParentFigure();

                if (constrainedParentFig == null) {
                    childConstraint.setTreeParentFigure(parentFigure);
                } else if (constrainedParentFig != parentFigure) {
                        indirectChildren.add(connection);
                }
            }
        } 
        else {
            indirectChildren.add(connection);
        }
    }
    connectionList.removeAll(indirectChildren);
    return connectionList;
}
项目:gef-gwt    文件:GraphicalNodeEditPolicy.java   
/**
 * Returns the ConnectionRouter for the creation feedback's connection.
 * 
 * @param request
 *            the create request
 * @return a connection router
 * @since 3.2
 */
protected ConnectionRouter getDummyConnectionRouter(
        CreateConnectionRequest request) {
    return ((ConnectionLayer) getLayer(LayerConstants.CONNECTION_LAYER))
            .getConnectionRouter();
}