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

项目:gw4e.project    文件:EdgePart.java   
@Override
protected void refreshVisuals() {
    EdgeFigure figure = (EdgeFigure) getFigure();
    GWEdge model = (GWEdge) getModel();
    figure.setName(model.getName());

    Connection connection = getConnectionFigure();

    List<AbsoluteBendpoint> figureConstraint = new ArrayList<AbsoluteBendpoint>();
    Iterator<Point> iter = ((GWLink) getModel()).getBendpointsIterator(); 
    while(iter.hasNext()) {
        Point p = iter.next();
        figureConstraint.add(new AbsoluteBendpoint(p));
    }
    connection.setRoutingConstraint(figureConstraint);

    figure.setTooltipText(this.getTooltipData());
    figure.setBlockedOrGuarded(model.isBlocked(),model.getGuard().getSource());
    figure.setActionScripted(model.getAction().getSource()); 
}
项目: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;
}
项目:FRaMED    文件:ORMRelationBendpointEditPolicy.java   
/**
 * This method creats and returns a command for changing the position of a {@link Bendpoint}.
 * 
 * @return {@link ORMRelationMoveBendpointCommand}
 */
@Override
protected Command getMoveBendpointCommand(final BendpointRequest request) {
  final ORMRelationMoveBendpointCommand command = new ORMRelationMoveBendpointCommand();

  Point p = request.getLocation();
  Connection conn = getConnection();

  conn.translateToRelative(p);
  Point sourceP = conn.getSourceAnchor().getReferencePoint();
  Point targetP = conn.getTargetAnchor().getReferencePoint();

  conn.translateToRelative(sourceP);
  conn.translateToRelative(targetP);

  command.setRelation((Relation) request.getSource().getModel());
  command.setNewDimension(p.getDifference(sourceP), p.getDifference(targetP));
  command.setIndex(request.getIndex());

  return command;
}
项目:wt-studio    文件:ConnectionBendPointEditPolicy.java   
protected Command getCreateBendpointCommand(BendpointRequest request) {
    CreateBendpointCommand cmd = new CreateBendpointCommand();
    Point p = request.getLocation();
    Connection conn = (Connection) getConnection();

     conn.translateToRelative(p);

    Point ref1 = getConnection().getSourceAnchor().getReferencePoint();
    Point ref2 = getConnection().getTargetAnchor().getReferencePoint();

     conn.translateToRelative(ref1);
     conn.translateToRelative(ref2);

    cmd.setRelativeDimensions(p.getDifference(ref1), p.getDifference(ref2));
    cmd.setConnection((com.wt.studio.plugin.modeldesigner.editor.model.NodeConnection) request.getSource()
            .getModel());
    cmd.setIndex(request.getIndex());
    return cmd;
}
项目:wt-studio    文件:ConnectionBendPointEditPolicy.java   
protected Command getMoveBendpointCommand(BendpointRequest request) {
    MoveBendpointCommand cmd = new MoveBendpointCommand();
    Point p = request.getLocation();
    Connection conn = getConnection();

    conn.translateToRelative(p);

    Point ref1 = getConnection().getSourceAnchor().getReferencePoint();
    Point ref2 = getConnection().getTargetAnchor().getReferencePoint();

    conn.translateToRelative(ref1);
    conn.translateToRelative(ref2);

    cmd.setRelativeDimensions(p.getDifference(ref1), p.getDifference(ref2));
    cmd.setConnection((com.wt.studio.plugin.modeldesigner.editor.model.NodeConnection) request.getSource()
            .getModel());
    cmd.setIndex(request.getIndex());
    return cmd;
}
项目:wt-studio    文件:ConnectionBendPointEditPolicy.java   
protected Command getCreateBendpointCommand(BendpointRequest request) {
    CreateBendpointCommand cmd = new CreateBendpointCommand();
    Point p = request.getLocation();
    Connection conn = (Connection) getConnection();

     conn.translateToRelative(p);

    Point ref1 = getConnection().getSourceAnchor().getReferencePoint();
    Point ref2 = getConnection().getTargetAnchor().getReferencePoint();

     conn.translateToRelative(ref1);
     conn.translateToRelative(ref2);

    cmd.setRelativeDimensions(p.getDifference(ref1), p.getDifference(ref2));
    cmd.setConnection((ColumnConnection)request.getSource()
            .getModel());
    cmd.setIndex(request.getIndex());
    return cmd;
}
项目:wt-studio    文件:ConnectionBendPointEditPolicy.java   
protected Command getMoveBendpointCommand(BendpointRequest request) {
    MoveBendpointCommand cmd = new MoveBendpointCommand();
    Point p = request.getLocation();
    Connection conn = getConnection();

    conn.translateToRelative(p);

    Point ref1 = getConnection().getSourceAnchor().getReferencePoint();
    Point ref2 = getConnection().getTargetAnchor().getReferencePoint();

    conn.translateToRelative(ref1);
    conn.translateToRelative(ref2);

    cmd.setRelativeDimensions(p.getDifference(ref1), p.getDifference(ref2));
    cmd.setConnection((ColumnConnection) request.getSource()
            .getModel());
    cmd.setIndex(request.getIndex());
    return cmd;
}
项目:neoscada    文件:GenericLevelPresets.java   
private void createConnection ( final Figure connLayer, final Label label, final Figure figure )
{
    final Connection c = new PolylineConnection ();
    c.setSourceAnchor ( new ChopboxAnchor ( label ) );
    c.setTargetAnchor ( new ChopboxAnchor ( figure ) );
    c.setConnectionRouter ( new BendpointConnectionRouter () );
    connLayer.add ( c );
}
项目:Open_Source_ECOA_Toolset_AS5    文件:LinkEditPart.java   
@Override
protected void refreshVisuals() {
    Connection connection = getConnectionFigure();
    List<Point> modelConstraint = ((Link) getModel()).getbPoints();
    List<AbsoluteBendpoint> figureConstraint = new ArrayList<AbsoluteBendpoint>();
    for (Point p : modelConstraint) {
        figureConstraint.add(new AbsoluteBendpoint(p));
    }
    connection.setRoutingConstraint(figureConstraint);
}
项目:gw4e.project    文件:Graph.java   
public SWTBotGefConnectionEditPart addEdge(String name, SWTBotGefEditPart fromPart, SWTBotGefEditPart toPart) {
    editor.activateTool(GW4EGraphicalEditorPalette.TOOL_EDGE_LABEL);
    editor.click(fromPart);
    syncWithUIThread();
    editor.click(toPart);
    syncWithUIThread();
    SWTBotGefConnectionEditPart edgePart = fromPart.sourceConnections().get(0);
    GWLink edge = (GWLink) (edgePart.part()).getModel();
    Connection edgeFigure = (Connection) edgePart.part().getFigure();
    edgePart.activateDirectEdit();
    editor.directEditType(name);
    assertEdge(name);
    return edgePart;
}
项目:Hydrograph    文件:LinkEditPart.java   
/**
 * Clear record count from job canvas after rerun or refresh.
 */
