public class TLspFXScaleIndicator extends ALcdScaleIndicator implements ILcdChangeSource
A JavaFX ALcdScaleIndicator
implementation for ILspView
.
By default the indicator will only change if you zoom, not if you pan.
Call ALcdScaleIndicator.setScaleAtCenterOfMap(boolean)
to change this behavior.
//Create a scale indicator for the view
TLspFXScaleIndicator scaleIndicator = new TLspFXScaleIndicator(view);
//Optionally, change some settings on the scale indicator.
//Check the javadoc for all available customization options
scaleIndicator.setBarColor(Color.DARK_GRAY);
scaleIndicator.setAlternateBarColor(Color.LIGHT_GRAY);
which is then added, together with the TLspFXView
, to the south-east corner of an AnchorPane
.
//Add the view and the scale indicator to the same pane
//This ensures that the scale label is placed on top of the map
AnchorPane pane = new AnchorPane(view.getHostNode(), scaleIndicator.getNode());
AnchorPane.setTopAnchor(view.getHostNode(), 0.0);
AnchorPane.setBottomAnchor(view.getHostNode(), 0.0);
AnchorPane.setLeftAnchor(view.getHostNode(), 0.0);
AnchorPane.setRightAnchor(view.getHostNode(), 0.0);
AnchorPane.setRightAnchor(scaleIndicator.getNode(), 10.0);
AnchorPane.setBottomAnchor(scaleIndicator.getNode(), 10.0);
//The AnchorPane now can be shown on a javafx.scene.Scene instance
ALcdScaleIndicator.Representation
Constructor and Description |
---|
TLspFXScaleIndicator(ILspView aView)
Creates a new instance of TLspFXScaleIndicator for the specified view.
|
Modifier and Type | Method and Description |
---|---|
void |
addChangeListener(ILcdChangeListener aListener)
Registers the given listener so it will receive change events from this source.
|
javafx.scene.Node |
getNode()
Returns a
Node containing this scale indicator as an icon. |
void |
removeChangeListener(ILcdChangeListener aListener)
Removes the specified listener so it is no longer notified.
|
protected ILcdXYZWorldReference |
retrieveMapReference()
Returns the current world reference of the map, used to retrieve the world unit of measure.
|
protected double |
retrieveScale()
Returns the current view scale according to the
ALcdScaleIndicator.isScaleAtCenterOfMap() value. |
addPropertyChangeListener, calculateScaleIndication, clone, firePropertyChangeEvent, getAlternateBarColor, getBarColor, getBarHeight, getBarSegmentCount, getBarWidth, getDistanceUnit, getFont, getFractionFormat, getHaloColor, getIconHeight, getIconWidth, getLabelColor, getScaleRepresentation, isScaleAtCenterOfMap, paintIcon, removePropertyChangeListener, setAlternateBarColor, setBarColor, setBarHeight, setBarSegmentCount, setBarWidth, setDistanceUnit, setFont, setFractionFormat, setHaloColor, setLabelColor, setScaleAtCenterOfMap, setScaleRepresentation, toggleScaleRepresentation
public TLspFXScaleIndicator(ILspView aView)
aView
- the specified viewpublic javafx.scene.Node getNode()
Node
containing this scale indicator as an icon.
The returned Node will automatically refresh itself when needed, for example on view changes
or when changing the settings of this scale indicator instance.
Additionally, clicking on the scale indicator will trigger the ALcdScaleIndicator.toggleScaleRepresentation()
method.public void addChangeListener(ILcdChangeListener aListener)
ILcdChangeSource
Registers the given listener so it will receive change events from this source.
In case you need to register a listener which keeps a reference to an object with a shorter life-time than this change source,
you can use a ALcdWeakChangeListener
instance as change listener.
addChangeListener
in interface ILcdChangeSource
aListener
- The listener to be notified when a change has happened.ILcdChangeSource.removeChangeListener(ILcdChangeListener)
,
ALcdWeakChangeListener
public void removeChangeListener(ILcdChangeListener aListener)
ILcdChangeSource
removeChangeListener
in interface ILcdChangeSource
aListener
- The listener to remove.protected double retrieveScale()
ALcdScaleIndicator
ALcdScaleIndicator.isScaleAtCenterOfMap()
value.retrieveScale
in class ALcdScaleIndicator
protected ILcdXYZWorldReference retrieveMapReference()
ALcdScaleIndicator
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.retrieveMapReference
in class ALcdScaleIndicator
null
if it is unknown