Class TLspLabelID
Class used to uniquely identify a label. A label is specified by its layer, paint representation, domain object, and a sublabel ID.
The sublabel ID is an object that uniquely identifies a label within the set of all
labels of a domain object. It should be immutable, and properly implement equals()
and
hashCode()
. Typical sublabel IDs would be a String
or Integer
object. This object should never be null
.
This class implement the equals
and hashCode
implementations,
so it can for example be used as a key in hash maps.
- Since:
- 2012.0
-
Constructor Summary
ConstructorDescriptionTLspLabelID
(ILspLayer aLayer, TLspPaintRepresentation aPaintRepresentation, Object aDomainObject, Object aSubLabelID) Create a new label identifier using the labels' domain object and sublabel ID -
Method Summary
Modifier and TypeMethodDescriptionboolean
This implementation of equals uses an index to compare label identifiers.Returns the domain object of this label.getLayer()
Returns the layer this label belongs to.Returns the paint representation this label is for.Returns the sublabel ID used to identify a label.int
hashCode()
This implementation of hashCode uses the sublabel ID to create a hash code for this label identifier.toString()
-
Constructor Details
-
TLspLabelID
public TLspLabelID(ILspLayer aLayer, TLspPaintRepresentation aPaintRepresentation, Object aDomainObject, Object aSubLabelID) Create a new label identifier using the labels' domain object and sublabel ID- Parameters:
aLayer
- the layer to which the domain object of the label belongs.aPaintRepresentation
- the paint representation stateaDomainObject
- the domain object to which the label belongs.aSubLabelID
- the Object that can be used to differentiate between multiple labels of the same domain object. This object can be used as a cache key, and shouldn't contain references to e.g. domain objects, layers or views. This object should never benull
.
-
-
Method Details
-
getLayer
Returns the layer this label belongs to.- Returns:
- the layer this label belongs to.
-
getPaintRepresentation
Returns the paint representation this label is for.- Returns:
- the paint representation this label is for.
-
getDomainObject
Returns the domain object of this label.- Returns:
- the domain object of this label.
-
getSubLabelID
Returns the sublabel ID used to identify a label. This sublabel ID is used to differentiate between multiple labels for the same domain object.
The sublabel ID is an object that uniquely identifies a label within the set of all labels of a domain object. It should be immutable, and properly implement
equals()
andhashCode()
. Typical sublabel IDs would be aString
orInteger
object. This object should never benull
.Note: This object can be used as a cache key, and should not contain references to for example domain objects, layers or views, as this could cause memory leaks.
- Returns:
- the sublabel ID used to identify this label.
-
equals
This implementation of equals uses an index to compare label identifiers. It also checks if the domain object is exactly the same (==
) as the domain object of the other label identifier. -
hashCode
public int hashCode()This implementation of hashCode uses the sublabel ID to create a hash code for this label identifier. It also uses the identity hash code (System.identityHashCode
) of the domain object and the layer. -
toString
-