javax.swing.text.html
Class InlineView

java.lang.Object
  extended by javax.swing.text.View
      extended by javax.swing.text.GlyphView
          extended by javax.swing.text.LabelView
              extended by javax.swing.text.html.InlineView
All 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)
          Tries to break the view near the specified view span 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)
          Determines how well the specified view location is suitable for inserting a line break.
 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
getBackground, getFont, getFontMetrics, getForeground, isStrikeThrough, isSubscript, isSuperscript, isUnderline, setBackground, setStrikeThrough, setSubscript, setSuperscript, setUnderline
 
Methods inherited from class javax.swing.text.GlyphView
checkPainter, clone, createFragment, getAlignment, getEndOffset, getGlyphPainter, getNextVisualPositionFrom, getPartialSpan, getPreferredSpan, getStartOffset, getTabbedSpan, getTabExpander, getText, modelToView, paint, setGlyphPainter, viewToModel
 
Methods inherited from class javax.swing.text.View
append, dump, forwardUpdate, forwardUpdateToView, getChildAllocation, getContainer, getDocument, getElement, getGraphics, getMaximumSpan, 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

InlineView

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

Parameters:
element - the element for this view
Method Detail

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 class 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 class GlyphView
Parameters:
e - the document event
a - the current allocation of this view
f - the view factory for creating new views
Since:
1.5

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 class 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 class View
Returns:
the attributes that are used for rendering

getBreakWeight

public int getBreakWeight(int axis,
                          float pos,
                          float len)
Description copied from class: GlyphView
Determines how well the specified view location is suitable for inserting a line break. If axis is View.Y_AXIS, then this method forwards to the superclass, if axis is View.X_AXIS then this method returns View.ExcellentBreakWeight if there is a suitable break location (usually whitespace) within the specified view span, or View.GoodBreakWeight if not.

Overrides:
getBreakWeight in class GlyphView
Parameters:
axis - the axis along which the break weight is requested
pos - the starting view location
len - the length of the span at which the view should be broken
Returns:
the break weight

breakView

public View breakView(int axis,
                      int offset,
                      float pos,
                      float len)
Description copied from class: GlyphView
Tries to break the view near the specified view span len. The glyph view can only be broken in the X direction. For Y direction it returns itself.

Overrides:
breakView in class GlyphView
Parameters:
axis - the axis for breaking, may be View.X_AXIS or View.Y_AXIS
offset - the model location where the fragment should start
pos - the view position along the axis where the fragment starts
len - the desired length of the fragment view
Returns:
the fragment view, or this if breaking was not possible

setPropertiesFromAttributes

protected void setPropertiesFromAttributes()
Loads the character style properties from the stylesheet.

Overrides:
setPropertiesFromAttributes in class LabelView

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

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 class View
Parameters:
axis - the axis
Returns:
the minimum span along the specified axis