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
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
Fields Modifier and Type Field Description protected booleanalwaysOnTopprotected java.util.List<LatLon>cornersprotected booleandragEnabledprotected DraggableSupportdraggableSupportprotected WWTexturegeneratedTextureprotected booleangeneratedTextureExpiredprotected java.lang.ObjectimageSourceprotected LayerpickLayerprotected PickSupportpickSupportprotected WWTexturepreviousGeneratedTextureprotected WWTexturepreviousSourceTextureprotected WWTexturesourceTextureprotected java.util.List<SurfaceImage>thisListA 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 voidapplyInternalTransform(DrawContext dc, boolean textureIdentityActive)booleanbind(DrawContext dc)voiddispose()Disposes of any internal resources allocated by the object.protected voiddoDrag(DragContext dragContext)voiddrag(DragContext dragContext)Drag the object given the providedDragContext.protected voiddraw(DrawContext dc)booleanequals(java.lang.Object o)voidexport(java.lang.String mimeType, java.lang.Object output)Export the Surface Image.protected voidexportAsKML(java.lang.Object output)Export the surface image to KML as a<GroundOverlay>element.protected voidexportKMLLatLonBox(javax.xml.stream.XMLStreamWriter xmlWriter)protected voidexportKMLLatLonQuad(javax.xml.stream.XMLStreamWriter xmlWriter)java.util.List<LatLon>getCorners()doublegetDistanceFromEye()Returns the ordered renderable's distance from the current view's eye point.ExtentgetExtent(DrawContext dc)java.lang.ObjectgetImageSource()doublegetOpacity()PositiongetReferencePosition()A position associated with the object that indicates its aggregate geographic position.SectorgetSector()inthashCode()protected WWTextureinitializeGeneratedTexture(DrawContext dc)protected voidinitializeGeometry(java.lang.Iterable<? extends LatLon> corners)protected voidinitializeSourceTexture(DrawContext dc)booleanisAlwaysOnTop()Indicates the state of this surface image's always-on-top flag.booleanisDragEnabled()Indicates whether the object is enabled for dragging.java.lang.StringisExportFormatSupported(java.lang.String format)Does this object support a certain export format?booleanisPickEnabled()voidmove(Position delta)Shift the shape over the globe's surface while maintaining its original azimuth, its orientation relative to North.voidmoveTo(Position position)Move the shape over the globe's surface while maintaining its original azimuth, its orientation relative to North.voidpick(DrawContext dc, java.awt.Point pickPoint)Executes a pick of the ordered renderable.voidpreRender(DrawContext dc)voidrender(DrawContext dc)Causes thisRenderableto render itself using the provided draw context.voidsetAlwaysOnTop(boolean alwaysOnTop)Specifies whether this surface image should appear on top of other image layers and surface shapes in the scene.voidsetCorners(java.lang.Iterable<? extends LatLon> corners)voidsetDragEnabled(boolean enabled)Controls whether the object is enabled for dragging.voidsetImageSource(java.lang.Object imageSource, Sector sector)voidsetImageSource(java.lang.Object imageSource, java.lang.Iterable<? extends LatLon> corners)voidsetOpacity(double opacity)voidsetPickEnabled(boolean pickEnabled)protected voidsetReferencePosition(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 aBufferedImagereference.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:DisposableDisposes of any internal resources allocated by the object.- Specified by:
disposein 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:
trueif 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-trueif 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:
getSectorin interfaceSurfaceTile
-
setCorners
public void setCorners(java.lang.Iterable<? extends LatLon> corners)
-
getCorners
public java.util.List<LatLon> getCorners()
- Specified by:
getCornersin interfaceSurfaceTile
-
getExtent
public Extent getExtent(DrawContext dc)
- Specified by:
getExtentin interfaceSurfaceTile
-
bind
public boolean bind(DrawContext dc)
- Specified by:
bindin interfaceSurfaceTile
-
applyInternalTransform
public void applyInternalTransform(DrawContext dc, boolean textureIdentityActive)
- Specified by:
applyInternalTransformin interfaceSurfaceTile
-
getDistanceFromEye
public double getDistanceFromEye()
Description copied from interface:OrderedRenderableReturns 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:
getDistanceFromEyein interfaceOrderedRenderable- Returns:
- the distance of the ordered renderable from the current view's eye point.
-
preRender
public void preRender(DrawContext dc)
- Specified by:
preRenderin interfacePreRenderable
-
render
public void render(DrawContext dc)
Description copied from interface:RenderableCauses thisRenderableto render itself using the provided draw context.- Specified by:
renderin interfaceRenderable- Parameters:
dc- theDrawContextto be used- See Also:
DrawContext
-
pick
public void pick(DrawContext dc, java.awt.Point pickPoint)
Description copied from interface:OrderedRenderableExecutes a pick of the ordered renderable.- Specified by:
pickin 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:MovableShift 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:MovableMove 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:MovableA 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:
getReferencePositionin 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:DraggableIndicates whether the object is enabled for dragging.- Specified by:
isDragEnabledin interfaceDraggable- Returns:
- true if the object is enabled, else false.
-
setDragEnabled
public void setDragEnabled(boolean enabled)
Description copied from interface:DraggableControls whether the object is enabled for dragging.- Specified by:
setDragEnabledin interfaceDraggable- Parameters:
enabled-trueif the object is enabled, elsefalse.
-
drag
public void drag(DragContext dragContext)
Description copied from interface:DraggableDrag the object given the providedDragContext.- Specified by:
dragin interfaceDraggable- Parameters:
dragContext- theDragContextof this dragging event.
-
doDrag
protected void doDrag(DragContext dragContext)
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
isExportFormatSupported
public java.lang.String isExportFormatSupported(java.lang.String format)
Does this object support a certain export format?- Specified by:
isExportFormatSupportedin 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.IOExceptionExport the Surface Image. Theoutputobject 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:
exportin 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.XMLStreamExceptionExport the surface image to KML as a<GroundOverlay>element. Theoutputobject 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
-
-