Ejemplo n.º 1
0
  public ActionsWithRoutingPolicyTest() {
    mainLayer = new LayerWidget(this);
    addChild(mainLayer);
    LayerWidget connLayer = new LayerWidget(this);
    addChild(connLayer);

    Widget source = createLabel("Source", 50, 200, Color.GREEN);
    Widget target = createLabel("Target", 450, 200, Color.GREEN);

    connection = new ConnectionWidget(this);
    connection.setSourceAnchor(
        AnchorFactory.createDirectionalAnchor(
            source, AnchorFactory.DirectionalAnchorKind.HORIZONTAL));
    connection.setTargetAnchor(
        AnchorFactory.createDirectionalAnchor(
            target, AnchorFactory.DirectionalAnchorKind.HORIZONTAL));
    connection.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);
    connection.setPaintControlPoints(true);
    connection.setControlPointShape(PointShape.SQUARE_FILLED_BIG);
    connection.setRouter(RouterFactory.createOrthogonalSearchRouter(mainLayer));
    connection
        .getActions()
        .addAction(
            ActionFactory.createAddRemoveControlPointAction(
                1.0, 5.0, ConnectionWidget.RoutingPolicy.UPDATE_END_POINTS_ONLY));
    connection
        .getActions()
        .addAction(
            ActionFactory.createMoveControlPointAction(
                ActionFactory.createFreeMoveControlPointProvider(),
                ConnectionWidget.RoutingPolicy.UPDATE_END_POINTS_ONLY));
    connLayer.addChild(connection);
  }
Ejemplo n.º 2
0
    public void createConnection(Widget source, Widget target) {

      // Select necessary nodes only

      ConfigNode cnSource = (ConfigNode) findObject(source);
      ConfigNode cnTarget = (ConfigNode) findObject(target);

      String cnSourceIdType = cnSource.getId().substring(0, 2);
      String cnTargetIdType = cnTarget.getId().substring(0, 2);

      String type = "TEMPORAL";

      // filter relavent links only
      if ((cnSourceIdType.equals("L2") && cnTargetIdType.equals("L1"))
          || (cnSourceIdType.equals("L1") && cnTargetIdType.equals("L0"))
          || (cnSourceIdType.equals(cnTargetIdType))) {

        ConnectionWidget conn = new ConnectionWidget(GraphSceneImpl.this);
        conn.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);

        // Double arrow head for cross features
        if (cnSourceIdType.equals(cnTargetIdType)) {
          conn.setSourceAnchorShape(AnchorShape.TRIANGLE_FILLED);
          type = "CROSS";
        }

        //
        // conn.setRouter(RouterFactory.createOrthogonalSearchRouter(GraphSceneImpl.widgetCollector));
        conn.setTargetAnchor(AnchorFactory.createRectangularAnchor(target));
        conn.setSourceAnchor(AnchorFactory.createRectangularAnchor(source));
        connectionLayer.addChild(conn);
        edgeMap.add(new NodeLinks(type, cnSource.getId(), cnTarget.getId()));
      }
    }
 @Override
 public void createConnection(Widget source, Widget target) {
   ConnectionWidget conn = new ConnectionWidget(VisualScene.this);
   conn.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);
   conn.setTargetAnchor(AnchorFactory.createRectangularAnchor(target));
   conn.setSourceAnchor(AnchorFactory.createRectangularAnchor(source));
   conn.getActions().addAction(createObjectHoverAction());
   conn.getActions().addAction(createSelectAction());
   connectionLayer.addChild(conn);
 }
  private void connect(VisualNode source, int sourcePort, VisualNode target, int targetPort) {
    CustomConnectionWidget connection = new CustomConnectionWidget(this);
    Widget src = source.getOutputPort(sourcePort);
    Widget tgt = target.getInputPort(targetPort);
    connection.setSourceAnchor(AnchorFactory.createCircularAnchor(src, 2));
    connection.setTargetAnchor(AnchorFactory.createCircularAnchor(tgt, 2));
    addEdge(connection);

    connections.add(new Connection(source, sourcePort, target, targetPort, connection));
  }
  public void connect(PortInteractor source, PortInteractor target) {
    CustomConnectionWidget connection = new CustomConnectionWidget(this);
    connection.setSourceAnchor(AnchorFactory.createCircularAnchor(source, 1));
    connection.setTargetAnchor(AnchorFactory.createCircularAnchor(target, 1));

    // save one for each so that they connections can be accessed in both directions
    connections.add(
        new Connection(
            source.getNode(),
            source.getPortNumber(),
            target.getNode(),
            target.getPortNumber(),
            connection));
    addEdge(connection);
  }
