Update to Worldwind release 0.4.1
[worldwind-tracker.git] / gov / nasa / worldwind / pick / PickedObject.java
blob4cdbdcc67acc2b2d4fdadb4e7208c292717cbab3
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 import java.awt.*;
15 /**
16 * @author lado
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)
29 super();
31 this.pickPoint = null;
32 this.colorCode = colorCode;
33 this.userObject = userObject;
34 this.isOnTop = false;
35 this.isTerrain = false;
38 public PickedObject(int colorCode, Object userObject, Position position, boolean isTerrain)
40 super();
42 this.pickPoint = null;
43 this.colorCode = colorCode;
44 this.userObject = userObject;
45 this.isOnTop = false;
46 this.isTerrain = isTerrain;
47 this.setPosition(position);
50 public PickedObject(Point pickPoint, int colorCode, Object userObject, Angle lat, Angle lon, double elev,
51 boolean isTerrain)
53 super();
55 this.pickPoint = pickPoint;
56 this.colorCode = colorCode;
57 this.userObject = userObject;
58 this.isOnTop = false;
59 this.isTerrain = isTerrain;
60 this.setPosition(new Position(lat, lon, elev));
63 public Point getPickPoint()
65 return pickPoint;
68 public int getColorCode()
70 return this.colorCode;
73 public Object getObject()
75 return userObject;
78 public void setOnTop()
80 this.isOnTop = true;
83 public boolean isOnTop()
85 return this.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)
120 if (this == o)
121 return true;
122 if (o == null || getClass() != o.getClass())
123 return false;
125 PickedObject that = (PickedObject) o;
127 if (colorCode != that.colorCode)
128 return false;
129 if (isOnTop != that.isOnTop)
130 return false;
131 //noinspection RedundantIfStatement
132 if (userObject != null ? !userObject.equals(that.userObject) : that.userObject != null)
133 return false;
135 return true;
138 public int hashCode()
140 int result;
141 result = colorCode;
142 result = 31 * result + (userObject != null ? userObject.hashCode() : 0);
143 result = 31 * result + (isOnTop ? 1 : 0);
144 return result;