Class SurfaceIcon
- java.lang.Object
-
- All Implemented Interfaces:
AVList,Draggable,MessageListener,Movable,OrderedRenderable,PreRenderable,Renderable,SurfaceObject,SurfaceRenderable,WWObject,java.beans.PropertyChangeListener,java.util.EventListener
- Direct Known Subclasses:
SurfaceIcons
public class SurfaceIcon extends AbstractSurfaceRenderable implements Movable, Draggable
Renders an icon image over the terrain surface.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classSurfaceIcon.SectorInfo-
Nested classes/interfaces inherited from class gov.nasa.worldwind.render.AbstractSurfaceObject
AbstractSurfaceObject.CacheEntry, AbstractSurfaceObject.SurfaceObjectStateKey
-
-
Field Summary
Fields Modifier and Type Field Description protected booleandragEnabledprotected DraggableSupportdraggableSupportprotected intimageHeightprotected intimageWidthprotected WWTexturetexture-
Fields inherited from class gov.nasa.worldwind.render.AbstractSurfaceObject
delegateOwner, drawBoundingSectors, enableBatchPicking, extentCache, lastModifiedTime, nextUniqueId, pickLayer, pickSupport, pickTileBuilder, uniqueId, visible
-
-
Constructor Summary
Constructors Constructor Description SurfaceIcon(java.lang.Object imageSource)SurfaceIcon(java.lang.Object imageSource, LatLon location)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidapplyDrawColor(DrawContext dc)protected voidapplyDrawTransform(DrawContext dc, SurfaceTileDrawContext sdc, LatLon location, double drawScale)protected voidbeginDraw(DrawContext dc)protected java.awt.geom.Rectangle2D.DoublecomputeDrawDimension(double pixelSize)protected java.awt.geom.Rectangle2D.DoublecomputeDrawDimension(DrawContext dc, LatLon location)protected AnglecomputeDrawHeading(DrawContext dc)protected doublecomputeDrawScale(DrawContext dc, SurfaceTileDrawContext sdc, LatLon location)protected java.util.List<Sector>computeSectors(DrawContext dc)protected voiddoDrag(DragContext dragContext)voiddrag(DragContext dragContext)Drag the object given the providedDragContext.voiddrawGeographic(DrawContext dc, SurfaceTileDrawContext sdc)Causes the SurfaceObject to render itself to the specified region in geographic coordinates.protected voiddrawIcon(DrawContext dc, SurfaceTileDrawContext sdc)protected voidendDraw(DrawContext dc)java.awt.ColorgetColor()Get theColorthe source image is combined with.ExtentgetExtent(DrawContext dc)Returns the surface object's enclosing volume as anExtentin model coordinates, given a specifiedDrawContext.AnglegetHeading()Get the current headingAngle, clockwise from North ornull.java.lang.ObjectgetImageSource()Get the source for the icon image.LatLongetLocation()Get the icon reference location on the globe.Vec4getLocationOffset()Get the icon displacement in pixels relative to the reference location.doublegetMaxSize()Get the maximum size in meter the icon image is allowed to be enlarged to once applied to the terrain surface.doublegetMinSize()Get the minimum size in meter the icon image is allowed to be reduced to once applied to the terrain surface.PositiongetReferencePosition()A position associated with the object that indicates its aggregate geographic position.doublegetScale()Get the current scaling factor applied to the source image.java.util.List<Sector>getSectors(DrawContext dc)Returns a list of sectors indicating the geographic region that bounds this renderable for the specified draw context.java.lang.ObjectgetStateKey(DrawContext dc)Returns an object that uniquely identifies this renderable's state for the specified draw context.protected WWTexturegetTexture()booleanisDragEnabled()Indicates whether the object is enabled for dragging.protected booleanisMaintainAppearance()booleanisMaintainSize()Determines whether the icon constantly maintains it's apparent size.booleanisUseMipMaps()Returns whether the icon will apply mip-map filtering to it's source image.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.voidsetColor(java.awt.Color color)Set theColorthe source image will be combined with - default to white.voidsetDragEnabled(boolean enabled)Controls whether the object is enabled for dragging.voidsetHeading(Angle heading)Set the headingAngle, clockwise from North.voidsetImageSource(java.lang.Object imageSource)Set the source for the icon image.voidsetLocation(LatLon location)Set the icon reference location on the globe.voidsetLocationOffset(Vec4 locationOffset)Set the icon displacement in pixels relative to the reference location.voidsetMaintainSize(boolean state)Sets whether the icon constantly maintains it's apparent size.voidsetMaxSize(double sizeInMeter)Get the maximum size in meter the icon image is allowed to be enlarged to once applied to the terrain surface.voidsetMinSize(double sizeInMeter)Set the minimum size in meter the icon image is allowed to be reduced to once applied to the terrain surface.voidsetScale(double scale)Set the scaling factor to apply to the source image.voidsetUseMipMaps(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, computeHemisphereOffset, computeNormalizedSectors, computePixelSizeAtLocation, computeRotatedSectorBounds, getOpacity, getViewHeading, setOpacity
-
Methods inherited from class gov.nasa.worldwind.render.AbstractSurfaceObject
buildPickRepresentation, clearCaches, computeExtent, computeExtent, createPickedObject, createPickTileBuilder, drawBoundingSectors, drawOrderedRenderable, drawPickRepresentation, getDelegateOwner, getDistanceFromEye, getUniqueId, intersectsFrustum, intersectsPickFrustum, intersectsVisibleSector, isDrawBoundingSectors, isEnableBatchPicking, isVisible, makeOrderedPreRenderable, makeOrderedRenderable, nextUniqueId, onShapeChanged, pick, pickBatched, pickOrderedRenderable, preRender, render, setDelegateOwner, setDrawBoundingSectors, setEnableBatchPicking, setVisible, updateModifiedTime
-
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
-
texture
protected WWTexture texture
-
imageWidth
protected int imageWidth
-
imageHeight
protected int imageHeight
-
dragEnabled
protected boolean dragEnabled
-
draggableSupport
protected DraggableSupport draggableSupport
-
-
Constructor Detail
-
SurfaceIcon
public SurfaceIcon(java.lang.Object imageSource)
-
SurfaceIcon
public SurfaceIcon(java.lang.Object imageSource, LatLon location)
-
-
Method Detail
-
getLocation
public LatLon getLocation()
Get the icon reference location on the globe.- Returns:
- the icon reference location on the globe.
-
setLocation
public void setLocation(LatLon location)
Set the icon reference location on the globe.- Parameters:
location- the icon reference location on the globe.- Throws:
java.lang.IllegalArgumentException- if location isnull.
-
getLocationOffset
public Vec4 getLocationOffset()
Get the icon displacement in pixels relative to the reference location. Can benull.When
nullthe icon will be drawn with it's image center on top of it's reference location - seesetLocation(LatLon). Otherwise the icon will be shifted of a distance equivalent to the number of pixels specified asxandyoffset values. Positive values will move the icon to the right forxand up fory. Negative values will have the opposite effect.- Returns:
- the icon displacement in pixels relative to the reference location.
-
setLocationOffset
public void setLocationOffset(Vec4 locationOffset)
Set the icon displacement in pixels relative to the reference location. Can benull.When
nullthe icon will be drawn with it's image center on top of it's refence location - seesetLocation(LatLon). Otherwise the icon will be shifted of a distance equivalent to the number of pixels specified asxandyoffset values. Positive values will move the icon to the right forxand up fory. Negative values will have the opposite effect.- Parameters:
locationOffset- the icon displacement in pixels relative to the reference location.
-
getImageSource
public java.lang.Object getImageSource()
Get the source for the icon image. Can be a file path to a local image or aBufferedImagereference.- Returns:
- the source for the icon image.
-
setImageSource
public void setImageSource(java.lang.Object imageSource)
Set the source for the icon image. Can be a file path to a local image or aBufferedImagereference.- Parameters:
imageSource- the source for the icon image.- Throws:
java.lang.IllegalArgumentException- if imageSource isnull.
-
isUseMipMaps
public boolean isUseMipMaps()
Returns whether the icon will apply mip-map filtering to it's source image. Iftruethe icon image is drawn using mip-maps. Iffalsethe icon is drawn without mip-maps, resulting in aliasing if the icon image is drawn smaller than it's native size in pixels.- Returns:
trueif the icon image is drawn with mip-map filtering;falseotherwise.
-
setUseMipMaps
public void setUseMipMaps(boolean useMipMaps)
Sets whether the icon will apply mip-map filtering to it's source image. Iftruethe icon image is drawn using mip-maps. Iffalsethe 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-trueif the icon image should be drawn with mip-map filtering;falseotherwise.
-
getScale
public double getScale()
Get the current scaling factor applied to the source image.- Returns:
- the current scaling factor applied to the source image.
-
setScale
public void setScale(double scale)
Set the scaling factor to apply to the source image. A value of1will produce no change, a value greater then1will enlarge the image and a value smaller then1will reduce it.- Parameters:
scale- the scaling factor to apply to the source image.- Throws:
java.lang.IllegalArgumentException- if scale is zero or negative.
-
getHeading
public Angle getHeading()
Get the current headingAngle, clockwise from North ornull.- Returns:
- the current heading
Angle, clockwise from North ornull.
-
setHeading
public void setHeading(Angle heading)
Set the headingAngle, clockwise from North. Setting this value tonullwill 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 headingAngle, clockwise from North ornull.
-
isMaintainSize
public boolean isMaintainSize()
Determines whether the icon constantly maintains it's apparent size. Iftruethe icon is constantly redrawn at the proper size depending on it's distance from the eye. Iffalsethe 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:
trueif the icon constantly maintains it's apparent size.
-
setMaintainSize
public void setMaintainSize(boolean state)
Sets whether the icon constantly maintains it's apparent size. Iftruethe icon is constantly redrawn at the proper size depending on it's distance from the eye. Iffalsethe 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-trueif the icon should constantly maintains it's apparent size.
-
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)andsetMaxSize(double).- Returns:
- the minimum 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)andsetMaxSize(double).- Parameters:
sizeInMeter- the minimum size of the icon in meter.
-
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)andsetMaxSize(double).- Returns:
- the maximum size of the icon in meter.
-
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)andsetMaxSize(double).- Parameters:
sizeInMeter- the maximum size of the icon in meter.
-
getColor
public java.awt.Color getColor()
Get theColorthe source image is combined with.- Returns:
- the
Colorthe source image is combined with.
-
setColor
public void setColor(java.awt.Color color)
Set theColorthe 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- theColorthe source image will be combined with.- Throws:
java.lang.IllegalArgumentException- if color isnull.
-
isMaintainAppearance
protected boolean isMaintainAppearance()
-
getStateKey
public java.lang.Object getStateKey(DrawContext dc)
Returns an object that uniquely identifies this renderable's state for the specified draw context.Callers can perform an equality test on two state keys using
Object.equals(Object)in order to determine whether or not a renderable has changed. The returned object is guaranteed to be globally unique with respect to other SurfaceRenderable state keys; an equality test with a state key from another renderable always returns false.Overridden to return a unique state key if the icon is configured to always redraw. SurfaceIcon does not use a cached representation if it's heading is configured to follow the view, or if it's configured to maintain a constant screen size.
- Specified by:
getStateKeyin interfaceSurfaceRenderable- Overrides:
getStateKeyin classAbstractSurfaceObject- Parameters:
dc- the draw context for which to determine this renderable's current state.- Returns:
- an object representing this renderable's current state.
- See Also:
getHeading(),isMaintainSize()
-
getSectors
public java.util.List<Sector> getSectors(DrawContext dc)
Description copied from interface:SurfaceRenderableReturns a list of sectors indicating the geographic region that bounds this renderable for the specified draw context.The returned list typically contains one sector that bounds this renderable in geographic coordinates. When this renderable spans the anti-meridian - the +/- 180 degree meridian - the returned list contains two sectors, one on either side of the anti-meridian.
- Specified by:
getSectorsin interfaceSurfaceRenderable- Parameters:
dc- the draw context for which to determine this renderable's geographic bounds.- Returns:
- a list of one or two sectors that bound this renderable.
-
getExtent
public Extent getExtent(DrawContext dc)
Description copied from class:AbstractSurfaceObjectReturns the surface object's enclosing volume as anExtentin model coordinates, given a specifiedDrawContext.- Specified by:
getExtentin interfaceSurfaceObject- Overrides:
getExtentin classAbstractSurfaceObject- Parameters:
dc- the current draw context.- Returns:
- the surface object's Extent in model coordinates.
-
drawGeographic
public void drawGeographic(DrawContext dc, SurfaceTileDrawContext sdc)
Description copied from class:AbstractSurfaceObjectCauses the SurfaceObject to render itself to the specified region in geographic coordinates. The specified viewport denotes the geographic region and its corresponding screen viewport.- Specified by:
drawGeographicin classAbstractSurfaceObject- Parameters:
dc- the current draw context.sdc- the context containing a geographic region and screen viewport corresponding to a surface tile.
-
computeSectors
protected java.util.List<Sector> computeSectors(DrawContext dc)
-
computeDrawDimension
protected java.awt.geom.Rectangle2D.Double computeDrawDimension(DrawContext dc, LatLon location)
-
computeDrawDimension
protected java.awt.geom.Rectangle2D.Double computeDrawDimension(double pixelSize)
-
computeDrawHeading
protected Angle computeDrawHeading(DrawContext dc)
-
beginDraw
protected void beginDraw(DrawContext dc)
-
endDraw
protected void endDraw(DrawContext dc)
-
applyDrawTransform
protected void applyDrawTransform(DrawContext dc, SurfaceTileDrawContext sdc, LatLon location, double drawScale)
-
computeDrawScale
protected double computeDrawScale(DrawContext dc, SurfaceTileDrawContext sdc, LatLon location)
-
applyDrawColor
protected void applyDrawColor(DrawContext dc)
-
drawIcon
protected void drawIcon(DrawContext dc, SurfaceTileDrawContext sdc)
-
getTexture
protected WWTexture getTexture()
-
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.
-
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.
-
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)
-
-