javax.swing.text

Class LabelView

public class LabelView extends GlyphView

A {@link GlyphView} that caches the textattributes for most effective rendering.
Constructor Summary
LabelView(Element element)
Creates a new GlyphView for the given Element.
Method Summary
voidchangedUpdate(DocumentEvent e, Shape a, ViewFactory vf)
Receives notification when text attributes change in the chunk of text that this view is responsible for.
ColorgetBackground()
Returns the background color for the glyphs.
FontgetFont()
Returns the font for the glyphs.
protected FontMetricsgetFontMetrics()
Returns the font metrics of the current font.
ColorgetForeground()
Returns the foreground color for the glyphs.
booleanisStrikeThrough()
Returns true if the glyphs are rendered strike-through, false otherwise.
booleanisSubscript()
Returns true if the glyphs are rendered as subscript, false otherwise.
booleanisSuperscript()
Returns true if the glyphs are rendered as superscript, false otherwise.
booleanisUnderline()
Returns true if the glyphs are rendered underlined, false otherwise.
protected voidsetBackground(Color bg)
Sets the background color for the glyphs.
protected voidsetPropertiesFromAttributes()
Loads the properties of this label view from the element's text attributes.
protected voidsetStrikeThrough(boolean flag)
Sets the strike-through flag.
protected voidsetSubscript(boolean flag)
Sets the subscript flag.
protected voidsetSuperscript(boolean flag)
Sets the superscript flag.
protected voidsetUnderline(boolean flag)
Sets the underline flag.

Constructor Detail

LabelView

public LabelView(Element element)
Creates a new GlyphView for the given Element.

Parameters: element the element that is rendered by this GlyphView

Method Detail

changedUpdate

public void changedUpdate(DocumentEvent e, Shape a, ViewFactory vf)
Receives notification when text attributes change in the chunk of text that this view is responsible for. This simply calls {@link #setPropertiesFromAttributes()}.

Parameters: e the document event a the allocation of this view vf the view factory to use for creating new views

getBackground

public Color getBackground()
Returns the background color for the glyphs.

Returns: the background color for the glyphs

getFont

public Font getFont()
Returns the font for the glyphs.

Returns: the font for the glyphs

getFontMetrics

protected FontMetrics getFontMetrics()

Deprecated: this is not used anymore

Returns the font metrics of the current font.

Returns: the font metrics of the current font

getForeground

public Color getForeground()
Returns the foreground color for the glyphs.

Returns: the foreground color for the glyphs

isStrikeThrough

public boolean isStrikeThrough()
Returns true if the glyphs are rendered strike-through, false otherwise.

Returns: true if the glyphs are rendered strike-through, false otherwise

isSubscript

public boolean isSubscript()
Returns true if the glyphs are rendered as subscript, false otherwise.

Returns: true if the glyphs are rendered as subscript, false otherwise

isSuperscript

public boolean isSuperscript()
Returns true if the glyphs are rendered as superscript, false otherwise.

Returns: true if the glyphs are rendered as superscript, false otherwise

isUnderline

public boolean isUnderline()
Returns true if the glyphs are rendered underlined, false otherwise.

Returns: true if the glyphs are rendered underlined, false otherwise

setBackground

protected void setBackground(Color bg)
Sets the background color for the glyphs. A value of null means the background of the parent view should shine through.

Parameters: bg the background to set or null

Since: 1.5

setPropertiesFromAttributes

protected void setPropertiesFromAttributes()
Loads the properties of this label view from the element's text attributes. This method is called from the constructor and the {@link #changedUpdate} method

setStrikeThrough

protected void setStrikeThrough(boolean flag)
Sets the strike-through flag.

Parameters: flag true if the glyphs are rendered strike-through, false otherwise

setSubscript

protected void setSubscript(boolean flag)
Sets the subscript flag.

Parameters: flag true if the glyphs are rendered as subscript, false otherwise

setSuperscript

protected void setSuperscript(boolean flag)
Sets the superscript flag.

Parameters: flag true if the glyphs are rendered as superscript, false otherwise

setUnderline

protected void setUnderline(boolean flag)
Sets the underline flag.

Parameters: flag true if the glyphs are rendered underlined, false otherwise