Class TLcdGXYLayer

java.lang.Object
com.luciad.view.TLcdLayer
com.luciad.view.gxy.TLcdGXYLayer
All Implemented Interfaces:
ILcdPropertyChangeSource, ILcdSelection<Object>, ILcdGXYEditableLabelsLayer, ILcdGXYLayer, ILcdLayer, Serializable
Direct Known Subclasses:
TLcdGXYLayerTreeNode, TLcdKML22GXYLayer, TLcdPOLLayer, TLcdS52GXYCatalogueLayer, TLcdS52GXYLayer, TLcdVPFLayer, TLcdWMSProxyGXYLayer, TLfnGXYVectorLayer

public class TLcdGXYLayer extends TLcdLayer implements ILcdGXYEditableLabelsLayer
Default implementation of the 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 in ILcdGXYLayer, 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 used ILcdGXYEditor 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 the applyOnInteract* 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 in ILcdGXYEditableLabelsLayer.
  • 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 the applyOnInteract* 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 labeled
  • setModelElementComparator(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:
  • 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 also create(ILcdModel).
    • TLcdGXYLayer

      public TLcdGXYLayer(ILcdModel aModel)
      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 also create(ILcdModel), which in addition sets a sensible default pen.
      Parameters:
      aModel - the model to visualize. Never null.
    • TLcdGXYLayer

      public TLcdGXYLayer(String aLabel)
      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 also create(ILcdModel).
      Parameters:
      aLabel - a textual representation of this layer.
    • TLcdGXYLayer

      public TLcdGXYLayer(ILcdModel aModel, String aLabel)
      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 also create(ILcdModel).
      Parameters:
      aModel - contains the objects that should be rendered in this layer.
      aLabel - a textual representation of this layer.
    • TLcdGXYLayer

      public TLcdGXYLayer(String aLabel, ILcdGXYPen aGXYPen)
      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 also create(ILcdModel).
      Parameters:
      aLabel - a textual representation of this layer.
      aGXYPen - the pen to use to render basic geometries (lines, points, arcs).
    • TLcdGXYLayer

      public TLcdGXYLayer(ILcdModel aModel, String aLabel, ILcdGXYPen aGXYPen)
      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 also create(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 creates TLcdGXYLayer instances that are already partially initialized: It offers a hook for further customization, such as setting a painter with custom styling. It returns null if aAcceptableModel returns false.
      Parameters:
      aAcceptableModel - Returns true if a layer should be created for this model, false if null should be returned. The ILcdModel to test is never null.
      aPostConstructCustomization - Callback to do further customization. For example layer -> layer.setGXYPainterProvider(myPainter)
      Returns:
      The layer factory.
      Since:
      2017.0
    • create

      public static TLcdGXYLayer create(ILcdModel aModel)
      Creates a layer that is already partially initialized: The layer can be further customized after it is created, for example by setting a painter:
      
         TLcdGXYLayer layer = TLcdGXYLayer.create(aModel);
         layer.setGXYPainterProvider(myPainter);
       
      See also TLcdGXYShapePainter for styling options, or TLcdGXYImagePainter 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 is true 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 either true or false as argument automatically turns off tracing for all other class instances for which setTraceOn has not been called. If the argument is false then only the informative, warning and error log messages are recorded.
      Overrides:
      setTraceOn in class TLcdLayer
      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.
      Returns true if tracing is enabled for this class.
      Overrides:
      isTraceOn in class TLcdLayer
      Returns:
      true if tracing is enabled for this class, false otherwise.
    • setModel

      public void setModel(ILcdModel aModel)
      Description copied from class: TLcdLayer
      Sets the ILcdModel to this ILcdLayer.
      Overrides:
      setModel in class TLcdLayer
      Parameters:
      aModel - the model that contains the objects that should be displayed in this layer.
    • setModelXYWorldTransfoClass

      public 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. 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 interface ILcdModelXYWorldTransformation.
      See Also:
    • getModelXYWorldTransfoClass

      public Class 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 interface ILcdGXYLayer
      Returns:
      the transformation class that to use to transform points and bounds from model space to world space and back.
      See Also:
    • getGXYPen

      public ILcdGXYPen getGXYPen()
      Returns the pen to use when performing basic painting operations for objects in this layers model.
      Specified by:
      getGXYPen in interface ILcdGXYLayer
      Returns:
      the pen to use when performing basic painting operations for objects in this layers model.
      See Also:
    • setGXYPen

      public void setGXYPen(ILcdGXYPen aGXYPen)
      Sets the pen to use to perform basic rendering operations. The default value is a TLcdGXYPen.
      Parameters:
      aGXYPen - the pen to use to perform basic rendering.
      See Also:
    • getLabelLocations

      public ALcdLabelLocations getLabelLocations()

      Returns the ALcdLabelLocations instance which contains all the information about the labels of this layer. You can use this instance to retrieve which labels have been drawn and where these labels are 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 returned ALcdLabelLocations 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 the ILcdGXYView.

      Specified by:
      getLabelLocations in interface ILcdGXYEditableLabelsLayer
      Returns:
      The ALcdLabelLocations instance. It never is null.
      See Also:
    • setLabelLocations

      public void setLabelLocations(ALcdLabelLocations aLabelLocations)
      Sets the ALcdLabelLocations used by this layer to store the locations of all labels, and which labels are painted.
      Parameters:
      aLabelLocations - The ALcdLabelLocations.
      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 during applyOnInteract (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 (if setPaintFromOverlaps(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 (if setPaintFromOverlaps(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

      public void setGXYLayerLabelPainter(ILcdGXYLayerLabelPainter aGXYLayerLabelPainter)
      Deprecated.
      label algorithm providers offer more flexibility for labeling
      Sets 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 mode ILcdGXYLayer.LABELS, and only the labels marked in the label locations when used with painting mode ILcdGXYEditableLabelsLayer.PLACED_LABELS.
      Parameters:
      aGXYLayerLabelPainter - a layer label painter to declutter labels.
      See Also:
    • getGXYLayerLabelPainter

      public ILcdGXYLayerLabelPainter getGXYLayerLabelPainter()
      Returns:
      the layer label painter of this layer, or null if there is no layer label painter
      See Also:
    • getGXYLabelingAlgorithm

      public ILcdGXYLabelingAlgorithm getGXYLabelingAlgorithm(TLcdLabelIdentifier aLabel)
      Returns the label algorithm to use for the given label ID. This implementation relies on the configured label algorithm provider.
      Specified by:
      getGXYLabelingAlgorithm in interface ILcdGXYEditableLabelsLayer
      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 as ILcdGXYLayer.isLabeledSupported() returns false. Objects for which the GXYLabelPainterProvider does not return a ILcdGXYLabelPainter or which do not pass the filter will not have their labels rendered.
      Specified by:
      setLabeled in interface ILcdGXYLayer
      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 when ILcdGXYLayer.isLabeledSupported() returns false.
      Specified by:
      isLabeled in interface ILcdGXYLayer
      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 interface ILcdGXYLayer
      Returns:
      true if getGXYLabelPainterProvider() returns a non null 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 a ILcdGXYLabelEditor or which do not pass the filter will not have their labels edited.
      Specified by:
      setLabelsEditable in interface ILcdGXYEditableLabelsLayer
      Parameters:
      aLabelsEditable - true to allow editing labels for all objects in the model for which the ILcdGXYLabelEditorProvider returns a ILcdGXYLabelEditor. 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 interface ILcdGXYEditableLabelsLayer
      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 an ILcdGXYLabelEditor for its objects. This layer supports editing labels when the ILcdGXYLabelEditorProvider is set to a non null value.
      Specified by:
      isLabelsEditableSupported in interface ILcdGXYEditableLabelsLayer
      Returns:
      true if getGXYLabelEditorProvider() returns a non null value, false otherwise.
      See Also:
    • isEditableSupported

      public boolean isEditableSupported()
      Returns true 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 interface ILcdLayer
      Overrides:
      isEditableSupported in class TLcdLayer
      Returns:
      true if getGXYEditorProvider() returns a non null value, false otherwise.
      See Also:
    • setGXYPainterProvider

      public void setGXYPainterProvider(ILcdGXYPainterProvider aGXYPainterProvider)
      Sets an ILcdGXYPainterProvider to this TLcdGXYLayer. 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 method TLcdLayer.firePropertyChangeEvent(java.beans.PropertyChangeEvent).

      Parameters:
      aGXYPainterProvider - the new painter provider
      See Also:
    • setGXYPainterProviderArray

      public void setGXYPainterProviderArray(ILcdGXYPainterProvider[] aGXYPainterProviderArray)
      Like, setGXYPainterProvider(com.luciad.view.gxy.ILcdGXYPainterProvider), but sets an array of ILcdGXYPainterProvider to this TLcdGXYLayer. 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

      public ILcdGXYPainterProvider getGXYPainterProvider()
      Returns the current ILcdGXYPainterProvider attached to this TLcdGXYLayer.
      Returns:
      the current painter provider
      See Also:
    • getGXYPainterProviderArray

      public ILcdGXYPainterProvider[] getGXYPainterProviderArray()
      Returns an array containing all painter providers for this layer
      Returns:
      all painter providers for this layer
      See Also:
    • setGXYEditorProvider

      public void setGXYEditorProvider(ILcdGXYEditorProvider aGXYEditorProvider)
      Sets an ILcdGXYEditorProvider to this TLcdGXYLayer. This allows an eternal entity (for example, an ILcdGXYController 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 an ILcdGXYEditor. 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

      public ILcdGXYEditorProvider getGXYEditorProvider()
      Gets the current ILcdGXYEditorProvider attached to this TLcdGXYLayer.
      Returns:
      the current editor provider
      See Also:
    • getGXYPainter

      public ILcdGXYPainter getGXYPainter(Object aObject)
      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, see setObject in ILcdGXYPainter.
      Specified by:
      getGXYPainter in interface ILcdGXYLayer
      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 given aObject.
      See Also:
    • getGXYPainters

      public Enumeration getGXYPainters(Object aObject)
      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

      public ILcdGXYEditor getGXYEditor(Object aObject)
      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, using setObject in ILcdGXYEditor.
      Specified by:
      getGXYEditor in interface ILcdGXYLayer
      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

      public void setGXYLabelPainterProvider(ILcdGXYLabelPainterProvider aGXYLabelPainterProvider)
      Sets an ILcdGXYLabelPainterProvider to this TLcdGXYLayer. 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

      public ILcdGXYLabelPainterProvider getGXYLabelPainterProvider()
      Gets the current ILcdGXYLabelPainterProvider attached to this TLcdGXYLayer.
      Returns:
      the current label painter provider
      See Also:
    • getGXYLabelPainter

      public ILcdGXYLabelPainter getGXYLabelPainter(Object aObject)
      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, see setObject in ILcdGXYLabelPainter.
      Specified by:
      getGXYLabelPainter in interface ILcdGXYLayer
      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 given aObject.
      See Also:
    • setGXYLabelEditorProvider

      public void setGXYLabelEditorProvider(ILcdGXYLabelEditorProvider aGXYLabelEditorProvider)
      Sets an ILcdGXYLabelEditorProvider to this TLcdGXYLayer. This allows an eternal entity (for example, an ILcdGXYController 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

      public ILcdGXYLabelLabelingAlgorithmProvider 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

      public ILcdGXYLabelEditorProvider getGXYLabelEditorProvider()
      Gets the current ILcdGXYLabelEditorProvider attached to this TLcdGXYLayer.
      Returns:
      the current label editor provider, or null if there is no label editor provider
      See Also:
    • getGXYLabelEditor

      public ILcdGXYLabelEditor getGXYLabelEditor(Object aObject)
      Description copied from interface: ILcdGXYEditableLabelsLayer
      Retrieves the label editor for the given object. This label editor can be used to move the label for aObject to a different location.
      Specified by:
      getGXYLabelEditor in interface ILcdGXYEditableLabelsLayer
      Parameters:
      aObject - The object for which to retrieve the label editor. This object should not be null 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 given aObject.
      See Also:
    • getIcon

      public ILcdIcon 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.
      Specified by:
      getIcon in interface ILcdLayer
      Overrides:
      getIcon in class TLcdLayer
      Returns:
      a visual indication of the contents of this layer.
    • setIcon

      public void setIcon(ILcdIcon aIcon)
      Description copied from interface: ILcdLayer
      Sets a visual indication of the contents of this layer.
      Specified by:
      setIcon in interface ILcdLayer
      Overrides:
      setIcon in class TLcdLayer
      Parameters:
      aIcon - a visual indication of the contents of this layer.
      See Also:
    • setPaintFromOverlaps

      public void setPaintFromOverlaps(boolean aNewPaintFromOverlaps)
      Sets whether the paint 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 the ILcd2DBoundsIndexedModel interface.
      Parameters:
      aNewPaintFromOverlaps - if true, the paint method uses paintFromOverlaps() for models implementing ILcd2DBoundsIndexedModel. If false, it uses paintFromModel.
      See Also:
    • isPaintFromOverlaps

      public boolean isPaintFromOverlaps()
      Returns:
      true, if the paint method uses paintFromOverlaps() for models implementing ILcd2DBoundsIndexedModel, false if it uses paintFromModel.
      See Also:
    • setModelElementComparator

      public void setModelElementComparator(Comparator<Object> aObjectElementComparator)
      Sets a comparator on this layer that defines an order between object elements. The Comparator.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

      public Comparator getModelElementComparator()
      Returns the comparator that defines an order between object elements.
      Returns:
      the comparator that defines an order between object elements.
      See Also:
    • setScaleRange

      public void setScaleRange(ILcdInterval aNewScaleRange)
      Sets the scale range in which this ILcdGXYLayer will paint its elements. The paint method of an ILcdGXYLayer 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 the unitless 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

      public ILcdInterval 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() or view.getScale() >= getScaleRange().getMax().

      This does not imply that all objects in the model should be painted when the scale is inside this range as other restrictions may apply. For example, a layer may have a filter which defines which objects should be painted.

      For most use cases, we recommended using the unitless map scale range instead. This property is mutually exclusive with the map scale range: only one of them has a non-null value.

      Specified by:
      getScaleRange in interface ILcdGXYLayer
      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 by ILcdGXYLayer.getMapScaleRange(). The scales are expressed in toolkit pixels/world unit.
      See Also:
    • setLabelScaleRange

      public void setLabelScaleRange(ILcdInterval aNewLabelScaleRange)
      Sets the scale range in which this ILcdGXYLayer will paint the labels of its elements if they have to be drawn at all. The paint method of an ILcdGXYLayer 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 the unitless map scale range instead.

      Parameters:
      aNewLabelScaleRange - the new label scale range, in toolkit pixels/world unit, or null 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

      public ILcdInterval 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() or view.getScale() >= getLabelScaleRange().getMax().

      This does not imply that labels for all objects in the model should be painted when the scale is inside this range as other restrictions may apply. For example, a layer may decide not to paint any labels for objects whose body is not painted.

      For most use cases, we recommended using the unitless map scale range instead. This property is mutually exclusive with the label map scale range: only one of them has a non-null value.

      Specified by:
      getLabelScaleRange in interface ILcdGXYLayer
      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 by ILcdGXYLayer.getLabelMapScaleRange() The scales are expressed in toolkit pixels/world unit.
      See Also:
    • getMapScaleRange

      public TLcdDimensionInterval<TLcdMapScale> 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 the toolkit scale range: only one of them has a non-null value.
      Specified by:
      getMapScaleRange in interface ILcdGXYLayer
      Returns:
      the minimum and maximum value of view scales for which objects should be rendered, or null if the scale constraints are determined by ILcdGXYLayer.getScaleRange()
    • setMapScaleRange

      public void setMapScaleRange(TLcdDimensionInterval<TLcdMapScale> aMapScaleRange)
      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, or null to disable any scale constraints
      Since:
      2021.0
    • getLabelMapScaleRange

      public TLcdDimensionInterval<TLcdMapScale> 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 the map scale range and inside the given map label scale range.

      This does not imply that labels for all objects in the model should be painted when the scale is inside this range as other restrictions may apply. For example, a layer may decide not to paint any labels for objects whose body is not painted.

      This property is mutually exclusive with the toolkit label scale range: only one of them has a non-null value.

      Specified by:
      getLabelMapScaleRange in interface ILcdGXYLayer
      Returns:
      the minimum and maximum value of map scales for which object labels should be rendered, or null if the scale constraints are determined by ILcdGXYLayer.getScaleRange()
    • setLabelMapScaleRange

      public void setLabelMapScaleRange(TLcdDimensionInterval<TLcdMapScale> aLabelMapScaleRange)
      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

      public ILcdInterval 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

      public void setPaintLabelsScaleRatioInterval(ILcdInterval aInterval)
      Sets the scale ratio interval in which the placed labels are painted when paint(java.awt.Graphics, int, ILcdGXYView) is called with the ILcdGXYEditableLabelsLayer.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 when isLabeled() returns false.
      Parameters:
      aNewSelectionLabeled - true if selected objects should always be labeled, regardless of isLabeled
      See Also:
    • isSelectionLabeled

      public boolean isSelectionLabeled()
      Returns whether selected objects are labeled when isLabeled() returns false.
      Returns:
      true if selected objects should always be labeled, regardless of isLabeled
      See Also:
    • getBounds

      public ILcdBounds getBounds(int aMode, ILcdGXYView aGXYView) throws TLcdNoBoundsException
      Returns the view bounds of this ILcdGXYLayer content, the bounds of all the drawings (for the supplied mode) that represent the Objects contained in the ILcdModel of this ILcdGXYLayer. For this operation, this ILcdGXYLayer is to be considered as part of aGXYView.

      Outside of the layers bounds no interaction with any object of the layer via its representation is possible. Note that these bounds do not necessarily encompass the representation of all objects in the model, only the objects for which there is a representation in the view.

      Specified by:
      getBounds in interface ILcdGXYLayer
      Parameters:
      aMode - a bitwise combination of ALL or SELECTION and one or more of BODIES and HANDLES. The ILcdGXYLayer.LABELS mode is not supported.
      aGXYView - the view in which the layer could be placed. This enables taking into account the views settings, for example the scale.
      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 interface ILcdGXYLayer
      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 - if true, the ILcdFunction shall be applied only to the objects interacting with the given bounds. When false is passed, other objects may be taken into account too. When applying the function to an object consumes less time than checking whether an objects representation interacts with the bounds, non-strict interaction is generally faster.
      aGXYView - the view in whose bounds the objects representations should be in order to be passed to the function.
      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 interface ILcdGXYEditableLabelsLayer
      Parameters:
      aFunction - the function to apply. When the function returns false, no more objects should be passed to the function.
      aGraphics - the graphics
      aPaintMode - 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 interface ILcdGXYEditableLabelsLayer
      Parameters:
      aLabelFunction - the function to apply. When the function returns false, no more labels should be passed to the function. The Object passed to this function is always a TLcdLabelIdentifier.
      aGraphics - the graphics
      aPaintMode - 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

      public final TLcdModelQueryConfiguration 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

      public final void setModelQueryConfiguration(TLcdModelQueryConfiguration aModelQueryConfiguration)
      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

      public void setFilter(ILcdFilter aFilter)

      Sets the ILcdFilter to filter the Object on this ILcdLayer. 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 is null.

      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.

      Overrides:
      setFilter in class TLcdLayer
      Parameters:
      aFilter - the filter that accepts only those objects that should be taken into account.
      See Also:
    • 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 returns false, no more objects should be passed to the function.
      aGraphics - the graphics
      aPaintMode - 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

      public 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.

      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 the labelpainter for that object.

      The view is passed to provide contextual information: some of the objects may have a different representation depending on the view, or depending on a property of the view, for example, the scale of the view.

      The combined representation of the objects has to be painted on the Graphics supplied, as these may be different from the Graphics provided by the view (due to double buffering, for example).

      When stopPainting is called, the current painting operation should be aborted.

      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 the ALcdLabelLocations retrieved using ILcdGXYEditableLabelsLayer.getLabelLocations().

      This implementation calls paintFromOverlaps or paintFromModel, depending on whether isPaintFromOverlaps() returns true or false.

      This method also calls applyOnInteract(com.luciad.util.ILcdFunction, java.awt.Graphics, int, ILcdGXYView) and applyOnInteractLabels(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 interface ILcdGXYEditableLabelsLayer
      Specified by:
      paint in interface ILcdGXYLayer
      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 interface ILcdLayer
      Overrides:
      setVisible in class TLcdLayer
      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 specific Thread and needs to be stopped in a safe state from another Thread.
      Specified by:
      stopPainting in interface ILcdGXYLayer
      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 method stopPainting() or the method startPainting() 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.
      The value is set to false at the start of every paint call.
      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 on
      aMode - see ILcdGXYLayer.paint.
      aModel - see getModel()
      aGXYContext - the ILcdGXYContext 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 all Object of the ILcd2DBoundsIndexedModel that interact with the view clip. The paint order is determined by the model.
      Parameters:
      aGraphics - the graphics to paint on
      aMode - see ILcdGXYLayer.paint.
      a2DBoundsIndexedModel - the model to paint
      aGXYContext - the ILcdGXYContext to consider for painting.
    • modeToString

      public static String modeToString(int aMode)
      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.