2 Copyright (C) 2001, 2006 United States Government
3 as represented by the Administrator of the
4 National Aeronautics and Space Administration.
7 package gov
.nasa
.worldwind
.pick
;
9 import gov
.nasa
.worldwind
.avlist
.*;
10 import gov
.nasa
.worldwind
.geom
.*;
11 import gov
.nasa
.worldwind
.layers
.Layer
;
17 * @version $Id: PickedObject Feb 5, 2007 12:47:00 AM
19 public class PickedObject
extends AVListImpl
21 private final Point pickPoint
;
22 private final int colorCode
;
23 private final Object userObject
;
24 private boolean isOnTop
= false;
25 private boolean isTerrain
= false;
27 public PickedObject(int colorCode
, Object userObject
)
31 this.pickPoint
= null;
32 this.colorCode
= colorCode
;
33 this.userObject
= userObject
;
35 this.isTerrain
= false;
38 public PickedObject(int colorCode
, Object userObject
, Position position
, boolean isTerrain
)
42 this.pickPoint
= null;
43 this.colorCode
= colorCode
;
44 this.userObject
= userObject
;
46 this.isTerrain
= isTerrain
;
47 this.setPosition(position
);
50 public PickedObject(Point pickPoint
, int colorCode
, Object userObject
, Angle lat
, Angle lon
, double elev
,
55 this.pickPoint
= pickPoint
;
56 this.colorCode
= colorCode
;
57 this.userObject
= userObject
;
59 this.isTerrain
= isTerrain
;
60 this.setPosition(new Position(lat
, lon
, elev
));
63 public Point
getPickPoint()
68 public int getColorCode()
70 return this.colorCode
;
73 public Object
getObject()
78 public void setOnTop()
83 public boolean isOnTop()
88 public boolean isTerrain()
90 return this.isTerrain
;
93 public void setParentLayer(Layer layer
)
95 this.setValue(AVKey
.PICKED_OBJECT_PARENT_LAYER
, layer
);
98 public Layer
getParentLayer()
100 return (Layer
) this.getValue(AVKey
.PICKED_OBJECT_PARENT_LAYER
);
103 public void setPosition(Position position
)
105 this.setValue(AVKey
.POSITION
, position
);
108 public Position
getPosition()
110 return (Position
) this.getValue(AVKey
.POSITION
);
113 public boolean hasPosition()
115 return this.hasKey(AVKey
.POSITION
);
118 public boolean equals(Object o
)
122 if (o
== null || getClass() != o
.getClass())
125 PickedObject that
= (PickedObject
) o
;
127 if (colorCode
!= that
.colorCode
)
129 if (isOnTop
!= that
.isOnTop
)
131 //noinspection RedundantIfStatement
132 if (userObject
!= null ?
!userObject
.equals(that
.userObject
) : that
.userObject
!= null)
138 public int hashCode()
142 result
= 31 * result
+ (userObject
!= null ? userObject
.hashCode() : 0);
143 result
= 31 * result
+ (isOnTop ?
1 : 0);