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
;
15 * @version $Id: PickedObject Feb 5, 2007 12:47:00 AM
17 public class PickedObject
extends AVListImpl
19 private final int colorCode
;
20 private final Object userObject
;
21 private boolean isOnTop
= false;
22 private boolean isTerrain
= false;
24 public PickedObject(int colorCode
, Object userObject
)
27 this.colorCode
= colorCode
;
28 this.userObject
= userObject
;
30 this.isTerrain
= false;
33 public PickedObject(int colorCode
, Object userObject
, Position position
, boolean isTerrain
)
37 this.colorCode
= colorCode
;
38 this.userObject
= userObject
;
40 this.isTerrain
= isTerrain
;
41 this.setPosition(position
);
44 public PickedObject(int colorCode
, Object userObject
, Angle lat
, Angle lon
, double elev
, boolean isTerrain
)
48 this.colorCode
= colorCode
;
49 this.userObject
= userObject
;
51 this.isTerrain
= isTerrain
;
52 this.setPosition(new Position(lat
, lon
, elev
));
55 public int getColorCode()
57 return this.colorCode
;
60 public Object
getObject()
65 public void setOnTop()
70 public boolean isOnTop()
75 public boolean isTerrain()
77 return this.isTerrain
;
80 public void setParentLayer(Layer layer
)
82 this.setValue(AVKey
.PICKED_OBJECT_PARENT_LAYER
, layer
);
85 public Layer
getParentLayer()
87 return (Layer
) this.getValue(AVKey
.PICKED_OBJECT_PARENT_LAYER
);
90 public void setPosition(Position position
)
92 this.setValue(AVKey
.POSITION
, position
);
95 public Position
getPosition()
97 return (Position
) this.getValue(AVKey
.POSITION
);
100 public boolean hasPosition()
102 return this.hasKey(AVKey
.POSITION
);
105 public boolean equals(Object o
)
109 if (o
== null || getClass() != o
.getClass())
112 PickedObject that
= (PickedObject
) o
;
114 if (colorCode
!= that
.colorCode
)
116 if (isOnTop
!= that
.isOnTop
)
118 //noinspection RedundantIfStatement
119 if (userObject
!= null ?
!userObject
.equals(that
.userObject
) : that
.userObject
!= null)
125 public int hashCode()
129 result
= 31 * result
+ (userObject
!= null ? userObject
.hashCode() : 0);
130 result
= 31 * result
+ (isOnTop ?
1 : 0);