Class TLspRulerController
- All Implemented Interfaces:
ILcdUndoableSource,ILcdAWTEventListener,ILspController
A controller that allows to measure distances on the map.
The measurement information is displayed on a label with the polyline as illustrated in the figure above.
The polylines can be edited after creation.
As such, TLspRulerController is very similar to the TLspCreateController and TLspEditController.
The created polylines are instances of ALspRulerMeasurement.
The ruler measurement class exposes the distances (in meters) and azimuths (in degrees) calculated by the ruler controller.
You can access the last measurement in the controller itself.
You can also register a change listener to be notified when the current polyline changes.
It is possible to customize various aspects of this controller:
- Control the styling of the lines with
setLineStyler(com.luciad.view.lightspeed.style.styler.ILspStyler). - Control the styling of the radius circles with
setCircleStyler(com.luciad.view.lightspeed.style.styler.ILspCustomizableStyler)andsetDisplayEqualDistanceCircles(boolean). - Control the styling of the labels (including the distance unit) with
setLabelStyler(com.luciad.view.lightspeed.style.styler.ILspStyler), passing aTLspRulerLabelStyler. - Control the styling of the editing handles with
setHandleStyler(com.luciad.view.lightspeed.style.styler.ILspStyler)andsetFocusHandleStyler(com.luciad.view.lightspeed.style.styler.ILspStyler) - Set the measurement mode using
setMeasureMode(com.luciad.view.lightspeed.controller.ruler.TLspRulerController.MeasureMode) - Specify whether to keep measurements using
setKeepLayer(boolean)andsetKeepMeasurements(boolean). - Control the distance and azimuth calculations by overriding the
calculateAzimuth(com.luciad.shape.ILcdPoint, com.luciad.shape.ILcdPoint, com.luciad.model.ILcdModelReference, com.luciad.view.lightspeed.controller.ruler.TLspRulerController.MeasureMode)orcalculateDistance(com.luciad.shape.ILcdPoint, com.luciad.shape.ILcdPoint, com.luciad.model.ILcdModelReference, com.luciad.view.lightspeed.controller.ruler.TLspRulerController.MeasureMode)methods.
The handleFXEvent(Event aEvent) converts the native JavaFX TouchEvent
to a TLcdTouchEvent and passes it to the ALspController.handleAWTEvent(AWTEvent aEvent).
snappable layers.- Since:
- 2012.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnumeration that describes how the distances and azimuths are calculated. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new ruler controller.TLspRulerController(boolean aAddLayerToView) Creates a new ruler controller.TLspRulerController(boolean aAddLayerToView, ALspCreateControllerModel aCreateControllerModel) Creates a new ruler controller with the givenALspCreateControllerModel. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChangeListener(ILcdChangeListener aListener) Adds a change listener.voidaddUndoableListener(ILcdUndoableListener aUndoableListener) Adds a listener to this source, so this listener is notified when something undoable has happened.protected doublecalculateAzimuth(ILcdPoint aPoint1, ILcdPoint aPoint2, ILcdModelReference aReference, TLspRulerController.MeasureMode aMeasureMode) This method is called to calculate the azimuth for a segment of a ruler measurement.protected doublecalculateDistance(ILcdPoint aPoint1, ILcdPoint aPoint2, ILcdModelReference aReference, TLspRulerController.MeasureMode aMeasureMode) This method is called to calculate the distance of a segment of a ruler measurement.voidcancel()Cancels the creation of the ruler polyline.voidfinish()Finish the creation of the ruler polyline.Returns the customizable styler currently used to determine the style of equal distance circles.Returns the current measurement.Returns the mouse cursor for this controller.Returns the styler for focused editing handles.Returns the styler for editing handles.Returns the styler for distance and azimuth labels of ruler measurements that are being edited or created.getLabelStyler(TLspPaintState aPaintState) Returns the styler for distance and azimuth labels of ruler measurements for measurements in the given paintstate.Returns anILcdLayeredfor this controller.Returns the styler for ruler polylines that are being edited or created.Returns the current measurement mode.Returns theILcdStringTranslatorset on this controller.handleAWTEventImpl(AWTEvent aAWTEvent) Called byhandleAWTEvent.voidhandleFXEvent(Event aEvent) Delegates tohandleFXEventImpl.handleFXEventImpl(Event aEvent) Called byhandleFXEvent.booleanReturns true if a layer containing the measurements is added to the view (and as such visible in the layer tree).booleanReturns whether or not the ruler controller is currently creating or editing.booleanReturns whether or not azimuths are displayed for each segment.booleanReturns true if equal distance circles are displayed for polyline nodes that are moved.booleanReturns true if the layer is kept after the interaction with the ruler controller is terminated.booleanReturns true if measurements are kept after a new measurement is started.paintImpl(ILcdGLDrawable aGLDrawable, ILspView aView, TLspPaintPhase aPaintPhase) The specific implementation ofpaintfor this controller.voidremoveChangeListener(ILcdChangeListener aListener) Removes a change listener if it is present.voidremoveUndoableListener(ILcdUndoableListener aUndoableListener) Removes the specified listener so it is no longer notified.voidsetCircleStyler(ILspCustomizableStyler aCircleStyler) Sets the customizable styler currently used to paint equal distance circles.voidsetDisplayAzimuth(boolean aDisplayAzimuth) Sets whether or not azimuths are displayed for each segment.voidsetDisplayEqualDistanceCircles(boolean aDisplayEqualDistanceCircles) Sets whether or not equal distance circles are displayed for polyline nodes that are moved.voidsetFocusHandleStyler(ILspStyler aFocusHandleStyler) Sets the styler for focused editing handles.voidsetHandleStyler(ILspStyler aHandleStyler) Sets the styler for editing handles.voidsetKeepLayer(boolean aKeepLayer) Set to true if the layer is to be kept after the interaction with the ruler controller is terminated.voidsetKeepMeasurements(boolean aKeepMeasurements) Set to true is measurements should be kept after a new measurement is started.voidsetLabelStyler(TLspPaintState aState, ILspStyler aLabelStyler) Sets the styler for distance and azimuth labels, for the given paint state.voidsetLabelStyler(ILspStyler aLabelStyler) Sets the styler for distance and azimuth labels, for all supported paint states.voidsetLineStyler(TLspPaintState aPaintState, ILspStyler aLineStyler) Sets the styler for the ruler polylines for the given paint state.voidsetLineStyler(ILspStyler aLineStyler) Sets the styler for the ruler polylines, for all supported paint states.voidsetMeasureMode(TLspRulerController.MeasureMode aMeasureMode) Sets the measurement mode.voidsetStringTranslator(ILcdStringTranslator aStringTranslator) Sets theILcdStringTranslatorthat this controller should use to translate theStringsthat will be visible in the user interface.voidstartInteractionImpl(ILspView aView) The specific implementation ofstartInteractionfor this controller.voidterminateInteractionImpl(ILspView aView) The specific implementation ofterminateInteractionfor this controller.Methods inherited from class com.luciad.view.lightspeed.controller.ALspController
addPropertyChangeListener, addStatusListener, appendController, firePropertyChange, fireStatusEvent, getAWTFilter, getFXCursor, getFXFilter, getIcon, getName, getNextController, getShortDescription, getView, handleAWTEvent, paint, registerViewPropertyNameForReset, removePropertyChangeListener, removeStatusListener, setAWTFilter, setCursor, setFXCursor, setFXFilter, setIcon, setName, setShortDescription, startInteraction, terminateInteraction
-
Constructor Details
-
TLspRulerController
public TLspRulerController()Creates a new ruler controller. Equivalent to.new TLspRulerController(false, null) -
TLspRulerController
public TLspRulerController(boolean aAddLayerToView) Creates a new ruler controller. Based on the passed value, the ruler measurements will be painted in a layer added to the view, or in a layer offered by thelayeredof this controller. If the layer is added to the view, it is possible to keep it, even if the interaction with this controller is terminated. Equivalent to.new TLspRulerController(aAddLayerToView, null)- Parameters:
aAddLayerToView- true to add layer in view, false otherwise.
-
TLspRulerController
public TLspRulerController(boolean aAddLayerToView, ALspCreateControllerModel aCreateControllerModel) Creates a new ruler controller with the givenALspCreateControllerModel. Use this constructor to:- let the ruler controller create custom
ALspRulerMeasurementimplementations - limit the number of points the user can create measurements with
- be notified when a new measurement is created
- be notified when measurement creation is canceled
- Parameters:
aAddLayerToView- true to add layer in view, false otherwise. SeeTLspRulerController(boolean)for more information.aCreateControllerModel- The ruler controller uses this to create new measurements. When null, the ruler controller will use a defaultALspCreateControllerModelimplementation. Note that itsgetLayerimplementation must returnnull. Ifnullis returned from itscreate, then a default measurement will be created.- Since:
- 2018.0
- let the ruler controller create custom
-
-
Method Details
-
paintImpl
public TLspPaintProgress paintImpl(ILcdGLDrawable aGLDrawable, ILspView aView, TLspPaintPhase aPaintPhase) Description copied from class:ALspControllerThe specific implementation ofpaintfor this controller.- Overrides:
paintImplin classALspController- Parameters:
aGLDrawable- the drawable that should be painted onaView- the view that is painted onaPaintPhase- the current paint phase- Returns:
- whether or not the painting was finished
-
startInteractionImpl
Description copied from class:ALspControllerThe specific implementation ofstartInteractionfor this controller.- Overrides:
startInteractionImplin classALspController- Parameters:
aView- the view to start interaction with.
-
terminateInteractionImpl
Description copied from class:ALspControllerThe specific implementation ofterminateInteractionfor this controller.- Overrides:
terminateInteractionImplin classALspController- Parameters:
aView- the view to terminate interaction with.
-
handleAWTEventImpl
Description copied from class:ALspControllerCalled byhandleAWTEvent. Returnsnullwhen the controller consumed the event or a partially consumed event when the controller partially consumed the event (which could happen withTLcdTouchEvents). When the controller did not use the given event, it is returned unaltered.- Specified by:
handleAWTEventImplin classALspController- Parameters:
aAWTEvent- the event to be handled.- Returns:
nullwhen the input event was consumed, the (possibly modified) input event when it was (partially) consumed.
-
handleFXEvent
Description copied from class:ALspControllerDelegates tohandleFXEventImpl. If that method does not returnnull, the result is passed on to the next controller in the chain (if one exists). If the controller has a filter that does not accept the event, the event is not delegated and is immediately passed on to the next controller.- Specified by:
handleFXEventin interfaceILspController- Overrides:
handleFXEventin classALspController- Parameters:
aEvent- the event to be handled
-
handleFXEventImpl
Description copied from class:ALspControllerCalled byhandleFXEvent. Returnsnullwhen the controller consumed the event. When the controller did not use the given event, it is returned unaltered.- Overrides:
handleFXEventImplin classALspController- Parameters:
aEvent- the event to be handled.- Returns:
nullwhen the input event was consumed, the (possibly modified) input event when it was (partially) consumed.
-
setStringTranslator
Sets the
ILcdStringTranslatorthat this controller should use to translate theStringsthat will be visible in the user interface.This method should be called before this controller is used. Any
Stringsalready created by this controller will not be translated with the specified translator. TheILcdStringTranslatordoes not translate the controller's name and description.- Parameters:
aStringTranslator- TheILcdStringTranslatorthat should be used. Must not benull.The following list of
Stringsare translated by the given instance:- "Clear measurements"
- "Undo {0}".
{0}will be replaced by the display name of the action that is to be undone. E.g. "Undo Clear measurements". - "Redo {0}".
{0}will be replaced by the display name action that is to be redone. E.g. "Redo Clear measurements" - "Edit {0}".
{0}will be replaced by the result of callingObject.toString()on the edited object. E.g. "Edit ruler measurement". - "Create object"
- The result of calling
Object.toString()on the usedALspMeasurementobjects. For the defaultALspMeasurementimplementation, this is "ruler measurement".
ILcdStringTranslatorneeds to be able to translate what is passed in{0}, but not the entire formattedString. For example, for "Undo {0}" it needs to be able to translate "Undo {0}" itself and "Clear measurements", but not "Undo Clear measurements".
-
getStringTranslator
Returns the
ILcdStringTranslatorset on this controller.- Returns:
- The translator set on this controller. Never
null.
-
getCurrentMeasurement
Returns the current measurement. This is either the measurement currently under construction or the last created or edited measurement.- Returns:
- the current measurement.
-
addChangeListener
Adds a change listener. This listener will be informed when the current measurement is changed.- Parameters:
aListener- the listener that should be added.- See Also:
-
removeChangeListener
Removes a change listener if it is present.- Parameters:
aListener- the listener that should be removed.- See Also:
-
isAddLayerToView
public boolean isAddLayerToView()Returns true if a layer containing the measurements is added to the view (and as such visible in the layer tree).- Returns:
- true if the measurement layer is added to the view, false otherwise.
- See Also:
-
isKeepLayer
public boolean isKeepLayer()Returns true if the layer is kept after the interaction with the ruler controller is terminated. This will only have effect is the layer isaddedto the view. Otherwise this method will have no effect.- Returns:
- true if the layer is kept after the interaction with the ruler controller is terminated.
- See Also:
-
setKeepLayer
public void setKeepLayer(boolean aKeepLayer) Set to true if the layer is to be kept after the interaction with the ruler controller is terminated. For this to work, the ruler controller must be configured toadd a layer to the view. The default value isfalse.- Parameters:
aKeepLayer- True to keep layer in view, false otherwise.- See Also:
-
isKeepMeasurements
public boolean isKeepMeasurements()Returns true if measurements are kept after a new measurement is started.- Returns:
- true if measurements are kept.
- See Also:
-
setKeepMeasurements
public void setKeepMeasurements(boolean aKeepMeasurements) Set to true is measurements should be kept after a new measurement is started. Default is false.- Parameters:
aKeepMeasurements- True to keep measurements, false otherwise.- See Also:
-
getLayered
Description copied from interface:ILspControllerReturns an
ILcdLayeredfor this controller. Custom implementations of this method should take care to return the sameILcdLayeredinstance every time this method is called to guarantee correct working of theILcdLayeredinterface.The returned layered object should contain layers that are relevant to this controller. Any view using this controller should take into account the layers of its active controller.
Note that the ILcdLayered is only allowed to contain
ILspLayerinstances.- Specified by:
getLayeredin interfaceILspController- Overrides:
getLayeredin classALspController- Returns:
- an ILcdLayered object, or null if this controller has no layers.
-
getMeasureMode
Returns the current measurement mode. The default mode isMEASURE_GEODETIC.- Returns:
- the current measurement mode
-
setMeasureMode
Sets the measurement mode. The mode must be one ofMEASURE_GEODETIC,MEASURE_RHUMBorMEASURE_CARTESIAN.- Parameters:
aMeasureMode- the new measurement mode
-
getLineStyler
Returns the styler for ruler polylines that are being edited or created.- Returns:
- the current styler used by the polyline painter.
- See Also:
-
setLineStyler
Sets the styler for the ruler polylines, for all supported paint states. The objects to provide styles for extendALspRulerMeasurementand implementILcdPolyline.- Parameters:
aLineStyler- the styler to be used by the polyline painter.- See Also:
-
setLineStyler
Sets the styler for the ruler polylines for the given paint state. The objects to provide styles for extendALspRulerMeasurementand implementILcdPolyline.- Parameters:
aPaintState- the paintstate to set the styler for.aLineStyler- the styler to be used by the polyline painter.- See Also:
-
isDisplayEqualDistanceCircles
public boolean isDisplayEqualDistanceCircles()Returns true if equal distance circles are displayed for polyline nodes that are moved. Currently this is only relevant forMEASURE_GEODETIC.- Returns:
- true if equal distance circles are displayed.
-
setDisplayEqualDistanceCircles
public void setDisplayEqualDistanceCircles(boolean aDisplayEqualDistanceCircles) Sets whether or not equal distance circles are displayed for polyline nodes that are moved. Currently this is only relevant for measure modesMEASURE_GEODETIC. When another measure mode is used no circles will be displayed. Default is true.- Parameters:
aDisplayEqualDistanceCircles- true if equal distance circles have to be displayed, false otherwise.
-
getCircleStyler
Returns the customizable styler currently used to determine the style of equal distance circles.- Returns:
- the current styler used by the circle painter.
- See Also:
-
setCircleStyler
Sets the customizable styler currently used to paint equal distance circles. The customizable styler is in effect treated as a list of styles. All enabled customizable styles that are relevant will be used when styling the circles.- Parameters:
aCircleStyler- the styler to be used by the circle painter.- See Also:
-
getLabelStyler
Returns the styler for distance and azimuth labels of ruler measurements that are being edited or created. This is equivalent to callinggetLabelStyler(TLspPaintState.EDITED).- Returns:
- the current styler used by the label painter.
- See Also:
-
getLabelStyler
Returns the styler for distance and azimuth labels of ruler measurements for measurements in the given paintstate.- Parameters:
aPaintState- the paintstate to get the label styler for.- Returns:
- the current styler used by the label painter.
- See Also:
-
setLabelStyler
Sets the styler for distance and azimuth labels, for all supported paint states. The objects to provide styles for extendALspRulerMeasurementand implementILcdPolyline. By default a standardTLspRulerLabelStyleris used. The styler will be used to paint measurements in the REGULAR, EDITED and SELECTED paintstates.- Parameters:
aLabelStyler- the styler to be used by the label painter.- See Also:
-
setLabelStyler
Sets the styler for distance and azimuth labels, for the given paint state. The objects to provide styles for extendALspRulerMeasurementand implementILcdPolyline. By default a standardTLspRulerLabelStyleris used.- Parameters:
aState- the paintstate to get the styler foraLabelStyler- the styler to be used by the label painter.- See Also:
-
setHandleStyler
Sets the styler for editing handles. By default, a standardTLspEditHandleStyleris used.- Parameters:
aHandleStyler- The styler to be used for editing handles.
-
getHandleStyler
Returns the styler for editing handles. By default, this is a standardTLspEditHandleStyler.- Returns:
- The styler for editing handles.
-
setFocusHandleStyler
Sets the styler for focused editing handles. By default, a standardTLspEditHandleStylerwith a red icon style for points, is used.- Parameters:
aFocusHandleStyler- The styler to be used for focused editing handles.
-
getFocusHandleStyler
Returns the styler for focused editing handles. By default, a standardTLspEditHandleStylerwith a red icon style for points, is used.- Returns:
- The styler for focused editing handles.
-
isDisplayAzimuth
public boolean isDisplayAzimuth()Returns whether or not azimuths are displayed for each segment.- Returns:
- whether or not azimuths are displayed for each segment.
- See Also:
-
setDisplayAzimuth
public void setDisplayAzimuth(boolean aDisplayAzimuth) Sets whether or not azimuths are displayed for each segment. When set totrue, an azimuth label is shown for every segment. Note that this method is a convenience method; it works when the ruler label styler is not customized. More specifically, it works under the following conditions:- the set label styler is a customizable styler
- one of the customizable styles in this styler is a
TLspRulerSegmentLabelContentStyle.
TLspRulerSegmentLabelContentStyle.Builder#displayAzimuthis used to create a newTLspRulerSegmentLabelContentStylethat is capable of returning the current azimuth value. On top of that, calling this method also adds an arrow to the middle of every line segment. Note that this is a convenience method as well. It works by default, or when the used line styler- doesn't call
ALspStyleCollector#geometry. - uses one or more
TLspLineStyleobjects.
- Parameters:
aDisplayAzimuth- whether or not azimuths are displayed for each segment- See Also:
-
addUndoableListener
Description copied from interface:ILcdUndoableSourceAdds a listener to this source, so this listener is notified when something undoable has happened.- Specified by:
addUndoableListenerin interfaceILcdUndoableSource- Parameters:
aUndoableListener- The listener to be notified when something undoable has happened.
-
removeUndoableListener
Description copied from interface:ILcdUndoableSourceRemoves the specified listener so it is no longer notified.- Specified by:
removeUndoableListenerin interfaceILcdUndoableSource- Parameters:
aUndoableListener- The listener to remove.
-
calculateAzimuth
protected double calculateAzimuth(ILcdPoint aPoint1, ILcdPoint aPoint2, ILcdModelReference aReference, TLspRulerController.MeasureMode aMeasureMode) This method is called to calculate the azimuth for a segment of a ruler measurement. The default implementation returns an azimuth depending on the measure mode as follows:MEASURE_GEODETIC: the two dimensional forward azimuth between the two points, according to the ellipsoid the model reference is based on (seeILcdEllipsoid.forwardAzimuth2D).MEASURE_RHUMB: the two dimensional rhumbline azimuth between the two points, according to the ellipsoid the model reference is based on (seeILcdEllipsoid.rhumblineAzimuth2D).MEASURE_CARTESIAN:Double.NaN, there is no reliable way to calculate an azimuth for a line in world space.
- Parameters:
aPoint1- the first point of the segment to calculate the azimuth foraPoint2- the second point of the segment to calculate the azimuth foraReference- the reference the points are defined in.aMeasureMode- the measure mode to take into account.- Returns:
- an azimuth for the passed segment, of
Double.NaNif no azimuth could be calculated.
-
calculateDistance
protected double calculateDistance(ILcdPoint aPoint1, ILcdPoint aPoint2, ILcdModelReference aReference, TLspRulerController.MeasureMode aMeasureMode) This method is called to calculate the distance of a segment of a ruler measurement. The default implementation returns an distance depending on the measure mode as follows:MEASURE_GEODETIC: the geodetic distance between the two points, according to the ellipsoid the model reference is based on (seeILcdEllipsoid.geodesicDistance).MEASURE_RHUMB: the rhumbline distance between the two points, according to the ellipsoid the model reference is based on (seeILcdEllipsoid.rhumblineDistance).MEASURE_CARTESIAN: the cartesian distance between the two points (seeTLcdCartesian.distance3D), taking into account the unit of measure of the model reference (in this case the world reference of the view) if available.
- Parameters:
aPoint1- the first point of the segment to calculate the distance foraPoint2- the second point of the segment to calculate the distance foraReference- the reference the points are defined in.aMeasureMode- the measure mode to take into account.- Returns:
- an distance for the passed segment
-
isCreating
public boolean isCreating()Returns whether or not the ruler controller is currently creating or editing.- Returns:
- true if a ruler polyline is being created, false otherwise.
-
finish
public void finish()Finish the creation of the ruler polyline. -
cancel
public void cancel()Cancels the creation of the ruler polyline. -
getCursor
Description copied from class:ALspControllerReturns the mouse cursor for this controller. The cursor is typically retrieved by the view to configure its host component.
This method returns the cursor for this controller, not the rest of chain. However, the property change listeners of the controller will be informed about cursor changes for the entire controller chain. A cursor property change event's value will be the first non-null cursor along the controller chain. For JavaFX, see {#linkALspController.getFXCursor()}.- Overrides:
getCursorin classALspController- Returns:
- the cursor for this controller, or null if the controller does not have a specific cursor
- See Also:
-