APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.swing.text

public Class WrappedPlainView

extends BoxView
implements TabExpander
Class Inheritance
All Implemented Interfaces
javax.swing.text.TabExpander
Imports
java.awt.*, java.awt.font.FontRenderContext, java.awt.geom.Rectangle2D, java.lang.ref.SoftReference, javax.swing.event.*

View of plain text (text with only one font and color) that does line-wrapping. This view expects that its associated element has child elements that represent the lines it should be wrapping. It is implemented as a vertical box that contains logical line views. The logical line views are nested classes that render the logical line as multiple physical line if the logical line is too wide to fit within the allocation. The line views draw upon the outer class for its state to reduce their memory requirements.

The line views do all of their rendering through the drawLine method which in turn does all of its rendering through the drawSelectedText and drawUnselectedText methods. This enables subclasses to easily specialize the rendering without concern for the layout aspects.

Author
Timothy Prinzing
See Also
View

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class
WrappedPlainView.WrappedLine

Simple view of a line that wraps if it doesn't fit within the horizontal space allocated.

Field Summary

Modifier and TypeField and Description
private final boolean
private final boolean
private final boolean
pack-priv Segment
pack-priv FontMetrics
pack-priv int
pack-priv int
pack-priv Color
pack-priv int
pack-priv float
pack-priv Color
private final boolean
pack-priv boolean
pack-priv boolean
Inherited from javax.swing.text.BoxView:
majorAllocValidmajorAxismajorOffsetsmajorRequestmajorReqValidmajorSpanmajorSpansminorAllocValidminorOffsetsminorRequestminorReqValidminorSpanminorSpanstempRect

Constructor Summary

AccessConstructor and Description
public
WrappedPlainView(Element
the element underlying the view
elem
)

Creates a new WrappedPlainView.

public
WrappedPlainView(Element
the element underlying the view
elem
,
boolean
should lines be wrapped on word boundaries?
wordWrap
)

Creates a new WrappedPlainView.

Method Summary

Modifier and TypeMethod and Description
protected int

Returns:

the break position
calculateBreakPosition
(int
the starting document location
p0
,
int
the ending document location to use
p1
)

This is called by the nested wrapped line views to determine the break location.

private float
callDrawSelectedText(Graphics g, float x, float y, int p0, int p1)

private float
callDrawUnselectedText(Graphics g, float x, float y, int p0, int p1)

public void
changedUpdate(DocumentEvent
the change information from the associated document
e
,
Shape
the current allocation of the view
a
,
ViewFactory
the factory to use to rebuild if the view has children
f
)

Overrides javax.swing.text.View.changedUpdate.

Gives notification from the document that attributes were changed in a location that this view is responsible for.

protected void
drawLine(int
the starting document location to use >= 0
p0
,
int
the ending document location to use >= p1
p1
,
Graphics
the graphics context
g
,
int
the starting X position >= 0
x
,
int
the starting Y position >= 0
y
)
Deprecated since 9. replaced by drawLine(int, int, Graphics2D, float, float)

Renders a line of text, suppressing whitespace at the end and expanding any tabs.

protected void
drawLine(int
the starting document location to use >= 0
p0
,
int
the ending document location to use >= p1
p1
,
Graphics2D
the graphics context
g
,
float
the starting X position >= 0
x
,
float
the starting Y position >= 0
y
)

Renders a line of text, suppressing whitespace at the end and expanding any tabs.

private void
drawLineImpl(int p0, int p1, Graphics g, float x, float y, boolean useFPAPI)

protected int

Returns:

the location of the end of the range.
drawSelectedText
(Graphics
the graphics context
g
,
int
the starting X coordinate >= 0
x
,
int
the starting Y coordinate >= 0
y
,
int
the beginning position in the model >= 0
p0
,
int
the ending position in the model >= p0
p1
)

Renders the given range in the model as selected text.

protected float

Returns:

