APIdia Launch Partner
Top Description Fields Constructors Methods
sun.font

pack-priv final Class ExtendedTextSourceLabel

extends Object
implements TextLineComponent, Label
Class Inheritance
All Implemented Interfaces
sun.font.Decoration.Label, sun.font.TextLineComponent
Imports
java.awt.Font, .Graphics2D, .Rectangle, .Shape, java.awt.font.FontRenderContext, .GlyphJustificationInfo, .GlyphMetrics, .LineMetrics, .TextAttribute, java.awt.geom.AffineTransform, .Point2D, .Rectangle2D, java.util.Map

A label. Visual bounds is a rect that encompasses the entire rendered area. Logical bounds is a rect that defines how to position this next to other objects. Align bounds is a rect that defines how to align this to margins. it generally allows some overhang that logical bounds would prevent.

Field Summary

Modifier and TypeField and Description
private Rectangle2D
private final float
private static final int
private static final int
private final AffineTransform
private float[]
private final CoreMetrics
private static final boolean
private final Decoration
private final Font
private StandardGlyphVector
private Rectangle2D
private Rectangle2D
private static final int
private static final int
private static final int
private final TextSource
private Rectangle2D
private static final int
private static final int
private static final int
private static final int

Constructor Summary

AccessConstructor and Description
public
ExtendedTextSourceLabel(TextSource source, Decoration decorator)

Create from a TextSource.

Method Summary

Modifier and TypeMethod and Description
public TextLineComponent
applyJustificationDeltas(float[] deltas, int deltaStart, boolean[] flags)

Implements sun.font.TextLineComponent.applyJustificationDeltas.

Apply deltas to the data in this component, starting at offset deltaStart, and return the new component.

public boolean
caretAtOffsetIsValid(int offset)

Implements sun.font.TextLineComponent.caretAtOffsetIsValid.

Return whether a caret can exist on the leading edge of the character at offset.

protected Rectangle2D
createAlignBounds()

Like createLogicalBounds except ignore leading and logically trailing white space.

protected float[]
protected StandardGlyphVector
public Rectangle2D
protected Rectangle2D
createLogicalBounds()

The logical bounds extends from the origin of the glyphvector to the position at which a following glyphvector's origin should be placed.

public void
draw(Graphics2D g, float x, float y)

Implements sun.font.TextLineComponent.draw.

Render the label at x, y in the graphics.

public void
draw(Graphics2D g)

A convenience method that renders the label at 0, 0.

public float
public float
getAdvanceBetween(int start, int limit)

Implements sun.font.TextLineComponent.getAdvanceBetween.

Return the accumulated advances of all characters between logicalStart and logicalLimit.

public Rectangle2D
getAlignBounds(float x, float y)

Return a rectangle that corresponds to the alignment bounds of the text when this label is rendered at x, y.

public Rectangle2D
getAlignBounds()

A convenience method that returns the align bounds when rendered at 0, 0.

public AffineTransform
public float
getCharAdvance(int index)

Implements sun.font.TextLineComponent.getCharAdvance.

Return the advance of the character at the given logical index.

private float[]
public Rectangle2D
getCharVisualBounds(int logicalIndex)

Implements sun.font.TextLineComponent.getCharVisualBounds.

A convenience overload of getCharVisualBounds that defaults the label origin to 0, 0.

public Rectangle2D
getCharVisualBounds(int index, float x, float y)

Return the visual bounds of the character at the given logical index.

public float
getCharX(int index)

Implements sun.font.TextLineComponent.getCharX.

Return the x location of the character at the given logical index.

public float
getCharY(int index)

Implements sun.font.TextLineComponent.getCharY.

Return the y location of the character at the given logical index.

public CoreMetrics
getCoreMetrics()

Implements sun.font.TextLineComponent.getCoreMetrics, sun.font.Decoration.Label.getCoreMetrics.

Return the line metrics for all text in this label.

private StandardGlyphVector
public Rectangle2D
getItalicBounds(float x, float y)

Return a rectangle that corresponds to the logical bounds of the text, adjusted to angle the leading and trailing edges by the italic angle.

public Rectangle2D
getItalicBounds()

Implements sun.font.TextLineComponent.getItalicBounds.

A convenience method that returns the italic bounds when rendered at 0, 0.

public void
getJustificationInfos(GlyphJustificationInfo[] infos, int infoStart, int charStart, int charLimit)

