Home » openjdk-7 » javax » swing » text » [javadoc | source]
javax.swing.text
public class: ParagraphView [javadoc | source]
java.lang.Object
   javax.swing.text.View
      javax.swing.text.CompositeView
         javax.swing.text.BoxView
            javax.swing.text.FlowView
               javax.swing.text.ParagraphView

All Implemented Interfaces:
    TabExpander, SwingConstants

Direct Known Subclasses:
    PlainParagraph, ParagraphView, PlainParagraph, LineView, I18nFieldView

View of a simple line-wrapping paragraph that supports multiple fonts, colors, components, icons, etc. It is basically a vertical box with a margin around it. The contents of the box are a bunch of rows which are special horizontal boxes. This view creates a collection of views that represent the child elements of the paragraph element. Each of these views are placed into a row directly if they will fit, otherwise the breakView method is called to try and carve the view into pieces that fit.
Nested Class Summary:
class  ParagraphView.Row  Internally created view that has the purpose of holding the views that represent the children of the paragraph that have been arranged in rows. 
Field Summary
protected  int firstLineIndent    Indentation for the first line, from the left inset. 
static  Class i18nStrategy    Used to create an i18n-based layout strategy 
static  char[] tabChars    Used for searching for a tab. 
static  char[] tabDecimalChars    Used for searching for a tab or decimal character. 
Fields inherited from javax.swing.text.FlowView:
layoutSpan,  layoutPool,  strategy
Fields inherited from javax.swing.text.BoxView:
majorAxis,  majorSpan,  minorSpan,  majorReqValid,  minorReqValid,  majorRequest,  minorRequest,  majorAllocValid,  majorOffsets,  majorSpans,  minorAllocValid,  minorOffsets,  minorSpans,  tempRect
Fields inherited from javax.swing.text.View:
BadBreakWeight,  GoodBreakWeight,  ExcellentBreakWeight,  ForcedBreakWeight,  X_AXIS,  Y_AXIS,  sharedBiasReturn
Constructor:
 public ParagraphView(Element elem) 
    Constructs a ParagraphView for the given element.
    Parameters:
    elem - the element that this view is responsible for