the location of the end of the range.
drawSelectedText
(Graphics2D
the graphics context
g
,
float
the starting X coordinate >= 0
x
,
float
the starting Y coordinate >= 0
y
,
int
the beginning position in the model >= 0
p0
,
int
the ending position in the model >= p0
p1
)

Renders the given range in the model as selected text.

private float
drawSelectedTextImpl(Graphics g, float x, float y, int p0, int p1, boolean useFPAPI)

private float
drawText(Element elem, int p0, int p1, Graphics g, float x, float y)

protected int

Returns:

the X location of the end of the range >= 0
drawUnselectedText
(Graphics
the graphics context
g
,
int
the starting X coordinate >= 0
x
,
int
the starting Y coordinate >= 0
y
,
int
the beginning position in the model >= 0
p0
,
int
the ending position in the model >= p0
p1
)

Renders the given range in the model as normal unselected text.

protected float

Returns:

the X location of the end of the range >= 0
drawUnselectedText
(Graphics2D
the graphics context
g
,
float
the starting X coordinate >= 0
x
,
float
the starting Y coordinate >= 0
y
,
int
the beginning position in the model >= 0
p0
,
int
the ending position in the model >= p0
p1
)

Renders the given range in the model as normal unselected text.

private float
drawUnselectedTextImpl(Graphics g, float x, float y, int p0, int p1, boolean useFPAPI)

protected final Segment

Returns:

the buffer
getLineBuffer
()

Gives access to a buffer that can be used to fetch text from the associated document.

public float

Returns:

the span the view would like to be rendered into. Typically the view is told to render into the span that is returned, although there is no guarantee. The parent may choose to resize or break the view.
getMaximumSpan
(int
may be either View.X_AXIS or View.Y_AXIS
axis
)

Overrides javax.swing.text.BoxView.getMaximumSpan.

Determines the maximum span for this view along an axis.

public float

Returns:

the span the view would like to be rendered into. Typically the view is told to render into the span that is returned, although there is no guarantee. The parent may choose to resize or break the view.
getMinimumSpan
(int
may be either View.X_AXIS or View.Y_AXIS
axis
)

Overrides javax.swing.text.BoxView.getMinimumSpan.

Determines the minimum span for this view along an axis.

public float

Returns:

the span the view would like to be rendered into. Typically the view is told to render into the span that is returned, although there is no guarantee. The parent may choose to resize or break the view.
getPreferredSpan
(int
may be either View.X_AXIS or View.Y_AXIS
axis
)

Overrides javax.swing.text.BoxView.getPreferredSpan.

Determines the preferred span for this view along an axis.

protected int

Returns:

the tab size
getTabSize
()

Returns the tab size set for the document, defaulting to 8.

public void
insertUpdate(DocumentEvent
the change information from the associated document
e
,
Shape
the current allocation of the view
a
,
ViewFactory
the factory to use to rebuild if the view has children
f
)

Overrides javax.swing.text.View.insertUpdate.

Gives notification that something was inserted into the document in a location that this view is responsible for.

protected void
loadChildren(ViewFactory
the view factory
f
)

Overrides javax.swing.text.CompositeView.loadChildren.

Loads all of the children to initialize the view.

pack-priv final void
loadText(Segment segment, int p0, int p1)

Load the text buffer with the given range of text.

public float

Returns:

the tab stop, measured in points >= 0
nextTabStop
(float
the current position >= 0
x
,
int
the position within the text stream that the tab occurred at >= 0.
tabOffset
)

Implements javax.swing.text.TabExpander.nextTabStop.

Returns the next tab stop position after a given reference position.

public void
paint(Graphics
the rendering surface to use
g
,
Shape
the allocated region to render into
a
)

Overrides javax.swing.text.BoxView.paint.

Renders using the given rendering surface and area on that surface.

public void
removeUpdate(DocumentEvent
the change information from the associated document
e
,
Shape
the current allocation of the view
a
,
ViewFactory
the factory to use to rebuild if the view has children
f
)

Overrides javax.swing.text.View.removeUpdate.

