use of y.view.HitInfoFactory in project binnavi by google.
the class ZyGraphDragAndDropSupport method getDragOverState.
/**
* Determine the drag over state for the given location, i.e. the object under the cursor.
*
* @param graph The zygraph for which to determine the drag over state.
* @param location The location where to query the drag over state.
* @return The drag over state for the zygraph at the given location.
*/
public static DragOverState getDragOverState(final ZyGraph graph, final Point location) {
final Graph2DView view = graph.getView();
final double worldX = view.toWorldCoordX((int) location.getX());
final double worldY = view.toWorldCoordY((int) location.getY());
final HitInfoFactory factory = view.getHitInfoFactory();
final HitInfo hit = factory.createHitInfo(worldX, worldY, Graph2DTraversal.NODES, true);
if (hit.hasHitNodes()) {
final NaviNode naviNode = graph.getMappings().getNode(hit.getHitNode());
if (naviNode != null) {
return new DragOverState(naviNode, ZyNodeContentHelpers.getObjectWrapper(naviNode, worldX, worldY));
}
}
return new DragOverState(null, null);
}
Aggregations