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
getBoundsand 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 sizecan 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 intervalcan 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
ConstructorsConstructorDescriptionConstructs 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 intapplyOnInteract(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.intapplyOnInteract(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.intapplyOnInteract(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.intapplyOnInteractLabels(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 ILcdGXYLayerFactoryasFactory(Predicate<ILcdModel> aAcceptableModel, Consumer<TLcdGXYLayer> aPostConstructCustomization) Creates a layer factory that createsTLcdGXYLayerinstances 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 TLcdGXYLayerCreates 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 thisILcdGXYLayercontent, the bounds of all the drawings (for the supplied mode) that represent the Objects contained in theILcdModelof thisILcdGXYLayer.getGXYEditor(Object aObject) Returns the editor to use to modify the object via a view.Gets the currentILcdGXYEditorProviderattached to thisTLcdGXYLayer.getGXYLabelEditor(Object aObject) Retrieves the label editor for the given object.Gets the currentILcdGXYLabelEditorProviderattached 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 currentILcdGXYLabelPainterProviderattached to thisTLcdGXYLayer.getGXYPainter(Object aObject) Returns the painter to use to render the object in a view.Returns the currentILcdGXYPainterProviderattached 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.intReturns the largest possible difference (in pixels) between an object's model bounds and its representation.Returns theALcdLabelLocationsinstance 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.doubleReturns 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.booleanReturnstrueif the layer supports editing its objects.booleanReturns whether objects should be represented as text.booleanReturns whether this layer supports representing objects as text.booleanThis flag determines if the labels are editable, i.e. if they can be moved by the user.booleanThis property determines whether the layer is equipped to let the user edit the labels.booleanbooleanReturns whether selected objects are labeled whenisLabeled()returns false.protected final booleanReturns whether painting of the layer should be stopped.booleanDeprecated.This method has been deprecated.static StringmodeToString(int aMode) Utility method that provides a human readable form of the layer mode.voidpaint(Graphics aGraphics, int aMode, ILcdGXYView aGXYView) Paints the combined representation of the layer's objects for a view, taking into account the mode.protected voidpaintFromModel(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 voidpaintFromOverlaps(Graphics aGraphics, int aMode, ILcd2DBoundsIndexedModel a2DBoundsIndexedModel, ILcdGXYContext aGXYContext) Paints the objects in the passed model by applying a painting function to allObjectof theILcd2DBoundsIndexedModelthat interact with the view clip.static voidsetClassTraceOn(boolean aClassTraceOn) Deprecated.This method has been deprecated.voidsetFilter(ILcdFilter aFilter) Sets theILcdFilterto filter theObjecton thisILcdLayer.voidsetGXYEditorProvider(ILcdGXYEditorProvider aGXYEditorProvider) Sets anILcdGXYEditorProviderto thisTLcdGXYLayer.voidsetGXYLabelEditorProvider(ILcdGXYLabelEditorProvider aGXYLabelEditorProvider) Sets anILcdGXYLabelEditorProviderto thisTLcdGXYLayer.voidsetGXYLabelingAlgorithmProvider(ILcdGXYLabelLabelingAlgorithmProvider aGXYLabelingAlgorithmProvider) Configures the given labeling algorithm provider responsible for determining the position of the labels.voidsetGXYLabelPainterProvider(ILcdGXYLabelPainterProvider aGXYLabelPainterProvider) Sets anILcdGXYLabelPainterProviderto thisTLcdGXYLayer.voidsetGXYLayerLabelPainter(ILcdGXYLayerLabelPainter aGXYLayerLabelPainter) Deprecated.label algorithm providers offer more flexibility for labelingvoidsetGXYPainterProvider(ILcdGXYPainterProvider aGXYPainterProvider) Sets anILcdGXYPainterProviderto thisTLcdGXYLayer.voidsetGXYPainterProviderArray(ILcdGXYPainterProvider[] aGXYPainterProviderArray) Like,setGXYPainterProvider(com.luciad.view.gxy.ILcdGXYPainterProvider), but sets an array ofILcdGXYPainterProviderto thisTLcdGXYLayer.voidsetGXYPen(ILcdGXYPen aGXYPen) Sets the pen to use to perform basic rendering operations.voidSets a visual indication of the contents of this layer.voidsetInteractMargin(int aInteractMargin) Sets the largest possible difference (in pixels) between an object's model bounds and its representation.voidsetLabeled(boolean aLabeled) Sets whether objects should be represented as text.voidsetLabelLocations(ALcdLabelLocations aLabelLocations) Sets theALcdLabelLocationsused by this layer to store the locations of all labels, and which labels are painted.voidsetLabelMapScaleRange(TLcdDimensionInterval<TLcdMapScale> aLabelMapScaleRange) Sets the map scale range for which to paint labels for the elements of the model.voidsetLabelScaleRange(ILcdInterval aNewLabelScaleRange) Sets the scale range in which thisILcdGXYLayerwill paint the labels of its elements if they have to be drawn at all.voidsetLabelsEditable(boolean aLabelsEditable) This flag determines if the labels are editable, i.e. if they can be moved by the user.voidsetMapScaleRange(TLcdDimensionInterval<TLcdMapScale> aMapScaleRange) Sets the map scale range for which to paint the elements of the model.voidsetMinimumObjectSizeForPainting(double aMinimumObjectSizeForPainting) Sets the minimum size of an object in the view for it to be painted and handled otherwise.voidSets theILcdModelto thisILcdLayer.voidsetModelElementComparator(Comparator<Object> aObjectElementComparator) Sets a comparator on this layer that defines an order between object elements.final voidsetModelQueryConfiguration(TLcdModelQueryConfiguration aModelQueryConfiguration) Sets the model query configuration which defines the filters to query the model with during a paint operation.voidsetModelXYWorldTransfoClass(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.voidsetPaintFromOverlaps(boolean aNewPaintFromOverlaps) Sets whether thepaintmethod 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 theILcd2DBoundsIndexedModelinterface.voidsetPaintLabelsScaleRatioInterval(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_LABELSflag.voidsetScaleRange(ILcdInterval aNewScaleRange) Sets the scale range in which thisILcdGXYLayerwill paint its elements.voidsetSelectionLabeled(boolean aNewSelectionLabeled) Sets whether selected objects are labeled whenisLabeled()returns false.voidsetTraceOn(boolean aTraceOn) Deprecated.This method has been deprecated.voidsetVisible(boolean aVisible) Sets whether or not the layer's content is painted.protected final voidIndicates that rendering should no longer be stopped.voidInform 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, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.luciad.view.ILcdLayer
clearSelection, fireCollectedSelectionChanges, getLabel, getModel, isEditable, isSelectable, isSelectableSupported, isVisible, selectObject, setEditable, setLabel, setSelectableMethods inherited from interface com.luciad.util.ILcdPropertyChangeSource
addPropertyChangeListener, removePropertyChangeListenerMethods 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 createsTLcdGXYLayerinstances 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.
nullif aAcceptableModel returnsfalse.- Parameters:
aAcceptableModel- Returnstrueif a layer should be created for this model,falseifnullshould be returned. TheILcdModelto 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);TLcdGXYShapePainterfor styling options, orTLcdGXYImagePainterif 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 istruethen 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 eithertrueorfalseas argument automatically turns off tracing for all other class instances for whichsetTraceOnhas not been called. If the argument isfalsethen only the informative, warning and error log messages are recorded.- Overrides:
setTraceOnin 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.Returnstrueif tracing is enabled for this class. -
setModel
Description copied from class:TLcdLayerSets theILcdModelto 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:
getModelXYWorldTransfoClassin 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:
getGXYPenin 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
ALcdLabelLocationsinstance which contains all the information about the labels of this layer. You can use this instance to retrieve which labelshave been drawnand where these labelsare located.This instance can also be used to
alterthe location of the labels. As this method always returns the same instance, changes made to the returnedALcdLabelLocationsinstance immediately effect all other clients of this layer.If the location of a label is changed, the layer should be invalidated using the
invalidateGXYLayermethod of theILcdGXYView.- Specified by:
getLabelLocationsin interfaceILcdGXYEditableLabelsLayer- Returns:
- The
ALcdLabelLocationsinstance. It never isnull. - See Also:
-
setLabelLocations
Sets theALcdLabelLocationsused 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:
getGXYLabelingAlgorithmin 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 aILcdGXYLabelPainteror which do not pass the filter will not have their labels rendered.- Specified by:
setLabeledin 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:
isLabeledin 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:
isLabeledSupportedin interfaceILcdGXYLayer- Returns:
trueifgetGXYLabelPainterProvider()returns a nonnullvalue,falseotherwise.- 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 aILcdGXYLabelEditoror which do not pass the filter will not have their labels edited.- Specified by:
setLabelsEditablein 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:
isLabelsEditablein interfaceILcdGXYEditableLabelsLayer- Returns:
trueif the labels can be moved and reshaped by the user,falseotherwise.- 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 anILcdGXYLabelEditorfor its objects. This layer supports editing labels when the ILcdGXYLabelEditorProvider is set to a non null value.- Specified by:
isLabelsEditableSupportedin interfaceILcdGXYEditableLabelsLayer- Returns:
trueifgetGXYLabelEditorProvider()returns a nonnullvalue,falseotherwise.- See Also:
-
isEditableSupported
public boolean isEditableSupported()Returnstrueif 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:
isEditableSupportedin interfaceILcdLayer- Overrides:
isEditableSupportedin classTLcdLayer- Returns:
trueifgetGXYEditorProvider()returns a nonnullvalue,falseotherwise.- See Also:
-
setGXYPainterProvider
Sets anILcdGXYPainterProviderto 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 ofILcdGXYPainterProviderto 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 currentILcdGXYPainterProviderattached 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 anILcdGXYEditorProviderto thisTLcdGXYLayer. This allows an eternal entity (for example, anILcdGXYControllerto 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 currentILcdGXYEditorProviderattached to thisTLcdGXYLayer.- Returns:
- the current editor provider
- See Also:
-
getGXYPainter
Description copied from interface:ILcdGXYLayerReturns 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, seesetObjectin ILcdGXYPainter.- Specified by:
getGXYPainterin 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,nullotherwise. 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:ILcdGXYLayerReturns 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, usingsetObjectin ILcdGXYEditor.- Specified by:
getGXYEditorin interfaceILcdGXYLayer- Parameters:
aObject- the object to find an editor for.- Returns:
getGXYEditorProvider.getGXYEditor(aObject)if getGXYEditorProvider returns a non null value,nullotherwise.- See Also:
-
setGXYLabelPainterProvider
Sets anILcdGXYLabelPainterProviderto 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 currentILcdGXYLabelPainterProviderattached to thisTLcdGXYLayer.- Returns:
- the current label painter provider
- See Also:
-
getGXYLabelPainter
Description copied from interface:ILcdGXYLayerReturns 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, seesetObjectin ILcdGXYLabelPainter.- Specified by:
getGXYLabelPainterin interfaceILcdGXYLayer- Parameters:
aObject- the object to find a label painter for.- Returns:
getGXYLabelPainterProvider.getGXYLabelPainter(aObject)if getGXYLabelPainterProvider returns a non null value,nullotherwise. The returned painter is properly initialized to the givenaObject.- See Also:
-
setGXYLabelEditorProvider
Sets anILcdGXYLabelEditorProviderto thisTLcdGXYLayer. This allows an eternal entity (for example, anILcdGXYControllerto 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 currentILcdGXYLabelEditorProviderattached to thisTLcdGXYLayer.- Returns:
- the current label editor provider, or null if there is no label editor provider
- See Also:
-
getGXYLabelEditor
Description copied from interface:ILcdGXYEditableLabelsLayerRetrieves the label editor for the given object. This label editor can be used to move the label foraObjectto a different location.- Specified by:
getGXYLabelEditorin interfaceILcdGXYEditableLabelsLayer- Parameters:
aObject- The object for which to retrieve the label editor. This object should not benulland should be contained in the model of this layer.- Returns:
getGXYLabelEditorProvider.getGXYLabelEditor(aObject)if getGXYLabelEditorProvider returns a non null value,nullotherwise. The returned painter is properly initialized to the givenaObject.- See Also:
-
getIcon
Description copied from interface:ILcdLayerReturns 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:ILcdLayerSets a visual indication of the contents of this layer. -
setPaintFromOverlaps
public void setPaintFromOverlaps(boolean aNewPaintFromOverlaps) Sets whether thepaintmethod 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 theILcd2DBoundsIndexedModelinterface.- 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,falseif 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 thisILcdGXYLayerwill paint its elements. The paint method of anILcdGXYLayershall 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 rangeinstead.
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 rangeinstead. This property is mutually exclusive with the map scale range: only one of them has a non-nullvalue.- Specified by:
getScaleRangein interfaceILcdGXYLayer- Returns:
- an
ILcdIntervalcontaining the minimum and maximum value of view scales for which objects should be rendered, excluding the maximum.nullif 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 thisILcdGXYLayerwill paint the labels of its elements if they have to be drawn at all. The paint method of anILcdGXYLayershall 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 rangeinstead.- Parameters:
aNewLabelScaleRange- the new label scale range, in toolkit pixels/world unit, ornullto 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 rangeinstead. This property is mutually exclusive with the label map scale range: only one of them has a non-nullvalue.- Specified by:
getLabelScaleRangein interfaceILcdGXYLayer- Returns:
- an
ILcdIntervalcontaining the minimum and maximum value of view scales for which labels should be rendered, excluding the maximum.nullif the scale constraints are determined byILcdGXYLayer.getLabelMapScaleRange()The scales are expressed in toolkit pixels/world unit. - See Also:
-
getMapScaleRange
Description copied from interface:ILcdGXYLayerReturns 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-nullvalue.- Specified by:
getMapScaleRangein interfaceILcdGXYLayer- Returns:
- the minimum and maximum value of view scales for which objects should be rendered,
or
nullif 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, ornullto disable any scale constraints- Since:
- 2021.0
-
getLabelMapScaleRange
Description copied from interface:ILcdGXYLayerReturns 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 rangeand 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-nullvalue.- Specified by:
getLabelMapScaleRangein interfaceILcdGXYLayer- Returns:
- the minimum and maximum value of map scales for which object labels should be rendered,
or
nullif 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 rangeand 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_LABELSflag.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 thisILcdGXYLayercontent, the bounds of all the drawings (for the supplied mode) that represent the Objects contained in theILcdModelof thisILcdGXYLayer. For this operation, thisILcdGXYLayeris 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:
getBoundsin interfaceILcdGXYLayer- Parameters:
aMode- a bitwise combination of ALL or SELECTION and one or more of BODIES and HANDLES. TheILcdGXYLayer.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.- 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
truefor 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:
applyOnInteractin 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, theILcdFunctionshall 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:ILcdGXYEditableLabelsLayerApplies 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
truefor 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:
applyOnInteractin 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:ILcdGXYEditableLabelsLayerApplies 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
truefor 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:
applyOnInteractLabelsin 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-nullmodel query configuration- Since:
- 2017.0
-
setFilter
Sets the
ILcdFilterto filter theObjecton 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
nullfilter, 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
painterfor that object, when the LABELS mode is passed, painting shall be delegated to thelabelpainterfor 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
stopPaintingis called, the current painting operation should be aborted.If this layer is asked to paint its labels, it must inform its
ALcdLabelLocationsinstance 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 theALcdLabelLocationsretrieved usingILcdGXYEditableLabelsLayer.getLabelLocations().This implementation calls
paintFromOverlapsorpaintFromModel, depending on whetherisPaintFromOverlaps()returnstrueorfalse.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:
paintin interfaceILcdGXYEditableLabelsLayer- Specified by:
paintin 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:ILcdLayerSets whether or not the layer's content is painted.- Specified by:
setVisiblein interfaceILcdLayer- Overrides:
setVisiblein classTLcdLayer- Parameters:
aVisible-trueif the layer should be visible,falseotherwise.- 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 specificThreadand needs to be stopped in a safe state from another Thread.- Specified by:
stopPaintingin 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- theILcdGXYContextto 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 allObjectof theILcd2DBoundsIndexedModelthat 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- theILcdGXYContextto 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.
-