Gives notification that something was removed from the document in a location that this view is responsible for.

public void
setSize(float
the width >= 0
width
,
float
the height >= 0
height
)

Overrides javax.swing.text.BoxView.setSize.

Sets the size of the view.

pack-priv void
updateChildren(DocumentEvent e, Shape a)

Update the child views in response to a document event.

pack-priv final void
Inherited from javax.swing.text.BoxView:
baselineLayoutbaselineRequirementscalculateMajorAxisRequirementscalculateMinorAxisRequirementscheckRequestschildAllocationflipEastAndWestAtEndsforwardUpdategetAlignmentgetAxisgetChildAllocationgetHeightgetOffsetgetResizeWeightgetSpangetSpanOnAxisgetViewAtPointgetWidthisAfterisAllocationValidisBeforeisLayoutValidlayoutlayoutChangedlayoutMajorAxislayoutMinorAxismodelToViewpaintChildpreferenceChangedreplacesetAxissetSpanOnAxisupdateChildSizesupdateLayoutArrayviewToModel

Field Detail

drawLineOverriddenback to summary
private final boolean drawLineOverridden
drawSelectedTextOverriddenback to summary
private final boolean drawSelectedTextOverridden
drawUnselectedTextOverriddenback to summary
private final boolean drawUnselectedTextOverridden
lineBufferback to summary
pack-priv Segment lineBuffer
metricsback to summary
pack-priv FontMetrics metrics
sel0back to summary
pack-priv int sel0
sel1back to summary
pack-priv int sel1
selectedback to summary
pack-priv Color selected
tabBaseback to summary
pack-priv int tabBase
tabSizeback to summary
pack-priv float tabSize
unselectedback to summary
pack-priv Color unselected
useFloatingPointAPIback to summary
private final boolean useFloatingPointAPI
widthChangingback to summary
pack-priv boolean widthChanging
wordWrapback to summary
pack-priv boolean wordWrap

Constructor Detail

WrappedPlainViewback to summary
public WrappedPlainView(Element elem)

Creates a new WrappedPlainView. Lines will be wrapped on character boundaries.

Parameters
elem:Element

the element underlying the view

WrappedPlainViewback to summary
public WrappedPlainView(Element elem, boolean wordWrap)

Creates a new WrappedPlainView. Lines can be wrapped on either character or word boundaries depending upon the setting of the wordWrap parameter.

Parameters
elem:Element

the element underlying the view

wordWrap:boolean

should lines be wrapped on word boundaries?

Method Detail

calculateBreakPositionback to summary
protected int calculateBreakPosition(int p0, int p1)

This is called by the nested wrapped line views to determine the break location. This can be reimplemented to alter the breaking behavior. It will either break at word or character boundaries depending upon the break argument given at construction.

Parameters
p0:int

the starting document location

p1:int

the ending document location to use

Returns:int

the break position

callDrawSelectedTextback to summary
private float callDrawSelectedText(Graphics g, float x, float y, int p0, int p1) throws BadLocationException
callDrawUnselectedTextback to summary
private float callDrawUnselectedText(Graphics g, float x, float y, int p0, int p1) throws BadLocationException
changedUpdateback to summary
public void changedUpdate(DocumentEvent e, Shape a, ViewFactory f)

Overrides javax.swing.text.View.changedUpdate.

Gives notification from the document that attributes were changed in a location that this view is responsible for.

Parameters
e:DocumentEvent

the change information from the associated document

a:Shape

the current allocation of the view

f:ViewFactory

the factory to use to rebuild if the view has children

See Also
View#changedUpdate
drawLineback to summary
protected void drawLine(int p0, int p1, Graphics g, int x, int y)

Deprecated

since 9.

replaced by drawLine(int, int, Graphics2D, float, float)

Renders a line of text, suppressing whitespace at the end and expanding any tabs. This is implemented to make calls to the methods drawUnselectedText and drawSelectedText so that the way selected and unselected text are rendered can be customized.

Parameters
p0:int

the starting document location to use >= 0

