Package com.massifmaps.celestial
Class CelestialObject
java.lang.Object
com.massifmaps.celestial.CelestialObject
- Direct Known Subclasses:
CelestialArc,CelestialSprite
A base class for objects that are placed in the sky rather than on the map.
An object is anchored in one of two ways:
- by DIRECTION (azimuth and altitude), with an optional distance. A distance of 0 means
infinitely far: the object keeps its direction whatever the camera does, which is what
a body at an effectively infinite distance needs. A finite distance gives real parallax
and is what an aircraft or a satellite overhead needs.
- by geographic POSITION plus an altitude in meters, for an object that belongs to a place
on the map but is above it.
Objects are hit-tested against the touch ray like any other layer's elements, so a click on
one is reported through the layer's listener, and terrain in front of it wins the hit.
An object is anchored in one of two ways:
- by DIRECTION (azimuth and altitude), with an optional distance. A distance of 0 means
infinitely far: the object keeps its direction whatever the camera does, which is what
a body at an effectively infinite distance needs. A finite distance gives real parallax
and is what an aircraft or a satellite overhead needs.
- by geographic POSITION plus an altitude in meters, for an object that belongs to a place
on the map but is above it.
Objects are hit-tested against the touch ray like any other layer's elements, so a click on
one is reported through the layer's listener, and terrain in front of it wins the hit.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if this object is equal to the specified object.floatReturns the altitude of a direction-anchored object.floatReturns the azimuth of a direction-anchored object.getColor()Returns the color of the object.doubleReturns the distance of a direction-anchored object.getMetaDataElement(String key) Returns a meta data value.Returns the geographic position of a position-anchored object.doubleReturns the altitude of a position-anchored object.inthashCode()Returns the hash value of this object.booleanReturns true if the object is anchored by direction, false if by geographic position.booleanReturns the visibility of the object.voidSets the color of the object.voidsetDirection(float azimuth, float altitude, double distance) Anchors the object by direction.voidsetMetaDataElement(String key, Variant element) Sets a meta data value.voidsetPosition(MapPos pos, double altitude) Anchors the object above a place on the map.voidsetVisible(boolean visible) Sets the visibility of the object.
-
Method Details
-
equals
Checks if this object is equal to the specified object. -
hashCode
public int hashCode()Returns the hash value of this object. -
isDirectionAnchored
public boolean isDirectionAnchored()Returns true if the object is anchored by direction, false if by geographic position.- Returns:
- True if the object is anchored by direction.
-
getAzimuth
public float getAzimuth()Returns the azimuth of a direction-anchored object.- Returns:
- The azimuth in degrees, clockwise from north.
-
getAltitude
public float getAltitude()Returns the altitude of a direction-anchored object.- Returns:
- The altitude in degrees above the horizon.
-
getDistance
public double getDistance()Returns the distance of a direction-anchored object.- Returns:
- The distance in meters, or 0 for infinitely far.
-
setDirection
public void setDirection(float azimuth, float altitude, double distance) Anchors the object by direction. This is the anchor for anything that behaves like a
celestial body.- Parameters:
azimuth- The azimuth in degrees, clockwise from north.altitude- The altitude in degrees above the horizon.distance- The distance in meters. 0 means infinitely far, so the object never
parallaxes when the camera moves.
-
getPosition
Returns the geographic position of a position-anchored object.- Returns:
- The position, in the coordinate system of the layer's data source projection.
-
getPositionAltitude
public double getPositionAltitude()Returns the altitude of a position-anchored object.- Returns:
- The altitude in meters above the ground.
-
setPosition
Anchors the object above a place on the map. Use this for aircraft, satellites, or
anything else that has a real location.- Parameters:
pos- The position, in the coordinate system of the layer's data source projection.altitude- The altitude in meters above the ground.
-
getColor
Returns the color of the object.- Returns:
- The color of the object.
-
setColor
Sets the color of the object. The color multiplies the bitmap, if there is one.- Parameters:
color- The new color.
-
isVisible
public boolean isVisible()Returns the visibility of the object.- Returns:
- True if the object is drawn.
-
setVisible
public void setVisible(boolean visible) Sets the visibility of the object. An invisible object is neither drawn nor clickable.- Parameters:
visible- The new visibility.
-
getMetaDataElement
Returns a meta data value.- Parameters:
key- The key of the value.- Returns:
- The value, or an empty variant if the key does not exist.
-
setMetaDataElement
Sets a meta data value. Meta data is carried through to the click listener, which is how
an application tells its objects apart.- Parameters:
key- The key of the value.element- The value.
-