APIdia Launch Partner
Top Description Fields Constructors Methods
javax.swing.text

public Class LabelView

extends GlyphView
implements TabableView
Class Inheritance
All Implemented Interfaces
javax.swing.text.TabableView
Known Direct Subclasses
javax.swing.text.html.InlineView
Imports
java.awt.*, javax.swing.event.*

A LabelView is a styled chunk of text that represents a view mapped over an element in the text model. It caches the character level attributes used for rendering.
Author
Timothy Prinzing

Field Summary

Modifier and TypeField and Description
private Color
private Color
private Font
private boolean
private boolean
private boolean
private boolean
Inherited from javax.swing.text.GlyphView:
defaultPainterexpanderimpliedCRlengthoffsetpainterskipWidthx

Constructor Summary

AccessConstructor and Description
public
LabelView(Element
the element
elem
)

Constructs a new view wrapped on an element.

Method Summary

Modifier and TypeMethod and Description
public void
changedUpdate(DocumentEvent
the change information from the associated document
e
,
Shape
the current allocation of the view
a
,
ViewFactory
the factory to use to rebuild if the view has children
f
)

Overrides javax.swing.text.GlyphView.changedUpdate.

Gives notification from the document that attributes were changed in a location that this view is responsible for.

public Color

Returns:

the cached background color
getBackground
()

Overrides javax.swing.text.GlyphView.getBackground.

Fetches the background color to use to render the glyphs.

public Font

Returns:

the cached font
getFont
()

Overrides javax.swing.text.GlyphView.getFont.

Fetches the font that the glyphs should be based upon.

protected FontMetrics

Returns:

the FontMetrics used for this view
getFontMetrics
()
Deprecated FontMetrics are not used for glyph rendering when running in the JDK.

Fetches the FontMetrics used for this view.

public Color

Returns:

the cached foreground color
getForeground
()

Overrides javax.swing.text.GlyphView.getForeground.

Fetches the foreground color to use to render the glyphs.

public boolean

Returns:

the value of the cached strikeThrough property
isStrikeThrough
()

Overrides javax.swing.text.GlyphView.isStrikeThrough.

Determines if the glyphs should have a strikethrough line.

public boolean

Returns:

the value of the cached subscript property
isSubscript
()

Overrides javax.swing.text.GlyphView.isSubscript.

Determines if the glyphs should be rendered as superscript.

public boolean

Returns:

the value of the cached superscript property
isSuperscript
()

Overrides javax.swing.text.GlyphView.isSuperscript.

Determines if the glyphs should be rendered as subscript.

public boolean

Returns:

the value of the cached underline property
isUnderline
()

Overrides javax.swing.text.GlyphView.isUnderline.

Determines if the glyphs should be underlined.

protected void
setBackground(Color
background color, or null
bg
)

Sets the background color for the view.

protected void
setPropertiesFromAttributes()

Sets the cached properties from the attributes.

protected void
setStrikeThrough(boolean
true if the view has a strike/line through it, otherwise false
s
)

Sets whether or not the view has a strike/line through it.

protected void
setSubscript(boolean
true if the view represents a subscript, otherwise false
s
)

Sets whether or not the view represents a subscript.

protected void
setSuperscript(boolean
true if the view represents a superscript, otherwise false
s
)

Sets whether or not the view represents a superscript.

protected void
setUnderline(boolean
true if the view is underlined, otherwise false
u
)

Sets whether or not the view is underlined.

pack-priv final void
sync()

Synchronize the view's cached values with the model.

Inherited from javax.swing.text.GlyphView:
breakViewcheckPainterclonecreateFragmentgetAlignmentgetBreakWeightgetEndOffsetgetGlyphPaintergetJustificationInfogetMinimumSpangetNextVisualPositionFromgetPartialSpangetPreferredSpangetStartOffsetgetTabbedSpangetTabExpandergetTextinsertUpdatemodelToViewpaintpaintTextUsingColorremoveUpdatesetGlyphPainterupdateAfterChangeviewToModel

Field Detail

bgback to summary
private Color bg
fgback to summary
private Color fg
fontback to summary
private Font font
strikeback to summary
private boolean strike
subscriptback to summary
private boolean subscript
superscriptback to summary
private boolean superscript
underlineback to summary
private boolean underline

Constructor Detail

LabelViewback to summary
public LabelView(Element elem)

Constructs a new view wrapped on an element.

Parameters
elem:Element

the element

Method Detail

changedUpdateback to summary
public void changedUpdate(DocumentEvent e, Shape a, ViewFactory f)

Overrides javax.swing.text.GlyphView.changedUpdate.

Gives notification from the document that attributes were changed in a location that this view is responsible for.