p1:int

the ending document location to use >= p1

g:Graphics

the graphics context

x:int

the starting X position >= 0

y:int

the starting Y position >= 0

Annotations
@Deprecated
since:9
See Also
drawUnselectedText, drawSelectedText
drawLineback to summary
protected void drawLine(int p0, int p1, Graphics2D g, float x, float y)

Renders a line of text, suppressing whitespace at the end and expanding any tabs. This is implemented to make calls to the methods drawUnselectedText and drawSelectedText so that the way selected and unselected text are rendered can be customized.

Parameters
p0:int

the starting document location to use >= 0

p1:int

the ending document location to use >= p1

g:Graphics2D

the graphics context

x:float

the starting X position >= 0

y:float

the starting Y position >= 0

Since
9
See Also
drawUnselectedText, drawSelectedText
drawLineImplback to summary
private void drawLineImpl(int p0, int p1, Graphics g, float x, float y, boolean useFPAPI)
drawSelectedTextback to summary
protected int drawSelectedText(Graphics g, int x, int y, int p0, int p1) throws BadLocationException

Renders the given range in the model as selected text. This is implemented to render the text in the color specified in the hosting component. It assumes the highlighter will render the selected background.

Parameters
g:Graphics

the graphics context

x:int

the starting X coordinate >= 0

y:int

the starting Y coordinate >= 0

p0:int

the beginning position in the model >= 0

p1:int

the ending position in the model >= p0

Returns:int

the location of the end of the range.

Annotations
@Deprecated
since:9
Exceptions
BadLocationException:
if the range is invalid
drawSelectedTextback to summary
protected float drawSelectedText(Graphics2D g, float x, float y, int p0, int p1) throws BadLocationException

Renders the given range in the model as selected text. This is implemented to render the text in the color specified in the hosting component. It assumes the highlighter will render the selected background.

Parameters
g:Graphics2D

the graphics context

x:float

the starting X coordinate >= 0

y:float

the starting Y coordinate >= 0

p0:int

the beginning position in the model >= 0

p1:int

the ending position in the model >= p0

Returns:float

the location of the end of the range.

Exceptions
BadLocationException:
if the range is invalid
Since
9
drawSelectedTextImplback to summary
private float drawSelectedTextImpl(Graphics g, float x, float y, int p0, int p1, boolean useFPAPI) throws BadLocationException
drawTextback to summary
private float drawText(Element elem, int p0, int p1, Graphics g, float x, float y) throws BadLocationException
drawUnselectedTextback to summary
protected int drawUnselectedText(Graphics g, int x, int y, int p0, int p1) throws BadLocationException

Renders the given range in the model as normal unselected text.

Parameters
g:Graphics

the graphics context

x:int

the starting X coordinate >= 0

y:int

the starting Y coordinate >= 0

p0:int

the beginning position in the model >= 0

p1:int

the ending position in the model >= p0

Returns:int

the X location of the end of the range >= 0

Annotations
@Deprecated
since:9
Exceptions
BadLocationException:
if the range is invalid
drawUnselectedTextback to summary
protected float drawUnselectedText(Graphics2D g, float x, float y, int p0, int p1) throws BadLocationException

Renders the given range in the model as normal unselected text.

Parameters
g:Graphics2D

the graphics context

x:float

the starting X coordinate >= 0

y:float

the starting Y coordinate >= 0

p0:int

the beginning position in the model >= 0

p1:int

the ending position in the model >= p0

Returns:float

the X location of the end of the range >= 0

Exceptions
BadLocationException:
if the range is invalid
Since
9
drawUnselectedTextImplback to summary
private float drawUnselectedTextImpl(Graphics g, float x, float y, int p0, int p1, boolean useFPAPI) throws BadLocationException
getLineBufferback to summary
protected final Segment getLineBuffer()

Gives access to a buffer that can be used to fetch text from the associated document.

Returns:Segment

the buffer

getMaximumSpanback to summary
public float getMaximumSpan(int axis)

