Class CelestialObject

java.lang.Object
com.massifmaps.celestial.CelestialObject
Direct Known Subclasses:
CelestialArc, CelestialSprite

public class CelestialObject extends Object
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.
  • Method Details

    • equals

      public boolean equals(Object obj)
      Checks if this object is equal to the specified object.
      Overrides:
      equals in class Object
      Parameters:
      obj - The reference object.
      Returns:
      True when objects are equal, false otherwise.
    • hashCode

      public int hashCode()
      Returns the hash value of this object.
      Overrides:
      hashCode in class Object
      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

      public MapPos 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

      public void setPosition(MapPos pos, double altitude)
      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

      public Color getColor()
      Returns the color of the object.
      Returns:
      The color of the object.
    • setColor

      public void setColor(Color color)
      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

      public Variant getMetaDataElement(String key)
      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

      public void setMetaDataElement(String key, Variant element)
      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.