public void clearRecordCountAtPort(){
    List<Figure> labels = new ArrayList<>(); 
    Connection connection = (Connection) getFigure();
    for(Object figure:connection.getChildren()){
        if(figure instanceof Label){
            labels.add((Figure) figure);
        }
    }
    for (Figure label : labels) {
        connection.remove(label);
    }
}
项目:statecharts    文件:FeedbackGraphicalNodeEditPolicy.java   
@Override
protected Connection createDummyConnection(Request req) {
    if (req instanceof CreateUnspecifiedTypeConnectionRequest) {
        if (((CreateUnspecifiedTypeConnectionRequest) req).isDirectionReversed()) {
            return new TransitionFigure(getMapMode(), true);
        }
    }
    return new TransitionFigure(getMapMode());
}
项目:statecharts    文件:TreeLayout.java   
protected List<List<TreeNode>> getTreeLevels(List<TreeNode> treeNodeList,
        int level) {
    final List<List<TreeNode>> levelElements = new ArrayList<List<TreeNode>>();
    final List<TreeNode> nextRankElements = new ArrayList<TreeNode>();
    levelElements.add(new ArrayList<TreeNode>());
    levelElements.get(0).addAll(treeNodeList);

    for (final TreeNode treeNode : treeNodeList) {
        // Set level of the treeNode
        treeNode.level = level;

        if (treeNode.children.isEmpty()) {

            // calculate child GraphNodes in next Rank
            final List<Connection> connectionList = TreeLayoutUtil
                    .getTreeFigureIncomingConnections(connectionLayer,
                            treeNode.getFigure());

            for (int i = 0; i < connectionList.size(); i++) {
                final Connection connection = connectionList.get(i);
                if (connection.getSourceAnchor().getOwner() != null) {
                    final IFigure childFig = connection.getSourceAnchor()
                            .getOwner();
                    final TreeNode childTreeNode = new TreeNode(treeNode,
                            childFig);
                    treeNode.children.add(childTreeNode);
                }
            }
        }

        treeNode.children = sortTreeNodeList(treeNode.children);
        nextRankElements.addAll(treeNode.children);
    }
    // add ranks for childTreeNodeList
    if (!nextRankElements.isEmpty()) {
        levelElements.addAll(getTreeLevels(nextRankElements, ++level));
    }
    return levelElements;
}
项目:gef-gwt    文件:AbstractConnectionEditPart.java   
/**
 * @see AccessibleAnchorProvider#getSourceAnchorLocations()
 */
