|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.text.View
javax.swing.text.CompositeView
javax.swing.text.BoxView
org.fife.ui.rsyntaxtextarea.WrappedSyntaxView
public class WrappedSyntaxView
The view used by RSyntaxTextArea
when word wrap is enabled.
This class is a work-in-progress and will eventually replace
WrappedSyntaxView
(which works, but ignores token styles).
Field Summary |
---|
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 | |
---|---|
WrappedSyntaxView(Element elem)
Creates a new WrappedSyntaxView. |
Method Summary | |
---|---|
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(DocumentEvent e,
Shape a,
ViewFactory f)
Gives notification from the document that attributes were changed in a location that this view is responsible for. |
protected void |
drawView(Graphics2D g,
Rectangle r,
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. |
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. |
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 void |
loadChildren(ViewFactory f)
Loads all of the children to initialize the view. |
Shape |
modelToView(int p0,
Position.Bias b0,
int p1,
Position.Bias b1,
Shape a)
Provides a mapping, for a given region, from the document model coordinate space to the view coordinate space. |
float |
nextTabStop(float x,
int tabOffset)
Returns the next tab stop position after a given reference position. |
void |
paint(Graphics g,
Shape a)
Paints the word-wrapped text. |
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. |
int |
yForLineContaining(Rectangle alloc,
int offs)
Returns the y-coordinate of the line containing a specified offset. |
Methods inherited from class javax.swing.text.BoxView |
---|
baselineLayout, baselineRequirements, calculateMajorAxisRequirements, calculateMinorAxisRequirements, childAllocation, flipEastAndWestAtEnds, forwardUpdate, getAlignment, getAxis, getChildAllocation, getHeight, getOffset, getResizeWeight, getSpan, getViewAtPoint, getWidth, isAfter, isAllocationValid, isBefore, isLayoutValid, layout, layoutChanged, layoutMajorAxis, layoutMinorAxis, modelToView, paintChild, preferenceChanged, replace, setAxis, viewToModel |
Methods inherited from class javax.swing.text.CompositeView |
---|
getBottomInset, getInsideAllocation, getLeftInset, getNextEastWestVisualPositionFrom, getNextNorthSouthVisualPositionFrom, getNextVisualPositionFrom, getRightInset, getTopInset, getView, getViewAtPosition, getViewCount, getViewIndex, getViewIndexAtPosition, setInsets, setParagraphInsets, setParent |
Methods inherited from class javax.swing.text.View |
---|
append, breakView, createFragment, forwardUpdateToView, getAttributes, getBreakWeight, getContainer, getDocument, getElement, getEndOffset, getGraphics, getParent, getStartOffset, getToolTipText, getViewFactory, getViewIndex, insert, isVisible, modelToView, remove, removeAll, updateChildren, updateLayout, viewToModel |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public WrappedSyntaxView(Element elem)
elem
- the element underlying the viewMethod Detail |
---|
protected int calculateBreakPosition(int p0, Token tokenList, float x0)
public void changedUpdate(DocumentEvent e, Shape a, ViewFactory f)
changedUpdate
in class 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(Graphics2D g, Rectangle r, View view, int fontHeight, int y)
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.public float getMaximumSpan(int axis)
getMaximumSpan
in class BoxView
axis
- may be either View.X_AXIS or View.Y_AXIS
View.getMaximumSpan(int)
public float getMinimumSpan(int axis)
getMinimumSpan
in class BoxView
axis
- may be either View.X_AXIS or View.Y_AXIS
View.getMinimumSpan(int)
public float getPreferredSpan(int axis)
getPreferredSpan
in class BoxView
axis
- may be either View.X_AXIS or View.Y_AXIS
View.getPreferredSpan(int)
protected int getTabSize()
public void insertUpdate(DocumentEvent changes, Shape a, ViewFactory f)
insertUpdate
in class 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(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
in class CompositeView
f
- the view factorypublic Shape modelToView(int p0, Position.Bias b0, int p1, Position.Bias b1, Shape a) throws 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
in class 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 region
BadLocationException
- if the given position does
not represent a valid location in the associated document
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
in interface TabExpander
x
- the current position >= 0tabOffset
- the position within the text stream
that the tab occurred at >= 0.
public void paint(Graphics g, Shape a)
paint
in class BoxView
g
- The graphics context in which to paint.a
- The shape (usually a rectangle) in which to paint.public void removeUpdate(DocumentEvent changes, Shape a, ViewFactory f)
removeUpdate
in class 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
in class BoxView
width
- the width >= 0height
- the height >= 0public int yForLineContaining(Rectangle alloc, int offs) throws 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.
BadLocationException
- If offs
isn't a valid offset
into the document.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |