public class TLcdGXYEditController2 extends TLcdGXYSelectController2
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.fXPressed, fXReleased, fYPressed, fYReleased
Constructor and Description |
---|
TLcdGXYEditController2()
Constructs a new edit controller, using a default
TLcdGXYEditControllerModel2 and TLcdGXYSelectControllerModel2 . |
Modifier and Type | Method and Description |
---|---|
protected 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.
|
TLcdGXYEditControllerModel2 |
getEditControllerModel()
Returns the edit controller model.
|
ILcdGXYLayerSubsetList |
getSnappables()
Returns the snappables.
|
ILcdFilter |
getStickyLabelsLayerFilter()
This method returns the filter that will determine which layers have sticky labels when
hovering over them.
|
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.
|
void |
keyPressed(KeyEvent aKeyEvent)
Handles key pressed events.
|
void |
keyReleased(KeyEvent aKeyEvent)
Handles key released events.
|
void |
mouseDragged(MouseEvent me)
Handles mouse dragged events.
|
void |
mouseExited(MouseEvent me)
Will perform a pan depending on the values of isDragging,
isPanOnMouseDragExit and isPanOnMouseMoveExit properties
|
void |
mouseMoved(MouseEvent me)
Handles mouse moved events.
|
void |
mousePressed(MouseEvent me)
Handles mouse pressed events.
|
void |
mouseReleased(MouseEvent me)
Handles mouse released events.
|
void |
paint(Graphics aGraphics)
If an edit is ongoing, this method paints the edited objects in their
editing state.
|
protected void |
repaintGXYView(ILcdGXYView aGXYView)
Repaints the given
ILcdGXYView . |
void |
setCursor(Cursor aCursor)
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.
|
appendGXYController, getAWTFilter, getDoubleClickAction, getMultiSelectModifierKey, getNextGXYController, getRightClickAction, getSelectControllerModel, handleAWTEvent, selectByWhatMode, selectHowMode, setAWTFilter, setDoubleClickAction, setMultiSelectModifierKey, setNextGXYController, setRightClickAction, setSelectControllerModel, trigger
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
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
addStatusListener, asGXYController, fireStatusEvent, getCursor, getGXYView, getIcon, getName, getShortDescription, registerInstance, removeStatusListener, retrieveGXYViewXYWorldTransformation, setClassTraceOn, setGXYView, setIcon, setName, setShortDescription, viewRepaint
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
mouseClicked, mouseEntered
getCursor, getIcon, getLayered, getName, getShortDescription, viewRepaint
public TLcdGXYEditController2()
TLcdGXYEditControllerModel2
and TLcdGXYSelectControllerModel2
.
The controller can be activated using ILcdGXYView.setGXYController(com.luciad.view.gxy.ILcdGXYController)
.public void startInteraction(ILcdGXYView aGXYView)
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 TLcdGXYSelectController2
aGXYView
- 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 TLcdGXYSelectController2
aGXYView
- the ILcdGXYView
this ILcdGXYController
interacted with.ILcdGXYView.setGXYController(com.luciad.view.gxy.ILcdGXYController)
,
ILcdGXYController.startInteraction(com.luciad.view.gxy.ILcdGXYView)
public TLcdGXYEditControllerModel2 getEditControllerModel()
setEditControllerModel(TLcdGXYEditControllerModel2)
public void setEditControllerModel(TLcdGXYEditControllerModel2 aEditControllerModel)
TLcdGXYEditControllerModel2
for more information.aEditControllerModel
- The edit controller model to set.public ILcdGXYLayerSubsetList getSnappables()
setSnappables(com.luciad.view.gxy.ILcdGXYLayerSubsetList)
public void setSnappables(ILcdGXYLayerSubsetList aSnappables)
null
to disable snapping.
Please refer to the developer guide for more information about snapping.aSnappables
- the list of objects that are candidates to snap to.getSnappables()
public boolean isInstantEditing()
setInstantEditing(boolean)
public void setInstantEditing(boolean aInstantEditing)
aInstantEditing
- when true instant editing will be enabled, when false disabled.isInstantEditing()
public ILcdFilter getStickyLabelsLayerFilter()
setStickyLabelsLayerFilter(com.luciad.util.ILcdFilter)
public void setStickyLabelsLayerFilter(ILcdFilter aStickyLabelsLayerFilter)
aStickyLabelsLayerFilter
- the filter that will indicate which layers should have sticky labelsgetStickyLabelsLayerFilter()
public void keyPressed(KeyEvent aKeyEvent)
keyPressed
in interface KeyListener
keyPressed
in class ALcdGXYSmartController
aKeyEvent
- The key event describing the change.public void keyReleased(KeyEvent aKeyEvent)
keyReleased
in interface KeyListener
keyReleased
in class ALcdGXYSmartController
aKeyEvent
- The key event describing the change.public void mouseMoved(MouseEvent me)
mouseMoved
in interface MouseMotionListener
mouseMoved
in class TLcdGXYDragRectangleController
me
- The mouse event describing the change.public void mouseExited(MouseEvent me)
ALcdGXYSmartController
mouseExited
in interface MouseListener
mouseExited
in class ALcdGXYSmartController
protected int editHowMode(ILcdGXYView aGXYView, ILcdGXYLayerSubsetList aSnappables, Point aFrom, Point aTo, MouseEvent aMouseEvent)
By default, it returns TLcdGXYEditControllerModel2.EDIT_HOW_RESHAPING
if ctrl is pressed,
TLcdGXYEditControllerModel2.EDIT_HOW_TRANSLATING
if no modifiers are pressed, and
TLcdGXYEditControllerModel2.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.
aGXYView
- The ILcdGXYView
, 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.TLcdGXYEditControllerModel2
that start with EDIT_HOW
.protected int editWhatMode(ILcdGXYView aGXYView, ILcdGXYLayerSubsetList aSnappables, Point aFrom, Point aTo, MouseEvent aMouseEvent, int aEditHow)
TLcdGXYEditControllerModel2.EDIT_WHAT_OBJECTS
if
the objects are touched for aFrom, and TLcdGXYEditControllerModel2.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.aGXYView
- The ILcdGXYView
, 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 class TLcdGXYEditControllerModel2
that start with EDIT_HOW
. For example the result of the
method editHowMode
.TLcdGXYEditControllerModel2
that start with EDIT_WHAT
.public void mousePressed(MouseEvent me)
mousePressed
in interface MouseListener
mousePressed
in class TLcdGXYSelectController2
me
- The mouse event describing the change.public void mouseDragged(MouseEvent me)
mouseDragged
in interface MouseMotionListener
mouseDragged
in class TLcdGXYSelectController2
me
- The mouse event describing the change.public void mouseReleased(MouseEvent me)
mouseReleased
in interface MouseListener
mouseReleased
in class TLcdGXYSelectController2
me
- The mouse event describing the change.protected void repaintGXYView(ILcdGXYView aGXYView)
ILcdGXYView
. Whenever this controller wants
the ILcdGXYView
to be repainted, this method is invoked.aGXYView
- The ILcdGXYView
.public void paint(Graphics aGraphics)
ILcdGXYPainter.TRANSLATING
).
If no edit is ongoing, painting is delegated to the super class.paint
in interface ILcdGXYController
paint
in class TLcdGXYSelectController2
aGraphics
- The graphics to draw on.public void setCursor(Cursor aCursor)
setCursor
in class ALcdGXYController
aCursor
- The cursor to use when no specific cursor is available.