edu.northwestern.at.utils.swing
Class JustifiableTextParagraphView

java.lang.Object
  extended by javax.swing.text.View
      extended by javax.swing.text.CompositeView
          extended by javax.swing.text.BoxView
              extended by javax.swing.text.FlowView
                  extended by javax.swing.text.ParagraphView
                      extended by edu.northwestern.at.utils.swing.JustifiableTextParagraphView
All Implemented Interfaces:
javax.swing.SwingConstants, javax.swing.text.TabExpander

public class JustifiableTextParagraphView
extends javax.swing.text.ParagraphView

A paragraph view for styled text which can contain fully justified lines of text.


Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.text.FlowView
javax.swing.text.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
JustifiableTextParagraphView(javax.swing.text.Element elem)
          Create a JustifiableParagraphView for a paragraph element.
 
Method Summary
protected  javax.swing.text.View createRow()
          Create a JustifiedTextRowView to hold a a row's worth of children in a flow.
 int getFlowSpan(int index)
          Fetch the constraining span to flow against for the given child index.
protected  void layoutMinorAxis(int targetSpan, int axis, int[] offsets, int[] spans)
          Perform layout for the minor axis of the box.
 
Methods inherited from class javax.swing.text.ParagraphView
adjustRow, breakView, changedUpdate, findOffsetToCharactersInString, flipEastAndWestAtEnds, getAlignment, getBreakWeight, getClosestPositionTo, getFlowStart, getLayoutView, getLayoutViewCount, getNextNorthSouthVisualPositionFrom, getPartialSize, getTabBase, getTabSet, nextTabStop, paint, setFirstLineIndent, setJustification, setLineSpacing, setPropertiesFromAttributes
 
Methods inherited from class javax.swing.text.FlowView
calculateMinorAxisRequirements, getFlowAxis, getViewIndexAtPosition, insertUpdate, layout, loadChildren, removeUpdate, setParent
 
Methods inherited from class javax.swing.text.BoxView
baselineLayout, baselineRequirements, calculateMajorAxisRequirements, childAllocation, forwardUpdate, getAxis, getChildAllocation, getHeight, getMaximumSpan, getMinimumSpan, getOffset, getPreferredSpan, getResizeWeight, getSpan, getViewAtPoint, getWidth, isAfter, isAllocationValid, isBefore, isLayoutValid, layoutChanged, layoutMajorAxis, 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, getAttributes, getBreakWeight, getContainer, getDocument, getElement, getEndOffset, getGraphics, getParent, getStartOffset, getToolTipText, getViewFactory, getViewIndex, insert, isVisible, modelToView, remove, removeAll, updateChildren, updateLayout, viewToModel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JustifiableTextParagraphView

public JustifiableTextParagraphView(javax.swing.text.Element elem)
Create a JustifiableParagraphView for a paragraph element.

Parameters:
elem - The paragraph text element.

JustifiableTextFlowStrategy is used as the flow strategy. Each line of text in the paragraph is stored in a JustifiedTextRowView.

Method Detail

createRow

protected javax.swing.text.View createRow()
Create a JustifiedTextRowView to hold a a row's worth of children in a flow.

Overrides:
createRow in class javax.swing.text.ParagraphView
Returns:
The new JustifiedTextRowView.

getFlowSpan

public int getFlowSpan(int index)
Fetch the constraining span to flow against for the given child index.

Overrides:
getFlowSpan in class javax.swing.text.ParagraphView
Parameters:
index - The index of the view being queried.
Returns:
The constraining span for the given view at index.

layoutMinorAxis

protected void layoutMinorAxis(int targetSpan,
                               int axis,
                               int[] offsets,
                               int[] spans)
Perform layout for the minor axis of the box.

This is the same as the layout for a standard paragraph view except that we honor the first line indent attributed.

Overrides:
layoutMinorAxis in class javax.swing.text.BoxView
Parameters:
targetSpan - The total span given to the view, which should be used to layout the children.
axis - The axis being layed out.
offsets - The offsets from the origin of the view for each of the child views. This is a return value and is filled in here.
spans - The span of each child view. This is a return value and is filled in here.

The offset and span for each child view is stored in the offsets and spans parameters.