Implements sun.font.TextLineComponent.getJustificationInfos.

Return GlyphJustificationInfo objects for the characters between charStart and charLimit, starting at offset infoStart.

public int
getLineBreakIndex(int start, float width)

Implements sun.font.TextLineComponent.getLineBreakIndex.

Return the logical index of the character, starting with the character at logicalStart, whose accumulated advance exceeds width.

public Rectangle2D
getLogicalBounds(float x, float y)

Return a rectangle that corresponds to the logical bounds of the text when this label is rendered at x, y.

public Rectangle2D
getLogicalBounds()

Implements sun.font.TextLineComponent.getLogicalBounds, sun.font.Decoration.Label.getLogicalBounds.

A convenience method that returns the logical bounds when rendered at 0, 0.

public int
getNumCharacters()

Implements sun.font.TextLineComponent.getNumCharacters.

Return the number of characters represented by this label.

public int
getNumJustificationInfos()

Implements sun.font.TextLineComponent.getNumJustificationInfos.

Return the number of justification records this uses.

public Shape
getOutline(float x, float y)

Implements sun.font.TextLineComponent.getOutline.

Return an outline of the characters in the label when rendered at x, y.

public Shape
getOutline()

A convenience method that returns the outline when rendered at 0, 0.

public Rectangle
public TextLineComponent
getSubset(int start, int limit, int dir)

Implements sun.font.TextLineComponent.getSubset.

Return a TextLineComponent for the characters in the range start, limit.

public Rectangle2D
getVisualBounds(float x, float y)

Return a rectangle that surrounds the text outline when this label is rendered at x, y.

public Rectangle2D
getVisualBounds()

Implements sun.font.TextLineComponent.getVisualBounds.

A convenience method that returns the visual bounds when rendered at 0, 0.

public void
public Rectangle2D
public Shape
public Rectangle2D
public boolean
protected int
l2v(int index)

Map logical character index to visual character index.

public int
logicalToVisual(int logicalIndex)

Return the visual index of the character at the given logical index.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

protected int
v2l(int index)

Map visual character index to logical character index.

private void
validate(int index)

public int
visualToLogical(int visualIndex)

Return the logical index of the character at the given visual index.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

abback to summary
private Rectangle2D ab
advTrackingback to summary
private final float advTracking
advxback to summary
private static final int advx
advyback to summary
private static final int advy
baseTXback to summary
private final AffineTransform baseTX
charinfoback to summary
private float[] charinfo
cmback to summary
private final CoreMetrics cm
DEBUGback to summary
private static final boolean DEBUG
decoratorback to summary
private final Decoration decorator
fontback to summary
private final Font font
gvback to summary
private StandardGlyphVector gv
ibback to summary
private Rectangle2D ib
lbback to summary
private Rectangle2D lb
numvalsback to summary
private static final int numvals
posxback to summary
private static final int posx
posyback to summary
private static final int posy
sourceback to summary
private final TextSource source
vbback to summary
private Rectangle2D vb
vishback to summary
private static final int vish
viswback to summary
private static final int visw
visxback to summary
private static final int visx
visyback to summary
private static final int visy

Constructor Detail

ExtendedTextSourceLabelback to summary
public ExtendedTextSourceLabel(TextSource source, Decoration decorator)

Create from a TextSource.

Method Detail

applyJustificationDeltasback to summary
public TextLineComponent applyJustificationDeltas(float[] deltas, int deltaStart, boolean[] flags)

Implements sun.font.TextLineComponent.applyJustificationDeltas.

Apply deltas to the data in this component, starting at offset deltaStart, and return the new component. There are two floats for each justification info, for a total of 2 * getNumJustificationInfos. The first delta is the left adjustment, the second is the right adjustment.

If flags[0] is true on entry, rejustification is allowed. If the new component requires rejustification (ligatures were formed or split), flags[0] will be set on exit.

caretAtOffsetIsValidback to summary
public boolean caretAtOffsetIsValid(int offset)

Implements sun.font.TextLineComponent.caretAtOffsetIsValid.

Return whether a caret can exist on the leading edge of the character at offset. If the character is part of a ligature (for example) a caret may not be appropriate at offset.

createAlignBoundsback to summary
protected Rectangle2D createAlignBounds()

