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

public Class ParagraphView

extends FlowView
implements TabExpander
Class Inheritance
All Implemented Interfaces
javax.swing.text.TabExpander
Known Direct Subclasses
javax.swing.text.html.ParagraphView, javax.swing.JEditorPane.PlainEditorKit.PlainParagraph, javax.swing.plaf.basic.BasicTextFieldUI.I18nFieldView, javax.swing.plaf.basic.BasicTextAreaUI.PlainParagraph
Imports
java.awt.*, java.awt.font.TextAttribute, java.awt.geom.Rectangle2D, javax.swing.event.*, javax.swing.SizeRequirements

View of a simple line-wrapping paragraph that supports multiple fonts, colors, components, icons, etc. It is basically a vertical box with a margin around it. The contents of the box are a bunch of rows which are special horizontal boxes. This view creates a collection of views that represent the child elements of the paragraph element. Each of these views are placed into a row directly if they will fit, otherwise the breakView method is called to try and carve the view into pieces that fit.
Authors
Timothy Prinzing, Scott Violet, Igor Kushnirskiy
See Also
View

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class
ParagraphView.Row

Internally created view that has the purpose of holding the views that represent the children of the paragraph that have been arranged in rows.

Field Summary

Modifier and TypeField and Description
protected int
firstLineIndent

Indentation for the first line, from the left inset.

pack-priv static Class<?>
i18nStrategy

Used to create an i18n-based layout strategy

private int
private float
private int
tabBase

Used by the TabExpander functionality to determine where to base the tab calculations.

pack-priv static char[]
tabChars

Used for searching for a tab.

pack-priv static char[]
tabDecimalChars

Used for searching for a tab or decimal character.

Inherited from javax.swing.text.FlowView:
layoutPoollayoutSpanstrategy

Constructor Summary

AccessConstructor and Description
public
ParagraphView(Element
the element that this view is responsible for
elem
)

Constructs a ParagraphView for the given element.

Method Summary

Modifier and TypeMethod and Description
public View

Returns:

the fragment of the view that represents the given span, if the view can be broken; if the view doesn't support breaking behavior, the view itself is returned
breakView
(int
may be either View.X_AXIS or View.Y_AXIS
axis
,
float
specifies where a potential break is desired along the given axis >= 0
len
,
Shape
the current allocation of the view
a
)

Breaks this view on the given axis at the given length.

protected SizeRequirements

Returns:

the new or adjusted SizeRequirements object
calculateMinorAxisRequirements
(int
the minor axis
axis
,
SizeRequirements
the input SizeRequirements object
r
)

Overrides javax.swing.text.FlowView.calculateMinorAxisRequirements.

Calculate the needs for the paragraph along the minor axis.