public List getSourceAnchorLocations() {
    List list = new ArrayList();
    if (getFigure() instanceof Connection) {
        Point p = ((Connection) getFigure()).getPoints().getMidpoint();
        getFigure().translateToAbsolute(p);
        list.add(p);
    }
    return list;
}
项目:antlr4ide    文件:RailroadConnectionRouter.java   
@Override
public void route(final Connection connection) {
  PointList points = connection.getPoints();
  points.removeAllPoints();
  Point startPoint = getStartPoint(connection);
  connection.translateToRelative(startPoint);
  points.addPoint(startPoint);
  Point endPoint = getEndPoint(connection);
  connection.translateToRelative(endPoint);
  Object constraint = getConstraint(connection);
  if (constraint instanceof BendConstraint) {
    int dx = Integer.signum(endPoint.x - startPoint.x) * ILayoutConstants.connectionRadius();
    int dy = Integer.signum(endPoint.y - startPoint.y) * ILayoutConstants.connectionRadius();
    // can be simplified but becomes unreadable
    if (((BendConstraint) constraint).isConvex()) {
      if (((BendConstraint) constraint).isStart()) {
        points.addPoint(startPoint.x - dx, startPoint.y + dy);
        points.addPoint(startPoint.x - dx, endPoint.y - dy);
        points.addPoint(startPoint.x , endPoint.y);
      } else {
        points.addPoint(endPoint.x, startPoint.y);
        points.addPoint(endPoint.x + dx, startPoint.y + dy);
        points.addPoint(endPoint.x + dx, endPoint.y - dy);
      }
    } else {
      if (((BendConstraint) constraint).isStart()) {
        points.addPoint(startPoint.x + dx, startPoint.y + dy);
        points.addPoint(startPoint.x + dx, endPoint.y - dy);
        points.addPoint(startPoint.x + 2 * dx, endPoint.y);
      } else {
        points.addPoint(endPoint.x - 2 * dx, startPoint.y);
        points.addPoint(endPoint.x - dx, startPoint.y + dy);
        points.addPoint(endPoint.x - dx, endPoint.y - dy);
      }
    }
  }
  points.addPoint(endPoint);
  connection.setPoints(points);
}
项目:FRaMED    文件:ORMRelationBendpointEditPolicy.java   
/**
 * This method creats and returns a command for the creation of a {@link Bendpoint}.
 * 
 * @return {@link ORMRelationCreateBendpointCommand}
 */
