Package com.google.gwt.user.client.ui

Examples of com.google.gwt.user.client.ui.AbsolutePanel


  }

  public void showShapeConnectorStartPoints() {
    endPointsShowTimer.cancel();
    if (endPoints.isEmpty()) {
      AbsolutePanel boundaryPanel = diagram.boundaryPanel;
      for (ConnectionPoint cp : connectionPoints) {
        if (cp.gluedEndPoints.size() == 0) {
          Point cpPoint = getCPPosition(cp);
          ShapeConnectorStart ep =
              new ShapeConnectorStart(cpPoint.getLeft(), cpPoint.getTop(), Shape.this, endPointsShowTimer, cp);
          boundaryPanel.add(ep, cpPoint.getLeft(), cpPoint.getTop());
          diagram.endPointDragController.makeDraggable(ep);
          endPoints.add(ep);
        }
      }
    }
View Full Code Here


    return shape;
  }

  @Override
  protected Widget createImage() {
    Widget w = new AbsolutePanel();
    w.addStyleName(ConnectorsClientBundle.INSTANCE.css().gwtConnectorsShapeConnectorStartInner());
    return w;
  }
View Full Code Here

      public void onUncaughtException(Throwable e) {
        LOG.log(Level.SEVERE, "Uncaught error", e);
      }
    });

    AbsolutePanel viewPanel = new AbsolutePanel();
    DOM.setStyleAttribute(viewPanel.getElement(), "overflow", "scroll");
    viewPanel.setSize("100%", "100%");
   
    // Create boundary panel
    AbsolutePanel boundaryPanel = new AbsolutePanel();
    boundaryPanel.setSize("20000px", "20000px");
    viewPanel.add(boundaryPanel, 0, 0);
   
    RootPanel.get().add(viewPanel, 0, 0);
   
    final Diagram diagram = new Diagram(boundaryPanel);

    boundaryPanel.add(new Label("Connectors example for GWT 2.4"), 10, 2);
    Connector connector1 = new Connector(50, 80, 150, 200, new SectionDecoration(DecorationType.ARROW_SOLID), new SectionDecoration(DecorationType.ARROW_SOLID));
    connector1.showOnDiagram(diagram);

    ArrayList<CornerPoint> cp = new ArrayList<CornerPoint>();
    cp.add(new CornerPoint(370, 200));
    cp.add(new CornerPoint(370, 120));
    cp.add(new CornerPoint(270, 120));
    SectionDecoration startDecoration = new SectionDecoration(DecorationType.ARROW_LINE);
    SectionDecoration endDecoration = new SectionDecoration(
        new Image("http://code.google.com/images/code_sm.png"),
        new Image("http://code.google.com/images/code_sm.png"));
    Connector connector2 = new Connector(350, 200, 270, 80, cp, startDecoration, endDecoration);
    connector2.style = ConnectorStyle.DASHED;
    connector2.showOnDiagram(diagram);

    Connector connector3 = new Connector(450, 120, 500, 80, new SectionDecoration(DecorationType.ARROW_SOLID), new SectionDecoration(DecorationType.ARROW_SOLID));
    connector3.style = ConnectorStyle.DOTTED;
    connector3.showOnDiagram(diagram);

    FocusPanel diamond = new FocusPanel();
    Image img = AbstractImagePrototype.create(ConnectorsBundle.INSTANCE.diamondImg()).createImage();
    img.getElement().getStyle().setDisplay(Display.BLOCK);
    diamond.setWidget(img);
    boundaryPanel.add(diamond, 700, 400);

    // Add some elements that can be connected
    final Label label = new Label("LABEL");
    final Label label2 = new Label("LABEL_2");
    final Image image = new Image("http://code.google.com/images/code_sm.png");

    final Label label3 = new Label("LABEL_3 Test Longer Label with rectangle connection points");

    image.setPixelSize(153, 55);

    BPMNTask task = new BPMNTask();
    boundaryPanel.add(task, 500, 300);
   
    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);
