Package gov.nasa.worldwind.render
Class ScreenImage
- java.lang.Object
-
- gov.nasa.worldwind.avlist.AVListImpl
-
- gov.nasa.worldwind.WWObjectImpl
-
- gov.nasa.worldwind.render.ScreenImage
-
- All Implemented Interfaces:
AVList,MessageListener,Exportable,Renderable,WWObject,java.beans.PropertyChangeListener,java.util.EventListener
- Direct Known Subclasses:
KMLScreenImageImpl,ScreenCreditImage
public class ScreenImage extends WWObjectImpl implements Renderable, Exportable
Draws an image parallel to the screen at a specified screen location relative to the WorldWindow. If no image is specified, a filled rectangle is drawn in its place.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classScreenImage.OrderedImage
-
Field Summary
Fields Modifier and Type Field Description protected java.awt.PointawtScreenLocationIndicates the location of this screen image in the viewport (on the screen) in AWT coordinates.protected java.awt.Colorcolorprotected java.lang.ObjectdelegateOwnerprotected doubledxprotected doubledyprotected longframeNumberprotected intheightprotected OffsetimageOffsetprotected java.lang.ObjectimageSourceprotected doubleopacityprotected ScreenImage.OrderedImageorderedImageprotected intoriginalImageHeightprotected intoriginalImageWidthprotected LayerpickLayerprotected PickSupportpickSupportprotected java.lang.Doublerotationprotected OffsetrotationOffsetprotected java.awt.PointrotationPointprotected java.awt.PointscreenLocationIndicates the location of this screen image in the viewport (on the screen) in OpenGL coordinates.protected OffsetscreenOffsetprotected Sizesizeprotected BasicWWTexturetextureprotected intwidth-
Fields inherited from interface gov.nasa.worldwind.Exportable
FORMAT_NOT_SUPPORTED, FORMAT_PARTIALLY_SUPPORTED, FORMAT_SUPPORTED
-
-
Constructor Summary
Constructors Constructor Description ScreenImage()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcomputeOffsets(DrawContext dc)Compute the image size, rotation, and position based on the current viewport size.protected voiddoRender(DrawContext dc)protected voiddraw(DrawContext dc)voidexport(java.lang.String mimeType, java.lang.Object output)Export the screen image.protected voidexportAsKML(java.lang.Object output)Export the screen image to KML as a<ScreenOverlay>element.java.awt.ColorgetColor()If no image is set, or if the image is not yet available, a rectangle will be drawn in this color.java.lang.ObjectgetDelegateOwner()Indicates the object included inSelectEvents when this object is picked.intgetImageHeight(DrawContext dc)Returns the height of the image after dynamic scaling has been applied.OffsetgetImageOffset()Get the offset of the point on the image to align with the screen offset point.java.lang.ObjectgetImageSource()Returns the current image source.intgetImageWidth(DrawContext dc)Returns the width of the source image after dynamic scaling has been applied.doublegetOpacity()Returns the opacity of the surface.java.lang.DoublegetRotation()Get the rotation applied to the image.OffsetgetRotationOffset()Get the point about which the image is rotated.java.awt.PointgetScreenLocation()Returns the location of the image on the screen.java.awt.PointgetScreenLocation(DrawContext dc)Returns the location of the image on the screen.OffsetgetScreenOffset()Get the offset of the point on the screen to align with the image offset point.SizegetSize()Get the dimension to apply to the image.protected BasicWWTexturegetTexture()Get the texture for this image.protected BasicWWTextureinitializeTexture()Create and initialize the texture from the image source.java.lang.StringisExportFormatSupported(java.lang.String format)Does this object support a certain export format?voidpick(DrawContext dc, java.awt.Point pickPoint)voidrender(DrawContext dc)Causes thisRenderableto render itself using the provided draw context.voidsetColor(java.awt.Color defaultColor)Set the color of the rectangle drawn when the image cannot be drawn.voidsetDelegateOwner(java.lang.Object delegateOwner)Specify the object to identify as the picked object when this shape is picked.voidsetImageOffset(Offset imageOffset)Set the image offset point.voidsetImageSource(java.lang.Object imageSource)Specifies the image source, which may be either a file pathStringor aBufferedImage.voidsetOpacity(double opacity)Sets the opacity of the surface.voidsetRotation(java.lang.Double rotation)Specifies a rotation to be applied to the image.voidsetRotationOffset(Offset rotationOffset)Set the point on the image about which rotation is performed.voidsetScreenLocation(java.awt.Point screenLocation)Convenience method to specify the location of the image on the screen.voidsetScreenOffset(Offset screenOffset)Set the offset of the image relative to the viewport.voidsetSize(Size size)Set a dynamic dimension to apply to the image.-
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, equals, 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
-
imageSource
protected java.lang.Object imageSource
-
texture
protected BasicWWTexture texture
-
orderedImage
protected ScreenImage.OrderedImage orderedImage
-
pickSupport
protected PickSupport pickSupport
-
opacity
protected double opacity
-
rotation
protected java.lang.Double rotation
-
color
protected java.awt.Color color
-
delegateOwner
protected java.lang.Object delegateOwner
-
size
protected Size size
-
screenOffset
protected Offset screenOffset
-
imageOffset
protected Offset imageOffset
-
rotationOffset
protected Offset rotationOffset
-
frameNumber
protected long frameNumber
-
width
protected int width
-
height
protected int height
-
originalImageWidth
protected int originalImageWidth
-
originalImageHeight
protected int originalImageHeight
-
rotationPoint
protected java.awt.Point rotationPoint
-
screenLocation
protected java.awt.Point screenLocation
Indicates the location of this screen image in the viewport (on the screen) in OpenGL coordinates. This property is computed incomputeOffsetsand used indrawInitiallynull.
-
awtScreenLocation
protected java.awt.Point awtScreenLocation
Indicates the location of this screen image in the viewport (on the screen) in AWT coordinates. This property is assigned insetScreenLocationandcomputeOffsets. IncomputeOffsets, this is computed by converting thescreenLocationfrom OpenGL coordinates to AWT coordinates. Initiallynull.
-
dx
protected double dx
-
dy
protected double dy
-
pickLayer
protected Layer pickLayer
-
-
Method Detail
-
getScreenLocation
public java.awt.Point getScreenLocation()
Returns the location of the image on the screen. The position is relative to the upper-left corner of the World Window. The point specified by the image offset will be aligned to this point. If the position was specified as an offset, it may change if the viewport size changes. The value returned by this method is the most recently computed screen location. CallgetScreenLocation(DrawContext)to ensure an accurate result based on the current viewport.- Returns:
- the current screen position.
- See Also:
getScreenLocation(DrawContext),getImageOffset(),getScreenOffset()
-
getScreenLocation
public java.awt.Point getScreenLocation(DrawContext dc)
Returns the location of the image on the screen. The position is relative to the upper-left corner of the World Window. The image is centered on this position.- Parameters:
dc- The DrawContext in which the image will be drawn.- Returns:
- the current screen position.
-
setScreenLocation
public void setScreenLocation(java.awt.Point screenLocation)
Convenience method to specify the location of the image on the screen. The specifiedscreenLocationis relative to the upper-left corner of the WorldWindow, and the image is centered on this location.- Parameters:
screenLocation- the screen location on which to center the image. May be null, in which case the image is not displayed.- See Also:
setScreenOffset(Offset),setImageOffset(Offset)
-
getScreenOffset
public Offset getScreenOffset()
Get the offset of the point on the screen to align with the image offset point.- Returns:
- Offset of the image point that will be aligned to the image offset point.
- See Also:
getImageOffset()
-
setScreenOffset
public void setScreenOffset(Offset screenOffset)
Set the offset of the image relative to the viewport. The screen point identified by this offset will be aligned to the image point identified by the image offset.- Parameters:
screenOffset- The screen offset.- See Also:
setImageOffset(Offset)
-
getImageOffset
public Offset getImageOffset()
Get the offset of the point on the image to align with the screen offset point.- Returns:
- Offset of the image point that will be aligned to the screen offset point.
- See Also:
getScreenOffset()
-
setImageOffset
public void setImageOffset(Offset imageOffset)
Set the image offset point. This point will be aligned to the screen point identified by the screen offset.- Parameters:
imageOffset- Offset that identifies a point on the image to align with the screen offset point.- See Also:
setScreenOffset(Offset)
-
getRotation
public java.lang.Double getRotation()
Get the rotation applied to the image.- Returns:
- Rotation in decimal degrees, or null if there is no rotation.
- See Also:
getRotationOffset()
-
setRotation
public void setRotation(java.lang.Double rotation)
Specifies a rotation to be applied to the image.- Parameters:
rotation- Rotation in decimal degrees.- See Also:
setRotationOffset(Offset)
-
getRotationOffset
public Offset getRotationOffset()
Get the point about which the image is rotated.- Returns:
- Rotation point in image coordinates, or null if there is no rotation point set. The origin of the coordinate system is at the lower left corner of the image.
- See Also:
getRotation()
-
setRotationOffset
public void setRotationOffset(Offset rotationOffset)
Set the point on the image about which rotation is performed.- Parameters:
rotationOffset- Rotation offset.- See Also:
setRotation(Double)
-
getSize
public Size getSize()
Get the dimension to apply to the image.- Returns:
- Image dimension.
-
setSize
public void setSize(Size size)
Set a dynamic dimension to apply to the image. The dimension allows the image to be scaled relative to the viewport size.- Parameters:
size- Image dimension. May not be null.
-
getImageSource
public java.lang.Object getImageSource()
Returns the current image source.- Returns:
- the current image source.
- See Also:
getImageSource()
-
setImageSource
public void setImageSource(java.lang.Object imageSource)
Specifies the image source, which may be either a file pathStringor aBufferedImage. If the image is not already in memory, it will be loaded in the background.- Parameters:
imageSource- the image source, either a file pathStringor aBufferedImage.- Throws:
java.lang.IllegalArgumentException- if theimageSourceis null.
-
initializeTexture
protected BasicWWTexture initializeTexture()
Create and initialize the texture from the image source. If the image is not in memory this method will request that it be loaded and return null.- Returns:
- The texture, or null if the texture is not yet available.
-
getOpacity
public double getOpacity()
Returns the opacity of the surface. A value of 1 or greater means the surface is fully opaque, a value of 0 means that the surface is fully transparent.- Returns:
- the surface opacity.
-
getColor
public java.awt.Color getColor()
If no image is set, or if the image is not yet available, a rectangle will be drawn in this color.- Returns:
- The color for the default rectangle.
-
setColor
public void setColor(java.awt.Color defaultColor)
Set the color of the rectangle drawn when the image cannot be drawn. The image may not be drawn because it has not been loaded, or because no image has been set.- Parameters:
defaultColor- New color for the default rectangle.
-
setOpacity
public void setOpacity(double opacity)
Sets the opacity of the surface. A value of 1 or greater means the surface is fully opaque, a value of 0 means that the surface is fully transparent.- Parameters:
opacity- a positive value indicating the opacity of the surface.- Throws:
java.lang.IllegalArgumentException- if the specified opacity is less than zero.
-
getImageWidth
public int getImageWidth(DrawContext dc)
Returns the width of the source image after dynamic scaling has been applied. If no image has been specified, but a dimension has been specified, the width of the dimension is returned.- Parameters:
dc- the current draw context.- Returns:
- the source image width after scaling.
- See Also:
getSize()
-
getImageHeight
public int getImageHeight(DrawContext dc)
Returns the height of the image after dynamic scaling has been applied. If no image has been specified, but a dimension has been specified, the height of the dimension is returned.- Parameters:
dc- the current draw context.- Returns:
- the source image height after scaling.
- See Also:
getSize()
-
getDelegateOwner
public java.lang.Object getDelegateOwner()
Indicates the object included inSelectEvents when this object is picked.- Returns:
- the object identified as the picked object.
-
setDelegateOwner
public void setDelegateOwner(java.lang.Object delegateOwner)
Specify the object to identify as the picked object when this shape is picked.- Parameters:
delegateOwner- the object included inSelectEvents as the picked object.
-
computeOffsets
protected void computeOffsets(DrawContext dc)
Compute the image size, rotation, and position based on the current viewport size. This method updates the calculated values for screen point, rotation point, width, and height. The calculation is not performed if the values have already been calculated for this frame.- Parameters:
dc- DrawContext into which the image will be rendered.
-
getTexture
protected BasicWWTexture getTexture()
Get the texture for this image. The texture is loaded on a background thread. This method will return null until the texture has been loaded.- Returns:
- The texture or null if the texture is not yet available.
-
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)
-
doRender
protected void doRender(DrawContext dc)
-
draw
protected void draw(DrawContext dc)
-
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 screen 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 screen image to KML as a<ScreenOverlay>element. Theoutputobject will receive the data. This object must be one of: java.io.Writer java.io.OutputStream javax.xml.stream.XMLStreamWriter.The image path can only be exported if the image source is a path or URL. If the image source is a BufferedImage, for example, the image will not be exported and no icon reference will be written into the ScreenOverlay tag.
- 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)
-
-