NASA World Wind

gov.nasa.worldwind.layers
Class ScalebarLayer

java.lang.Object
  extended by gov.nasa.worldwind.avlist.AVListImpl
      extended by gov.nasa.worldwind.WWObjectImpl
          extended by gov.nasa.worldwind.layers.AbstractLayer
              extended by gov.nasa.worldwind.layers.RenderableLayer
                  extended by gov.nasa.worldwind.layers.ScalebarLayer
All Implemented Interfaces:
AVList, Disposable, Layer, Restorable, WWObject, PropertyChangeListener, EventListener

public class ScalebarLayer
extends RenderableLayer

Renders a scalebar graphic in a screen corner.


Field Summary
static String NORTHEAST
           
static String NORTHWEST
           
static String RESIZE_KEEP_FIXED_SIZE
           
static String RESIZE_SHRINK_ONLY
           
static String RESIZE_STRETCH
           
static String SOUTHEAST
           
static String SOUTHWEST
           
static String UNIT_IMPERIAL
           
static String UNIT_METRIC
           
 
Fields inherited from class gov.nasa.worldwind.avlist.AVListImpl
changeSupport
 
Constructor Summary
ScalebarLayer()
          Renders a scalebar graphic in a screen corner
 
Method Summary
 void dispose()
          Disposes the contents of this layer's internal Renderable collection, but does not remove any elements from that collection.
 void doRender(DrawContext dc)
           
 void draw(DrawContext dc)
           
 int getBorderWidth()
           
 Color getColor()
          Get the scalebar color
 Font getFont()
          Get the scalebar legend Fon
 String getPosition()
           
 String getResizeBehavior()
          Returns the layer's resize behavior.
 Dimension getSize()
          Get the scalebar graphic Dimension (in pixels)
 double getToViewportScale()
          Returns the scalebar-to-viewport scale factor.
 String getUnit()
           
 void setBorderWidth(int borderWidth)
          Sets the scalebar offset from the viewport border.
 void setColor(Color color)
          Set the scalbar Color
 void setFont(Font font)
          Set the scalebar legend Fon
 void setPosition(String position)
          Sets the relative viewport location to display the scalebar.
 void setResizeBehavior(String resizeBehavior)
          Sets the behavior the layer uses to size the scalebar when the viewport size changes, typically when the World Wind window is resized.
 void setSize(Dimension size)
          Set the scalebar graphic Dimenion (in pixels)
 void setToViewportScale(double toViewportScale)
          Sets the scale factor applied to the viewport size to determine the displayed size of the scalebar.
 void setUnit(String unit)
          Sets the unit the scalebar uses to display distances.
 String toString()
           
 
Methods inherited from class gov.nasa.worldwind.layers.RenderableLayer
addRenderable, addRenderables, doPick, getDelegateOwner, getRenderables, removeAllRenderables, removeRenderable, setRenderables
 
Methods inherited from class gov.nasa.worldwind.layers.AbstractLayer
getMaxActiveAltitude, getMinActiveAltitude, getName, getOpacity, getRestorableState, getScale, isAtMaxResolution, isEnabled, isLayerActive, isLayerInView, isMultiResolution, isPickEnabled, pick, render, restoreState, setEnabled, setMaxActiveAltitude, setMinActiveAltitude, setName, setOpacity, setPickEnabled
 
Methods inherited from class gov.nasa.worldwind.WWObjectImpl
propertyChange
 
Methods inherited from class gov.nasa.worldwind.avlist.AVListImpl
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, getStringValue, getStringValue, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, 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
 
Methods inherited from interface java.beans.PropertyChangeListener
propertyChange
 

Field Detail

NORTHEAST

public static final String NORTHEAST
See Also:
Constant Field Values

NORTHWEST

public static final String NORTHWEST
See Also:
Constant Field Values

RESIZE_KEEP_FIXED_SIZE

public static final String RESIZE_KEEP_FIXED_SIZE
See Also:
Constant Field Values

RESIZE_SHRINK_ONLY

public static final String RESIZE_SHRINK_ONLY
See Also:
Constant Field Values

RESIZE_STRETCH