@Override
protected Command getCreateBendpointCommand(final BendpointRequest request) {
  final ORMRelationCreateBendpointCommand command = new ORMRelationCreateBendpointCommand();

  Point p = request.getLocation();
  Connection conn = getConnection();

  conn.translateToRelative(p);
  Point sourceP = conn.getSourceAnchor().getReferencePoint();
  Point targetP = conn.getTargetAnchor().getReferencePoint();

  conn.translateToRelative(sourceP);
  conn.translateToRelative(targetP);


  command.setRelation((Relation) request.getSource().getModel());
  command.setDimension(p.getDifference(sourceP), p.getDifference(targetP));
  command.setIndex(request.getIndex());

  org.framed.orm.geometry.Point sourceRef = GeometryFactory.eINSTANCE.createPoint();
  sourceRef.setX(sourceP.x());
  sourceRef.setY(sourceP.y());
  command.setSourceRefence(sourceRef);
  org.framed.orm.geometry.Point targetRef = GeometryFactory.eINSTANCE.createPoint();
  sourceRef.setX(targetP.x());
  sourceRef.setY(targetP.y());
  command.setTargetRefence(targetRef);

  return command;
}
项目:FRaMED    文件:ORMRelationEditPart.java   
/**
 * {@inheritDoc} The refreshVisuals of this {@link EditPart} updates/adds the {@link Bendpoint}s
 * of a {@link Relation}. The content of this method should only be called when the
 * compartmenttype/group/rootmodel where this {@link Relation}s parentrolemodel(for the cases
 * compartmenttype/group) belongs to is the current opened(content of the viewer)
 * compartmenttype/group/rootmodel. The test of getSource() != null and getTarget() != null is
 * needed, because it exist cases where this method is called and getSource() or getTarget()
 * returns null.
 * 
 */
@Override
protected void refreshVisuals() {

  if ((getSource() != null && getTarget() != null)
      && (testRootModel() || testGroup()
          && getSource().getParent().getParent().getParent() instanceof ScalableRootEditPart || getRoot()
          .getContents() instanceof ORMCompartmentEditPart)) {

    Connection connection = getConnectionFigure();
    connection.setVisible(true);
    List<RelativePoint> relativePoints = ((Relation) getModel()).getBendpoints();

    // the bendpoints are added as RelativeBendpoint, because the position of the bendpoints
    // must change when the position of the source or target of the relation changes or the the
    // figure of the content of the viewer has expandable and collapsable elements
    ArrayList<RelativeBendpoint> figureConstraint = new ArrayList<RelativeBendpoint>();

    for (int i = 0; i < relativePoints.size(); i++) {
      RelativeBendpoint rbp = new RelativeBendpoint(getConnectionFigure());
      // p.x = width p.y = height
      Point pSource = relativePoints.get(i).getDistances().get(0);
      Point pTarget = relativePoints.get(i).getDistances().get(1);
      Dimension dim1 = new Dimension(pSource.getX(), pSource.getY());
      Dimension dim2 = new Dimension(pTarget.getX(), pTarget.getY());
      rbp.setRelativeDimensions(dim1, dim2);

      figureConstraint.add(rbp);
    }

    connection.setRoutingConstraint(figureConstraint);
  } else {
    getConnectionFigure().setVisible(false);
  }
}
项目:jive    文件:TerminatorMessageEditPart.java   
private void addTargetLabel(final Connection connection)
{
  final SequenceDiagramEditPart contents = (SequenceDiagramEditPart) getRoot().getContents();
  final TerminatorMessage message = (TerminatorMessage) getModel();
  if (contents.isCollapsed(message.target()))
  {
    final Label label = new Label("+");
    label.setForegroundColor(ColorConstants.gray);
    final ConnectionEndpointLocator endpointLocator = new ConnectionEndpointLocator(connection,
        true);
    endpointLocator.setUDistance(5);
    endpointLocator.setVDistance(-4);
    connection.add(label, endpointLocator);
  }
}
项目:xeda    文件:CommonStyleRouter.java   
@Override
public void route(Connection conn) {
    PointList pl = conn.getPoints();
    pl.removeAllPoints();
    Point start = getStartPoint(conn);
    conn.translateToRelative(start);
    Point end = getEndPoint(conn);
    conn.translateToRelative(end);

    if (style == RouteStyle.direct) {
        pl.addPoint(start);
        pl.addPoint(end);
        return;
    }

    Point middle;
    pl.addPoint(start);
    if (style == RouteStyle.heightFirst) {
        middle = new Point(start.x, end.y);
        pl.addPoint(middle);
        if(middle.x == end.x)
            return;
    } else {
        middle = new Point(end.x, start.y);
        pl.addPoint(middle);
        if(middle.y == end.y)
            return;
    }

    pl.addPoint(end);
}
项目:seg.jUCMNav    文件:ConnectionLabelEditPart.java   
@Override
public void activate() {
    LinkRefEditPart nc = (LinkRefEditPart) getViewer().getEditPartRegistry().get(getConnection());

    routingListener = new RoutingListener.Stub(){
        public void postRoute(Connection connection) {
            refreshVisuals();
        }
    };

    if (nc!=null)
        ((LinkRefConnection)nc.getConnectionFigure()).addRoutingListener(routingListener);
    super.activate();
}
项目:seg.jUCMNav    文件:UCMConnectionRouter.java   
/**
 * If the passed SplineConnection is dirty (as defined by the connections HashMap), redraw it.
 * 
 * Otherwise, redraw is not required.
 * 
 * @see org.eclipse.draw2d.ConnectionRouter#route(org.eclipse.draw2d.Connection)
 */
