public class PickSupport
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected int[] |
minAndMaxColorCodes
Indicates the minimum and maximum color code associated with the picked objects in the pickableObjects map.
|
protected java.util.Map<Range,PickedObjectFactory> |
pickableObjectRanges
The picked object color code ranges currently registered with this PickSupport, represented as a map of color
code ranges to picked object factories.
|
protected java.util.Map<java.lang.Integer,PickedObject> |
pickableObjects
The picked objects currently registered with this PickSupport, represented as a map of color codes to picked
objects.
|
Constructor and Description |
---|
PickSupport() |
Modifier and Type | Method and Description |
---|---|
void |
addPickableObject(int colorCode,
java.lang.Object o) |
void |
addPickableObject(int colorCode,
java.lang.Object o,
Position position) |
void |
addPickableObject(int colorCode,
java.lang.Object o,
Position position,
boolean isTerrain) |
void |
addPickableObject(PickedObject po) |
void |
addPickableObjectRange(int colorCode,
int count,
PickedObjectFactory factory)
Associates a collection of picked objects with a range of pick colors.
|
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,
java.awt.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,
java.awt.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 java.util.Map<Range,PickedObjectFactory> |
getPickableObjectRanges() |
protected java.util.Map<java.lang.Integer,PickedObject> |
getPickableObjects() |
int |
getTopColor(DrawContext dc,
java.awt.Point pickPoint)
Returns the framebuffer RGB color for a point in AWT screen coordinates, formatted as a pick color code.
|
PickedObject |
getTopObject(DrawContext dc,
java.awt.Point pickPoint) |
protected boolean |
hasPickableObjects() |
protected PickedObject |
lookupPickableObject(int colorCode) |
PickedObject |
resolvePick(DrawContext dc,
java.awt.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.
|
protected int[] minAndMaxColorCodes
null
, indicating that the minimum and maximum color codes are unknown.protected java.util.Map<Range,PickedObjectFactory> pickableObjectRanges
protected java.util.Map<java.lang.Integer,PickedObject> pickableObjects
public void addPickableObject(int colorCode, java.lang.Object o)
public void addPickableObject(int colorCode, java.lang.Object o, Position position)
public void addPickableObject(int colorCode, java.lang.Object o, Position position, boolean isTerrain)
public void addPickableObject(PickedObject po)
public void addPickableObjectRange(int colorCode, int count, PickedObjectFactory factory)
colorCode
- the first color code associated with the range of sequential color codes.count
- the number of sequential color codes in the range of sequential color codes.factory
- the PickedObjectFactory to use when creating a PickedObject for a color in the specified range.protected void adjustExtremeColorCodes(int colorCode)
colorCode
- the code used to adjust the current min and max codes.public static boolean areSelectionsTheSame(PickedObject a, PickedObject b)
a
- the first picked object.b
- the second picked object.public void beginPicking(DrawContext dc)
public void clearPickList()
protected PickedObject doResolvePick(DrawContext dc, java.awt.Point pickPoint, Layer layer)
dc
- the draw context which receives the picked object.pickPoint
- the point in AWT screen coordinates.layer
- the layer associated with the picked object.null
if no picked object is drawn at the
specified point.protected void doResolvePick(DrawContext dc, java.awt.Rectangle pickRect, Layer layer)
dc
- the draw context which receives the picked objects.pickRect
- the rectangle in AWT screen coordinates.layer
- the layer associated with the picked objects.public void endPicking(DrawContext dc)
protected java.util.Map<Range,PickedObjectFactory> getPickableObjectRanges()
protected java.util.Map<java.lang.Integer,PickedObject> getPickableObjects()
public int getTopColor(DrawContext dc, java.awt.Point pickPoint)
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.
dc
- the draw context to return a color for.pickPoint
- the point to return a color for, in AWT screen coordinates.public PickedObject getTopObject(DrawContext dc, java.awt.Point pickPoint)
protected boolean hasPickableObjects()
protected PickedObject lookupPickableObject(int colorCode)
public PickedObject resolvePick(DrawContext dc, java.awt.Point pickPoint, Layer layer)
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.
dc
- the draw context which receives the picked object.pickPoint
- the point in AWT screen coordinates.layer
- the layer associated with the picked object.null
if no picked object is drawn at the
specified point.