Search in sources :

Example 1 with HitInfoFactory

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);
}
Also used : Graph2DView(y.view.Graph2DView) HitInfo(y.view.HitInfo) HitInfoFactory(y.view.HitInfoFactory)

Aggregations

Graph2DView (y.view.Graph2DView)1 HitInfo (y.view.HitInfo)1 HitInfoFactory (y.view.HitInfoFactory)1