IconLabelRenderer
Renderer that draws a label, which consists of a text string,
an icon, or both. This is based on the prefuse LabelRenderer
class, but changes image for icon. It was converted from Java to Scala,
so the code looks a bit ugly.
When created using the default constructor, the renderer attempts
to use text from the "label" field. To use a different field, use the
appropriate constructor or use the setTextField
method.
To perform custom String selection, subclass this Renderer and override the
getText
method. When the text field is
null
, no text label will be shown. Labels can span multiple
lines of text, determined by the presence of newline characters ('\n')
within the text string.
By default, no icon is shown. To show an icon, the icon field needs
to be set, either using the appropriate constructor or the
setIconField
method. The value of the icon field should
be an Icon
instance to use.
The position of the icon relative to text can be set using the
setIconPosition
method. Images can be placed to the
left, right, above, or below the text. The horizontal and vertical
alignments of either the text or the icon can be set explicitly
using the appropriate methods of this class (e.g.,
setHorizontalTextAlignment
). By default, both the
text and icon are centered along both the horizontal and
vertical directions.
Value members
Constructors
Creates a new LabelRenderer. Draws a text label using the given text data field and does not draw an icon.
Creates a new LabelRenderer. Draws a text label using the given text data field and does not draw an icon.
- Value Params
- textField
the data field for the text label.
Creates a new LabelRenderer. Draws a text label using the given text data field, and draws the icon at the location reported by the given icon data field.
Creates a new LabelRenderer. Draws a text label using the given text data field, and draws the icon at the location reported by the given icon data field.
- Value Params
- iconField
the data field for the icon location. This value in the data field should be an
Icon
, or null for no icon. If theiconField
parameter is null, no icon at all will be drawn.- textField
the data field for the text label
Concrete methods
Returns the icon to draw. Subclasses can override this class to perform custom icon selection beyond looking up the value from a data field.
Returns the icon to draw. Subclasses can override this class to perform custom icon selection beyond looking up the value from a data field.
- Value Params
- item
the item for which to select an icon to draw
- Returns
the icon to use, or null for no icon
Returns the text to draw. Subclasses can override this class to perform custom text selection.
Returns the text to draw. Subclasses can override this class to perform custom text selection.
- Value Params
- item
the item to represent as a
String
- Returns
a
String
to draw
Gets the horizontal alignment of this node with respect to its x, y coordinates.
Gets the horizontal alignment of this node with respect to its x, y coordinates.
- Returns
the horizontal alignment, one of { @link prefuse.Constants#LEFT}, { @link prefuse.Constants#RIGHT}, or { @link prefuse.Constants#CENTER}.
Sets the horizontal alignment of this node with respect to its x, y coordinates.
Sets the horizontal alignment of this node with respect to its x, y coordinates.
- Value Params
- value
the horizontal alignment, one of { @link prefuse.Constants#LEFT}, { @link prefuse.Constants#RIGHT}, or { @link prefuse.Constants#CENTER}.
Gets the horizontal icon alignment within the layout. One of
Constants.LEFT
, Constants.RIGHT
, or
Constants.CENTER
. The default is a centered icon.
Gets the horizontal icon alignment within the layout. One of
Constants.LEFT
, Constants.RIGHT
, or
Constants.CENTER
. The default is a centered icon.
- Returns
the horizontal icon alignment
Sets the horizontal icon alignment within the layout. One of
Constants.LEFT
, Constants.RIGHT
, or
Constants.CENTER
. The default is a centered icon.
Sets the horizontal icon alignment within the layout. One of
Constants.LEFT
, Constants.RIGHT
, or
Constants.CENTER
. The default is a centered icon.
- Value Params
- value
the desired horizontal icon alignment
Returns the amount of padding in pixels between the content and the border of this item along the horizontal dimension.
Returns the amount of padding in pixels between the content and the border of this item along the horizontal dimension.
- Returns
the horizontal padding
Sets the amount of padding in pixels between the content and the border of this item along the horizontal dimension.
Sets the amount of padding in pixels between the content and the border of this item along the horizontal dimension.
- Value Params
- value
the horizontal padding to set
Gets the horizontal text alignment within the layout. One of
Constants.LEFT
, Constants.RIGHT
, or
Constants.CENTER
. The default is centered text.
Gets the horizontal text alignment within the layout. One of
Constants.LEFT
, Constants.RIGHT
, or
Constants.CENTER
. The default is centered text.
- Returns
the horizontal text alignment
Sets the horizontal text alignment within the layout. One of
Constants.LEFT
, Constants.RIGHT
, or
Constants.CENTER
. The default is centered text.
Sets the horizontal text alignment within the layout. One of
Constants.LEFT
, Constants.RIGHT
, or
Constants.CENTER
. The default is centered text.
- Value Params
- value
the desired horizontal text alignment
Gets the data field for icon locations. The value stored
in the data field should be an Icon
, or null for no icon.
Gets the data field for icon locations. The value stored
in the data field should be an Icon
, or null for no icon.
- Returns
the data field for icon locations, or null for no icon
Sets the data field for icon locations. The value stored
in the data field should be an Icon
, or null for no icon. If the
iconField
parameter is null, no icons at all will be
drawn.
Sets the data field for icon locations. The value stored
in the data field should be an Icon
, or null for no icon. If the
iconField
parameter is null, no icons at all will be
drawn.
- Value Params
- value
the data field for icon locations, or null for no icons
Gets the icon position, determining where the icon is placed with
respect to the text. One of Constants.LEFT
,
Constants.RIGHT
, Constants.TOP
, or
Constants.BOTTOM
. The default is left.
Gets the icon position, determining where the icon is placed with
respect to the text. One of Constants.LEFT
,
Constants.RIGHT
, Constants.TOP
, or
Constants.BOTTOM
. The default is left.
- Returns
the icon position
Sets the icon position, determining where the icon is placed with
respect to the text. One of Constants.LEFT
,
Constants.RIGHT
, Constants.TOP
, or
Constants.BOTTOM
. The default is left.
Sets the icon position, determining where the icon is placed with
respect to the text. One of Constants.LEFT
,
Constants.RIGHT
, Constants.TOP
, or
Constants.BOTTOM
. The default is left.
- Value Params
- value
the desired icon position
Gets the padding, in pixels, between an icon and text.
Gets the padding, in pixels, between an icon and text.
- Returns
the padding between an icon and text
Sets the padding, in pixels, between an icon and text.
Sets the padding, in pixels, between an icon and text.
- Value Params
- value
the padding to use between an icon and text
Sets the maximum width that should be allowed of the text label. A value of -1 specifies no limit (this is the default).
Sets the maximum width that should be allowed of the text label. A value of -1 specifies no limit (this is the default).
- Value Params
- value
the maximum width of the text or -1 for no limit
Helper method, which calculates the top-left co-ordinate of an item given the item's alignment.
Helper method, which calculates the top-left co-ordinate of an item given the item's alignment.
- See also
prefuse.render.Renderer#render(java.awt.Graphics2D, prefuse.visual.VisualItem)
- Definition Classes
- AbstractShapeRenderer -> Renderer
Rounds the corners of the bounding rectangle in which the text string is rendered. This will only be seen if either the stroke or fill color is non-transparent.
Rounds the corners of the bounding rectangle in which the text string is rendered. This will only be seen if either the stroke or fill color is non-transparent.
- Value Params
- arcHeight
the height of the curved corner
- arcWidth
the width of the curved corner
Gets the field name to use for text labels.
Gets the field name to use for text labels.
- Returns
the data field for text labels, or null for no text
Sets the field name to use for text labels.
Sets the field name to use for text labels.
- Value Params
- value
the data field for text labels, or null for no text
Gets the vertical alignment of this node with respect to its x, y coordinates.
Gets the vertical alignment of this node with respect to its x, y coordinates.
- Returns
the vertical alignment, one of { @link prefuse.Constants#TOP}, { @link prefuse.Constants#BOTTOM}, or { @link prefuse.Constants#CENTER}.
Sets the vertical alignment of this node with respect to its x, y coordinates.
Sets the vertical alignment of this node with respect to its x, y coordinates.
- Value Params
- value
the vertical alignment, one of { @link prefuse.Constants#TOP}, { @link prefuse.Constants#BOTTOM}, or { @link prefuse.Constants#CENTER}.
Gets the vertical icon alignment within the layout. One of
Constants.TOP
, Constants.BOTTOM
, or
Constants.CENTER
. The default is a centered icon.
Gets the vertical icon alignment within the layout. One of
Constants.TOP
, Constants.BOTTOM
, or
Constants.CENTER
. The default is a centered icon.
- Returns
the vertical icon alignment
Sets the vertical icon alignment within the layout. One of
Constants.TOP
, Constants.BOTTOM
, or
Constants.CENTER
. The default is a centered icon.
Sets the vertical icon alignment within the layout. One of
Constants.TOP
, Constants.BOTTOM
, or
Constants.CENTER
. The default is a centered icon.
- Value Params
- value
the desired vertical icon alignment
Returns the amount of padding in pixels between the content and the border of this item along the vertical dimension.
Returns the amount of padding in pixels between the content and the border of this item along the vertical dimension.
- Returns
the vertical padding
Sets the amount of padding in pixels between the content and the border of this item along the vertical dimension.
Sets the amount of padding in pixels between the content and the border of this item along the vertical dimension.
- Value Params
- value
the vertical padding
Gets the vertical text alignment within the layout. One of
Constants.TOP
, Constants.BOTTOM
, or
Constants.CENTER
. The default is centered text.
Gets the vertical text alignment within the layout. One of
Constants.TOP
, Constants.BOTTOM
, or
Constants.CENTER
. The default is centered text.
- Returns
the vertical text alignment
Sets the vertical text alignment within the layout. One of
Constants.TOP
, Constants.BOTTOM
, or
Constants.CENTER
. The default is centered text.
Sets the vertical text alignment within the layout. One of
Constants.TOP
, Constants.BOTTOM
, or
Constants.CENTER
. The default is centered text.
- Value Params
- value
the desired vertical text alignment