public void route(Connection connection) {
    SplineConnection spline = (SplineConnection) connection;

    if (connections == null || spline.getLink() == null || connections.get(spline.getLink()) == null) {
        // Gunter once observed a NPE in the next if so we try to catch it before it causes a problem.
        // We don't know why he obtained an error; might be something else that caused it.
        return;
    }
    if (connections.get(spline.getLink()).equals(Boolean.FALSE)) {
        isDuringRoute=true;
        drawSpline(spline);
        isDuringRoute=false;
    }
}
项目:olca-app    文件:TreeConnectionRouter.java   
@Override
public void route(Connection conn) {
    super.route(conn);
    if (conn.getSourceAnchor().getOwner() == null || conn.getTargetAnchor().getOwner() == null)
        return;
    PointList points = new PointList();
    points.addPoint(conn.getPoints().getFirstPoint());
    ProcessFigure source = getProcessFigure(conn.getSourceAnchor());
    ProcessFigure target = getProcessFigure(conn.getTargetAnchor());
    Point sourceLoc = source.getLocation();
    Point targetLoc = target.getLocation();
    Point firstPoint = conn.getPoints().getFirstPoint();
    Point lastPoint = conn.getPoints().getLastPoint();
    if (targetLoc.x < sourceLoc.x + source.getSize().width
            || targetLoc.x > sourceLoc.x + source.getSize().width + LayoutManager.H_SPACE + target.getSize().width
            || target == source) {
        points.addPoint(firstPoint.getTranslated(LayoutManager.H_SPACE / 2, 0));
        int y1 = sourceLoc.y < targetLoc.y ? targetLoc.y : sourceLoc.y;
        y1 -= LayoutManager.V_SPACE / 2;
        points.addPoint(firstPoint.getTranslated(LayoutManager.H_SPACE / 2, 0).x, y1);
        points.addPoint(lastPoint.getTranslated(-LayoutManager.H_SPACE / 2, 0).x, y1);
        points.addPoint(lastPoint.getTranslated(-LayoutManager.H_SPACE / 2, 0));
    } else {
        points.addPoint(firstPoint.getTranslated(LayoutManager.H_SPACE / 2, 0));
        points.addPoint(firstPoint.getTranslated(LayoutManager.H_SPACE / 2, 0).x, lastPoint.y);
    }
    points.addPoint(lastPoint);
    conn.setPoints(points);
}
项目:olca-app    文件:ProcessLinkCreatePolicy.java   
@Override
protected Connection createDummyConnection(Request req) {
    PolylineConnection con = (PolylineConnection) super.createDummyConnection(req);
    con.setForegroundColor(Link.COLOR);
    if (!(req instanceof CreateConnectionRequest)) {
        con.setTargetDecoration(new PolygonDecoration());
        return con;
    }
    CreateLinkCommand cmd = (CreateLinkCommand) ((CreateConnectionRequest) req).getStartCommand();
    if (cmd.output != null)
        con.setTargetDecoration(new PolygonDecoration());
    else if (cmd.input != null)
        con.setSourceDecoration(new PolygonDecoration());
    return con;
}
项目:olca-app    文件:Animation.java   
static boolean playbackState(Connection conn) {
    if (!PLAYBACK) {
        return false;
    }

    PointList list1 = (PointList) initialStates.get(conn);
    PointList list2 = (PointList) finalStates.get(conn);
    if (list1 == null) {
        conn.setVisible(false);
        return true;
    }
    if (list1.size() == list2.size()) {
        Point pt1 = new Point(), pt2 = new Point();
        PointList points = conn.getPoints();
        points.removeAllPoints();
        for (int i = 0; i < list1.size(); i++) {
            list1.getPoint(pt2, i);
            list2.getPoint(pt1, i);
            pt1.x = (int) Math.round(pt1.x * progress + (1 - progress)
                    * pt2.x);
            pt1.y = (int) Math.round(pt1.y * progress + (1 - progress)
                    * pt2.y);
            points.addPoint(pt1);
        }
        conn.setPoints(points);
    }
    return true;
}
项目:olca-app    文件:Animation.java   
static void recordFinalState(IFigure child) {
    if (child instanceof Connection) {
        recordFinalState((Connection) child);
        return;
    }
    Rectangle rect2 = child.getBounds().getCopy();
    Rectangle rect1 = (Rectangle) initialStates.get(child);
    if (rect1.isEmpty()) {
        rect1.x = rect2.x;
        rect1.y = rect2.y;
        rect1.width = rect2.width;
    }
    finalStates.put(child, rect2);
}
项目:olca-app    文件:Animation.java   
public static void recordInitialState(Connection connection) {
    if (!RECORDING) {
        return;
    }
    PointList points = connection.getPoints().getCopy();
    if (points.size() == 2
            && points.getPoint(0).equals(Point.SINGLETON.setLocation(0, 0))
            && points.getPoint(1).equals(
                    Point.SINGLETON.setLocation(100, 100))) {
        initialStates.put(connection, null);
    } else {
        initialStates.put(connection, points);
    }
}
项目:olca-app    文件:TreeConnectionRouter.java   
@Override
public void route(Connection conn) {
    // pre route
    NULL.route(conn);

    // get points
    PointList points = conn.getPoints();
    Point first = points.getFirstPoint();
    Point last = points.getLastPoint();

    // distance from to point to connection anchor
    final int trans = GraphLayoutManager.verticalSpacing / 4;

    // create new list
    PointList newPoints = new PointList();
    // add first point
    newPoints.addPoint(first);

    // add 2 new points
    newPoints.addPoint(first.x, first.y - trans);
    newPoints.addPoint(last.x, last.y + trans);

    // add last point
    newPoints.addPoint(last);
    // set new list
    conn.setPoints(newPoints);
}
项目:olca-app    文件:ConnectionRouterImp.java   
@Override
public void route(Connection conn) {
    NULL.route(conn);
    PointList points = conn.getPoints();
    Point start = points.getFirstPoint();
    Point end = points.getLastPoint();
    points.removeAllPoints();
    points.addPoint(start);
    if (start.y > end.y)
        routeBottomToTop(start, end, points);
    else
        routeTopToBottom(start, end, points);
    points.addPoint(end);
}
项目:pandionj    文件:TestFigure.java   
private static void createDiagram(IFigure root) {
    // Array com iteradores
    MockArray array = new MockArray("Integer", 1,2,3,4,5);
    //      MockVariable var = new MockVariable("int[]", "v", null, array);
    MockReference ref = new MockReference("int[]", "v", array, false);

    MockValue i1 = new MockValue("int", "i1", null, 0, false);
    MockArrayIndex ii1 = new MockArrayIndex(i1, ref, Direction.NONE);
    MockValue i2 = new MockValue("int", "i2", null, 1, false);
    MockArrayIndex ii2 = new MockArrayIndex(i2, ref, Direction.FORWARD);
    MockValue i3 = new MockValue("int", "i3", null, 5, false);
    MockArrayIndex ii3 = new MockArrayIndex(i3, ref, Direction.FORWARD, new MyBound(-1, BoundType.OPEN, "-1"));

    //      array.addIndexVariable(ii1);
    //      array.addIndexVariable(ii2);
    //      array.addIndexVariable(ii3);

    List<IArrayIndexModel> vars = new ArrayList<>();
    vars.add(ii1);
    vars.add(ii2);

    ArrayReferenceFigure fig = new ArrayReferenceFigure(array);
    fig.setLocation(new Point(100, 100));

    root.add(fig);



    //      IllustrationBorder b = new IllustrationBorder(vars, fig);
    //      MarginBorder b = new MarginBorder(15);
    //      fig.setBorder(b);



    // Array com lenght maior que o tamanho maximo da figura
    MockArray array2 = new MockArray("int", 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25);
    ArrayPrimitiveFigure fig2 = new ArrayPrimitiveFigure(array2);
    fig2.setLocation(new Point(250, 300));
    root.add(fig2);

    // Array vazia
    MockArray array3 = new MockArray("int");
    ArrayPrimitiveFigure fig3 = new ArrayPrimitiveFigure(array3);
    fig3.setLocation(new Point(400, 200));
    root.add(fig3);

    Connection c = new PolylineConnection();
    ChopboxAnchor a = new ChopboxAnchor(fig);
    ChopboxAnchor b = new ChopboxAnchor(fig2);
    c.setSourceAnchor(a);
    c.setTargetAnchor(b);

    root.add(c);

    Button but = new Button("test");
    but.setLocation(new Point(5, 5));
    but.setSize(but.getPreferredSize());
    but.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            i1.set(ii1.getCurrentIndex()+1);
            try {
                if(ii3.getBound().getValue() != ii3.getCurrentIndex()) {
                    i3.set(ii3.getCurrentIndex() - 1);
                }
                array.set(ii3.getCurrentIndex(), 9);
            }
            catch(IndexOutOfBoundsException e) {
                e.printStackTrace();
            }
            fig.repaint();
        }
    });
    root.add(but);
}
项目:NEXCORE-UML-Modeler    文件:AbstractDiagramConnectionEditPart.java   
/**
 * @return
 */
