public Node(LayoutModel<N> layoutModel) { super(layoutModel); this.accessor = new RadiusNetworkNodeAccessor<>(); }
/** * @param layoutModel * @param p the pick point * @return the node associated with location p */ @Override public N getNode(LayoutModel<N> layoutModel, Point p) { return getNode(layoutModel, p.x, p.y); }
@Override public void visit(LayoutModel<N> layoutModel) { if (log.isTraceEnabled()) { log.trace("visiting {}", layoutModel); } super.visit(layoutModel); this.elementAccessor = new RadiusNetworkNodeAccessor<>(); initialize(); }
@Override public N getClosestElement(double x, double y) { if (!isActive()) { return fallback.getNode(layoutModel, x, y); } Collection<TreeNode> leafs = getContainingLeafs(x, y); if (leafs.size() != 0) { TreeNode leaf = leafs.iterator().next(); Rectangle2D area = leaf.getBounds(); double radius = area.getWidth(); N closest = null; while (closest == null) { double diameter = radius * 2; Ellipse2D searchArea = new Ellipse2D.Double(x - radius, y - radius, diameter, diameter); Collection<N> nodes = getVisibleElements(searchArea); closest = getClosest(nodes, x, y, radius); // if I have already considered all of the nodes in the graph // (in the spatialquadtree) there is no reason to enlarge the // area and try again if (nodes.size() >= layoutModel.getGraph().nodes().size()) { break; } // double the search area size and try again radius *= 2; } return closest; } return null; } /**
protected AbstractSpatial(LayoutModel<NT> layoutModel) { this.layoutModel = layoutModel; if (layoutModel != null) { this.rectangle = new Rectangle2D.Double(0, 0, layoutModel.getWidth(), layoutModel.getHeight()); this.fallback = new RadiusNetworkNodeAccessor(); } }
public N getClosestElement(double x, double y) { if (!isActive()) { return fallback.getNode(layoutModel, x, y);
SpatialRTree.Nodes<String> tree) { vv.getPickedNodeState().clear(); NetworkNodeAccessor<String> slowWay = new RadiusNetworkNodeAccessor<>(Double.MAX_VALUE);
if (!isActive() || !rtree.getRoot().isPresent()) { return fallback.getNode(layoutModel, x, y);
Spatial<String> tree) { vv.getPickedNodeState().clear(); NetworkNodeAccessor<String> slowWay = new RadiusNetworkNodeAccessor<>(Double.MAX_VALUE);
Spatial<String> tree) { vv.getPickedNodeState().clear(); NetworkNodeAccessor<String> slowWay = new RadiusNetworkNodeAccessor<>(Double.MAX_VALUE);
SpatialQuadTree<String> tree) { vv.getPickedNodeState().clear(); NetworkNodeAccessor<String> slowWay = new RadiusNetworkNodeAccessor<>(Double.MAX_VALUE);