NASA World Wind

gov.nasa.worldwind.render
Class SurfaceImage

java.lang.Object
  extended by gov.nasa.worldwind.avlist.AVListImpl
      extended by gov.nasa.worldwind.WWObjectImpl
          extended by gov.nasa.worldwind.render.SurfaceImage
All Implemented Interfaces:
AVList, Disposable, MessageListener, Exportable, Movable, PreRenderable, Renderable, SurfaceTile, WWObject, PropertyChangeListener, EventListener
Direct Known Subclasses:
KMLSurfaceImageImpl

public class SurfaceImage
extends WWObjectImpl
implements SurfaceTile, Renderable, PreRenderable, Movable, Disposable, Exportable

Renders a single image contained in a local file, a remote file, or a BufferedImage.

Note: The view input handlers detect the surface image rather than the terrain as the top picked object in SelectEvents and will not respond to the user's attempts at navigation when the cursor is over the image. If this is not the desired behavior, disable picking for the layer containing the surface image.


Field Summary
protected  List<LatLon> corners
           
protected  WWTexture generatedTexture
           
protected  boolean generatedTextureExpired
           
protected  Object imageSource
           
protected  WWTexture previousGeneratedTexture
           
protected  WWTexture previousSourceTexture
           
protected  WWTexture sourceTexture
           
protected  List<SurfaceImage> thisList
          A list that contains only a reference to this instance.
 
Fields inherited from interface gov.nasa.worldwind.Exportable
FORMAT_NOT_SUPPORTED, FORMAT_PARTIALLY_SUPPORTED, FORMAT_SUPPORTED
 
Constructor Summary
SurfaceImage()
          Create a new surface image with no image source.
SurfaceImage(Object imageSource, Iterable<? extends LatLon> corners)
           
SurfaceImage(Object imageSource, Sector sector)
          Renders a single image tile from a local image source.
 
Method Summary
 void applyInternalTransform(DrawContext dc, boolean textureIdentityActive)
           
 boolean bind(DrawContext dc)
           
 void dispose()
          Disposes of any internal resources allocated by the object.
 boolean equals(Object o)
           
 void export(String mimeType, Object output)
          Export the Surface Image.
protected  void exportAsKML(Object output)
          Export the surface image to KML as a <GroundOverlay> element.
protected  void exportKMLLatLonBox(XMLStreamWriter xmlWriter)
           
protected  void exportKMLLatLonQuad(XMLStreamWriter xmlWriter)
           
 List<LatLon> getCorners()
           
 Extent getExtent(DrawContext dc)
           
 Object getImageSource()
           
 double getOpacity()
           
 Position getReferencePosition()
          A position associated with the object that indicates its aggregate geographic position.
 Sector getSector()
           
 int hashCode()
           
protected  WWTexture initializeGeneratedTexture(DrawContext dc)
           
protected  void initializeGeometry(Iterable<? extends LatLon> corners)
           
protected  void initializeSourceTexture(DrawContext dc)
           
 String isExportFormatSupported(String format)
          Does this object support a certain export format?
 boolean isPickEnabled()
           
 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 preRender(DrawContext dc)
           
 void render(DrawContext dc)
          Causes this Renderable to render itself using the provided draw context.
 void setCorners(Iterable<? extends LatLon> corners)
           
 void setImageSource(Object imageSource, Iterable<? extends LatLon> corners)
           
 void setImageSource(Object imageSource, Sector sector)
           
 void setOpacity(double opacity)
           
 void setPickEnabled(boolean pickEnabled)
           
protected  void setReferencePosition(Position referencePosition)
           
 
Methods inherited from class gov.nasa.worldwind.WWObjectImpl
onMessage, propertyChange
 
Methods inherited from class gov.nasa.worldwind.avlist.AVListImpl
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getBooleanValue, getBooleanValue, getChangeSupport, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, getRestorableStateForAVPair, getStringValue, getStringValue, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, 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

corners

protected List<LatLon> corners

generatedTexture

protected WWTexture generatedTexture

generatedTextureExpired

protected boolean generatedTextureExpired

imageSource

protected Object imageSource

previousGeneratedTexture

protected WWTexture previousGeneratedTexture

previousSourceTexture

protected WWTexture previousSourceTexture

sourceTexture

protected WWTexture sourceTexture

thisList

protected List<SurfaceImage> thisList
A list that contains only a reference to this instance. Used as an argument to the surface tile renderer to prevent its having to create a list every time this surface image is rendered.

Constructor Detail

SurfaceImage

public SurfaceImage()
Create a new surface image with no image source. The image will not be rendered until an image source is set.


SurfaceImage

public SurfaceImage(Object imageSource,
                    Iterable<? extends LatLon> corners)

