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
;
9 import gov
.nasa
.worldwind
.geom
.*;
13 * @version $Id: PickedObject Feb 5, 2007 12:47:00 AM
15 public class PickedObject
extends AVListImpl
17 private final int colorCode
;
18 private final Object userObject
;
19 private boolean isOnTop
= false;
20 private boolean isTerrain
= false;
22 public PickedObject(int colorCode
, Object userObject
)
25 this.colorCode
= colorCode
;
26 this.userObject
= userObject
;
28 this.isTerrain
= false;
31 public PickedObject(int colorCode
, Object userObject
, Position position
, boolean isTerrain
)
35 this.colorCode
= colorCode
;
36 this.userObject
= userObject
;
38 this.isTerrain
= isTerrain
;
39 this.setPosition(position
);
42 public PickedObject(int colorCode
, Object userObject
, Angle lat
, Angle lon
, double elev
, boolean isTerrain
)
46 this.colorCode
= colorCode
;
47 this.userObject
= userObject
;
49 this.isTerrain
= isTerrain
;
50 this.setPosition(new Position(lat
, lon
, elev
));
53 public int getColorCode()
55 return this.colorCode
;
58 public Object
getObject()
63 public void setOnTop()
68 public boolean isOnTop()
73 public boolean isTerrain()
75 return this.isTerrain
;
78 public void setParentLayer(Layer layer
)
80 this.setValue(AVKey
.PICKED_OBJECT_PARENT_LAYER
, layer
);
83 public Layer
getParentLayer()
85 return (Layer
) this.getValue(AVKey
.PICKED_OBJECT_PARENT_LAYER
);
88 public void setPosition(Position position
)
90 this.setValue(AVKey
.POSITION
, position
);
93 public Position
getPosition()
95 return (Position
) this.getValue(AVKey
.POSITION
);
98 public boolean hasPosition()
100 return this.hasKey(AVKey
.POSITION
);
103 public boolean equals(Object o
)
107 if (o
== null || getClass() != o
.getClass())
110 PickedObject that
= (PickedObject
) o
;
112 if (colorCode
!= that
.colorCode
)
114 if (isOnTop
!= that
.isOnTop
)
116 //noinspection RedundantIfStatement
117 if (userObject
!= null ?
!userObject
.equals(that
.userObject
) : that
.userObject
!= null)
123 public int hashCode()
127 result
= 31 * result
+ (userObject
!= null ? userObject
.hashCode() : 0);
128 result
= 31 * result
+ (isOnTop ?
1 : 0);