Class java.awt.swing.text.WrappedPlainView
java.lang.Object
|
+----java.awt.swing.text.View
|
+----java.awt.swing.text.CompositeView
|
+----java.awt.swing.text.BoxView
|
+----java.awt.swing.text.WrappedPlainView
- public class WrappedPlainView
- extends BoxView
- implements TabExpander
View of plain text (text with only one font and color)
that does line-wrapping. This view expects that it's
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 it's state
to reduce their memory requirements.
The line views do all of their rendering through the
drawLine
method which in turn does all of
it's rendering through the drawSelectedText
and drawUnselectedText
methods. This
enables subclasses to easily specialize the rendering
without concern for the layout aspects.
- See Also:
- View
Method Summary
|
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.
|
void
|
drawLine(int p0,
int p1,
Graphics g,
int x,
int y)
Renders a line of text, suppressing whitespace at the end
and exanding any tabs.
|
int
|
drawSelectedText(Graphics g,
int x,
int y,
int p0,
int p1)
Renders the given range in the model as selected text.
|
int
|
drawUnselectedText(Graphics g,
int x,
int y,
int p0,
int p1)
Renders the given range in the model as normal unselected
text.
|
Segment
|
getLineBuffer()
Gives access to a buffer that can be used to fetch
text from the associated document.
|
float
|
getPreferredSpan(int axis)
Determines the preferred span for this view along an
axis.
|
int
|
getTabSize()
Returns the tab size set for the document, defaulting to 8.
|
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.
|
void
|
loadChildren(ViewFactory f)
Loads all of the children to initialize the view.
|
float
|
nextTabStop(float x,
int tabOffset)
Returns the next tab stop position after a given reference position.
|
void
|
paint(Graphics g,
Shape a)
Renders using the given rendering surface and area
on that surface.
|
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.
|
void
|
setSize(float width,
float height)
Sets the size of the view.
|
Methods inherited from class java.awt.swing.text.BoxView
|
changedUpdate, childAllocation, getAlignment, getPreferredSpan, getResizeWeight, getViewAtPoint, insertUpdate, isAfter, isAllocationValid, isBefore, layout, modelToView, paint, paintChild, preferenceChanged, removeUpdate, replace, setSize, viewToModel |
Methods inherited from class java.awt.swing.text.CompositeView
|
append, childAllocation, getBottomInset, getChildAllocation, getInsideAllocation, getLeftInset, getRightInset, getTopInset, getView, getViewAtPoint, getViewAtPosition, getViewCount, insert, isAfter, isBefore, loadChildren, modelToView, removeAll, replace, setInsets, setParagraphInsets, setParent, viewToModel |
Methods inherited from class java.awt.swing.text.View
|
breakView, changedUpdate, createFragment, getAlignment, getBreakWeight, getChildAllocation, getContainer, getDocument, getElement, getEndOffset, getParent, getPreferredSpan, getResizeWeight, getStartOffset, getView, getViewCount, getViewFactory, insertUpdate, modelToView, paint, preferenceChanged, removeUpdate, setParent, setSize, viewToModel |
Methods inherited from class java.lang.Object
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
WrappedPlainView
public WrappedPlainView(Element elem)
getTabSize
protected int getTabSize()
- Returns the tab size set for the document, defaulting to 8.
- Returns:
- the tab size
drawLine
protected void drawLine(int p0,
int p1,
Graphics g,
int x,
int y)
- Renders a line of text, suppressing whitespace at the end
and exanding 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.
- Parameters:
p0
- the starting document location to use
p1
- the ending document location to use
g
- the graphics context
x
- the starting X position
y
- the starting Y position
- See Also:
- drawUnselectedText, drawSelectedText
drawUnselectedText
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.
- Parameters:
g
- the graphics context
x
- the starting X coordinate
y
- the starting Y coordinate
p0
- the beginning position in the model
p1
- the ending position in the model
- Throws:
- BadLocationException - if the range is invalid
drawSelectedText
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.
- Parameters:
g
- the graphics context
x
- the starting X coordinate
y
- the starting Y coordinate
p0
- the beginning position in the model
p1
- the ending position in the model
- Throws:
- BadLocationException - if the range is invalid
getLineBuffer
protected final Segment getLineBuffer()
- Gives access to a buffer that can be used to fetch
text from the associated document.
loadChildren
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.
- Parameters:
f
- the view factory
- Overrides:
- loadChildren in class CompositeView
nextTabStop
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.
- Implements:
- nextTabStop in interface TabExpander
- Parameters:
x
- the current position
tabOffset
- the position within the text stream
that the tab occurred at.
- Returns:
- the tab stop, measured in points
paint
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.
- Parameters:
g
- the rendering surface to use
a
- the allocated region to render into
- Overrides:
- paint in class BoxView
- See Also:
- paint
setSize
public void setSize(float width,
float height)
- Sets the size of the view. If the size has changed, layout
is redone. The size is the full size of the view including
the inset areas.
- Parameters:
width
- the width
height
- the height
- Overrides:
- setSize in class BoxView
getPreferredSpan
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).
- Parameters:
axis
- may be either X_AXIS or Y_AXIS
- Overrides:
- getPreferredSpan in class BoxView
- See Also:
- getPreferredSpan
insertUpdate
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.
- Parameters:
e
- the change information from the associated document
a
- the current allocation of the view
f
- the factory to use to rebuild if the view has children
- Overrides:
- insertUpdate in class BoxView
- See Also:
- insertUpdate
removeUpdate
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.
- Parameters:
e
- the change information from the associated document
a
- the current allocation of the view
f
- the factory to use to rebuild if the view has children
- Overrides:
- removeUpdate in class BoxView
- See Also:
- removeUpdate
changedUpdate
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.
- Parameters:
e
- the change information from the associated document
a
- the current allocation of the view
f
- the factory to use to rebuild if the view has children
- Overrides:
- changedUpdate in class BoxView
- See Also:
- changedUpdate
Submit a bug or feature
Submit comments/suggestions about new javadoc look.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.