Like createLogicalBounds except ignore leading and logically trailing white space. this assumes logically trailing whitespace is also visually trailing. Whitespace is anything that has a zero visual width, regardless of its advance.

We make the same simplifying assumptions as in createLogicalBounds, namely that we can rely on the charinfo to shield us from any glyph positioning oddities in the font that place the glyph for a character at other than the pos + advance of the character to its left. So we no longer need to skip chars with zero advance, as their bounds (right and left) are already correct.

createCharinfoback to summary
protected float[] createCharinfo()
createGVback to summary
protected StandardGlyphVector createGV()
createItalicBoundsback to summary
public Rectangle2D createItalicBounds()
createLogicalBoundsback to summary
protected Rectangle2D createLogicalBounds()

The logical bounds extends from the origin of the glyphvector to the position at which a following glyphvector's origin should be placed. We always assume glyph vectors are rendered from left to right, so the origin is always to the left.

On a left-to-right run, combining marks and 'ligatured away' characters are to the right of their base characters. The charinfo array will record the character positions for these 'missing' characters as being at the origin+advance of the base glyph, with zero advance. (This is not necessarily the same as the glyph position, for example, an umlaut glyph may have a position to the left of this point, it depends on whether the font was designed so that such glyphs overhang to the left of their origin, or whether it presumes some kind of kerning to position the glyphs). Anyway, the left of the bounds is the origin of the first logical (leftmost) character, and the right is the origin + advance of the last logical (rightmost) character.

On a right-to-left run, these special characters are to the left of their base characters. Again, since 'glyph position' has been abstracted away, we can use the origin of the leftmost character, and the origin + advance of the rightmost character.

On a mixed run (hindi) we can't rely on the first logical character being the leftmost character. However we can again rely on the leftmost character origin and the rightmost character + advance.

drawback to summary
public void draw(Graphics2D g, float x, float y)

Implements sun.font.TextLineComponent.draw.

Render the label at x, y in the graphics.

drawback to summary
public void draw(Graphics2D g)

A convenience method that renders the label at 0, 0.

getAdvanceback to summary
public float getAdvance()

Implements sun.font.TextLineComponent.getAdvance.

getAdvanceBetweenback to summary
public float getAdvanceBetween(int start, int limit)

Implements sun.font.TextLineComponent.getAdvanceBetween.

Return the accumulated advances of all characters between logicalStart and logicalLimit.

getAlignBoundsback to summary
public Rectangle2D getAlignBounds(float x, float y)

Return a rectangle that corresponds to the alignment bounds of the text when this label is rendered at x, y. This rectangle is used when positioning text next to a margin. It differs from the logical bounds in that it does not include leading or trailing whitespace.

getAlignBoundsback to summary
public Rectangle2D getAlignBounds()

A convenience method that returns the align bounds when rendered at 0, 0.

getBaselineTransformback to summary
public AffineTransform getBaselineTransform()

Implements sun.font.TextLineComponent.getBaselineTransform.

getCharAdvanceback to summary
public float getCharAdvance(int index)

Implements sun.font.TextLineComponent.getCharAdvance.

Return the advance of the character at the given logical index.

getCharinfoback to summary
private float[] getCharinfo()
getCharVisualBoundsback to summary
public Rectangle2D getCharVisualBounds(int logicalIndex)

Implements sun.font.TextLineComponent.getCharVisualBounds.

A convenience overload of getCharVisualBounds that defaults the label origin to 0, 0.

getCharVisualBoundsback to summary
public Rectangle2D getCharVisualBounds(int index, float x, float y)

Return the visual bounds of the character at the given logical index. This bounds encloses all the pixels of the character when the label is rendered at x, y.

getCharXback to summary
public float getCharX(int index)

Implements sun.font.TextLineComponent.getCharX.

Return the x location of the character at the given logical index.

getCharYback to summary
public float getCharY(int index)

Implements sun.font.TextLineComponent.getCharY.

Return the y location of the character at the given logical index.

getCoreMetricsback to summary
public CoreMetrics getCoreMetrics()

Implements sun.font.TextLineComponent.getCoreMetrics, sun.font.Decoration.Label.getCoreMetrics.

Return the line metrics for all text in this label.

getGVback to summary
private StandardGlyphVector getGV()
getItalicBoundsback to summary
public Rectangle2D getItalicBounds(float x, float y)

