This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


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
 
Constructor Summary

          Constructs a new view wrapped on an element.
 
Method Summary
 void

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

          Fetches the background color to use to render the glyphs.
 Font

          Fetches the font that the glyphs should be based upon.
protected FontMetrics

          Fetches the FontMetrics used for this view.
 Color

          Fetches the foreground color to use to render the glyphs.
 boolean

          Determines if the glyphs should have a strikethrough line.
 boolean

          Determines if the glyphs should be rendered as superscript.
 boolean

          Determines if the glyphs should be rendered as subscript.
 boolean

          Determines if the glyphs should be underlined.
protected void

          Sets the background color for the view.
protected void

          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, changedUpdate, checkPainter, clone, createFragment, getAlignment, getBackground, getBreakWeight, getEndOffset, getFont, getForeground, getGlyphPainter, getNextVisualPositionFrom, getPartialSpan, getPreferredSpan, getStartOffset, getTabbedSpan, getTabExpander, getText, insertUpdate, isStrikeThrough, isSubscript, isSuperscript, isUnderline, modelToView, paint, removeUpdate, setGlyphPainter, viewToModel
 
Methods inherited from class javax.swing.text.View
append, breakView, changedUpdate, createFragment, forwardUpdate, forwardUpdateToView, getAlignment, getAttributes, getBreakWeight, getChildAllocation, getContainer, getDocument, getElement, getEndOffset, getGraphics, getMaximumSpan, getMinimumSpan, getNextVisualPositionFrom, getParent, getPreferredSpan, getResizeWeight, getStartOffset, getToolTipText, getView, getViewCount, getViewFactory, getViewIndex, getViewIndex, insert, insertUpdate, isVisible, modelToView, modelToView, modelToView, paint, preferenceChanged, remove, removeAll, removeUpdate, replace, setParent, setSize, updateChildren, updateLayout, viewToModel, viewToModel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LabelView

public LabelView(Element elem)
Constructs a new view wrapped on an element.

Parameters:
elem - the element
Method Detail

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 in class GlyphView
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

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 in class GlyphView
Returns:
the cached background 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 in class GlyphView
Returns:
the cached font

getFontMetrics

protected FontMetrics getFontMetrics()
Fetches the FontMetrics used for this view.


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 in class GlyphView
Returns:
the cached foreground color

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

Overrides:
isStrikeThrough in class GlyphView
Returns:
the value of the cached strikeThrough property

isSubscript

public boolean isSubscript()
Determines if the glyphs should be rendered as superscript.

Overrides:
isSubscript in class GlyphView
Returns:
the value of the cached subscript 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.


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

Overrides:
isSuperscript in class GlyphView
Returns:
the value of the cached superscript property

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

Overrides:
isUnderline in class GlyphView
Returns:
the value of the cached underline property

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

setPropertiesFromAttributes

protected void setPropertiesFromAttributes()
Sets the cached properties from the attributes.


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

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

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

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


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.