Parameters
e:DocumentEvent

the change information from the associated document

a:Shape

the current allocation of the view

f:ViewFactory

the factory to use to rebuild if the view has children

See Also
View#changedUpdate
getBackgroundback to summary
public Color getBackground()

Overrides javax.swing.text.GlyphView.getBackground.

Fetches the background color to use to render the glyphs. This is implemented to return a cached background color, which defaults to null.

Returns:Color

the cached background color

Since
1.3
getFontback to summary
public Font getFont()

Overrides javax.swing.text.GlyphView.getFont.

Fetches the font that the glyphs should be based upon. This is implemented to return a cached font.

Returns:Font

the cached font

getFontMetricsback to summary
protected FontMetrics getFontMetrics()

Deprecated

FontMetrics are not used for glyph rendering when running in the JDK.

Fetches the FontMetrics used for this view.

Returns:FontMetrics

the FontMetrics used for this view

Annotations
@Deprecated
getForegroundback to summary
public Color getForeground()

Overrides javax.swing.text.GlyphView.getForeground.

Fetches the foreground color to use to render the glyphs. This is implemented to return a cached foreground color, which defaults to null.

Returns:Color

the cached foreground color

Since
1.3
isStrikeThroughback to summary
public boolean isStrikeThrough()

Overrides javax.swing.text.GlyphView.isStrikeThrough.

Determines if the glyphs should have a strikethrough line. If true, a line should be drawn through the center of the glyphs. This is implemented to return the cached strikeThrough property.

When you request this property, LabelView re-syncs its state with the properties of the Element's AttributeSet. If Element's AttributeSet does not have this property set, it will revert to false.

Returns:boolean

the value of the cached strikeThrough property

Since
1.3
isSubscriptback to summary
public boolean isSubscript()

Overrides javax.swing.text.GlyphView.isSubscript.

Determines if the glyphs should be rendered as superscript.

When you request this property, LabelView re-syncs its state with the properties of the Element's AttributeSet. If Element's AttributeSet does not have this property set, it will revert to false.

Returns:boolean

the value of the cached subscript property

Since
1.3
isSuperscriptback to summary
public boolean isSuperscript()

Overrides javax.swing.text.GlyphView.isSuperscript.

Determines if the glyphs should be rendered as subscript.

When you request this property, LabelView re-syncs its state with the properties of the Element's AttributeSet. If Element's AttributeSet does not have this property set, it will revert to false.

Returns:boolean

the value of the cached superscript property

Since
1.3
isUnderlineback to summary
public boolean isUnderline()

Overrides javax.swing.text.GlyphView.isUnderline.

Determines if the glyphs should be underlined. If true, an underline should be drawn through the baseline. This is implemented to return the cached underline property.

When you request this property, LabelView re-syncs its state with the properties of the Element's AttributeSet. If Element's AttributeSet does not have this property set, it will revert to false.

Returns:boolean

the value of the cached underline property

Since
1.3
setBackgroundback to summary
protected void setBackground(Color bg)

Sets the background color for the view. This method is typically invoked as part of configuring this View. If you need to customize the background color you should override setPropertiesFromAttributes and invoke this method. A value of null indicates no background should be rendered, so that the background of the parent View will show through.

Parameters
bg:Color

background color, or null

Since
1.5
See Also
setPropertiesFromAttributes
setPropertiesFromAttributesback to summary
protected void setPropertiesFromAttributes()

Sets the cached properties from the attributes.

setStrikeThroughback to summary
protected void setStrikeThrough(boolean s)

Sets whether or not the view has a strike/line through it. Note that this setter is protected and is really only meant if you need to update some additional state when set.

Parameters
s:boolean

true if the view has a strike/line through it, otherwise false

See Also
isStrikeThrough
setSubscriptback to summary
protected void setSubscript(boolean s)

Sets whether or not the view represents a subscript. Note that this setter is protected and is really only meant if you need to update some additional state when set.

Parameters
s:boolean

true if the view represents a subscript, otherwise false

See Also
isSubscript
setSuperscriptback to summary
protected void setSuperscript(boolean s)

Sets whether or not the view represents a superscript. Note that this setter is protected and is really only meant if you need to update some additional state when set.

Parameters
s:boolean

true if the view represents a superscript, otherwise false

See Also
isSuperscript
setUnderlineback to summary
protected void setUnderline(boolean u)

Sets whether or not the view is underlined. Note that this setter is protected and is really only meant if you need to update some additional state when set.

Parameters
u:boolean

true if the view is underlined, otherwise false

See Also
isUnderline
syncback to summary
pack-priv final void sync()

Synchronize the view's cached values with the model. This causes the font, metrics, color, etc to be re-cached if the cache has been invalidated.