Method from javax.swing.text.ParagraphView Summary:
breakView,   calculateMinorAxisRequirements,   changedUpdate,   createRow,   findOffsetToCharactersInString,   flipEastAndWestAtEnds,   getAlignment,   getBreakWeight,   getClosestPositionTo,   getFlowSpan,   getFlowStart,   getLayoutView,   getLayoutViewCount,   getNextNorthSouthVisualPositionFrom,   getPartialSize,   getTabBase,   getTabSet,   nextTabStop,   paint,   setFirstLineIndent,   setJustification,   setLineSpacing,   setPropertiesFromAttributes
Methods from javax.swing.text.FlowView:
calculateMinorAxisRequirements,   changedUpdate,   createRow,   getFlowAxis,   getFlowSpan,   getFlowStart,   getViewIndexAtPosition,   insertUpdate,   layout,   loadChildren,   removeUpdate,   setParent
Methods from javax.swing.text.BoxView:
baselineLayout,   baselineRequirements,   calculateMajorAxisRequirements,   calculateMinorAxisRequirements,   checkRequests,   childAllocation,   flipEastAndWestAtEnds,   forwardUpdate,   getAlignment,   getAxis,   getChildAllocation,   getHeight,   getMaximumSpan,   getMinimumSpan,   getOffset,   getPreferredSpan,   getResizeWeight,   getSpan,   getSpanOnAxis,   getViewAtPoint,   getWidth,   isAfter,   isAllocationValid,   isBefore,   isLayoutValid,   layout,   layoutChanged,   layoutMajorAxis,   layoutMinorAxis,   modelToView,   paint,   paintChild,   preferenceChanged,   replace,   setAxis,   setSize,   setSpanOnAxis,   updateChildSizes,   updateLayoutArray,   viewToModel
Methods from 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 from javax.swing.text.View:
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,   isVisible,   modelToView,   modelToView,   modelToView,   paint,   preferenceChanged,   remove,   removeAll,   removeUpdate,   replace,   setParent,   setSize,   updateChildren,   updateLayout,   viewToModel,   viewToModel
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from javax.swing.text.ParagraphView Detail:
 public View breakView(int axis,
    float len,
    Shape a) 
    Breaks this view on the given axis at the given length.

    ParagraphView instances are breakable along the Y_AXIS only, and only if len is after the first line.

 protected SizeRequirements calculateMinorAxisRequirements(int axis,
    SizeRequirements r) 
    Calculate the needs for the paragraph along the minor axis.

    This uses size requirements of the superclass, modified to take into account the non-breakable areas at the adjacent views edges. The minimal size requirements for such views should be no less than the sum of all adjacent fragments.

    If the {@code axis} parameter is neither {@code View.X_AXIS} nor {@code View.Y_AXIS}, IllegalArgumentException is thrown. If the {@code r} parameter is {@code null,} a new {@code SizeRequirements} object is created, otherwise the supplied {@code SizeRequirements} object is returned.

 public  void changedUpdate(DocumentEvent changes,
    Shape a,
    ViewFactory f) 
    Gives notification from the document that attributes were changed in a location that this view is responsible for.
 protected View createRow() 
    Create a View that should be used to hold a a row's worth of children in a flow.
 protected int findOffsetToCharactersInString(char[] string,
    int start) 
    Finds the next character in the document with a character in string, starting at offset start. If there are no characters found, -1 will be returned.
 protected boolean flipEastAndWestAtEnds(int position,
    Bias bias) 
    Determines in which direction the next view lays. Consider the View at index n. Typically the Views are layed out from left to right, so that the View to the EAST will be at index n + 1, and the View to the WEST will be at index n - 1. In certain situations, such as with bidirectional text, it is possible that the View to EAST is not at index n + 1, but rather at index n - 1, or that the View to the WEST is not at index n - 1, but index n + 1. In this case this method would return true, indicating the Views are layed out in descending order.

    This will return true if the text is layed out right to left at position, otherwise false.

 public float getAlignment(int axis) 
    Determines the desired alignment for this view along an axis. This is implemented to give the alignment to the center of the first row along the y axis, and the default along the x axis.
 public int getBreakWeight(int axis,
    float len) 
    Gets the break weight for a given location.

    ParagraphView instances are breakable along the Y_AXIS only, and only if len is after the first row. If the length is less than one row, a value of BadBreakWeight is returned.

 protected int getClosestPositionTo(int pos,
    Bias b,
    Shape a,
    int direction,
    Bias[] biasRet,
    int rowIndex,
    int x) throws BadLocationException 
    Returns the closest model position to x. rowIndex gives the index of the view that corresponds that should be looked in.
 public int getFlowSpan(int index) 
    Fetches the constraining span to flow against for the given child index.
 public int getFlowStart(int index) 
    Fetches the location along the flow axis that the flow span will start at.
 protected View getLayoutView(int index) 
    Returns the view at a given index. The child views of the paragraph are rows which have been used to arrange pieces of the Views that represent the child elements. This methods returns the view responsible for the child element index (prior to breaking). These are the Views that were produced from a factory (to represent the child elements) and used for layout.
 protected int getLayoutViewCount() 
    Returns the number of views that this view is responsible for. The child views of the paragraph are rows which have been used to arrange pieces of the Views that represent the child elements. This is the number of views that have been tiled in two dimensions, and should be equivalent to the number of child elements to the element this view is responsible for.
 protected int getNextNorthSouthVisualPositionFrom(int pos,
    Bias b,
    Shape a,
    int direction,
    Bias[] biasRet) throws BadLocationException 
    Returns the next visual position for the cursor, in either the east or west direction. Overridden from CompositeView.
 protected float getPartialSize(int startOffset,
    int endOffset) 
    Returns the size used by the views between startOffset and endOffset. This uses getPartialView to calculate the size if the child view implements the TabableView interface. If a size is needed and a View does not implement the TabableView interface, the preferredSpan will be used.
 protected float getTabBase() 
    Returns where the tabs are calculated from.
 protected TabSet getTabSet() 
    Gets the Tabset to be used in calculating tabs.
 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).

 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.
 protected  void setFirstLineIndent(float fi) 
    Sets the indent on the first line.
 protected  void setJustification(int j) 
    Sets the type of justification.
 protected  void setLineSpacing(float ls) 
    Sets the line spacing.
 protected  void setPropertiesFromAttributes() 
    Set the cached properties from the attributes.