is new.
java.lang.Objectjavax.swing.text.View
javax.swing.text.PlainView
public class PlainView
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. |
| Fields inherited from class javax.swing.text. View |
|---|
| BadBreakWeight , ExcellentBreakWeight , ForcedBreakWeight , GoodBreakWeight , X_AXIS , Y_AXIS |
| Fields inherited from interface javax.swing. SwingConstants |
|---|
| BOTTOM , CENTER , EAST , HORIZONTAL , LEADING , LEFT , NEXT , NORTH , NORTH_EAST , NORTH_WEST , PREVIOUS , RIGHT , SOUTH , SOUTH_EAST , SOUTH_WEST , TOP , TRAILING , VERTICAL , WEST |
| Constructor Summary | |
|---|---|
|
PlainView
(
Element
elem) Constructs a new PlainView wrapped on an element. |
|
| Method Summary | |
|---|---|
| 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. |
| protected int |
drawSelectedText
(
Graphics
g, int x, int y, int p0, int p1) Renders the given range in the model as selected text. |
| protected int |
drawUnselectedText
(
Graphics
g, int x, int y, int p0, int p1) Renders the given range in the model as normal unselected text. |
| protected 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. |
| protected int |
getTabSize
() Returns the tab size set for the document, defaulting to 8. |
| 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. |
| Shape |
modelToView
(int pos,
Shape
a,
Position.Bias
b) Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it. |
| 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
changes,
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. |
| protected void |
updateDamage
(
DocumentEvent
changes,
Shape
a,
ViewFactory
Repaint the region of change covered by the given document event.
|
| protected void |
updateMetrics
() Checks to see if the font metrics and longest line are up-to-date. |
| int |
viewToModel
(float fx, float fy,
Shape
a,
Position.Bias
[] bias) Provides a mapping from the view coordinate space to the logical coordinate space of the model. |
| Methods inherited from class javax.swing.text. View |
|---|
| append , breakView , createFragment , forwardUpdate , forwardUpdateToView , getAlignment , getAttributes , getBreakWeight , getChildAllocation , getContainer , getDocument , getElement , getEndOffset , getGraphics , getMaximumSpan , getMinimumSpan , getNextVisualPositionFrom , getParent , getResizeWeight , getStartOffset , getToolTipText , getView , getViewCount , getViewFactory , getViewIndex , getViewIndex , insert , isVisible , modelToView , modelToView , preferenceChanged , remove , removeAll , replace , setParent , updateChildren , updateLayout , viewToModel |
| Methods inherited from class java.lang. Object |
|---|
| clone , equals , finalize , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait |
| Field Detail |
|---|
protected FontMetrics metrics
| Constructor Detail |
|---|
public PlainView(Element elem)
| Method Detail |
|---|
protected int getTabSize()
protected void drawLine(int lineIndex,
Graphics g,
int x,
int y)
protected int drawUnselectedText(Graphics g,
int x,
int y,
int p0,
int p1)
throws BadLocationException
protected int drawSelectedText(Graphics g,
int x,
int y,
int p0,
int p1)
throws BadLocationException
protected final Segment getLineBuffer()
protected void updateMetrics()
public float getPreferredSpan(int axis)
public void paint(Graphics g,
Shape a)
public Shape modelToView(int pos,
Shape a,
Position.Bias b)
throws BadLocationException
public int viewToModel(float fx,
float fy,
Shape a,
Position.Bias[] bias)
public void insertUpdate(DocumentEvent changes,
Shape a,
ViewFactory f)
public void removeUpdate(DocumentEvent changes,
Shape a,
ViewFactory f)
public void changedUpdate(DocumentEvent changes,
Shape a,
ViewFactory f)
public void setSize(float width,
float height)
public float nextTabStop(float x,
int tabOffset)
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.
Since:
1.4
protected void damageLineRange(int line0,
int line1,
Shape a,
Component host)
protected Rectangle lineToRect(Shape a,
int line)