Package gov.nasa.worldwind.render
Class SurfaceImage
- java.lang.Object
-
- gov.nasa.worldwind.avlist.AVListImpl
-
- gov.nasa.worldwind.WWObjectImpl
-
- gov.nasa.worldwind.render.SurfaceImage
-
- All Implemented Interfaces:
AVList
,Disposable
,Draggable
,MessageListener
,Exportable
,Movable
,OrderedRenderable
,PreRenderable
,Renderable
,SurfaceTile
,WWObject
,java.beans.PropertyChangeListener
,java.util.EventListener
- Direct Known Subclasses:
KMLSurfaceImageImpl
public class SurfaceImage extends WWObjectImpl implements SurfaceTile, OrderedRenderable, PreRenderable, Movable, Disposable, Exportable, Draggable
Renders a single image contained in a local file, a remote file, or aBufferedImage
.Note: The view input handlers detect the surface image rather than the terrain as the top picked object in
SelectEvent
s 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
Fields Modifier and Type Field Description protected boolean
alwaysOnTop
protected java.util.List<LatLon>
corners
protected boolean
dragEnabled
protected DraggableSupport
draggableSupport
protected WWTexture
generatedTexture
protected boolean
generatedTextureExpired
protected java.lang.Object
imageSource
protected Layer
pickLayer
protected PickSupport
pickSupport
protected WWTexture
previousGeneratedTexture
protected WWTexture
previousSourceTexture
protected WWTexture
sourceTexture
protected java.util.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
Constructors Constructor Description SurfaceImage()
Create a new surface image with no image source.SurfaceImage(java.lang.Object imageSource, Sector sector)
Renders a single image tile from a local image source.SurfaceImage(java.lang.Object imageSource, java.lang.Iterable<? extends LatLon> corners)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
applyInternalTransform(DrawContext dc, boolean textureIdentityActive)
boolean
bind(DrawContext dc)
void
dispose()
Disposes of any internal resources allocated by the object.protected void
doDrag(DragContext dragContext)
void
drag(DragContext dragContext)
Drag the object given the providedDragContext
.protected void
draw(DrawContext dc)
boolean
equals(java.lang.Object o)
void
export(java.lang.String mimeType, java.lang.Object output)
Export the Surface Image.protected void
exportAsKML(java.lang.Object output)
Export the surface image to KML as a<GroundOverlay>
element.protected void
exportKMLLatLonBox(javax.xml.stream.XMLStreamWriter xmlWriter)
protected void
exportKMLLatLonQuad(javax.xml.stream.XMLStreamWriter xmlWriter)
java.util.List<LatLon>
getCorners()
double
getDistanceFromEye()
Returns the ordered renderable's distance from the current view's eye point.Extent
getExtent(DrawContext dc)
java.lang.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(java.lang.Iterable<? extends LatLon> corners)
protected void
initializeSourceTexture(DrawContext dc)
boolean
isAlwaysOnTop()
Indicates the state of this surface image's always-on-top flag.boolean
isDragEnabled()
Indicates whether the object is enabled for dragging.java.lang.String
isExportFormatSupported(java.lang.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
pick(DrawContext dc, java.awt.Point pickPoint)
Executes a pick of the ordered renderable.void
preRender(DrawContext dc)
void
render(DrawContext dc)
Causes thisRenderable
to render itself using the provided draw context.void
setAlwaysOnTop(boolean alwaysOnTop)
Specifies whether this surface image should appear on top of other image layers and surface shapes in the scene.void
setCorners(java.lang.Iterable<? extends LatLon> corners)
void
setDragEnabled(boolean enabled)
Controls whether the object is enabled for dragging.void
setImageSource(java.lang.Object imageSource, Sector sector)
void
setImageSource(java.lang.Object imageSource, java.lang.Iterable<? extends LatLon> corners)
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, 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
-
alwaysOnTop
protected boolean alwaysOnTop
-
pickSupport
protected PickSupport pickSupport
-
pickLayer
protected Layer pickLayer
-
imageSource
protected java.lang.Object imageSource
-
sourceTexture
protected WWTexture sourceTexture
-
generatedTexture
protected WWTexture generatedTexture
-
corners
protected java.util.List<LatLon> corners
-
previousSourceTexture
protected WWTexture previousSourceTexture
-
previousGeneratedTexture
protected WWTexture previousGeneratedTexture
-
generatedTextureExpired
protected boolean generatedTextureExpired
-
dragEnabled
protected boolean dragEnabled
-
draggableSupport
protected DraggableSupport draggableSupport
-
thisList
protected java.util.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(java.lang.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 aBufferedImage
reference.sector
- the sector covered by the image.
-
SurfaceImage
public SurfaceImage(java.lang.Object imageSource, java.lang.Iterable<? extends LatLon> corners)
-
-
Method Detail
-
dispose
public void dispose()
Description copied from interface:Disposable
Disposes of any internal resources allocated by the object.- Specified by:
dispose
in interfaceDisposable
-
setImageSource
public void setImageSource(java.lang.Object imageSource, Sector sector)
-
setImageSource
public void setImageSource(java.lang.Object imageSource, java.lang.Iterable<? extends LatLon> corners)
-
isPickEnabled
public boolean isPickEnabled()
-
setPickEnabled
public void setPickEnabled(boolean pickEnabled)
-
isAlwaysOnTop
public boolean isAlwaysOnTop()
Indicates the state of this surface image's always-on-top flag.- Returns:
true
if the always-on-top flag is set, otherwisefalse
.- See Also:
setAlwaysOnTop(boolean)
-
setAlwaysOnTop
public void setAlwaysOnTop(boolean alwaysOnTop)
Specifies whether this surface image should appear on top of other image layers and surface shapes in the scene. If the flag istrue
, this surface image appears visually above other image layers and surface shapes. Otherwise, this surface image appears interleaved with other image layers according to its relative order in the layer list, and appears beneath all surface shapes. The default isfalse
.- Parameters:
alwaysOnTop
-true
if the surface image should appear always on top, otherwisefalse
.
-
initializeGeometry
protected void initializeGeometry(java.lang.Iterable<? extends LatLon> corners)
-
getImageSource
public java.lang.Object getImageSource()
-
getOpacity
public double getOpacity()
-
setOpacity
public void setOpacity(double opacity)
-
getSector
public Sector getSector()
- Specified by:
getSector
in interfaceSurfaceTile
-
setCorners
public void setCorners(java.lang.Iterable<? extends LatLon> corners)
-
getCorners
public java.util.List<LatLon> getCorners()
- Specified by:
getCorners
in interfaceSurfaceTile
-
getExtent
public Extent getExtent(DrawContext dc)
- Specified by:
getExtent
in interfaceSurfaceTile
-
bind
public boolean bind(DrawContext dc)
- Specified by:
bind
in interfaceSurfaceTile
-
applyInternalTransform
public void applyInternalTransform(DrawContext dc, boolean textureIdentityActive)
- Specified by:
applyInternalTransform
in interfaceSurfaceTile
-
getDistanceFromEye
public double getDistanceFromEye()
Description copied from interface:OrderedRenderable
Returns the ordered renderable's distance from the current view's eye point. Intended to be used only to sort a list of ordered renderables according to eye distance, and only during frame generation when a view is active.- Specified by:
getDistanceFromEye
in interfaceOrderedRenderable
- Returns:
- the distance of the ordered renderable from the current view's eye point.
-
preRender
public void preRender(DrawContext dc)
- Specified by:
preRender
in interfacePreRenderable
-
render
public void render(DrawContext dc)
Description copied from interface:Renderable
Causes thisRenderable
to render itself using the provided draw context.- Specified by:
render
in interfaceRenderable
- Parameters:
dc
- theDrawContext
to be used- See Also:
DrawContext
-
pick
public void pick(DrawContext dc, java.awt.Point pickPoint)
Description copied from interface:OrderedRenderable
Executes a pick of the ordered renderable.- Specified by:
pick
in interfaceOrderedRenderable
- Parameters:
dc
- the current draw context.pickPoint
- the pick point.
-
draw
protected void draw(DrawContext dc)
-
initializeSourceTexture
protected void initializeSourceTexture(DrawContext dc)
-
initializeGeneratedTexture
protected WWTexture initializeGeneratedTexture(DrawContext dc)
-
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.
-
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.
-
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 interfaceMovable
- Returns:
- the object's reference position, or null if no reference position is available.
-
setReferencePosition
protected void setReferencePosition(Position referencePosition)
-
isDragEnabled
public boolean isDragEnabled()
Description copied from interface:Draggable
Indicates whether the object is enabled for dragging.- Specified by:
isDragEnabled
in interfaceDraggable
- Returns:
- true if the object is enabled, else false.
-
setDragEnabled
public void setDragEnabled(boolean enabled)
Description copied from interface:Draggable
Controls whether the object is enabled for dragging.- Specified by:
setDragEnabled
in interfaceDraggable
- Parameters:
enabled
-true
if the object is enabled, elsefalse
.
-
drag
public void drag(DragContext dragContext)
Description copied from interface:Draggable
Drag the object given the providedDragContext
.- Specified by:
drag
in interfaceDraggable
- Parameters:
dragContext
- theDragContext
of this dragging event.
-
doDrag
protected void doDrag(DragContext dragContext)
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
isExportFormatSupported
public java.lang.String isExportFormatSupported(java.lang.String format)
Does this object support a certain export format?- Specified by:
isExportFormatSupported
in interfaceExportable
- Parameters:
format
- Desired export format.- Returns:
- One of
Exportable.FORMAT_SUPPORTED
,Exportable.FORMAT_NOT_SUPPORTED
, orExportable.FORMAT_PARTIALLY_SUPPORTED
. - See Also:
Exportable.export(String, Object)
-
export
public void export(java.lang.String mimeType, java.lang.Object output) throws java.io.IOException
Export the Surface Image. Theoutput
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 interfaceExportable
- 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:
java.io.IOException
- If an exception occurs writing to the output object.- See Also:
Exportable.isExportFormatSupported(String)
-
exportAsKML
protected void exportAsKML(java.lang.Object output) throws java.io.IOException, javax.xml.stream.XMLStreamException
Export the surface image to KML as a<GroundOverlay>
element. Theoutput
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:
javax.xml.stream.XMLStreamException
- If an exception occurs while writing the KMLjava.io.IOException
- if an exception occurs while exporting the data.- See Also:
export(String, Object)
-
exportKMLLatLonBox
protected void exportKMLLatLonBox(javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException
- Throws:
javax.xml.stream.XMLStreamException
-
exportKMLLatLonQuad
protected void exportKMLLatLonQuad(javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException
- Throws:
javax.xml.stream.XMLStreamException
-
-