Package org.eclipse.draw2d

Examples of org.eclipse.draw2d.Connection


  @Override
  public void execute() {
    int x = rectangle.x;
    int y = rectangle.y;
    Connection connection = (Connection)editPart.getFigure().getParent();
    SapphireMidpointLocator location = new SapphireMidpointLocator(editPart.getConfigurationManager(), connection);
    Point midpoint = location.getMidpoint();
    midpoint = editPart.getConfigurationManager().getDiagramEditor().calculateRealMouseLocation(midpoint);
    org.eclipse.sapphire.ui.Point newPos = new org.eclipse.sapphire.ui.Point(x - midpoint.x, y - midpoint.y);
    editPart.getDiagramConnectionPart().setLabelPosition(newPos);
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().get("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().get("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

{

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((Wire)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((Wire)request.getSource().getModel());
  com.setIndex(request.getIndex());
View Full Code Here

* Returns a newly created Figure to represent the connection.
*
* @return  The created Figure.
*/
protected IFigure createFigure() {
  Connection connx = FigureFactory.createNewBendableWire(getWire());
  return connx;
}
View Full Code Here

    editor.click(130, 20);

    final SWTBotGefEditPart circuitPart = editor.editParts(instanceOf(CircuitEditPart.class)).get(0);
    final SWTBotGefConnectionEditPart wirePart = circuitPart.sourceConnections().get(0);
    final Wire wire = (Wire) (wirePart.part()).getModel();
    final Connection connection = (Connection) wirePart.part().getFigure();

    editor.activateTool("Select");
    assertEquals("Select", getActiveToolLabel());

    Point startMove = connection.getPoints().getMidpoint().getCopy();
    editor.click(startMove.x, startMove.y);

   
   
    /* we need to wait element selection before proceed or drag will fail */
 
View Full Code Here

      connectionToPaths = new HashMap();
      hookAll();
    }

    while (iter.hasNext()) {
      Connection conn = (Connection) iter.next();

      Path path = (Path) connectionToPaths.get(conn);
      if (path == null) {
        path = new Path(conn);
        connectionToPaths.put(conn, path);
        algorithm.addPath(path);
      }

      List constraint = (List) getConstraint(conn);
      if (constraint == null)
        constraint = Collections.EMPTY_LIST;

      Point start = conn.getSourceAnchor().getReferencePoint().getCopy();
      Point end = conn.getTargetAnchor().getReferencePoint().getCopy();

      container.translateToRelative(start);
      container.translateToRelative(end);

      path.setStartPoint(start);
View Full Code Here

    if (isDirty) {
      ignoreInvalidate = true;
      processStaleConnections();
      isDirty = false;
      List updated = algorithm.solve();
      Connection current;
      for (int i = 0; i < updated.size(); i++) {
        Path path = (Path) updated.get(i);
        current = (Connection) path.data;
        current.revalidate();

        PointList points = path.getPoints().getCopy();
        Point ref1, ref2, start, end;
        ref1 = new PrecisionPoint(points.getPoint(1));
        ref2 = new PrecisionPoint(points.getPoint(points.size() - 2));
        current.translateToAbsolute(ref1);
        current.translateToAbsolute(ref2);

        start = current.getSourceAnchor().getLocation(ref1).getCopy();
        end = current.getTargetAnchor().getLocation(ref2).getCopy();

        current.translateToRelative(start);
        current.translateToRelative(end);
        points.setPoint(start, 0);
        points.setPoint(end, points.size() - 1);

        current.setPoints(points);
      }
      ignoreInvalidate = false;
    }
  }
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.