NASA World Wind

gov.nasa.worldwind.render
Class SurfaceIcon

java.lang.Object
  extended by gov.nasa.worldwind.avlist.AVListImpl
      extended by gov.nasa.worldwind.render.AbstractSurfaceObject
          extended by gov.nasa.worldwind.render.AbstractSurfaceRenderable
              extended by gov.nasa.worldwind.render.SurfaceIcon
All Implemented Interfaces:
AVList, Movable, PreRenderable, Renderable, SurfaceObject
Direct Known Subclasses:
SurfaceIcons

public class SurfaceIcon
extends AbstractSurfaceRenderable
implements Movable

Renders an icon image over the terrain surface.


Nested Class Summary
protected static class SurfaceIcon.CacheEntry<T>
           
 
Field Summary
protected static int DEFAULT_CACHE_CAPACITY
           
protected  int imageHeight
           
protected  int imageWidth
           
protected  BoundedHashMap<Object,SurfaceIcon.CacheEntry<Iterable<? extends Sector>>> sectorCache
           
protected  WWTexture texture
           
 
Fields inherited from class gov.nasa.worldwind.render.AbstractSurfaceRenderable
pickSupport, renderer, renderToTextureSupport, stateSupport
 
Fields inherited from class gov.nasa.worldwind.render.AbstractSurfaceObject
lastModifiedTime, visible
 
Fields inherited from class gov.nasa.worldwind.avlist.AVListImpl
changeSupport
 
Constructor Summary
SurfaceIcon(Object imageSource)
           
SurfaceIcon(Object imageSource, LatLon location)
           
 
Method Summary
protected  void applyDrawColor(DrawContext dc)
           
protected  void applyDrawTransform(DrawContext dc, Sector sector, int x, int y, int width, int height, LatLon location, double drawScale, Matrix geoTransform)
           
protected  void beginDraw(DrawContext dc)
           
protected  Rectangle2D.Double computeDrawDimension(double pixelSize)
           
protected  Rectangle2D.Double computeDrawDimension(DrawContext dc, LatLon location)
           
protected  Angle computeDrawHeading(DrawContext dc)
           
protected  double computeDrawScale(DrawContext dc, Sector sector, int width, int height, LatLon location)
           
protected  Sector computeSector(DrawContext dc, LatLon location)
           
 void doRenderToRegion(DrawContext dc, Sector sector, int x, int y, int width, int height)
           
protected  void drawIcon(DrawContext dc, Sector sector, int x, int y, int width, int height)
           
protected  void endDraw(DrawContext dc)
           
 Color getColor()
          Get the Color the source image is combined with.
 Angle getHeading()
          Get the current heading Angle, clockwise from North or null.
 Object getImageSource()
          Get the source for the icon image.
 long getLastModifiedTime()
           
 LatLon getLocation()
          Get the icon reference location on the globe.
 Vec4 getLocationOffset()
          Get the icon displacement in pixels relative to the reference location.
 double getMaxSize()
          Get the maximum size in meter the icon image is allowed to be enlarged to once applied to the terrain surface.
 double getMinSize()
          Get the minimum size in meter the icon image is allowed to be reduced to once applied to the terrain surface.
 Position getReferencePosition()
           
 double getScale()
          Get the current scaling factor applied to the source image.
 Iterable<? extends Sector> getSectors(DrawContext dc, double texelSizeRadians)
           
protected  WWTexture getTexture()
           
protected  boolean isMaintainAppearance()
           
 boolean isMaintainSize()
          Determines whether the icon constantly maintains it's apparent size.
 boolean isUseMipMaps()
          Returns whether the icon will apply mip-map filtering to it's source image.
 void move(Position delta)
          Shift the shape over the globe's surface while maintaining its original azimuth, its orientation relative to North.
 void moveTo(Position position)
          Move the shape over the globe's surface while maintaining its original azimuth, its orientation relative to North.
 void setColor(Color color)
          Set the Color the source image will be combined with - default to white.
 void setHeading(Angle heading)
          Set the heading Angle, clockwise from North.
 void setImageSource(Object imageSource)
          Set the source for the icon image.
 void setLocation(LatLon location)
          Set the icon reference location on the globe.
 void setLocationOffset(Vec4 locationOffset)
          Set the icon displacement in pixels relative to the reference location.
 void setMaintainSize(boolean state)
          Sets whether the icon constantly maintains it's apparent size.
 void setMaxSize(double sizeInMeter)
          Get the maximum size in meter the icon image is allowed to be enlarged to once applied to the terrain surface.
 void setMinSize(double sizeInMeter)
          Set the minimum size in meter the icon image is allowed to be reduced to once applied to the terrain surface.
 void setScale(double scale)
          Set the scaling factor to apply to the source image.
 void setUseMipMaps(boolean useMipMaps)
          Sets whether the icon will apply mip-map filtering to it's source image.
 