SurfaceImage

public SurfaceImage(Object imageSource,
                    Sector sector)
Renders a single image tile from a local image source.

Parameters:
imageSource - either the file path to a local image or a BufferedImage reference.
sector - the sector covered by the image.
Method Detail

applyInternalTransform

public void applyInternalTransform(DrawContext dc,
                                   boolean textureIdentityActive)
Specified by:
applyInternalTransform in interface SurfaceTile

bind

public boolean bind(DrawContext dc)
Specified by:
bind in interface SurfaceTile

dispose

public void dispose()
Description copied from interface: Disposable
Disposes of any internal resources allocated by the object.

Specified by:
dispose in interface Disposable

equals

public boolean equals(Object o)
Overrides:
equals in class Object

export

public void export(String mimeType,
                   Object output)
            throws IOException
Export the Surface Image. The output object will receive the exported data. The type of this object depends on the export format. The formats and object types supported by this class are:

 Format                                         Supported output object types
 ================================================================================
 KML (application/vnd.google-earth.kml+xml)     java.io.Writer
                                                java.io.OutputStream
                                                javax.xml.stream.XMLStreamWriter
 

Specified by:
export in interface Exportable
Parameters:
mimeType - MIME type of desired export format.
output - An object that will receive the exported data. The type of this object depends on the export format (see above).
Throws:
IOException - If an exception occurs writing to the output object.
See Also:
Exportable.isExportFormatSupported(String)

exportAsKML

protected void exportAsKML(Object output)
                    throws IOException,
                           XMLStreamException
Export the surface image to KML as a <GroundOverlay> element. The output object will receive the data. This object must be one of: java.io.Writer java.io.OutputStream javax.xml.stream.XMLStreamWriter

Parameters:
output - Object to receive the generated KML.
Throws:
XMLStreamException - If an exception occurs while writing the KML
IOException - if an exception occurs while exporting the data.
See Also:
export(String, Object)

exportKMLLatLonBox

protected void exportKMLLatLonBox(XMLStreamWriter xmlWriter)
                           throws XMLStreamException
Throws:
XMLStreamException

exportKMLLatLonQuad

protected void exportKMLLatLonQuad(XMLStreamWriter xmlWriter)
                            throws XMLStreamException
Throws:
XMLStreamException

getCorners

public List<LatLon> getCorners()
Specified by:
getCorners in interface SurfaceTile

getExtent

public Extent getExtent(DrawContext dc)
Specified by:
getExtent in interface SurfaceTile

getImageSource

public Object getImageSource()

getOpacity

public double getOpacity()

getReferencePosition

public Position getReferencePosition()
Description copied from interface: Movable
A position associated with the object that indicates its aggregate geographic position. The chosen position varies among implementers of this interface. For objects defined by a list of positions, the reference position is typically the first position in the list. For symmetric objects the reference position is often the center of the object. In many cases the object's reference position may be explicitly specified by the application.

Specified by:
getReferencePosition in interface Movable
Returns:
the object's reference position, or null if no reference position is available.

getSector

public Sector getSector()
Specified by:
getSector in interface SurfaceTile

hashCode

public int hashCode()
Overrides:
hashCode in class Object

initializeGeneratedTexture

protected WWTexture initializeGeneratedTexture(DrawContext dc)

initializeGeometry

protected void initializeGeometry(Iterable<? extends LatLon> corners)

initializeSourceTexture

protected void initializeSourceTexture(DrawContext dc)

isExportFormatSupported

public String isExportFormatSupported(String format)
Does this object support a certain export format?

Specified by:
isExportFormatSupported in interface Exportable
Parameters:
format - Desired export format.
Returns:
One of Exportable.FORMAT_SUPPORTED, Exportable.FORMAT_NOT_SUPPORTED, or Exportable.FORMAT_PARTIALLY_SUPPORTED.
See Also:
Exportable.export(String, Object)

isPickEnabled

public boolean isPickEnabled()

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.

preRender

public void preRender(DrawContext dc)
Specified by:
preRender in interface PreRenderable

render

public void render(DrawContext dc)
Description copied from interface: Renderable
Causes this Renderable to render itself using the provided draw context.

Specified by:
render in interface Renderable
Parameters:
dc - the DrawContext to be used
See Also:
DrawContext

setCorners

public void setCorners(Iterable<? extends LatLon> corners)

setImageSource

public void setImageSource(Object imageSource,
                           Iterable<? extends LatLon> corners)

setImageSource

public void setImageSource(Object imageSource,
                           Sector sector)

setOpacity

public void setOpacity(double opacity)

setPickEnabled

public void setPickEnabled(boolean pickEnabled)

setReferencePosition

protected void setReferencePosition(Position referencePosition)

NASA World Wind