コード例 #1
0
ファイル: VCytographer.java プロジェクト: osmax/vaadin-graph
  @Override
  public void onMouseDown(final MouseDownEvent event) {
    VConsole.log("onMouseDown");
    extractSelection();
    removeSelectionBox();

    if (currentKeyModifiers.contains(KeyCodes.KEY_CTRL)) {
      selectionBox.setSelectionBoxStartX(event.getX());
      selectionBox.setSelectionBoxStartY(event.getY());
      selectionBox.setSelectionBoxVisible(true);
      VConsole.log(
          "onMouseDown - selection started:"
              + selectionBox.getSelectionBoxStartX()
              + ","
              + selectionBox.getSelectionBoxStartY());
    } else if (event.getSource() instanceof VNode) {
      onMove = false;
    } else if (event.getSource() instanceof DrawingArea) {
      onMove = true;
      startX = event.getX();
      startY = event.getY();
      VConsole.log("onMouseDown - moving");
    } else {
      VConsole.error("onMouseDown - UNKNOWN STATE");
    }
  }
コード例 #2
0
  private void setStartNodeAndOuterLimits(Element root, Node node1, Node node2) {
    List<Node> node1Parents = getParents(root, node1);
    List<Node> node2Parents = getParents(root, node2);

    if (!node1Parents.isEmpty()
        && !node2Parents.isEmpty()
        && (node1Parents.get(0).equals(node2Parents.get(0)))) {

      int idx = 0;

      // the smaller size of the two lists of parents is the maximum parent index
      // we can check (for greater index numbers there is no partner parent to check against)
      int maxParentIdx = Math.min(node1Parents.size(), node2Parents.size());

      VConsole.log("maxParentIdx: " + maxParentIdx);

      DebugUtil.printNodes("node1Parents", node1Parents);
      DebugUtil.printNodes("node2Parents", node2Parents);

      // find the closest common parent node
      for (; idx < maxParentIdx; idx++) {

        VConsole.log("searching for the closest common parent, checking index: " + idx);
        if (!node1Parents.get(idx).equals(node2Parents.get(idx))) {
          // ok, the last one was the closest, because now we are no longer on the common branch
          break;
        }
      }

      startNode =
          node1Parents.get(idx - 1); // get the last common parent node, which is the closest

      // is one of the node a parent of the other?
      if (idx == maxParentIdx) {
        // one of the nodes is not a text node since text nodes cannot have children
        throw new IllegalStateException("idx==maxParentIdx, should not happen");
      } else {
        // if the second node's index is larger than the index of the first node
        // from their parents point of view, then the first node is on the outer left side of
        // the subtree and the second node is on the outer right side of the subtree;
        // in the other case the positions are swapped
        isAfter =
            indexOf(startNode, node2Parents.get(idx)) > indexOf(startNode, node1Parents.get(idx));

        if (isAfter) {
          outerLeftNode = node1;
          outerRightNode = node2;
        } else {
          outerLeftNode = node2;
          outerRightNode = node1;
        }
      }
    }
  }
コード例 #3
0
 public void disconnected() {
   VConsole.log("WS Disconnected");
   // re-open immediately if timeout happened
   // TODO I guess this should be configurable for different use cases
   // TODO how to handle windows forgotten open ?
   getWebSocket();
 }
コード例 #4
0
  public void onRemoveFromModel() {

    VConsole.log("NodePresenter.onRemoveFromModel()");

    model.setController(null);
    view.removeFromParent();
  }
コード例 #5
0
 @Override
 public void start() {
   VConsole.log("No real start here");
   /*
    * NOP, init when web sockect connected
    */
 }
コード例 #6
0
ファイル: VCytographer.java プロジェクト: osmax/vaadin-graph
 public void startLinkingFrom(final VNode node) {
   VConsole.log("onlink");
   onLink = true;
   linkNode = node;
   startX = node.getX();
   startY = node.getY();
 }
