Class TLcdMagneticNorthGXYController
- All Implemented Interfaces:
ILcdUndoableSource
,ILcdAWTEventListener
,ILcdStatusSource
,ILcdGXYChainableController
,ILcdGXYController
,KeyListener
,MouseListener
,MouseMotionListener
,Serializable
,EventListener
ILcdGXYView
, this ILcdController
will catch each mouseClicked and try to modify the properties of the
ILcdProjection
currently on the ILcdGXYView
accordingly.
More specifically it re-centers the projection at the touched point and it will rotate the map such that the direction to the magnetic north (what a compass would indicate) is equal to the (vertical) direction to the top of your screen.
This controller will also display a tool tip showing the declination at the point under
the mouse cursor, see formatToolTip
..
Note that the user of this class is responsible for giving this object a correctly initialized magnetic north map.
- See Also:
-
Constructor Summary
ConstructorDescriptionDefault constructor, you will have to set a magnetic north map before the object is usable.TLcdMagneticNorthGXYController
(ILcdMagneticNorthMap aMagneticNorthMap) Creates a newTLcdMagneticNorthGXYController
with the givenILcdMagneticNorthMap
.TLcdMagneticNorthGXYController
(Cursor aCursor) Constructs a new controller with the given cursor.TLcdMagneticNorthGXYController
(Cursor aCursor, ILcdMagneticNorthMap aMagneticNorthMap) Creates a newTLcdMagneticNorthGXYController
with the given cursor and the givenILcdMagneticNorthMap
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
This method will append the passed controller to the end of the chain.protected String[]
formatToolTip
(double aValue) Formats the tool tip for the given declination value.Returns the action that will be triggered after each recenter and rotation of the gxy.float
Gets the height the cursor is assumed to be above the surface of the earth.Returns the label background color.Returns the font for used by the label displaying the declination.Returns the color of the font of the label displaying the declination.Returns the magnetic north map this controller is using.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.void
handleAWTEvent
(AWTEvent aEvent) This is method is called when the target of the listener has a new AWTEvent available.boolean
Returns true if the label should be displayed, false otherwise.boolean
Returns true if the map will be rotated such that the magnetic north is at the top of the map on a mouse click.void
mouseClicked
(MouseEvent aMouseEvent) Invoked when a mouse button has been clicked on theILcdGXYView
component.void
mouseDragged
(MouseEvent aMouseEvent) void
Invoked when the mouse enters theILcdGXYView
component.void
Invoked when the mouse exits theILcdGXYView
component.void
mouseMoved
(MouseEvent aMouseEvent) void
Invoked when a mouse button has been pressed on theILcdGXYView
component.void
mouseReleased
(MouseEvent aMouseEvent) void
Enables the controller to give visual feedback on the current user interactions.void
restore()
Restores the map rotation to normal.protected double
retrieveDeclination
(MouseEvent aMouseEvent) Returns the declination for the point associated with the current mouse position.void
setActionToTrigger
(ILcdAction aActionToTrigger) Sets anILcdAction
to trigger just after having recentered and rotated theILcdGXYView
.void
setDisplayLabel
(boolean aDisplayLabel) Sets whether this controller should display a label containing the declination at the point under the mouse cursor.void
setHeightAboveSeaLevel
(float aHeightAboveSeaLevel) Sets the height above the surface of the earth to perform the calculations for.void
setLabelBackgroundColor
(Color aLabelBackgroundColor) Sets a new background color for the label.void
setLabelFont
(Font aLabelFont) Sets a new font for the label displaying the declination.void
setLabelFontColor
(Color aLabelFontColor) Sets the font color of the label.void
setMagneticNorthMap
(ILcdMagneticNorthMap aMagneticNorthMap) Sets the magnetic north map this controller will use.void
This method sets the next controller in the chain for this controller.void
setRotateNorthToTopOnClick
(boolean aRotateNorthToTopOnClick) Sets whether this controller should rotate the map such that the magnetic north is at the top of the map.void
startInteraction
(ILcdGXYView aView) Sets up the controller to receive input through the view passed.void
terminateInteraction
(ILcdGXYView aGXYView) Releases a few items.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, keyPressed, keyReleased, keyTyped, removeUndoableListener, setDownPanChars, setDownPanCodes, setIsDragging, setLeftPanChars, setLeftPanCodes, setPanAbsDelta, setPanOnMouseDragExit, setPanOnMouseMoveExit, setPanUndoable, setRequestFocusOnMouseEntered, setRequestFocusOnMousePressed, setRightPanChars, setRightPanCodes, setTraceOn, setUpPanChars, setUpPanCodes, setZoomInChars, setZoomInCodes, setZoomOutChars, setZoomOutCodes, setZoomUndoable, updateViewLocationAfterZoomSFCT
Methods inherited from class com.luciad.view.gxy.controller.ALcdGXYController
addStatusListener, asGXYController, fireStatusEvent, getCursor, getGXYView, getIcon, getName, getShortDescription, registerInstance, removeStatusListener, retrieveGXYViewXYWorldTransformation, setClassTraceOn, setCursor, setGXYView, setIcon, setName, setShortDescription, viewRepaint
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.luciad.view.gxy.ILcdGXYController
getCursor, getIcon, getLayered, getName, getShortDescription, viewRepaint
-
Constructor Details
-
TLcdMagneticNorthGXYController
public TLcdMagneticNorthGXYController()Default constructor, you will have to set a magnetic north map before the object is usable. -
TLcdMagneticNorthGXYController
Constructs a new controller with the given cursor. You will have to set a magnetic north map before the object is usable.- Parameters:
aCursor
- The cursor for this controller
-
TLcdMagneticNorthGXYController
Creates a newTLcdMagneticNorthGXYController
with the givenILcdMagneticNorthMap
. The object is ready to use.- Parameters:
aMagneticNorthMap
- The magnetic north map the controller will use.
-
TLcdMagneticNorthGXYController
Creates a newTLcdMagneticNorthGXYController
with the given cursor and the givenILcdMagneticNorthMap
.- Parameters:
aCursor
- The cursor for this controlleraMagneticNorthMap
- The magnetic north map this controller will use.
-
-
Method Details
-
setActionToTrigger
Sets anILcdAction
to trigger just after having recentered and rotated theILcdGXYView
. This can be used to set anotherILcdGXController
after each recenter.- Parameters:
aActionToTrigger
- The action that will be triggered after each recenter and rotation of the gxy.- See Also:
-
getActionToTrigger
Returns the action that will be triggered after each recenter and rotation of the gxy.- Returns:
- the action that will be triggered after each recenter and rotation of the gxy.
- See Also:
-
getMagneticNorthMap
Returns the magnetic north map this controller is using.- Returns:
- the magnetic north map this controller is using.
- See Also:
-
setMagneticNorthMap
Sets the magnetic north map this controller will use.- Parameters:
aMagneticNorthMap
- The magnetic north map this controller will use- See Also:
-
getLabelFontColor
Returns the color of the font of the label displaying the declination.- Returns:
- the color of the font of the label displaying the declination.
- See Also:
-
setLabelFontColor
Sets the font color of the label.- Parameters:
aLabelFontColor
- The color for the font of the label.- See Also:
-
getLabelBackgroundColor
Returns the label background color.- Returns:
- the label background color.
- See Also:
-
setLabelBackgroundColor
Sets a new background color for the label.- Parameters:
aLabelBackgroundColor
- The background color for the label.- See Also:
-
getLabelFont
Returns the font for used by the label displaying the declination.- Returns:
- the font for used by the label displaying the declination.
- See Also:
-
setLabelFont
Sets a new font for the label displaying the declination.- Parameters:
aLabelFont
- The new font.- See Also:
-
isDisplayLabel
public boolean isDisplayLabel()Returns true if the label should be displayed, false otherwise.- Returns:
- true if the label should be displayed, false otherwise.
- See Also:
-
setDisplayLabel
public void setDisplayLabel(boolean aDisplayLabel) Sets whether this controller should display a label containing the declination at the point under the mouse cursor.- Parameters:
aDisplayLabel
- True if the label has to be displayed, false otherwise.- See Also:
-
isRotateNorthToTopOnClick
public boolean isRotateNorthToTopOnClick()Returns true if the map will be rotated such that the magnetic north is at the top of the map on a mouse click.- Returns:
- True if the map will be rotated on mouse click, false otherwise.
- See Also:
-
setRotateNorthToTopOnClick
public void setRotateNorthToTopOnClick(boolean aRotateNorthToTopOnClick) Sets whether this controller should rotate the map such that the magnetic north is at the top of the map.- Parameters:
aRotateNorthToTopOnClick
- True if the map should be rotated on mouse click, false otherwise.- See Also:
-
getHeightAboveSeaLevel
public float getHeightAboveSeaLevel()Gets the height the cursor is assumed to be above the surface of the earth.- Returns:
- The height the cursor is assumed to be above the surface of the earth. Unit is km.
- See Also:
-
setHeightAboveSeaLevel
public void setHeightAboveSeaLevel(float aHeightAboveSeaLevel) Sets the height above the surface of the earth to perform the calculations for.- Parameters:
aHeightAboveSeaLevel
- The height the cursor is above the surface of the earth. Unit is km.- See Also:
-
startInteraction
Description copied from class:ALcdGXYController
Sets up the controller to receive input through the view passed.All
ILcdGXYView
implementations that support interaction call this method when the controller has been made active withsetGXYController
on 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:
startInteraction
in interfaceILcdGXYController
- Overrides:
startInteraction
in classALcdGXYSmartController
- Parameters:
aView
- theILcdGXYView
thisILcdGXYController
will interact with.- See Also:
-
terminateInteraction
Description copied from class:ALcdGXYController
Releases a few items. Can be redefined but this 'super' method should be called too.- Specified by:
terminateInteraction
in interfaceILcdGXYController
- Overrides:
terminateInteraction
in classALcdGXYSmartController
- Parameters:
aGXYView
- theILcdGXYView
thisILcdGXYController
interacted with.- See Also:
-
retrieveDeclination
Returns the declination for the point associated with the current mouse position.- Parameters:
aMouseEvent
- the mouse event that contains the current mouse position.- Returns:
- the declination for the point associated with the current mouse position.
-
paint
Description copied from class:ALcdGXYController
Enables 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:
paint
in interfaceILcdGXYController
- Overrides:
paint
in classALcdGXYController
- Parameters:
aGraphics
- the Graphics on which the view was rendered.
-
formatToolTip
Formats the tool tip for the given declination value.- Parameters:
aValue
- The declination value, as an angle in degrees.- Returns:
- The formatted array of strings. Every string is painted on a new line.
-
mouseReleased
- Specified by:
mouseReleased
in interfaceMouseListener
- Overrides:
mouseReleased
in classALcdGXYSmartController
-
mouseDragged
- Specified by:
mouseDragged
in interfaceMouseMotionListener
- Overrides:
mouseDragged
in classALcdGXYSmartController
-
mouseMoved
- Specified by:
mouseMoved
in interfaceMouseMotionListener
- Overrides:
mouseMoved
in classALcdGXYSmartController
-
restore
public void restore()Restores the map rotation to normal. -
mouseClicked
Invoked when a mouse button has been clicked on theILcdGXYView
component.- Specified by:
mouseClicked
in interfaceMouseListener
- Overrides:
mouseClicked
in classALcdGXYSmartController
-
mousePressed
Invoked when a mouse button has been pressed on theILcdGXYView
component.- Specified by:
mousePressed
in interfaceMouseListener
- Overrides:
mousePressed
in classALcdGXYSmartController
-
mouseEntered
Invoked when the mouse enters theILcdGXYView
component.- Specified by:
mouseEntered
in interfaceMouseListener
- Overrides:
mouseEntered
in classALcdGXYSmartController
-
mouseExited
Invoked when the mouse exits theILcdGXYView
component.- Specified by:
mouseExited
in interfaceMouseListener
- Overrides:
mouseExited
in classALcdGXYSmartController
-
getNextGXYController
Description copied from interface:ILcdGXYChainableController
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.- Specified by:
getNextGXYController
in interfaceILcdGXYChainableController
- Returns:
- a reference to the next controller.
- See Also:
-
setNextGXYController
Description copied from interface:ILcdGXYChainableController
This 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:
setNextGXYController
in interfaceILcdGXYChainableController
- Parameters:
aNext
- the reference to the controller that will be the next element in the chain- See Also:
-
appendGXYController
Description copied from interface:ILcdGXYChainableController
This 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:
appendGXYController
in interfaceILcdGXYChainableController
- Parameters:
aEnd
- the controller to be appended to the end of the chain.
-
handleAWTEvent
Description copied from interface:ILcdAWTEventListener
This is method is called when the target of the listener has a new AWTEvent available.- Specified by:
handleAWTEvent
in interfaceILcdAWTEventListener
- Parameters:
aEvent
- The event to be handled.
-