Example #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);
  }
Example #2
0
  public static void main(String[] args) {
    final Scene scene = new Scene();

    LayerWidget layer = new LayerWidget(scene);
    scene.addChild(layer);

    Widget nodeWidget = new Widget(scene);
    nodeWidget.setBorder(BorderFactory.createLineBorder(1, Color.RED));
    nodeWidget.setPreferredLocation(new Point(100, 100));
    layer.addChild(nodeWidget);

    final Widget deferredWidget = new Widget(scene);
    deferredWidget.setLayout(LayoutFactory.createCardLayout(deferredWidget));
    deferredWidget.setBorder(BorderFactory.createLineBorder(1, Color.BLUE));
    nodeWidget.addChild(deferredWidget);

    final Widget label = new LabelWidget(scene, "Click me to add ComponentWidget");
    label.setBorder(BorderFactory.createLineBorder(1, Color.GREEN));
    deferredWidget.addChild(label);
    LayoutFactory.setActiveCard(deferredWidget, label);

    label
        .getActions()
        .addAction(
            ActionFactory.createEditAction(
                new EditProvider() {
                  public void edit(Widget widget) {
                    ComponentWidget component =
                        new ComponentWidget(scene, new JButton("This is the new ComponentWidget"));
                    component.setBorder(BorderFactory.createLineBorder(1, Color.GREEN));
                    deferredWidget.addChild(component);
                    LayoutFactory.setActiveCard(deferredWidget, component);
                  }
                }));

    scene
        .getActions()
        .addAction(
            ActionFactory.createEditAction(
                new EditProvider() {
                  public void edit(Widget widget) {
                    LayoutFactory.setActiveCard(deferredWidget, label);
                  }
                }));

    // to force the boundary
    //        nodeWidget.setPreferredBounds (new Rectangle (0, 0, 70, 30));
    //        nodeWidget.setPreferredSize (new Dimension (70, 30));
    nodeWidget.setLayout(LayoutFactory.createOverlayLayout());
    nodeWidget.setCheckClipping(true);
    //

    SceneSupport.show(scene);
  }
Example #3
0
 private Widget createLabel(String text, int x, int y, Color color) {
   LabelWidget label = new LabelWidget(this, text);
   label.setOpaque(true);
   label.setBackground(color);
   label.setBorder(BorderFactory.createLineBorder(5));
   label.setPreferredLocation(new Point(x, y));
   label.getActions().addAction(ActionFactory.createMoveAction());
   mainLayer.addChild(label);
   return label;
 }