public abstract class ALcdScaleIndicator extends Object implements ILcdIcon, Cloneable
BAR
representation: The map scale is represented by
a bar of a certain length in pixels, along with its corresponding length in world distance in text
on top of it.FRACTION
representation: The map scale is represented as
a unit-less fraction of screen distance to world distance, for example "1 : 10,000".fractionFormat
property.
ALcdScaleIndicator
have to implement
retrieveScale()
, which returns the scale of a map as the number of
pixels per meter world distance.Modifier and Type | Class and Description |
---|---|
static class |
ALcdScaleIndicator.Representation
Enumeration of possible map scale representations.
|
Constructor and Description |
---|
ALcdScaleIndicator()
Constructs an
ALcdScaleIndicator object. |
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
Registers the given
PropertyChangeListener to be notified when this scale
indicator's properties change. |
protected TLcdISO19103DistanceMeasure |
calculateScaleIndication(double aScale)
Calculates the value to display textually and graphically for the given scale.
|
Object |
clone()
Makes
Object.clone() public. |
protected void |
firePropertyChangeEvent(String aPropertyName,
Object aOldValue,
Object aNewValue)
Fires a new
PropertyChangeEvent to all the PropertyChangeListeners registered
with this ALcdScaleIndicator . |
Color |
getAlternateBarColor()
Returns the alternate color of the bar used to indicate the scale.
|
Color |
getBarColor()
Returns the main color of the bar used to indicate the scale.
|
int |
getBarHeight()
Returns the height of the bar used to indicate the scale.
|
int |
getBarSegmentCount()
Returns the amount of segments the scale indicator uses in its bar.
|
int |
getBarWidth()
Returns the maximum width of the bar used to indicate the scale.
|
TLcdDistanceUnit |
getDistanceUnit()
Gets the distance unit of this scale indicator.
|
Font |
getFont()
Gets the font of the text displaying the scale of the view.
|
TLcdScaleFormat |
getFractionFormat()
Returns the format string that is used to display the fraction when using
ALcdScaleIndicator.Representation.FRACTION . |
Color |
getHaloColor()
Gets the halo color of the text displaying the scale of the view.
|
int |
getIconHeight()
Gets the height of the icon for displaying the scale of the
ILcdGXYView . |
int |
getIconWidth()
Gets the width of the icon for displaying the scale of the
ILcdGXYView . |
Color |
getLabelColor()
Gets the color of the text displaying the scale of the view.
|
ALcdScaleIndicator.Representation |
getScaleRepresentation()
Returns the current scale representation.
|
boolean |
isScaleAtCenterOfMap()
Returns whether the scale is shown at the center of what the user is looking at,
or the center of the entire projection.
|
void |
paintIcon(Component c,
Graphics g,
int x,
int y)
Draw the
ALcdScaleIndicator at the specified location. |
void |
removePropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
Unregisters the given
PropertyChangeListener from receiving property change events
for this scale indicator. |
protected Object |
retrieveMapReference()
Returns the current world reference of the map, used to retrieve the world unit of measure.
|
protected abstract double |
retrieveScale()
Returns the current view scale according to the
isScaleAtCenterOfMap() value. |
void |
setAlternateBarColor(Color aColor)
Sets the alternate color of the bar used to indicate the scale.
|
void |
setBarColor(Color aColor)
Sets the main color of the bar used to indicate the scale.
|
void |
setBarHeight(int aBarHeight)
Returns the height of the bar used to indicate the scale.
|
void |
setBarSegmentCount(int aBarSegmentCount)
Configures the amount of segments the scale indicator uses in its bar.
|
void |
setBarWidth(int aWidth)
Sets the maximum width of the bar used to indicate the scale.
|
void |
setDistanceUnit(TLcdDistanceUnit aDistanceUnit)
Sets the distance unit for the view.
|
void |
setFont(Font aFont)
Sets the font of the text displaying the scale of the view.
|
void |
setFractionFormat(TLcdScaleFormat aFractionFormat)
Sets the format to be used to display the fraction when using
ALcdScaleIndicator.Representation.FRACTION . |
void |
setHaloColor(Color aHaloColor)
Sets the halo color of the text displaying the scale of the view.
|
void |
setLabelColor(Color aLabelColor)
Sets the color of the text displaying the scale of the view.
|
void |
setScaleAtCenterOfMap(boolean aScaleAtCenterOfMap)
Sets whether to show the scale at the center of the map portion the user is looking at,
or a global scale for the entire projection.
|
void |
setScaleRepresentation(ALcdScaleIndicator.Representation aScaleRepresentation)
Sets the scale representation.
|
void |
toggleScaleRepresentation()
Toggles between all possible scale representation values, see
setScaleRepresentation(com.luciad.view.swing.ALcdScaleIndicator.Representation) . |
public ALcdScaleIndicator()
ALcdScaleIndicator
object.public int getIconWidth()
ILcdGXYView
.
Returns the fixed width of the icon.getIconWidth
in interface ILcdIcon
public int getIconHeight()
ILcdGXYView
. If
a font is set, the height is dependant of the font. Otherwise the height is set to 45.
Returns the fixed height of the icon.getIconHeight
in interface ILcdIcon
public int getBarHeight()
public void setBarHeight(int aBarHeight)
aBarHeight
- the new bar height, in pixelspublic int getBarWidth()
public void setBarWidth(int aWidth)
aWidth
- the new bar width, in pixelspublic void setBarColor(Color aColor)
aColor
- the new main colorsetAlternateBarColor(java.awt.Color)
public Color getBarColor()
getAlternateBarColor()
public void setAlternateBarColor(Color aColor)
aColor
- the new alternate colorsetAlternateBarColor(java.awt.Color)
public Color getAlternateBarColor()
getAlternateBarColor()
public void setDistanceUnit(TLcdDistanceUnit aDistanceUnit)
aDistanceUnit
differs from the current distance unit,
a PropertyChangeEvent
is thrown.aDistanceUnit
- the distance unit to setpublic TLcdScaleFormat getFractionFormat()
ALcdScaleIndicator.Representation.FRACTION
.setFractionFormat(TLcdScaleFormat)
public void setFractionFormat(TLcdScaleFormat aFractionFormat)
ALcdScaleIndicator.Representation.FRACTION
.
The default value is new TLcdScaleFormat()
.
See also setScaleRepresentation(com.luciad.view.swing.ALcdScaleIndicator.Representation)
.
If aFractionFormat
differs from the current fraction format,
a PropertyChangeEvent
is fired.
aFractionFormat
- the fraction format stringTLcdScaleFormat
public ALcdScaleIndicator.Representation getScaleRepresentation()
public void setScaleRepresentation(ALcdScaleIndicator.Representation aScaleRepresentation)
If aScaleRepresentation
differs from the current scale representation value,
a PropertyChangeEvent
is fired.
aScaleRepresentation
- the scale representationpublic void toggleScaleRepresentation()
setScaleRepresentation(com.luciad.view.swing.ALcdScaleIndicator.Representation)
.
The representations are iterated according to the order in which they are defined in the
ALcdScaleIndicator.Representation
enum.
When the last item has been reached, this method will switch to the first item.
A PropertyChangeEvent
is fired.
public void addPropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
PropertyChangeListener
to be notified when this scale
indicator's properties change.aPropertyChangeListener
- the listener to notify of changes of this indicator's propertiespublic void removePropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
PropertyChangeListener
from receiving property change events
for this scale indicator.aPropertyChangeListener
- the listener that should no longer be notified of changes of
this indicator's propertiesprotected void firePropertyChangeEvent(String aPropertyName, Object aOldValue, Object aNewValue)
PropertyChangeEvent
to all the PropertyChangeListeners registered
with this ALcdScaleIndicator
.aPropertyName
- The name of the changed propertyaOldValue
- The old value of the changed propertyaNewValue
- The new value of the changed propertypublic void setFont(Font aFont)
aFont
differs from the current font, a PropertyChangeEvent
is thrown.aFont
- the font of the display textpublic void setHaloColor(Color aHaloColor)
aHaloColor
differs from the current halo color, a PropertyChangeEvent
is thrown.aHaloColor
- The halo color of the display textpublic void setLabelColor(Color aLabelColor)
aLabelColor
differs from the current halo color, a PropertyChangeEvent
is thrown.aLabelColor
- the color of the display textpublic Font getFont()
public Color getHaloColor()
public Color getLabelColor()
public TLcdDistanceUnit getDistanceUnit()
public int getBarSegmentCount()
getBarColor()
and getAlternateBarColor()
.public void setBarSegmentCount(int aBarSegmentCount)
getBarColor()
and getAlternateBarColor()
.
The default is 4.aBarSegmentCount
- the new amount of bar segments. The amount should be more than zero and fit given the total
width
of the bar.public final void paintIcon(Component c, Graphics g, int x, int y)
ALcdScaleIndicator
at the specified location.
Draw the ILcdIcon
at the specified location. ILcdIcon
implementations
may use the Component
argument to get properties useful for
painting, e.g. the foreground or background color.paintIcon
in interface ILcdIcon
c
- a Component to retrieve properties from.g
- the Graphics on which the icon will be painted.x
- the x position where the icon will be painted. x is the first coordinate of the top left
corner point of the icon.y
- the y position where the icon will be painted. y is the second coordinate of the top left
corner point of the icon.public boolean isScaleAtCenterOfMap()
public void setScaleAtCenterOfMap(boolean aScaleAtCenterOfMap)
aScaleAtCenterOfMap
- If true the scale at the center of the view will be shown, otherwise a global
projection scale will be shown.protected abstract double retrieveScale()
isScaleAtCenterOfMap()
value.protected Object retrieveMapReference()
ILcdXYWorldReference
or
ILcdXYZWorldReference
.
This method will return null
if the reference is unknown, in which case the world unit
will be assumed to be 1 meter.null
if it is unknownprotected TLcdISO19103DistanceMeasure calculateScaleIndication(double aScale)
distance unit
, e.g. 1km, 2km, 5km, 10km, 20km, 50km...
valueInMeters * scale < getIconWidth()
The measure must have a TLcdDistanceUnit configured as its unit of measure.aScale
- the current scale, in pixels per meterpublic Object clone()
Makes Object.clone()
public.
java.lang.Object
, it can be implemented like this:
public Object clone() {
try {
return super.clone();
} catch ( CloneNotSupportedException e ) {
// Cannot happen: extends from Object and implements Cloneable (see also Object.clone)
throw new RuntimeException( e );
}
}
clone
in interface ILcdCloneable
clone
in class Object
Object.clone()