Overrides javax.swing.text.BoxView.getMaximumSpan.

Determines the maximum span for this view along an axis. This is implemented to provide the superclass behavior after first making sure that the current font metrics are cached (for the nested lines which use the metrics to determine the height of the potentially wrapped lines).

Parameters
axis:int

may be either View.X_AXIS or View.Y_AXIS

Returns:float

the span the view would like to be rendered into. Typically the view is told to render into the span that is returned, although there is no guarantee. The parent may choose to resize or break the view.

See Also
View#getMaximumSpan
getMinimumSpanback to summary
public float getMinimumSpan(int axis)

Overrides javax.swing.text.BoxView.getMinimumSpan.

Determines the minimum span for this view along an axis. This is implemented to provide the superclass behavior after first making sure that the current font metrics are cached (for the nested lines which use the metrics to determine the height of the potentially wrapped lines).

Parameters
axis:int

may be either View.X_AXIS or View.Y_AXIS

Returns:float

the span the view would like to be rendered into. Typically the view is told to render into the span that is returned, although there is no guarantee. The parent may choose to resize or break the view.

See Also
View#getMinimumSpan
getPreferredSpanback to summary
public float getPreferredSpan(int axis)

Overrides javax.swing.text.BoxView.getPreferredSpan.

Determines the preferred span for this view along an axis. This is implemented to provide the superclass behavior after first making sure that the current font metrics are cached (for the nested lines which use the metrics to determine the height of the potentially wrapped lines).

Parameters
axis:int

may be either View.X_AXIS or View.Y_AXIS

Returns:float

the span the view would like to be rendered into. Typically the view is told to render into the span that is returned, although there is no guarantee. The parent may choose to resize or break the view.

See Also
View#getPreferredSpan
getTabSizeback to summary
protected int getTabSize()

Returns the tab size set for the document, defaulting to 8.

Returns:int

the tab size

insertUpdateback to summary
public void insertUpdate(DocumentEvent e, Shape a, ViewFactory f)

Overrides javax.swing.text.View.insertUpdate.

Gives notification that something was inserted into the document in a location that this view is responsible for. This is implemented to simply update the children.

Parameters
e:DocumentEvent

the change information from the associated document

a:Shape

the current allocation of the view

f:ViewFactory

the factory to use to rebuild if the view has children

See Also
View#insertUpdate
loadChildrenback to summary
protected void loadChildren(ViewFactory f)

Overrides javax.swing.text.CompositeView.loadChildren.

Loads all of the children to initialize the view. This is called by the setParent method. Subclasses can reimplement this to initialize their child views in a different manner. The default implementation creates a child view for each child element.

Parameters
f:ViewFactory

the view factory

loadTextback to summary
pack-priv final void loadText(Segment segment, int p0, int p1)

Load the text buffer with the given range of text. This is used by the fragments broken off of this view as well as this view itself.

nextTabStopback to summary
public float nextTabStop(float x, int tabOffset)

Implements javax.swing.text.TabExpander.nextTabStop.

Returns the next tab stop position after a given reference position. This implementation does not support things like centering so it ignores the tabOffset argument.

Parameters
x:float

the current position >= 0

tabOffset:int

the position within the text stream that the tab occurred at >= 0.

Returns:float

the tab stop, measured in points >= 0

paintback to summary
public void paint(Graphics g, Shape a)

Overrides javax.swing.text.BoxView.paint.

Renders using the given rendering surface and area on that surface. This is implemented to stash the selection positions, selection colors, and font metrics for the nested lines to use.

Parameters
g:Graphics

the rendering surface to use

a:Shape

the allocated region to render into

See Also
View#paint
removeUpdateback to summary
public void removeUpdate(DocumentEvent e, Shape a, ViewFactory f)

Overrides javax.swing.text.View.removeUpdate.

Gives notification that something was removed from the document in a location that this view is responsible for. This is implemented to simply update the children.

Parameters
e:DocumentEvent

the change information from the associated document

a:Shape

