javax.swing.text

Class ParagraphView

public class ParagraphView extends FlowView implements TabExpander

A {@link FlowView} that flows it's children horizontally and boxes the rows vertically.
Field Summary
protected intfirstLineIndent
The indentation of the first line of the paragraph.
Constructor Summary
ParagraphView(Element element)
Creates a new ParagraphView for the given Element.
Method Summary
protected voidadjustRow(ParagraphView.Row r, int desiredSpan, int x)
ViewbreakView(int axis, float len, Shape a)
voidchangedUpdate(DocumentEvent ev, Shape a, ViewFactory vf)
Receives notification when some attributes of the displayed element changes.
protected ViewcreateRow()
Creates a new view that represents a row within a flow.
protected intfindOffsetToCharactersInString(char[] string, int start)
Finds the next offset in the document that has one of the characters specified in string.
floatgetAlignment(int axis)
Returns the alignment for this paragraph view for the specified axis.
intgetBreakWeight(int axis, float len)
protected intgetClosestPositionTo(int pos, Position.Bias bias, Shape a, int direction, Position.Bias[] biasRet, int rowIndex, int x)
protected ViewgetLayoutView(int i)
Returns the i-th view from the logical views, before breaking into rows.
protected intgetLayoutViewCount()
Returns the number of logical child views.
protected floatgetPartialSize(int startOffset, int endOffset)
Returns the size that is used by this view (or it's child views) between startOffset and endOffset.
protected floatgetTabBase()
Returns the location where the tabs are calculated from.
protected TabSetgetTabSet()
Returns the TabSet used by this ParagraphView.
floatnextTabStop(float x, int tabOffset)
protected voidsetFirstLineIndent(float i)
Sets the indentation of the first line of the paragraph.
protected voidsetJustification(int j)
Sets the justification of the paragraph.
protected voidsetLineSpacing(float s)
Sets the line spacing for this paragraph.
protected voidsetPropertiesFromAttributes()
Fetches the cached properties from the element's attributes.

Field Detail

firstLineIndent

protected int firstLineIndent
The indentation of the first line of the paragraph.

Constructor Detail

ParagraphView

public ParagraphView(Element element)
Creates a new ParagraphView for the given Element.

Parameters: element the element that is rendered by this ParagraphView

Method Detail

adjustRow

protected void adjustRow(ParagraphView.Row r, int desiredSpan, int x)

UNKNOWN: This method is specified to take a Row parameter, which is a private inner class of that class, which makes it unusable from application code. Also, this method seems to be replaced by {@link FlowStrategy#adjustRow(FlowView, int, int, int)}.

breakView

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

UNKNOWN: This method's signature differs from the one defined in {@link View} and is therefore never called. It is probably there for historical reasons.

changedUpdate

public void changedUpdate(DocumentEvent ev, Shape a, ViewFactory vf)
Receives notification when some attributes of the displayed element changes. This triggers a refresh of the cached attributes of this paragraph.

Parameters: ev the document event a the allocation of this view vf the view factory to use for creating new child views

createRow

protected View createRow()
Creates a new view that represents a row within a flow.

Returns: a view for a new row

findOffsetToCharactersInString

protected int findOffsetToCharactersInString(char[] string, int start)
Finds the next offset in the document that has one of the characters specified in string. If there is no such character found, this returns -1.

Parameters: string the characters to search for start the start offset

Returns: the next offset in the document that has one of the characters specified in string

getAlignment

public float getAlignment(int axis)
Returns the alignment for this paragraph view for the specified axis. For the X_AXIS the paragraph view will be aligned at it's left edge (0.0F). For the Y_AXIS the paragraph view will be aligned at the center of it's first row.

Parameters: axis the axis which is examined

Returns: the alignment for this paragraph view for the specified axis

getBreakWeight

public int getBreakWeight(int axis, float len)

UNKNOWN: This method's signature differs from the one defined in {@link View} and is therefore never called. It is probably there for historical reasons.

getClosestPositionTo

protected int getClosestPositionTo(int pos, Position.Bias bias, Shape a, int direction, Position.Bias[] biasRet, int rowIndex, int x)

getLayoutView

protected View getLayoutView(int i)
Returns the i-th view from the logical views, before breaking into rows.

Parameters: i the index of the logical view to return

Returns: the i-th view from the logical views, before breaking into rows

getLayoutViewCount

protected int getLayoutViewCount()
Returns the number of logical child views.

Returns: the number of logical child views

getPartialSize

protected float getPartialSize(int startOffset, int endOffset)
Returns the size that is used by this view (or it's child views) between startOffset and endOffset. If the child views implement the {@link TabableView} interface, then this is used to determine the span, otherwise we use the preferred span of the child views.

Parameters: startOffset the start offset endOffset the end offset

Returns: the span used by the view between startOffset and endOffset

getTabBase

protected float getTabBase()
Returns the location where the tabs are calculated from. This returns 0.0F by default.

Returns: the location where the tabs are calculated from

getTabSet

protected TabSet getTabSet()
Returns the TabSet used by this ParagraphView.

Returns: the TabSet used by this ParagraphView

nextTabStop

public float nextTabStop(float x, int tabOffset)

setFirstLineIndent

protected void setFirstLineIndent(float i)
Sets the indentation of the first line of the paragraph.

Parameters: i the indentation to set

setJustification

protected void setJustification(int j)
Sets the justification of the paragraph.

Parameters: j the justification to set

setLineSpacing

protected void setLineSpacing(float s)
Sets the line spacing for this paragraph.

Parameters: s the line spacing to set

setPropertiesFromAttributes

protected void setPropertiesFromAttributes()
Fetches the cached properties from the element's attributes.