Methods inherited from class gov.nasa.worldwind.render.AbstractSurfaceRenderable
applyNonPremultipliedAlphaColor, applyPremultipliedAlphaColor, computeDrawPixelSize, computeDrawPoint, computePixelSizeAtLocation, computeRotatedSectorBounds, getOpacity, getRenderer, getViewHeading, preRender, render, setOpacity
 
Methods inherited from class gov.nasa.worldwind.render.AbstractSurfaceObject
isVisible, renderToRegion, setVisible, updateModifiedTime
 
Methods inherited from class gov.nasa.worldwind.avlist.AVListImpl
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, getStringValue, getStringValue, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.nasa.worldwind.avlist.AVList
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
 

Field Detail

DEFAULT_CACHE_CAPACITY

protected static final int DEFAULT_CACHE_CAPACITY
See Also:
Constant Field Values

imageHeight

protected int imageHeight

imageWidth

protected int imageWidth

sectorCache

protected BoundedHashMap<Object,SurfaceIcon.CacheEntry<Iterable<? extends Sector>>> sectorCache

texture

protected WWTexture texture
Constructor Detail

SurfaceIcon

public SurfaceIcon(Object imageSource)

SurfaceIcon

public SurfaceIcon(Object imageSource,
                   LatLon location)
Method Detail

applyDrawColor

protected void applyDrawColor(DrawContext dc)

applyDrawTransform

protected void applyDrawTransform(DrawContext dc,
                                  Sector sector,
                                  int x,
                                  int y,
                                  int width,
                                  int height,
                                  LatLon location,
                                  double drawScale,
                                  Matrix geoTransform)

beginDraw

protected void beginDraw(DrawContext dc)

computeDrawDimension

protected Rectangle2D.Double computeDrawDimension(double pixelSize)

computeDrawDimension

protected Rectangle2D.Double computeDrawDimension(DrawContext dc,
                                                  LatLon location)

computeDrawHeading

protected Angle computeDrawHeading(DrawContext dc)

computeDrawScale

protected double computeDrawScale(DrawContext dc,
                                  Sector sector,
                                  int width,
                                  int height,
                                  LatLon location)

computeSector

protected Sector computeSector(DrawContext dc,
                               LatLon location)

doRenderToRegion

public void doRenderToRegion(DrawContext dc,
                             Sector sector,
                             int x,
                             int y,
                             int width,
                             int height)
Specified by:
doRenderToRegion in class AbstractSurfaceRenderable

drawIcon

protected void drawIcon(DrawContext dc,
                        Sector sector,
                        int x,
                        int y,
                        int width,
                        int height)

endDraw

protected void endDraw(DrawContext dc)

getColor

public Color getColor()
Get the Color the source image is combined with.

Returns:
the Color the source image is combined with.

getHeading

public Angle getHeading()
Get the current heading Angle, clockwise from North or null.

Returns:
the current heading Angle, clockwise from North or null.

getImageSource

public Object getImageSource()
Get the source for the icon image. Can be a file path to a local image or a BufferedImage reference.

Returns:
the source for the icon image.

getLastModifiedTime

public long getLastModifiedTime()
Specified by:
getLastModifiedTime in interface SurfaceObject
Overrides:
getLastModifiedTime in class AbstractSurfaceObject

getLocation

public LatLon getLocation()
Get the icon reference location on the globe.

Returns:
the icon reference location on the globe.

getLocationOffset

public Vec4 getLocationOffset()
Get the icon displacement in pixels relative to the reference location. Can be null.

When null the icon will be drawn with it's image center on top of it's refence location - see setLocation(LatLon). Otherwise the icon will be shifted of a distance equivalent to the number of pixels specified as x and y offset values. Positive values will move the icon to the right for x and up for y. Negative values will have the opposite effect.

Returns:
the icon displacement in pixels relative to the reference location.

getMaxSize

public double getMaxSize()
Get the maximum size in meter the icon image is allowed to be enlarged to once applied to the terrain surface. This limit applies to the source image largest dimension.

The icon will try to maintain it's apparent size depending on it's distance from the eye and will extend over a rectangular area which largest dimension is bounded by the values provided with setMinSize(double) and setMaxSize(double).

Returns:
the maximum size of the icon in meter.

getMinSize

public double getMinSize()
Get the minimum size in meter the icon image is allowed to be reduced to once applied to the terrain surface. This limit applies to the source image largest dimension.

The icon will try to maintain it's apparent size depending on it's distance from the eye and will extend over a rectangular area which largest dimension is bounded by the values provided with setMinSize(double) and setMaxSize(double).

Returns:
the minimum size of the icon in meter.

getReferencePosition

public Position getReferencePosition()
Specified by:
getReferencePosition in interface Movable

getScale

public double getScale()
Get the current scaling factor applied to the source image.

Returns:
the current scaling factor applied to the source image.

getSectors

public Iterable<? extends Sector> getSectors(DrawContext dc,
                                             double texelSizeRadians)
Specified by:
getSectors in interface SurfaceObject
Specified by:
getSectors in class AbstractSurfaceRenderable