the current allocation of the view

f:ViewFactory

the factory to use to rebuild if the view has children

See Also
View#removeUpdate
setSizeback to summary
public void setSize(float width, float height)

Overrides javax.swing.text.BoxView.setSize.

Sets the size of the view. This should cause layout of the view along the given axis, if it has any layout duties.

Parameters
width:float

the width >= 0

height:float

the height >= 0

updateChildrenback to summary
pack-priv void updateChildren(DocumentEvent e, Shape a)

Update the child views in response to a document event.

updateMetricsback to summary
pack-priv final void updateMetrics()
javax.swing.text back to summary

pack-priv Class WrappedPlainView.WrappedLine

extends View
Class Inheritance

Simple view of a line that wraps if it doesn't fit within the horizontal space allocated. This class tries to be lightweight by carrying little state of its own and sharing the state of the outer class with its siblings.

Field Summary

Modifier and TypeField and Description
pack-priv SoftReference<int[]>
pack-priv int
Inherited from javax.swing.text.View:
BadBreakWeightExcellentBreakWeightfirstUpdateIndexForcedBreakWeightGoodBreakWeightlastUpdateIndexsharedBiasReturnX_AXISY_AXIS

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv final int[]

Returns:

the cache created, ot null if text breaks into one line
breakLines
(int
position to start breaking from
startPos
)

Creates line cache if text breaks into more than one physical line.

private int
findLine(int offset)

Binary search in the cache for line containing specified offset (which is relative to the beginning of the view).

private int
findLine(int[] array, int offset, int min, int max)

pack-priv final int[]
getLineEnds()

Returns line cache.

public float

Returns:

the span the view would like to be rendered into. Typically the view is told to render into the span that is returned, although there is no guarantee. The parent may choose to resize or break the view.
getPreferredSpan
(int
may be either X_AXIS or Y_AXIS
axis
)

Implements abstract javax.swing.text.View.getPreferredSpan.

Determines the preferred span for this view along an axis.

public void
insertUpdate(DocumentEvent e, Shape a, ViewFactory f)

Overrides javax.swing.text.View.insertUpdate.

Gives notification that something was inserted into the document in a location that this view is responsible for.

public Shape

Returns:

the bounding box of the given position is returned
modelToView
(int
the position to convert
pos
,
Shape
the allocated region to render into
a
,
Position.Bias b)

Implements abstract javax.swing.text.View.modelToView.

Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.

public void
paint(Graphics
the rendering surface to use
g
,
Shape
the allocated region to render into
a
)

Implements abstract javax.swing.text.View.paint.

Renders using the given rendering surface and area on that surface.

public void
removeUpdate(DocumentEvent e, Shape a, ViewFactory f)

Overrides javax.swing.text.View.removeUpdate.

Gives notification that something was removed from the document in a location that this view is responsible for.

private void
public int

Returns:

the location within the model that best represents the given point in the view
viewToModel
(float
the X coordinate
fx
,
float
the Y coordinate
fy
,
Shape
the allocated region to render into
a
,
Position.Bias[] bias)

Implements abstract javax.swing.text.View.viewToModel.

Provides a mapping from the view coordinate space to the logical coordinate space of the model.

Inherited from javax.swing.text.View:
appendbreakViewcalculateUpdateIndexeschangedUpdatecreateFragmentforwardUpdateforwardUpdateToViewgetAlignmentgetAttributesgetBreakWeightgetChildAllocationgetContainergetDocumentgetElementgetEndOffsetgetGraphicsgetMaximumSpangetMinimumSpangetNextVisualPositionFromgetParentgetResizeWeightgetStartOffsetgetToolTipTextgetViewgetViewCountgetViewFactorygetViewIndexgetViewIndexinsertisVisiblemodelToViewmodelToViewpreferenceChangedremoveremoveAllreplacesetParentsetSizeupdateAfterChangeupdateChildrenupdateLayoutviewToModel

Field Detail

