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 ILcdGXYPainters
and ILcdGXYEditors.
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
ConstructorsConstructorDescriptionConstructs a new edit controller, using a defaultTLcdGXYEditControllerModel2andTLcdGXYSelectControllerModel2. -
Method Summary
Modifier and TypeMethodDescriptionprotected inteditHowMode(ILcdGXYView aGXYView, ILcdGXYLayerSubsetList aSnappables, Point aFrom, Point aTo, MouseEvent aMouseEvent) Returns the edit-how mode.protected inteditWhatMode(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.booleanThis 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.voidkeyPressed(KeyEvent aKeyEvent) Handles key pressed events.voidkeyReleased(KeyEvent aKeyEvent) Handles key released events.voidHandles mouse dragged events.voidWill perform a pan depending on the values of isDragging, isPanOnMouseDragExit and isPanOnMouseMoveExit propertiesvoidmouseMoved(MouseEvent me) Handles mouse moved events.voidHandles mouse pressed events.voidHandles mouse released events.voidIf an edit is ongoing, this method paints the edited objects in their editing state.protected voidrepaintGXYView(ILcdGXYView aGXYView) Repaints the givenILcdGXYView.voidThis cursor is only used when there is no specific cursor provided by the controller model.voidsetEditControllerModel(TLcdGXYEditControllerModel2 aEditControllerModel) Sets the edit controller model.voidsetInstantEditing(boolean aInstantEditing) The method can be used to activate or deactivate instant editing.voidsetSnappables(ILcdGXYLayerSubsetList aSnappables) Sets the set of objects that are used as candidates-to-snap-to while editing other objects.voidsetStickyLabelsLayerFilter(ILcdFilter aStickyLabelsLayerFilter) Sets the filter that will indicate which layers should have sticky labels when hovering over them.voidstartInteraction(ILcdGXYView aGXYView) Sets up the controller to receive input through the view passed.voidterminateInteraction(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, triggerMethods 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, undoMethods 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, updateViewLocationAfterZoomSFCTMethods 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, viewRepaintMethods 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
getCursor, getIcon, getLayered, getName, getShortDescription, viewRepaintMethods inherited from interface java.awt.event.MouseListener
mouseClicked, mouseEntered
-
Constructor Details
-
TLcdGXYEditController2
public TLcdGXYEditController2()Constructs a new edit controller, using a defaultTLcdGXYEditControllerModel2andTLcdGXYSelectControllerModel2. The controller can be activated usingILcdGXYView.setGXYController(com.luciad.view.gxy.ILcdGXYController).
-
-
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 classTLcdGXYSelectController2- 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 classTLcdGXYSelectController2- Parameters:
aGXYView- theILcdGXYViewthisILcdGXYControllerinteracted 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 toTLcdGXYEditControllerModel2for 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 tonullto 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:
keyPressedin interfaceKeyListener- Overrides:
keyPressedin 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:
keyReleasedin interfaceKeyListener- Overrides:
keyReleasedin 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:
mouseMovedin interfaceMouseMotionListener- Overrides:
mouseMovedin classTLcdGXYDragRectangleController- Parameters:
me- The mouse event describing the change.
-
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
-
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_RESHAPINGif ctrl is pressed,TLcdGXYEditControllerModel2.EDIT_HOW_TRANSLATINGif no modifiers are pressed, andTLcdGXYEditControllerModel2.EDIT_HOW_NO_CHANGEotherwise.Please note that the actual meaning of reshaping and translating is defined by the implementation of
ILcdGXYPainter/ILcdGXYEditorthat 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
TLcdGXYEditControllerModel2that 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_OBJECTSif the objects are touched for aFrom, andTLcdGXYEditControllerModel2.EDIT_WHAT_LABELSif 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_CHANGEis 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 classTLcdGXYEditControllerModel2that start withEDIT_HOW. For example the result of the methodeditHowMode.- Returns:
- one of the constants in the class
TLcdGXYEditControllerModel2that start withEDIT_WHAT.
-
mousePressed
Handles mouse pressed events. For more information on behavior, see the class documentation above.- Specified by:
mousePressedin interfaceMouseListener- Overrides:
mousePressedin 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:
mouseDraggedin interfaceMouseMotionListener- Overrides:
mouseDraggedin 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:
mouseReleasedin interfaceMouseListener- Overrides:
mouseReleasedin classTLcdGXYSelectController2- Parameters:
me- The mouse event describing the change.
-
repaintGXYView
Repaints the givenILcdGXYView. Whenever this controller wants theILcdGXYViewto 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:
paintin interfaceILcdGXYController- Overrides:
paintin 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:
setCursorin classALcdGXYController- Parameters:
aCursor- The cursor to use when no specific cursor is available.
-