Package pl.tecna.gwt.connectors.client.elements

Examples of pl.tecna.gwt.connectors.client.elements.Shape


      public void onDragEnd(DragEndEvent event) {

        Widget widget = event.getContext().draggable;
        if (event.getContext().vetoException != null) {
          if (event.getContext().draggable instanceof Shape) {
            Shape draggable = (Shape) event.getContext().draggable;
            draggable.updateConnectors();
          }
        }
        if (widget instanceof Shape) {
          Shape shape = (Shape) event.getContext().draggable;
          if (!ctrlPressed) {
            fixShapePosition(shape);

            for (ConnectionPoint cp : shape.connectionPoints) {
              for (EndPoint ep : cp.gluedEndPoints) {
                // connector between two dragged shapes
                if (ep.connector.startEndPoint.gluedConnectionPoint != null
                    && ep.connector.endEndPoint.gluedConnectionPoint != null
                    && ep.connector.startEndPoint.gluedConnectionPoint.getParentWidget() != null
                    && ep.connector.endEndPoint.gluedConnectionPoint.getParentWidget() != null
                    && selectedWidgets.contains(ep.connector.startEndPoint.gluedConnectionPoint.getParentWidget())
                    && selectedWidgets.contains(ep.connector.endEndPoint.gluedConnectionPoint.getParentWidget())) {
                  ep.connector.moveOffsetFromStartPos(shape.getTranslationX(), shape.getTranslationY());
                } else {
                  ep.connector.updateCornerPoints();
                }
              }
            }

            fixLineSections(shape);
          } else {
            fixShapePosition(shape);
            for (Connector c : shape.getConnectedConnectors()) {
              if (c.startEndPoint.gluedConnectionPoint != null && c.endEndPoint.gluedConnectionPoint != null
                  && c.startEndPoint.gluedConnectionPoint.getParentWidget() != null
                  && c.endEndPoint.gluedConnectionPoint.getParentWidget() != null
                  && selectedWidgets.contains(c.startEndPoint.gluedConnectionPoint.getParentWidget())
                  && selectedWidgets.contains(c.endEndPoint.gluedConnectionPoint.getParentWidget())) {
                c.moveOffsetFromStartPos(shape.getTranslationX(), shape.getTranslationY());
              } else {
                c.fixEndSectionDirection(c.endEndPoint);
                c.fixEndSectionDirection(c.startEndPoint);
                c.fixLineSections(c.getCorners());
                c.drawSections();
View Full Code Here


  @Override
  public void onEnter(DragContext context) {
    if (context.draggable instanceof EndPoint) {
      if (getDropTarget() instanceof Shape) {
        Shape dropTarget = (Shape) getDropTarget();
        EndPoint ep = (EndPoint) context.draggable;
        if (ep.connector.startEndPoint.isGluedToConnectionPoint()
            && ep.connector.startEndPoint.gluedConnectionPoint.getParentShape().equals(dropTarget)) {

        } else {
          dropTarget.showConnectionPoints(dropTarget.diagram);
        }
      }
    }
    super.onEnter(context);
  }
View Full Code Here

  @Override
  public void onLeave(DragContext context) {
    if (context.draggable instanceof EndPoint) {
      if (getDropTarget() instanceof Shape) {
        Shape dropTarget = (Shape) getDropTarget();
        dropTarget.hideConnectionPoints(dropTarget.diagram);
      }
    }
    super.onLeave(context);
  }
View Full Code Here

  @Override
  public void onDrop(DragContext context) {
    if (context.draggable instanceof EndPoint) {
      // Glue end point to the nearest connection point
      if (getDropTarget() instanceof Shape) {
        Shape dropTarget = (Shape) getDropTarget();
        EndPoint endPoint = (EndPoint) context.draggable;
        endPoint
            .glueToConnectionPoint(dropTarget.findNearestFreeConnectionPoint(endPoint.getLeft(), endPoint.getTop()));

        // Unglue if EndPoints are glued to the same element
        Connector conn = endPoint.connector;
        if (conn.startEndPoint.isGluedToConnectionPoint() && conn.endEndPoint.isGluedToConnectionPoint()) {
          if (conn.endEndPoint.gluedConnectionPoint.getParentWidget() == conn.startEndPoint.gluedConnectionPoint
View Full Code Here

    addDragHandler(new DragHandlerAdapter() {

      @Override
      public void onPreviewDragStart(DragStartEvent event) {
        if (event.getContext().draggable instanceof Shape) {
          Shape shape = (Shape) event.getContext().draggable;
          shape.hideShapeConnectorStartPionts();
        }
      }
    });
  }
View Full Code Here

    startX = diagram.boundaryPanel.getWidgetLeft(context.draggable) - diagram.boundaryPanel.getAbsoluteLeft();
    startY = diagram.boundaryPanel.getWidgetTop(context.draggable) - diagram.boundaryPanel.getAbsoluteTop();

    for (Widget widget : diagram.shapeDragController.getSelectedWidgets()) {
      if (widget instanceof Shape) {
        Shape shape = (Shape) widget;
        for (ConnectionPoint cp : shape.connectionPoints) {
          for (EndPoint ep : cp.gluedEndPoints) {
            ep.connector.rememberSectionsPositions();
          }
        }
View Full Code Here

    // Update glued end points positions and update connector
    // TODO
    diagram.selectedWidgets = context.selectedWidgets;
    for (Widget widget : context.selectedWidgets) {
      if (widget instanceof Shape) {
        Shape shape = (Shape) widget;
        shape.setTranslationX(context.desiredDraggableX - startX - diagram.boundaryPanel.getAbsoluteLeft());
        shape.setTranslationY(context.desiredDraggableY - startY - diagram.boundaryPanel.getAbsoluteTop());
        for (ConnectionPoint cp : shape.connectionPoints) {
          for (EndPoint ep : cp.gluedEndPoints) {
            if (diagram.ctrlPressed) {

              ep.setLeft(cp.getCenterLeft());
View Full Code Here

   
    boundaryPanel.add(label, 50, 250);
    boundaryPanel.add(label2, 450, 200);
    boundaryPanel.add(label3, 700, 500);

    Shape shapeForLabel = new Shape(label, CPShapeType.DIAMOND);
    shapeForLabel.showOnDiagram(diagram);
    shapeForLabel.setTitle("shapeForLabel");
    shapeForLabel.enableConnectionCreate(true);

    Shape shapeForLabel2 = new Shape(label2, CPShapeType.OVAL);
    shapeForLabel2.showOnDiagram(diagram);
    shapeForLabel2.setTitle("shapeForLabel2");
   
    Shape shapeForLabel3 = new Shape(label3, CPShapeType.RECTANGLE);
    shapeForLabel3.showOnDiagram(diagram);
    shapeForLabel3.setTitle("shapeForLabel");
    shapeForLabel3.enableConnectionCreate(true);

    Shape shapeForDiamond = new Shape(diamond, CPShapeType.DIAMOND);
    shapeForDiamond.showOnDiagram(diagram);
    shapeForDiamond.enableConnectionCreate(true);
    shapeForDiamond.setTitle("shapeForDiamond");
   
    Shape shapeForTask = new Shape(task, CPShapeType.RECTANGLE);
    shapeForTask.connectorsStyle = ConnectorStyle.DASHED;
    shapeForTask.showOnDiagram(diagram);
    shapeForTask.enableConnectionCreate(true);
    shapeForTask.setTitle("Shape for task");
   
  }
View Full Code Here

  }

  public void fixConnectorPath(EndPoint dragEndPoint) {
    Connector conn = dragEndPoint.connector;
    if (conn.startEndPoint.isGluedToConnectionPoint()) {
      Shape shape = conn.startEndPoint.gluedConnectionPoint.getParentShape();
      ArrayList<ConnectionPoint> excluded = new ArrayList<ConnectionPoint>();
      for (ConnectionPoint cp : shape.connectionPoints) {
        if (cp.gluedEndPoints != null && cp.gluedEndPoints.size() != 0
            && !cp.equals(conn.startEndPoint.gluedConnectionPoint)) {
          excluded.add(cp);
        }
      }

      if (!diagram.altPressed) {
        ConnectionPoint nearestCP =
            shape.findNearestConnectionPoint(dragEndPoint.getLeft(), dragEndPoint.getTop(), excluded);
        if (nearestCP != null && nearestCP != conn.startEndPoint.gluedConnectionPoint) {
          conn.startEndPoint.unglueFromConnectionPoint();
          conn.startEndPoint.glueToConnectionPoint(nearestCP);
          conn.startEndPoint.setLeft(nearestCP.getCenterLeft());
          conn.startEndPoint.setTop(nearestCP.getCenterTop());
View Full Code Here

TOP

Related Classes of pl.tecna.gwt.connectors.client.elements.Shape

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.