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

All Implemented Interfaces:
    TabExpander, SwingConstants

Direct Known Subclasses:
    FieldView, PasswordView

Implements View interface for a simple multi-line text view that has text in one font and color. The view represents each child element as a line of text.
Field Summary
protected  FontMetrics metrics    Font metrics for the current font. 
 Element longLine    The current longest line. This is used to calculate the preferred width of the view. Since the calculation is potentially expensive we try to avoid it by stashing which line is currently the longest. 
 Font font    Font used to calculate the longest line... if this changes we need to recalculate the longest line 
 Segment lineBuffer     
 int tabSize     
 int tabBase     
 int sel0     
 int sel1     
 Color unselected     
 Color selected     
 int firstLineOffset    Offset of where to draw the first character on the first line. This is a hack and temporary until we can better address the problem of text measuring. This field is actually never set directly in PlainView, but by FieldView. 
Fields inherited from javax.swing.text.View:
BadBreakWeight,  GoodBreakWeight,  ExcellentBreakWeight,  ForcedBreakWeight,  X_AXIS,  Y_AXIS,  sharedBiasReturn
Constructor:
 public PlainView(Element elem) 
    Constructs a new PlainView wrapped on an element.
    Parameters:
    elem - the element
Method from javax.swing.text.PlainView Summary:
adjustPaintRegion,   changedUpdate,   damageLineRange,   drawLine,   drawSelectedText,   drawUnselectedText,   getLineBuffer,   getPreferredSpan,   getTabSize,   insertUpdate,   lineToRect,   modelToView,   nextTabStop,   paint,   removeUpdate,   setSize,   updateDamage,   updateMetrics,   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.PlainView Detail:
 Shape adjustPaintRegion(Shape a) 
    Should return a shape ideal for painting based on the passed in Shape a. This is useful if painting in a different region. The default implementation returns a.
 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  void damageLineRange(int line0,
    int line1,
    Shape a,
    Component host) 
    Repaint the given line range.
 protected  void drawLine(int lineIndex,
    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. Uses the foreground or disabled color to render the text.
 protected final Segment getLineBuffer() 
    Gives access to a buffer that can be used to fetch text from the associated document.
 public float getPreferredSpan(int axis) 
    Determines the preferred span for this view along an axis.
 protected int getTabSize() 
    Returns the tab size set for the document, defaulting to 8.
 public  void insertUpdate(DocumentEvent changes,
    Shape a,
    ViewFactory f) 
    Gives notification that something was inserted into the document in a location that this view is responsible for.
 protected Rectangle lineToRect(Shape a,
    int line) 
    Determine the rectangle that represents the given line.
 public Shape modelToView(int pos,
    Shape a,
    Bias b) throws BadLocationException 
    Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.
 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. The view may need to do layout and create child views to enable itself to render into the given allocation.
 public  void removeUpdate(DocumentEvent changes,
    Shape a,
    ViewFactory f) 
    Gives notification that something was removed from the document in a location that this view is responsible for.
 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.
 protected  void updateDamage(DocumentEvent changes,
    Shape a,
    ViewFactory f) 
    Repaint the region of change covered by the given document event. Damages the line that begins the range to cover the case when the insert/remove is only on one line. If lines are added or removed, damages the whole view. The longest line is checked to see if it has changed.
 protected  void updateMetrics() 
    Checks to see if the font metrics and longest line are up-to-date.
 public int viewToModel(float fx,
    float fy,
    Shape a,
    Bias[] bias) 
    Provides a mapping from the view coordinate space to the logical coordinate space of the model.