private Connection getConnection() {
    return (Connection) this.getConnectionFigure();
}
项目:statecharts    文件:TransitionEditPart.java   
@Override
protected Connection createConnectionFigure() {
    return new TransitionFigure(getMapMode());
}
项目: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    文件:ConnectionHandle.java   
/**
 * Adds this as a {@link org.eclipse.draw2d.FigureListener} to the owner's
 * {@link org.eclipse.draw2d.Figure}.
 */
public void addNotify() {
    super.addNotify();
    getConnection().addPropertyChangeListener(Connection.PROPERTY_POINTS,
            this);
}
项目:gef-gwt    文件:ConnectionHandle.java   
/**
 * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
 */
public void propertyChange(PropertyChangeEvent evt) {
    if (evt.getPropertyName().equals(Connection.PROPERTY_POINTS))
        revalidate();
}
项目:gef-gwt    文件:ConnectionHandle.java   
/**
 * Extended to remove a listener.
 * 
 * @see org.eclipse.draw2d.IFigure#removeNotify()
 */
public void removeNotify() {
    getConnection().removePropertyChangeListener(
            Connection.PROPERTY_POINTS, this);
    super.removeNotify();
}
项目:gef-gwt    文件:ConnectionEndpointEditPolicy.java   
public void addNotify() {
    super.addNotify();
    getConnection().addPropertyChangeListener(
            Connection.PROPERTY_POINTS, this);
    getConnection().addAncestorListener(ancestorListener);
}
项目:gef-gwt    文件:ConnectionEndpointEditPolicy.java   
public void removeNotify() {
    getConnection().removePropertyChangeListener(
            Connection.PROPERTY_POINTS, this);
    getConnection().removeAncestorListener(ancestorListener);
    super.removeNotify();
}
项目:gef-gwt    文件:MarqueeSelectionTool.java   
/**
 * Determines which edit parts are directly affected by the current marquee
 * selection. Calculation is performed by regarding the current marquee
 * selection rectangle ( {@link #getCurrentMarqueeSelectionRectangle()}),
 * taking into consideration the current marquee behavior (contained vs.
 * touched) that was provided ( {@link #setMarqueeBehavior(int)} ).
 * 
 * @param editPart
 *            the {@link EditPart} whose state is to be determined
 * @return <code>true</code> if the {@link EditPart} should be regarded as
 *         being included in the current marquee selection,
 *         <code>false</code> otherwise.
 * @since 3.7
 */
