public class WrappedSyntaxView
extends javax.swing.text.BoxView
implements javax.swing.text.TabExpander
RSyntaxTextArea
when word wrap is enabled.构造器和说明 |
---|
WrappedSyntaxView(javax.swing.text.Element elem)
Creates a new WrappedSyntaxView.
|
限定符和类型 | 方法和说明 |
---|---|
protected int |
calculateBreakPosition(int p0,
Token tokenList,
float x0)
This is called by the nested wrapped line
views to determine the break location.
|
void |
changedUpdate(javax.swing.event.DocumentEvent e,
java.awt.Shape a,
javax.swing.text.ViewFactory f)
Gives notification from the document that attributes were changed
in a location that this view is responsible for.
|
protected void |
drawView(com.fr.design.gui.syntax.ui.rsyntaxtextarea.TokenPainter painter,
java.awt.Graphics2D g,
java.awt.Rectangle r,
javax.swing.text.View view,
int fontHeight,
int y)
Draws a single view (i.e., a line of text for a wrapped view),
wrapping the text onto multiple lines if necessary.
|
protected void |
drawViewWithSelection(com.fr.design.gui.syntax.ui.rsyntaxtextarea.TokenPainter painter,
java.awt.Graphics2D g,
java.awt.Rectangle r,
javax.swing.text.View view,
int fontHeight,
int y,
int selStart,
int selEnd)
Draws a single view (i.e., a line of text for a wrapped view), wrapping
the text onto multiple lines if necessary.
|
java.awt.Shape |
getChildAllocation(int index,
java.awt.Shape a)
Fetches the allocation for the given child view.
|
java.awt.Shape |
getChildAllocationImpl(int line,
java.awt.Shape a)
Fetches the allocation for the given child view to render into.
|
float |
getMaximumSpan(int axis)
Determines the maximum span for this view along an
axis.
|
float |
getMinimumSpan(int axis)
Determines the minimum span for this view along an
axis.
|
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 5.
|
protected javax.swing.text.View |
getViewAtPoint(int x,
int y,
java.awt.Rectangle alloc)
Overridden to allow for folded regions.
|
void |
insertUpdate(javax.swing.event.DocumentEvent changes,
java.awt.Shape a,
javax.swing.text.ViewFactory f)
Gives notification that something was inserted into the
document in a location that this view is responsible for.
|
protected void |
loadChildren(javax.swing.text.ViewFactory f)
Loads all of the children to initialize the view.
|
java.awt.Shape |
modelToView(int p0,
javax.swing.text.Position.Bias b0,
int p1,
javax.swing.text.Position.Bias b1,
java.awt.Shape a)
Provides a mapping, for a given region, from the document model
coordinate space to the view coordinate space.
|
java.awt.Shape |
modelToView(int pos,
java.awt.Shape a,
javax.swing.text.Position.Bias b) |
float |
nextTabStop(float x,
int tabOffset)
Returns the next tab stop position after a given reference position.
|
void |
paint(java.awt.Graphics g,
java.awt.Shape a)
Paints the word-wrapped text.
|
void |
removeUpdate(javax.swing.event.DocumentEvent changes,
java.awt.Shape a,
javax.swing.text.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.
|
int |
viewToModel(float x,
float y,
java.awt.Shape a,
javax.swing.text.Position.Bias[] bias) |
int |
yForLine(java.awt.Rectangle alloc,
int line)
Returns the y-coordinate of the specified line.
|
int |
yForLineContaining(java.awt.Rectangle alloc,
int offs)
Returns the y-coordinate of the line containing a specified offset.
|
baselineLayout, baselineRequirements, calculateMajorAxisRequirements, calculateMinorAxisRequirements, childAllocation, flipEastAndWestAtEnds, forwardUpdate, getAlignment, getAxis, getHeight, getOffset, getResizeWeight, getSpan, getWidth, isAfter, isAllocationValid, isBefore, isLayoutValid, layout, layoutChanged, layoutMajorAxis, layoutMinorAxis, paintChild, preferenceChanged, replace, setAxis
getBottomInset, getInsideAllocation, getLeftInset, getNextEastWestVisualPositionFrom, getNextNorthSouthVisualPositionFrom, getNextVisualPositionFrom, getRightInset, getTopInset, getView, getViewAtPosition, getViewCount, getViewIndex, getViewIndexAtPosition, setInsets, setParagraphInsets, setParent
append, breakView, createFragment, forwardUpdateToView, getAttributes, getBreakWeight, getContainer, getDocument, getElement, getEndOffset, getGraphics, getParent, getStartOffset, getToolTipText, getViewFactory, getViewIndex, insert, isVisible, modelToView, remove, removeAll, updateChildren, updateLayout, viewToModel
public WrappedSyntaxView(javax.swing.text.Element elem)
elem
- the element underlying the viewprotected int calculateBreakPosition(int p0, Token tokenList, float x0)
public void changedUpdate(javax.swing.event.DocumentEvent e, java.awt.Shape a, javax.swing.text.ViewFactory f)
changedUpdate
在类中 javax.swing.text.View
e
- 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)
protected void drawView(com.fr.design.gui.syntax.ui.rsyntaxtextarea.TokenPainter painter, java.awt.Graphics2D g, java.awt.Rectangle r, javax.swing.text.View view, int fontHeight, int y)
painter
- The painter to use to render tokens.g
- The graphics context in which to paint.r
- The rectangle in which to paint.view
- The View
to paint.fontHeight
- The height of the font being used.y
- The y-coordinate at which to begin painting.protected void drawViewWithSelection(com.fr.design.gui.syntax.ui.rsyntaxtextarea.TokenPainter painter, java.awt.Graphics2D g, java.awt.Rectangle r, javax.swing.text.View view, int fontHeight, int y, int selStart, int selEnd)
painter
- The painter to use to render tokens.g
- The graphics context in which to paint.r
- The rectangle in which to paint.view
- The View
to paint.fontHeight
- The height of the font being used.y
- The y-coordinate at which to begin painting.selStart
- The start of the selection.selEnd
- The end of the selection.public java.awt.Shape getChildAllocation(int index, java.awt.Shape a)
Overridden to account for code folding.
getChildAllocation
在类中 javax.swing.text.BoxView
index
- The index of the child, >= 0 && < getViewCount().a
- The allocation to this viewnull
if
a
is null
; or null
if the
layout is invalidpublic java.awt.Shape getChildAllocationImpl(int line, java.awt.Shape a)
Overridden to account for lines hidden by collapsed folded regions.
line
- The index of the child, >= 0 && < getViewCount()a
- The allocation to this viewpublic float getMaximumSpan(int axis)
getMaximumSpan
在类中 javax.swing.text.BoxView
axis
- may be either View.X_AXIS or View.Y_AXISView.getMaximumSpan(int)
public float getMinimumSpan(int axis)
getMinimumSpan
在类中 javax.swing.text.BoxView
axis
- may be either View.X_AXIS or View.Y_AXISView.getMinimumSpan(int)
public float getPreferredSpan(int axis)
getPreferredSpan
在类中 javax.swing.text.BoxView
axis
- may be either View.X_AXIS or View.Y_AXISView.getPreferredSpan(int)
protected int getTabSize()
protected javax.swing.text.View getViewAtPoint(int x, int y, java.awt.Rectangle alloc)
getViewAtPoint
在类中 javax.swing.text.BoxView
public void insertUpdate(javax.swing.event.DocumentEvent changes, java.awt.Shape a, javax.swing.text.ViewFactory f)
insertUpdate
在类中 javax.swing.text.View
changes
- The change information from the associated document.a
- 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)
protected void loadChildren(javax.swing.text.ViewFactory f)
setParent
method.
Subclasses can re-implement this to initialize their
child views in a different manner. The default
implementation creates a child view for each
child element.loadChildren
在类中 javax.swing.text.CompositeView
f
- the view factorypublic java.awt.Shape modelToView(int pos, java.awt.Shape a, javax.swing.text.Position.Bias b) throws javax.swing.text.BadLocationException
modelToView
在类中 javax.swing.text.BoxView
javax.swing.text.BadLocationException
public java.awt.Shape modelToView(int p0, javax.swing.text.Position.Bias b0, int p1, javax.swing.text.Position.Bias b1, java.awt.Shape a) throws javax.swing.text.BadLocationException
This is implemented to subtract the width of the second character, as
this view's modelToView
actually returns the width of the
character instead of "1" or "0" like the View implementations in
javax.swing.text
. Thus, if we don't override this method,
the View
implementation will return one character's width
too much for its consumers (implementations of
javax.swing.text.Highlighter
).
modelToView
在类中 javax.swing.text.CompositeView
p0
- the position of the first character (>=0)b0
- The bias of the first character position, toward the previous
character or the next character represented by the offset, in
case the position is a boundary of two views; b0
will have one of these values:
Position.Bias.Forward
Position.Bias.Backward
p1
- the position of the last character (>=0)b1
- the bias for the second character position, defined
one of the legal values shown abovea
- the area of the view, which encompasses the requested regionjavax.swing.text.BadLocationException
- if the given position does
not represent a valid location in the associated documentjava.lang.IllegalArgumentException
- if b0
or
b1
are not one of the
legal Position.Bias
values listed aboveView.viewToModel(float, float, java.awt.Shape, javax.swing.text.Position.Bias[])
public float nextTabStop(float x, int tabOffset)
nextTabStop
在接口中 javax.swing.text.TabExpander
x
- the current position >= 0tabOffset
- the position within the text stream
that the tab occurred at >= 0.public void paint(java.awt.Graphics g, java.awt.Shape a)
paint
在类中 javax.swing.text.BoxView
g
- The graphics context in which to paint.a
- The shape (usually a rectangle) in which to paint.public void removeUpdate(javax.swing.event.DocumentEvent changes, java.awt.Shape a, javax.swing.text.ViewFactory f)
removeUpdate
在类中 javax.swing.text.View
changes
- The change information from the associated document.a
- 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 setSize(float width, float height)
setSize
在类中 javax.swing.text.BoxView
width
- the width >= 0height
- the height >= 0public int viewToModel(float x, float y, java.awt.Shape a, javax.swing.text.Position.Bias[] bias)
viewToModel
在类中 javax.swing.text.BoxView
public int yForLine(java.awt.Rectangle alloc, int line) throws javax.swing.text.BadLocationException
This method is quicker than using traditional
modelToView(int)
calls, as the entire bounding box isn't
computed.
alloc
- The area the text area can render into.line
- The line number.-1
if
this text area doesn't yet have a positive size or the line is
hidden (i.e. from folding).javax.swing.text.BadLocationException
- If line
isn't a valid line
number for this document.public int yForLineContaining(java.awt.Rectangle alloc, int offs) throws javax.swing.text.BadLocationException
This method is quicker than using traditional
modelToView(int)
calls, as the entire bounding box isn't
computed.
alloc
- The area the text area can render into.offs
- The offset info the document.-1
if
this text area doesn't yet have a positive size or the line is
hidden (i.e. from folding).javax.swing.text.BadLocationException
- If offs
isn't a valid offset
into the document.