A controller allows interaction with a view. It translates the low-level user interactions into higher-level operations on
ILcdGXYLayer objects, and so on. The following sections describe how to use and customize the main implementations of
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-key is pressed during the drag, the single object that is touched
by the mouse pointer is reshaped. Note that the meaning of translating and reshaping is defined by the implementations of
ILcdGXYPainter instances and
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
ILcdGXYLabelPainter2 (not just
ILcdGXYLabelPainter) are available from the layer.
You can customize all editing-related logic by setting a custom
TLcdGXYEditControllerModel2 using the method
setEditControllerModel. For example, to change the behavior of modifier keys, disable editing of labels, influence which objects should be edited,
and so on. The controller model for the edit controller has a similar structure as the
TLcdGXYSelectControllerModel2. Refer to the API reference of
TLcdGXYEditControllerModel2 for more information.
TLcdGXYNewController2 allows a user to graphically create objects on an
ILcdGXYView using the
mouse. The controller needs a controller model extending from
ALcdGXYNewControllerModel2 to translate
mouse events to the steps necessary for creating and initializing a new object. The default controller
model uses the object’s target layer’s
ILcdGXYEditor, which already
offer most of the functionality for creating new objects and visualizing the creation. To instantiate the
ALcdGXYNewControllerModel2, you only need to implement two more methods:
getGXYLayerto retrieve a relevant
ILcdGXYLayerto insert the object into. By default, the controller model delegates painting and editing steps to the layer’s
ILcdGXYEditor, and commits the object to the layer when the object is successfully initialized.
createto create a new object ready to be initialized by the mouse.
You can further customize the creation process in the following two ways:
customize the key actions involved in the creation process:
edit: to perform a mouse-based initialization step
cancel: to cancel the creation process
revert: to go back a step in the creation process
paint: to paint the creation in progress
commit: to insert the object into the target layer
customize the translation of mouse events into the above actions
Refer to the API reference of
ALcdGXYNewControllerModel2 for more information on customizing the creation process. Creating a shape with TLcdGXYNewController2 explains the implementation of a controller model to create a hippodrome shape. It includes a diagram showing the interaction
between the controller and the controller model.