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

All Implemented Interfaces:
    TabExpander, SwingConstants

View of plain text (text with only one font and color) that does line-wrapping. This view expects that its associated element has child elements that represent the lines it should be wrapping. It is implemented as a vertical box that contains logical line views. The logical line views are nested classes that render the logical line as multiple physical line if the logical line is too wide to fit within the allocation. The line views draw upon the outer class for its state to reduce their memory requirements.

The line views do all of their rendering through the drawLine method which in turn does all of its rendering through the drawSelectedText and drawUnselectedText methods. This enables subclasses to easily specialize the rendering without concern for the layout aspects.

Nested Class Summary:
class  WrappedPlainView.WrappedLine  Simple view of a line that wraps if it doesn't fit withing the horizontal space allocated. This class tries to be lightweight by carrying little state of it's own and sharing the state of the outer class with it's sibblings. 
Field Summary
 FontMetrics metrics     
 Segment lineBuffer     
 boolean widthChanging     
 int tabBase     
 int tabSize     
 boolean wordWrap     
 int sel0     
 int sel1     
 Color unselected     
 Color selected     
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 WrappedPlainView(Element elem) 
    Creates a new WrappedPlainView. Lines will be wrapped on character boundaries.
    Parameters:
    elem - the element underlying the view
 public WrappedPlainView(Element elem,
    boolean wordWrap) 
    Creates a new WrappedPlainView. Lines can be wrapped on either character or word boundaries depending upon the setting of the wordWrap parameter.
    Parameters:
    elem - the element underlying the view
    wordWrap - should lines be wrapped on word boundaries?
Method from javax.swing.text.WrappedPlainView Summary:
calculateBreakPosition,   changedUpdate,   drawLine,   drawSelectedText,   drawUnselectedText,   getLineBuffer,   getMaximumSpan,   getMinimumSpan,   getPreferredSpan,   getTabSize,   insertUpdate,   loadChildren,   loadText,   nextTabStop,   paint,   removeUpdate,   setSize,   updateChildren,   updateMetrics
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.WrappedPlainView Detail:
 protected int calculateBreakPosition(int p0,
    int p1) 
    This is called by the nested wrapped line views to determine the break location. This can be reimplemented to alter the breaking behavior. It will either break at word or character boundaries depending upon the break argument given at construction.
 public  void changedUpdate(DocumentEvent e,
    Shape a,
    ViewFactory f) 
    Gives notification from the document that attributes were changed in a location that this view is responsible for.
 protected  void drawLine(int p0,
    int p1,
    Graphics g,
    int x,
    int y) 
    Renders a line of text, suppressing whitespace at the end and expanding any tabs. This is implemented to make calls to the methods drawUnselectedText and drawSelectedText so that the way selected and unselected text are rendered can be customized.
 protected int drawSelectedText(Graphics g,
    int x,
    int y,
    int p0,
    int p1) throws BadLocationException 
    Renders the given range in the model as selected text. This is implemented to render the text in the color specified in the hosting component. It assumes the highlighter will render the selected background.
 protected int drawUnselectedText(Graphics g,
    int x,
    int y,
    int p0,
    int p1) throws BadLocationException 
    Renders the given range in the model as normal unselected text.
 protected final Segment getLineBuffer() 
    Gives access to a buffer that can be used to fetch text from the associated document.
 public float getMaximumSpan(int axis) 
    Determines the maximum span for this view along an axis. This is implemented to provide the superclass behavior after first making sure that the current font metrics are cached (for the nested lines which use the metrics to determine the height of the potentially wrapped lines).
 public float getMinimumSpan(int axis) 
    Determines the minimum span for this view along an axis. This is implemented to provide the superclass behavior after first making sure that the current font metrics are cached (for the nested lines which use the metrics to determine the height of the potentially wrapped lines).
 public float getPreferredSpan(int axis) 
    Determines the preferred span for this view along an axis. This is implemented to provide the superclass behavior after first making sure that the current font metrics are cached (for the nested lines which use the metrics to determine the height of the potentially wrapped lines).
 protected int getTabSize() 
    Returns the tab size set for the document, defaulting to 8.
 public  void insertUpdate(DocumentEvent e,
    Shape a,
    ViewFactory f) 
    Gives notification that something was inserted into the document in a location that this view is responsible for. This is implemented to simply update the children.
 protected  void loadChildren(ViewFactory f) 
    Loads all of the children to initialize the view. This is called by the setParent method. Subclasses can reimplement this to initialize their child views in a different manner. The default implementation creates a child view for each child element.
 final  void loadText(Segment segment,
    int p0,
    int p1) 
    Load the text buffer with the given range of text. This is used by the fragments broken off of this view as well as this view itself.
 public float nextTabStop(float x,
    int tabOffset) 
    Returns the next tab stop position after a given reference position. This implementation does not support things like centering so it ignores the tabOffset argument.
 public  void paint(Graphics g,
    Shape a) 
    Renders using the given rendering surface and area on that surface. This is implemented to stash the selection positions, selection colors, and font metrics for the nested lines to use.
 public  void removeUpdate(DocumentEvent e,
    Shape a,
    ViewFactory f) 
    Gives notification that something was removed from the document in a location that this view is responsible for. This is implemented to simply update the children.
 public  void setSize(float width,
    float height) 
    Sets the size of the view. This should cause layout of the view along the given axis, if it has any layout duties.
  void updateChildren(DocumentEvent e,
    Shape a) 
    Update the child views in response to a document event.
 final  void updateMetrics()