lineCacheback to summary
pack-priv SoftReference<int[]> lineCache
lineCountback to summary
pack-priv int lineCount

Constructor Detail

WrappedLineback to summary
pack-priv WrappedLine(Element elem)

Method Detail

breakLinesback to summary
pack-priv final int[] breakLines(int startPos)

Creates line cache if text breaks into more than one physical line.

Parameters
startPos:int

position to start breaking from

Returns:int[]

the cache created, ot null if text breaks into one line

findLineback to summary
private int findLine(int offset)

Binary search in the cache for line containing specified offset (which is relative to the beginning of the view). This method assumes that cache exists.

findLineback to summary
private int findLine(int[] array, int offset, int min, int max)
getLineEndsback to summary
pack-priv final int[] getLineEnds()

Returns line cache. If the cache was GC'ed, recreates it. If there's no cache, returns null

getPreferredSpanback to summary
public float getPreferredSpan(int axis)

Implements abstract javax.swing.text.View.getPreferredSpan.

Determines the preferred span for this view along an axis.

Parameters
axis:int

may be either X_AXIS or Y_AXIS

Returns:float

the span the view would like to be rendered into. Typically the view is told to render into the span that is returned, although there is no guarantee. The parent may choose to resize or break the view.

See Also
View#getPreferredSpan
insertUpdateback to summary
public void insertUpdate(DocumentEvent e, Shape a, ViewFactory f)

Overrides javax.swing.text.View.insertUpdate.

Doc from javax.swing.text.View.insertUpdate.

Gives notification that something was inserted into the document in a location that this view is responsible for. To reduce the burden to subclasses, this functionality is spread out into the following calls that subclasses can reimplement:

  1. updateChildren is called if there were any changes to the element this view is responsible for. If this view has child views that are represent the child elements, then this method should do whatever is necessary to make sure the child views correctly represent the model.
  2. forwardUpdate is called to forward the DocumentEvent to the appropriate child views.
  3. updateLayout is called to give the view a chance to either repair its layout, to reschedule layout, or do nothing.
modelToViewback to summary
public Shape modelToView(int pos, Shape a, Position.Bias b) throws BadLocationException

Implements abstract javax.swing.text.View.modelToView.

Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.

Parameters
pos:int

the position to convert

a:Shape

the allocated region to render into

Returns:Shape

the bounding box of the given position is returned

Exceptions
BadLocationException:
if the given position does not represent a valid location in the associated document
See Also
View#modelToView
paintback to summary
public void paint(Graphics g, Shape a)

Implements abstract javax.swing.text.View.paint.

Renders using the given rendering surface and area on that surface. The view may need to do layout and create child views to enable itself to render into the given allocation.

Parameters
g:Graphics

the rendering surface to use

a:Shape

the allocated region to render into

See Also
View#paint
removeUpdateback to summary
public void removeUpdate(DocumentEvent e, Shape a, ViewFactory f)

Overrides javax.swing.text.View.removeUpdate.

Doc from javax.swing.text.View.removeUpdate.

Gives notification that something was removed from the document in a location that this view is responsible for. To reduce the burden to subclasses, this functionality is spread out into the following calls that subclasses can reimplement:

  1. updateChildren is called if there were any changes to the element this view is responsible for. If this view has child views that are represent the child elements, then this method should do whatever is necessary to make sure the child views correctly represent the model.
  2. forwardUpdate is called to forward the DocumentEvent to the appropriate child views.
  3. updateLayout is called to give the view a chance to either repair its layout, to reschedule layout, or do nothing.
updateback to summary
private void update(DocumentEvent ev, Shape a)
viewToModelback to summary
public int viewToModel(float fx, float fy, Shape a, Position.Bias[] bias)

Implements abstract javax.swing.text.View.viewToModel.

Provides a mapping from the view coordinate space to the logical coordinate space of the model.

Parameters
fx:float

the X coordinate

fy:float

the Y coordinate

a:Shape

the allocated region to render into

Returns:int

the location within the model that best represents the given point in the view

See Also
View#viewToModel