public static final String RESIZE_STRETCH
See Also:
Constant Field Values

SOUTHEAST

public static final String SOUTHEAST
See Also:
Constant Field Values

SOUTHWEST

public static final String SOUTHWEST
See Also:
Constant Field Values

UNIT_IMPERIAL

public static final String UNIT_IMPERIAL
See Also:
Constant Field Values

UNIT_METRIC

public static final String UNIT_METRIC
See Also:
Constant Field Values
Constructor Detail

ScalebarLayer

public ScalebarLayer()
Renders a scalebar graphic in a screen corner

Method Detail

dispose

public void dispose()
Description copied from class: RenderableLayer
Disposes the contents of this layer's internal Renderable collection, but does not remove any elements from that collection.

Specified by:
dispose in interface Disposable
Overrides:
dispose in class RenderableLayer

doRender

public void doRender(DrawContext dc)
Overrides:
doRender in class RenderableLayer

draw

public void draw(DrawContext dc)

getBorderWidth

public int getBorderWidth()

getColor

public Color getColor()
Get the scalebar color

Returns:
the scalebar Color

getFont

public Font getFont()
Get the scalebar legend Fon

Returns:
the scalebar legend Font

getPosition

public String getPosition()

getResizeBehavior

public String getResizeBehavior()
Returns the layer's resize behavior.

Returns:
the layer's resize behavior

getSize

public Dimension getSize()
Get the scalebar graphic Dimension (in pixels)

Returns:
the scalebar graphic Dimension

getToViewportScale

public double getToViewportScale()
Returns the scalebar-to-viewport scale factor.

Returns:
the scalebar-to-viewport scale factor

getUnit

public String getUnit()

setBorderWidth

public void setBorderWidth(int borderWidth)
Sets the scalebar offset from the viewport border.

Parameters:
borderWidth - the number of pixels to offset the scalebar from the borders indicated by setPosition(String).

setColor

public void setColor(Color color)
Set the scalbar Color

Parameters:
color - the scalebar Color

setFont

public void setFont(Font font)
Set the scalebar legend Fon

Parameters:
font - the scalebar legend Font

setPosition

public void setPosition(String position)
Sets the relative viewport location to display the scalebar. Can be one of NORTHEAST (the default), NORTHWEST, SOUTHEAST, or SOUTHWEST. These indicate the corner of the viewport.

Parameters:
position - the desired scalebar position

setResizeBehavior

public void setResizeBehavior(String resizeBehavior)
Sets the behavior the layer uses to size the scalebar when the viewport size changes, typically when the World Wind window is resized. If the value is RESIZE_KEEP_FIXED_SIZE, the scalebar size is kept to the size specified in its Dimension scaled by the layer's current icon scale. If the value is RESIZE_STRETCH, the scalebar is resized to have a constant size relative to the current viewport size. If the viewport shrinks the scalebar size decreases; if it expands then the scalebar enlarges. If the value is RESIZE_SHRINK_ONLY (the default), scalebar sizing behaves as for RESIZE_STRETCH but it will not grow larger than the size specified in its Dimension.

Parameters:
resizeBehavior - the desired resize behavior

setSize

public void setSize(Dimension size)
Set the scalebar graphic Dimenion (in pixels)

Parameters:
size - the scalebar graphic Dimension

setToViewportScale

public void setToViewportScale(double toViewportScale)
Sets the scale factor applied to the viewport size to determine the displayed size of the scalebar. This scale factor is used only when the layer's resize behavior is RESIZE_STRETCH or RESIZE_SHRINK_ONLY. The scalebar's width is adjusted to occupy the proportion of the viewport's width indicated by this factor. The scalebar's height is adjusted to maintain the scalebar's Dimension aspect ratio.

Parameters:
toViewportScale - the scalebar to viewport scale factor

setUnit

public void setUnit(String unit)
Sets the unit the scalebar uses to display distances. Can be one of UNIT_METRIC (the default), or UNIT_IMPERIAL.

Parameters:
unit - the desired unit

toString

public String toString()
Overrides:
toString in class RenderableLayer

NASA World Wind