java.awt.font
Class TextLine

java.lang.Object
  extended byjava.awt.font.TextLine

final class TextLine
extends Object


Nested Class Summary
private static class TextLine.Function
           
(package private) static class TextLine.TextLineMetrics
           
 
Field Summary
private  float[] fBaselineOffsets
           
private  byte[] fCharLevels
           
private  int[] fCharLogicalOrder
           
private  char[] fChars
           
private  int fCharsLimit
           
private  int fCharsStart
           
private  int[] fCharVisualOrder
           
private  sun.awt.font.TextLineComponent[] fComponents
           
private  int[] fComponentVisualOrder
           
private static TextLine.Function fgAdvanceF
           
private static TextLine.Function fgXPositionF
           
private static TextLine.Function fgYPositionF
           
private  boolean fIsDirectionLTR
           
private  TextLine.TextLineMetrics fMetrics
           
 
Constructor Summary
TextLine(sun.awt.font.TextLineComponent[] components, float[] baselineOffsets, char[] chars, int charsStart, int charsLimit, int[] charLogicalOrder, byte[] charLevels, boolean isDirectionLTR)
           
 
Method Summary
(package private) static boolean advanceToFirstFont(AttributedCharacterIterator aci)
          When this returns, the ACI's current position will be at the start of the first run which does NOT contain a GraphicAttribute.
private  float applyFunctionAtIndex(int logicalIndex, TextLine.Function f)
           
 boolean caretAtOffsetIsValid(int offset)
           
 int characterCount()
           
private  void checkCtorArgs()
           
private static int[] computeComponentOrder(sun.awt.font.TextLineComponent[] components, int[] charsLtoV)
          Compute the components order from the given components array and logical-to-visual character mapping.
static sun.awt.font.TextLineComponent[] createComponentsOnRun(int runStart, int runLimit, char[] chars, int[] charsLtoV, byte[] levels, sun.awt.font.TextLabelFactory factory, Font font, LineMetrics lm, FontRenderContext frc, sun.awt.font.Decoration decorator, sun.awt.font.TextLineComponent[] components, int numComponents)
          Returns an array in logical order of the TextLineComponents on the text in the given range, with the given attributes.
static TextLine createLineFromText(char[] chars, StyledParagraph styledParagraph, sun.awt.font.TextLabelFactory factory, boolean isDirectionLTR, float[] baselineOffsets)
          Create a TextLine from the Font and character data over the range.
 void draw(Graphics2D g2, float x, float y)
           
private static sun.awt.font.TextLineComponent[] expandArray(sun.awt.font.TextLineComponent[] orig)
           
static TextLine fastCreateTextLine(FontRenderContext frc, char[] chars, Font font, LineMetrics lm, Map attributes)
          Create a TextLine from the text.
private static int firstVisualChunk(int[] order, byte[] direction, int start, int limit)
           
static float getAdvanceBetween(sun.awt.font.TextLineComponent[] components, int start, int limit)
           
 Rectangle2D getBounds()
           
 float getCharAdvance(int logicalIndex)
           
 float getCharAngle(int logicalIndex)
           
 float getCharAscent(int logicalIndex)
           
 Rectangle2D getCharBounds(int logicalIndex)
           
 float getCharDescent(int logicalIndex)
           
 byte getCharLevel(int logicalIndex)
           
 float getCharLinePosition(int logicalIndex)
           
 int getCharType(int logicalIndex)
           
 float getCharXPosition(int logicalIndex)
           
 float getCharYPosition(int logicalIndex)
           
static sun.awt.font.TextLineComponent[] getComponents(StyledParagraph styledParagraph, char[] chars, int textStart, int textLimit, int[] charsLtoV, byte[] levels, sun.awt.font.TextLabelFactory factory)
          Returns an array (in logical order) of the TextLineComponents representing the text.
private  float getComponentShift(int index)
           
(package private) static Font getFontAtCurrentPos(AttributedCharacterIterator aci)
           
 TextLine getJustifiedLine(float justificationWidth, float justifyRatio, int justStart, int justLimit)
           
(package private) static float getJustifyRatio(Map attributes)
          Utility method for getting justification ratio from attributes.
private  LineMetrics getLineMetricsAt(int logicalIndex)
           
 TextLine.TextLineMetrics getMetrics()
           
(package private) static float[] getNormalizedOffsets(float[] baselineOffsets, byte baseline)
           
 Shape getOutline(AffineTransform tx)
           
 int hashCode()
          Returns a hash code value for the object.
 boolean isCharLTR(int logicalIndex)
           
 boolean isCharSpace(int logicalIndex)
           
 boolean isCharWhitespace(int logicalIndex)
           
 boolean isDirectionLTR()
           
 int logicalToVisual(int logicalIndex)
           
static TextLine standardCreateTextLine(FontRenderContext frc, AttributedCharacterIterator text, char[] chars, float[] baselineOffsets)
          Create a TextLine from the text.
 String toString()
          Returns a string representation of the object.
 int visualToLogical(int visualIndex)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

fComponents

private sun.awt.font.TextLineComponent[] fComponents

fBaselineOffsets

private float[] fBaselineOffsets

fComponentVisualOrder

private int[] fComponentVisualOrder

fChars

private char[] fChars

fCharsStart

private int fCharsStart

fCharsLimit

private int fCharsLimit

fCharVisualOrder

private int[] fCharVisualOrder

fCharLogicalOrder

private int[] fCharLogicalOrder

fCharLevels

private byte[] fCharLevels

fIsDirectionLTR

private boolean fIsDirectionLTR

fMetrics

private TextLine.TextLineMetrics fMetrics

fgAdvanceF

private static TextLine.Function fgAdvanceF

fgXPositionF

private static TextLine.Function fgXPositionF

fgYPositionF

