+ if (e.button == MouseEvent.RIGHT_BUTTON && !nodes.isEmpty()) {
+ nodes.remove(nodes.size() - 1);
+ } else if (e.button == MouseEvent.LEFT_BUTTON) {
+ Point2D localPos = NodeUtil.worldToLocal(this, e.controlPosition, new Point2D.Double());
+ if (currentRouteNode == null && canStartEdge(localPos)) {
+ // ok, we can start from here
+ currentRouteNode = new DrawingNode();
+ currentRouteNode.routeNodes.add(new Point2D.Double(localPos.getX(), localPos.getY()));
+ nodes.add(currentRouteNode);
+ } else if (currentRouteNode != null && canStartEdge(localPos)) {
+ // let's commit our new routenode
+ currentRouteNode.routeNodes.add(new Point2D.Double(localPos.getX(), localPos.getY()));
+ Iterator<DrawingNode> nodeIter = nodes.iterator();
+ while (nodeIter.hasNext()) {
+ createEdge(nodeIter.next());
+ }
+ currentRouteNode = null;
+ nodes.clear();
+ } else if (currentRouteNode != null) {
+ currentRouteNode.routeNodes.add(new Point2D.Double(localPos.getX(), localPos.getY()));
+ }