Class TLcdGXYLayer
- All Implemented Interfaces:
ILcdPropertyChangeSource
,ILcdSelection<Object>
,ILcdGXYEditableLabelsLayer
,ILcdGXYLayer
,ILcdLayer
,Serializable
- Direct Known Subclasses:
TLcdGXYLayerTreeNode
,TLcdKML22GXYLayer
,TLcdPOLLayer
,TLcdS52GXYCatalogueLayer
,TLcdS52GXYLayer
,TLcdVPFLayer
,TLcdWMSProxyGXYLayer
,TLfnGXYVectorLayer
ILcdGXYEditableLabelsLayer
interface.
The minimal setup of a TLcdGXYLayer
comprises setting a
model and a
painter provider.
It is also recommended to set an appropriate pen. It may be convenient to use
asFactory(Predicate, Consumer)
or create(ILcdModel)
to assist with this.
Domain object representations
As mentioned inILcdGXYLayer
, the geometry representations for objects are determined
by painters. The used ILcdGXYPainter
for each object is determined by a
painter provider.
Labeling
Visualization of labels is determined by label painters, which are retrieved from a label painter provider. Advanced placement is determined by a labeling algorithm, which is retrieved from a labeling algorithm provider.Adding edit behavior
The usedILcdGXYEditor
for each object is determined by an
editor provider. Similarly, label editors are retrieved from
a label editor provider.
Paint and iteration restrictions
The model objects to be handled by the layer can be changed in the following ways:- the filter allows per-object filtering
when painting, in the selection, in
getBounds
and when iterating over the objects using theapplyOnInteract*
methods. - the label scale range and scale range
allow scale-based filtering
when painting, and when iterating over the objects
using the
applyOnInteract*
methods defined inILcdGXYEditableLabelsLayer
. - a
minimum object size
can be set to improve the painting speed of large models. The setting is used when painting, in the selection, and when iterating over the objects using theapplyOnInteract*
methods. - a model query configuration can be set
to limit the amount of data that is queried from the model based on the scale values.
This is done by querying the model with a filter
to only request a part of the data for the currently visible area of the view.
The setting is used when painting
and when iterating over the objects using the
applyOnInteract*
methods. - a
label scale ratio interval
can be used to avoid displaying out-of-date labels, when label positions are calculated asynchronously. The setting is used when painting. setSelectionLabeled(boolean)
determines if labels are shown for the selected objects, in case the layer itself is not labeledsetModelElementComparator(java.util.Comparator)
determines the order in which object elements are handled by this layer. It will influence the paint order, as well as the applyOnInteract() methods behavior.
- See Also:
-
Field Summary
Fields inherited from interface com.luciad.view.gxy.ILcdGXYEditableLabelsLayer
PLACED_LABELS
-
Constructor Summary
ConstructorDescriptionConstructs an empty layer.TLcdGXYLayer
(ILcdModel aModel) Constructs an empty layer with the given model.TLcdGXYLayer
(ILcdModel aModel, String aLabel) Constructs a layer with the given label and model.TLcdGXYLayer
(ILcdModel aModel, String aLabel, ILcdGXYPen aGXYPen) Constructs a layer with the given label, model and pen.TLcdGXYLayer
(String aLabel) Constructs an empty layer with the given label.TLcdGXYLayer
(String aLabel, ILcdGXYPen aGXYPen) Constructs an empty layer with the given label and pen. -
Method Summary
Modifier and TypeMethodDescriptionprotected int
applyOnInteract
(ILcdFunction aFunction, Graphics aGraphics, int aPaintMode, ILcdModel aModel, ILcdGXYView aGXYView) Applies the function to (at the least) all objects from the given model that are contained (partially or completely) in the bounds of the view.int
applyOnInteract
(ILcdFunction aFunction, Graphics aGraphics, int aPaintMode, ILcdGXYView aGXYView) Applies the function to (at the least) all objects that are contained (partially or completely) in the bounds of the view.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.int
applyOnInteractLabels
(ILcdFunction aLabelFunction, Graphics aGraphics, int aPaintMode, ILcdGXYView aGXYView) Applies the function to (at the least) all labels that are contained (partially or completely) in the bounds of the view.static ILcdGXYLayerFactory
asFactory
(Predicate<ILcdModel> aAcceptableModel, Consumer<TLcdGXYLayer> aPostConstructCustomization) Creates a layer factory that createsTLcdGXYLayer
instances that are already partially initialized: The model is set. It derives a sensible layer name based on the model descriptor. It provides a pen with sensible default settings. It sets up a suitable painter if the model's metadata only contains shape or raster data. It offers a hook for further customization, such as setting a painter with custom styling.static TLcdGXYLayer
Creates a layer that is already partially initialized: The model is set. It derives a sensible layer name based on the model descriptor. It provides a pen with sensible default settings, generally more accurate than whatTLcdGXYLayer(com.luciad.model.ILcdModel)
would. It sets up a suitable painter if the model's metadata only contains shape or raster data. It returns aTLcdGXYLayerTreeNode
(without any children) if the model implementsILcdModelTreeNode
. The layer can be further customized after it is created, for example by setting a painter:getBounds
(int aMode, ILcdGXYView aGXYView) Returns the view bounds of thisILcdGXYLayer
content, the bounds of all the drawings (for the supplied mode) that represent the Objects contained in theILcdModel
of thisILcdGXYLayer
.getGXYEditor
(Object aObject) Returns the editor to use to modify the object via a view.Gets the currentILcdGXYEditorProvider
attached to thisTLcdGXYLayer
.getGXYLabelEditor
(Object aObject) Retrieves the label editor for the given object.Gets the currentILcdGXYLabelEditorProvider
attached to thisTLcdGXYLayer
.Returns the label algorithm to use for the given label ID.Returns the current labeling algorithm provider responsible for determining the position of the labels.getGXYLabelPainter
(Object aObject) Returns the label painter to use to paint the objects label in a view.Gets the currentILcdGXYLabelPainterProvider
attached to thisTLcdGXYLayer
.getGXYPainter
(Object aObject) Returns the painter to use to render the object in a view.Returns the currentILcdGXYPainterProvider
attached to thisTLcdGXYLayer
.Returns an array containing all painter providers for this layergetGXYPainters
(Object aObject) Returns all the painters for this object.Returns the pen to use when performing basic painting operations for objects in this layers model.getIcon()
Returns a visual indication of the contents of this layer.int
Returns the largest possible difference (in pixels) between an object's model bounds and its representation.Returns theALcdLabelLocations
instance which contains all the information about the labels of this layer.Returns the map ratio scale range for which to display labels for elements of the model.Returns the toolkit scale range for which to display labels for elements of the model.Returns the map ratio scale range for which to display elements of the model.double
Returns the minimum size of an object in the view for it to be painted and handled otherwise.Returns the comparator that defines an order between object elements.Returns the model query configuration which is used by this layer to retrieve the filters to query the model with during a paint operation.Returns the transformation class that to use to transform points and bounds from model space to world space and back.Returns the scale ratio interval in which the placed labels are painted.Returns the toolkit scale range for which to display elements of the model.boolean
Returnstrue
if the layer supports editing its objects.boolean
Returns whether objects should be represented as text.boolean
Returns whether this layer supports representing objects as text.boolean
This flag determines if the labels are editable, i.e. if they can be moved by the user.boolean
This property determines whether the layer is equipped to let the user edit the labels.boolean
boolean
Returns whether selected objects are labeled whenisLabeled()
returns false.protected final boolean
Returns whether painting of the layer should be stopped.boolean
Deprecated.This method has been deprecated.static String
modeToString
(int aMode) Utility method that provides a human readable form of the layer mode.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.protected void
paintFromModel
(Graphics aGraphics, int aMode, ILcdModel aModel, ILcdGXYContext aGXYContext) Paints the objects in the passed model by iterating over all the model's objects, in the order determined by the model.protected void
paintFromOverlaps
(Graphics aGraphics, int aMode, ILcd2DBoundsIndexedModel a2DBoundsIndexedModel, ILcdGXYContext aGXYContext) Paints the objects in the passed model by applying a painting function to allObject
of theILcd2DBoundsIndexedModel
that interact with the view clip.static void
setClassTraceOn
(boolean aClassTraceOn) Deprecated.This method has been deprecated.void
setFilter
(ILcdFilter aFilter) Sets theILcdFilter
to filter theObject
on thisILcdLayer
.void
setGXYEditorProvider
(ILcdGXYEditorProvider aGXYEditorProvider) Sets anILcdGXYEditorProvider
to thisTLcdGXYLayer
.void
setGXYLabelEditorProvider
(ILcdGXYLabelEditorProvider aGXYLabelEditorProvider) Sets anILcdGXYLabelEditorProvider
to thisTLcdGXYLayer
.void
setGXYLabelingAlgorithmProvider
(ILcdGXYLabelLabelingAlgorithmProvider aGXYLabelingAlgorithmProvider) Configures the given labeling algorithm provider responsible for determining the position of the labels.void
setGXYLabelPainterProvider
(ILcdGXYLabelPainterProvider aGXYLabelPainterProvider) Sets anILcdGXYLabelPainterProvider
to thisTLcdGXYLayer
.void
setGXYLayerLabelPainter
(ILcdGXYLayerLabelPainter aGXYLayerLabelPainter) Deprecated.label algorithm providers offer more flexibility for labelingvoid
setGXYPainterProvider
(ILcdGXYPainterProvider aGXYPainterProvider) Sets anILcdGXYPainterProvider
to thisTLcdGXYLayer
.void
setGXYPainterProviderArray
(ILcdGXYPainterProvider[] aGXYPainterProviderArray) Like,setGXYPainterProvider(com.luciad.view.gxy.ILcdGXYPainterProvider)
, but sets an array ofILcdGXYPainterProvider
to thisTLcdGXYLayer
.void
setGXYPen
(ILcdGXYPen aGXYPen) Sets the pen to use to perform basic rendering operations.void
Sets a visual indication of the contents of this layer.void
setInteractMargin
(int aInteractMargin) Sets the largest possible difference (in pixels) between an object's model bounds and its representation.void
setLabeled
(boolean aLabeled) Sets whether objects should be represented as text.void
setLabelLocations
(ALcdLabelLocations aLabelLocations) Sets theALcdLabelLocations
used by this layer to store the locations of all labels, and which labels are painted.void
setLabelMapScaleRange
(TLcdDimensionInterval<TLcdMapScale> aLabelMapScaleRange) Sets the map scale range for which to paint labels for the elements of the model.void
setLabelScaleRange
(ILcdInterval aNewLabelScaleRange) Sets the scale range in which thisILcdGXYLayer
will paint the labels of its elements if they have to be drawn at all.void
setLabelsEditable
(boolean aLabelsEditable) This flag determines if the labels are editable, i.e. if they can be moved by the user.void
setMapScaleRange
(TLcdDimensionInterval<TLcdMapScale> aMapScaleRange) Sets the map scale range for which to paint the elements of the model.void
setMinimumObjectSizeForPainting
(double aMinimumObjectSizeForPainting) Sets the minimum size of an object in the view for it to be painted and handled otherwise.void
Sets theILcdModel
to thisILcdLayer
.void
setModelElementComparator
(Comparator<Object> aObjectElementComparator) Sets a comparator on this layer that defines an order between object elements.final void
setModelQueryConfiguration
(TLcdModelQueryConfiguration aModelQueryConfiguration) Sets the model query configuration which defines the filters to query the model with during a paint operation.void
setModelXYWorldTransfoClass
(Class aModelXYWorldTransfoClass) Sets the transformation class that should be used to transform coordinates of objects in the model to XY world coordinates of the view this layer will be part of.void
setPaintFromOverlaps
(boolean aNewPaintFromOverlaps) Sets whether thepaint
method should try to paint all objects (paintFromModel) or only the objects that are visible in the context passed to the paint method (paintFromOverlaps), by taking advantage of theILcd2DBoundsIndexedModel
interface.void
setPaintLabelsScaleRatioInterval
(ILcdInterval aInterval) Sets the scale ratio interval in which the placed labels are painted whenpaint(java.awt.Graphics, int, ILcdGXYView)
is called with theILcdGXYEditableLabelsLayer.PLACED_LABELS
flag.void
setScaleRange
(ILcdInterval aNewScaleRange) Sets the scale range in which thisILcdGXYLayer
will paint its elements.void
setSelectionLabeled
(boolean aNewSelectionLabeled) Sets whether selected objects are labeled whenisLabeled()
returns false.void
setTraceOn
(boolean aTraceOn) Deprecated.This method has been deprecated.void
setVisible
(boolean aVisible) Sets whether or not the layer's content is painted.protected final void
Indicates that rendering should no longer be stopped.void
Inform the layer that it should terminate the current paint operation.Methods inherited from class com.luciad.view.TLcdLayer
addPropertyChangeListener, addSelectionListener, clearSelection, fireCollectedSelectionChanges, firePropertyChangeEvent, getFilter, getLabel, getModel, getSelectionCount, invalidate, isEditable, isSelectable, isSelectableSupported, isSelected, isVisible, removePropertyChangeListener, removeSelectionListener, selectedObjects, selectObject, selectObjects, setEditable, setLabel, setSelectable, setSelectableSupported, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.luciad.view.ILcdLayer
clearSelection, fireCollectedSelectionChanges, getLabel, getModel, isEditable, isSelectable, isSelectableSupported, isVisible, selectObject, setEditable, setLabel, setSelectable
Methods inherited from interface com.luciad.util.ILcdPropertyChangeSource
addPropertyChangeListener, removePropertyChangeListener
Methods inherited from interface com.luciad.util.ILcdSelection
addSelectionListener, getSelectedObjects, getSelectionCount, isSelected, removeSelectionListener, selectedObjects
-
Constructor Details
-
TLcdGXYLayer
public TLcdGXYLayer()Constructs an empty layer. For a minimal setup, a model and painter provider should be set before including this layer in a view. See alsocreate(ILcdModel)
. -
TLcdGXYLayer
Constructs an empty layer with the given model. The display name of the model's descriptor (if it exists) is used as the label of this layer. For a minimal setup, a painter provider should be set before including this layer in a view. See alsocreate(ILcdModel)
, which in addition sets a sensible default pen.- Parameters:
aModel
- the model to visualize. Never null.
-
TLcdGXYLayer
Constructs an empty layer with the given label. For a minimal setup, a model and painter provider should be set before including this layer in a view. See alsocreate(ILcdModel)
.- Parameters:
aLabel
- a textual representation of this layer.
-
TLcdGXYLayer
Constructs a layer with the given label and model. For a minimal setup, a painter provider should be set before including this layer in a view. See alsocreate(ILcdModel)
.- Parameters:
aModel
- contains the objects that should be rendered in this layer.aLabel
- a textual representation of this layer.
-
TLcdGXYLayer
Constructs an empty layer with the given label and pen. For a minimal setup, a model and painter provider should be set before including this layer in a view. See alsocreate(ILcdModel)
.- Parameters:
aLabel
- a textual representation of this layer.aGXYPen
- the pen to use to render basic geometries (lines, points, arcs).
-
TLcdGXYLayer
Constructs a layer with the given label, model and pen. For a minimal setup, a painter provider should be set before including this layer in a view. See alsocreate(ILcdModel)
.- Parameters:
aModel
- contains the objects that should be rendered in this layer.aLabel
- a textual representation of this layer.aGXYPen
- the pen to use to render basic geometries (lines, points, arcs).
-
-
Method Details
-
asFactory
public static ILcdGXYLayerFactory asFactory(Predicate<ILcdModel> aAcceptableModel, Consumer<TLcdGXYLayer> aPostConstructCustomization) Creates a layer factory that createsTLcdGXYLayer
instances that are already partially initialized:- The model is set.
- It derives a sensible layer name based on the model descriptor.
- It provides a pen with sensible default settings.
- It sets up a suitable painter if the model's metadata only contains shape or raster data.
null
if aAcceptableModel returnsfalse
.- Parameters:
aAcceptableModel
- Returnstrue
if a layer should be created for this model,false
ifnull
should be returned. TheILcdModel
to test is nevernull
.aPostConstructCustomization
- Callback to do further customization. For examplelayer -> layer.setGXYPainterProvider(myPainter)
- Returns:
- The layer factory.
- Since:
- 2017.0
-
create
Creates a layer that is already partially initialized:- The model is set.
- It derives a sensible layer name based on the model descriptor.
- It provides a pen with sensible default settings, generally more accurate than what
TLcdGXYLayer(com.luciad.model.ILcdModel)
would. - It sets up a suitable painter if the model's metadata only contains shape or raster data.
- It returns a
TLcdGXYLayerTreeNode
(without any children) if the model implementsILcdModelTreeNode
.
See alsoTLcdGXYLayer layer = TLcdGXYLayer.create(aModel); layer.setGXYPainterProvider(myPainter);
TLcdGXYShapePainter
for styling options, orTLcdGXYImagePainter
if your model contains imagery.- Returns:
- The layer.
- Since:
- 2017.0
-
setClassTraceOn
public static void setClassTraceOn(boolean aClassTraceOn) Deprecated.This method has been deprecated. It is recommended to use the standard Java logging framework directly.Enables tracing for all instances of this class. If the argument istrue
then all log messages are recorded, otherwise only the informative, warning and error messages are recorded.- Parameters:
aClassTraceOn
- if true then all log messages are recorded, otherwise only the informative, warning and error messages are recorded.
-
setTraceOn
public void setTraceOn(boolean aTraceOn) Deprecated.This method has been deprecated. It is recommended to use the standard Java logging framework directly.Enables tracing for this class instance. Calling this method with eithertrue
orfalse
as argument automatically turns off tracing for all other class instances for whichsetTraceOn
has not been called. If the argument isfalse
then only the informative, warning and error log messages are recorded.- Overrides:
setTraceOn
in classTLcdLayer
- Parameters:
aTraceOn
- if true then all log messages are recorded for this instance. If false, then only the informative, warning and error log messages are recorded.
-
isTraceOn
public boolean isTraceOn()Deprecated.This method has been deprecated. It is recommended to use the standard Java logging framework directly.Returnstrue
if tracing is enabled for this class. -
setModel
Description copied from class:TLcdLayer
Sets theILcdModel
to thisILcdLayer
. -
setModelXYWorldTransfoClass
Sets the transformation class that should be used to transform coordinates of objects in the model to XY world coordinates of the view this layer will be part of. The default class is
TLcdDefaultModelXYWorldTransformation
, which covers the built-in LuciadLightspeed transformations.This layer will create instances of this Class using Class#newInstance().
- Parameters:
aModelXYWorldTransfoClass
- the transformation class should be consistent with the model reference of the model of the layer and the XY world reference of the view this layer will be part of. The class passed should implement the interfaceILcdModelXYWorldTransformation
.- See Also:
-
getModelXYWorldTransfoClass
Returns the transformation class that to use to transform points and bounds from model space to world space and back. This class has to be conform with the reference of the model of this layer and the reference of the view this layer is part of.- Specified by:
getModelXYWorldTransfoClass
in interfaceILcdGXYLayer
- Returns:
- the transformation class that to use to transform points and bounds from model space to world space and back.
- See Also:
-
getGXYPen
Returns the pen to use when performing basic painting operations for objects in this layers model.- Specified by:
getGXYPen
in interfaceILcdGXYLayer
- Returns:
- the pen to use when performing basic painting operations for objects in this layers model.
- See Also:
-
setGXYPen
Sets the pen to use to perform basic rendering operations. The default value is aTLcdGXYPen
.- Parameters:
aGXYPen
- the pen to use to perform basic rendering.- See Also:
-
getLabelLocations
Returns the
ALcdLabelLocations
instance which contains all the information about the labels of this layer. You can use this instance to retrieve which labelshave been drawn
and where these labelsare located
.This instance can also be used to
alter
the location of the labels. As this method always returns the same instance, changes made to the returnedALcdLabelLocations
instance immediately effect all other clients of this layer.If the location of a label is changed, the layer should be invalidated using the
invalidateGXYLayer
method of theILcdGXYView
.- Specified by:
getLabelLocations
in interfaceILcdGXYEditableLabelsLayer
- Returns:
- The
ALcdLabelLocations
instance. It never isnull
. - See Also:
-
setLabelLocations
Sets theALcdLabelLocations
used by this layer to store the locations of all labels, and which labels are painted.- Parameters:
aLabelLocations
- TheALcdLabelLocations
.- See Also:
-
getMinimumObjectSizeForPainting
public double getMinimumObjectSizeForPainting()Returns the minimum size of an object in the view for it to be painted and handled otherwise.- Returns:
- the minimum size of an object in the view for it to be painted and handled otherwise.
- See Also:
-
setMinimumObjectSizeForPainting
public void setMinimumObjectSizeForPainting(double aMinimumObjectSizeForPainting) Sets the minimum size of an object in the view for it to be painted and handled otherwise. So objects that are smaller as this minimum size are ignored during painting and duringapplyOnInteract
(which is for example used during selection). A value of 0 will always paint all objects, no matter how small they appear. Larger values can discard more objects. This typically improves the painting speed, although it might leave undesirable gaps in models containing many small objects. The default value is 1 pixel.- Parameters:
aMinimumObjectSizeForPainting
- The minimal size, expressed in pixels.- See Also:
-
getInteractMargin
public int getInteractMargin()Returns the largest possible difference (in pixels) between an object's model bounds and its representation. This value is used when calling one of the applyOnInteract methods or when painting an ILcd2DBoundsIndexedModel (ifsetPaintFromOverlaps(boolean)
is true).- Returns:
- the margin (in pixels) to take into account when interacting with the model
- See Also:
-
setInteractMargin
public void setInteractMargin(int aInteractMargin) Sets the largest possible difference (in pixels) between an object's model bounds and its representation. This value is used when calling one of the applyOnInteract methods or when painting an ILcd2DBoundsIndexedModel (ifsetPaintFromOverlaps(boolean)
is true). It ensures, for example, that a model element is still painted if its visual representation falls inside the view, but its model bounds do not. If for example icons are used to represent points on the map, the icon could be 16 by 16 pixels, whereas the object itself is a point, having a zero size. Depending on where the point is located in the icon, the required interact margin for this example can be up to 16 pixels. The drawback of setting a too large value is a performance loss. The drawback of setting a too small value is that objects (e.g. icons) disappear when they are located partly outside the view. The default value is 32.- Parameters:
aInteractMargin
- the margin (in pixels) to take into account when interacting with the model- See Also:
-
setGXYLayerLabelPainter
Deprecated.label algorithm providers offer more flexibility for labelingSets a layer label painter on this layer. The layer label painter is responsible for label decluttering within this layer. If no layer label painter is set, the layer will paint all labels of a domain object when used with painting modeILcdGXYLayer.LABELS
, and only the labels marked in the label locations when used with painting modeILcdGXYEditableLabelsLayer.PLACED_LABELS
.- Parameters:
aGXYLayerLabelPainter
- a layer label painter to declutter labels.- See Also:
-
getGXYLayerLabelPainter
- Returns:
- the layer label painter of this layer, or null if there is no layer label painter
- See Also:
-
getGXYLabelingAlgorithm
Returns the label algorithm to use for the given label ID. This implementation relies on the configuredlabel algorithm provider
.- Specified by:
getGXYLabelingAlgorithm
in interfaceILcdGXYEditableLabelsLayer
- Parameters:
aLabel
- the identifier defining the label and its associated domain object- Returns:
- the result of querying the configured labeling algorithm provider. If no provider is configured, it returns
null
.
-
setLabeled
public void setLabeled(boolean aLabeled) Sets whether objects should be represented as text. The value set for this property shall have no effect as long asILcdGXYLayer.isLabeledSupported()
returns false. Objects for which the GXYLabelPainterProvider does not return aILcdGXYLabelPainter
or which do not pass the filter will not have their labels rendered.- Specified by:
setLabeled
in interfaceILcdGXYLayer
- Parameters:
aLabeled
- true to have a textual representation of the objects in the model, false to have no such representation.- See Also:
-
isLabeled
public boolean isLabeled()Returns whether objects should be represented as text. Note that this property shall not be taken into account whenILcdGXYLayer.isLabeledSupported()
returns false.- Specified by:
isLabeled
in interfaceILcdGXYLayer
- Returns:
- whether objects should be represented as text.
- See Also:
-
isLabeledSupported
public boolean isLabeledSupported()Returns whether this layer supports representing objects as text. If not, no effort should be made trying to represent the objects with labels. This layer supports labeling when the GXYLabelPainterProvider is set to a non null value.- Specified by:
isLabeledSupported
in interfaceILcdGXYLayer
- Returns:
true
ifgetGXYLabelPainterProvider()
returns a nonnull
value,false
otherwise.- See Also:
-
setLabelsEditable
public void setLabelsEditable(boolean aLabelsEditable) This flag determines if the labels are editable, i.e. if they can be moved by the user. Note that the labels can however still be moved by, for instance, labeling algorithms. Objects for which the ILcdGXYLabelEditorProvider does not return aILcdGXYLabelEditor
or which do not pass the filter will not have their labels edited.- Specified by:
setLabelsEditable
in interfaceILcdGXYEditableLabelsLayer
- Parameters:
aLabelsEditable
- true to allow editing labels for all objects in the model for which the ILcdGXYLabelEditorProvider returns aILcdGXYLabelEditor
. False to not have labels editable for any object in the model.- See Also:
-
isLabelsEditable
public boolean isLabelsEditable()This flag determines if the labels are editable, i.e. if they can be moved by the user. Note that the labels can however still be moved by, for instance, labeling algorithms.- Specified by:
isLabelsEditable
in interfaceILcdGXYEditableLabelsLayer
- Returns:
true
if the labels can be moved and reshaped by the user,false
otherwise.- See Also:
-
isLabelsEditableSupported
public boolean isLabelsEditableSupported()This property determines whether the layer is equipped to let the user edit the labels. More specifically this property determines whether the layer can provide anILcdGXYLabelEditor
for its objects. This layer supports editing labels when the ILcdGXYLabelEditorProvider is set to a non null value.- Specified by:
isLabelsEditableSupported
in interfaceILcdGXYEditableLabelsLayer
- Returns:
true
ifgetGXYLabelEditorProvider()
returns a nonnull
value,false
otherwise.- See Also:
-
isEditableSupported
public boolean isEditableSupported()Returnstrue
if the layer supports editing its objects. This implementation always returns true. Override this method if editing behavior is restricted. This layer supports editing when the GXYEditorProvider to this layer is set to a non null value.- Specified by:
isEditableSupported
in interfaceILcdLayer
- Overrides:
isEditableSupported
in classTLcdLayer
- Returns:
true
ifgetGXYEditorProvider()
returns a nonnull
value,false
otherwise.- See Also:
-
setGXYPainterProvider
Sets anILcdGXYPainterProvider
to thisTLcdGXYLayer
. During painting, the provider will be queried to return a painter for the relevant domain objects. If no painter provider is set to this layer, nothing will be rendered. This call overwrites the painter provider array with a new one containing the given provider. Note that no property change listeners can be added to the painter provider, so the layer is not automatically notified when a property on the painter provider has changed. To notify the layer and its listeners, a property change event has to be fired, using the methodTLcdLayer.firePropertyChangeEvent(java.beans.PropertyChangeEvent)
.- Parameters:
aGXYPainterProvider
- the new painter provider- See Also:
-
setGXYPainterProviderArray
Like,setGXYPainterProvider(com.luciad.view.gxy.ILcdGXYPainterProvider)
, but sets an array ofILcdGXYPainterProvider
to thisTLcdGXYLayer
. Painting is done for each of the providers (in the order of the array), each time for the whole set of elements. This can be useful to perform multiple painting passes.- Parameters:
aGXYPainterProviderArray
- a sequence of painter providers- See Also:
-
getGXYPainterProvider
Returns the currentILcdGXYPainterProvider
attached to thisTLcdGXYLayer
.- Returns:
- the current painter provider
- See Also:
-
getGXYPainterProviderArray
Returns an array containing all painter providers for this layer- Returns:
- all painter providers for this layer
- See Also:
-
setGXYEditorProvider
Sets anILcdGXYEditorProvider
to thisTLcdGXYLayer
. This allows an eternal entity (for example, anILcdGXYController
to edit the domain objects of this layer by retrieving an editor for it. Editing of objects in the model through the layer is only possible for objects for which the editor provider returns anILcdGXYEditor
. By default the editor provider is null and no editing is possible.Note that no property change listeners can be added to the editor provider, so the layer is not automatically notified when a property on the editor provider has changed. To notify the layer and its listeners, a property change event has to be fired, using the method
TLcdLayer.firePropertyChangeEvent(java.beans.PropertyChangeEvent)
.- Parameters:
aGXYEditorProvider
- the new editor provider- See Also:
-
getGXYEditorProvider
Gets the currentILcdGXYEditorProvider
attached to thisTLcdGXYLayer
.- Returns:
- the current editor provider
- See Also:
-
getGXYPainter
Description copied from interface:ILcdGXYLayer
Returns the painter to use to render the object in a view. If no painter is available, the object has no representation. When a painter is available, the object shall be assigned to the painter before using the painter, seesetObject
in ILcdGXYPainter.- Specified by:
getGXYPainter
in interfaceILcdGXYLayer
- Parameters:
aObject
- the object to return a painter for.- Returns:
- the
getGXYPainterProvider.getGXYPainter(aObject)
for the first provider that returns a non-null one,null
otherwise. The returned painter is properly initialized to the givenaObject
. - See Also:
-
getGXYPainters
Returns all the painters for this object.- Parameters:
aObject
- the object to retrieve painters for- Returns:
- an enumeration of painters for this object, coming from the GXYPainterProviderArray
- See Also:
-
getGXYEditor
Description copied from interface:ILcdGXYLayer
Returns the editor to use to modify the object via a view. If no editor is available, the object cannot be edited via interaction through a view. When an editor is available, the object shall be assigned to the editor before editing, usingsetObject
in ILcdGXYEditor.- Specified by:
getGXYEditor
in interfaceILcdGXYLayer
- Parameters:
aObject
- the object to find an editor for.- Returns:
getGXYEditorProvider.getGXYEditor(aObject)
if getGXYEditorProvider returns a non null value,null
otherwise.- See Also:
-
setGXYLabelPainterProvider
Sets anILcdGXYLabelPainterProvider
to thisTLcdGXYLayer
. During painting, the provider will be queried to return a label painter for the relevant domain objects. If no label painter provider is set to this layer, no labels will be rendered.Note that no property change listeners can be added to the label painter provider, so the layer is not automatically notified when a property on the label painter provider has changed. To notify the layer and its listeners, a property change event has to be fired, using the method
TLcdLayer.firePropertyChangeEvent(java.beans.PropertyChangeEvent)
.- Parameters:
aGXYLabelPainterProvider
- the new label painter provider- See Also:
-
getGXYLabelPainterProvider
Gets the currentILcdGXYLabelPainterProvider
attached to thisTLcdGXYLayer
.- Returns:
- the current label painter provider
- See Also:
-
getGXYLabelPainter
Description copied from interface:ILcdGXYLayer
Returns the label painter to use to paint the objects label in a view. If no label painter is available, the object does not have a label. When a label painter is available, the object shall be assigned to the label painter before using the label painter, seesetObject
in ILcdGXYLabelPainter.- Specified by:
getGXYLabelPainter
in interfaceILcdGXYLayer
- Parameters:
aObject
- the object to find a label painter for.- Returns:
getGXYLabelPainterProvider.getGXYLabelPainter(aObject)
if getGXYLabelPainterProvider returns a non null value,null
otherwise. The returned painter is properly initialized to the givenaObject
.- See Also:
-
setGXYLabelEditorProvider
Sets anILcdGXYLabelEditorProvider
to thisTLcdGXYLayer
. This allows an eternal entity (for example, anILcdGXYController
to edit the labels of domain objects of this layer by retrieving a label editor for it. If no label editor provider is set, no labels can be edited for any object in the model. The default value is null.Note that no property change listeners can be added to the label editor provider, so the layer is not automatically notified when a property on the label editor provider has changed. To notify the layer and its listeners, a property change event has to be fired, using the method
TLcdLayer.firePropertyChangeEvent(java.beans.PropertyChangeEvent)
.- Parameters:
aGXYLabelEditorProvider
- the new label editor provider- See Also:
-
getGXYLabelingAlgorithmProvider
Returns the current labeling algorithm provider responsible for determining the position of the labels. The provider is typically used by the view's label placer. During label placement, the provider will be queried to return a label algorithm for the relevant domain objects.- Returns:
- the current label algorithm provider, or null if there is no provider
- Since:
- 2020.0
- See Also:
-
setGXYLabelingAlgorithmProvider
public void setGXYLabelingAlgorithmProvider(ILcdGXYLabelLabelingAlgorithmProvider aGXYLabelingAlgorithmProvider) Configures the given labeling algorithm provider responsible for determining the position of the labels. The provider is typically used by the view's label placer. During label placement, the provider will be queried to return a label algorithm for the relevant domain objects.Note that no property change listeners can be added to the label algorithm provider, so the layer is not automatically notified when a property on the label algorithm provider has changed. To notify the layer and its listeners, fire a property change event.
- Parameters:
aGXYLabelingAlgorithmProvider
- the new label algorithm provider- Since:
- 2020.0
- See Also:
-
getGXYLabelEditorProvider
Gets the currentILcdGXYLabelEditorProvider
attached to thisTLcdGXYLayer
.- Returns:
- the current label editor provider, or null if there is no label editor provider
- See Also:
-
getGXYLabelEditor
Description copied from interface:ILcdGXYEditableLabelsLayer
Retrieves the label editor for the given object. This label editor can be used to move the label foraObject
to a different location.- Specified by:
getGXYLabelEditor
in interfaceILcdGXYEditableLabelsLayer
- Parameters:
aObject
- The object for which to retrieve the label editor. This object should not benull
and should be contained in the model of this layer.- Returns:
getGXYLabelEditorProvider.getGXYLabelEditor(aObject)
if getGXYLabelEditorProvider returns a non null value,null
otherwise. The returned painter is properly initialized to the givenaObject
.- See Also:
-
getIcon
Description copied from interface:ILcdLayer
Returns a visual indication of the contents of this layer. For example, for a grid layer, an icon containing a grid could be used. -
setIcon
Description copied from interface:ILcdLayer
Sets a visual indication of the contents of this layer. -
setPaintFromOverlaps
public void setPaintFromOverlaps(boolean aNewPaintFromOverlaps) Sets whether thepaint
method should try to paint all objects (paintFromModel) or only the objects that are visible in the context passed to the paint method (paintFromOverlaps), by taking advantage of theILcd2DBoundsIndexedModel
interface.- Parameters:
aNewPaintFromOverlaps
- iftrue
, the paint method usespaintFromOverlaps()
for models implementingILcd2DBoundsIndexedModel
. Iffalse
, it usespaintFromModel
.- See Also:
-
isPaintFromOverlaps
public boolean isPaintFromOverlaps()- Returns:
true
, if the paint method usespaintFromOverlaps()
for models implementingILcd2DBoundsIndexedModel
,false
if it uses paintFromModel.- See Also:
-
setModelElementComparator
Sets a comparator on this layer that defines an order between object elements. TheComparator.compare(Object,Object)
method will be called using object elements. The given comparator will influence the order in which the applyOnInteract methods will apply a function on the object elements. This will also influence the paint order.For example, when the given comparator defines that
object1 < object2
, applyOnInteract() will apply its function first on object1, and only then on object2. Furthermore, object2 will be painted after object1, so it is painted on top.When the given comparator is
null
, the order in which applyOnInteract() applies its function on the object elements will be undefined.- Parameters:
aObjectElementComparator
- a comparator that defines an order between object elements- See Also:
-
getModelElementComparator
Returns the comparator that defines an order between object elements.- Returns:
- the comparator that defines an order between object elements.
- See Also:
-
setScaleRange
Sets the scale range in which thisILcdGXYLayer
will paint its elements. The paint method of anILcdGXYLayer
shall not perform any action when:
aGXYContext.getGXYView().getScale() < getScaleRange().getMin()
or
aGXYContext.getGXYView().getScale() > getScaleRange().getMax()
This also applies to the labels. Setting the scale range to null is equivalent to setting the scale range to [0, Double.MAX_VALUE], i.e. the layer will be painted, regardless of the scale. This method overrides any configured map scale range. For most use cases, we recommended using theunitless map scale range
instead.
An alternative for setting a scale range is configuring a model query configuration.- Parameters:
aNewScaleRange
- the new scale range, in toolkit pixels/world unit. The minimum (smallest) value is the most zoomed out, the maximum (largest) value is the most zoomed in.- See Also:
-
getScaleRange
Returns the toolkit scale range for which to display elements of the model. In other words, the paint method will not render any objects in a view when:
view.getScale()
<getScaleRange().getMin()
orview.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 theunitless map scale range
instead. This property is mutually exclusive with the map scale range: only one of them has a non-null
value.- Specified by:
getScaleRange
in interfaceILcdGXYLayer
- Returns:
- an
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 byILcdGXYLayer.getMapScaleRange()
. The scales are expressed in toolkit pixels/world unit. - See Also:
-
setLabelScaleRange
Sets the scale range in which thisILcdGXYLayer
will paint the labels of its elements if they have to be drawn at all. The paint method of anILcdGXYLayer
shall not draw any labels when:
aGXYContext.getGXYView().getScale() < getScaleRange().getMin()
or
aGXYContext.getGXYView().getScale() < getLabelScaleRange().getMin()
or
aGXYContext.getGXYView().getScale() >= getScaleRange().getMax()
or
aGXYContext.getGXYView().getScale() >= getLabelScaleRange().getMax()
This method overrides any configured label map scale range. For most use cases, we recommended using theunitless map scale range
instead.- Parameters:
aNewLabelScaleRange
- the new label scale range, in toolkit pixels/world unit, ornull
to disable all scale constraints The minimum (smallest) value is the most zoomed out, the maximum (largest) value is the most zoomed in.- See Also:
-
getLabelScaleRange
Returns the toolkit scale range for which to display labels for elements of the model. In other words, the paint method will not render any labels for objects in a view when:
view.getScale()
<getLabelScaleRange().getMin()
orview.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 theunitless map scale range
instead. This property is mutually exclusive with the label map scale range: only one of them has a non-null
value.- Specified by:
getLabelScaleRange
in interfaceILcdGXYLayer
- Returns:
- an
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 byILcdGXYLayer.getLabelMapScaleRange()
The scales are expressed in toolkit pixels/world unit. - See Also:
-
getMapScaleRange
Description copied from interface:ILcdGXYLayer
Returns the map ratio scale range for which to display elements of the model.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.- Specified by:
getMapScaleRange
in interfaceILcdGXYLayer
- Returns:
- the minimum and maximum value of view scales for which objects should be rendered,
or
null
if the scale constraints are determined byILcdGXYLayer.getScaleRange()
-
setMapScaleRange
Sets the map scale range for which to paint the elements of the model. The paint method will only paint model elements in a view if the view's map scale is inside the given 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 method overrides any configured toolkit scale range.- Parameters:
aMapScaleRange
- the new map scale range, ornull
to disable any scale constraints- Since:
- 2021.0
-
getLabelMapScaleRange
Description copied from interface:ILcdGXYLayer
Returns the map ratio scale range for which to display labels for elements of the model. The paint method will render labels for objects in a view if the view's map scale is both inside themap 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 thetoolkit label scale range
: only one of them has a non-null
value.- Specified by:
getLabelMapScaleRange
in interfaceILcdGXYLayer
- Returns:
- the minimum and maximum value of map scales for which object labels should be rendered,
or
null
if the scale constraints are determined byILcdGXYLayer.getScaleRange()
-
setLabelMapScaleRange
Sets the map scale range for which to paint labels for the elements of the model.The paint method will render labels for objects in a view if the view's map scale is both inside the
map scale range
and inside the given map label 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 method overrides any configured toolkit label scale range.- Parameters:
aLabelMapScaleRange
- the new map scale range- Since:
- 2021.0
-
getPaintLabelsScaleRatioInterval
Returns the scale ratio interval in which the placed labels are painted.- Returns:
- the scale ratio interval in which the placed labels are painted
- See Also:
-
setPaintLabelsScaleRatioInterval
Sets the scale ratio interval in which the placed labels are painted whenpaint(java.awt.Graphics, int, ILcdGXYView)
is called with theILcdGXYEditableLabelsLayer.PLACED_LABELS
flag.If the ratio between the current scale and the scale in which the labels were placed is within this interval, the labels are painted, otherwise they are not. Omitting labels can be useful when the locations of labels are not always up-to-date, for example, if they are calculated asynchronously.
By default placed labels are painted when the scale ratio is within the interval
[0.5, Double.Max_Value]
.- Parameters:
aInterval
- The scale ratio interval.- See Also:
-
setSelectionLabeled
public void setSelectionLabeled(boolean aNewSelectionLabeled) Sets whether selected objects are labeled whenisLabeled()
returns false.- Parameters:
aNewSelectionLabeled
- true if selected objects should always be labeled, regardless ofisLabeled
- See Also:
-
isSelectionLabeled
public boolean isSelectionLabeled()Returns whether selected objects are labeled whenisLabeled()
returns false.- Returns:
- true if selected objects should always be labeled, regardless of
isLabeled
- See Also:
-
getBounds
Returns the view bounds of thisILcdGXYLayer
content, the bounds of all the drawings (for the supplied mode) that represent the Objects contained in theILcdModel
of thisILcdGXYLayer
. For this operation, thisILcdGXYLayer
is to be considered as part ofaGXYView
.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.
- Specified by:
getBounds
in interfaceILcdGXYLayer
- Parameters:
aMode
- a bitwise combination of ALL or SELECTION and one or more of BODIES and HANDLES. TheILcdGXYLayer.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.- Returns:
- a bounds (in view coordinates, pixels) that encompasses the representation of all objects that are rendered in a view.
- Throws:
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.
-
applyOnInteract
public 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.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.
Objects smaller than the set minimum object size may be omitted.
- Specified by:
applyOnInteract
in interfaceILcdGXYLayer
- Parameters:
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
- iftrue
, theILcdFunction
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.- Returns:
- the number of objects the function was applied on.
-
applyOnInteract
public int applyOnInteract(ILcdFunction aFunction, Graphics aGraphics, int aPaintMode, ILcdGXYView aGXYView) Description copied from interface:ILcdGXYEditableLabelsLayer
Applies the function to (at the least) all objects that are contained (partially or completely) in the bounds of the view. This method behaves similar to the paint method, and as such is allowed to omit small or invisible objects for performance reasons. For example, it can disregard objects that are outside the scale range.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.The mode indicates what objects of the model should be taken into account. The objects to be taken into account shall be one of:
- ALL: all the objects in the layer's model, or
- SELECTION: all the objects in the layer's selection.
The representations provided shall be a combination of one or more of:
- BODIES: the combination of geometric representations of the objects,
- HANDLES: the handles for the objects,
- LABELS: the combination of the textual representations of the objects.
The mode supplied shall be a bitwise 'or' combination of a constant of the first group and a combination of constants of the second group.
- Specified by:
applyOnInteract
in interfaceILcdGXYEditableLabelsLayer
- Parameters:
aFunction
- the function to apply. When the function returnsfalse
, no more objects should be passed to the function.aGraphics
- the graphicsaPaintMode
- the paint mode.aGXYView
- the view in whose bounds the objects representations should be in order to be passed to the function. Note that for efficiency reasons (e.g. to avoid expensive bounds calculations) objects may be passed that are not inside the view bounds.- Returns:
- the number of objects the function was applied on.
-
applyOnInteractLabels
public int applyOnInteractLabels(ILcdFunction aLabelFunction, Graphics aGraphics, int aPaintMode, ILcdGXYView aGXYView) Description copied from interface:ILcdGXYEditableLabelsLayer
Applies the function to (at the least) all labels that are contained (partially or completely) in the bounds of the view. This method behaves similar to the paint method, and as such is allowed to omit labels for small or invisible objects for performance reasons. For example, it can disregard labels for objects outside the scale range, or labels outside the label scale range.The function shall be applied successively to all labels in the bounds as long as the function returns
true
for a label. This allows developers to indicate a stop condition. Note that the order in which the labels are passed to the function is not specified.The mode indicates what labels should be taken into account. The labels to be taken into account shall be one of:
- ALL: all the labels in the layer's model, or
- SELECTION: all the labels in the layer's selection.
The representations provided shall be a combination of one or more of:
- BODIES: the combination of label representations of the objects,
- HANDLES: the handles for the labeled objects,
- LABELS: the combination of the textual labels representations of the objects.
The mode supplied shall be a bitwise 'or' combination of a constant of the first group and a combination of constants of the second group.
- Specified by:
applyOnInteractLabels
in interfaceILcdGXYEditableLabelsLayer
- Parameters:
aLabelFunction
- the function to apply. When the function returnsfalse
, no more labels should be passed to the function. The Object passed to this function is always aTLcdLabelIdentifier
.aGraphics
- the graphicsaPaintMode
- the paint mode.aGXYView
- the view in whose bounds the objects representations should be in order passed to the function. Note that for efficiency reasons (e.g. to avoid expensive bounds calculations) objects may be passed that are not inside the view bounds.- Returns:
- the number of objects the function was applied on.
-
getModelQueryConfiguration
Returns the model query configuration which is used by this layer to retrieve the filters to query the model with during a paint operation. This model query configuration allows to reduce the amount of the data that is loaded by this layer during painting. The default is a configuration which loads all data for the whole scale range. Consult the class javadoc for more information about data filtering.- Returns:
- the model query configuration which is used by the layer to retrieve the filters to query the model with during
a paint operation. Never
null
. - Since:
- 2017.0
-
setModelQueryConfiguration
Sets the model query configuration which defines the filters to query the model with during a paint operation. This model query configuration allows to reduce the amount of the data that is loaded by this layer during painting. Consult the class javadoc for more information about data filtering.- Parameters:
aModelQueryConfiguration
- The non-null
model query configuration- Since:
- 2017.0
-
setFilter
Sets the
ILcdFilter
to filter theObject
on thisILcdLayer
. Operations on this layer will only be applied to objects of the model that pass the filter. This includes painting, labeling, selection, editing, ...If the filter implements
ILcdChangeSource
, the layer will listen to changes in the filter to keep, for example, the selection up to date.Setting a
null
filter, lets all objects pass for rendering. By default the filter isnull
.The filtering performed by this filter is done inside the JVM, after the data has been queried from the model and been passed to the layer. Use the
setModelQueryConfiguration(TLcdModelQueryConfiguration)
if you have filters which should be evaluated on the model side. For example when using a database model, this would allow the database to do the filtering. -
applyOnInteract
protected int applyOnInteract(ILcdFunction aFunction, Graphics aGraphics, int aPaintMode, ILcdModel aModel, ILcdGXYView aGXYView) Applies the function to (at the least) all objects from the given model that are contained (partially or completely) in the bounds of the view. This method behaves similar to the paint method, and as such is allowed to omit small or invisible objects for performance reasons. For example, it can disregard objects that are outside the scale range.For more information on this method, see the javadoc of
applyOnInteract
.This method is called by
So it is possible to customise these methods by overriding this method. This can be used to e.g. customize the model content for painting of customise the model content for label placement.- Parameters:
aFunction
- the function to apply. When the function returnsfalse
, no more objects should be passed to the function.aGraphics
- the graphicsaPaintMode
- the paint mode.aModel
- the model for whose objects the given function is applied.aGXYView
- the view in whose bounds the objects representations should be in order to be passed to the function. Note that for efficiency reasons (e.g. to avoid expensive bounds calculations) objects may be passed that are not inside the view bounds.- Returns:
- the number of objects the function was applied on.
-
paint
Paints the combined representation of the layer's objects for a view, taking into account the mode.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:
- ALL: all the objects in the layer's model, or
- SELECTION: all the objects in the layer's selection.
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:
- BODIES: the combination of geometric representations of the objects,
- HANDLES: the handles for the objects. These are the parts of the objects representation on which user interaction can be applied. For example, for a circle this can be the center point, allowing to move the circle.
- LABELS: the combination of the textual representations of the objects.
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 thelabelpainter
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.If this layer is asked to paint its labels, it must inform its
ALcdLabelLocations
instance as to which labels have been painted and which haven't been.The paint mode may contain
ILcdGXYEditableLabelsLayer.PLACED_LABELS
. This is a paint mode to indicate that only labels that are already placed should be painted. The already placed labels can be retrieved from theALcdLabelLocations
retrieved usingILcdGXYEditableLabelsLayer.getLabelLocations()
.This implementation calls
paintFromOverlaps
orpaintFromModel
, depending on whetherisPaintFromOverlaps()
returnstrue
orfalse
.This method also calls
applyOnInteract(com.luciad.util.ILcdFunction, java.awt.Graphics, int, ILcdGXYView)
andapplyOnInteractLabels(com.luciad.util.ILcdFunction, java.awt.Graphics, int, ILcdGXYView)
to determine which objects or labels should be painted. Customizing these methods will also customize the painting behavior.Objects smaller than the set minimum object size may be omitted.
- Specified by:
paint
in interfaceILcdGXYEditableLabelsLayer
- Specified by:
paint
in interfaceILcdGXYLayer
- Parameters:
aGraphics
- the Graphics to paint on.aMode
- indicates what should be painted and how it should be painted.aGXYView
- the view to paint for.- See Also:
-
setVisible
public void setVisible(boolean aVisible) Description copied from interface:ILcdLayer
Sets whether or not the layer's content is painted.- Specified by:
setVisible
in interfaceILcdLayer
- Overrides:
setVisible
in classTLcdLayer
- Parameters:
aVisible
-true
if the layer should be visible,false
otherwise.- See Also:
-
startPainting
protected final void startPainting()Indicates that rendering should no longer be stopped. Note that this is automatically done for each repaint.- See Also:
-
stopPainting
public void stopPainting()Inform the layer that it should terminate the current paint operation. This method can be useful when the paint method is executed in a specificThread
and needs to be stopped in a safe state from another Thread.- Specified by:
stopPainting
in interfaceILcdGXYLayer
- See Also:
-
isStopPainting
protected final boolean isStopPainting()Returns whether painting of the layer should be stopped. This value can only be set by calling the methodstopPainting()
or the methodstartPainting()
The value of this property is checked when starting to paint:- the objects of the model,
- the labels of the objects of the model,
- the selected objects of the layer.
- Returns:
- whether painting of the layer should be stopped
- See Also:
-
paintFromModel
protected void paintFromModel(Graphics aGraphics, int aMode, ILcdModel aModel, ILcdGXYContext aGXYContext) Paints the objects in the passed model by iterating over all the model's objects, in the order determined by the model.- Parameters:
aGraphics
- the graphics to paint onaMode
- seeILcdGXYLayer.paint
.aModel
- seegetModel()
aGXYContext
- theILcdGXYContext
to consider for painting.
-
paintFromOverlaps
protected void paintFromOverlaps(Graphics aGraphics, int aMode, ILcd2DBoundsIndexedModel a2DBoundsIndexedModel, ILcdGXYContext aGXYContext) Paints the objects in the passed model by applying a painting function to allObject
of theILcd2DBoundsIndexedModel
that interact with the view clip. The paint order is determined by the model.- Parameters:
aGraphics
- the graphics to paint onaMode
- seeILcdGXYLayer.paint
.a2DBoundsIndexedModel
- the model to paintaGXYContext
- theILcdGXYContext
to consider for painting.
-
modeToString
Utility method that provides a human readable form of the layer mode.- Parameters:
aMode
- a combination of the constants ILcdGXYLayer.BODIES, ILcdGXYLayer.LABELS, ILcdGXYLayer.HANDLES and ILcdGXYLayer.SELECTION- Returns:
- a human readable form of the layer mode passed.
-