Worldwind public release 0.2.1
[worldwind-tracker.git] / gov / nasa / worldwind / PickedObject.java
blobd0d66b220c04d8adfe470eb9699faf3e9242bbb2
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;
9 import gov.nasa.worldwind.geom.*;
11 /**
12 * @author lado
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)
24 super();
25 this.colorCode = colorCode;
26 this.userObject = userObject;
27 this.isOnTop = false;
28 this.isTerrain = false;
31 public PickedObject(int colorCode, Object userObject, Position position, boolean isTerrain)
33 super();
35 this.colorCode = colorCode;
36 this.userObject = userObject;
37 this.isOnTop = false;
38 this.isTerrain = isTerrain;
39 this.setPosition(position);
42 public PickedObject(int colorCode, Object userObject, Angle lat, Angle lon, double elev, boolean isTerrain)
44 super();
46 this.colorCode = colorCode;
47 this.userObject = userObject;
48 this.isOnTop = false;
49 this.isTerrain = isTerrain;
50 this.setPosition(new Position(lat, lon, elev));
53 public int getColorCode()
55 return this.colorCode;
58 public Object getObject()
60 return userObject;
63 public void setOnTop()
65 this.isOnTop = true;
68 public boolean isOnTop()
70 return this.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)
105 if (this == o)
106 return true;
107 if (o == null || getClass() != o.getClass())
108 return false;
110 PickedObject that = (PickedObject) o;
112 if (colorCode != that.colorCode)
113 return false;
114 if (isOnTop != that.isOnTop)
115 return false;
116 //noinspection RedundantIfStatement
117 if (userObject != null ? !userObject.equals(that.userObject) : that.userObject != null)
118 return false;
120 return true;
123 public int hashCode()
125 int result;
126 result = colorCode;
127 result = 31 * result + (userObject != null ? userObject.hashCode() : 0);
128 result = 31 * result + (isOnTop ? 1 : 0);
129 return result;