javax.swing.text.html

Class ParagraphView

Implemented Interfaces:
SwingConstants, TabExpander

public class ParagraphView
extends ParagraphView

Displays the a paragraph, and uses css attributes for its configuration.

Nested Class Summary

Nested classes/interfaces inherited from class javax.swing.text.FlowView

FlowView.FlowStrategy

Field Summary

Fields inherited from class javax.swing.text.ParagraphView

firstLineIndent

Fields inherited from class javax.swing.text.FlowView

layoutPool, layoutSpan, strategy

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

ParagraphView(Element elem)
Constructs a ParagraphView for the given element.

Method Summary

protected SizeRequirements
calculateMinorAxisRequirements(int axis, SizeRequirements r)
Calculate the needs for the paragraph along the minor axis.
AttributeSet
getAttributes()
Fetches the attributes to use when rendering.
float
getMaximumSpan(int axis)
Determines the maximum span for this view along an axis.
float
getMinimumSpan(int axis)
Determines the minimum span for this view along an axis.
float
getPreferredSpan(int axis)
Determines the preferred span for this view.
protected StyleSheet
getStyleSheet()
boolean
isVisible()
Indicates whether or not this view should be displayed.
void
paint(Graphics g, Shape a)
Renders using the given rendering surface and area on that surface.
void
setParent(View parent)
Establishes the parent view for this view.
protected void
setPropertiesFromAttributes()
Sets up the paragraph from css attributes instead of the values found in StyleConstants (i.e.

Methods inherited from class javax.swing.text.ParagraphView

adjustRow, breakView, changedUpdate, createRow, findOffsetToCharactersInString, flipEastAndWestAtEnds, getAlignment, getBreakWeight, getClosestPositionTo, getFlowSpan, getFlowStart, getLayoutView, getLayoutViewCount, getNextNorthSouthVisualPositionFrom, getPartialSize, getTabBase, getTabSet, nextTabStop, paint, setFirstLineIndent, setJustification, setLineSpacing, setPropertiesFromAttributes

Methods inherited from class javax.swing.text.FlowView

calculateMinorAxisRequirements, changedUpdate, createRow, getFlowAxis, getFlowSpan, getFlowStart, getViewIndexAtPosition, insertUpdate, layout, loadChildren, removeUpdate, setParent

Methods inherited from class javax.swing.text.BoxView

baselineLayout, baselineRequirements, calculateMajorAxisRequirements, calculateMinorAxisRequirements, childAllocation, flipEastAndWestAtEnds, forwardUpdate, getAlignment, getAxis, getChildAllocation, getHeight, getMaximumSpan, getMinimumSpan, getOffset, getPreferredSpan, getResizeWeight, getSpan, getViewAtPoint, getWidth, isAfter, isAllocationValid, isBefore, isLayoutValid, layout, layoutChanged, layoutMajorAxis, layoutMinorAxis, modelToView, paint, paintChild, preferenceChanged, replace, setAxis, setSize, viewToModel

Methods inherited from class javax.swing.text.CompositeView

childAllocation, flipEastAndWestAtEnds, getBottomInset, getChildAllocation, getInsideAllocation, getLeftInset, getNextEastWestVisualPositionFrom, getNextNorthSouthVisualPositionFrom, getNextVisualPositionFrom, getRightInset, getTopInset, getView, getViewAtPoint, getViewAtPosition, getViewCount, getViewIndex, getViewIndexAtPosition, isAfter, isBefore, loadChildren, modelToView, modelToView, replace, setInsets, setParagraphInsets, setParent, viewToModel

Methods inherited from class javax.swing.text.View

Shape modelToView, append, breakView, changedUpdate, createFragment, 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, int viewToModel, isVisible, modelToView, modelToView, paint, preferenceChanged, remove, removeAll, removeUpdate, replace, setParent, setSize, updateChildren, updateLayout, viewToModel

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

ParagraphView

public ParagraphView(Element elem)
Constructs a ParagraphView for the given element.
Parameters:
elem - the element that this view is responsible for

Method Details

calculateMinorAxisRequirements

protected SizeRequirements calculateMinorAxisRequirements(int axis,
                                                          SizeRequirements r)
Calculate the needs for the paragraph along the minor axis. This implemented to use the requirements of the superclass, modified slightly to set a minimum span allowed. Typical html rendering doesn't let the view size shrink smaller than the length of the longest word.
Overrides:
calculateMinorAxisRequirements in interface FlowView

getAttributes

public AttributeSet getAttributes()
Fetches the attributes to use when rendering. This is implemented to multiplex the attributes specified in the model with a StyleSheet.
Overrides:
getAttributes in interface View

getMaximumSpan

public float getMaximumSpan(int axis)
Determines the maximum span for this view along an axis. Returns 0 if the view is not visible, otherwise it calls the superclass method ot get the maximum span.
Overrides:
getMaximumSpan in interface BoxView
Parameters:
axis - may be either View.X_AXIS or View.Y_AXIS
Returns:
the maximum span the view can be rendered into
See Also:
ParagraphView

getMinimumSpan

public float getMinimumSpan(int axis)
Determines the minimum span for this view along an axis. Returns 0 if the view is not visible, otherwise it calls the superclass method to get the minimum span.
Overrides:
getMinimumSpan in interface BoxView
Parameters:
axis - may be either View.X_AXIS or View.Y_AXIS
Returns:
the minimum span the view can be rendered into
See Also:
ParagraphView

getPreferredSpan

public float getPreferredSpan(int axis)
Determines the preferred span for this view. Returns 0 if the view is not visible, otherwise it calls the superclass method to get the preferred span. axis.
Overrides:
getPreferredSpan in interface BoxView
Parameters:
axis - may be either View.X_AXIS or View.Y_AXIS
Returns:
the span the view would like to be rendered into; typically the view is told to render into the span that is returned, although there is no guarantee; the parent may choose to resize or break the view
See Also:
ParagraphView

getStyleSheet

protected StyleSheet getStyleSheet()

isVisible

public boolean isVisible()
Indicates whether or not this view should be displayed. If none of the children wish to be displayed and the only visible child is the break that ends the paragraph, the paragraph will not be considered visible. Otherwise, it will be considered visible and return true.
Overrides:
isVisible in interface View
Returns:
true if the paragraph should be displayed

paint

public void paint(Graphics g,
                  Shape a)
Renders using the given rendering surface and area on that surface. This is implemented to delgate to the superclass after stashing the base coordinate for tab calculations.
Overrides:
paint in interface ParagraphView
Parameters:
g - the rendering surface to use
a - the allocated region to render into

setParent

public void setParent(View parent)
Establishes the parent view for this view. This is guaranteed to be called before any other methods if the parent view is functioning properly.

This is implemented to forward to the superclass as well as call the setPropertiesFromAttributes method to set the paragraph properties from the css attributes. The call is made at this time to ensure the ability to resolve upward through the parents view attributes.

Overrides:
setParent in interface FlowView
Parameters:
parent - the new parent, or null if the view is being removed from a parent it was previously added to

setPropertiesFromAttributes

protected void setPropertiesFromAttributes()
Sets up the paragraph from css attributes instead of the values found in StyleConstants (i.e. which are used by the superclass). Since
Overrides:
setPropertiesFromAttributes in interface ParagraphView