Class TLcdAdvancedMapRulerController
- All Implemented Interfaces:
ILcdUndoableSource,ILcdAWTEventListener,ILcdStatusSource,ILcdGXYChainableController,ILcdGXYController,KeyListener,MouseListener,MouseMotionListener,Serializable,EventListener
- Direct Known Subclasses:
TLcdTerrainRulerController
ILcdGXYController serves the purpose of performing
measurements on an ILcdGXYView. A measurement is defined by succeeding clicks on the map. The measurement can be ended with a right click or a double click. The measurement is displayed as a polyline having a distance label on every segment and a total distance label. Optionally, the azimuth of every segment can be displayed as well.
All style related settings can be changed using simple set methods. If more advanced customization of the visualization is required, the painters, editors and label painters can be replaced by overriding the factory methods that create them. Formatting of distance and azimuth can be modified by setting a different distance or azimuth format.
Several measure modes are available: geodetic, rhumbline and projection plane. Please refer
to setMeasureMode for more details.
Events can be received whenever the measurement is changed. This can be used
to display the measurement values in a panel for instance. Please refer to
addMeasurementChangeListener for more details.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceInterface for listeners that want to be informed when the measurement changes. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newTLcdAdvancedMapRulerController, ready to be used. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the givenMeasurementChangeListener.voidaddPropertyChangeListener(PropertyChangeListener aPropertyChangeListener) Add the givenPropertyChangeListener.voidThis method will append the passed controller to the end of the chain.protected doublecalculateAzimuth(ILcdPoint aPoint1, ILcdPoint aPoint2, ILcdGeoReference aGeoReference, int aMeasureMode, ILcdGXYContext aGXYContext) Calculates the azimuth in degrees between the two given points.protected doublecalculateDistance(ILcdPoint aPoint1, ILcdPoint aPoint2, ILcdGeoReference aGeoReference, int aMeasureMode, ILcdGXYContext aGXYContext) Calculates the distance in meters between the two given points.protected ILcdGXYPainterCreates the painter of the equal distance curve for the polylines used to measure the distances.protected ILcdGXYLabelPainterCreates the label painter for the distance labels (or maybe angle labels, etc).protected TLcdGXYLayerCreate a new layer used for storing the measurements.protected ILcdGXYLayerLabelPainterCreates theILcdGXYLayerLabelPainterfor the ruler controller.protected ILcdGXYEditorCreates the editor for the polylines used to measure the distances.protected ILcdGXYPainterCreates the painter for the polylines used to measure the distances.protected voidReturns the format used to format azimuths and display them to the user.Returns the cursor that will be displayed on a view when this controller is active for that view.Returns the distance format used to format distances and display them to the user.Returns the edit controller that is currently used.Returns the ILcdGXYLayer containing the measurements.Returns the new controller that is currently used.Returns the color of the halo to be added around measurement lines.intReturns the thickness (in pixels) of the halo to be added around measurement lines.Returns the hot point icon, it can benull.intReturns the label alignment.Returns the background color of the labels.Returns the foreground color of the labels.Returns the selection color of the labels.intReturns the orthogonal distance (in pixels) between the label and the line segment.Returns the layers associated with this controller.Returns the style to paint lines.Returns the geo reference of the measurement points.getMeasurementPoint(int aIndex) The measurement point at the given index.intReturns the point count of the current measurement.doublegetMeasurementSegmentAzimuth(int aIndex) Returns the azimuth in degrees of the segment at the given index.intReturns the amount of segments of the current measurement.doublegetMeasurementSegmentDistance(int aIndex) Returns the distance in meters of the segment at the given index.doubleReturns the total distance in meters of the current measurement, the sum of all the segment distances.intReturns the current measuring mode.Returns a reference to the controller that is located after this one in a chain, or null if this controller is the last element of the chain.Returns the font of the segment distance labels (and possibly azimuth, ifisDisplayAzimuth()is true).Returns the snappables used by this controller.Returns the font of the total distance label.voidhandleAWTEvent(AWTEvent aEvent) This is method is called when the target of the listener has a new AWTEvent available.booleanChecks if the layer containing measurements should be added to the view.booleanChecks if multiple measurements are allowed at the same time.booleanReturns whether or not you can only create new measurements, not change existing ones.booleanReturns true if the azimuth is displayed on the map.booleanReturns true if the equal distance curve(s) are drawn, false otherwise.booleanReturns if the halo effect on the measurement lines is enabled.booleanReturns true if a filled rectangle should be painted behind the labels.booleanReturns true if a border is painted around the label text in the background color.booleanReturns true if the labels are surrounded by a frame, false otherwise.booleanReturns true if the labels can be rotated along the polyline, false otherwise.booleanReturns true if the measurement is preserved when the controller is terminated and started again.booleanChecks if the layer containing measurements should be removed from the view after terminating the controller interaction.voidkeyPressed(KeyEvent event) No action performed.voidkeyReleased(KeyEvent event) Calls doPanGXYView or doZoomGXYView depending on the value of e.getKeyChar().voidNo action performed.voidmouseClicked(MouseEvent event) voidmouseDragged(MouseEvent event) voidmouseEntered(MouseEvent event) voidmouseExited(MouseEvent event) Will perform a pan depending on the values of isDragging, isPanOnMouseDragExit and isPanOnMouseMoveExit propertiesvoidmouseMoved(MouseEvent event) voidmousePressed(MouseEvent event) voidmouseReleased(MouseEvent event) voidEnables the controller to give visual feedback on the current user interactions.protected voidInvalidates the calculations.voidRemoves the givenMeasurementChangeListener.voidremovePropertyChangeListener(PropertyChangeListener aPropertyChangeListener) Removes the givenPropertyChangeListener.voidsetAddGXYLayerToGXYView(boolean aAddGXYLayerToGXYView) When set to true, the layer containing measurements is added to the view.voidsetAllowMultipleMeasurements(boolean aAllowMultipleMeasurements) When set to true, multiple measurements are allowed at the same time.voidsetAlwaysCreate(boolean aAlwaysCreate) Determines whether or not you can only create new measurements, not change existing ones.voidsetAzimuthFormat(Format aAzimuthFormat) Sets the azimuth format to be used to format azimuths and display them to the user.voidsetDisplayAzimuth(boolean aDisplayAzimuth) Set to true if the azimuth must be displayed as a label on the map.voidsetDistanceFormat(Format aDistanceFormat) Sets the distance format to use to format distances to be displayed to the user.voidsetDrawEqualDistanceCurve(boolean aDrawEqualDistanceCurve) Sets if the equal distance curve(s) are drawn or not.voidsetGXYEditController(ILcdGXYController aGXYEditController) Sets the edit controller that is used to modify the measurement after it has been created.voidsetGXYNewController(ILcdGXYController aGXYNewController) Sets the new controller that is used to create a new measurement on the map.voidsetHaloColor(Color aHaloColor) Sets the color of the halo to be added around measurement lines.voidsetHaloEnabled(boolean aHaloEnabled) Enables or disables the halo effect on the measurement lines.voidsetHaloThickness(int aHaloThickness) Sets the thickness (in pixels) of the halo to be added around measurement lines.voidsetHotPointIcon(ILcdIcon aHotPointIcon) Sets the hot point icon, used to paint the handles on the measurement line.voidsetLabelAlignment(int aLabelAlignment) Sets the label alignment.voidsetLabelBackground(Color aLabelBackground) Sets the background color of the labels.voidsetLabelFilled(boolean aLabelFilled) Sets if a filled rectangle should be painted behind the labels.voidsetLabelFontBorder(boolean aLabelFontBorder) Sets if the painted text should be bordered with the background color.voidsetLabelForeground(Color aLabelForeground) Sets the foreground color of the labels.voidsetLabelFrame(boolean aLabelFrame) Labels can be drawn surrounded by a frame, the frame property determines whether to frame the labels or not.voidsetLabelRotationAllowed(boolean aLabelRotationAllowed) Labels can be rotated so that they have the same angle as the polyline.voidsetLabelSelectionColor(Color aLabelSelectionColor) Sets the selection color of the labels.voidsetLabelVGap(int aVerticalGap) Sets the orthogonal distance (in pixels) between the label and the line segment.voidsetLineStyle(ILcdGXYPainterStyle aLineStyle) Sets the style to use to paint lines.voidsetMeasureMode(int aMeasureMode) Sets the current measuring mode.voidThis method sets the next controller in the chain for this controller.voidsetPreserveMeasurement(boolean aPreserveMeasurement) Set to true to preserve the measurement between succeeding calls tostartInteraction(com.luciad.view.gxy.ILcdGXYView)andterminateInteraction(com.luciad.view.gxy.ILcdGXYView).voidsetRemoveGXYLayerFromGXYView(boolean aRemoveGXYLayerFromGXYView) When set to true, the layer containing measurements is removed from the view after terminating the controller interaction.voidsetSegmentLabelFont(Font aSegmentLabelFont) Sets the font of the segment distance labels (and possibly azimuth, ifisDisplayAzimuth()is true) to the given font.voidsetSnappables(ILcdGXYLayerSubsetList aSnappables) Sets the new snappables for this controller, default is null.voidsetTotalDistanceLabelFont(Font aTotalDistanceLabelFont) Sets the font of the total distance label.voidstartInteraction(ILcdGXYView aGXYView) Sets up the controller to receive input through the view passed.voidterminateInteraction(ILcdGXYView aGXYView) Releases a few items.voidviewRepaint(ILcdGXYView aILcdGXYView) Empty implementation.Methods inherited from class com.luciad.view.gxy.controller.ALcdGXYSmartController
addUndoableListener, doPanGXYView, doZoomGXYView, fireUndoableEvent, getDownPanChars, getDownPanCodes, getLeftPanChars, getLeftPanCodes, getPanAbsDelta, getPanAbsDelta, getRightPanChars, getRightPanCodes, getUndoableListenerCount, getUpPanChars, getUpPanCodes, getZoomInChars, getZoomInCodes, getZoomOutChars, getZoomOutCodes, isDragging, isPanOnMouseDragExit, isPanOnMouseMoveExit, isPanUndoable, isRequestFocusOnMouseEntered, isRequestFocusOnMousePressed, isTraceOn, isZoomUndoable, removeUndoableListener, setDownPanChars, setDownPanCodes, setIsDragging, setLeftPanChars, setLeftPanCodes, setPanAbsDelta, setPanOnMouseDragExit, setPanOnMouseMoveExit, setPanUndoable, setRequestFocusOnMouseEntered, setRequestFocusOnMousePressed, setRightPanChars, setRightPanCodes, setTraceOn, setUpPanChars, setUpPanCodes, setZoomInChars, setZoomInCodes, setZoomOutChars, setZoomOutCodes, setZoomUndoable, updateViewLocationAfterZoomSFCTMethods inherited from class com.luciad.view.gxy.controller.ALcdGXYController
addStatusListener, asGXYController, fireStatusEvent, getGXYView, getIcon, getName, getShortDescription, registerInstance, removeStatusListener, retrieveGXYViewXYWorldTransformation, setClassTraceOn, setCursor, setGXYView, setIcon, setName, setShortDescriptionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.luciad.view.gxy.ILcdGXYController
getIcon, getName, getShortDescription
-
Field Details
-
MEASURE_GEODETIC
public static final int MEASURE_GEODETICGeodetic measure mode.- See Also:
-
MEASURE_RHUMBLINE
public static final int MEASURE_RHUMBLINERhumbline measure mode.- See Also:
-
MEASURE_PROJECTION_PLANE
public static final int MEASURE_PROJECTION_PLANEProjection plane measure mode.- See Also:
-
RULER_MODEL_TYPE_NAME
Returns the type name of the ruler model created by this controller.- Since:
- 2018.1
- See Also:
-
-
Constructor Details
-
TLcdAdvancedMapRulerController
public TLcdAdvancedMapRulerController()Creates a newTLcdAdvancedMapRulerController, ready to be used.
-
-
Method Details
-
startInteraction
Description copied from class:ALcdGXYControllerSets up the controller to receive input through the view passed.All
ILcdGXYViewimplementations that support interaction call this method when the controller has been made active withsetGXYControlleron the view, so this method shouldn't normally be called directly. Note that most view implementations add the controller as listener if appropriate before calling this method.Sets the cursor on the view and sets the view for which this controller is now active. Sends out a status event based on the
short description.- Specified by:
startInteractionin interfaceILcdGXYController- Overrides:
startInteractionin classALcdGXYSmartController- Parameters:
aGXYView- theILcdGXYViewthisILcdGXYControllerwill interact with.- See Also:
-
terminateInteraction
Description copied from class:ALcdGXYControllerReleases a few items. Can be redefined but this 'super' method should be called too.- Specified by:
terminateInteractionin interfaceILcdGXYController- Overrides:
terminateInteractionin classALcdGXYSmartController- Parameters:
aGXYView- theILcdGXYViewthisILcdGXYControllerinteracted with.- See Also:
-
viewRepaint
Description copied from class:ALcdGXYControllerEmpty implementation.- Specified by:
viewRepaintin interfaceILcdGXYController- Overrides:
viewRepaintin classALcdGXYController- Parameters:
aILcdGXYView- theILcdGXYViewto draw on.
-
firePropertyChangeEvent
-
paint
Description copied from class:ALcdGXYControllerEnables the controller to give visual feedback on the current user interactions. Note that the controller is responsible for repainting the view.Empty implementation. Redefine this method to render on the Graphics on which the view is rendered.
- Specified by:
paintin interfaceILcdGXYController- Overrides:
paintin classALcdGXYController- Parameters:
aGraphics- the Graphics on which the view was rendered.
-
getLayered
Description copied from interface:ILcdGXYControllerReturns the layers associated with this controller. A view using this controller should visualize the layers of its active controller and take them into account for label placement.Custom implementations of this method should take care to return the same
ILcdLayeredinstance every time this method is called to guarantee correct working of theILcdLayeredinterface.- Specified by:
getLayeredin interfaceILcdGXYController- Returns:
- an ILcdLayered object with GXY layers, or null if this controller has no layers.
-
getCursor
Description copied from interface:ILcdGXYControllerReturns the cursor that will be displayed on a view when this controller is active for that view.- Specified by:
getCursorin interfaceILcdGXYController- Overrides:
getCursorin classALcdGXYController- Returns:
- the
Cursorset by setCursor, orCursor.getDefaultCursor()if noCursorhas been set yet.
-
keyTyped
Description copied from class:ALcdGXYSmartControllerNo action performed.- Specified by:
keyTypedin interfaceKeyListener- Overrides:
keyTypedin classALcdGXYSmartController
-
keyPressed
Description copied from class:ALcdGXYSmartControllerNo action performed.- Specified by:
keyPressedin interfaceKeyListener- Overrides:
keyPressedin classALcdGXYSmartController
-
keyReleased
Description copied from class:ALcdGXYSmartControllerCalls doPanGXYView or doZoomGXYView depending on the value of e.getKeyChar(). This method can be redefined and make use of doZoomGXYView and or doPanGXYView- Specified by:
keyReleasedin interfaceKeyListener- Overrides:
keyReleasedin classALcdGXYSmartController
-
mousePressed
- Specified by:
mousePressedin interfaceMouseListener- Overrides:
mousePressedin classALcdGXYSmartController
-
mouseReleased
- Specified by:
mouseReleasedin interfaceMouseListener- Overrides:
mouseReleasedin classALcdGXYSmartController
-
mouseClicked
- Specified by:
mouseClickedin interfaceMouseListener- Overrides:
mouseClickedin classALcdGXYSmartController
-
mouseEntered
- Specified by:
mouseEnteredin interfaceMouseListener- Overrides:
mouseEnteredin classALcdGXYSmartController
-
mouseExited
Description copied from class:ALcdGXYSmartControllerWill perform a pan depending on the values of isDragging, isPanOnMouseDragExit and isPanOnMouseMoveExit properties- Specified by:
mouseExitedin interfaceMouseListener- Overrides:
mouseExitedin classALcdGXYSmartController
-
mouseMoved
- Specified by:
mouseMovedin interfaceMouseMotionListener- Overrides:
mouseMovedin classALcdGXYSmartController
-
mouseDragged
- Specified by:
mouseDraggedin interfaceMouseMotionListener- Overrides:
mouseDraggedin classALcdGXYSmartController
-
addPropertyChangeListener
Add the givenPropertyChangeListener.- Parameters:
aPropertyChangeListener- The listener to be added.- See Also:
-
removePropertyChangeListener
Removes the givenPropertyChangeListener. Does nothing if the listener was never added (or already removed).- Parameters:
aPropertyChangeListener- The listener to remove.- See Also:
-
addMeasurementChangeListener
public void addMeasurementChangeListener(TLcdAdvancedMapRulerController.MeasurementChangeListener aListener) Adds the givenMeasurementChangeListener. This allows to receive updates whenever the measurement is changed.- Parameters:
aListener- The listener to add.- See Also:
-
removeMeasurementChangeListener
public void removeMeasurementChangeListener(TLcdAdvancedMapRulerController.MeasurementChangeListener aListener) Removes the givenMeasurementChangeListener. Does nothing if the listener was never added or already removed.- Parameters:
aListener- The listener to remove.- See Also:
-
getMeasureMode
public int getMeasureMode()Returns the current measuring mode.- Returns:
- the current measuring mode.
-
setMeasureMode
public void setMeasureMode(int aMeasureMode) Sets the current measuring mode.- Parameters:
aMeasureMode- The measuring mode. One of- TLcdAdvancedMapRulerController.MEASURE_GEODETIC Measures the distance and azimuth between two points using the geodetic mode, on the ILcdEllipsoid of the ILcdXYWorldReference of the ILcdGXYView.
- TLcdAdvancedMapRulerController.MEASURE_RHUMBLINE Measures the distance and azimuth between two points using the rhumbline mode, on the ILcdEllipsoid of the ILcdXYWorldReference of the ILcdGXYView.
- TLcdAdvancedMapRulerController.MEASURE_PROJECTION_PLANE Measures the distance and angle between two points in the projection plane of the ILcdXYWorldReference of the ILcdGXYView. This means the measurements are only accurate in a small area around the center of the projection.
-
recalculateMeasureMents
protected void recalculateMeasureMents()Invalidates the calculations. This method should be called when a property is updated which affects the measurement between two points. -
getDistanceFormat
Returns the distance format used to format distances and display them to the user. The default format displays the distance as kilometers.- Returns:
- The distance format.
- See Also:
-
setDistanceFormat
Sets the distance format to use to format distances to be displayed to the user.- Parameters:
aDistanceFormat- The new distance format- See Also:
-
getAzimuthFormat
Returns the format used to format azimuths and display them to the user. The default format shows the angle in degrees, having one fraction digit. It also adds a degree symbol.- Returns:
- The azimuth format.
- See Also:
-
setAzimuthFormat
Sets the azimuth format to be used to format azimuths and display them to the user.- Parameters:
aAzimuthFormat- The new azimuth format.- See Also:
-
isDrawEqualDistanceCurve
public boolean isDrawEqualDistanceCurve()Returns true if the equal distance curve(s) are drawn, false otherwise.- Returns:
- true if the equal distance curve(s) are drawn, false otherwise.
- See Also:
-
setDrawEqualDistanceCurve
public void setDrawEqualDistanceCurve(boolean aDrawEqualDistanceCurve) Sets if the equal distance curve(s) are drawn or not. When a measurement is created, a curve showing points at equal distance as the distance between the mouse pointer and the last measurement point can be displayed. This curve is a circle when using the projection plane measuring mode, a geodesic circle when using geodesic measuring mode and a rhumbline circle when using rhumbline measuring mode.- Parameters:
aDrawEqualDistanceCurve- True to draw the curves, false otherwise.
-
getSnappables
Returns the snappables used by this controller.- Returns:
- the snappables used by this controller.
- See Also:
-
setSnappables
Sets the new snappables for this controller, default is null. If snappables is set to null, snapping will be disabled.- Parameters:
aSnappables- The new list of snappables for this controller- See Also:
-
getGXYEditController
Returns the edit controller that is currently used.- Returns:
- the edit controller that is currently used.
- See Also:
-
setGXYEditController
Sets the edit controller that is used to modify the measurement after it has been created. The list of snappables (getSnappables()is automatically passed to the given aGXYEditController. Note that the edit controller will only be activated when a measurement already exists and when the mouse touches it (ILcdGXYPainter.isTouched). The list of snappables (getSnappables()) is also automatically set to the given controller, provided the controller is of typeTLcdGXYEditControllerorTLcdGXYEditController2. For other types, the snappables should be passed to the controller manually. The edit controller must not be set while this controller is active.- Parameters:
aGXYEditController- The edit controller. Preferably an instance ofTLcdGXYEditControllerorTLcdGXYEditController2.- See Also:
-
getGXYNewController
Returns the new controller that is currently used.- Returns:
- the new controller that is currently used.
- See Also:
-
setGXYNewController
Sets the new controller that is used to create a new measurement on the map. A customILcdGXYNewControllerModelorALcdGXYNewControllerModel2is automatically set to the given aGXYNewController so that it creates the correct object type, provided the controller is of typeTLcdGXYNewControllerorTLcdGXYNewController2, respectively. If the controller is of an other type, the user should make sure it creates the correct type of objects. The list of snappables (getSnappables()) is also automatically set to the given controller, provided the controller is of typeTLcdGXYNewControllerorTLcdGXYNewController2. For other types, the snappables should be passed to the controller manually. The new controller must not be set while this controller is active.- Parameters:
aGXYNewController- The new controller. Preferably an instance ofTLcdGXYNewControllerorTLcdGXYNewController2.- See Also:
-
setLineStyle
Sets the style to use to paint lines.- Parameters:
aLineStyle- the new line style to set.- See Also:
-
getLineStyle
Returns the style to paint lines.- Returns:
- the style to paint lines.
- See Also:
-
isDisplayAzimuth
public boolean isDisplayAzimuth()Returns true if the azimuth is displayed on the map.- Returns:
- true if the azimuth is displayed on the map.
- See Also:
-
setDisplayAzimuth
public void setDisplayAzimuth(boolean aDisplayAzimuth) Set to true if the azimuth must be displayed as a label on the map. Default is false.
When set to
true, an arrow is also added to the middle of every line segment.- Parameters:
aDisplayAzimuth- True to display azimuth on the map, false otherwise.- See Also:
-
setHaloEnabled
public void setHaloEnabled(boolean aHaloEnabled) Enables or disables the halo effect on the measurement lines.- Parameters:
aHaloEnabled- true if halos should be added, false otherwise- See Also:
-
isHaloEnabled
public boolean isHaloEnabled()Returns if the halo effect on the measurement lines is enabled.- Returns:
- if the halo effect on the measurement lines is enabled.
- See Also:
-
setHaloThickness
public void setHaloThickness(int aHaloThickness) Sets the thickness (in pixels) of the halo to be added around measurement lines.- Parameters:
aHaloThickness- the thickness (in pixels) of the halo to be added around measurement lines.- See Also:
-
getHaloThickness
public int getHaloThickness()Returns the thickness (in pixels) of the halo to be added around measurement lines.- Returns:
- the thickness (in pixels) of the halo to be added around measurement lines.
- See Also:
-
setHaloColor
Sets the color of the halo to be added around measurement lines.- Parameters:
aHaloColor- the color of the halo to be added around measurement lines.- See Also:
-
getHaloColor
Returns the color of the halo to be added around measurement lines.- Returns:
- the color of the halo to be added around measurement lines.
- See Also:
-
isPreserveMeasurement
public boolean isPreserveMeasurement()Returns true if the measurement is preserved when the controller is terminated and started again. See alsosetPreserveMeasurement(boolean).- Returns:
- true if the measurement is preserved when the controller is terminated and started again, false otherwise.
-
setPreserveMeasurement
public void setPreserveMeasurement(boolean aPreserveMeasurement) Set to true to preserve the measurement between succeeding calls tostartInteraction(com.luciad.view.gxy.ILcdGXYView)andterminateInteraction(com.luciad.view.gxy.ILcdGXYView). If set to false, the previous measurement is removed every time the controller is started.- Parameters:
aPreserveMeasurement- True to preserve measurements, false otherwise.
-
getGXYLayer
Returns the ILcdGXYLayer containing the measurements. Long term references to the returned layer should not be stored, as it may change. The contents of this layer depend on the controller settings.If the preserve measurement is set to false, the contents of the layer are cleared when terminating the interaction with the controller. If it is set ot true, the measurements are kept.
If the allow multiple measurements flag is set ot true, the layer contains at most one measurement. If not, it can contain any number of measurements.
- Returns:
- the ILcdGXYLayer containing the measurements.
- See Also:
-
setAllowMultipleMeasurements
public void setAllowMultipleMeasurements(boolean aAllowMultipleMeasurements) When set to true, multiple measurements are allowed at the same time.Multiple measurements only works when using a TLcdGXYNewController2. If not, creating a new measurement can be interrupted when touching an other measurement.
In order to have control over the removal of measurements, the measurement layer can be used,
getGXYLayer()can be used.- Parameters:
aAllowMultipleMeasurements- true to allow multiple measurements at the same time.
-
isAllowMultipleMeasurements
public boolean isAllowMultipleMeasurements()Checks if multiple measurements are allowed at the same time.- Returns:
- true if multiple measurements are allowed, and false otherwise.
- See Also:
-
setAlwaysCreate
public void setAlwaysCreate(boolean aAlwaysCreate) Determines whether or not you can only create new measurements, not change existing ones. This setter is only relevant whenallowing multiple measurements. It allows you to define a new measurement starting from an existing one. The default value isfalse, which means that clicking or dragging an existing measurement edits that measurement.Snapping to previously created measurements
Measurements can be snapped to like any other object, if you add them to this controller'ssnappables list.
The easiest way to achieve this is by using thesamples.gxy.common.controller.SnappablesSubsetListsample class and adding the ruler's layer to it as follows:new TLcdAdvancedMapRulerController() { public void startInteraction(ILcdGXYView aGXYView) { super.startInteraction(aGXYView); // Allow snapping to the ruler controller measurements fSnappables.getSnappableLayers().add(getGXYLayer()); } public void terminateInteraction(ILcdGXYView aGXYView) { fSnappables.getSnappableLayers().remove(getGXYLayer()); super.terminateInteraction(aGXYView); } };- Parameters:
aAlwaysCreate- true to always define new measurements- Since:
- 2017.0
- See Also:
-
isAlwaysCreate
public boolean isAlwaysCreate()Returns whether or not you can only create new measurements, not change existing ones. Enabling this behavior in conjunction withsetAllowMultipleMeasurements(boolean)allows you to define a new measurement starting from an existing one.- Since:
- 2017.0
-
setAddGXYLayerToGXYView
public void setAddGXYLayerToGXYView(boolean aAddGXYLayerToGXYView) When set to true, the layer containing measurements is added to the view. This makes it possible to display the measurements, even after terminating the interaction with the controller.The layer will only display its contents after terminating interaction with the view when the preserve measurements property is enabled, and when the remove measurement layer setting is disabled.
- Parameters:
aAddGXYLayerToGXYView- true if the measurement layer should be added to the view, and false otherwise.- See Also:
-
isAddGXYLayerToGXYView
public boolean isAddGXYLayerToGXYView()Checks if the layer containing measurements should be added to the view.- Returns:
- true if the layer should be added, and false otherwise.
- See Also:
-
setRemoveGXYLayerFromGXYView
public void setRemoveGXYLayerFromGXYView(boolean aRemoveGXYLayerFromGXYView) When set to true, the layer containing measurements is removed from the view after terminating the controller interaction. This setting only has effect when the layer containing measurements is also added to the view during interaction.- Parameters:
aRemoveGXYLayerFromGXYView- true if the measurement layer should be removed from the view, and false otherwise.- See Also:
-
isRemoveGXYLayerFromGXYView
public boolean isRemoveGXYLayerFromGXYView()Checks if the layer containing measurements should be removed from the view after terminating the controller interaction.- Returns:
- true if the layer should be removed, and false otherwise.
- See Also:
-
setLabelAlignment
public void setLabelAlignment(int aLabelAlignment) Sets the label alignment.- Parameters:
aLabelAlignment- The alignment of the label. One ofTLcdGXYPolylineLabelPainter.ABOVE,TLcdGXYPolylineLabelPainter.CENTER,TLcdGXYPolylineLabelPainter.BELOW
-
getLabelAlignment
public int getLabelAlignment()Returns the label alignment.- Returns:
- The label alignment. One of
TLcdGXYPolylineLabelPainter.ABOVE,TLcdGXYPolylineLabelPainter.CENTER,TLcdGXYPolylineLabelPainter.BELOW.
-
setTotalDistanceLabelFont
Sets the font of the total distance label.- Parameters:
aTotalDistanceLabelFont- The font.
-
getTotalDistanceLabelFont
Returns the font of the total distance label.- Returns:
- the font of the total distance label.
-
setSegmentLabelFont
Sets the font of the segment distance labels (and possibly azimuth, ifisDisplayAzimuth()is true) to the given font.- Parameters:
aSegmentLabelFont- The new font.
-
getSegmentLabelFont
Returns the font of the segment distance labels (and possibly azimuth, ifisDisplayAzimuth()is true).- Returns:
- The font of the segment labels.
-
isLabelFontBorder
public boolean isLabelFontBorder()Returns true if a border is painted around the label text in the background color.- Returns:
- true if a border is painted around the label text.
- See Also:
-
setLabelFontBorder
public void setLabelFontBorder(boolean aLabelFontBorder) Sets if the painted text should be bordered with the background color. This improves readability because the text will be readable on both light and dark background colors.- Parameters:
aLabelFontBorder- True if text should be bordered, false otherwise.- See Also:
-
setLabelForeground
Sets the foreground color of the labels.- Parameters:
aLabelForeground- The foreground color of the labels.
-
getLabelForeground
Returns the foreground color of the labels.- Returns:
- the foreground color of the labels.
-
setLabelBackground
Sets the background color of the labels. This color is used to fill the background of the labels ifisLabelFilled()returns true, or to paint a border around the text whenisLabelFontBorder()returns true.- Parameters:
aLabelBackground- The background color of the labels.
-
getLabelBackground
Returns the background color of the labels.- Returns:
- the background color of the labels.
-
setLabelSelectionColor
Sets the selection color of the labels.- Parameters:
aLabelSelectionColor- The label selection color.
-
getLabelSelectionColor
Returns the selection color of the labels.- Returns:
- the selection color of the labels.
-
setLabelFrame
public void setLabelFrame(boolean aLabelFrame) Labels can be drawn surrounded by a frame, the frame property determines whether to frame the labels or not.- Parameters:
aLabelFrame- True if the labels should be surrounded by a frame, false otherwise.
-
isLabelFrame
public boolean isLabelFrame()Returns true if the labels are surrounded by a frame, false otherwise.- Returns:
- true if the labels are surrounded by a frame, false otherwise.
-
setLabelRotationAllowed
public void setLabelRotationAllowed(boolean aLabelRotationAllowed) Labels can be rotated so that they have the same angle as the polyline. The rotationAllowed property determines whether it is allowed to rotate labels.- Parameters:
aLabelRotationAllowed- True if the labels can be rotated, false otherwise.
-
isLabelRotationAllowed
public boolean isLabelRotationAllowed()Returns true if the labels can be rotated along the polyline, false otherwise.- Returns:
- true if the labels can be rotated along the polyline, false otherwise.
- See Also:
-
setLabelFilled
public void setLabelFilled(boolean aLabelFilled) Sets if a filled rectangle should be painted behind the labels. The rectangle is filled with thegetLabelBackground()color.- Parameters:
aLabelFilled- True if a filled rectangle is painted behind the labels, false otherwise.
-
isLabelFilled
public boolean isLabelFilled()Returns true if a filled rectangle should be painted behind the labels.- Returns:
- true if a filled rectangle should be painted behind the labels.
-
setLabelVGap
public void setLabelVGap(int aVerticalGap) Sets the orthogonal distance (in pixels) between the label and the line segment. This property allows to define a shift on top of the alignment.- Parameters:
aVerticalGap- The orthogonal distance (in pixels) between the label and the line segment.
-
getLabelVGap
public int getLabelVGap()Returns the orthogonal distance (in pixels) between the label and the line segment.- Returns:
- the orthogonal distance (in pixels) between the label and the line segment.
-
getHotPointIcon
Returns the hot point icon, it can benull.- Returns:
- the hot point icon, it can be
null. - See Also:
-
setHotPointIcon
Sets the hot point icon, used to paint the handles on the measurement line.- Parameters:
aHotPointIcon- The hot point icon, ornullfor a default icon.- See Also:
-
getMeasurementPointCount
public int getMeasurementPointCount()Returns the point count of the current measurement.- Returns:
- the point count of the current measurement.
- See Also:
-
getMeasurementPoint
The measurement point at the given index.- Parameters:
aIndex- The index of the point to retrieve. 0 <= aIndex < getMeasurementPointCount()- Returns:
- the measurement point at the given index.
- See Also:
-
getMeasurementGeoReference
Returns the geo reference of the measurement points.- Returns:
- the geo reference of the measurement points.
- See Also:
-
getMeasurementSegmentCount
public int getMeasurementSegmentCount()Returns the amount of segments of the current measurement.- Returns:
- the amount of segments of the current measurement.
- See Also:
-
getMeasurementSegmentDistance
public double getMeasurementSegmentDistance(int aIndex) Returns the distance in meters of the segment at the given index. ReturnsDouble.NaNif no distance is available. Please note thatDouble.NaN == Double.NaNalways returnsfalse, one must useDouble.isNaN( double ).- Parameters:
aIndex- The index of the segment. 0 <= aIndex < getMeasurementSegmentCount()- Returns:
- the distance in meters of the segment at the given index.
- See Also:
-
getMeasurementSegmentAzimuth
public double getMeasurementSegmentAzimuth(int aIndex) Returns the azimuth in degrees of the segment at the given index. 0 degrees is at 12 o clock, positive clock wise. ReturnsDouble.NaNif no azimuth is available. Please note thatDouble.NaN == Double.NaNalways returnsfalse, one must useDouble.isNaN( double ).- Parameters:
aIndex- The index of the segment. 0 <= aIndex < getMeasurementSegmentCount()- Returns:
- the azimuth in degrees of the segment at the given index.
- See Also:
-
getMeasurementTotalDistance
public double getMeasurementTotalDistance()Returns the total distance in meters of the current measurement, the sum of all the segment distances. ReturnsDouble.NaNif no total distance is available. Please note thatDouble.NaN == Double.NaNalways returnsfalse, one must useDouble.isNaN( double ).- Returns:
- the total distance in meters of the current measurement.
-
createGXYLayer
Create a new layer used for storing the measurements.The default implementation returns a new TLcdGXYLayer.
- Returns:
- a new layer used for storing the measurements.
-
createGXYPolylinePainter
Creates the painter for the polylines used to measure the distances. The painter must accept objects of typeILcd3DEditablePolyline. The properties of the returned painter must be synchronized with the properties of this controller. For example, if the lineStyle of this controller is changed, the returned painter must respect this change. This can easily be achieved by adding a property change listener to this controller that synchronizes the properties of this controller and the painter. If you override this method, make sure that the painter also implements ILcdGXYEditor, or overridecreateGXYPolylineEditor()as well.- Returns:
- ILcdGXYPainter that accepts
ILcd3DEditablePolylineobjects.
-
createGXYPolylineEditor
Creates the editor for the polylines used to measure the distances. The editor must accept objects of typeILcd3DEditablePolyline. The properties of the returned editor must be synchronized with the properties of this controller. For example, if the lineStyle of this controller is changed, the returned editor must respect this change. This can easily be achieved by adding a property change listener to this controller that synchronizes the properties of this controller and the painter. The default implementation of this method callscreateGXYPolylinePainter()and casts it toILcdGXYEditor.- Returns:
- ILcdGXYEditor that accepts
ILcd3DEditablePolylineobjects.
-
createGXYEqualDistanceCurvePainter
Creates the painter of the equal distance curve for the polylines used to measure the distances. The painter/editor must accepts objects of typeILcd3DEditablePolyline, and draw the equal distance curve when the polyline is modified. The properties of the returned painter must be synchronized with the properties of this controller. For example, if the lineStyle of this controller is changed, the returned painter must respect this change. This can easily be achieved by adding a property change listener to this controller that synchronizes the properties of this controller and the painter.- Returns:
- ILcdGXYPainter that accepts
ILcd3DEditablePolylineobjects and paints the equal distance curve when the polyline is modified.
-
createGXYLabelPainter
Creates the label painter for the distance labels (or maybe angle labels, etc). You might want to return aILcdGXYMultiLabelPainterto put multiple labels on the one polyline. This label painter must accept objects of typeILcd3DEditablePolyline. This object implements bothILcdDataObjectandILcdFeatured. The object has the following three properties (features):- index 0: the total distance of the line as a
Double - index 1: this property is a list property of type double (the feature value is as such
a
VectorofDoubles) containing the distance in meters for every segment - index 2: this property is also a list property of type double containing the azimuth in degrees of every segment.
- Returns:
- The
ILcdGXYLabelPainterresponsible to paint the distance labels etc.
- index 0: the total distance of the line as a
-
createGXYLayerLabelPainter
Creates theILcdGXYLayerLabelPainterfor the ruler controller. This painter is used to position the different labels, so it contains the label decluttering logic.- Returns:
- The
ILcdGXYLayerLabelPainterresponsible to position the labels.
-
calculateDistance
protected double calculateDistance(ILcdPoint aPoint1, ILcdPoint aPoint2, ILcdGeoReference aGeoReference, int aMeasureMode, ILcdGXYContext aGXYContext) Calculates the distance in meters between the two given points.- Parameters:
aPoint1- The first point.aPoint2- The second point.aGeoReference- The geo reference of the points.aMeasureMode- The measure mode: one of MEASURE_GEODETIC, MEASURE_RHUMBLINE or MEASURE_PROJECTION_PLANEaGXYContext- The context.- Returns:
- The distance in meters between the two points, or
Double.NaN if no distance calculation can be performed. Please note that
Double.NaN == Double.NaNalways returnsfalse, one must useDouble.isNaN( double ).
-
calculateAzimuth
protected double calculateAzimuth(ILcdPoint aPoint1, ILcdPoint aPoint2, ILcdGeoReference aGeoReference, int aMeasureMode, ILcdGXYContext aGXYContext) Calculates the azimuth in degrees between the two given points. 0 degrees is at 12 o clock, positive clock wise.- Parameters:
aPoint1- The first point.aPoint2- The second point.aGeoReference- The geo reference of the points.aMeasureMode- The measure mode: one of MEASURE_GEODETIC, MEASURE_RHUMBLINE or MEASURE_PROJECTION_PLANEaGXYContext- The context.- Returns:
- The azimuth in degrees between the points, or
Double.NaN if no azimuth calculation can be performed. Please note that
Double.NaN == Double.NaNalways returnsfalse, one must useDouble.isNaN( double ).
-
getNextGXYController
Description copied from interface:ILcdGXYChainableControllerReturns a reference to the controller that is located after this one in a chain, or null if this controller is the last element of the chain.- Specified by:
getNextGXYControllerin interfaceILcdGXYChainableController- Returns:
- a reference to the next controller.
- See Also:
-
setNextGXYController
Description copied from interface:ILcdGXYChainableControllerThis method sets the next controller in the chain for this controller. You can set null if you want the chain to end. This method does not start or terminate any interaction. If you need to replace a controller while it's being used you are responsible for properly terminating and starting it yourself.- Specified by:
setNextGXYControllerin interfaceILcdGXYChainableController- Parameters:
aNext- the reference to the controller that will be the next element in the chain- See Also:
-
appendGXYController
Description copied from interface:ILcdGXYChainableControllerThis method will append the passed controller to the end of the chain. The controller will be the stored as the next controller in the last element of the current chain.- Specified by:
appendGXYControllerin interfaceILcdGXYChainableController- Parameters:
aEnd- the controller to be appended to the end of the chain.
-
handleAWTEvent
Description copied from interface:ILcdAWTEventListenerThis is method is called when the target of the listener has a new AWTEvent available.- Specified by:
handleAWTEventin interfaceILcdAWTEventListener- Parameters:
aEvent- The event to be handled.
-