Return a rectangle that corresponds to the logical bounds of the text, adjusted to angle the leading and trailing edges by the italic angle.

getItalicBoundsback to summary
public Rectangle2D getItalicBounds()

Implements sun.font.TextLineComponent.getItalicBounds.

A convenience method that returns the italic bounds when rendered at 0, 0.

getJustificationInfosback to summary
public void getJustificationInfos(GlyphJustificationInfo[] infos, int infoStart, int charStart, int charLimit)

Implements sun.font.TextLineComponent.getJustificationInfos.

Return GlyphJustificationInfo objects for the characters between charStart and charLimit, starting at offset infoStart. Infos will be in visual order. All positions between infoStart and getNumJustificationInfos will be set. If a position corresponds to a character outside the provided range, it is set to null.

getLineBreakIndexback to summary
public int getLineBreakIndex(int start, float width)

Implements sun.font.TextLineComponent.getLineBreakIndex.

Return the logical index of the character, starting with the character at logicalStart, whose accumulated advance exceeds width. If the advances of all characters do not exceed width, return getNumCharacters. If width is less than zero, return logicalStart - 1.

getLogicalBoundsback to summary
public Rectangle2D getLogicalBounds(float x, float y)

Return a rectangle that corresponds to the logical bounds of the text when this label is rendered at x, y. This rectangle is used when positioning text next to other text.

getLogicalBoundsback to summary
public Rectangle2D getLogicalBounds()

Implements sun.font.TextLineComponent.getLogicalBounds, sun.font.Decoration.Label.getLogicalBounds.

A convenience method that returns the logical bounds when rendered at 0, 0.

getNumCharactersback to summary
public int getNumCharacters()

Implements sun.font.TextLineComponent.getNumCharacters.

Return the number of characters represented by this label.

getNumJustificationInfosback to summary
public int getNumJustificationInfos()

Implements sun.font.TextLineComponent.getNumJustificationInfos.

Return the number of justification records this uses.

getOutlineback to summary
public Shape getOutline(float x, float y)

Implements sun.font.TextLineComponent.getOutline.

Return an outline of the characters in the label when rendered at x, y.

getOutlineback to summary
public Shape getOutline()

A convenience method that returns the outline when rendered at 0, 0.

getPixelBoundsback to summary
public Rectangle getPixelBounds(FontRenderContext frc, float x, float y)

Implements sun.font.TextLineComponent.getPixelBounds.

getSubsetback to summary
public TextLineComponent getSubset(int start, int limit, int dir)

Implements sun.font.TextLineComponent.getSubset.

Doc from sun.font.TextLineComponent.getSubset.

Return a TextLineComponent for the characters in the range start, limit. The range is relative to this TextLineComponent (ie, the first character is at 0).

getVisualBoundsback to summary
public Rectangle2D getVisualBounds(float x, float y)

Return a rectangle that surrounds the text outline when this label is rendered at x, y.

getVisualBoundsback to summary
public Rectangle2D getVisualBounds()

Implements sun.font.TextLineComponent.getVisualBounds.

A convenience method that returns the visual bounds when rendered at 0, 0.

handleDrawback to summary
public void handleDraw(Graphics2D g, float x, float y)

Implements sun.font.Decoration.Label.handleDraw.

handleGetCharVisualBoundsback to summary
public Rectangle2D handleGetCharVisualBounds(int index)

Implements sun.font.Decoration.Label.handleGetCharVisualBounds.

handleGetOutlineback to summary
public Shape handleGetOutline(float x, float y)

Implements sun.font.Decoration.Label.handleGetOutline.

handleGetVisualBoundsback to summary
public Rectangle2D handleGetVisualBounds()

Implements sun.font.Decoration.Label.handleGetVisualBounds.

isSimpleback to summary
public boolean isSimple()

Implements sun.font.TextLineComponent.isSimple.

l2vback to summary
protected int l2v(int index)

Map logical character index to visual character index.

This ignores hindi reordering.

See Also
createCharinfo
logicalToVisualback to summary
public int logicalToVisual(int logicalIndex)

Return the visual index of the character at the given logical index.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

v2lback to summary
protected int v2l(int index)

Map visual character index to logical character index.

This ignores hindi reordering.

See Also
createCharinfo
validateback to summary
private void validate(int index)
visualToLogicalback to summary
public int visualToLogical(int visualIndex)

Return the logical index of the character at the given visual index.