public class SimpleLabel extends Object implements ILabel
ILabel
interface that can be used stand-alone.
Note that this class is not the one used as the default implementation of a DefaultGraph
's ILabel
s and
casting them to SimpleLabel
will fail. Instances of this class can be used without an accompanying graph
instance. All of the properties are mutable. An example of a possible use case would be the rendering of a label into a
graphics context: Simply create a
SimpleLabel
, associate a style with it and use the style's renderer instance to obtain a rendering for the
label.
Constructor and Description |
---|
SimpleLabel(ILabelOwner owner,
String text,
ILabelModelParameter layoutParameter)
Creates an instance of the
SimpleLabel class with default lookup ,
an instance of VoidLabelStyle and the given parameter , text, and owner. |
Modifier and Type | Method and Description |
---|---|
void |
adoptPreferredSizeFromStyle()
Gets the
ILabelStyleRenderer.getPreferredSize(ILabel, ILabelStyle) from the
labels style and sets the PreferredSize to that value. |
ILabelModelParameter |
getLayoutParameter()
Gets the label model's parameter that determines the positioning of this label.
|
ILookup |
getLookupImplementation()
Gets the
ILookup implementation used for calls to lookup(Class) on this instance. |
ILabelOwner |
getOwner()
Gets the owner of this label.
|
SizeD |
getPreferredSize()
Gets the preferred size of the label with respect to its current contents and the implementation of the visualization.
|
ILabelStyle |
getStyle()
Returns the style that is responsible for the visual representation of this node in a
CanvasControl . |
Object |
getTag()
Gets the tag associated with this instance.
|
String |
getText()
Gets the text string associated with this label.
|
<TLookup> TLookup |
lookup(Class<TLookup> type)
Returns an instance that implements the given type or
null . |
void |
setLayoutParameter(ILabelModelParameter value)
Sets the label model's parameter that determines the positioning of this label.
|
void |
setLookupImplementation(ILookup value)
Sets the
ILookup implementation used for calls to lookup(Class) on this instance. |
void |
setOwner(ILabelOwner value)
Sets the owner of this label.
|
void |
setPreferredSize(SizeD value)
Sets the preferred size of the label with respect to its current contents and the implementation of the visualization.
|
void |
setStyle(ILabelStyle value)
Returns the style that is responsible for the visual representation of this node in a
CanvasControl . |
void |
setTag(Object value)
Sets the tag associated with this instance.
|
void |
setText(String value)
Sets the text string associated with this label.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
createDictionaryLookup, createDynamic, createSingle, createSingle, createWrapped, lookup, lookup, safeLookup
public SimpleLabel(ILabelOwner owner, String text, ILabelModelParameter layoutParameter)
SimpleLabel
class with default lookup
,
an instance of VoidLabelStyle
and the given parameter
, text, and owner.layoutParameter
- The parameter that describes the label's layout.text
- The label's text.owner
- The label's owner.public void adoptPreferredSizeFromStyle()
ILabelStyleRenderer.getPreferredSize(ILabel, ILabelStyle)
from the
labels style and sets the PreferredSize
to that value.public final ILabelModelParameter getLayoutParameter()
ILabel
In order to set a different parameter for this label, use IGraph
's IGraph.setLabelLayoutParameter(ILabel, ILabelModelParameter)
method. Note that the label model parameter instance associated with a label instance may be shared between multiple
label instances and that the modification of this instance or its Model
will
result in a change of the positioning of all labels that are associated with the same parameter or model instance.
getLayoutParameter
in interface ILabel
public final ILookup getLookupImplementation()
ILookup
implementation used for calls to lookup(Class)
on this instance.setLookupImplementation(ILookup)
public final ILabelOwner getOwner()
ILabel
public final SizeD getPreferredSize()
ILabel
Often times the layout's
size will be the same as the preferred size, but it's up to the
implementation of the ILabelModel
to interpret it differently. In order to
set a different preferred size for this label instance use IGraph
's IGraph.setLabelPreferredSize(ILabel, SizeD)
method.
getPreferredSize
in interface ILabel
public final ILabelStyle getStyle()
ILabel
CanvasControl
.
In order to set the style on an instance, use the IGraph.setStyle(ILabel, ILabelStyle)
method. Note that the style instance associated with a label instance may be shared between multiple label instances and
that the modification of this style will result in a change of the appearance of all labels that are associated with the
same style instance.
public final Object getTag()
ITagOwner
The implementation itself does not normally depend on the tag associated with it. It serves as storage for the object only.
getTag
in interface ITagOwner
ITagOwner.setTag(Object)
public final String getText()
ILabel
It is up to the visualization engine to interpret this property for the visualization of the label. Normally, it will
render the text into the layout
of this instance.
public <TLookup> TLookup lookup(Class<TLookup> type)
ILookup
null
.
Typically, this method will be called in order to obtain a different view or
aspect of the current instance. This is quite similar to casting or using
a super type or interface of this instance, but is not limited to inheritance or
compile time constraints. An instance implementing this method is not
required to return non-null
implementations for the types, nor does it
have to return the same instance any time. Also it depends on the
type and context whether the instance returned stays up to date or needs to
be reobtained for subsequent use.public final void setLayoutParameter(ILabelModelParameter value)
In order to set a different parameter for this label, use IGraph
's IGraph.setLabelLayoutParameter(ILabel, ILabelModelParameter)
method. Note that the label model parameter instance associated with a label instance may be shared between multiple
label instances and that the modification of this instance or its Model
will
result in a change of the positioning of all labels that are associated with the same parameter or model instance.
value
- The LayoutParameter to set.getLayoutParameter()
public final void setLookupImplementation(ILookup value)
ILookup
implementation used for calls to lookup(Class)
on this instance.value
- The LookupImplementation to set.getLookupImplementation()
public final void setOwner(ILabelOwner value)
value
- The Owner to set.getOwner()
public final void setPreferredSize(SizeD value)
Often times the layout's
size will be the same as the preferred size, but it's up to the
implementation of the ILabelModel
to interpret it differently. In order to
set a different preferred size for this label instance use IGraph
's IGraph.setLabelPreferredSize(ILabel, SizeD)
method.
value
- The PreferredSize to set.getPreferredSize()
public final void setStyle(ILabelStyle value)
CanvasControl
.
In order to set the style on an instance, use the IGraph.setStyle(ILabel, ILabelStyle)
method. Note that the style instance associated with a label instance may be shared between multiple label instances and
that the modification of this style will result in a change of the appearance of all labels that are associated with the
same style instance.
value
- The Style to set.getStyle()
public final void setTag(Object value)
ITagOwner
The implementation itself does not normally depend on the tag associated with it. It serves as storage for the object only.
setTag
in interface ITagOwner
value
- The user object associated with this instance.ITagOwner.getTag()
public final void setText(String value)
It is up to the visualization engine to interpret this property for the visualization of the label. Normally, it will
render the text into the layout
of this instance.
value
- The Text to set.getText()