public void nodeOrEdgeSelectionChanged() { final String[] edges = new String[graph.getSelectedEdges().size()]; final String[] nodes = new String[graph.getSelectedShapes().size()]; int i = 0; for (final VEdge vedge : graph.getSelectedEdges()) { edges[i] = vedge.toString(); ++i; } i = 0; for (final VNode vnode : graph.getSelectedShapes()) { nodes[i] = vnode.toString(); ++i; } client.updateVariable(paintableId, "selectedEdges", edges, false); client.updateVariable(paintableId, "selectedNodes", nodes, true); }
public void updateFromUIDL(final UIDL uidl, final ApplicationConnection client) { if (!started) { started = true; client.updateVariable(uidl.getId(), "AppStarted", true, true); } }
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); }
@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); }
private void zoom(final double factor) { if (factor < 1) { zoomFactor--; } else { zoomFactor++; } for (final VNode n : graph.getPaintedShapes()) { n.setX((float) ((n.getX() - centerX) * factor) + centerX); n.setY((float) ((n.getY() - centerY) * factor) + centerY); if (n.getView() instanceof Circle) { if (factor > 1) { ((Circle) n.getView()).setRadius((((Circle) n.getView()).getRadius() + 1)); } else { ((Circle) n.getView()).setRadius((((Circle) n.getView()).getRadius() - 1)); } } graph.updateEdges(n, false); } client.updateVariable(paintableId, "zoomFactor", zoomFactor, true); }
/** Override the method to communicate the new value to server. */ @Override public void setColor(String newcolor) { // Ignore if no change if (newcolor.equals(currentcolor.getText())) { return; } // Let the original implementation to do whatever it needs to do super.setColor(newcolor); // Updating the state to the server can not be done before // the server connection is known, i.e., before updateFromUIDL() // has been called. if (uidlId == null || client == null) { return; } // Communicate the user interaction parameters to server. This call will // initiate an AJAX request to the server. client.updateVariable(uidlId, "colorname", newcolor, true); }
private void deleteEdge(final VEdge edge, final boolean immediate) { client.updateVariable(paintableId, "removedEdge", edge.getName(), immediate); graph.removeEdge(edge); }
public void deleteNode(final VNode node, final boolean immediate) { client.updateVariable(paintableId, "removedNode", node.getName(), immediate); graph.removeNode(node); }
private void updateValueToServer() { client.updateVariable(id, "value", value.doubleValue(), immediate); }