Ejemplo n.º 6
0
  public void createConnection(Widget sourceWidget, Widget targetWidget) {
    try {
      ConnectionWidget connection = new ConnectionWidget(sourceWidget.getScene());
      connection.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);
      connection.setSourceAnchor(AnchorFactory.createRectangularAnchor(sourceWidget));
      connection.setTargetAnchor(AnchorFactory.createRectangularAnchor(targetWidget));
      Stroke stroke = Costanti.BASIC_STROKE;
      connection.setStroke(stroke);
      connection
          .getActions()
          .addAction(
              ActionFactory.createPopupMenuAction(
                  new MyPopupProviderConnectionFunc(
                      sourceWidget.getScene(), mainLayer, caratteristiche)));
      ConnectionInfo connectionInfo = new ConnectionInfo();
      connectionInfo.setTargetWidget(targetWidget);
      connectionInfo.setConnectionWidget(connection);
      caratteristiche.setTargetWidget((VMDPinWidgetTarget) targetWidget);

      creator.createCorrespondenceWithFunction(
          mainLayer, targetWidget, caratteristiche, connectionInfo);

      caratteristiche.setConnectionInfo(connectionInfo);
      connectionLayer.addChild(connection, connectionInfo);
    } catch (ExpressionSyntaxException e) {
      DialogDisplayer.getDefault()
          .notify(
              new NotifyDescriptor.Message(
                  NbBundle.getMessage(Costanti.class, Costanti.SYNTAX_WARNING)
                      + " : "
                      + e.getMessage(),
                  DialogDescriptor.WARNING_MESSAGE));
      // giannisk delete target connection if exception if caught
      deleteTargetConnection(sourceWidget);
    }
  }
 @Override
 protected void attachEdgeTargetAnchor(Object edge, Object n, Object targetNode) {
   Widget w = targetNode != null ? findInput(targetNode) : null;
   ((ConnectionWidget) findWidget(edge)).setTargetAnchor(AnchorFactory.createRectangularAnchor(w));
 }
 @Override
 protected void attachEdgeSourceAnchor(Object edge, Object sourceNode, Object n1) {
   Widget w = sourceNode != null ? findOutput(sourceNode) : null;
   ((ConnectionWidget) findWidget(edge)).setSourceAnchor(AnchorFactory.createRectangularAnchor(w));
 }
Ejemplo n.º 9
0
 @Override
 protected void attachEdgeTargetAnchor(Edge edge, Node oldTarget, Node newTarget) {
   Widget w = newTarget != null ? findWidget(newTarget) : null;
   ((ConnectionWidget) findWidget(edge)).setTargetAnchor(AnchorFactory.createRectangularAnchor(w));
 }
Ejemplo n.º 10
0
 @Override
 protected void attachEdgeSourceAnchor(Edge edge, Node oldSource, Node newSource) {
   Widget w = newSource != null ? findWidget(newSource) : null;
   ((ConnectionWidget) findWidget(edge)).setSourceAnchor(AnchorFactory.createRectangularAnchor(w));
 }
Ejemplo n.º 11
0
  public ProxyAnchorExpandTest() {
    setBackground(Color.LIGHT_GRAY);

    // layer for widgets
    LayerWidget mainLayer = new LayerWidget(this);
    addChild(mainLayer);
    // layer for connections
    LayerWidget connLayer = new LayerWidget(this);
    addChild(connLayer);

    // outer widget
    Widget outerWidget = new Widget(this);
    outerWidget.setOpaque(true);
    outerWidget.setBackground(Color.WHITE);
    outerWidget.setBorder(BorderFactory.createLineBorder(10));
    outerWidget.setPreferredLocation(new Point(100, 100));
    outerWidget.setLayout(
        LayoutFactory.createVerticalFlowLayout(LayoutFactory.SerialAlignment.CENTER, 4));

    outerWidget.addChild(
        new LabelWidget(
            this, "The anchor switches based on a state in StateModel used by ProxyAnchor."));
    outerWidget.addChild(
        new LabelWidget(this, "ConnectionWidget has the same anchors assigned all the time."));

    // inner widget
    LabelWidget innerWidget = new LabelWidget(this, "Internal frame");
    innerWidget.setBorder(BorderFactory.createLineBorder());
    outerWidget.addChild(innerWidget);

    mainLayer.addChild(outerWidget);

    // the target widget
    Widget targetWidget =
        new LabelWidget(this, "Click here to switch the state in StateModel/anchor.");
    targetWidget.setOpaque(true);
    targetWidget.setBackground(Color.WHITE);
    targetWidget.setBorder(BorderFactory.createLineBorder(10));
    targetWidget.setPreferredLocation(new Point(450, 300));
    mainLayer.addChild(targetWidget);

    // an action for switching a state of a StateModel used by the ProxyAnchor to determinate an
    // active anchor
    WidgetAction switchAction = ActionFactory.createSelectAction(new SwitchProvider());
    targetWidget.getActions().addAction(switchAction);

    Anchor outerAnchor = AnchorFactory.createRectangularAnchor(outerWidget);
    Anchor innerAnchor = AnchorFactory.createRectangularAnchor(innerWidget);

    // a proxy anchor which acts like an one of the specified anchors.
    // The active anchor is defined by a state in the StateModel
    Anchor proxyAnchor = AnchorFactory.createProxyAnchor(model, outerAnchor, innerAnchor);

    // the connection widget
    ConnectionWidget conn = new ConnectionWidget(this);
    conn.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);
    connLayer.addChild(conn);

    // the proxy anchor is used as a source
    conn.setSourceAnchor(proxyAnchor);
    // the target anchor is assigned to the targetWidget widget
    conn.setTargetAnchor(AnchorFactory.createRectangularAnchor(targetWidget));
  }