All Packages Class Hierarchy This Package Previous Next Index
Class com.sun.java.swing.text.PlainView
java.lang.Object
|
+----com.sun.java.swing.text.View
|
+----com.sun.java.swing.text.PlainView
- public class PlainView
- extends View
- implements TabExpander
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.
- See Also:
- View
-
metrics
- Font metrics for the currrent font.
-
PlainView(Element)
- Constructs a new view wrapped on an element.
-
changedUpdate(DocumentEvent, Shape, ViewFactory)
- Gives notification from the document that attributes were changed
in a location that this view is responsible for.
-
drawLine(int, Graphics, int, int)
- Renders a line of text, suppressing whitespace at the end
and exanding any tabs.
-
drawSelectedText(Graphics, int, int, int, int)
- Renders the given range in the model as selected text.
-
drawUnselectedText(Graphics, int, int, int, int)
- Renders the given range in the model as normal unselected
text.
-
getLineBuffer()
- Gives access to a buffer that can be used to fetch
text from the associated document.
-
getLineLimit()
- Returns the max number of characters per line set for the document,
-
getPreferredSpan(int)
- Determines the preferred span for this view along an
axis.
-
getTabSize()
- Returns the tab size set for the document, defaulting to 8.
-
insertUpdate(DocumentEvent, Shape, ViewFactory)
- Gives notification that something was inserted into the document
in a location that this view is responsible for.
-
modelToView(int, Shape)
- Provides a mapping from the document model coordinate space
to the coordinate space of the view mapped to it.
-
nextTabStop(float, int)
- Returns the next tab stop position after a given reference position.
-
paint(Graphics, Shape)
- Renders using the given rendering surface and area on that surface.
-
preferenceChanged(View, boolean, boolean)
- Desired span has changed.
-
removeUpdate(DocumentEvent, Shape, ViewFactory)
- Gives notification that something was removed from the document
in a location that this view is responsible for.
-
setParent(View)
- Sets the parent of the view.
-
viewToModel(float, float, Shape)
- Provides a mapping from the view coordinate space to the logical
coordinate space of the model.
metrics
protected FontMetrics metrics
- Font metrics for the currrent font.
PlainView
public PlainView(Element elem)
- Constructs a new view wrapped on an element.
- Parameters:
- elem - the element
getTabSize
protected int getTabSize()
- Returns the tab size set for the document, defaulting to 8.
- Returns:
- the tab size
getLineLimit
protected int getLineLimit()
- Returns the max number of characters per line set for the document,
- Returns:
- the max number
drawLine
protected void drawLine(int lineIndex,
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:
- lineIndex - the line to draw
- 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
- Returns:
- s the location of the end of the range
- 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
- Returns:
- s the location of the end of the range.
- 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.
- Returns:
- s the buffer
setParent
public void setParent(View p)
- Sets the parent of the view.
The parent calls this on the child to tell it who its
parent is. If this is null, the view has been removed
and we need to remove the associated component from its
parent. This is used here to determine what the hosting
component is.
- Parameters:
- p - the parent view
- Overrides:
- setParent in class View
getPreferredSpan
public float getPreferredSpan(int axis)
- Determines the preferred span for this view along an
axis.
- Parameters:
- axis - may be either X_AXIS or Y_AXIS
- Returns:
- s the span the view would like to be rendered into.
Typically the view is told to render into the span
that is returned, although there is no guarantee.
The parent may choose to resize or break the view.
- Overrides:
- getPreferredSpan in class View
paint
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.
- Parameters:
- g - the rendering surface to use
- a - the allocated region to render into
- Overrides:
- paint in class View
- See Also:
- paint
preferenceChanged
public void preferenceChanged(View child,
boolean width,
boolean height)
- Desired span has changed.
- Parameters:
- child - the child view
- width - true if the width preference has changed
- height - true if the height preference has changed
- Overrides:
- preferenceChanged in class View
- See Also:
- revalidate
modelToView
public Shape modelToView(int pos,
Shape a) throws BadLocationException
- Provides a mapping from the document model coordinate space
to the coordinate space of the view mapped to it.
- Parameters:
- pos - the position to convert
- a - the allocated region to render into
- Returns:
- the bounding box of the given position
- Throws: BadLocationException
- if the given position does not
represent a valid location in the associated document
- Overrides:
- modelToView in class View
- See Also:
- modelToView
viewToModel
public int viewToModel(float fx,
float fy,
Shape a)
- Provides a mapping from the view coordinate space to the logical
coordinate space of the model.
- Parameters:
- fx - the X coordinate
- fy - the Y coordinate
- a - the allocated region to render into
- Returns:
- the location within the model that best represents the
given point in the view
- Overrides:
- viewToModel in class View
- See Also:
- viewToModel
insertUpdate
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.
- Parameters:
- changes - 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 View
- See Also:
- insertUpdate
removeUpdate
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.
- Parameters:
- changes - 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 View
- See Also:
- removeUpdate
changedUpdate
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.
- Parameters:
- changes - 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 View
- See Also:
- changedUpdate
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.
- Parameters:
- x - the current position
- tabOffset - the position within the text stream
that the tab occurred at.
- Returns:
- the tab stop, measured in points
All Packages Class Hierarchy This Package Previous Next Index