View Full Code Here

     * .gwt-connectors-line { font-size: 1px; line-height:1px; background-color: black }
     * .gwt-connectors-line-vertical { width:1px } .gwt-connectors-line-horizontal { height:1px }
     */

    this.style = style;
    AbsolutePanel panel = diagram.boundaryPanel;

    boolean allowHorizontalDragging = false;
    boolean allowVerticalDragging = false;

    // Set line look and behavior

    if (isVertical()) {
      if (isSelected) {
        this.setHTML(selectedVerticalLine(this.height + additionalHeight, style));
      } else {
        this.setHTML(verticalLine(this.height + additionalHeight, style));
      }
      allowHorizontalDragging = true;
    } else if (isHorizontal()) {
      if (isSelected) {
        this.setHTML(selectedHorizontalLine(this.width + additionalWidth, style));
      } else {
        this.setHTML(horizontalLine(this.width + additionalWidth, style));
      }
      allowVerticalDragging = true;
    }

    // Set Section's cursor
    if (isVertical()) {
      DOM.setStyleAttribute(this.getElement(), "cursor", "w-resize");
    } else if (isHorizontal()) {
      DOM.setStyleAttribute(this.getElement(), "cursor", "n-resize");
    }

    // Add drag and drop functionality
    this.sectionDragController = new AxisXYDragController(panel, true, allowHorizontalDragging, allowVerticalDragging) {

      @Override
      public void dragStart() {

        // If dragged section startPoint or dragged section endPoint
        // is glued to connectionPoint then split section into three
        // to draw new lines to connectionPoint
        try {
          if (Section.this.startPointIsGluedToConnectionPoint() || Section.this.endPointIsGluedToConnectionPoint()) {
            // Calculate new CornerPoints
            ArrayList<CornerPoint> newCornerPoints = new ArrayList<CornerPoint>();
            Point sp = Section.this.startPoint;
            Point ep = Section.this.endPoint;
            CornerPoint cp1 =
                new CornerPoint(sp.getLeft() + (ep.getLeft() - sp.getLeft()) / 2, sp.getTop()
                    + (ep.getTop() - sp.getTop()) / 2);
            CornerPoint cp2 =
                new CornerPoint(sp.getLeft() + (ep.getLeft() - sp.getLeft()) / 2, sp.getTop()
                    + (ep.getTop() - sp.getTop()) / 2);
            newCornerPoints.add(cp1);
            newCornerPoints.add(cp2);
            // Split Section
            Section.this.splitSection(newCornerPoints);
          }
        } catch (Exception e) {
          LOG.info("Section drag start error " + e.getMessage());
          e.printStackTrace();
        }
        try {
          super.dragStart();
        } catch (Exception e) {
          LOG.info("Section (super) drag start error " + e.getMessage());
          e.printStackTrace();
        }
      }

      @Override
      public void dragMove() {
        try {

          if (isAllowHorizontalDragging()) {
            if (Section.this.startPoint.getLeft() < Section.this.endPoint.getLeft()) {
              Section.this.startPoint.setLeft(context.draggable.getAbsoluteLeft()
                  - context.boundaryPanel.getAbsoluteLeft());
              Section.this.endPoint.setLeft(context.draggable.getAbsoluteLeft()
                  - context.boundaryPanel.getAbsoluteLeft() + width);
            } else {
              Section.this.startPoint.setLeft(context.draggable.getAbsoluteLeft()
                  - context.boundaryPanel.getAbsoluteLeft() + width);
              Section.this.endPoint.setLeft(context.draggable.getAbsoluteLeft()
                  - context.boundaryPanel.getAbsoluteLeft());
            }
          }

          if (isAllowVerticalDragging()) {
            if (Section.this.startPoint.getTop() < Section.this.endPoint.getTop()) {
              Section.this.startPoint.setTop(context.draggable.getAbsoluteTop()
                  - context.boundaryPanel.getAbsoluteTop());
              Section.this.endPoint.setTop(context.draggable.getAbsoluteTop() - context.boundaryPanel.getAbsoluteTop()
                  + height);
            } else {
              Section.this.startPoint.setTop(context.draggable.getAbsoluteTop()
                  - context.boundaryPanel.getAbsoluteTop() + height);
              Section.this.endPoint.setTop(context.draggable.getAbsoluteTop() - context.boundaryPanel.getAbsoluteTop());
            }
          }

          if (Section.this.connector.getNextSection(Section.this) != null) {
            Section.this.connector.getNextSection(Section.this).update();
          };
          if (Section.this.connector.getPrevSection(Section.this) != null) {
            Section.this.connector.getPrevSection(Section.this).update();
          };

          Section.this.connector.endEndPoint.update();
          Section.this.connector.startEndPoint.update();

          if (startPointDecoration != null) {
            startPointDecoration.update(calculateStartPointDecorationDirection(), startPoint.getLeft(), startPoint
                .getTop());
          }
          if (endPointDecoration != null) {
            endPointDecoration.update(calculateEndPointDecorationDirection(), endPoint.getLeft(), endPoint.getTop());
          }
        } catch (Exception e) {
          LOG.info("Section drag move error " + e.getMessage());
          e.printStackTrace();
        }

        try {
          // super.dragMove();

          // To provide XY drag feature (BEGIN)
          if (isAllowHorizontalDragging() == false) {
            context.desiredDraggableX = initialDraggableLocation.getLeft() + boundaryOffsetX;
          }
          if (isAllowVerticalDragging() == false) {
            context.desiredDraggableY = initialDraggableLocation.getTop() + boundaryOffsetY;
          }
          // To provide XY drag feature (END)

          int desiredLeft = context.desiredDraggableX - boundaryOffsetX;
          int desiredTop = context.desiredDraggableY - boundaryOffsetY;

          if (getBehaviorConstrainedToBoundaryPanel()) {
            desiredLeft =
                Math.max(0, Math.min(desiredLeft, dropTargetClientWidth - context.draggable.getOffsetWidth()));
            desiredTop =
                Math.max(0, Math.min(desiredTop, dropTargetClientHeight - context.draggable.getOffsetHeight()));
          }

          if (isAllowHorizontalDragging()) {
            if (startPoint.getTop().intValue() > endPoint.getTop().intValue()) {
              desiredTop = endPoint.getTop();
            } else {
              desiredTop = startPoint.getTop();
            }
          }
          if (isAllowVerticalDragging()) {
            if (startPoint.getLeft().intValue() > endPoint.getLeft().intValue()) {
              desiredLeft = endPoint.getLeft();
            } else {
              desiredLeft = startPoint.getLeft();
            }
          }

          DOMUtil.fastSetElementPosition(movablePanel.getElement(), desiredLeft, desiredTop);

          DropController newDropController = getIntersectDropController(context.mouseX, context.mouseY);
          if (context.dropController != newDropController) {
            if (context.dropController != null) {
              context.dropController.onLeave(context);
            }
            context.dropController = newDropController;
            if (context.dropController != null) {
              context.dropController.onEnter(context);
            }
          }

          if (context.dropController != null) {
            context.dropController.onMove(context);
          }

        } catch (Exception e) {
          LOG.info("Section (super) drag move error " + e.getMessage());
          e.printStackTrace();
        }
      }

      @Override
      public void dragEnd() {

        // If after dragging two or more neighbor Sections are aligned to the line
        // (they form one single line), those neighbor Sections are merged to one.
        if (Section.this.connector.sections.size() > 2) {
          if ((Section.this.connector.getPrevSection(Section.this) != null)
              && (Section.this.connector.getPrevSection(Section.this).hasNoDimensions())) {
            System.out.println("merge with preceding Section");
            // Loop 2 times to remove two preceding Sections
            try {
              for (int i = 0; i < 2; i++) {
                Section.this.startPoint = Section.this.connector.getPrevSection(Section.this).startPoint;
                Section.this.startPointDecoration =
                    Section.this.connector.getPrevSection(Section.this).startPointDecoration;
                Section.this.connector.getPrevSection(Section.this).removeFromDiagram();
                Section.this.connector.sections.remove(Section.this.connector.getPrevSection(Section.this));
              }
            } catch (Exception e) {
              // LOG.e("error merging sections", e);
            }
          }
          if ((Section.this.connector.getNextSection(Section.this) != null)
              && (Section.this.connector.getNextSection(Section.this).hasNoDimensions())) {
            System.out.println("merge with succeeding Section");
            // Loop 2 times to remove two succeeding Sections
            for (int i = 0; i < 2; i++) {
              try {
                Section.this.endPoint = Section.this.connector.getNextSection(Section.this).endPoint;
                Section.this.endPointDecoration =
                    Section.this.connector.getNextSection(Section.this).endPointDecoration;
                Section.this.connector.getNextSection(Section.this).removeFromDiagram();
                Section.this.connector.sections.remove(Section.this.connector.getNextSection(Section.this));
              } catch (Exception e) {
                // LOG.e("Error while connecting sections...");
              }
            }
          }
        }
        super.dragEnd();
        connector.updateCornerPoints();
      }

    };

    // Add line to given panel
    panel.add(this, Math.min(this.startPoint.getLeft(), this.endPoint.getLeft()), Math.min(this.startPoint.getTop(),
        this.endPoint.getTop()));
    this.sectionDragController.makeDraggable(this);
    this.sectionDragController.setBehaviorDragStartSensitivity(5);

    this.sectionDragController.addDragHandler(new DragHandlerAdapter() {
View Full Code Here

    if (getBehaviorDragProxy()) {
      movablePanel = newDragProxy(context);
      context.boundaryPanel.add(movablePanel, currentDraggableLocation.getLeft(), currentDraggableLocation.getTop());
    } else {
      saveSelectedWidgetsLocationAndStyle();
      AbsolutePanel container = new AbsolutePanel();
      DOM.setStyleAttribute(container.getElement(), "overflow", "visible");

      container.setPixelSize(context.draggable.getOffsetWidth(), context.draggable.getOffsetHeight());
      context.boundaryPanel.add(container, currentDraggableLocation.getLeft(), currentDraggableLocation.getTop());

      int draggableAbsoluteLeft = context.draggable.getAbsoluteLeft();
      int draggableAbsoluteTop = context.draggable.getAbsoluteTop();
      for (Iterator iterator = context.selectedWidgets.iterator(); iterator.hasNext();) {
        Widget widget = (Widget) iterator.next();
        if (widget != context.draggable) {
          int relativeX = widget.getAbsoluteLeft() - draggableAbsoluteLeft;
          int relativeY = widget.getAbsoluteTop() - draggableAbsoluteTop;
          container.add(widget, relativeX, relativeY);
        }
      }
      container.add(context.draggable, 0, 0);
      movablePanel = container;
    }
    movablePanel.addStyleName(PRIVATE_CSS_MOVABLE_PANEL);

    // one time calculation of boundary panel location for efficiency during dragging
View Full Code Here

   * @param context the current drag context
   * @return a new drag proxy
   */
  @SuppressWarnings("rawtypes")
  protected Widget newDragProxy(DragContext context) {
    AbsolutePanel container = new AbsolutePanel();
    DOM.setStyleAttribute(container.getElement(), "overflow", "visible");

    WidgetArea draggableArea = new WidgetArea(context.draggable, null);
    for (Iterator iterator = context.selectedWidgets.iterator(); iterator.hasNext();) {
      Widget widget = (Widget) iterator.next();
      WidgetArea widgetArea = new WidgetArea(widget, null);
      Widget proxy = new SimplePanel();
      proxy.setPixelSize(widget.getOffsetWidth(), widget.getOffsetHeight());
      proxy.addStyleName(PRIVATE_CSS_PROXY);
      container
          .add(proxy, widgetArea.getLeft() - draggableArea.getLeft(), widgetArea.getTop() - draggableArea.getTop());
    }

    return container;
  }
View Full Code Here

    // South, and West
    this.left =
        connectedWidget.getAbsoluteLeft() - connectedWidget.getParent().getAbsoluteLeft() - CP_MARGIN - offsetLeft;
    this.top = connectedWidget.getAbsoluteTop() - connectedWidget.getParent().getAbsoluteTop() - CP_MARGIN - offsetTop;

    connectionPointsPanel = new AbsolutePanel();

    this.add(connectionPointsPanel);

    connectionPointsPanel.setPixelSize(connectedWidget.getOffsetWidth() + CP_MARGIN * 2 + offsetLeft, connectedWidget
        .getOffsetHeight()
View Full Code Here

    return false;
  }

  public int getConnectedWidgetLeft() {
    if (this.isAttached()) {
      AbsolutePanel boundary = (AbsolutePanel) this.getParent();
      return connectedWidget.getAbsoluteLeft() - boundary.getAbsoluteLeft();
    } else {
      return -1;
    }
  }
View Full Code Here

    }
  }

  public int getConnectedWidgetTop() {
    if (this.isAttached()) {
      AbsolutePanel boundary = (AbsolutePanel) this.getParent();
      return connectedWidget.getAbsoluteTop() - boundary.getAbsoluteTop();
    } else {
      return -1;
    }
  }
View Full Code Here

   */

  public CollapsiblePanel() {

    // Create the composite widget.
    master = new AbsolutePanel() {
      {
        sinkEvents(Event.ONMOUSEOUT | Event.ONMOUSEOVER);
      }

      @Override
View Full Code Here

TOP

Related Classes of com.google.gwt.user.client.ui.AbsolutePanel

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.