javax.swing.text.html
Class LineView

java.lang.Object
  extended byjavax.swing.text.View
      extended byjavax.swing.text.CompositeView
          extended byjavax.swing.text.BoxView
              extended byjavax.swing.text.FlowView
                  extended byjavax.swing.text.ParagraphView
                      extended byjavax.swing.text.html.ParagraphView
                          extended byjavax.swing.text.html.LineView
All Implemented Interfaces:
SwingConstants, TabExpander

class LineView
extends ParagraphView

A view implementation to display an unwrapped preformatted line.

This subclasses ParagraphView, but this really only contains one Row of text.

Author:
Timothy Prinzing

Nested Class Summary
 
Nested classes inherited from class javax.swing.text.ParagraphView
 
Nested classes inherited from class javax.swing.text.FlowView
FlowView.FlowStrategy
 
Field Summary
(package private)  int tabBase
          Last place painted at.
 
Fields inherited from class javax.swing.text.html.ParagraphView
 
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.BoxView
 
Fields inherited from class javax.swing.text.CompositeView
 
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
LineView(Element elem)
          Creates a LineView object.
 
Method Summary
 float getAlignment(int axis)
          Gets the alignment for an axis.
protected  int getCharactersPerTab()
           
 float getMinimumSpan(int axis)
          Determines the minimum span for this view along an axis.
protected  float getPreTab(float x, int tabOffset)
          Returns the location for the tab.
 int getResizeWeight(int axis)
          Gets the resize weight for the specified axis.
 boolean isVisible()
          Preformatted lines are not suppressed if they have only whitespace, so they are always visible.
protected  void layout(int width, int height)
          Lays out the children.
 float nextTabStop(float x, int tabOffset)
          Returns the next tab stop position given a reference position.
 
Methods inherited from class javax.swing.text.html.ParagraphView
calculateMinorAxisRequirements, getAttributes, getMaximumSpan, getPreferredSpan, getStyleSheet, paint, setParent, setPropertiesFromAttributes
 
Methods inherited from class javax.swing.text.ParagraphView
adjustRow, breakView, changedUpdate, createRow, findOffsetToCharactersInString, flipEastAndWestAtEnds, getBreakWeight, getClosestPositionTo, getFlowSpan, getFlowStart, getLayoutView, getLayoutViewCount, getNextNorthSouthVisualPositionFrom, getPartialSize, getTabBase, getTabSet, setFirstLineIndent, setJustification, setLineSpacing
 
Methods inherited from class javax.swing.text.FlowView
getFlowAxis, getViewIndexAtPosition, insertUpdate, loadChildren, removeUpdate
 
Methods inherited from class javax.swing.text.BoxView
baselineLayout, baselineRequirements, calculateMajorAxisRequirements, childAllocation, forwardUpdate, getAxis, getChildAllocation, getHeight, getOffset, getSpan, getViewAtPoint, getWidth, isAfter, isAllocationValid, isBefore, isLayoutValid, layoutChanged, layoutMajorAxis, layoutMinorAxis, modelToView, paintChild, preferenceChanged, replace, setAxis, setSize, viewToModel
 
Methods inherited from class javax.swing.text.CompositeView
getBottomInset, getInsideAllocation, getLeftInset, getNextEastWestVisualPositionFrom, getNextVisualPositionFrom, getRightInset, getTopInset, getView, getViewAtPosition, getViewCount, getViewIndex, modelToView, setInsets, setParagraphInsets
 
Methods inherited from class javax.swing.text.View
append, breakView, createFragment, forwardUpdateToView, getBreakWeight, getContainer, getDocument, getElement, getEndOffset, getGraphics, getParent, getStartOffset, getToolTipText, getViewFactory, getViewIndex, insert, modelToView, remove, removeAll, updateChildren, updateLayout, viewToModel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tabBase

int tabBase
Last place painted at.

Constructor Detail

LineView

public LineView(Element elem)
Creates a LineView object.

Parameters:
elem - the element to wrap in a view
Method Detail

isVisible

public boolean isVisible()
Preformatted lines are not suppressed if they have only whitespace, so they are always visible.

Overrides:
isVisible in class ParagraphView
Returns:
true if the paragraph should be displayed

getMinimumSpan

public float getMinimumSpan(int axis)
Determines the minimum span for this view along an axis. The preformatted line should refuse to be sized less than the preferred size.

Overrides:
getMinimumSpan in class ParagraphView
Parameters:
axis - may be either View.X_AXIS or View.Y_AXIS
Returns:
the minimum span the view can be rendered into
See Also:
View.getPreferredSpan(int)

getResizeWeight

public int getResizeWeight(int axis)
Gets the resize weight for the specified axis.

Overrides:
getResizeWeight in class BoxView
Parameters:
axis - may be either X_AXIS or Y_AXIS
Returns:
the weight

getAlignment

public float getAlignment(int axis)
Gets the alignment for an axis.

Overrides:
getAlignment in class ParagraphView
Parameters:
axis - may be either X_AXIS or Y_AXIS
Returns:
the alignment

layout

protected void layout(int width,
                      int height)
Lays out the children. If the layout span has changed, the rows are rebuilt. The superclass functionality is called after checking and possibly rebuilding the rows. If the height has changed, the preferenceChanged method is called on the parent since the vertical preference is rigid.

Overrides:
layout in class FlowView
Parameters:
width - the width to lay out against >= 0. This is the width inside of the inset area.
height - the height to lay out against >= 0 (not used by paragraph, but used by the superclass). This is the height inside of the inset area.

nextTabStop

public float nextTabStop(float x,
                         int tabOffset)
Returns the next tab stop position given a reference position. This view implements the tab coordinate system, and calls getTabbedSpan on the logical children in the process of layout to determine the desired span of the children. The logical children can delegate their tab expansion upward to the paragraph which knows how to expand tabs. LabelView is an example of a view that delegates its tab expansion needs upward to the paragraph.

This is implemented to try and locate a TabSet in the paragraph element's attribute set. If one can be found, its settings will be used, otherwise a default expansion will be provided. The base location for for tab expansion is the left inset from the paragraphs most recent allocation (which is what the layout of the children is based upon).

Specified by:
nextTabStop in interface TabExpander
Overrides:
nextTabStop in class ParagraphView
Parameters:
x - the X reference position
tabOffset - the position within the text stream that the tab occurred at >= 0.
Returns:
the trailing end of the tab expansion >= 0
See Also:
TabSet, TabStop, LabelView

getPreTab

protected float getPreTab(float x,
                          int tabOffset)
Returns the location for the tab.


getCharactersPerTab

protected int getCharactersPerTab()
Returns:
number of characters per tab, 8.