Class TLcdGXYAsynchronousEditableLabelsLayerWrapper

java.lang.Object
com.luciad.view.gxy.asynchronous.TLcdGXYAsynchronousLayerWrapper
com.luciad.view.gxy.asynchronous.TLcdGXYAsynchronousEditableLabelsLayerWrapper
All Implemented Interfaces:
ILcdPropertyChangeSource, ILcdSelection<Object>, ILcdGXYAsynchronousLayerWrapper, ILcdGXYEditableLabelsLayer, ILcdGXYLayer, ILcdLayer, Serializable
Direct Known Subclasses:
TLcdGXYAsynchronousEditableLabelsLayerTreeNodeWrapper

public class TLcdGXYAsynchronousEditableLabelsLayerWrapper extends TLcdGXYAsynchronousLayerWrapper implements ILcdGXYEditableLabelsLayer
Implementation of ILcdGXYAsynchronousLayerWrapper for ILcdGXYEditableLabelsLayer instances, wrapping and protecting the latter interface's state. It manages label positions for asynchronous painting, in order to keep them consistent in between the layer and its asynchronous wrapper.

This wrapper does not support labels produced by ALcdGXYInteractiveLabelProvider.

Since:
7.2
See Also:
  • Constructor Details

    • TLcdGXYAsynchronousEditableLabelsLayerWrapper

      public TLcdGXYAsynchronousEditableLabelsLayerWrapper(ILcdGXYEditableLabelsLayer aDecoratedLayer)
      Creates a layer decorator that delegates painting to an asynchronous paint queue. This behavior is triggered for the first view that paints the layer. After construction, a paint queue must be set using setGXYAsynchronousPaintQueue(ILcdGXYAsynchronousPaintQueue)
      Parameters:
      aDecoratedLayer - the layer to decorate. The layer is automatically redrawn if the model changes.
    • TLcdGXYAsynchronousEditableLabelsLayerWrapper

      public TLcdGXYAsynchronousEditableLabelsLayerWrapper(ILcdGXYEditableLabelsLayer aDecoratedLayer, ILcdGXYAsynchronousPaintQueue aPaintQueue)
      Creates a layer decorator that delegates painting to an asynchronous paint queue. This behavior is triggered for the first view that paints the layer. After construction, a paint queue must be set using setGXYAsynchronousPaintQueue(ILcdGXYAsynchronousPaintQueue)
      Parameters:
      aDecoratedLayer - the layer to decorate. The layer is automatically redrawn if the model changes.
      aPaintQueue - the paint queue to delegate paint calls to
  • Method Details

    • getSynchronousGXYLayerChangeTracker

      public ILcdGXYLayerChangeTracker getSynchronousGXYLayerChangeTracker()
      Description copied from interface: ILcdGXYAsynchronousLayerWrapper
      Returns a state change synchronizer for this wrapper. The wrapper's changes will be applied to the wrapped layer before each asynchronous paint, using the asynchronous wrapper.
      Specified by:
      getSynchronousGXYLayerChangeTracker in interface ILcdGXYAsynchronousLayerWrapper
      Overrides:
      getSynchronousGXYLayerChangeTracker in class TLcdGXYAsynchronousLayerWrapper
      Returns:
      a synchronizer tracking changes for this wrapper. To protect this wrapper's state, the tracker should only be used in the synchronous thread, i.e. the event dispatch thread.
    • getAsynchronousGXYLayerChangeTracker

      public ILcdGXYLayerChangeTracker getAsynchronousGXYLayerChangeTracker()
      Description copied from interface: ILcdGXYAsynchronousLayerWrapper
      Returns a state change synchronizer for the wrapped layer. The changes will be applied after each asynchronous paint, using the synchronous tracker.
      Specified by:
      getAsynchronousGXYLayerChangeTracker in interface ILcdGXYAsynchronousLayerWrapper
      Overrides:
      getAsynchronousGXYLayerChangeTracker in class TLcdGXYAsynchronousLayerWrapper
      Returns:
      a synchronizer tracking changes for the wrapped layer. To protect the wrapped layer's state, the tracker should only be used in the asynchronous thread, i.e. the paint thread.
    • setAsynchronous

      public void setAsynchronous(boolean aAsynchronous) throws InterruptedException
      Description copied from interface: ILcdGXYAsynchronousLayerWrapper
      Disables or enables the asynchronous drawing.
      Specified by:
      setAsynchronous in interface ILcdGXYAsynchronousLayerWrapper
      Overrides:
      setAsynchronous in class TLcdGXYAsynchronousLayerWrapper
      Parameters:
      aAsynchronous - if false, paints synchronously, if true, paints asynchronously
      Throws:
      InterruptedException - when the thread is interrupted while waiting for the asynchronous paint to complete
    • paint

      public void paint(Graphics aGraphics, int aMode, ILcdGXYView aGXYView)
      Description copied from class: TLcdGXYAsynchronousLayerWrapper
      Paints the layer asynchronously or synchronously, depending on isAsynchronous. Asynchronous painting is delegated to the layer's paint queue.
      Specified by:
      paint in interface ILcdGXYEditableLabelsLayer
      Specified by:
      paint in interface ILcdGXYLayer
      Overrides:
      paint in class TLcdGXYAsynchronousLayerWrapper
      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:
    • setGXYAsynchronousPaintQueue

      public void setGXYAsynchronousPaintQueue(ILcdGXYAsynchronousPaintQueue aQueue)
      Description copied from interface: ILcdGXYAsynchronousLayerWrapper
      Sets the paint queue to delegate asynchronous paint requests to. Paint queues can be shared between multiple layer wrappers. This is even advised, as each paint queue uses memory for buffering the asynchronously generated images.
      Specified by:
      setGXYAsynchronousPaintQueue in interface ILcdGXYAsynchronousLayerWrapper
      Overrides:
      setGXYAsynchronousPaintQueue in class TLcdGXYAsynchronousLayerWrapper
      Parameters:
      aQueue - the asynchronous paint queue responsible for executing the paint calls.
    • getGXYLabelingAlgorithm

      public ILcdGXYLabelingAlgorithm getGXYLabelingAlgorithm(TLcdLabelIdentifier aLabel)
      Returns a clone of the wrapped layer's ILcdGXYLabelingAlgorithm, or the algorithm itself if the associated paint queue is empty.
      Specified by:
      getGXYLabelingAlgorithm in interface ILcdGXYEditableLabelsLayer
      Parameters:
      aLabel - the identifier defining the label and its associated domain object
      Returns:
      the label algorithm, or null to rely on the label painter
      See Also:
    • getGXYLabelEditor

      public ILcdGXYLabelEditor getGXYLabelEditor(Object aObject)
      Returns a clone of the wrapped layer's GXYLabelEditor, or the editor itself if the associated paint queue is empty.
      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:
      The editor for aObject. This editor should already have aObject set on it. The TLcdLabelLocation however still needs to be set.
      See Also:
    • getLabelLocations

      public ALcdLabelLocations getLabelLocations()
      Description copied from interface: ILcdGXYEditableLabelsLayer

      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:
    • isLabelsEditableSupported

      public boolean isLabelsEditableSupported()
      Description copied from interface: ILcdGXYEditableLabelsLayer
      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.
      Specified by:
      isLabelsEditableSupported in interface ILcdGXYEditableLabelsLayer
      Returns:
      true if the layer is equipped with label editors, false otherwise.
      See Also:
    • isLabelsEditable

      public boolean isLabelsEditable()
      Description copied from interface: ILcdGXYEditableLabelsLayer
      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:
    • setLabelsEditable

      public void setLabelsEditable(boolean aLabelsEditable)
      Description copied from interface: ILcdGXYEditableLabelsLayer
      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:
      setLabelsEditable in interface ILcdGXYEditableLabelsLayer
      Parameters:
      aLabelsEditable - true if you want the user to be able to move and reshape the labels, false otherwise.
      See Also:
    • 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.