javax.swing.text
Class LabelView

java.lang.Object
  |
  +--javax.swing.text.View
        |
        +--javax.swing.text.GlyphView
              |
              +--javax.swing.text.LabelView
All Implemented Interfaces:
Cloneable, SwingConstants, TabableView

public class LabelView
extends GlyphView
implements TabableView

Safe: 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.

Version:
1.60 12/03/01
Author:
Timothy Prinzing

Field Summary
private  Color bg
           
private  Color fg
           
private  Font font
           
private  boolean strike
           
private  boolean subscript
           
private  boolean superscript
           
private  boolean underline
           
 
Fields inherited from class javax.swing.text.GlyphView
defaultPainter, expander, length, offset, painter, x
 
Fields inherited from class javax.swing.text.View
BadBreakWeight, ExcellentBreakWeight, ForcedBreakWeight, GoodBreakWeight, sharedBiasReturn, 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)
          Enabled: Constructs a new view wrapped on an element.
 
Method Summary
 void changedUpdate(DocumentEvent e, Shape a, ViewFactory f)
          Suppressed: Gives notification from the document that attributes were changed in a location that this view is responsible for.
 Color getBackground()
          Enabled: Fetches the background color to use to render the glyphs.
 Font getFont()
          Enabled: 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 Java2 SDK.
 Color getForeground()
          Enabled: Fetches the foreground color to use to render the glyphs.
 boolean isStrikeThrough()
          Enabled: Determines if the glyphs should have a strikethrough line.
 boolean isSubscript()
          Enabled: Determines if the glyphs should be rendered as superscript.
 boolean isSuperscript()
          Enabled: Determines if the glyphs should be rendered as subscript.
 boolean isUnderline()
          Enabled: Determines if the glyphs should be underlined.
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.
(package private)  void sync()
          Synchronize the view's cached values with the model.
 
Methods inherited from class javax.swing.text.GlyphView
breakView, checkPainter, clone, createFragment, getAlignment, getBreakWeight, getEndOffset, getGlyphPainter, getNextVisualPositionFrom, getPartialSpan, getPreferredSpan, getStartOffset, getTabbedSpan, getTabExpander, getText, insertUpdate, modelToView, paint, paintTextUsingColor, removeUpdate, setGlyphPainter, viewToModel
 
Methods inherited from class javax.swing.text.View
append, forwardUpdate, forwardUpdateToView, getAttributes, getChildAllocation, getContainer, getDocument, getElement, getGraphics, getMaximumSpan, getMinimumSpan, getParent, getResizeWeight, getToolTipText, getView, getViewCount, getViewFactory, getViewIndex, getViewIndex, insert, isVisible, modelToView, modelToView, preferenceChanged, remove, removeAll, replace, setParent, setSize, updateChildren, updateLayout, viewToModel
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.text.TabableView
getPartialSpan, getTabbedSpan
 

Field Detail

font

private Font font

fg

private Color fg

bg

private Color bg

underline

private boolean underline

strike

private boolean strike

superscript

private boolean superscript

subscript

private boolean subscript
Constructor Detail

LabelView

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

Parameters:
elem - the element
Method Detail

sync

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.


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.

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.

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.

See Also:
isSubscript()

setPropertiesFromAttributes

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


getFontMetrics

protected FontMetrics getFontMetrics()
Deprecated. FontMetrics are not used for glyph rendering when running in the Java2 SDK.

Fetches the FontMetrics used for this view.


getBackground

public Color getBackground()
Enabled: 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

getForeground

public Color getForeground()
Enabled: 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

getFont

public Font getFont()
Enabled: 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

isUnderline

public boolean isUnderline()
Enabled: 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

isStrikeThrough

public boolean isStrikeThrough()
Enabled: 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()
Enabled: 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()
Enabled: 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

changedUpdate

public void changedUpdate(DocumentEvent e,
                          Shape a,
                          ViewFactory f)
Suppressed: 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
See Also:
View.changedUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)


comments?