NodePresenter(VGraphExplorer parent, NodeProxy model) { this.parent = parent; this.model = model; graph = parent.getGraph(); view.setTitle(model.getId()); Style style = view.getElement().getStyle(); style.setLeft(model.getX(), Unit.PX); style.setTop(model.getY(), Unit.PX); view.addDomHandler(this, MouseDownEvent.getType()); view.addDomHandler(this, MouseMoveEvent.getType()); view.addDomHandler(this, MouseUpEvent.getType()); parent.add(view); }
public void onMouseUp(MouseUpEvent event) { Element element = view.getElement(); if (!isDragging()) { updateCSS(); limitToBoundingBox(); if (NodeProxy.EXPANDED.equals(model.getState())) { model.setState(NodeProxy.COLLAPSED); for (NodeProxy neighbor : graph.getNeighbors(model)) { boolean collapsed = NodeProxy.COLLAPSED.equals(neighbor.getState()); boolean leafNode = graph.degree(neighbor) == 1; if (collapsed && leafNode) { graph.removeNode(neighbor); } } } parent.toggle(model); } else { parent.save(model, true); setDragging(false); } setMouseDown(false); DOM.releaseCapture(element); event.preventDefault(); }
public HandlerRegistration addMouseUpHandler(MouseUpHandler handler) { return addDomHandler(handler, MouseUpEvent.getType()); }