コード例 #7
0
  public Number unformat(String text) {
    Number result = null;
    if (text != null && !"".equals(text.trim())) {
      try {

        // FIXME CONTROLLARE!!
        if (groupingSeparator == '.') {
          String[] temp = text.split("\\.");
          if (
          /* NOT */ !(temp.length == 2 && (temp[1].length() != 3))) {
            text = removeChar(text, groupingSeparator);
          }
        }
        text = text.replace(decimalsSeparator, '.');
        BigDecimal bigDecimal = new BigDecimal(text);
        bigDecimal = bigDecimal.setScale(getScale(), DEFAULT_ROUNDING_MODE);

        result = bigDecimal;
      } catch (Exception e) {
        VConsole.log(e);

        result = -1;
      }
    }

    return result;
  }
コード例 #8
0
ファイル: VCytographer.java プロジェクト: osmax/vaadin-graph
 @Override
 public void onKeyUp(final KeyUpEvent event) {
   VConsole.log("KeyUpEvent");
   if (currentKeyModifiers.contains(KeyCodes.KEY_CTRL)) {
     removeSelectionBox();
   }
   currentKeyModifiers.clear();
 }
コード例 #9
0
ファイル: VCytographer.java プロジェクト: osmax/vaadin-graph
 private void removeSelectionBox() {
   if (selectionBox.isSelectionBoxVisible()) {
     canvas.remove(selectionBox);
     selectionBox.setSelectionBoxVisible(false);
     VConsole.log("selection box removed from canvas");
     selectionBox.setSelectionBoxRightHandSide(true);
   }
 }
コード例 #10
0
ファイル: VCytographer.java プロジェクト: osmax/vaadin-graph
 public void constructLinkTo(final VNode node2) {
   VConsole.log("linked");
   final String name =
       linkNode.getName() + "_to_" + node2.getName() + "_" + new Random().nextInt(1000);
   final VEdge edge = VEdge.createAnEdge(null, this, graph, name, linkNode, node2, style);
   client.updateVariable(
       paintableId, "edgeCreated", new String[] {linkNode.getName(), node2.getName(), name}, true);
   graph.addEdge(edge);
 }
コード例 #11
0
ファイル: VCytographer.java プロジェクト: osmax/vaadin-graph
 @Override
 public void onDoubleClick(final DoubleClickEvent event) {
   VConsole.log("onDoubleClick");
   final int x = event.getX();
   final int y = event.getY();
   final VNode node = VNode.createANode(x, y, this, graph, style);
   graph.addNode(node);
   client.updateVariable(paintableId, "createdANode", new Object[] {node.getName(), x, y}, true);
 }
コード例 #12
0
ファイル: VCytographer.java プロジェクト: osmax/vaadin-graph
 @Override
 public void onClick(final ClickEvent event) {
   VConsole.log("onClick");
   removeLinkLine();
   onMove = false;
   removeMenu();
   extractSelection();
   removeSelectionBox();
 }
コード例 #13
0
ファイル: VCytographer.java プロジェクト: osmax/vaadin-graph
 private void extractSelection() {
   final int x1 = selectionBox.getSelectionBoxStartX();
   final int y1 = selectionBox.getSelectionBoxStartY();
   if (selectionBox.isSelectionBoxVisible()) {
     final int x2 = x1 + selectionBox.getWidth();
     final int y2 = y1 + selectionBox.getHeight();
     VConsole.log("selectNodesAndEdgesInTheBox: " + x1 + "," + y1 + " " + x2 + "," + y2);
     selectNodesAndEdgesInTheBox(x1, y1, x2, y2);
   }
 }
コード例 #14
0
ファイル: VCytographer.java プロジェクト: osmax/vaadin-graph
 @Override
 public void onMouseUp(final MouseUpEvent event) {
   VConsole.log("onMouseUp");
   extractSelection();
   removeSelectionBox();
   graph.setMovedShape(null);
   onMove = false;
   startX = 0;
   startY = 0;
 }
