public interface ILcdGXYLayer extends ILcdLayer
ILcdGXYViewof all objects in an
ILcdModel. Representing means how it is visualized, but also how it behaves during graphical editing, or how its labels should appear. Layers are often instantiated using a factory.
In order to provide a representation for an object, the layer needs to know how basic rendering operations
are performed, using a
pen, and how the object is transformed to its world
representation, using a
model to world transformation class.
ILcdGXYLayer distinguishes between two representations for an object:
a geometry and a textual representation, called a label.
Rendering the geometry is handled by a
painter per object,
whereas rendering the object as text, is handled by a
If no painter nor label painter is available for an object, it won't get a representation.
A layer will often not display all objects, as it is possible that the representations of some
objects lie outside the bounds of the view.
In addition, the layer can decide not to display geometry and/or labels at a certain zoom level
scaleRange) or as text (
Implementations are free to add other means to restrict and/or filter (e.g. interactively determined
by the user) the visible objects.
Since interaction via the view is only possible with objects which are visible in the view, the method
enables applying an arbitrary function to objects based on whether their representation is inside a given
bounds or not. This method enables the reduction of the number of objects to which a function should be applied, as
it is not applied to any objects whose representation would fall outside the bounds.
Note that the
ILcdGXYEditableLabelsLayer interface defines additional methods that closer
correspond to the paint method by taking into account painting criteria such as the scale range
and layer visibility .
To quickly check whether any interaction is possible with a layer, the layer provides its
bounds in a view, which contain the representations in that
view of all objects on the layer.
Outside the layer's bounds, no interaction with any of the layer's objects is possible.
For every object in the layer's model, an
ILcdGXYEditor can be provided to handle interactions with
the object (modifying the geometry of an object, for example). The handles of the geometry indicate where such
interactions can take place.
Note: This interface has been extended in the
ILcdGXYEditableLabelsLayer interface. If you implement your own layer, it is advised to
implement that interface in addition to this one.
|Modifier and Type||Field and Description|
Paint mode to indicate that all objects in the model should be taken into account.
Paint mode to indicate that the body of the geometry of the objects should be painted.
Paint mode to indicate that the handles of the geometry of the objects should be painted.
Paint mode to indicate that the objects should be painted as text.
Paint mode to indicate that only objects in the selection should be taken into account.
|Modifier and Type||Method and Description|
Applies the function to (at the least) all objects that are contained (partially or completely) in the bounds of the view.
Returns the view bounds of this
Returns the editor to use to modify the object via a view.
Returns the label painter to use to paint the objects label in a view.
Returns the painter to use to render the object in a view.
Returns the pen to use when performing basic painting operations for objects in this layers model.
Returns the scale range outside of which no labels for elements of the model are painted.
Returns the transformation class that to use to transform points and bounds from model space to world space and back.
Returns the scale range outside of which no elements of the model are painted.
Returns whether objects should be represented as text.
Returns whether this layer supports representing objects as text.
Paints the combined representation of the layer's objects for a view, taking into account the mode.
Sets whether objects should be represented as text.
Inform the layer that it should terminate the current paint operation.
clearSelection, fireCollectedSelectionChanges, getIcon, getLabel, getModel, isEditable, isEditableSupported, isSelectable, isSelectableSupported, isVisible, selectObject, setEditable, setIcon, setLabel, setSelectable, setVisible
addSelectionListener, getSelectedObjects, getSelectionCount, isSelected, removeSelectionListener, selectedObjects
static final int ALL
static final int SELECTION
static final int BODIES
static final int HANDLES
static final int LABELS
void paint(java.awt.Graphics aGraphics, int aMode, ILcdGXYView aGXYView)
The mode indicates what objects of the model should be taken into account and what representation should be provided. The objects to be taken into account shall be one of:
Note that the combined representation may contain less than the representation of all objects that were taken into account, as some objects may be disregarded for various reasons (filters, scale, ... ). When the views scale is outside the scale range (BODIES or HANDLES mode) or the label scale range (LABELS mode) nothing shall be painted.
The representations provided shall be one or more of:
The mode supplied shall be a bitwise or combination of a constant of the first group and one or more of the
second group. When painting in BODIES or HANDLES mode, painting of an object shall be delegated to the
painter for that object, when the LABELS mode is passed, painting shall be delegated
labelpainter for that object.
The view is passed to provide contextual information: some of the objects may have a different representation depending on the view, or depending on a property of the view, for example, the scale of the view.
The combined representation of the objects has to be painted on the Graphics supplied, as these may be different from the Graphics provided by the view (due to double buffering, for example).
stopPainting is called, the current painting operation should be aborted.
int applyOnInteract(ILcdFunction aFunction, java.awt.Rectangle aBounds, boolean aStrictInteract, ILcdGXYView aGXYView)
The function shall be applied successively to all objects in the bounds as long as the function returns
true for an object. This allows developers to indicate a stop condition. Note that the order in
which the objects are passed to the function is not specified.
When strict interaction is required, only objects whose representation lies within the given bounds, completely or partially, are candidates to be passed to the function. An object whose representation does not interact with the bounds should not be passed to the function. Applying non strict interaction can be useful to avoid heavy computations to determine whether an objects representation lies within the bounds.
This method behaves similar to the paint method, and as such is allowed to omit small or invisible objects for performance reasons.
aFunction- the function to apply. When the function returns false, no more objects should be passed to the function.
aBounds- all objects who lie partially or completely in this area in the view are candidates to be passed to the function.
ILcdFunctionshall be applied only to the objects interacting with the given bounds. When false is passed, other objects may be taken into account too. When applying the function to an object consumes less time than checking whether an objects representation interacts with the bounds, non-strict interaction is generally faster.
aGXYView- the view in whose bounds the objects representations should be in order to be passed to the function.
ILcdBounds getBounds(int aMode, ILcdGXYView aGXYView) throws TLcdNoBoundsException
ILcdGXYLayercontent, the bounds of all the drawings (for the supplied mode) that represent the Objects contained in the
ILcdGXYLayer. For this operation, this
ILcdGXYLayeris to be considered as part of
Outside of the layers bounds no interaction with any object of the layer via its representation is possible. Note that these bounds do not necessarily encompass the representation of all objects in the model, only the objects for which there is a representation in the view.
aMode- a bitwise combination of ALL or SELECTION and one or more of BODIES and HANDLES. The
ILcdGXYLayer.LABELSmode is not supported.
aGXYView- the view in which the layer could be placed. This enables taking into account the views settings, for example the scale.
TLcdNoBoundsException- if the layer doesn't have any valid bounds, for example when none of the elements have a representation for the views current settings.
java.lang.IllegalArgumentException- if the mode contains
Threadand needs to be stopped in a safe state from another Thread.
More strictly, the paint method should not render any objects in a view when:
This does not imply that all objects in the model should be painted when the scale is inside this range as other restrictions may apply. For example, a layer may have a filter which defines which objects should be painted.
ILcdIntervalcontaining the minimum and maximum value of view scales for which objects should be rendered, excluding the maximum.
More strictly, the paint method should not render any labels for objects in a view when:
This does not imply that labels for all objects in the model should be painted when the scale is inside this range as other restrictions may apply. For example, a layer may decide not to paint any labels for objects whose body is not painted.
ILcdIntervalcontaining the minimum and maximum value of view scales for which objects labels should be rendered, excluding the maximum.
ILcdGXYPainter getGXYPainter(java.lang.Object aObject)
aObject- the object to find a painter for.
ILcdGXYEditor getGXYEditor(java.lang.Object aObject)
aObject- the object to find an editor for.
ILcdGXYLabelPainter getGXYLabelPainter(java.lang.Object aObject)
aObject- the object to find a label painter for.
void setLabeled(boolean aLabeled)
aLabeled- true to have a textual representation of the objects in the model, false to have no such representation.