Package org.eclipse.draw2d

Examples of org.eclipse.draw2d.Connection


    pos = p;
    positions.get(c).add(this);
  }

  protected Point getReferencePoint() {
    Connection conn = getConnection();
    List<PropertyLocator> listOfProperties = positions.get(conn);
    int maxIndex = listOfProperties.indexOf(this);
    int dec = 5;
    for (int i = 0; i < maxIndex; i++) {
      if (listOfProperties.get(i).pos == this.pos) {
        dec += 10;
      }
    }

    int xdirec = 0;
    int ydirec = 0;
    Point p = Point.SINGLETON;
    Point f = conn.getPoints().getFirstPoint();
    Point l = conn.getPoints().getLastPoint();

    if (l.x > f.x) {
      xdirec = 1;
    } else {
      xdirec = -1;
    }

    if (l.y > f.y) {
      ydirec = 1;
    } else {
      ydirec = -1;
    }
    if (pos.equals(ParameterPosition.West)
        || pos.equals(ParameterPosition.NorthWest)
        || pos.equals(ParameterPosition.SouthWest)) {
      Point refP = conn.getPoints().getFirstPoint().getCopy();
      conn.getParent().translateToAbsolute(refP);
      p.setLocation(refP.x + (dec * xdirec), refP.y + (dec * ydirec));
    } else if (pos.equals(ParameterPosition.East)
        || pos.equals(ParameterPosition.NorthEast)
        || pos.equals(ParameterPosition.SouthEast)) {
      Point refP = conn.getPoints().getLastPoint().getCopy();
      conn.getParent().translateToAbsolute(refP);
      p.setLocation(refP.x - (dec * xdirec), refP.y - (dec * ydirec));
    } else {
      Point refP = conn.getPoints().getMidpoint().getCopy();
      conn.getParent().translateToAbsolute(refP);
      p.setLocation(refP.x - (dec * xdirec), refP.y - (dec * ydirec));
    }

    return p;
  }
View Full Code Here


  protected Command getCreateBendpointCommand(BendpointRequest request)
  {
    CreateBendpointCommand com = new CreateBendpointCommand();
    Point p = request.getLocation();
    Connection conn = getConnection();

    conn.translateToRelative(p);

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

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


    com.setRelativeDimensions(p.getDifference(ref1),
      p.getDifference(ref2));
    com.setWire((EdgeModel) request.getSource().getModel());
View Full Code Here

  protected Command getMoveBendpointCommand(BendpointRequest request)
  {
    MoveBendpointCommand com = new MoveBendpointCommand();
    Point p = request.getLocation();
    Connection conn = getConnection();

    conn.translateToRelative(p);

    com.setLocation(p);

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

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

    com.setRelativeDimensions(p.getDifference(ref1),
      p.getDifference(ref2));
    com.setWire((EdgeModel) request.getSource().getModel());
    com.setIndex(request.getIndex());
View Full Code Here

    public ConnectionWrapper getConnectionWrapper() {
        return (ConnectionWrapper) getModel();
    }

    protected IFigure createFigure() {
        Connection result = (Connection) super.createFigure();
        // add connection label
        String label = (String) getConnectionWrapper().getConnection().getMetaData("label");
        if (label != null) {
            ConnectionEndpointLocator sourceEndpointLocator = new ConnectionEndpointLocator(result, true);
            sourceEndpointLocator.setVDistance(15);
            sourceLabel = new Label(label);
            result.add(sourceLabel, sourceEndpointLocator);
        }
        return result;
    }
View Full Code Here

        super.refreshLabel();
        String label = (String) getConnectionWrapper().getConnection().getMetaData("label");
        if (sourceLabel != null) {
            sourceLabel.setText(label == null ? "" : label);
        } else if (label != null) {
            Connection connection = (Connection) getFigure();
            ConnectionEndpointLocator endpointLocator = new ConnectionEndpointLocator(connection, true);
            endpointLocator.setVDistance(15);
            sourceLabel = new Label(label);
            connection.add(sourceLabel, endpointLocator);
        }
    }
View Full Code Here

  @Override
  public ConnectionAnchor getSourceConnectionAnchor(
      ConnectionEditPart connection) {
    VertexFigure figure = (VertexFigure) getFigure();
    Edge edge = (Edge) connection.getModel();
    Connection conn = (Connection) connection.getFigure();
    return figure.getSourceAnchor(edge, conn);
  }
View Full Code Here

  @Override
  public ConnectionAnchor getTargetConnectionAnchor(
      ConnectionEditPart connection) {
    VertexFigure figure = (VertexFigure) getFigure();
    Edge edge = (Edge) connection.getModel();
    Connection conn = (Connection) connection.getFigure();
    return figure.getTargetAnchor(edge, conn);
  }
View Full Code Here

    {
      return null;
    }
    CreateBendPointCommand com = new CreateBendPointCommand();
    Point p = request.getLocation();
    Connection conn = getConnection();

    conn.translateToRelative(p);

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

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

    com.setRelativeDimensions(p.getDifference(ref1), p.getDifference(ref2));
    com.setDiagramConnectionModel((DiagramConnectionModel) request.getSource().getModel());
    com.setIndex(request.getIndex());
    return com;
View Full Code Here

    {
      return null;
    }
    MoveBendPointCommand com = new MoveBendPointCommand();
    Point p = request.getLocation();
    Connection conn = getConnection();

    conn.translateToRelative(p);

    com.setLocation(p);

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

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

    com.setRelativeDimensions(p.getDifference(ref1), p.getDifference(ref2));
    com.setDiagramConnectionModel((DiagramConnectionModel) request.getSource().getModel());
    com.setIndex(request.getIndex());
    return com;
View Full Code Here

      double zoom = manager.getDiagramEditor().getZoomLevel();
      realDelta = realDelta.getScaled(zoom);
      midPoint.x += realDelta.x;
      midPoint.y += realDelta.y;
    } else {
      Connection conn = getConnection();
      PointList points = conn.getPoints();
      Point p1;
      Point p2;
      int size = points.size();
      if (size % 2 == 0) {
        int i = points.size() / 2;
View Full Code Here

TOP

Related Classes of org.eclipse.draw2d.Connection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.