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

A GlyphView that caches the textattributes for most effective 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 element)
          Creates a new GlyphView for the given Element.
 
Method Summary
 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.
 Color getBackground()
          Returns the background color for the glyphs.
 Font getFont()
          Returns the font for the glyphs.
protected  FontMetrics getFontMetrics()
          Deprecated. this is not used anymore
 Color getForeground()
          Returns the foreground color for the glyphs.
 boolean isStrikeThrough()
          Returns true if the glyphs are rendered strike-through, false otherwise.
 boolean isSubscript()
          Returns true if the glyphs are rendered as subscript, false otherwise.
 boolean isSuperscript()
          Returns true if the glyphs are rendered as superscript, false otherwise.
 boolean isUnderline()
          Returns true if the glyphs are rendered underlined, false otherwise.
protected  void setBackground(Color bg)
          Sets the background color for the glyphs.
protected  void setPropertiesFromAttributes()
          Loads the properties of this label view from the element's text attributes.
protected  void setStrikeThrough(boolean flag)
          Sets the strike-through flag.
protected  void setSubscript(boolean flag)
          Sets the subscript flag.
protected  void setSuperscript(boolean flag)
          Sets the superscript flag.
protected  void setUnderline(boolean flag)
          Sets the underline flag.
 
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, removeUpdate, setGlyphPainter, viewToModel
 
Methods inherited from class javax.swing.text.View
append, dump, 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
 

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

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 changedUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory) method


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 setPropertiesFromAttributes().

Overrides:
changedUpdate in class GlyphView
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.

Overrides:
getBackground in class GlyphView
Returns:
the background color for the glyphs

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

getForeground

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

Overrides:
getForeground in class GlyphView
Returns:
the foreground color for the glyphs

getFont

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

Overrides:
getFont in class GlyphView
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

isUnderline

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

Overrides:
isUnderline in class GlyphView
Returns:
true if the glyphs are rendered underlined, false otherwise

setUnderline

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

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

isSubscript

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

Overrides:
isSubscript in class GlyphView
Returns:
true if the glyphs are rendered as subscript, false otherwise

setSubscript

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

Parameters:
flag - 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.

Overrides:
isSuperscript in class GlyphView
Returns:
true if the glyphs are rendered as superscript, false otherwise

setSuperscript

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

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

isStrikeThrough

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

Overrides:
isStrikeThrough in class GlyphView
Returns:
true if the glyphs are rendered strike-through, false otherwise

setStrikeThrough

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

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