LabelView (Java 2 Platform SE 5.0) (original) (raw)


javax.swing.text

Class LabelView

java.lang.Object extended by javax.swing.text.View extended by javax.swing.text.GlyphView extended by javax.swing.text.LabelView

All Implemented Interfaces:

Cloneable, SwingConstants, TabableView

Direct Known Subclasses:

InlineView


public class LabelView

extends GlyphView

implements TabableView

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.


Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.text.GlyphView
GlyphView.GlyphPainter
Field Summary
Fields inherited from class javax.swing.text.View
BadBreakWeight, ExcellentBreakWeight, ForcedBreakWeight, GoodBreakWeight, X_AXIS, Y_AXIS
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
Constructor Summary
LabelView(Element elem) Constructs a new view wrapped on an element.
Method Summary
void [changedUpdate](../../../javax/swing/text/LabelView.html#changedUpdate%28javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory%29)(DocumentEvent e,Shape a,ViewFactory f) Gives notification from the document that attributes were changed in a location that this view is responsible for.
Color getBackground() Fetches the background color to use to render the glyphs.
Font getFont() Fetches the font that the glyphs should be based upon.
protected FontMetrics getFontMetrics() Deprecated. FontMetrics are not used for glyph rendering when running in the JDK.
Color getForeground() Fetches the foreground color to use to render the glyphs.
boolean isStrikeThrough() Determines if the glyphs should have a strikethrough line.
boolean isSubscript() Determines if the glyphs should be rendered as superscript.
boolean isSuperscript() Determines if the glyphs should be rendered as subscript.
boolean isUnderline() Determines if the glyphs should be underlined.
protected void setBackground(Color bg) Sets the background color for the view.
protected void setPropertiesFromAttributes() Sets the cached properties from the attributes.
protected void setStrikeThrough(boolean s) Sets whether or not the view has a strike/line through it.
protected void setSubscript(boolean s) Sets whether or not the view represents a subscript.
protected void setSuperscript(boolean s) Sets whether or not the view represents a superscript.
protected void setUnderline(boolean u) Sets whether or not the view is underlined.
Methods inherited from class javax.swing.text.GlyphView
[breakView](../../../javax/swing/text/GlyphView.html#breakView%28int, int, float, float%29), checkPainter, clone, [createFragment](../../../javax/swing/text/GlyphView.html#createFragment%28int, int%29), getAlignment, [getBreakWeight](../../../javax/swing/text/GlyphView.html#getBreakWeight%28int, float, float%29), getEndOffset, getGlyphPainter, [getNextVisualPositionFrom](../../../javax/swing/text/GlyphView.html#getNextVisualPositionFrom%28int, javax.swing.text.Position.Bias, java.awt.Shape, int, javax.swing.text.Position.Bias[]%29), [getPartialSpan](../../../javax/swing/text/GlyphView.html#getPartialSpan%28int, int%29), getPreferredSpan, getStartOffset, [getTabbedSpan](../../../javax/swing/text/GlyphView.html#getTabbedSpan%28float, javax.swing.text.TabExpander%29), getTabExpander, [getText](../../../javax/swing/text/GlyphView.html#getText%28int, int%29), [insertUpdate](../../../javax/swing/text/GlyphView.html#insertUpdate%28javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory%29), [modelToView](../../../javax/swing/text/GlyphView.html#modelToView%28int, java.awt.Shape, javax.swing.text.Position.Bias%29), [paint](../../../javax/swing/text/GlyphView.html#paint%28java.awt.Graphics, java.awt.Shape%29), [removeUpdate](../../../javax/swing/text/GlyphView.html#removeUpdate%28javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory%29), setGlyphPainter, [viewToModel](../../../javax/swing/text/GlyphView.html#viewToModel%28float, float, java.awt.Shape, javax.swing.text.Position.Bias[]%29)
Methods inherited from class javax.swing.text.View
append, [forwardUpdate](../../../javax/swing/text/View.html#forwardUpdate%28javax.swing.event.DocumentEvent.ElementChange, javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory%29), [forwardUpdateToView](../../../javax/swing/text/View.html#forwardUpdateToView%28javax.swing.text.View, javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory%29), getAttributes, [getChildAllocation](../../../javax/swing/text/View.html#getChildAllocation%28int, java.awt.Shape%29), getContainer, getDocument, getElement, getGraphics, getMaximumSpan, getMinimumSpan, getParent, getResizeWeight, [getToolTipText](../../../javax/swing/text/View.html#getToolTipText%28float, float, java.awt.Shape%29), getView, getViewCount, getViewFactory, [getViewIndex](../../../javax/swing/text/View.html#getViewIndex%28float, float, java.awt.Shape%29), [getViewIndex](../../../javax/swing/text/View.html#getViewIndex%28int, javax.swing.text.Position.Bias%29), [insert](../../../javax/swing/text/View.html#insert%28int, javax.swing.text.View%29), isVisible, [modelToView](../../../javax/swing/text/View.html#modelToView%28int, javax.swing.text.Position.Bias, int, javax.swing.text.Position.Bias, java.awt.Shape%29), [modelToView](../../../javax/swing/text/View.html#modelToView%28int, java.awt.Shape%29), [preferenceChanged](../../../javax/swing/text/View.html#preferenceChanged%28javax.swing.text.View, boolean, boolean%29), remove, removeAll, [replace](../../../javax/swing/text/View.html#replace%28int, int, javax.swing.text.View[]%29), setParent, [setSize](../../../javax/swing/text/View.html#setSize%28float, float%29), [updateChildren](../../../javax/swing/text/View.html#updateChildren%28javax.swing.event.DocumentEvent.ElementChange, javax.swing.event.DocumentEvent, javax.swing.text.ViewFactory%29), [updateLayout](../../../javax/swing/text/View.html#updateLayout%28javax.swing.event.DocumentEvent.ElementChange, javax.swing.event.DocumentEvent, java.awt.Shape%29), [viewToModel](../../../javax/swing/text/View.html#viewToModel%28float, float, java.awt.Shape%29)
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, [wait](../../../java/lang/Object.html#wait%28long, int%29)
Methods inherited from interface javax.swing.text.TabableView
[getPartialSpan](../../../javax/swing/text/TabableView.html#getPartialSpan%28int, int%29), [getTabbedSpan](../../../javax/swing/text/TabableView.html#getTabbedSpan%28float, javax.swing.text.TabExpander%29)
Constructor Detail

LabelView

public LabelView(Element elem)

Constructs a new view wrapped on an element.

Parameters:

elem - the element

Method Detail

setUnderline

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 - true if the view is underlined, otherwise false

See Also:

isUnderline()


setStrikeThrough

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 - true if the view has a strike/line through it, otherwise false

See Also:

isStrikeThrough()


setSuperscript

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 - true if the view represents a superscript, otherwise false

See Also:

isSuperscript()


setSubscript

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 - true if the view represents a subscript, otherwise false

See Also:

isSubscript()


setBackground

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 overridesetPropertiesFromAttributes 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 - background color, or null

Since:

1.5

See Also:

setPropertiesFromAttributes()


setPropertiesFromAttributes

protected void setPropertiesFromAttributes()

Sets the cached properties from the attributes.


getFontMetrics

@Deprecated protected FontMetrics getFontMetrics()

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

Fetches the FontMetrics used for this view.


getBackground

public Color getBackground()

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

Overrides:

[getBackground](../../../javax/swing/text/GlyphView.html#getBackground%28%29) in class [GlyphView](../../../javax/swing/text/GlyphView.html "class in javax.swing.text")

Returns:

the cached background color


getForeground

public Color getForeground()

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

Overrides:

[getForeground](../../../javax/swing/text/GlyphView.html#getForeground%28%29) in class [GlyphView](../../../javax/swing/text/GlyphView.html "class in javax.swing.text")

Returns:

the cached foreground color


getFont

public Font getFont()

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

Overrides:

[getFont](../../../javax/swing/text/GlyphView.html#getFont%28%29) in class [GlyphView](../../../javax/swing/text/GlyphView.html "class in javax.swing.text")

Returns:

the cached font


isUnderline

public boolean 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 theElement's AttributeSet. If Element's AttributeSet does not have this property set, it will revert to false.

Overrides:

[isUnderline](../../../javax/swing/text/GlyphView.html#isUnderline%28%29) in class [GlyphView](../../../javax/swing/text/GlyphView.html "class in javax.swing.text")

Returns:

the value of the cachedunderline property


isStrikeThrough

public boolean 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 theElement's AttributeSet. If Element's AttributeSet does not have this property set, it will revert to false.

Overrides:

[isStrikeThrough](../../../javax/swing/text/GlyphView.html#isStrikeThrough%28%29) in class [GlyphView](../../../javax/swing/text/GlyphView.html "class in javax.swing.text")

Returns:

the value of the cachedstrikeThrough property


isSubscript

public boolean isSubscript()

Determines if the glyphs should be rendered as superscript.

Overrides:

[isSubscript](../../../javax/swing/text/GlyphView.html#isSubscript%28%29) in class [GlyphView](../../../javax/swing/text/GlyphView.html "class in javax.swing.text")

Returns:

the value of the cached subscript property

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


isSuperscript

public boolean isSuperscript()

Determines if the glyphs should be rendered as subscript.

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

Overrides:

[isSuperscript](../../../javax/swing/text/GlyphView.html#isSuperscript%28%29) in class [GlyphView](../../../javax/swing/text/GlyphView.html "class in javax.swing.text")

Returns:

the value of the cachedsuperscript property


changedUpdate

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

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

Overrides:

[changedUpdate](../../../javax/swing/text/GlyphView.html#changedUpdate%28javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory%29) in class [GlyphView](../../../javax/swing/text/GlyphView.html "class in javax.swing.text")

Parameters:

e - the change information from the associated document

a - the current allocation of the view

f - the factory to use to rebuild if the view has children

See Also:

[View.changedUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)](../../../javax/swing/text/View.html#changedUpdate%28javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory%29)



Submit a bug or feature
For further API reference and developer documentation, see Java 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.

Copyright © 2004, 2010 Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.