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

pack-priv Class TextLayoutStrategy

extends FlowStrategy
Class Inheritance
Imports
java.awt.Container, .Font, .Rectangle, java.awt.font.FontRenderContext, .LineBreakMeasurer, .TextAttribute, .TextLayout, java.text.AttributedCharacterIterator, .BreakIterator, java.util.HashSet, .Hashtable, .Map, .Set, javax.swing.JComponent, javax.swing.event.DocumentEvent, sun.font.BidiUtils

A flow strategy that uses java.awt.font.LineBreakMeasurer to produce java.awt.font.TextLayout for i18n capable rendering. If the child view being placed into the flow is of type GlyphView and can be rendered by TextLayout, a GlyphPainter that uses TextLayout is plugged into the GlyphView.
Author
Timothy Prinzing

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
TextLayoutStrategy.AttributedSegment

Implementation of AttributedCharacterIterator that supports the GlyphView attributes for rendering the glyphs through a TextLayout.

Field Summary

Modifier and TypeField and Description
private LineBreakMeasurer
private TextLayoutStrategy.AttributedSegment
Inherited from javax.swing.text.FlowView.FlowStrategy:
damageStartviewBuffer

Constructor Summary

AccessConstructor and Description
public
TextLayoutStrategy()

Constructs a layout strategy for paragraphs based upon java.awt.font.LineBreakMeasurer.

Method Summary

Modifier and TypeMethod and Description
protected void
adjustRow(FlowView fv, int
the row to adjust to the current layout span.
rowIndex
,
int
the current layout span >= 0
desiredSpan
,
int
the location r starts at.
x
)

Overrides javax.swing.text.FlowView.FlowStrategy.adjustRow.

Adjusts the given row if possible to fit within the layout span.

public void
changedUpdate(FlowView fv, DocumentEvent
the change information from the associated document
e
,
Rectangle
the current allocation of the view inside of the insets.
alloc
)

Overrides javax.swing.text.FlowView.FlowStrategy.changedUpdate.

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

protected View
createView(FlowView
the view holding the flow
fv
,
int
the start location for the view being created
startOffset
,
int
the amount of span left to fill in the row
spanLeft
,
int
the row the view will be placed into
rowIndex
)

Overrides javax.swing.text.FlowView.FlowStrategy.createView.

Creates a unidirectional view that can be used to represent the current chunk.

pack-priv int
getLimitingOffset(View
the logical view representing the starting offset.
v
,
int
the model location to start at.
startOffset
,
int spanLeft, boolean requireNextWord)

Calculate the limiting offset for the next view fragment.

public void
insertUpdate(FlowView fv, DocumentEvent
the change information from the associated document
e
,
Rectangle
the current allocation of the view inside of the insets. This value will be null if the view has not yet been displayed.
alloc
)

Overrides javax.swing.text.FlowView.FlowStrategy.insertUpdate.

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

public void
layout(FlowView
the view to reflow
fv
)

Overrides javax.swing.text.FlowView.FlowStrategy.layout.

Does a full layout on the given View.

protected int

Returns:

the position to start the next row
layoutRow
(FlowView fv, int
the row to fill in with views. This is assumed to be empty on entry.
rowIndex
,
int
The current position in the children of this view element from which to start.
p0
)

Overrides javax.swing.text.FlowView.FlowStrategy.layoutRow.

Creates a row of views that will fit within the layout span of the row.

public void
removeUpdate(FlowView fv, DocumentEvent
the change information from the associated document
e
,
Rectangle
the current allocation of the view inside of the insets.
alloc
)

Overrides javax.swing.text.FlowView.FlowStrategy.removeUpdate.

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

pack-priv void
sync(FlowView fv)

Synchronize the strategy with its FlowView.

Inherited from javax.swing.text.FlowView.FlowStrategy:
addDamagegetLogicalViewreparentViewsunsetDamage

Field Detail

measurerback to summary
private LineBreakMeasurer measurer
textback to summary
private TextLayoutStrategy.AttributedSegment text

Constructor Detail

TextLayoutStrategyback to summary
public TextLayoutStrategy()

Constructs a layout strategy for paragraphs based upon java.awt.font.LineBreakMeasurer.

Method Detail

adjustRowback to summary
protected void adjustRow(FlowView fv, int rowIndex, int desiredSpan, int x)

Overrides javax.swing.text.FlowView.FlowStrategy.adjustRow.

Adjusts the given row if possible to fit within the layout span. Since all adjustments were already calculated by the LineBreakMeasurer, this is implemented to do nothing.

Parameters
rowIndex:int

the row to adjust to the current layout span.

desiredSpan:int

the current layout span >= 0

x:int

the location r starts at.

changedUpdateback to summary
public void changedUpdate(FlowView fv, DocumentEvent e, Rectangle alloc)

