public class TLcdGXYNewController2 extends ALcdGXYSmartController implements ILcdGXYChainableController
create
;
edit steps
;
comitting
of the domain object to a model.
ALcdGXYNewControllerModel2 controllerModel = new ALcdGXYNewControllerModel2() {
public ILcdGXYLayer getGXYLayer(Graphics aGraphics, MouseEvent aMouseEvent, ILcdGXYLayerSubsetList aSnappables, ILcdGXYContext aContext) {
return myLayer;
}
public Object create(int aEditCount, Graphics aGraphics, MouseEvent aMouseEvent, ILcdGXYLayerSubsetList aSnappables, ILcdGXYContext aContext) {
return new MyDomainObject();
}
};
TLcdGXYNewController2 controller = new TLcdGXYNewController2(controllerModel);
view.setGXYController(controller);
This controller supports snapping if snapping candidates are configured
.
canUndo()
and canRedo()
can be used to check
whether an undo or redo operation is possible at any given time during the creation process. The
methods doUndo()
and doRedo()
will respectively undo the last creation
interaction or redo the last action that was undone.
After creation has finished (the object is committed), all registered ILcdUndoableListeners
are notified with an undoable that will remove the object from the layer.shouldCommit
, shouldEdit
,
and shouldUndo
can be overridden to map mouse events to specific
editing behaviour.canUndo()
,
canRedo()
, canCommit()
and canCancel()
indicate whether or not an undo,
redo, commit or cancel action are possible at the moment. The methods doUndo()
,
doRedo()
, doCommit()
and doCancel()
will execute the actions when possible.
See ALcdGXYNewControllerModel2
for a more detailed explanation of the interaction with the controller model.
ALcdGXYNewControllerModel2
,
Serialized FormConstructor and Description |
---|
TLcdGXYNewController2()
Constructs a controller to create and initialize new objects via mouse interaction.
|
TLcdGXYNewController2(ALcdGXYNewControllerModel2 aControllerModel)
Constructs a controller to create and initialize new objects via mouse interaction.
|
Modifier and Type | Method and Description |
---|---|
void |
appendGXYController(ILcdGXYChainableController aEnd)
This method will append the passed controller to the end of the chain.
|
boolean |
canCancel()
This method indicates whether or not it's possible to cancel the creation of the current
object.
|
boolean |
canCommit()
This method indicates whether are not an object is ready to be committed.
|
boolean |
canRedo()
This method indicates whether or not an creation step can be redone.
|
boolean |
canUndo()
This method indicates whether or not an creation step can be undone.
|
void |
doCancel()
If
canCancel() returns true, this method will cancel the creation of the current
object. |
void |
doCommit()
If
canCommit() returns true, this method will commit the object currently under
creation, and trigger the action to trigger after commit if it's available. |
void |
doRedo()
When
canRedo() returns true, this method will redo the last creation step that was
undone. |
void |
doUndo()
When
canUndo() returns true, this method will undo the last creation step. |
ILcdAction |
getActionToTriggerAfterCommit()
Returns the
ILcdAction that will be will be triggered just after this ILcdGXYController
has created a new Object , initialized it and committed it to an ILcdModel . |
ILcdGXYLayer |
getGXYLayer()
Returns the layer for which the controller is creating.
|
ALcdGXYNewControllerModel2 |
getNewControllerModel()
Returns the
ILcdGXYNewControllerModel this TLcdGXYNewController delegates to. |
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.
|
Object |
getObject()
Returns the object that the controller is creating.
|
int |
getSensitivity()
This method returns the sensitivity that will be used for snapping.
|
ILcdGXYLayerSubsetList |
getSnappables()
Returns the Objects to snap to when initializing a new created Object,
or
null when snapping is disabled. |
void |
handleAWTEvent(AWTEvent aEvent)
This is method is called when the target of the listener has a new AWTEvent available.
|
void |
mouseDragged(MouseEvent aMouseEvent) |
void |
mouseExited(MouseEvent aMouseEvent)
Only pans the view when an object is actively being created.
|
void |
mouseMoved(MouseEvent aMouseEvent) |
void |
mousePressed(MouseEvent aMouseEvent) |
void |
mouseReleased(MouseEvent aMouseEvent) |
void |
paint(Graphics aGraphics)
Enables the controller to give visual feedback on the current user interactions.
|
void |
setActionToTriggerAfterCommit(ILcdAction aNewActionToTriggerAfterCommit)
Sets the
ILcdAction that will be triggered just after this ILcdGXYController has created
a new Object and committed it to an ILcdModel . |
void |
setCursor(Cursor aCursor)
This cursor is only used when there is no
specific cursor
provided by the controller model.
|
void |
setNewControllerModel(ALcdGXYNewControllerModel2 aControllerModel)
Sets the
ILcdGXYNewControllerModel to delegate to. |
void |
setNextGXYController(ILcdGXYChainableController aNext)
This method sets the next controller in the chain for this controller.
|
void |
setSensitivity(int aSensitivity)
This method sets the sensitivity that should be used by painters/editors for snapping purposes.
|
void |
setSnappables(ILcdGXYLayerSubsetList aSnappables)
Sets the Objects to snap to when initializing a new created Object.
|
protected boolean |
shouldCommit(Object aObject,
int aEditCount,
Graphics aGraphics,
MouseEvent aMouseEvent,
ILcdGXYLayerSubsetList aSnappables,
ILcdGXYContext aContext)
Returns whether the mouse event should trigger a commit of the object, given the context parameters.
|
protected boolean |
shouldEdit(Object aObject,
int aEditCount,
Graphics aGraphics,
MouseEvent aMouseEvent,
ILcdGXYLayerSubsetList aSnappables,
ILcdGXYContext aContext)
Returns whether the mouse event should trigger an edit of the object, given the context parameters.
|
protected boolean |
shouldUndo(Object aObject,
int aEditCount,
Graphics aGraphics,
MouseEvent aMouseEvent,
ILcdGXYLayerSubsetList aSnappables,
ILcdGXYContext aContext)
Returns whether the mouse event should undo the last edit operation, given the context parameters.
|
void |
startInteraction(ILcdGXYView aGXYView)
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, mouseClicked, mouseEntered, 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, setGXYView, setIcon, setName, setShortDescription, viewRepaint
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getCursor, getIcon, getLayered, getName, getShortDescription, viewRepaint
public TLcdGXYNewController2()
public TLcdGXYNewController2(ALcdGXYNewControllerModel2 aControllerModel)
aControllerModel
- the model that defines what type of object will be created and how they are edited and added to the view.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 ALcdGXYSmartController
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 ALcdGXYSmartController
aGXYView
- the ILcdGXYView
this ILcdGXYController
interacted with.ILcdGXYView.setGXYController(com.luciad.view.gxy.ILcdGXYController)
,
ILcdGXYController.startInteraction(com.luciad.view.gxy.ILcdGXYView)
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.public void setCursor(Cursor aCursor)
setCursor
in class ALcdGXYController
aCursor
- The cursor to use when no specific cursor is available.public boolean canCommit()
ALcdGXYNewControllerModel2.getCreationStatus(java.lang.Object, int, java.awt.Graphics, java.awt.event.MouseEvent, com.luciad.view.gxy.ILcdGXYLayerSubsetList, com.luciad.view.gxy.ILcdGXYContext)
)
is equal to ALcdGXYNewControllerModel2.CreationStatus.COMMITTABLE
.public void doCommit()
canCommit()
returns true, this method will commit the object currently under
creation, and trigger the action to trigger after commit if it's available.public boolean canCancel()
public void doCancel()
canCancel()
returns true, this method will cancel the creation of the current
object.canCancel()
public boolean canUndo()
public void doUndo()
canUndo()
returns true, this method will undo the last creation step.public boolean canRedo()
public void doRedo()
canRedo()
returns true, this method will redo the last creation step that was
undone.public void mousePressed(MouseEvent aMouseEvent)
mousePressed
in interface MouseListener
mousePressed
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 mouseReleased(MouseEvent aMouseEvent)
mouseReleased
in interface MouseListener
mouseReleased
in class ALcdGXYSmartController
public void mouseExited(MouseEvent aMouseEvent)
mouseExited
in interface MouseListener
mouseExited
in class ALcdGXYSmartController
aMouseEvent
- the mouse event indicating that the mouse has left the view.ALcdGXYSmartController.isPanOnMouseDragExit()
,
ALcdGXYSmartController.isPanOnMouseMoveExit()
public void setNewControllerModel(ALcdGXYNewControllerModel2 aControllerModel)
ILcdGXYNewControllerModel
to delegate to.aControllerModel
- the ILcdGXYNewControllerModel
to delegate to.getNewControllerModel()
public ALcdGXYNewControllerModel2 getNewControllerModel()
ILcdGXYNewControllerModel
this TLcdGXYNewController
delegates to.ILcdGXYNewControllerModel
this TLcdGXYNewController
delegates to.setNewControllerModel(com.luciad.view.gxy.controller.ALcdGXYNewControllerModel2)
public void setActionToTriggerAfterCommit(ILcdAction aNewActionToTriggerAfterCommit)
ILcdAction
that will be triggered just after this ILcdGXYController
has created
a new Object
and committed it to an ILcdModel
. It might be interesting for example to set an
ILcdGXYController
( using a TLcdGXYSetControllerAction
) that can edit the new
Object
, just after this one has been created and initialized. When no action is set, the new
controller model will be requested for an object and a layer when creation has been finished or has been canceled.aNewActionToTriggerAfterCommit
- the ILcdAction
to be triggered or null
if no ILcdAction
has to be
triggered.TLcdGXYSetControllerAction
,
getActionToTriggerAfterCommit()
public ILcdAction getActionToTriggerAfterCommit()
ILcdAction
that will be will be triggered just after this ILcdGXYController
has created a new Object
, initialized it and committed it to an ILcdModel
.ILcdAction
to be triggered after creation of a new Object.setActionToTriggerAfterCommit(com.luciad.gui.ILcdAction)
public void setSnappables(ILcdGXYLayerSubsetList aSnappables)
null
, snapping is disabled.aSnappables
- the new value for the snappables property, or null
to disable snappinggetSnappables()
public ILcdGXYLayerSubsetList getSnappables()
null
when snapping is disabled.null
when snapping is disabledsetSnappables(com.luciad.view.gxy.ILcdGXYLayerSubsetList)
public Object getObject()
ALcdGXYNewControllerModel2.edit(java.lang.Object, int, java.awt.Graphics, java.awt.event.MouseEvent, com.luciad.view.gxy.ILcdGXYLayerSubsetList, com.luciad.view.gxy.ILcdGXYContext)
.public ILcdGXYLayer getGXYLayer()
ALcdGXYNewControllerModel2.create(int, java.awt.Graphics, java.awt.event.MouseEvent, com.luciad.view.gxy.ILcdGXYLayerSubsetList, com.luciad.view.gxy.ILcdGXYContext)
.public int getSensitivity()
TLcdGXYContext
passed to the painters/editors.setSensitivity(int)
,
TLcdGXYContext.getSensitivity()
public void setSensitivity(int aSensitivity)
aSensitivity
- the sensitivity that will be used for snapping.getSensitivity()
protected boolean shouldEdit(Object aObject, int aEditCount, Graphics aGraphics, MouseEvent aMouseEvent, ILcdGXYLayerSubsetList aSnappables, ILcdGXYContext aContext)
ALcdGXYNewControllerModel2.shouldEdit(java.lang.Object, int, java.awt.Graphics, java.awt.event.MouseEvent, com.luciad.view.gxy.ILcdGXYLayerSubsetList, com.luciad.view.gxy.ILcdGXYContext)
method.aObject
- the object that may be editedaEditCount
- the number of previous edit operationsaGraphics
- the graphics onto which the object is paintedaMouseEvent
- the mouse event that is eligible for causing an edit operationaSnappables
- the list of potential snap targetsaContext
- the GXY context informationprotected boolean shouldUndo(Object aObject, int aEditCount, Graphics aGraphics, MouseEvent aMouseEvent, ILcdGXYLayerSubsetList aSnappables, ILcdGXYContext aContext)
aObject
- the object that may be revertedaEditCount
- the number of previous edit operationsaGraphics
- the graphics onto which the object is paintedaMouseEvent
- the mouse event that is eligible for causing a revert operationaSnappables
- the list of potential snap targetsaContext
- the GXY context informationprotected boolean shouldCommit(Object aObject, int aEditCount, Graphics aGraphics, MouseEvent aMouseEvent, ILcdGXYLayerSubsetList aSnappables, ILcdGXYContext aContext)
ALcdGXYNewControllerModel2.shouldCommit(java.lang.Object, int, java.awt.Graphics, java.awt.event.MouseEvent, com.luciad.view.gxy.ILcdGXYLayerSubsetList, com.luciad.view.gxy.ILcdGXYContext)
method.aObject
- the object that may be committedaEditCount
- the number of previous edit operationsaGraphics
- the graphics onto which the object is paintedaMouseEvent
- the mouse event that is eligible for causing a commit operationaSnappables
- the list of potential snap targetsaContext
- the GXY context informationpublic 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.