Updated to worldwind release 20070817
[worldwind-tracker.git] / gov / nasa / worldwind / pick / PickedObject.java
blob7508dcf97fddde3b911990b18f1dbdd9a2378f4e
1 /*
2 Copyright (C) 2001, 2006 United States Government
3 as represented by the Administrator of the
4 National Aeronautics and Space Administration.
5 All Rights Reserved.
6 */
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;
13 /**
14 * @author lado
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)
26 super();
27 this.colorCode = colorCode;
28 this.userObject = userObject;
29 this.isOnTop = false;
30 this.isTerrain = false;
33 public PickedObject(int colorCode, Object userObject, Position position, boolean isTerrain)
35 super();
37 this.colorCode = colorCode;
38 this.userObject = userObject;
39 this.isOnTop = false;
40 this.isTerrain = isTerrain;
41 this.setPosition(position);
44 public PickedObject(int colorCode, Object userObject, Angle lat, Angle lon, double elev, boolean isTerrain)
46 super();
48 this.colorCode = colorCode;
49 this.userObject = userObject;
50 this.isOnTop = false;
51 this.isTerrain = isTerrain;
52 this.setPosition(new Position(lat, lon, elev));
55 public int getColorCode()
57 return this.colorCode;
60 public Object getObject()
62 return userObject;
65 public void setOnTop()
67 this.isOnTop = true;
70 public boolean isOnTop()
72 return this.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)
107 if (this == o)
108 return true;
109 if (o == null || getClass() != o.getClass())
110 return false;
112 PickedObject that = (PickedObject) o;
114 if (colorCode != that.colorCode)
115 return false;
116 if (isOnTop != that.isOnTop)
117 return false;
118 //noinspection RedundantIfStatement
119 if (userObject != null ? !userObject.equals(that.userObject) : that.userObject != null)
120 return false;
122 return true;
125 public int hashCode()
127 int result;
128 result = colorCode;
129 result = 31 * result + (userObject != null ? userObject.hashCode() : 0);
130 result = 31 * result + (isOnTop ? 1 : 0);
131 return result;