public void
changedUpdate(DocumentEvent
the change information from the associated document
changes
,
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.FlowView.changedUpdate.

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

protected View

Returns:

the new View
createRow
()

Implements abstract javax.swing.text.FlowView.createRow.

Create a View that should be used to hold a a row's worth of children in a flow.

private float
findEdgeSpan(View v, int axis, int fp, int p0, int p1)

Binary search for the longest non-breakable fragment at the view edge.

protected int

Returns:

the document offset, or -1 if no characters found
findOffsetToCharactersInString
(char[]
the string of characters
string
,
int
where to start in the model >= 0
start
)

Finds the next character in the document with a character in string, starting at offset start.

protected boolean

Returns:

true if the text is laid out right to left at position, otherwise false.
flipEastAndWestAtEnds
(int
position into the model
position
,
Position.Bias
either Position.Bias.Forward or Position.Bias.Backward
bias
)

Overrides javax.swing.text.BoxView.flipEastAndWestAtEnds.

Determines in which direction the next view lays.

public float

Returns:

the desired alignment. This should be a value between 0.0 and 1.0 inclusive, where 0 indicates alignment at the origin and 1.0 indicates alignment to the full span away from the origin. An alignment of 0.5 would be the center of the view.
getAlignment
(int
may be either View.X_AXIS or View.Y_AXIS
axis
)

Overrides javax.swing.text.BoxView.getAlignment.

Determines the desired alignment for this view along an axis.

public int

Returns:

a value indicating the attractiveness of breaking here; either GoodBreakWeight or BadBreakWeight
getBreakWeight
(int
may be either View.X_AXIS or View.Y_AXIS
axis
,
float
specifies where a potential break is desired >= 0
len
)

Gets the break weight for a given location.

protected int

Returns:

the closest model position to x
getClosestPositionTo
(int
position into the model
pos
,
Position.Bias
the bias
b
,
Shape
the allocated region to render into
a
,
int
one of the following values:
  • SwingConstants.NORTH
  • SwingConstants.SOUTH
direction
,
Position.Bias[]
an array containing the bias that were checked in this method
biasRet
,
int
the index of the view
rowIndex
,
int
the x coordinate of interest
x
)

Returns the closest model position to x.

public int

Returns:

the constraining span for the given view at index
getFlowSpan
(int
the index of the view being queried
index
)

Overrides javax.swing.text.FlowView.getFlowSpan.

Fetches the constraining span to flow against for the given child index.

public int

Returns:

the location for the given view at index
getFlowStart
(int
the index of the view being queried
index
)

Overrides javax.swing.text.FlowView.getFlowStart.

Fetches the location along the flow axis that the flow span will start at.

protected View

Returns:

the view at index
getLayoutView
(int
the index of the desired view
index
)

Returns the view at a given index.

protected int

Returns:

the number of views that this ParagraphView is responsible for
getLayoutViewCount
()

Returns the number of views that this view is responsible for.

protected int

Returns:

the location in the model that represents the next location visual position
getNextNorthSouthVisualPositionFrom
(int
position into the model
pos
,
Position.Bias
either Position.Bias.Forward or Position.Bias.Backward
b
,
Shape
the allocated region to render into
a
,
int
either SwingConstants.NORTH or SwingConstants.SOUTH
direction
,
Position.Bias[]
an array containing the bias that were checked in this method
biasRet
)

Overrides javax.swing.text.CompositeView.getNextNorthSouthVisualPositionFrom.

Returns the next visual position for the cursor, in either the east or west direction.

protected float

Returns:

the size >= 0
getPartialSize
(int
the starting document offset >= 0
startOffset
,
int
the ending document offset >= startOffset
endOffset
)

Returns the size used by the views between startOffset and endOffset.

protected float

Returns:

where tabs are calculated from
getTabBase
()

Returns where the tabs are calculated from.

protected TabSet

Returns:

the TabSet
getTabSet
()

Gets the Tabset to be used in calculating tabs.

public float

Returns:

the trailing end of the tab expansion >= 0
nextTabStop
(float
the X reference position
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 given a 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.

protected void
setFirstLineIndent(float
the value in points
fi
)

Sets the indent on the first line.

protected void
setJustification(int
one of the following values:
  • StyleConstants.ALIGN_LEFT
  • StyleConstants.ALIGN_CENTER
  • StyleConstants.ALIGN_RIGHT
j
)

Sets the type of justification.

protected void
setLineSpacing(float
the value is a factor of the line height
ls
)

Sets the line spacing.

protected void
setPropertiesFromAttributes()

Set the cached properties from the attributes.

Inherited from javax.swing.text.FlowView:
getFlowAxisgetViewIndexAtPositioninsertUpdatelayoutloadChildrenremoveUpdatesetParent

Field Detail

firstLineIndentback to summary
protected int firstLineIndent

Indentation for the first line, from the left inset.

i18nStrategyback to summary
pack-priv static Class<?> i18nStrategy

Used to create an i18n-based layout strategy

justificationback to summary
private int justification
lineSpacingback to summary
private float lineSpacing
tabBaseback to summary
private int tabBase

Used by the TabExpander functionality to determine where to base the tab calculations. This is basically the location of the left side of the paragraph.

tabCharsback to summary
pack-priv static char[] tabChars

Used for searching for a tab.

tabDecimalCharsback to summary
pack-priv static char[] tabDecimalChars

Used for searching for a tab or decimal character.

Constructor Detail

ParagraphViewback to summary
public ParagraphView(Element elem)

Constructs a ParagraphView for the given element.

Parameters
elem:Element

the element that this view is responsible for

Method Detail

breakViewback to summary
public View breakView(int axis, float len, Shape a)

Breaks this view on the given axis at the given length.

ParagraphView instances are breakable along the Y_AXIS only, and only if len is after the first line.

Parameters
axis:int

may be either View.X_AXIS or View.Y_AXIS

len:float

specifies where a potential break is desired along the given axis >= 0

a:Shape

the current allocation of the view

Returns:View

the fragment of the view that represents the given span, if the view can be broken; if the view doesn't support breaking behavior, the view itself is returned

See Also
View#breakView
calculateMinorAxisRequirementsback to summary
protected SizeRequirements calculateMinorAxisRequirements(int axis, SizeRequirements r)

Overrides javax.swing.text.FlowView.calculateMinorAxisRequirements.

Calculate the needs for the paragraph along the minor axis.

This uses size requirements of the superclass, modified to take into account the non-breakable areas at the adjacent views edges. The minimal size requirements for such views should be no less than the sum of all adjacent fragments.

If the axis parameter is neither View.X_AXIS nor View.Y_AXIS, IllegalArgumentException is thrown. If the r parameter is null, a new SizeRequirements object is created, otherwise the supplied SizeRequirements object is returned.

Parameters
axis:int

the minor axis

r:SizeRequirements

the input SizeRequirements object

Returns:SizeRequirements

the new or adjusted SizeRequirements object

Annotations
@Override
Exceptions
IllegalArgumentException:
if the axis parameter is invalid
changedUpdateback to summary
public void changedUpdate(DocumentEvent changes, Shape a, ViewFactory f)

Overrides javax.swing.text.FlowView.changedUpdate.

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

Parameters
changes: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
createRowback to summary
protected View createRow()

Implements abstract javax.swing.text.FlowView.createRow.

Create a View that should be used to hold a a row's worth of children in a flow.

Returns:View

the new View

Since
1.3
findEdgeSpanback to summary
private float findEdgeSpan(View v, int axis, int fp, int p0, int p1)

Binary search for the longest non-breakable fragment at the view edge.

findOffsetToCharactersInStringback to summary
protected int findOffsetToCharactersInString(char[] string, int start)

Finds the next character in the document with a character in string, starting at offset start. If there are no characters found, -1 will be returned.

Parameters
string:char[]

the string of characters

start:int

where to start in the model >= 0

Returns:int

the document offset, or -1 if no characters found

flipEastAndWestAtEndsback to summary
protected boolean flipEastAndWestAtEnds(int position, Position.Bias bias)

Overrides javax.swing.text.BoxView.flipEastAndWestAtEnds.

Determines in which direction the next view lays. Consider the View at index n. Typically the Views are laid out from left to right, so that the View to the EAST will be at index n + 1, and the View to the WEST will be at index n - 1. In certain situations, such as with bidirectional text, it is possible that the View to EAST is not at index n + 1, but rather at index n - 1, or that the View to the WEST is not at index n - 1, but index n + 1. In this case this method would return true, indicating the Views are laid out in descending order.

This will return true if the text is laid out right to left at position, otherwise false.

Parameters
position:int

position into the model

bias:Position.Bias

either Position.Bias.Forward or Position.Bias.Backward

Returns:boolean

true if the text is laid out right to left at position, otherwise false.

getAlignmentback to summary
public float getAlignment(int axis)

Overrides javax.swing.text.BoxView.getAlignment.

Determines the desired alignment for this view along an axis. This is implemented to give the alignment to the center of the first row along the y axis, and the default along the x axis.

Parameters
axis:int

may be either View.X_AXIS or View.Y_AXIS

Returns:float

the desired alignment. This should be a value between 0.0 and 1.0 inclusive, where 0 indicates alignment at the origin and 1.0 indicates alignment to the full span away from the origin. An alignment of 0.5 would be the center of the view.

getBreakWeightback to summary
public int getBreakWeight(int axis, float len)

Gets the break weight for a given location.

ParagraphView instances are breakable along the Y_AXIS only, and only if len is after the first row. If the length is less than one row, a value of BadBreakWeight is returned.

Parameters
axis:int

may be either View.X_AXIS or View.Y_AXIS

len:float

specifies where a potential break is desired >= 0

Returns:int

a value indicating the attractiveness of breaking here; either GoodBreakWeight or BadBreakWeight

See Also
View#getBreakWeight
getClosestPositionToback to summary
protected int getClosestPositionTo(int pos, Position.Bias b, Shape a, int direction, Position.Bias[] biasRet, int rowIndex, int x) throws BadLocationException

Returns the closest model position to x. rowIndex gives the index of the view that corresponds that should be looked in.

Parameters
pos:int

position into the model

b:Position.Bias

the bias

a:Shape

the allocated region to render into

direction:int

one of the following values:

  • SwingConstants.NORTH
  • SwingConstants.SOUTH
biasRet:Position.Bias[]

an array containing the bias that were checked in this method

rowIndex:int

the index of the view

x:int

the x coordinate of interest

Returns:int

the closest model position to x

Annotations
@SuppressWarnings:deprecation
Exceptions
BadLocationException:
if a bad location is encountered
getFlowSpanback to summary
public int getFlowSpan(int index)

Overrides javax.swing.text.FlowView.getFlowSpan.

Fetches the constraining span to flow against for the given child index.

Parameters
index:int

the index of the view being queried

Returns:int

the constraining span for the given view at index

Since
1.3
getFlowStartback to summary
public int getFlowStart(int index)

Overrides javax.swing.text.FlowView.getFlowStart.

Fetches the location along the flow axis that the flow span will start at.

Parameters
index:int

the index of the view being queried

Returns:int

the location for the given view at index

Since
1.3
getLayoutViewback to summary
protected View getLayoutView(int index)

Returns the view at a given index. The child views of the paragraph are rows which have been used to arrange pieces of the Views that represent the child elements. This methods returns the view responsible for the child element index (prior to breaking). These are the Views that were produced from a factory (to represent the child elements) and used for layout.

Parameters
index:int

the index of the desired view

Returns:View

the view at index

getLayoutViewCountback to summary
protected int getLayoutViewCount()

Returns the number of views that this view is responsible for. The child views of the paragraph are rows which have been used to arrange pieces of the Views that represent the child elements. This is the number of views that have been tiled in two dimensions, and should be equivalent to the number of child elements to the element this view is responsible for.

Returns:int

the number of views that this ParagraphView is responsible for

getNextNorthSouthVisualPositionFromback to summary
protected int getNextNorthSouthVisualPositionFrom(int pos, Position.Bias b, Shape a, int direction, Position.Bias[] biasRet) throws BadLocationException

Overrides javax.swing.text.CompositeView.getNextNorthSouthVisualPositionFrom.

Returns the next visual position for the cursor, in either the east or west direction. Overridden from CompositeView.

Parameters
pos:int

position into the model

b:Position.Bias

either Position.Bias.Forward or Position.Bias.Backward

a:Shape

the allocated region to render into

direction:int

either SwingConstants.NORTH or SwingConstants.SOUTH

biasRet:Position.Bias[]

an array containing the bias that were checked in this method

Returns:int

the location in the model that represents the next location visual position

Annotations
@SuppressWarnings:deprecation
Exceptions
BadLocationException:

Doc from javax.swing.text.CompositeView.getNextNorthSouthVisualPositionFrom.

for a bad location within a document model

getPartialSizeback to summary
protected float getPartialSize(int startOffset, int endOffset)

Returns the size used by the views between startOffset and endOffset. This uses getPartialView to calculate the size if the child view implements the TabableView interface. If a size is needed and a View does not implement the TabableView interface, the preferredSpan will be used.

Parameters
startOffset:int

the starting document offset >= 0

endOffset:int

the ending document offset >= startOffset

Returns:float

the size >= 0

getTabBaseback to summary
protected float getTabBase()

Returns where the tabs are calculated from.

Returns:float

where tabs are calculated from

getTabSetback to summary
protected TabSet getTabSet()

Gets the Tabset to be used in calculating tabs.

Returns:TabSet

the TabSet

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

Implements javax.swing.text.TabExpander.nextTabStop.

Returns the next tab stop position given a reference position. This view implements the tab coordinate system, and calls getTabbedSpan on the logical children in the process of layout to determine the desired span of the children. The logical children can delegate their tab expansion upward to the paragraph which knows how to expand tabs. LabelView is an example of a view that delegates its tab expansion needs upward to the paragraph.

This is implemented to try and locate a TabSet in the paragraph element's attribute set. If one can be found, its settings will be used, otherwise a default expansion will be provided. The base location for tab expansion is the left inset from the paragraphs most recent allocation (which is what the layout of the children is based upon).

Parameters
x:float

the X reference position

tabOffset:int

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

Returns:float

the trailing end of the tab expansion >= 0

See Also
TabSet, TabStop, LabelView
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 delegate to the superclass after stashing the base coordinate for tab calculations.

Parameters
g:Graphics

the rendering surface to use

a:Shape

the allocated region to render into

See Also
View#paint
setFirstLineIndentback to summary
protected void setFirstLineIndent(float fi)

Sets the indent on the first line.

Parameters
fi:float

the value in points

setJustificationback to summary
protected void setJustification(int j)

Sets the type of justification.

Parameters
j:int

one of the following values:

  • StyleConstants.ALIGN_LEFT
  • StyleConstants.ALIGN_CENTER
  • StyleConstants.ALIGN_RIGHT
setLineSpacingback to summary
protected void setLineSpacing(float ls)

Sets the line spacing.

Parameters
ls:float

the value is a factor of the line height

setPropertiesFromAttributesback to summary
protected void setPropertiesFromAttributes()

Set the cached properties from the attributes.

javax.swing.text back to summary

pack-priv Class ParagraphView.Row

extends BoxView
Class Inheritance

Internally created view that has the purpose of holding the views that represent the children of the paragraph that have been arranged in rows.

Field Summary

Modifier and TypeField and Description
pack-priv static final int
pack-priv int[]
pack-priv static final int
pack-priv static final int
pack-priv static final int
Inherited from javax.swing.text.BoxView:
majorAllocValidmajorAxismajorOffsetsmajorRequestmajorReqValidmajorSpanmajorSpansminorAllocValidminorOffsetsminorRequestminorReqValidminorSpanminorSpanstempRect

Constructor Summary

AccessConstructor and Description
pack-priv
Row(Element elem)

Method Summary

Modifier and TypeMethod and Description
protected SizeRequirements
calculateMajorAxisRequirements(int axis, SizeRequirements r)

Overrides javax.swing.text.BoxView.calculateMajorAxisRequirements.

Calculates the size requirements for the major axis axis.

protected SizeRequirements
calculateMinorAxisRequirements(int axis, SizeRequirements r)

Overrides javax.swing.text.BoxView.calculateMinorAxisRequirements.

Calculates the size requirements for the minor axis axis.

public float
getAlignment(int axis)

Overrides javax.swing.text.BoxView.getAlignment.

Determines the desired alignment for this view along an axis.

public AttributeSet
getAttributes()

Overrides javax.swing.text.View.getAttributes.

Fetches the attributes to use when rendering.

protected short
public int
getEndOffset()

Overrides javax.swing.text.View.getEndOffset.

Fetches the portion of the model for which this view is responsible.

protected short

Returns:

the inset
getLeftInset
()

Overrides javax.swing.text.CompositeView.getLeftInset.

Gets the left inset.

public float
getMaximumSpan(int axis)

Overrides javax.swing.text.BoxView.getMaximumSpan.

Determines the maximum span for this view along an axis.

public int
getStartOffset()

Overrides javax.swing.text.View.getStartOffset.

Range represented by a row in the paragraph is only a subset of the total range of the paragraph element.

protected int

Returns:

index of the view representing the given position, or -1 if no view represents that position
getViewIndexAtPosition
(int
the position >= 0
pos
)

Overrides javax.swing.text.CompositeView.getViewIndexAtPosition.

Fetches the child view index representing the given position in the model.

private boolean
private boolean
private boolean

Returns:

true if this Row should be justified.
isJustifyEnabled
()

Whether we need to justify this Row.

private boolean
protected void
layoutMajorAxis(int targetSpan, int axis, int[] offsets, int[] spans)

Overrides javax.swing.text.BoxView.layoutMajorAxis.

Performs layout for the major axis of the box (i.e. the axis that it represents).

protected void

Returns:

the offset and span for each child view in the offsets and spans parameters
layoutMinorAxis
(int
the total span given to the view, which would be used to layout the children.
targetSpan
,
int
the axis being laid out.
axis
,
int[]
the offsets from the origin of the view for each of the child views. This is a return value and is filled in by the implementation of this method.
offsets
,
int[]
the span of each child view. This is a return value and is filled in by the implementation of this method.
spans
)

Overrides javax.swing.text.BoxView.layoutMinorAxis.

Perform layout for the minor axis of the box (i.e. the axis orthogonal to the axis that it represents).

protected void
loadChildren(ViewFactory f)

Overrides javax.swing.text.CompositeView.loadChildren.

This is reimplemented to do nothing since the paragraph fills in the row with its needed children.

public Shape

Returns:

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

Overrides javax.swing.text.BoxView.modelToView.

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

Inherited from javax.swing.text.BoxView:
baselineLayoutbaselineRequirementscheckRequestschildAllocationflipEastAndWestAtEndsforwardUpdategetAxisgetChildAllocationgetHeightgetMinimumSpangetOffsetgetPreferredSpangetResizeWeightgetSpangetSpanOnAxisgetViewAtPointgetWidthisAfterisAllocationValidisBeforeisLayoutValidlayoutlayoutChangedpaintpaintChildpreferenceChangedreplacesetAxissetSizesetSpanOnAxisupdateChildSizesupdateLayoutArrayviewToModel

Field Detail

END_JUSTIFIABLEback to summary
pack-priv static final int END_JUSTIFIABLE
justificationDataback to summary
pack-priv int[] justificationData
SPACE_ADDONback to summary
pack-priv static final int SPACE_ADDON
SPACE_ADDON_LEFTOVER_ENDback to summary
pack-priv static final int SPACE_ADDON_LEFTOVER_END
START_JUSTIFIABLEback to summary
pack-priv static final int START_JUSTIFIABLE

Constructor Detail

Rowback to summary
pack-priv Row(Element elem)

Method Detail

calculateMajorAxisRequirementsback to summary
protected SizeRequirements calculateMajorAxisRequirements(int axis, SizeRequirements r)

Overrides javax.swing.text.BoxView.calculateMajorAxisRequirements.

Doc from javax.swing.text.BoxView.calculateMajorAxisRequirements.

Calculates the size requirements for the major axis axis.

Annotations
@Override
calculateMinorAxisRequirementsback to summary
protected SizeRequirements calculateMinorAxisRequirements(int axis, SizeRequirements r)

Overrides javax.swing.text.BoxView.calculateMinorAxisRequirements.

Doc from javax.swing.text.BoxView.calculateMinorAxisRequirements.

Calculates the size requirements for the minor axis axis.

getAlignmentback to summary
public float getAlignment(int axis)

Overrides javax.swing.text.BoxView.getAlignment.

Doc from javax.swing.text.BoxView.getAlignment.

Determines the desired alignment for this view along an axis. This is implemented to give the total alignment needed to position the children with the alignment points lined up along the axis orthogonal to the axis that is being tiled. The axis being tiled will request to be centered (i.e. 0.5f).

getAttributesback to summary
public AttributeSet getAttributes()

Overrides javax.swing.text.View.getAttributes.

Fetches the attributes to use when rendering. This view isn't directly responsible for an element so it returns the outer classes attributes.

getBottomInsetback to summary
protected short getBottomInset()

Overrides javax.swing.text.CompositeView.getBottomInset.

Doc from javax.swing.text.CompositeView.getBottomInset.

Gets the bottom inset.

getEndOffsetback to summary
public int getEndOffset()

Overrides javax.swing.text.View.getEndOffset.

Doc from javax.swing.text.View.getEndOffset.

Fetches the portion of the model for which this view is responsible.

getLeftInsetback to summary
protected short getLeftInset()

Overrides javax.swing.text.CompositeView.getLeftInset.

Gets the left inset.

Returns:short

the inset

getMaximumSpanback to summary
public float getMaximumSpan(int axis)

Overrides javax.swing.text.BoxView.getMaximumSpan.

Doc from javax.swing.text.BoxView.getMaximumSpan.

Determines the maximum span for this view along an axis.

Annotations
@Override
getStartOffsetback to summary
public int getStartOffset()

Overrides javax.swing.text.View.getStartOffset.

Range represented by a row in the paragraph is only a subset of the total range of the paragraph element.

getViewIndexAtPositionback to summary
protected int getViewIndexAtPosition(int pos)

Overrides javax.swing.text.CompositeView.getViewIndexAtPosition.

Fetches the child view index representing the given position in the model.

Parameters
pos:int

the position >= 0

Returns:int

index of the view representing the given position, or -1 if no view represents that position

isBrokenRowback to summary
private boolean isBrokenRow()
isJustifiableDocumentback to summary
private boolean isJustifiableDocument()
isJustifyEnabledback to summary
private boolean isJustifyEnabled()

Whether we need to justify this Row. At this time (jdk1.6) we support justification on for non 18n text.

Returns:boolean

true if this Row should be justified.

isLastRowback to summary
private boolean isLastRow()
layoutMajorAxisback to summary
protected void layoutMajorAxis(int targetSpan, int axis, int[] offsets, int[] spans)

Overrides javax.swing.text.BoxView.layoutMajorAxis.

Doc from javax.swing.text.BoxView.layoutMajorAxis.

Performs layout for the major axis of the box (i.e. the axis that it represents). The results of the layout (the offset and span for each children) are placed in the given arrays which represent the allocations to the children along the major axis.

Annotations
@Override
layoutMinorAxisback to summary
protected void layoutMinorAxis(int targetSpan, int axis, int[] offsets, int[] spans)

Overrides javax.swing.text.BoxView.layoutMinorAxis.

Perform layout for the minor axis of the box (i.e. the axis orthogonal to the axis that it represents). The results of the layout should be placed in the given arrays which represent the allocations to the children along the minor axis.

This is implemented to do a baseline layout of the children by calling BoxView.baselineLayout.

Parameters
targetSpan:int

the total span given to the view, which would be used to layout the children.

axis:int

the axis being laid out.

offsets:int[]

the offsets from the origin of the view for each of the child views. This is a return value and is filled in by the implementation of this method.

spans:int[]

the span of each child view. This is a return value and is filled in by the implementation of this method.

Returns:void

the offset and span for each child view in the offsets and spans parameters

loadChildrenback to summary
protected void loadChildren(ViewFactory f)

Overrides javax.swing.text.CompositeView.loadChildren.

This is reimplemented to do nothing since the paragraph fills in the row with its needed children.

modelToViewback to summary
public Shape modelToView(int pos, Shape a, Position.Bias b) throws BadLocationException

Overrides javax.swing.text.BoxView.modelToView.

Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it. This is implemented to let the superclass find the position along the major axis and the allocation of the row is used along the minor axis, so that even though the children are different heights they all get the same caret height.

Parameters
pos:int

the position to convert

a:Shape

the allocated region to render into

Returns:Shape

the bounding box of the given position

Exceptions
BadLocationException:
if the given position does not represent a valid location in the associated document
See Also
View#modelToView