java.lang.Object | +--javax.swing.text.View | +--javax.swing.text.PlainView
Safe: 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.
ViewBadBreakWeight, ExcellentBreakWeight, ForcedBreakWeight, GoodBreakWeight, sharedBiasReturn, X_AXIS, Y_AXIS
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
(package private) Shape
adjustPaintRegion(Shape a)
a.
private void
calculateLongestLine()
void
changedUpdate(DocumentEvent changes,
Shape a,
ViewFactory f)
protected void
damageLineRange(int line0,
int line1,
Shape a,
Component host)
protected void
drawLine(int lineIndex,
Graphics g,
int x,
int y)
protected int
drawSelectedText(Graphics g,
int x,
int y,
int p0,
int p1)
protected int
drawUnselectedText(Graphics g,
int x,
int y,
int p0,
int p1)
protected Segment
getLineBuffer()
private int
getLineWidth(Element line)
float
getPreferredSpan(int axis)
void
insertUpdate(DocumentEvent changes,
Shape a,
ViewFactory f)
protected Rectangle
lineToRect(Shape a,
int line)
Shape
modelToView(int pos,
Shape a,
javax.swing.text.Position.Bias b)
float
nextTabStop(float x,
int tabOffset)
void
paint(Graphics g,
Shape a)
void
removeUpdate(DocumentEvent changes,
Shape a,
ViewFactory f)
int
viewToModel(float fx,
float fy,
Shape a,
javax.swing.text.Position.Bias[] bias)
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
protected FontMetrics metrics
Element longLine
Font font
Segment lineBuffer
int tabSize
int tabBase
int sel0
int sel1
Color unselected
Color selected
public PlainView(Element elem)
elem - the elementprotected int getTabSize()
protected void drawLine(int lineIndex, Graphics g, int x, int y)
drawUnselectedText and
drawSelectedText so that the way selected and
unselected text are rendered can be customized.
lineIndex - the line to draw>= 0g - the Graphics contextx - the starting X position>= 0y - the starting Y position>= 0drawUnselectedText(java.awt.Graphics, int, int, int, int),
drawSelectedText(java.awt.Graphics, int, int, int, int)private int drawElement(Element elem, Graphics g, int x, int y) throws BadLocationException
protected int drawUnselectedText(Graphics g, int x, int y, int p0, int p1) throws BadLocationException
g - the graphics contextx - the starting X coordinate>= 0y - the starting Y coordinate>= 0p0 - the beginning position in the model>= 0p1 - the ending position in the model>= 0
BadLocationExceptionprotected int drawSelectedText(Graphics g, int x, int y, int p0, int p1) throws BadLocationException
g - the graphics contextx - the starting X coordinate>= 0y - the starting Y coordinate>= 0p0 - the beginning position in the model>= 0p1 - the ending position in the model>= 0
BadLocationExceptionprotected final Segment getLineBuffer()
protected void updateMetrics()
public float getPreferredSpan(int axis)
getPreferredSpan in class Viewaxis - may be either View.X_AXIS or View.Y_AXIS
View.getPreferredSpan(int)public void paint(Graphics g, Shape a)
g - the rendering surface to usea - the allocated region to render intoView.paint(java.awt.Graphics, java.awt.Shape)Shape adjustPaintRegion(Shape a)
a. This is useful if painting in a different
region. The default implementation returns a.
public Shape modelToView(int pos, Shape a, javax.swing.text.Position.Bias b) throws BadLocationException
modelToView in class Viewpos - the position to convert>= 0a - the allocated region to render intob - the bias toward the previous character or the
next character represented by the offset, in case the
position is a boundary of two views; b will have one
of these values:
Position.Bias.Forward
Position.Bias.Backward
BadLocationExceptionView.modelToView(int, java.awt.Shape, javax.swing.text.Position.Bias)public int viewToModel(float fx, float fy, Shape a, javax.swing.text.Position.Bias[] bias)
viewToModel in class Viewfx - the X coordinate>= 0fy - the Y coordinate>= 0a - the allocated region to render into
View.viewToModel(float, float, java.awt.Shape, javax.swing.text.Position.Bias[])public void insertUpdate(DocumentEvent changes, Shape a, ViewFactory f)
insertUpdate in class Viewchanges - the change information from the associated documenta - the current allocation of the viewf - the factory to use to rebuild if the view has childrenView.insertUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)public void removeUpdate(DocumentEvent changes, Shape a, ViewFactory f)
removeUpdate in class Viewchanges - the change information from the associated documenta - the current allocation of the viewf - the factory to use to rebuild if the view has childrenView.removeUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)public void changedUpdate(DocumentEvent changes, Shape a, ViewFactory f)
changedUpdate in class Viewchanges - the change information from the associated documenta - the current allocation of the viewf - the factory to use to rebuild if the view has childrenView.changedUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)public void setSize(float width, float height)
width - the width>= 0height - the height>= 0public float nextTabStop(float x, int tabOffset)
nextTabStop in interface TabExpanderx - the current position>= 0tabOffset - the position within the text stream
that the tab occurred at>= 0.
protected void updateDamage(DocumentEvent changes, Shape a, ViewFactory f)
protected void damageLineRange(int line0, int line1, Shape a, Component host)
host - the component hosting the view (used to call repaint)a - the region allocated for the view to render intoline0 - the starting line number to repaint. This must
be a valid line number in the model.line1 - the ending line number to repaint. This must
be a valid line number in the model.protected Rectangle lineToRect(Shape a, int line)
a - the region allocated for the view to render intoline - the line number to find the region of. This must
be a valid line number in the model.private void calculateLongestLine()
private int getLineWidth(Element line)