Search this API

y.view
Class HitInfoFactories.DefaultHitInfoFactory

java.lang.Object
  extended by y.view.HitInfoFactories.DefaultHitInfoFactory
All Implemented Interfaces:
HitInfoFactory
Enclosing class:
HitInfoFactories

public static class HitInfoFactories.DefaultHitInfoFactory
extends java.lang.Object
implements HitInfoFactory

This hit info factory creates hit information which use the reversed paint order of the view. As an exception, if a node label which is not selected would be returned as the first hit and node labels are among the types to be returned and the owning node of the label is also at the hit location, then the node is returned instead of the node label.

 

Constructor Summary
HitInfoFactories.DefaultHitInfoFactory(Graph2DView view)
          Initializes a new DefaultHitInfoFactory instance that test the elements of the graph that is associated to the specified graph view for hits.
 
Method Summary
 HitInfo createHitInfo(double x, double y, int types, boolean firstHitOnly)
          Creates a hit info for a given type of graph elements at the specified location.
protected  HitInfo createHitInfo(Graph2DView view, Graph2D graph, double x, double y, int elementTypes, boolean firstHitOnly)
          Creates a hit information object for a given type of graph elements at the specified location.
protected  Graph2D getGraph()
          Returns the graph whose elements are checked for hits in createHitInfo(double, double, int, boolean).
protected  Graph2DView getView()
          Returns the graph view that is associated to this factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HitInfoFactories.DefaultHitInfoFactory

public HitInfoFactories.DefaultHitInfoFactory(Graph2DView view)
Initializes a new DefaultHitInfoFactory instance that test the elements of the graph that is associated to the specified graph view for hits.

Parameters:
view - the Graph2DView whose graph is checked for hits.
Method Detail

createHitInfo

public HitInfo createHitInfo(double x,
                             double y,
                             int types,
                             boolean firstHitOnly)
Creates a hit info for a given type of graph elements at the specified location. A hit info provides information on the graph elements at the given world coordinates.

This implementation returns a

 new HitInfo(getGraph(), iterator, x, y, firstHitOnly)
 
where the iterator iterates over the graph elements of the specified types in the reversed paint order of the view.

As an exception, if a node label which is not selected would be returned as the first hit only and node ports and/or nodes are among the types to be returned and the node port associated to the label/the owning node of the label is also at the hit location, then the associated node port/the owning node is returned instead of the node label.

Specified by:
createHitInfo in interface HitInfoFactory
Parameters:
x - x world coordinate
y - y world coordinate
types - a bitwise combination of the type masks provided by Graph2DTraversal or Graph2DTraversal.ALL.
firstHitOnly - if true only the hit info only considers the first graph element at the specified coordinates
Returns:
a collection of elements at the specified location.

createHitInfo

protected HitInfo createHitInfo(Graph2DView view,
                                Graph2D graph,
                                double x,
                                double y,
                                int elementTypes,
                                boolean firstHitOnly)
Creates a hit information object for a given type of graph elements at the specified location.

Parameters:
view - the view whose rendering order determines the order in which elements are checked for hits.

This implementation returns a

 new HitInfo(graph, iterator, x, y, firstHitOnly)
 
where the iterator iterates over the graph elements of the specified types in the reversed paint order of the view.

Called from createHitInfo(double, double, int, boolean).

graph - the graph whose elements are checked for hits.
x - the x-coordinate of the hit location.
y - the y-coordinate of the hit location.
elementTypes - determines the types of graph elements that should be checked for hits. The elementTypes argument is a bitwise combination of the type masks provided by Graph2DTraversal or Graph2DTraversal.ALL.
firstHitOnly - if true only the first element at the specified location is returned; otherwise all elements at the specified location are returned.
Returns:
a collection of elements at the specified location.

getView

protected Graph2DView getView()
Returns the graph view that is associated to this factory.

Returns:
the Graph2DView associated to this factory.

getGraph

protected Graph2D getGraph()
Returns the graph whose elements are checked for hits in createHitInfo(double, double, int, boolean).

Returns:
the Graph2D associated to the factory's graph view.

© Copyright 2000-2022,
yWorks GmbH.
All rights reserved.