public interface ILcdGXYLayer extends ILcdLayer
ILcdGXYView
of 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.
pen
, and how the object is transformed to its world
representation, using a model to world transformation class
.
Next, a layer distinguishes between two representations for an object:
a geometry
and a (typically textual) label
representation.
Rendering the geometry is handled by a painter
per object,
whereas rendering the label is handled by a label painter
per object.
If no painter nor label painter is available for an object, it won't get a representation.
Layers that support selection also have an appropriate
selection representation modifier
.
Finally, editable layers can display handles to interact with the domain objects.
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
(see scaleRange
) or as text (labelScaleRange
).
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
applyOnInteract
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.
ILcdGXYView
,
ILcdGXYEditableLabelsLayer
Modifier and Type | Field and Description |
---|---|
static int |
ALL
Paint mode to indicate that all objects in the model should be taken into account.
|
static int |
BODIES
Paint mode to indicate that the body of the geometry of the objects should be painted.
|
static int |
HANDLES
Paint mode to indicate that the handles of the geometry of the objects should be painted.
|
static int |
LABELS
Paint mode to indicate that the objects should be painted as text.
|
static int |
SELECTION
Paint mode to indicate that only objects in the selection should be taken into account.
|
Modifier and Type | Method and Description |
---|---|
int |
applyOnInteract(ILcdFunction aFunction,
Rectangle aBounds,
boolean aStrictInteract,
ILcdGXYView aGXYView)
Applies the function to (at the least) all objects that are contained (partially or completely) in the bounds of the view.
|
ILcdBounds |
getBounds(int aMode,
ILcdGXYView aGXYView)
Returns the view bounds of this
ILcdGXYLayer content,
the bounds of all the drawings (for the supplied mode) that represent the Objects contained in
the ILcdModel of this ILcdGXYLayer . |
ILcdGXYEditor |
getGXYEditor(Object aObject)
Returns the editor to use to modify the object via a view.
|
ILcdGXYLabelPainter |
getGXYLabelPainter(Object aObject)
Returns the label painter to use to paint the objects label in a view.
|
ILcdGXYPainter |
getGXYPainter(Object aObject)
Returns the painter to use to render the object in a view.
|
ILcdGXYPen |
getGXYPen()
Returns the pen to use when performing basic painting operations for objects in this layers model.
|
default TLcdDimensionInterval<TLcdMapScale> |
getLabelMapScaleRange()
Returns the map ratio scale range for which to display labels for elements of the model.
|
ILcdInterval |
getLabelScaleRange()
Returns the toolkit scale range for which to display labels for elements of the model.
|
default TLcdDimensionInterval<TLcdMapScale> |
getMapScaleRange()
Returns the map ratio scale range for which to display elements of the model.
|
Class |
getModelXYWorldTransfoClass()
Returns the transformation class that to use to transform points and bounds from model space to world space and
back.
|
ILcdInterval |
getScaleRange()
Returns the toolkit scale range for which to display elements of the model.
|
boolean |
isLabeled()
Returns whether objects should be represented as text.
|
boolean |
isLabeledSupported()
Returns whether this layer supports representing objects as text.
|
void |
paint(Graphics aGraphics,
int aMode,
ILcdGXYView aGXYView)
Paints the combined representation of the layer's objects for a view, taking into account the mode.
|
void |
setLabeled(boolean aLabeled)
Sets whether objects should be represented as text.
|
void |
stopPainting()
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
addPropertyChangeListener, removePropertyChangeListener
static final int ALL
static final int SELECTION
static final int BODIES
static final int HANDLES
static final int LABELS
void paint(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
to the 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).
When stopPainting
is called, the current painting operation should be aborted.
aGraphics
- the Graphics to paint on.aMode
- indicates what should be painted and how it should be painted.aGXYView
- the view to paint for.getGXYPainter(Object)
,
getGXYLabelPainter(Object)
,
getScaleRange()
,
getLabelScaleRange()
,
stopPainting()
int applyOnInteract(ILcdFunction aFunction, 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.aStrictInteract
- if true
, the ILcdFunction
shall 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
ILcdGXYLayer
content,
the bounds of all the drawings (for the supplied mode) that represent the Objects contained in
the ILcdModel
of this ILcdGXYLayer
.
For this operation, this ILcdGXYLayer
is to be considered
as part of aGXYView
.
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.LABELS
mode 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.IllegalArgumentException
- if the mode contains ILcdGXYLayer.LABELS
void stopPainting()
Thread
and needs to be
stopped in a safe state from another Thread.paint
ILcdInterval getScaleRange()
view.getScale()
< getScaleRange().getMin()
or
view.getScale()
>= getScaleRange().getMax()
.
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.
For most use cases, we recommended using the unitless map scale range
instead.
This property is mutually exclusive with the map scale range:
only one of them has a non-null
value.ILcdInterval
containing the minimum and maximum value of view scales for which objects
should be rendered, excluding the maximum. null
if the scale constraints are determined by getMapScaleRange()
.
The scales are expressed in toolkit pixels/world unit.getMapScaleRange()
default TLcdDimensionInterval<TLcdMapScale> getMapScaleRange()
The paint method won't render objects in a view if the view's map scale is outside the scale range.
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.
This property is mutually exclusive with thetoolkit scale range
:
only one of them has a non-null
value.null
if the scale constraints are determined by getScaleRange()
ILcdInterval getLabelScaleRange()
view.getScale()
< getLabelScaleRange().getMin()
or
view.getScale()
>= getLabelScaleRange().getMax()
.
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.
For most use cases, we recommended using the unitless map scale range
instead.
This property is mutually exclusive with the label map scale range:
only one of them has a non-null
value.ILcdInterval
containing the minimum and maximum value of view scales for which
labels should be rendered, excluding the maximum.
null
if the scale constraints are determined by getLabelMapScaleRange()
The scales are expressed in toolkit pixels/world unit.getLabelMapScaleRange()
default TLcdDimensionInterval<TLcdMapScale> getLabelMapScaleRange()
map scale range
and inside the given map label scale range.
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.
This property is mutually exclusive with the toolkit label scale range
:
only one of them has a non-null
value.null
if the scale constraints are determined by getScaleRange()
ILcdGXYPainter getGXYPainter(Object aObject)
setObject
in ILcdGXYPainter.aObject
- the object to find a painter for.ILcdGXYEditor getGXYEditor(Object aObject)
setObject
in ILcdGXYEditor.aObject
- the object to find an editor for.ILcdGXYLabelPainter getGXYLabelPainter(Object aObject)
setObject
in ILcdGXYLabelPainter.aObject
- the object to find a label painter for.ILcdGXYPen getGXYPen()
Class getModelXYWorldTransfoClass()
boolean isLabeledSupported()
boolean isLabeled()
isLabeledSupported()
returns false.isLabeledSupported()
void setLabeled(boolean aLabeled)
isLabeledSupported()
returns false.aLabeled
- true to have a textual representation of the objects in the model, false to have no such
representation.