NASA World Wind

gov.nasa.worldwind.pick
Class PickSupport

java.lang.Object
  extended by gov.nasa.worldwind.pick.PickSupport
Direct Known Subclasses:
Path.PathPickSupport

public class PickSupport
extends Object


Field Summary
protected  int[] minAndMaxColorCodes
          Indicates the minimum and maximum color code associated with the picked objects in the pickableObjects map.
protected  Map<Integer,PickedObject> pickableObjects
          The picked objects currently registered with this PickSupport, represented as a map of color codes to picked objects.
 
Constructor Summary
PickSupport()
           
 
Method Summary
 void addPickableObject(int colorCode, Object o)
           
 void addPickableObject(int colorCode, Object o, Position position)
           
 void addPickableObject(int colorCode, Object o, Position position, boolean isTerrain)
           
 void addPickableObject(PickedObject po)
           
protected  void adjustExtremeColorCodes(int colorCode)
          Adjust this PickSupport's minimum and maximum color codes by decreasing and increasing each extreme, respectively, according to the specified code.
static boolean areSelectionsTheSame(PickedObject a, PickedObject b)
          Indicates whether two picked objects refer to the same user object.
 void beginPicking(DrawContext dc)
           
 void clearPickList()
           
protected  PickedObject doResolvePick(DrawContext dc, Point pickPoint, Layer layer)
          Adds a picked object registered with this PickSupport that is drawn at the specified point in AWT screen coordinates (if one exists) to the draw context's list of picked objects.
protected  void doResolvePick(DrawContext dc, Rectangle pickRect, Layer layer)
          Adds all picked objects that are registered with this PickSupport and intersect the specified rectangle in AWT screen coordinates (if any) to the draw context's list of picked objects.
 void endPicking(DrawContext dc)
           
protected  Map<Integer,PickedObject> getPickableObjects()
           
 int getTopColor(DrawContext dc, Point pickPoint)
          Returns the framebuffer RGB color for a point in AWT screen coordinates, formatted as a pick color code.
 PickedObject getTopObject(DrawContext dc, Point pickPoint)
           
 PickedObject resolvePick(DrawContext dc, Point pickPoint, Layer layer)
          Adds picked object registered with this PickSupport that are drawn at the specified pick point or intersect the draw context's pick rectangle to the draw context's list of picked objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

minAndMaxColorCodes

protected int[] minAndMaxColorCodes
Indicates the minimum and maximum color code associated with the picked objects in the pickableObjects map. Initially null, indicating that the minimum and maximum color codes are unknown.


pickableObjects

protected Map<Integer,PickedObject> pickableObjects
The picked objects currently registered with this PickSupport, represented as a map of color codes to picked objects. This maps provides constant time access to a picked object when its color code is known.

Constructor Detail

PickSupport

public PickSupport()
Method Detail

addPickableObject

public void addPickableObject(int colorCode,
                              Object o)

addPickableObject

public void addPickableObject(int colorCode,
                              Object o,
                              Position position)

addPickableObject

public void addPickableObject(int colorCode,
                              Object o,
                              Position position,
                              boolean isTerrain)

addPickableObject

public void addPickableObject(PickedObject po)

adjustExtremeColorCodes

protected void adjustExtremeColorCodes(int colorCode)
Adjust this PickSupport's minimum and maximum color codes by decreasing and increasing each extreme, respectively, according to the specified code. If the minimum and maximum color codes are unknown, both the minimum and maximum color codes are set to the specified code.

Parameters:
colorCode - the code used to adjust the current min and max codes.

areSelectionsTheSame

public static boolean areSelectionsTheSame(PickedObject a,
                                           PickedObject b)
Indicates whether two picked objects refer to the same user object.

Parameters:
a - the first picked object.
b - the second picked object.
Returns:
true if both objects are not null and they refer to the same user object, otherwise false.

beginPicking

public void beginPicking(DrawContext dc)

clearPickList

public void clearPickList()

doResolvePick

protected PickedObject doResolvePick(DrawContext dc,
                                     Point pickPoint,
                                     Layer layer)
Adds a picked object registered with this PickSupport that is drawn at the specified point in AWT screen coordinates (if one exists) to the draw context's list of picked objects.

Parameters:
dc - the draw context which receives the picked object.
pickPoint - the point in AWT screen coordinates.
layer - the layer associated with the picked object.
Returns:
the picked object added to the draw context, or null if no picked object is drawn at the specified point.

doResolvePick

protected void doResolvePick(DrawContext dc,
                             Rectangle pickRect,
                             Layer layer)
Adds all picked objects that are registered with this PickSupport and intersect the specified rectangle in AWT screen coordinates (if any) to the draw context's list of picked objects.

Parameters:
dc - the draw context which receives the picked objects.
pickRect - the rectangle in AWT screen coordinates.
layer - the layer associated with the picked objects.

endPicking

public void endPicking(DrawContext dc)

getPickableObjects

protected Map<Integer,PickedObject> getPickableObjects()

getTopColor

public int getTopColor(DrawContext dc,
                       Point pickPoint)
Returns the framebuffer RGB color for a point in AWT screen coordinates, formatted as a pick color code. The red, green, and blue components are each stored as an 8-bit unsigned integer, and packed into bits 0-23 of the returned integer as follows: bits 16-23 are red, bits 8-15 are green, and bits 0-7 are blue. This format is consistent with the RGB integers used to create the pick colors.

This returns 0 if the point is null, if the point contains the clear color, or if the point is outside the draw context's drawable area.

Parameters:
dc - the draw context to return a color for.
pickPoint - the point to return a color for, in AWT screen coordinates.
Returns:
the RGB color corresponding to the specified point.

getTopObject

public PickedObject getTopObject(DrawContext dc,
                                 Point pickPoint)

resolvePick

public PickedObject resolvePick(DrawContext dc,
                                Point pickPoint,
                                Layer layer)
Adds picked object registered with this PickSupport that are drawn at the specified pick point or intersect the draw context's pick rectangle to the draw context's list of picked objects. This clears any registered picked objects upon returning.

If this pick point is null, this ignores the pick point and does not attempt to determine which picked objects are drawn there. If the draw context's pick rectangle is null, this ignores the pick rectangle and does not attempt to determine which picked objects intersect it. This does nothing if no picked objects are currently registered with this PickSupport.

Parameters:
dc - the draw context which receives the picked object.
pickPoint - the point in AWT screen coordinates.
layer - the layer associated with the picked object.
Returns:
the picked object added to the draw context, or null if no picked object is drawn at the specified point.

NASA World Wind