private boolean isPrimaryMarqueeSelectedEditPart(GraphicalEditPart editPart) {
    // figure bounds are used to determine if edit part is included in
    // selection
    IFigure figure = editPart.getFigure();
    Rectangle r = figure.getBounds().getCopy();
    figure.translateToAbsolute(r);

    boolean included = false;
    Rectangle marqueeSelectionRectangle = getCurrentMarqueeSelectionRectangle();
    if (editPart instanceof ConnectionEditPart) {
        if (marqueeBehavior == BEHAVIOR_CONNECTIONS_TOUCHED
                || marqueeBehavior == BEHAVIOR_CONNECTIONS_CONTAINED) {
            if (marqueeSelectionRectangle.intersects(r)) {
                // children will contain ConnectionEditParts only in case
                // behavior is BEHAVIOR_CONNECTIONS_TOUCHED or
                // BEHAVIOR_CONNECTIONS_CONTAINED
                Rectangle relMarqueeRect = Rectangle.SINGLETON;
                figure.translateToRelative(relMarqueeRect
                        .setBounds(marqueeSelectionRectangle));
                if (marqueeBehavior == BEHAVIOR_CONNECTIONS_TOUCHED) {
                    included = ((Connection) figure).getPoints()
                            .intersects(relMarqueeRect);
                } else if (marqueeBehavior == BEHAVIOR_CONNECTIONS_CONTAINED) {
                    included = relMarqueeRect
                            .contains(((Connection) figure).getPoints()
                                    .getBounds());
                }
            }
        }
    } else {
        // otherwise children will only be 'node' edit parts
        if (marqueeBehavior == BEHAVIOR_NODES_TOUCHED
                || marqueeBehavior == BEHAVIOR_NODES_TOUCHED_AND_RELATED_CONNECTIONS) {
            included = marqueeSelectionRectangle.intersects(r);
        } else if (marqueeBehavior == BEHAVIOR_NODES_CONTAINED
                || marqueeBehavior == BEHAVIOR_NODES_CONTAINED_AND_RELATED_CONNECTIONS) {
            included = marqueeSelectionRectangle.contains(r);
        }
    }
    return included;
}