public class TLcdMagneticNorthGXYController extends ALcdGXYSmartController implements ILcdGXYChainableController
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.
Constructor and Description |
---|
TLcdMagneticNorthGXYController()
Default constructor, you will have to set a magnetic north map before the object
is usable.
|
TLcdMagneticNorthGXYController(Cursor aCursor)
Constructs a new controller with the given cursor.
|
TLcdMagneticNorthGXYController(Cursor aCursor,
ILcdMagneticNorthMap aMagneticNorthMap)
Creates a new
TLcdMagneticNorthGXYController with the given
cursor and the given ILcdMagneticNorthMap . |
TLcdMagneticNorthGXYController(ILcdMagneticNorthMap aMagneticNorthMap)
Creates a new
TLcdMagneticNorthGXYController with the given
ILcdMagneticNorthMap . |
Modifier and Type | Method and Description |
---|---|
void |
appendGXYController(ILcdGXYChainableController aEnd)
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.
|
ILcdAction |
getActionToTrigger()
Returns the action that will be triggered after each recenter and rotation of the gxy.
|
float |
getHeightAboveSeaLevel()
Gets the height the cursor is assumed to be above the surface of the earth.
|
Color |
getLabelBackgroundColor()
Returns the label background color.
|
Font |
getLabelFont()
Returns the font for used by the label displaying the declination.
|
Color |
getLabelFontColor()
Returns the color of the font of the label displaying the declination.
|
ILcdMagneticNorthMap |
getMagneticNorthMap()
Returns the magnetic north map this controller is using.
|
ILcdGXYChainableController |
getNextGXYController()
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 |
isDisplayLabel()
Returns true if the label should be displayed, false otherwise.
|
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.
|
void |
mouseClicked(MouseEvent aMouseEvent)
Invoked when a mouse button has been clicked on the
ILcdGXYView component. |
void |
mouseDragged(MouseEvent aMouseEvent) |
void |
mouseEntered(MouseEvent me)
Invoked when the mouse enters the
ILcdGXYView component. |
void |
mouseExited(MouseEvent me)
Invoked when the mouse exits the
ILcdGXYView component. |
void |
mouseMoved(MouseEvent aMouseEvent) |
void |
mousePressed(MouseEvent me)
Invoked when a mouse button has been pressed on the
ILcdGXYView component. |
void |
mouseReleased(MouseEvent aMouseEvent) |
void |
paint(Graphics aGraphics)
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 an
ILcdAction to trigger just after having recentered and rotated
the ILcdGXYView . |
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 |
setNextGXYController(ILcdGXYChainableController aNext)
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.
|
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
addStatusListener, asGXYController, fireStatusEvent, getCursor, getGXYView, getIcon, getName, getShortDescription, registerInstance, removeStatusListener, retrieveGXYViewXYWorldTransformation, setClassTraceOn, setCursor, setGXYView, setIcon, setName, setShortDescription, viewRepaint
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getCursor, getIcon, getLayered, getName, getShortDescription, viewRepaint
public TLcdMagneticNorthGXYController()
public TLcdMagneticNorthGXYController(Cursor aCursor)
aCursor
- The cursor for this controllerpublic TLcdMagneticNorthGXYController(ILcdMagneticNorthMap aMagneticNorthMap)
TLcdMagneticNorthGXYController
with the given
ILcdMagneticNorthMap
. The object is ready to use.aMagneticNorthMap
- The magnetic north map the controller will use.public TLcdMagneticNorthGXYController(Cursor aCursor, ILcdMagneticNorthMap aMagneticNorthMap)
TLcdMagneticNorthGXYController
with the given
cursor and the given ILcdMagneticNorthMap
.aCursor
- The cursor for this controlleraMagneticNorthMap
- The magnetic north map this controller will use.public void setActionToTrigger(ILcdAction aActionToTrigger)
ILcdAction
to trigger just after having recentered and rotated
the ILcdGXYView
.
This can be used to set another ILcdGXController
after each recenter.aActionToTrigger
- The action that will be triggered after each recenter and rotation of the gxy.getActionToTrigger()
public ILcdAction getActionToTrigger()
setActionToTrigger(com.luciad.gui.ILcdAction)
public ILcdMagneticNorthMap getMagneticNorthMap()
setMagneticNorthMap(com.luciad.format.magneticnorth.ILcdMagneticNorthMap)
public void setMagneticNorthMap(ILcdMagneticNorthMap aMagneticNorthMap)
aMagneticNorthMap
- The magnetic north map this controller will usegetMagneticNorthMap()
public Color getLabelFontColor()
setLabelFontColor(java.awt.Color)
public void setLabelFontColor(Color aLabelFontColor)
aLabelFontColor
- The color for the font of the label.getLabelFontColor()
public Color getLabelBackgroundColor()
setLabelBackgroundColor(java.awt.Color)
public void setLabelBackgroundColor(Color aLabelBackgroundColor)
aLabelBackgroundColor
- The background color for the label.getLabelBackgroundColor()
public Font getLabelFont()
setLabelFont(java.awt.Font)
public void setLabelFont(Font aLabelFont)
aLabelFont
- The new font.getLabelFont()
public boolean isDisplayLabel()
setDisplayLabel(boolean)
public void setDisplayLabel(boolean aDisplayLabel)
aDisplayLabel
- True if the label has to be displayed, false otherwise.isDisplayLabel()
public boolean isRotateNorthToTopOnClick()
setRotateNorthToTopOnClick(boolean)
public void setRotateNorthToTopOnClick(boolean aRotateNorthToTopOnClick)
aRotateNorthToTopOnClick
- True if the map should be rotated on mouse click, false otherwise.isRotateNorthToTopOnClick()
public float getHeightAboveSeaLevel()
setHeightAboveSeaLevel(float)
public void setHeightAboveSeaLevel(float aHeightAboveSeaLevel)
aHeightAboveSeaLevel
- The height the cursor is above the surface of the earth. Unit is km.getHeightAboveSeaLevel()
public void startInteraction(ILcdGXYView aView)
ALcdGXYController
All ILcdGXYView
implementations that support interaction call this method when the controller
has been made active with setGXYController
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
.
startInteraction
in interface ILcdGXYController
startInteraction
in class ALcdGXYSmartController
aView
- the ILcdGXYView
this ILcdGXYController
will interact with.ILcdGXYView.setGXYController(com.luciad.view.gxy.ILcdGXYController)
,
ILcdGXYController.terminateInteraction(com.luciad.view.gxy.ILcdGXYView)
public void terminateInteraction(ILcdGXYView aGXYView)
ALcdGXYController
terminateInteraction
in interface ILcdGXYController
terminateInteraction
in class ALcdGXYSmartController
aGXYView
- the ILcdGXYView
this ILcdGXYController
interacted with.ILcdGXYView.setGXYController(com.luciad.view.gxy.ILcdGXYController)
,
ILcdGXYController.startInteraction(com.luciad.view.gxy.ILcdGXYView)
protected double retrieveDeclination(MouseEvent aMouseEvent)
aMouseEvent
- the mouse event that contains the current mouse position.public void paint(Graphics aGraphics)
ALcdGXYController
Empty implementation. Redefine this method to render on the Graphics on which the view is rendered.
paint
in interface ILcdGXYController
paint
in class ALcdGXYController
aGraphics
- the Graphics on which the view was rendered.protected String[] formatToolTip(double aValue)
aValue
- The declination value, as an angle in degrees.public void mouseReleased(MouseEvent aMouseEvent)
mouseReleased
in interface MouseListener
mouseReleased
in class ALcdGXYSmartController
public void mouseDragged(MouseEvent aMouseEvent)
mouseDragged
in interface MouseMotionListener
mouseDragged
in class ALcdGXYSmartController
public void mouseMoved(MouseEvent aMouseEvent)
mouseMoved
in interface MouseMotionListener
mouseMoved
in class ALcdGXYSmartController
public void restore()
public void mouseClicked(MouseEvent aMouseEvent)
ILcdGXYView
component.mouseClicked
in interface MouseListener
mouseClicked
in class ALcdGXYSmartController
public void mousePressed(MouseEvent me)
ILcdGXYView
component.mousePressed
in interface MouseListener
mousePressed
in class ALcdGXYSmartController
public void mouseEntered(MouseEvent me)
ILcdGXYView
component.mouseEntered
in interface MouseListener
mouseEntered
in class ALcdGXYSmartController
public void mouseExited(MouseEvent me)
ILcdGXYView
component.mouseExited
in interface MouseListener
mouseExited
in class ALcdGXYSmartController
public ILcdGXYChainableController getNextGXYController()
ILcdGXYChainableController
getNextGXYController
in interface ILcdGXYChainableController
ILcdGXYChainableController.setNextGXYController(ILcdGXYChainableController)
public void setNextGXYController(ILcdGXYChainableController aNext)
ILcdGXYChainableController
setNextGXYController
in interface ILcdGXYChainableController
aNext
- the reference to the controller that will be the next element in the chainILcdGXYChainableController.getNextGXYController()
public void appendGXYController(ILcdGXYChainableController aEnd)
ILcdGXYChainableController
appendGXYController
in interface ILcdGXYChainableController
aEnd
- the controller to be appended to the end of the chain.public void handleAWTEvent(AWTEvent aEvent)
ILcdAWTEventListener
handleAWTEvent
in interface ILcdAWTEventListener
aEvent
- The event to be handled.