Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
javax.swing.text.View
javax.swing.text.CompositeView
javax.swing.text.BoxView
javax.swing.text.WrappedPlainView
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 | |
| |
|
Method Summary | |
protected int |
|
void |
|
protected void | |
protected int |
|
protected int |
|
protected Segment |
|
float |
|
float |
|
float |
|
protected int |
|
void |
|
protected void |
|
float |
|
void | |
void |
|
void |
|
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public WrappedPlainView(Element elem)
Creates a newCompositeView
for the givenElement
.
- Parameters:
protected int calculateBreakPosition(int p0, int p1)
Calculates the break position for the text between model positions p0 and p1. Will break on word boundaries or character boundaries depending on the break argument given in construction of this WrappedPlainView. Used by the nested WrappedLine class to determine when to start the next logical line.
- Parameters:
p0
- the start model positionp1
- the end model position
- Returns:
- the model position at which to break the text
public void changedUpdate(DocumentEvent e, Shape a, ViewFactory f)
Called when the portion of the Document that this View is responsible for changes. Overridden so that the view factory creates WrappedLine views.
- Overrides:
- changedUpdate in interface View
protected void drawLine(int p0, int p1, Graphics g, int x, int y)
Draws a line of text, suppressing white space at the end and expanding tabs. Calls drawSelectedText and drawUnselectedText.
- Parameters:
p0
- starting document position to usep1
- ending document position to useg
- graphics contextx
- starting x positiony
- starting y position
protected int drawSelectedText(Graphics g, int x, int y, int p0, int p1) throws BadLocationException
Renders the range of text as selected text. Just paints the text in the color specified by the host component. Assumes the highlighter will render the selected background.
- Parameters:
g
- the graphics contextx
- the starting X coordinatey
- the starting Y coordinatep0
- the starting model locationp1
- the ending model location
- Returns:
- the X coordinate of the end of the text
- Throws:
BadLocationException
- if the given range is invalid
protected int drawUnselectedText(Graphics g, int x, int y, int p0, int p1) throws BadLocationException
Renders the range of text as normal unhighlighted text.
- Parameters:
g
- the graphics contextx
- the starting X coordinatey
- the starting Y coordinatep0
- the starting model locationp1
- the end model location
- Returns:
- the X location of the end off the range
- Throws:
BadLocationException
- if the range given is invalid
protected final Segment getLineBuffer()
Provides access to the Segment used for retrievals from the Document.
- Returns:
- the Segment.
public float getMaximumSpan(int axis)
Determines the maximum span along the given axis. Implemented to cache the font metrics and then call the super classes method.
- Overrides:
- getMaximumSpan in interface BoxView
public float getMinimumSpan(int axis)
Determines the minimum span along the given axis. Implemented to cache the font metrics and then call the super classes method.
- Overrides:
- getMinimumSpan in interface BoxView
public float getPreferredSpan(int axis)
Determines the preferred span along the given axis. Implemented to cache the font metrics and then call the super classes method.
- Overrides:
- getPreferredSpan in interface BoxView
protected int getTabSize()
Returns the tab size for the Document based on PlainDocument.tabSizeAttribute, defaulting to 8 if this property is not defined
- Returns:
- the tab size.
public void insertUpdate(DocumentEvent e, Shape a, ViewFactory f)
Called when something was inserted. Overridden so that the view factory creates WrappedLine views.
- Overrides:
- insertUpdate in interface View
protected void loadChildren(ViewFactory f)
Loads the children to initiate the view. Called by setParent. Creates a WrappedLine for each child Element.
- Overrides:
- loadChildren in interface CompositeView
public float nextTabStop(float x, int tabStop)
Returns the next tab stop position after a given reference position. This implementation ignores thetabStop
argument.
- Specified by:
- nextTabStop in interface TabExpander
- Parameters:
x
- the current x position in pixelstabStop
- the position within the text stream that the tab occured at
public void paint(Graphics g, Shape a)
Renders theElement
that is associated with thisView
. Caches the metrics and then calls super.paint to paint all the child views.
- Parameters:
g
- theGraphics
context to render toa
- the allocated region for theElement
public void removeUpdate(DocumentEvent e, Shape a, ViewFactory f)
Called when something is removed. Overridden so that the view factory creates WrappedLine views.
- Overrides:
- removeUpdate in interface View
public void setSize(float width, float height)
Sets the size of the View. Implemented to update the metrics and then call super method.