Package org.eclipse.draw2d

Examples of org.eclipse.draw2d.PolylineConnection


    }

    protected void applyResults(ElementConnectionEditPart connectionPart)    {
        Edge e = (Edge) partToNodesMap.get(connectionPart);
        NodeList nodes = e.vNodes;
        PolylineConnection conn = (PolylineConnection) connectionPart.getConnectionFigure();
        conn.setTargetDecoration(new PolygonDecoration());
        if (nodes != null) {
            List bends = new ArrayList();
            for (int i = 0; i < nodes.size(); i++) {
                Node vn = nodes.getNode(i);
                int x = vn.x;
                int y = vn.y;
                if (e.isFeedback()) {
                    bends.add(new AbsoluteBendpoint(x, y + vn.height));
                    bends.add(new AbsoluteBendpoint(x, y));
                } else {
                    bends.add(new AbsoluteBendpoint(x, y));
                    bends.add(new AbsoluteBendpoint(x, y + vn.height));
                }
            }
            conn.setRoutingConstraint(bends);
        } else {
            conn.setRoutingConstraint(Collections.EMPTY_LIST);
        }
    }
View Full Code Here


    installEditPolicy(EditPolicy.COMPONENT_ROLE, new DiagramConnectionEditPolicy());
  }

  @Override
  protected IFigure createFigure() {
    PolylineConnection connection = new DiagramConnectionFigure();
    IDiagramConnectionDef def = getCastedModel().getModelPart().getConnectionDef();
   
    ConnectionEndpointType type1 = ConnectionEndpointType.NONE;
    if (def.getEndpoint1() != null) {
      type1 = def.getEndpoint1().getType().content();
    }
    if (type1.equals(ConnectionEndpointType.ARROW)) {
      connection.setSourceDecoration(new PolygonDecoration());
    }
   
    ConnectionEndpointType type2 = ConnectionEndpointType.NONE;
    if (def.getEndpoint2() != null) {
      type2 = def.getEndpoint2().getType().content();
    }
    if (type2.equals(ConnectionEndpointType.ARROW)) {
      connection.setTargetDecoration(new PolygonDecoration());
    }

    updateStyle(connection);
    return connection;
  }
View Full Code Here

  private void refreshLabel() {
    ((Label)getFigure()).setText(getDiagramConnectionPart().getLabel());
  }
 
  private void refreshLabelLocation() {
    PolylineConnection parent = (PolylineConnection)getFigure().getParent();
    Point position = getDiagramConnectionPart().getLabelPosition();
    SapphireMidpointLocator locator = position == null ?
            new SapphireMidpointLocator(getConfigurationManager(), parent) :
            new SapphireMidpointLocator(getConfigurationManager(), parent, position.getX(), position.getY());
    parent.getLayoutManager().setConstraint(getFigure(), locator);
  }
View Full Code Here

  @Override
  protected Connection createDummyConnection(Request req) {
    identifySourceFigure(req);
    IFigure hostFigure = getHostFigure();
    PolylineConnection connection = new DummyPolylineConnection(hostFigure);
    connection.setLineWidth(2);
    connection.setLineStyle(SWT.LINE_DASH);
    if (getHost() instanceof DiagramNodeEditPart) {
      DiagramResourceCache cache = ((DiagramNodeEditPart)getHost()).getCastedModel().getDiagramModel().getResourceCache();
      connection.setForegroundColor(cache.getColor(DUMMY_CONNECTION_FOREGROUND));
    }
    return connection;
  }
View Full Code Here

public class LogicNodeEditPolicy
  extends org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy
{

protected Connection createDummyConnection(Request req) {
  PolylineConnection conn = FigureFactory.createNewWire(null);
  return conn;
}
View Full Code Here

import org.eclipse.gef.examples.logicdesigner.model.Wire;

public class FigureFactory {

public static PolylineConnection createNewBendableWire(Wire wire){
  PolylineConnection conn = new PolylineConnection();
  conn.addRoutingListener(RoutingAnimator.getDefault());
//  conn.setSourceDecoration(new PolygonDecoration());
//  conn.setTargetDecoration(new PolylineDecoration());
  return conn;
}
View Full Code Here

  return conn;
}

public static PolylineConnection createNewWire(Wire wire){

  PolylineConnection conn = new PolylineConnection();
  conn.addRoutingListener(RoutingAnimator.getDefault());
  PolygonDecoration arrow;
 
  if (wire == null || wire.getSource() instanceof SimpleOutput)
    arrow = null;
  else {
    arrow = new PolygonDecoration();
    arrow.setTemplate(PolygonDecoration.INVERTED_TRIANGLE_TIP);
    arrow.setScale(5,2.5);
  }
  conn.setSourceDecoration(arrow);
 
  if (wire == null || wire.getTarget() instanceof SimpleOutput)
    arrow = null;
  else {
    arrow = new PolygonDecoration();
    arrow.setTemplate(PolygonDecoration.INVERTED_TRIANGLE_TIP);
    arrow.setScale(5,2.5);
  }
  conn.setTargetDecoration(arrow);
  return conn;
}
View Full Code Here

    return (Reference) getModel();
  }

  @Override
  protected IFigure createFigure() {
    PolylineConnection conn = createConnection(getReference());
    Label label = new Label();
    BeanType type = getReference().getType();
    if (type == BeanType.PARENT) {
      conn.setLineStyle(Graphics.LINE_DOT);
      label.setText("Parent bean: "
          + getReference().getTargetBean().getName());
    } else if (type == BeanType.FACTORY) {
      conn.setLineStyle(Graphics.LINE_DASH);
      label.setText("Factory bean");
    } else if (type == BeanType.DEPENDS_ON) {
      conn.setLineStyle(Graphics.LINE_DASH);
      label.setText("Depends-on bean");
    } else if (type == BeanType.METHOD_OVERRIDE) {
      conn.setLineStyle(Graphics.LINE_DOT);
      label.setText("Method-override bean");
    } else if (type == BeanType.INTERCEPTOR) {
      conn.setLineStyle(Graphics.LINE_DASHDOT);
      label.setText("Interceptor bean");
    } else {
      Node node = getReference().getNode();
      if (node instanceof ConstructorArgument) {
        label.setText("ConstructorArgument: "
            + ((ConstructorArgument) node).getName());
      } else if (node instanceof Property) {
        label.setText("Property: " + ((Property) node).getName());
      }
    }
    conn.setToolTip(label);
    return conn;
  }
View Full Code Here

  @Override
  protected void createEditPolicies() {
  }

  protected PolylineConnection createConnection(Edge edge) {
    PolylineConnection conn = new PolylineConnection();

    // Prepare connection router with corresponding bendpoints
    conn.setConnectionRouter(new BendpointConnectionRouter());

    // Add bend point if source's bean prefered height is different from
    // heigth calculated by DirectedGraphLayout
    List<AbsoluteBendpoint> bends = new ArrayList<AbsoluteBendpoint>();
    Bean source = (Bean) getReference().source;
    if (source.height > source.preferredHeight) {
      Rectangle rect = new Rectangle(source.x + GraphPart.MARGIN_SIZE,
          source.y + GraphPart.MARGIN_SIZE, source.width,
          source.height);
      bends.add(new AbsoluteBendpoint(rect.getBottom()));
    }

    // Create bend points for edge's virtual nodes (if any)
    NodeList nodes = edge.vNodes;
    if (nodes != null) {
      for (int i = 0; i < nodes.size(); i++) {
        Node node = nodes.getNode(i);

        // Check if edge was inverted (due to broken cycle)
        if (edge.isFeedback()) {
          bends.add(new AbsoluteBendpoint(node.x
              + GraphPart.MARGIN_SIZE, node.y
              + GraphPart.MARGIN_SIZE + node.height));
          bends.add(new AbsoluteBendpoint(node.x
              + GraphPart.MARGIN_SIZE, node.y
              + GraphPart.MARGIN_SIZE));
        } else {
          bends.add(new AbsoluteBendpoint(node.x
              + GraphPart.MARGIN_SIZE, node.y
              + GraphPart.MARGIN_SIZE));
          bends.add(new AbsoluteBendpoint(node.x
              + GraphPart.MARGIN_SIZE, node.y
              + GraphPart.MARGIN_SIZE + node.height));
        }
      }
    }
    conn.setRoutingConstraint(bends);
    conn.setTargetDecoration(new PolylineDecoration());
    if (getReference().isInner()) {
      conn.setLineStyle(Graphics.LINE_DOT);
    }
    return conn;
  }
View Full Code Here

    super(model);
  }

  @Override
  protected IFigure createFigure() {
    PolylineConnection conn = (PolylineConnection) super.createFigure();
    // conn.setForegroundColor(ColorConstants.blue);
    return conn;
  }
View Full Code Here

TOP

Related Classes of org.eclipse.draw2d.PolylineConnection

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.