コード例 #15
0
 public void message(String message) {
   if (!ownRequestPending) {
     startRequest();
     VConsole.log("Changeset pushed by the server");
   } else {
     ownRequestPending = false;
   }
   final Date start = new Date();
   message = "{" + message + "}";
   VConsole.log("Received socket message:");
   ValueMap json = evaluateUIDL(message);
   if (applicationRunning) {
     handleUIDLMessage(start, message, json);
   } else {
     applicationRunning = true;
     handleWhenCSSLoaded(message, json);
     ApplicationConfiguration.startNextApplication();
   }
 }
コード例 #16
0
ファイル: VSliderComp.java プロジェクト: e-gius/catma
 private void processHandleEvent(Event event) {
   switch (DOM.eventGetType(event)) {
     case Event.ONMOUSEDOWN:
     case Event.ONTOUCHSTART:
       if (!disabled && !readonly) {
         focus();
         feedbackPopup.show();
         dragging = true;
         DOM.setElementProperty(
             handle, "className", CLASSNAME + "-handle " + CLASSNAME + "-handle-active");
         DOM.setCapture(getElement());
         DOM.eventPreventDefault(event); // prevent selecting text
         DOM.eventCancelBubble(event, true);
         event.stopPropagation();
         VConsole.log("Slider move start");
       }
       break;
     case Event.ONMOUSEMOVE:
     case Event.ONTOUCHMOVE:
       if (dragging) {
         VConsole.log("Slider move");
         setValueByEvent(event, false);
         updateFeedbackPosition();
         event.stopPropagation();
       }
       break;
     case Event.ONTOUCHEND:
       feedbackPopup.hide();
     case Event.ONMOUSEUP:
       // feedbackPopup.hide();
       VConsole.log("Slider move end");
       dragging = false;
       DOM.setElementProperty(handle, "className", CLASSNAME + "-handle");
       DOM.releaseCapture(getElement());
       setValueByEvent(event, true);
       event.stopPropagation();
       break;
     default:
       break;
   }
 }
コード例 #17
0
 private WebSocket getWebSocket() {
   if (ws == null) {
     // if timed out or not started, create websocket to server
     String replaceFirst2 = GWT.getHostPageBaseURL().replaceFirst("http", "ws");
     replaceFirst2 = replaceFirst2.substring(0, replaceFirst2.length() - 1);
     replaceFirst2 += getConfiguration().getApplicationUri() + "UIDL";
     VConsole.log(replaceFirst2);
     ws = WebSocket.bind(replaceFirst2);
     ws.setListener(_cb);
   }
   return ws;
 }
コード例 #18
0
 @Override
 protected void makeUidlRequest(String requestData, String extraParams, boolean forceSync) {
   VConsole.log("new Socket message: " + requestData);
   if (forceSync) {
     /*
      * TODO figure out if socket can be used on unload.
      */
     super.makeUidlRequest(requestData, extraParams, forceSync);
   } else {
     startRequest();
     ownRequestPending = true;
     getWebSocket().send(extraParams + "#" + requestData);
   }
 }
コード例 #19
0
ファイル: VNode.java プロジェクト: AKSW/SAIM
  public void addValue1(VCytoprocess vcypro, String name, Double value) {
    if (LOG) VConsole.log("VNode: addValue1");

    if (label1 == null) {

      if (!name.trim().isEmpty()) {
        label1 =
            vcypro.text(name + ": " + value, shape.getX(), shape.getY() + label.getTextHeight());

        setStyle(label, label1);
        value1 = value;
      }
    } else if (!name.trim().isEmpty()) label1.setText(name + ": " + value);

    bringToFront(vcypro.getCanvas());
  }
コード例 #20
0
 public void connected() {
   VConsole.log("WS Connected");
   if (!applicationRunning) {
     repaintAll();
   }
 }