Class ALcdGXYLabelPainter
- All Implemented Interfaces:
ILcdPropertyChangeSource,ILcdGXYLabelPainter,ILcdGXYLabelPainter2,ILcdGXYMultiLabelPainter,Serializable,Cloneable
- Direct Known Subclasses:
TLcdGXYCompositeLabelPainter,TLcdGXYCurvedPathLabelPainter,TLcdGXYLabelPainterAdapter,TLcdGXYOffsetIconPainter,TLcdGXYPolygonStampLabelPainter,TLcdGXYPolylineStampLabelPainter,TLcdGXYStampLabelPainter
This class implements some of the functionality common to most ILcdGXYLabelPainter2s.
It is provided to facilitate the implementation of an ILcdGXYLabelPainter2.
This default implementation assumes a single label and with a single sublabel. Override the
getLabelCount and getSubLabelCount methods to provide support
for multiple labels with multiple sublabels.
- Since:
- 7.0
- See Also:
-
Field Summary
Fields inherited from interface com.luciad.view.gxy.ILcdGXYLabelPainter
DEFAULT, SELECTEDFields inherited from interface com.luciad.view.gxy.ILcdGXYLabelPainter2
BODY, CREATING, HANDLES, RESHAPING, SNAPS, TRANSLATING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPropertyChangeListener(PropertyChangeListener aPropertyChangeListener) Registers the givenPropertyChangeListenerto be notified when this object's properties change.clone()Returns a new instance of thisALcdGXYLabelPainter.protected voidfirePropertyChangeEvent(PropertyChangeEvent aPropertyChangeEvent) Notifies the registeredPropertyChangeListeners of the specified event.This default implementation returns the display name set withsetDisplayName, ortoString()if this was set tonull.intgetLabelCount(Graphics aGraphics, ILcdGXYContext aGXYContext) Return the number of labels for the currently set object.getLabelCursor(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext) Returns aCursorto indicate the type of editingaModeandaGXYContext.intReturns the index of the label that is currently painted or scheduled to paint.Returns theTLcdLabelLocationthat was previously set that contains the information on the whereabouts of the label.intGets the index of location where to paint the label(s) of the set Object.Gets the Object this ILcdGXYLabelPainter can label.intgetSubLabelCount(int aLabelIndex) Returns the number of sublabels for the set object and the given label index.intReturns the index of the sublabel to paint.labelSnapTarget(Graphics aGraphics, ILcdGXYContext aGXYContext) Returns anObjectthat can be used as snapping target when graphically editing anotherObjector label than the one this ILcdGXYLabelPainter2 represents.voidremovePropertyChangeListener(PropertyChangeListener aPropertyChangeListener) De-registers the givenPropertyChangeListenerfrom receiving property change events for this object.voidsetDisplayName(String aDisplayName) Sets the display name for this label painter.voidsetLabelIndex(int aLabelIndex) Sets the label.voidsetLabelLocation(TLcdLabelLocation aLabelLocation) Sets the label location of the label.voidsetLocationIndex(int aLocationIndex) Sets the index of location where to paint the label(s) of the set Object.voidSets the Object to be labeled by this ILcdGXYLabelPainter.voidsetSubLabelIndex(int aSubLabelIndex) Sets the sublabel index.booleansupportLabelSnap(Graphics aGraphics, ILcdGXYContext aGXYContext) Returns whether this label painter supports snapping for the label specified bysetObject,setLabelIndexandsetSubLabelIndex, considering the givenILcdGXYContextinstance.Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.luciad.view.gxy.ILcdGXYLabelPainter
getPossibleLocationCountMethods inherited from interface com.luciad.view.gxy.ILcdGXYLabelPainter2
isLabelTouched, labelAnchorPointSFCT, labelBoundsSFCT, paintLabel
-
Constructor Details
-
ALcdGXYLabelPainter
public ALcdGXYLabelPainter()
-
-
Method Details
-
addPropertyChangeListener
Description copied from interface:ILcdPropertyChangeSourceRegisters the given
PropertyChangeListenerto be notified when this object's properties change.In case you need to register a listener which keeps a reference to an object with a shorter life-time than this change source, you can use a
ALcdWeakPropertyChangeListenerinstance as property change listener.- Specified by:
addPropertyChangeListenerin interfaceILcdPropertyChangeSource- Parameters:
aPropertyChangeListener- The listener to be notified- See Also:
-
removePropertyChangeListener
Description copied from interface:ILcdPropertyChangeSourceDe-registers the given
PropertyChangeListenerfrom receiving property change events for this object.If the listener was added more than once, it will be notified one less time after being removed. If the listener is
null, or was never added, no exception is thrown and no action is taken.- Specified by:
removePropertyChangeListenerin interfaceILcdPropertyChangeSource- Parameters:
aPropertyChangeListener- the listener that should no longer be notified of changes of this object's properties- See Also:
-
firePropertyChangeEvent
Notifies the registeredPropertyChangeListeners of the specified event.- Parameters:
aPropertyChangeEvent- The event describing the property change of which the registered listeners should be notified.- See Also:
-
getLabelLocation
Description copied from interface:ILcdGXYLabelPainter2Returns theTLcdLabelLocationthat was previously set that contains the information on the whereabouts of the label.- Specified by:
getLabelLocationin interfaceILcdGXYLabelPainter2- Returns:
- The label location that was previously set.
- See Also:
-
setLabelLocation
Description copied from interface:ILcdGXYLabelPainter2Sets the label location of the label. This label location will be used to determine what the bounds of the label are, where it must be painted, etc.
Note that
aLabelLocationalso contains a label location index. This is independent of theILcdGXYLabelPainter.getLocationIndex()of the super interface. Contrary to the location index returned bygetLocationIndex, the location index inaLabelLocationcan be less than0, in which case the labels are freely placed.This method has to be called after
ILcdGXYLabelPainter2.setObject(java.lang.Object)has been called, as callingsetObjectclears this label location.- Specified by:
setLabelLocationin interfaceILcdGXYLabelPainter2- Parameters:
aLabelLocation- TheTLcdLabelLocationinstance containing all the information about the location of the label.- See Also:
-
setObject
Description copied from interface:ILcdGXYLabelPainter2Sets the Object to be labeled by this ILcdGXYLabelPainter.Setting the object should set the
TLcdLabelLocationtonull, to ensure that older code which has not been adapted to this new interface keeps working.- Specified by:
setObjectin interfaceILcdGXYLabelPainter- Specified by:
setObjectin interfaceILcdGXYLabelPainter2- Parameters:
aObject- The object to be labeled.- See Also:
-
getObject
Description copied from interface:ILcdGXYLabelPainterGets the Object this ILcdGXYLabelPainter can label.- Specified by:
getObjectin interfaceILcdGXYLabelPainter- Returns:
- the Object this ILcdGXYLabelPainter can label.
- See Also:
-
getLabelCount
Return the number of labels for the currently set object. The default implementation returns
1. Override this method if you need to support multiple labels.- Specified by:
getLabelCountin interfaceILcdGXYMultiLabelPainter- Parameters:
aGraphics- TheGraphicsinstance on which the labels would be painted.aGXYContext- The context containing information about the layer and the view for which the label would be drawn.- Returns:
- The number of labels for the set object. This should be greater than
0.
-
setLabelIndex
public void setLabelIndex(int aLabelIndex) Description copied from interface:ILcdGXYMultiLabelPainterSets the label. The results of any subsequent method calls to
ILcdGXYLabelPainter.paintLabel(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)andILcdGXYLabelPainter.labelBoundsSFCT(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext, java.awt.Rectangle)etc. will apply to the label and sublabel indicated by this label index.- Specified by:
setLabelIndexin interfaceILcdGXYMultiLabelPainter- Parameters:
aLabelIndex- The label index. This should be larger than or equal to0and less than the resultILcdGXYMultiLabelPainter.getLabelCount(java.awt.Graphics, com.luciad.view.gxy.ILcdGXYContext).- See Also:
-
getLabelIndex
public int getLabelIndex()Description copied from interface:ILcdGXYMultiLabelPainterReturns the index of the label that is currently painted or scheduled to paint.- Specified by:
getLabelIndexin interfaceILcdGXYMultiLabelPainter- Returns:
- the index of the label that is currently painted or scheduled to paint.
- See Also:
-
getSubLabelCount
public int getSubLabelCount(int aLabelIndex) Returns the number of sublabels for the set object and the given label index. The default implementation returns
1. Override this method if you need to support multiple sublabels.- Specified by:
getSubLabelCountin interfaceILcdGXYMultiLabelPainter- Parameters:
aLabelIndex- The label index for which you need to know the number of sublabels.- Returns:
- The number of sublabels. This should be greater than
0. - See Also:
-
setSubLabelIndex
public void setSubLabelIndex(int aSubLabelIndex) Description copied from interface:ILcdGXYMultiLabelPainterSets the sublabel index. The results of any subsequent method calls toILcdGXYLabelPainter.paintLabel(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)andILcdGXYLabelPainter.labelBoundsSFCT(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext, java.awt.Rectangle)etc. will apply to the label and sublabel indicated by this sublabel index.- Specified by:
setSubLabelIndexin interfaceILcdGXYMultiLabelPainter- Parameters:
aSubLabelIndex- The sub label index. This should be larger than or equal to0and less than the resultILcdGXYMultiLabelPainter.getSubLabelCount(int).- See Also:
-
getSubLabelIndex
public int getSubLabelIndex()Description copied from interface:ILcdGXYMultiLabelPainterReturns the index of the sublabel to paint.- Specified by:
getSubLabelIndexin interfaceILcdGXYMultiLabelPainter- Returns:
- the index of the sublabel to paint.
- See Also:
-
setLocationIndex
public void setLocationIndex(int aLocationIndex) Description copied from interface:ILcdGXYLabelPainterSets the index of location where to paint the label(s) of the set Object.- Specified by:
setLocationIndexin interfaceILcdGXYLabelPainter- Parameters:
aLocationIndex- the index of the location. Must be between 0 and getPossibleLocationCount() - 1.- See Also:
-
getLocationIndex
public int getLocationIndex()Description copied from interface:ILcdGXYLabelPainterGets the index of location where to paint the label(s) of the set Object.- Specified by:
getLocationIndexin interfaceILcdGXYLabelPainter- Returns:
- the index of the position. Must be between 0 and getPossibleLocationCount() - 1.
- See Also:
-
clone
Returns a new instance of thisALcdGXYLabelPainter. The label location of the clone is a clone of the label location of the original. No other objects are cloned.- Specified by:
clonein interfaceILcdGXYLabelPainter- Specified by:
clonein interfaceILcdGXYLabelPainter2- Overrides:
clonein classObject- Returns:
- A new instance of this
ALcdGXYLabelPainterof which the label location is a deep clone.
-
getLabelCursor
Returns aCursorto indicate the type of editingaModeandaGXYContext.This default implementation always returns
null. Override this method if you want to display custom cursors.- Specified by:
getLabelCursorin interfaceILcdGXYLabelPainter2- Parameters:
aGraphics- TheGraphicsinstance on which the label is painted.aMode- The mode to consider. SeeILcdGXYLabelPainter2.paintLabel(java.awt.Graphics, int, ILcdGXYContext)for more information.aGXYContext- TheILcdGXYContextcontaining extra information, such as the layer, the view and the mouse position.- Returns:
- a
Cursorto indicate the type of editingaModeandaGXYContext. Returnsnullif no particularCursoris required.
-
supportLabelSnap
Returns whether this label painter supports snapping for the label specified by
setObject,setLabelIndexandsetSubLabelIndex, considering the givenILcdGXYContextinstance. When the label painter supports snap for the specified label and context, it can return a snap target for this label and context.Before calling this method, the domain object, the label index, the sublabel index and the location of the label should be set using the respective methods.
This default implementation returns
false. Override this method if you want to support snapping.- Specified by:
supportLabelSnapin interfaceILcdGXYLabelPainter2- Parameters:
aGraphics- the Graphics on which is worked.aGXYContext- the ILcdGXYContext of the snapping.- Returns:
trueif this label painter supports snapping for the specified label.- See Also:
-
labelSnapTarget
Returns anObjectthat can be used as snapping target when graphically editing anotherObjector label than the one this ILcdGXYLabelPainter2 represents. The returnedObjectcan be theObjectthis ILcdGXYLabelPainter2 represents or any other (e.g. anILcdPointif getObject() is anILcdPointList).This default implementation always returns
null. Override this method if you want to support snapping.- Specified by:
labelSnapTargetin interfaceILcdGXYLabelPainter2- Parameters:
aGraphics- the Graphics on which is worked.aGXYContext- the ILcdGXYContext of the snapping.- Returns:
- an
Objectthat can be used as snapping target when graphically editing anotherObjector label than the one this ILcdGXYLabelPainter2 represents (returned by getObject()). This object can benull.
-
getDisplayName
This default implementation returns the display name set withsetDisplayName, ortoString()if this was set tonull.- Specified by:
getDisplayNamein interfaceILcdGXYLabelPainter2- Returns:
- the display name of this
ILcdGXYLabelPainter2
-
setDisplayName
Sets the display name for this label painter.- Parameters:
aDisplayName- The display name for this label painter. This can benull, in which casegetDisplayName()will return the result oftoString().- See Also:
-