javax.swing.text

Class LabelView

Implemented Interfaces:
Cloneable, SwingConstants, TabableView
Known Direct 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, changedUpdate, checkPainter, clone, createFragment, getAlignment, getBackground, getBreakWeight, getEndOffset, getFont, getForeground, getGlyphPainter, getNextVisualPositionFrom, getPartialSpan, getPreferredSpan, getStartOffset, getTabExpander, getTabbedSpan, getText, insertUpdate, isStrikeThrough, isSubscript, isSuperscript, isUnderline, modelToView, paint, removeUpdate, setGlyphPainter, viewToModel

Methods inherited from class javax.swing.text.View

append, breakView, changedUpdate, createFragment, dump, 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, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

LabelView

public LabelView(Element element)
Creates a new GlyphView for the given Element.
Parameters:
element - the element that is rendered by this GlyphView

Method Details

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 interface 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 interface GlyphView
Returns:
the background color for the glyphs

getFont

public Font getFont()
Returns the font for the glyphs.
Overrides:
getFont in interface 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

getForeground

public Color getForeground()
Returns the foreground color for the glyphs.
Overrides:
getForeground in interface GlyphView
Returns:
the foreground color for the glyphs

isStrikeThrough

public boolean isStrikeThrough()
Returns true if the glyphs are rendered strike-through, false otherwise.
Overrides:
isStrikeThrough in interface GlyphView
Returns:
true if the glyphs are rendered strike-through, false otherwise

isSubscript

public boolean isSubscript()
Returns true if the glyphs are rendered as subscript, false otherwise.
Overrides:
isSubscript in interface GlyphView
Returns:
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 interface GlyphView
Returns:
true if the glyphs are rendered as superscript, false otherwise

isUnderline

public boolean isUnderline()
Returns true if the glyphs are rendered underlined, false otherwise.
Overrides:
isUnderline in interface GlyphView
Returns:
true if the glyphs are rendered underlined, false otherwise

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

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(DocumentEvent,Shape,ViewFactory) method

setStrikeThrough

protected void setStrikeThrough(boolean flag)
Sets the strike-through flag.
Parameters:
flag - true if the glyphs are rendered strike-through, false otherwise

setSubscript

protected void setSubscript(boolean flag)
Sets the subscript flag.
Parameters:
flag - true if the glyphs are rendered as subscript, false otherwise

setSuperscript

protected void setSuperscript(boolean flag)
Sets the superscript flag.
Parameters:
flag - true if the glyphs are rendered as superscript, false otherwise

setUnderline

protected void setUnderline(boolean flag)
Sets the underline flag.
Parameters:
flag - true if the glyphs are rendered underlined, false otherwise

LabelView.java -- A view to render styled text Copyright (C) 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.