javax.swing.text.html

Class InlineView

Implemented Interfaces:
Cloneable, SwingConstants, TabableView

public class InlineView
extends LabelView

Renders HTML content (identified by HTML.Tag.CONTENT). This is basically a LabelView that is adjusted to understand styles defined by stylesheets.

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

InlineView(Element element)
Creates a new InlineView that renders the specified element.

Method Summary

View
breakView(int axis, int offset, float pos, float len)
void
changedUpdate(DocumentEvent e, Shape a, ViewFactory f)
Receives notification that attributes have changed in the document in a location that this view is responsible for.
AttributeSet
getAttributes()
Returns the attributes that are used for rendering.
int
getBreakWeight(int axis, float pos, float len)
float
getMinimumSpan(int axis)
Returns the minimum span for the specified axis.
protected StyleSheet
getStyleSheet()
Returns the stylesheet used by this view.
void
insertUpdate(DocumentEvent e, Shape a, ViewFactory f)
Receives notification that something was inserted into the document in a location that this view is responsible for.
void
removeUpdate(DocumentEvent e, Shape a, ViewFactory f)
Receives notification that something was removed from the document in a location that this view is responsible for.
protected void
setPropertiesFromAttributes()
Loads the character style properties from the stylesheet.

Methods inherited from class javax.swing.text.LabelView

changedUpdate, getBackground, getFont, getFontMetrics, getForeground, isStrikeThrough, isSubscript, isSuperscript, isUnderline, setBackground, setPropertiesFromAttributes, setStrikeThrough, setSubscript, setSuperscript, setUnderline

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

InlineView

public InlineView(Element element)
Creates a new InlineView that renders the specified element.
Parameters:
element - the element for this view

Method Details

breakView

public View breakView(int axis,
                      int offset,
                      float pos,
                      float len)
Overrides:
breakView in interface GlyphView

changedUpdate

public void changedUpdate(DocumentEvent e,
                          Shape a,
                          ViewFactory f)
Receives notification that attributes have changed in the document in a location that this view is responsible for. This calls setPropertiesFromAttributes().
Overrides:
changedUpdate in interface LabelView
Parameters:
e - the document event
a - the current allocation of this view
f - the view factory for creating new views
Since:
1.5

getAttributes

public AttributeSet getAttributes()
Returns the attributes that are used for rendering. This is implemented to multiplex the attributes specified in the model with a stylesheet.
Overrides:
getAttributes in interface View
Returns:
the attributes that are used for rendering

getBreakWeight

public int getBreakWeight(int axis,
                          float pos,
                          float len)
Overrides:
getBreakWeight in interface GlyphView

getMinimumSpan

public float getMinimumSpan(int axis)
Returns the minimum span for the specified axis. This returns the width of the longest word for the X axis and the super behaviour for the Y axis. This is a slight deviation from the reference implementation. IMO this should improve rendering behaviour so that an InlineView never gets smaller than the longest word in it.
Overrides:
getMinimumSpan in interface View

getStyleSheet

protected StyleSheet getStyleSheet()
Returns the stylesheet used by this view. This returns the stylesheet of the HTMLDocument that is rendered by this view.
Returns:
the stylesheet used by this view

insertUpdate

public void insertUpdate(DocumentEvent e,
                         Shape a,
                         ViewFactory f)
Receives notification that something was inserted into the document in a location that this view is responsible for.
Overrides:
insertUpdate in interface GlyphView
Parameters:
e - the document event
a - the current allocation of this view
f - the view factory for creating new views
Since:
1.5

removeUpdate

public void removeUpdate(DocumentEvent e,
                         Shape a,
                         ViewFactory f)
Receives notification that something was removed from the document in a location that this view is responsible for.
Overrides:
removeUpdate in interface GlyphView
Parameters:
e - the document event
a - the current allocation of this view
f - the view factory for creating new views
Since:
1.5

setPropertiesFromAttributes

protected void setPropertiesFromAttributes()
Loads the character style properties from the stylesheet.
Overrides:
setPropertiesFromAttributes in interface LabelView

InlineView.java -- Renders HTML content Copyright (C) 2006 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.