IconLabelRenderer

class IconLabelRenderer() extends AbstractShapeRenderer

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.

class AbstractShapeRenderer
trait Renderer
class Object
trait Matchable
class Any

Value members

Constructors

def this(textField: String)

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.

def this(textField: String, iconField: String)

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 the iconField parameter is null, no icon at all will be drawn.

textField

the data field for the text label

Concrete methods

protected
def getIcon(item: VisualItem): Icon

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

protected
def getRawShape(item: VisualItem): Shape
See also

prefuse.render.AbstractShapeRenderer#getRawShape(prefuse.visual.VisualItem)

protected
def getText(item: VisualItem): String

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}.

def horizontalAlignment_=(value: Int): Unit

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

def horizontalIconAlignment_=(value: Int): Unit

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

def horizontalPadding_=(value: Int): Unit

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

def horizontalTextAlignment_=(value: Int): Unit

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

def iconField: String

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

def iconField_=(value: String): Unit

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

def iconPosition: Int

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

def iconPosition_=(value: Int): Unit

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

def iconTextPadding_=(value: Int): Unit

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

def maximumTextWidth_=(value: Int): Unit

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

protected
def mkAlignedPoint(p: Point2D, item: VisualItem, w: Double, h: Double, xAlign: Int, yAlign: Int): Unit

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.

override
def render(g: Graphics2D, item: VisualItem): Unit
See also

prefuse.render.Renderer#render(java.awt.Graphics2D, prefuse.visual.VisualItem)

Definition Classes
AbstractShapeRenderer -> Renderer
def setRoundedCorner(arcWidth: Int, arcHeight: Int): Unit

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

def textField: String

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

def textField_=(value: String): Unit

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}.

def verticalAlignment_=(value: Int): Unit

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

def verticalIconAlignment_=(value: Int): Unit

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

def verticalPadding_=(value: Int): Unit

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

def verticalTextAlignment_=(value: Int): Unit

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

Inherited methods

def getRenderType(x$0: VisualItem): Int
Inherited from
AbstractShapeRenderer
def getShape(x$0: VisualItem): Shape
Inherited from
AbstractShapeRenderer
def locatePoint(x$0: Point2D, x$1: VisualItem): Boolean
Inherited from
AbstractShapeRenderer
def setBounds(x$0: VisualItem): Unit
Inherited from
AbstractShapeRenderer
def setManageBounds(x$0: Boolean): Unit
Inherited from
AbstractShapeRenderer
def setRenderType(x$0: Int): Unit
Inherited from
AbstractShapeRenderer

Concrete fields

protected
var m_arcHeight: Int
protected
var m_arcWidth: Int
protected
var m_bBox: RectangularShape

The holder for the currently computed bounding box

The holder for the currently computed bounding box

protected
var m_delim: String
protected
var m_font: Font
protected
var m_hIconAlign: Int
protected
var m_hTextAlign: Int
protected
var m_horizBorder: Int
protected
var m_iconMargin: Int
protected
var m_iconName: String
protected
var m_iconPos: Int
protected
var m_labelName: String
protected
protected
var m_pt: Point2D
protected
var m_text: String
protected
var m_textDim: Dimension
protected
var m_vIconAlign: Int
protected
var m_vTextAlign: Int
protected
var m_vertBorder: Int
protected
var m_xAlign: Int
protected
var m_yAlign: Int