Class TLcdGXYEditController2
- All Implemented Interfaces:
ILcdUndoableSource
,ILcdAWTEventListener
,ILcdStatusSource
,ILcdGXYChainableController
,ILcdGXYController
,KeyListener
,MouseListener
,MouseMotionListener
,Serializable
,EventListener
TLcdGXYSelectController2
that adds editing
capabilities to it. It allows a user to graphically edit objects on an
ILcdGXYView
using the mouse.
The selected objects are translated by moving the mouse pointer over them,
and dragging them to a new location. Selecting and dragging can be performed
as one operation. If the ctrl modifier key is pressed during the drag, the
single object that is touched by the mouse pointer is reshaped. Escape can be
used to abort the edit operation. Note that the meaning of translating and
reshaping is defined by the implementations of the ILcdGXYPainter
s
and ILcdGXYEditor
s.
Both the objects themselves (bodies) and their labels can be edited. Editing
an object requires that an ILcdGXYEditor
is available from
the layer, editing the labels requires that an ILcdGXYLabelEditor
and an ILcdGXYLabelPainter2
(not just ILcdGXYLabelPainter
)
are available from the layer.
All editing related logic can programmatically be customized by setting
a custom
TLcdGXYEditControllerModel2
, for example to change the behavior of
modifier keys, disable editing of labels, influence which objects should be
edited, specify which mouse cursor to use, etc. Please refer to
TLcdGXYEditControllerModel2
for more information.
This controller can be configured to instantly edit objects and labels, instead of only
applying the edit when the mouse is released. See setInstantEditing
for more information.
This controller supports undo capabilities, please refer to TLcdGXYEditControllerModel2
for more information.
This controller also has snapping capabilities. A list of candidates for
snapping must be set
to enable this feature.- Since:
- 7.0
- See Also:
-
Field Summary
Fields inherited from class com.luciad.view.gxy.controller.TLcdGXYDragRectangleController
fXPressed, fXReleased, fYPressed, fYReleased
-
Constructor Summary
ConstructorDescriptionConstructs a new edit controller, using a defaultTLcdGXYEditControllerModel2
andTLcdGXYSelectControllerModel2
. -
Method Summary
Modifier and TypeMethodDescriptionprotected int
editHowMode
(ILcdGXYView aGXYView, ILcdGXYLayerSubsetList aSnappables, Point aFrom, Point aTo, MouseEvent aMouseEvent) Returns the edit-how mode.protected int
editWhatMode
(ILcdGXYView aGXYView, ILcdGXYLayerSubsetList aSnappables, Point aFrom, Point aTo, MouseEvent aMouseEvent, int aEditHow) Returns the edit-what mode.Returns the edit controller model.Returns the snappables.This method returns the filter that will determine which layers have sticky labels when hovering over them.boolean
This method indicates whether the object being edited is painted in a temporary state and only changed when the mouse is released, or whether the object is instantly edited while the mouse is dragged.void
keyPressed
(KeyEvent aKeyEvent) Handles key pressed events.void
keyReleased
(KeyEvent aKeyEvent) Handles key released events.void
Handles mouse dragged events.void
Will perform a pan depending on the values of isDragging, isPanOnMouseDragExit and isPanOnMouseMoveExit propertiesvoid
mouseMoved
(MouseEvent me) Handles mouse moved events.void
Handles mouse pressed events.void
Handles mouse released events.void
If an edit is ongoing, this method paints the edited objects in their editing state.protected void
repaintGXYView
(ILcdGXYView aGXYView) Repaints the givenILcdGXYView
.void
This cursor is only used when there is no specific cursor provided by the controller model.void
setEditControllerModel
(TLcdGXYEditControllerModel2 aEditControllerModel) Sets the edit controller model.void
setInstantEditing
(boolean aInstantEditing) The method can be used to activate or deactivate instant editing.void
setSnappables
(ILcdGXYLayerSubsetList aSnappables) Sets the set of objects that are used as candidates-to-snap-to while editing other objects.void
setStickyLabelsLayerFilter
(ILcdFilter aStickyLabelsLayerFilter) Sets the filter that will indicate which layers should have sticky labels when hovering over them.void
startInteraction
(ILcdGXYView aGXYView) 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.TLcdGXYSelectController2
appendGXYController, getAWTFilter, getDoubleClickAction, getMultiSelectModifierKey, getNextGXYController, getRightClickAction, getSelectControllerModel, handleAWTEvent, selectByWhatMode, selectHowMode, setAWTFilter, setDoubleClickAction, setMultiSelectModifierKey, setNextGXYController, setRightClickAction, setSelectControllerModel, trigger
Methods inherited from class com.luciad.view.gxy.controller.TLcdGXYDragRectangleController
adaptRectangle, doPanGXYView, doZoomGXYView, drawGhost, getCurrentRectangle, getGhostColor, getGhostLineWidth, getHaloColor, getHaloThickness, getMouseDraggedSensitivity, getXORModelColor, isDragCentered, isForceToSquare, isHaloEnabled, isRepaintOnReleased, isTraceOn, isXORMode, lastXPressed, lastXReleased, lastYPressed, lastYReleased, setDragCentered, setForceToSquare, setGhostColor, setGhostLineWidth, setHaloColor, setHaloEnabled, setHaloThickness, setMouseDraggedSensitivity, setRepaintOnReleased, setTraceOn, setXORMode, setXORModeColor, undo
Methods inherited from class com.luciad.view.gxy.controller.ALcdGXYSmartController
addUndoableListener, fireUndoableEvent, getDownPanChars, getDownPanCodes, getLeftPanChars, getLeftPanCodes, getPanAbsDelta, getPanAbsDelta, getRightPanChars, getRightPanCodes, getUndoableListenerCount, getUpPanChars, getUpPanCodes, getZoomInChars, getZoomInCodes, getZoomOutChars, getZoomOutCodes, isDragging, isPanOnMouseDragExit, isPanOnMouseMoveExit, isPanUndoable, isRequestFocusOnMouseEntered, isRequestFocusOnMousePressed, isZoomUndoable, keyTyped, mouseClicked, mouseEntered, removeUndoableListener, setDownPanChars, setDownPanCodes, setIsDragging, setLeftPanChars, setLeftPanCodes, setPanAbsDelta, setPanOnMouseDragExit, setPanOnMouseMoveExit, setPanUndoable, setRequestFocusOnMouseEntered, setRequestFocusOnMousePressed, setRightPanChars, setRightPanCodes, 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, 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
Methods inherited from interface java.awt.event.MouseListener
mouseClicked, mouseEntered
-
Constructor Details
-
TLcdGXYEditController2
public TLcdGXYEditController2()Constructs a new edit controller, using a defaultTLcdGXYEditControllerModel2
andTLcdGXYSelectControllerModel2
. The controller can be activated usingILcdGXYView.setGXYController(com.luciad.view.gxy.ILcdGXYController)
.
-
-
Method Details
-
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 classTLcdGXYSelectController2
- Parameters:
aGXYView
- 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 classTLcdGXYSelectController2
- Parameters:
aGXYView
- theILcdGXYView
thisILcdGXYController
interacted with.- See Also:
-
getEditControllerModel
Returns the edit controller model.- Returns:
- the edit controller model.
- See Also:
-
setEditControllerModel
Sets the edit controller model. This allows to customize the editing logic, such as the behavior of modifier keys, which objects should be edited, etc. Please refer toTLcdGXYEditControllerModel2
for more information.- Parameters:
aEditControllerModel
- The edit controller model to set.
-
getSnappables
Returns the snappables.- Returns:
- the snappables.
- See Also:
-
setSnappables
Sets the set of objects that are used as candidates-to-snap-to while editing other objects. Set tonull
to disable snapping. Please refer to the developer guide for more information about snapping.- Parameters:
aSnappables
- the list of objects that are candidates to snap to.- See Also:
-
isInstantEditing
public boolean isInstantEditing()This method indicates whether the object being edited is painted in a temporary state and only changed when the mouse is released, or whether the object is instantly edited while the mouse is dragged.- Returns:
- true if this controller instantly edits objects, without painting them in a temporary state, false otherwise.
- See Also:
-
setInstantEditing
public void setInstantEditing(boolean aInstantEditing) The method can be used to activate or deactivate instant editing. When instant editing is enabled objects will be edited whenever the mouse is dragged. When it is disabled, objects will be edited only when the mouse button is released, and will be painted in a temporary state. When enabling instant editing, take into account:- performance may suffer, the view invalidates the layer that is edited, and as a result this layer has to be repainted.
- no snap targets will be visible, snapping will still work but with less feedback.
- when dragging a handle over another handle, it's possible that the second handle is edited instead of the first
- Parameters:
aInstantEditing
- when true instant editing will be enabled, when false disabled.- See Also:
-
getStickyLabelsLayerFilter
This method returns the filter that will determine which layers have sticky labels when hovering over them. These labels will not be moved by a label placer while the mouse hovers over the label. If null is returned sticky labels are disabled for all layers.- Returns:
- the filter that indicates which layers should have sticky labels.
- See Also:
-
setStickyLabelsLayerFilter
Sets the filter that will indicate which layers should have sticky labels when hovering over them. If a layer has sticky labels, they can't be moved by a label placer when the mouse is hovering over them. The default value is null which means no layers will have sticky labels. This setting is especially useful for real time layers.- Parameters:
aStickyLabelsLayerFilter
- the filter that will indicate which layers should have sticky labels- See Also:
-
keyPressed
Handles key pressed events. For more information on behavior, see the class documentation above.- Specified by:
keyPressed
in interfaceKeyListener
- Overrides:
keyPressed
in classALcdGXYSmartController
- Parameters:
aKeyEvent
- The key event describing the change.
-
keyReleased
Handles key released events. For more information on behavior, see the class documentation above.- Specified by:
keyReleased
in interfaceKeyListener
- Overrides:
keyReleased
in classALcdGXYSmartController
- Parameters:
aKeyEvent
- The key event describing the change.
-
mouseMoved
Handles mouse moved events. For more information on behavior, see the class documentation above.- Specified by:
mouseMoved
in interfaceMouseMotionListener
- Overrides:
mouseMoved
in classTLcdGXYDragRectangleController
- Parameters:
me
- The mouse event describing the change.
-
mouseExited
Description copied from class:ALcdGXYSmartController
Will perform a pan depending on the values of isDragging, isPanOnMouseDragExit and isPanOnMouseMoveExit properties- Specified by:
mouseExited
in interfaceMouseListener
- Overrides:
mouseExited
in classALcdGXYSmartController
-
editHowMode
protected int editHowMode(ILcdGXYView aGXYView, ILcdGXYLayerSubsetList aSnappables, Point aFrom, Point aTo, MouseEvent aMouseEvent) Returns the edit-how mode. This mode indicates how the edit should behave: should the editing candidates be translated or reshaped? This method should be overridden if a different behaviour is desired.By default, it returns
TLcdGXYEditControllerModel2.EDIT_HOW_RESHAPING
if ctrl is pressed,TLcdGXYEditControllerModel2.EDIT_HOW_TRANSLATING
if no modifiers are pressed, andTLcdGXYEditControllerModel2.EDIT_HOW_NO_CHANGE
otherwise.Please note that the actual meaning of reshaping and translating is defined by the implementation of
ILcdGXYPainter/ILcdGXYEditor
that is used.- Parameters:
aGXYView
- TheILcdGXYView
, provided as contextual information.aSnappables
- The list of potential snapping candidates, provided as contextual information.aFrom
- The point where the edit originated.aTo
- The point where the edit terminated (so far).aMouseEvent
- The last mouse event that was involved in the edit process.- Returns:
- One of the constants in
TLcdGXYEditControllerModel2
that start withEDIT_HOW
.
-
editWhatMode
protected int editWhatMode(ILcdGXYView aGXYView, ILcdGXYLayerSubsetList aSnappables, Point aFrom, Point aTo, MouseEvent aMouseEvent, int aEditHow) Returns the edit-what mode. This mode indicates what the edit should do: should the labels be edited, or the objects themselves? This method can be overridden if a different behaviour is required. If the left mouse button is used, returnsTLcdGXYEditControllerModel2.EDIT_WHAT_OBJECTS
if the objects are touched for aFrom, andTLcdGXYEditControllerModel2.EDIT_WHAT_LABELS
if the labels are touched for aFrom. If the mouse event is a mouse moved event, the test on the mouse button is skipped. So for that case, it returns what would happen if a button would be pressed. In all other cases,TLcdGXYEditControllerModel2.EDIT_WHAT_NO_CHANGE
is returned.- Parameters:
aGXYView
- TheILcdGXYView
, provided as contextual information.aSnappables
- The list of potential snapping candidates, provided as contextual information.aFrom
- The point where the edit originated.aTo
- The point where the edit terminated (so far).aMouseEvent
- The last mouse event that was involved in the edit process.aEditHow
- The edit-how mode: one of the constants in the classTLcdGXYEditControllerModel2
that start withEDIT_HOW
. For example the result of the methodeditHowMode
.- Returns:
- one of the constants in the class
TLcdGXYEditControllerModel2
that start withEDIT_WHAT
.
-
mousePressed
Handles mouse pressed events. For more information on behavior, see the class documentation above.- Specified by:
mousePressed
in interfaceMouseListener
- Overrides:
mousePressed
in classTLcdGXYSelectController2
- Parameters:
me
- The mouse event describing the change.
-
mouseDragged
Handles mouse dragged events. For more information on behavior, see the class documentation above.- Specified by:
mouseDragged
in interfaceMouseMotionListener
- Overrides:
mouseDragged
in classTLcdGXYSelectController2
- Parameters:
me
- The mouse event describing the change.
-
mouseReleased
Handles mouse released events. For more information on behavior, see the class documentation above.- Specified by:
mouseReleased
in interfaceMouseListener
- Overrides:
mouseReleased
in classTLcdGXYSelectController2
- Parameters:
me
- The mouse event describing the change.
-
repaintGXYView
Repaints the givenILcdGXYView
. Whenever this controller wants theILcdGXYView
to be repainted, this method is invoked.- Parameters:
aGXYView
- TheILcdGXYView
.
-
paint
If an edit is ongoing, this method paints the edited objects in their editing state. If for example the selected objects are being dragged to a new location, this method paints those objects in their translating state (seeILcdGXYPainter.TRANSLATING
). If no edit is ongoing, painting is delegated to the super class.- Specified by:
paint
in interfaceILcdGXYController
- Overrides:
paint
in classTLcdGXYSelectController2
- Parameters:
aGraphics
- The graphics to draw on.
-
setCursor
This cursor is only used when there is no specific cursor provided by the controller model.- Overrides:
setCursor
in classALcdGXYController
- Parameters:
aCursor
- The cursor to use when no specific cursor is available.
-