Overrides javax.swing.text.FlowView.FlowStrategy.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

alloc:Rectangle

the current allocation of the view inside of the insets.

See Also
View#changedUpdate
createViewback to summary
protected View createView(FlowView fv, int startOffset, int spanLeft, int rowIndex)

Overrides javax.swing.text.FlowView.FlowStrategy.createView.

Creates a unidirectional view that can be used to represent the current chunk. This can be either an entire view from the logical view, or a fragment of the view.

Parameters
fv:FlowView

the view holding the flow

startOffset:int

the start location for the view being created

spanLeft:int

the amount of span left to fill in the row

rowIndex:int

the row the view will be placed into

getLimitingOffsetback to summary
pack-priv int getLimitingOffset(View v, int startOffset, int spanLeft, boolean requireNextWord)

Calculate the limiting offset for the next view fragment. At most this would be the entire view (i.e. the limiting offset would be the end offset in that case). If the range contains a tab or a direction change, that will limit the offset to something less. This value is then fed to the LineBreakMeasurer as a limit to consider in addition to the remaining span.

Parameters
v:View

the logical view representing the starting offset.

startOffset:int

the model location to start at.

insertUpdateback to summary
public void insertUpdate(FlowView fv, DocumentEvent e, Rectangle alloc)

Overrides javax.swing.text.FlowView.FlowStrategy.insertUpdate.

Gives notification that something was inserted into the document in a location that the given flow view is responsible for. The strategy should update the appropriate changed region (which depends upon the strategy used for repair).

Parameters
e:DocumentEvent

the change information from the associated document

alloc:Rectangle

the current allocation of the view inside of the insets. This value will be null if the view has not yet been displayed.

See Also
View#insertUpdate
layoutback to summary
public void layout(FlowView fv)

Overrides javax.swing.text.FlowView.FlowStrategy.layout.

Does a full layout on the given View. This causes all of the rows (child views) to be rebuilt to match the given constraints for each row. This is called by FlowView.layout to update the child views in the flow.

Parameters
fv:FlowView

the view to reflow

layoutRowback to summary
protected int layoutRow(FlowView fv, int rowIndex, int p0)

Overrides javax.swing.text.FlowView.FlowStrategy.layoutRow.

Creates a row of views that will fit within the layout span of the row. This is implemented to execute the superclass functionality (which fills the row with child views or view fragments) and follow that with bidi reordering of the unidirectional view fragments.

Parameters
rowIndex:int

the row to fill in with views. This is assumed to be empty on entry.

p0:int

The current position in the children of this view element from which to start.

Returns:int

the position to start the next row

removeUpdateback to summary
public void removeUpdate(FlowView fv, DocumentEvent e, Rectangle alloc)

Overrides javax.swing.text.FlowView.FlowStrategy.removeUpdate.

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

Parameters
e:DocumentEvent

the change information from the associated document

alloc:Rectangle

the current allocation of the view inside of the insets.

See Also
View#removeUpdate
syncback to summary
pack-priv void sync(FlowView fv)

Synchronize the strategy with its FlowView. Allows the strategy to update its state to account for changes in that portion of the model represented by the FlowView. Also allows the strategy to update the FlowView in response to these changes.

javax.swing.text back to summary

pack-priv Class TextLayoutStrategy.AttributedSegment

extends Segment
implements AttributedCharacterIterator
Class Inheritance
All Implemented Interfaces
java.text.AttributedCharacterIterator, java.text.CharacterIterator, java.lang.Cloneable

Implementation of AttributedCharacterIterator that supports the GlyphView attributes for rendering the glyphs through a TextLayout.

Field Summary

Modifier and TypeField and Description
pack-priv static Set<AttributedCharacterIterator.Attribute>
private Object
pack-priv View
v

Inherited from javax.swing.text.Segment:
arraycopycountoffset

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public Set<AttributedCharacterIterator.Attribute>
getAllAttributeKeys()

Implements java.text.AttributedCharacterIterator.getAllAttributeKeys.

Returns the keys of all attributes defined on the iterator's text range.

public Object
getAttribute(AttributedCharacterIterator.Attribute
the key of the attribute whose value is requested.
attribute
)

Implements java.text.AttributedCharacterIterator.getAttribute.

Returns the value of the named attribute for the current character.

public Map<AttributedCharacterIterator.Attribute, Object>
getAttributes()

Implements java.text.AttributedCharacterIterator.getAttributes.

Returns a map with the attributes defined on the current character.

pack-priv Font
getFont(int childIndex)

Get the font at the given child index.

pack-priv int

Returns:

the location in model coordinates. This is not the same as the Segment coordinates.
getFontBoundary
(int childIndex, int dir)

Get a boundary position for the font.

public int
getRunLimit()