getTexture

protected WWTexture getTexture()

isMaintainAppearance

protected boolean isMaintainAppearance()

isMaintainSize

public boolean isMaintainSize()
Determines whether the icon constantly maintains it's apparent size. If true the icon is constantly redrawn at the proper size depending on it's distance from the eye. If false the icon will be drawn only once per level of the underlying tile pyramid. Thus it's apparent size will vary up to twice it's 'normal' dimension in between levels.

Returns:
true if the icon constantly maintains it's apparent size.

isUseMipMaps

public boolean isUseMipMaps()
Returns whether the icon will apply mip-map filtering to it's source image. If true the icon image is drawn using mip-maps. If false the icon is drawn without mip-maps, resulting in aliasing if the icon image is drawn smaller than it's native size in pixels.

Returns:
true if the icon image is drawn with mip-map filtering; false otherwise.

move

public void move(Position delta)
Description copied from interface: Movable
Shift the shape over the globe's surface while maintaining its original azimuth, its orientation relative to North.

Specified by:
move in interface Movable
Parameters:
delta - the latitude and longitude to add to the shape's reference position.

moveTo

public void moveTo(Position position)
Description copied from interface: Movable
Move the shape over the globe's surface while maintaining its original azimuth, its orientation relative to North.

Specified by:
moveTo in interface Movable
Parameters:
position - the new position of the shape's reference position.

setColor

public void setColor(Color color)
Set the Color the source image will be combined with - default to white.

A non white color will mostly affect the white portions from the original image. This is mostly useful to alter the appearance of 'colorless' icons - which mainly contain black, white and shades of gray.

Parameters:
color - the Color the source image will be combined with.
Throws:
IllegalArgumentException - if color is null.

setHeading

public void setHeading(Angle heading)
Set the heading Angle, clockwise from North. Setting this value to null will have the icon follow the view heading so as to always face the eye. The icon will rotate around it's reference location.

Parameters:
heading - the heading Angle, clockwise from North or null.

setImageSource

public void setImageSource(Object imageSource)
Set the source for the icon image. Can be a file path to a local image or a BufferedImage reference.

Parameters:
imageSource - the source for the icon image.
Throws:
IllegalArgumentException - if imageSource is null.

setLocation

public void setLocation(LatLon location)
Set the icon reference location on the globe.

Parameters:
location - the icon reference location on the globe.
Throws:
IllegalArgumentException - if location is null.

setLocationOffset

public void setLocationOffset(Vec4 locationOffset)
Set the icon displacement in pixels relative to the reference location. Can be null.

When null the icon will be drawn with it's image center on top of it's refence location - see setLocation(LatLon). Otherwise the icon will be shifted of a distance equivalent to the number of pixels specified as x and y offset values. Positive values will move the icon to the right for x and up for y. Negative values will have the opposite effect.

Parameters:
locationOffset - the icon displacement in pixels relative to the reference location.

setMaintainSize

public void setMaintainSize(boolean state)
Sets whether the icon constantly maintains it's apparent size. If true the icon is constantly redrawn at the proper size depending on it's distance from the eye. If false the icon will be drawn only once per level of the underlying tile pyramid. Thus it's apparent size will vary up to twice it's 'normal' dimension in between levels.

Parameters:
state - true if the icon should constantly maintains it's apparent size.

setMaxSize

public void setMaxSize(double sizeInMeter)
Get the maximum size in meter the icon image is allowed to be enlarged to once applied to the terrain surface. This limit applies to the source image largest dimension.

The icon will try to maintain it's apparent size depending on it's distance from the eye and will extend over a rectangular area which largest dimension is bounded by the values provided with setMinSize(double) and setMaxSize(double).

Parameters:
sizeInMeter - the maximum size of the icon in meter.

setMinSize

public void setMinSize(double sizeInMeter)
Set the minimum size in meter the icon image is allowed to be reduced to once applied to the terrain surface. This limit applies to the source image largest dimension.

The icon will try to maintain it's apparent size depending on it's distance from the eye and will extend over a rectangular area which largest dimension is bounded by the values provided with setMinSize(double) and setMaxSize(double).

Parameters:
sizeInMeter - the minimum size of the icon in meter.

setScale

public void setScale(double scale)
Set the scaling factor to apply to the source image. A value of 1 will produce no change, a value greater then 1 will enlarge the image and a value smaller then 1 will reduce it.

Parameters:
scale - the scaling factor to apply to the source image.
Throws:
IllegalArgumentException - if scale is zero or negative.

setUseMipMaps

public void setUseMipMaps(boolean useMipMaps)
Sets whether the icon will apply mip-map filtering to it's source image. If true the icon image is drawn using mip-maps. If false the icon is drawn without mip-maps, resulting in aliasing if the icon image is drawn smaller than it's native size in pixels.

Parameters:
useMipMaps - true if the icon image should be drawn with mip-map filtering; false otherwise.

NASA World Wind

Hosted by docs.bugaco.com