private static TextLine.Function fgYPositionF
Constructor Detail

TextLine

public TextLine(sun.awt.font.TextLineComponent[] components,
                float[] baselineOffsets,
                char[] chars,
                int charsStart,
                int charsLimit,
                int[] charLogicalOrder,
                byte[] charLevels,
                boolean isDirectionLTR)
Method Detail

checkCtorArgs

private void checkCtorArgs()

characterCount

public int characterCount()

isDirectionLTR

public boolean isDirectionLTR()

getMetrics

public TextLine.TextLineMetrics getMetrics()

visualToLogical

public int visualToLogical(int visualIndex)

logicalToVisual

public int logicalToVisual(int logicalIndex)

getCharLevel

public byte getCharLevel(int logicalIndex)

isCharLTR

public boolean isCharLTR(int logicalIndex)

getCharType

public int getCharType(int logicalIndex)

isCharSpace

public boolean isCharSpace(int logicalIndex)

isCharWhitespace

public boolean isCharWhitespace(int logicalIndex)

getCharAngle

public float getCharAngle(int logicalIndex)

getLineMetricsAt

private LineMetrics getLineMetricsAt(int logicalIndex)

getCharAscent

public float getCharAscent(int logicalIndex)

getCharDescent

public float getCharDescent(int logicalIndex)

applyFunctionAtIndex

private float applyFunctionAtIndex(int logicalIndex,
                                   TextLine.Function f)

getCharAdvance

public float getCharAdvance(int logicalIndex)

getCharXPosition

public float getCharXPosition(int logicalIndex)

getCharYPosition

public float getCharYPosition(int logicalIndex)

getCharLinePosition

public float getCharLinePosition(int logicalIndex)

caretAtOffsetIsValid

public boolean caretAtOffsetIsValid(int offset)

getCharBounds

public Rectangle2D getCharBounds(int logicalIndex)

getComponentShift

private float getComponentShift(int index)

draw

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

getBounds

public Rectangle2D getBounds()

getOutline

public Shape getOutline(AffineTransform tx)

hashCode

public int hashCode()
Description copied from class: Object
Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable.

The general contract of hashCode is:

As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)

Overrides:
hashCode in class Object
Returns:
a hash code value for this object.
See Also:
Object.equals(java.lang.Object), Hashtable

toString

public String toString()
Description copied from class: Object
Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Overrides:
toString in class Object
Returns:
a string representation of the object.

fastCreateTextLine

public static TextLine fastCreateTextLine(FontRenderContext frc,
                                          char[] chars,
                                          Font font,
                                          LineMetrics lm,
                                          Map attributes)
Create a TextLine from the text. The Font must be able to display all of the text. attributes==null is equivalent to using an empty Map for attributes


expandArray

private static sun.awt.font.TextLineComponent[] expandArray(sun.awt.font.TextLineComponent[] orig)

createComponentsOnRun

public static sun.awt.font.TextLineComponent[] createComponentsOnRun(int runStart,
                                                                     int runLimit,
                                                                     char[] chars,
                                                                     int[] charsLtoV,
                                                                     byte[] levels,
                                                                     sun.awt.font.TextLabelFactory factory,
                                                                     Font font,
                                                                     LineMetrics lm,
                                                                     FontRenderContext frc,
                                                                     sun.awt.font.Decoration decorator,
                                                                     sun.awt.font.TextLineComponent[] components,
                                                                     int numComponents)
Returns an array in logical order of the TextLineComponents on the text in the given range, with the given attributes.


getComponents

public static sun.awt.font.TextLineComponent[] getComponents(StyledParagraph styledParagraph,
                                                             char[] chars,
                                                             int textStart,
                                                             int textLimit,
                                                             int[] charsLtoV,
                                                             byte[] levels,
                                                             sun.awt.font.TextLabelFactory factory)
Returns an array (in logical order) of the TextLineComponents representing the text. The components are both logically and visually contiguous.


createLineFromText

public static TextLine createLineFromText(char[] chars,
                                          StyledParagraph styledParagraph,
                                          sun.awt.font.TextLabelFactory factory,
                                          boolean isDirectionLTR,
                                          float[] baselineOffsets)
Create a TextLine from the Font and character data over the range. The range is relative to both the StyledParagraph and the character array.


computeComponentOrder

private static int[] computeComponentOrder(sun.awt.font.TextLineComponent[] components,
                                           int[] charsLtoV)
Compute the components order from the given components array and logical-to-visual character mapping. May return null if canonical.


standardCreateTextLine

public static TextLine standardCreateTextLine(FontRenderContext frc,
                                              AttributedCharacterIterator text,
                                              char[] chars,
                                              float[] baselineOffsets)
Create a TextLine from the text. chars is just the text in the iterator.


advanceToFirstFont

static boolean advanceToFirstFont(AttributedCharacterIterator aci)
When this returns, the ACI's current position will be at the start of the first run which does NOT contain a GraphicAttribute. If no such run exists the ACI's position will be at the end, and this method will return false.


getNormalizedOffsets

static float[] getNormalizedOffsets(float[] baselineOffsets,
                                    byte baseline)

getFontAtCurrentPos

static Font getFontAtCurrentPos(AttributedCharacterIterator aci)

getJustifyRatio

static float getJustifyRatio(Map attributes)
Utility method for getting justification ratio from attributes.


firstVisualChunk

private static int firstVisualChunk(int[] order,
                                    byte[] direction,
                                    int start,
                                    int limit)

getJustifiedLine

public TextLine getJustifiedLine(float justificationWidth,
                                 float justifyRatio,
                                 int justStart,
                                 int justLimit)

getAdvanceBetween

public static float getAdvanceBetween(sun.awt.font.TextLineComponent[] components,
                                      int start,
                                      int limit)