Implements java.text.AttributedCharacterIterator.getRunLimit.

Returns the index of the first character following the run with respect to all attributes containing the current character.

public int
getRunLimit(AttributedCharacterIterator.Attribute attribute)

Implements java.text.AttributedCharacterIterator.getRunLimit.

Returns the index of the first character following the run with respect to the given attribute containing the current character.

public int
getRunLimit(Set<? extends AttributedCharacterIterator.Attribute> attributes)

Implements java.text.AttributedCharacterIterator.getRunLimit.

Returns the index of the first character following the run with respect to the given attributes containing the current character.

public int
getRunStart()

Implements java.text.AttributedCharacterIterator.getRunStart.

Returns the index of the first character of the run with respect to all attributes containing the current character.

public int
getRunStart(AttributedCharacterIterator.Attribute attribute)

Implements java.text.AttributedCharacterIterator.getRunStart.

Returns the index of the first character of the run with respect to the given attribute containing the current character.

public int
getRunStart(Set<? extends AttributedCharacterIterator.Attribute> attributes)

Implements java.text.AttributedCharacterIterator.getRunStart.

Returns the index of the first character of the run with respect to the given attributes containing the current character.

pack-priv View
private void
setShaper(Object shaper)

pack-priv void
pack-priv int
toIteratorIndex(int pos)

pack-priv int
toModelPosition(int index)

Inherited from javax.swing.text.Segment:
charAtclonecurrentfirstgetBeginIndexgetEndIndexgetIndexisPartialReturnlastlengthnextprevioussetIndexsetPartialReturnsubSequencetoString

Field Detail

keysback to summary
pack-priv static Set<AttributedCharacterIterator.Attribute> keys
shaperback to summary
private Object shaper
vback to summary
pack-priv View v

Constructor Detail

AttributedSegmentback to summary
pack-priv AttributedSegment()

Method Detail

getAllAttributeKeysback to summary
public Set<AttributedCharacterIterator.Attribute> getAllAttributeKeys()

Implements java.text.AttributedCharacterIterator.getAllAttributeKeys.

Returns the keys of all attributes defined on the iterator's text range. The set is empty if no attributes are defined.

getAttributeback to summary
public Object getAttribute(AttributedCharacterIterator.Attribute attribute)

Implements java.text.AttributedCharacterIterator.getAttribute.

Returns the value of the named attribute for the current character. Returns null if the attribute is not defined.

Parameters
attribute:AttributedCharacterIterator.Attribute

the key of the attribute whose value is requested.

getAttributesback to summary
public Map<AttributedCharacterIterator.Attribute, Object> getAttributes()

Implements java.text.AttributedCharacterIterator.getAttributes.

Returns a map with the attributes defined on the current character.

getFontback to summary
pack-priv Font getFont(int childIndex)

Get the font at the given child index.

getFontBoundaryback to summary
pack-priv int getFontBoundary(int childIndex, int dir)

Get a boundary position for the font. This is implemented to assume that two fonts are equal if their references are equal (i.e. that the font came from a cache).

Returns:int

the location in model coordinates. This is not the same as the Segment coordinates.

getRunLimitback to summary
public int getRunLimit()

Implements java.text.AttributedCharacterIterator.getRunLimit.

Returns the index of the first character following the run with respect to all attributes containing the current character.

getRunLimitback to summary
public int getRunLimit(AttributedCharacterIterator.Attribute attribute)

Implements java.text.AttributedCharacterIterator.getRunLimit.

Returns the index of the first character following the run with respect to the given attribute containing the current character.

getRunLimitback to summary
public int getRunLimit(Set<? extends AttributedCharacterIterator.Attribute> attributes)

Implements java.text.AttributedCharacterIterator.getRunLimit.

Returns the index of the first character following the run with respect to the given attributes containing the current character.

getRunStartback to summary
public int getRunStart()

Implements java.text.AttributedCharacterIterator.getRunStart.

Returns the index of the first character of the run with respect to all attributes containing the current character.

getRunStartback to summary
public int getRunStart(AttributedCharacterIterator.Attribute attribute)

Implements java.text.AttributedCharacterIterator.getRunStart.

Returns the index of the first character of the run with respect to the given attribute containing the current character.

getRunStartback to summary
public int getRunStart(Set<? extends AttributedCharacterIterator.Attribute> attributes)

Implements java.text.AttributedCharacterIterator.getRunStart.

Returns the index of the first character of the run with respect to the given attributes containing the current character.

getViewback to summary
pack-priv View getView()
setShaperback to summary
private void setShaper(Object shaper)
setViewback to summary
pack-priv void setView(View v)
toIteratorIndexback to summary
pack-priv int toIteratorIndex(int pos)
toModelPositionback to summary
pack-priv int toModelPosition(int index)