| 
Java Platform 1.2 | 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--java.awt.font.TextLayout
TextLayout is an immutable graphical representation of styled 
 character data.
 
It provides the following capabilities:
 A TextLayout object can be rendered using 
 its draw method.
 
 TextLayout can be constructed either directly or through 
 the use of a LineBreakMeasurer.  When constructed directly, the 
 source text represents a single paragraph.  LineBreakMeasurer
 allows styled text to be broken into lines that fit within a particular 
 width.  See the LineBreakMeasurer documentation for more
 information.
 
 TextLayout construction logically proceeds as follows:
 
TextAttribute.FONT is present, otherwise by computing
 a default font using the attributes that have been defined
 
 All graphical information returned from a TextLayout 
 object's methods is relative to the origin of the 
 TextLayout, which is the intersection of the
 TextLayout object's baseline with its left edge.  Also, 
 coordinates passed into a TextLayout object's methods 
 are assumed to be relative to the TextLayout object's
 origin.  Clients usually need to translate between a 
 TextLayout object's coordinate system and the coordinate
 system in another object (such as a 
 Graphics object).
 
 TextLayout objects are constructed from styled text, 
 but they do not retain a reference to their source text.  Thus, 
 changes in the text previously used to generate a TextLayout
 do not affect the TextLayout.
 
 Three methods on a TextLayout object 
 (getNextRightHit, getNextLeftHit, and 
 hitTestChar) return instances of TextHitInfo.  
 The offsets contained in these TextHitInfo objects
 are relative to the start of the TextLayout, not 
 to the text used to create the TextLayout.  Similarly, 
 TextLayout methods that accept TextHitInfo
 instances as parameters expect the TextHitInfo object's 
 offsets to be relative to the TextLayout, not to any 
 underlying text storage model.
 
Examples:
 Constructing and drawing a TextLayout and its bounding 
 rectangle:
 
   Graphics2D g = ...;
   Point2D loc = ...;
   Font font = Font.getFont("Helvetica-bold-italic");
   FontRenderContext frc = g.getFontRenderContext();
   TextLayout layout = new TextLayout("This is a string", font, frc);
   layout.draw(g, loc.getX(), loc.getY());
   Rectangle2D bounds = layout.getBounds();
   bounds.setRect(bounds.getX()+loc.getX(),
                  bounds.getY()+loc.getY(),
                  bounds.getWidth(),
                  bounds.getHeight())
   g.draw(bounds);
 
 
 
 Hit-testing a TextLayout (determining which character is at
 a particular graphical location):
 
   Point2D click = ...;
   TextHitInfo hit = layout.hitTestChar(
                         (float) (click.getX() - loc.getX()),
                         (float) (click.getY() - loc.getY()));
 
 
 
 Responding to a right-arrow key press:
  
 Drawing a selection range corresponding to a substring in the source text.
 The selected area may not be visually contiguous:
  
 Drawing a visually contiguous selection range.  The selection range may
 correspond to more than one substring in the source text.  The ranges of
 the corresponding source text substrings can be obtained with
  
 
 
 The  
 All the text is styled using the provided attributes.
  
  
 The iterator must specify a single paragraph of text because an
 entire paragraph is required for the bidirectional
 algorithm. 
 If this  
 Some code may rely on immutablity of layouts.  Subclassers should not
 call this directly, but instead should call getJustifiedLayout, which
 will call this method on a clone of this layout, preserving
 the original. 
 The array is indexed by one of the values defined in 
  
 The leading is computed from the leading, descent, and baseline
 of all glyphvectors in the  
 This method is meant for informational use.  To display carets, it
 is better to use  
 If the selection includes the leftmost (topmost) position, the selection
 is extended to the left (top) of  
 Although the selection is always contiguous, the logically selected
 text can be discontiguous on lines with mixed-direction text.  The
 logical ranges of text selected can be retrieved using
  
 If the selection range includes the first logical character, the
 selection is extended to the portion of  
 The selection can be discontiguous on lines with mixed-direction text.
 Only those characters in the logical range between start and limit
 appear selected.  For example, consider the text 'ABCdef' where capital
 letters indicate right-to-left text, rendered on a right-to-left line,
 with a logical selection from 0 to 4 ('ABCd').  The text appears as
 follows, with bold standing in for the selection, and underlining for
 the extension:
 
   int insertionIndex = ...;
   TextHitInfo next = layout.getNextRightHit(insertionIndex);
   if (next != null) {
       // translate graphics to origin of layout on screen
       g.translate(loc.getX(), loc.getY());
       Shape[] carets = layout.getCaretShapes(next.getInsertionIndex());
       g.draw(carets[0]);
       if (carets[1] != null) {
           g.draw(carets[1]);
       }
   }
 
 
   // selStart, selLimit should be relative to the layout,
   // not to the source text
   int selStart = ..., selLimit = ...;
   Color selectionColor = ...;
   Shape selection = layout.getLogicalHighlightShape(selStart, selLimit);
   // selection may consist of disjoint areas
   // graphics is assumed to be tranlated to origin of layout
   g.setColor(selectionColor);
   g.fill(selection);
 
 getLogicalRangesForVisualSelection():
 
   TextHitInfo selStart = ..., selLimit = ...;
   Shape selection = layout.getVisualHighlightShape(selStart, selLimit);
   g.setColor(selectionColor);
   g.fill(selection);
   int[] ranges = getLogicalRangesForVisualSelection(selStart, selLimit);
   // ranges[0], ranges[1] is the first selection range,
   // ranges[2], ranges[3] is the second selection range, etc.
 
 
LineBreakMeasurer, 
TextAttribute, 
TextHitInfo
 
 
Inner Class Summary 
 
 
static classTextLayout.CaretPolicy
          Defines a policy for determining the strong caret location.
 
 
Field Summary 
 
 
static TextLayout.CaretPolicyDEFAULT_CARET_POLICY
          This CaretPolicy is used when a policy is not specified 
 by the client.
 
 
Constructor Summary 
 
TextLayout(AttributedCharacterIterator text,
           FontRenderContext frc)
          Constructs a TextLayout from an iterator over styled text.
 
TextLayout(String string,
           Font font,
           FontRenderContext frc)
          Constructs a TextLayout from a String
 and a Font.
 
TextLayout(String string,
           Map attributes,
           FontRenderContext frc)
          Constructs a TextLayout from a String
 and an attribute set.
 
 
Method Summary 
 
 
protected  Objectclone()
          Creates a copy of this TextLayout.
 
 
 voiddraw(Graphics2D g2,
     float x,
     float y)
          Renders this TextLayout at the specified location in 
 the specified Graphics2D context.
 
 
 booleanequals(Object obj)
          Returns true if the specified Object is a 
 TextLayout object and if the specified Object
 equals this TextLayout.
 
 
 booleanequals(TextLayout rhs)
          Returns true if the two layouts are equal.
 
 
 floatgetAdvance()
          Returns the advance of this TextLayout.
 
 
 floatgetAscent()
          Returns the ascent of this TextLayout.
 
 
 bytegetBaseline()
          Returns the baseline for this TextLayout.
 
 
 float[]getBaselineOffsets()
          Returns the offsets array for the baselines used for this 
 TextLayout.
 
 
 ShapegetBlackBoxBounds(int firstEndpoint,
                  int secondEndpoint)
          Returns the black box bounds of the characters in the specified range.
 
 
 Rectangle2DgetBounds()
          Returns the bounds of this TextLayout.
 
 
 float[]getCaretInfo(TextHitInfo hit)
          Returns information about the caret corresponding to hit.
 
 
 float[]getCaretInfo(TextHitInfo hit,
             Rectangle2D bounds)
          Returns information about the caret corresponding to hit.
 
 
 ShapegetCaretShape(TextHitInfo hit)
          Returns a Shape representing the caret at the specified
 hit inside the natural bounds of this TextLayout.
 
 
 ShapegetCaretShape(TextHitInfo hit,
              Rectangle2D bounds)
          Returns a Shape representing the caret at the specified 
 hit inside the specified bounds.
 
 
 Shape[]getCaretShapes(int offset)
          Returns two paths corresponding to the strong and weak caret.
 
 
 Shape[]getCaretShapes(int offset,
               Rectangle2D bounds)
          Returns two paths corresponding to the strong and weak caret.
 
 
 Shape[]getCaretShapes(int offset,
               Rectangle2D bounds,
               TextLayout.CaretPolicy policy)
          Returns two paths corresponding to the strong and weak caret.
 
 
 intgetCharacterCount()
          Returns the number of characters represented by this 
 TextLayout.
 
 
 bytegetCharacterLevel(int index)
          Returns the level of the character at index.
 
 
 floatgetDescent()
          Returns the descent of this TextLayout.
 
 
 TextLayoutgetJustifiedLayout(float justificationWidth)
          Creates a copy of this TextLayout justified to the 
 specified width.
 
 
 floatgetLeading()
          Returns the leading of the TextLayout.
 
 
 ShapegetLogicalHighlightShape(int firstEndpoint,
                         int secondEndpoint)
          Returns a Shape enclosing the logical selection in the
 specified range, extended to the natural bounds of this
 TextLayout.
 
 
 ShapegetLogicalHighlightShape(int firstEndpoint,
                         int secondEndpoint,
                         Rectangle2D bounds)
          Returns a Shape enclosing the logical selection in the
 specified range, extended to the specified bounds.
 
 
 int[]getLogicalRangesForVisualSelection(TextHitInfo firstEndpoint,
                                   TextHitInfo secondEndpoint)
          Returns the logical ranges of text corresponding to a visual selection.
 
 
 TextHitInfogetNextLeftHit(int offset)
          Returns the hit for the next caret to the left (top); if no
 such hit, returns null.
 
 
 TextHitInfogetNextLeftHit(int offset,
               TextLayout.CaretPolicy policy)
          Returns the hit for the next caret to the left (top); if no
 such hit, returns null.
 
 
 TextHitInfogetNextLeftHit(TextHitInfo hit)
          Returns the hit for the next caret to the left (top); if no such
 hit, returns null.
 
 
 TextHitInfogetNextRightHit(int offset)
          Returns the hit for the next caret to the right (bottom); if no
 such hit, returns null.
 
 
 TextHitInfogetNextRightHit(int offset,
                TextLayout.CaretPolicy policy)
          Returns the hit for the next caret to the right (bottom); if no
 such hit, returns null.
 
 
 TextHitInfogetNextRightHit(TextHitInfo hit)
          Returns the hit for the next caret to the right (bottom); if there 
 is no such hit, returns null.
 
 
 ShapegetOutline(AffineTransform tx)
          Returns a Shape representing the outline of this
 TextLayout.
 
 
 floatgetVisibleAdvance()
          Returns the advance of this TextLayout, minus trailing 
 whitespace.
 
 
 ShapegetVisualHighlightShape(TextHitInfo firstEndpoint,
                        TextHitInfo secondEndpoint)
          Returns a Shape enclosing the visual selection in the
 specified range, extended to the bounds.
 
 
 ShapegetVisualHighlightShape(TextHitInfo firstEndpoint,
                        TextHitInfo secondEndpoint,
                        Rectangle2D bounds)
          Returns a path enclosing the visual selection in the specified range,
 extended to bounds.
 
 
 TextHitInfogetVisualOtherHit(TextHitInfo hit)
          Returns the hit on the opposite side of the specified hit's caret.
 
 
protected  voidhandleJustify(float justificationWidth)
          Justify this layout.
 
 
 inthashCode()
          Returns the hash code of this TextLayout.
 
 
 TextHitInfohitTestChar(float x,
            float y)
          Returns a TextHitInfo corresponding to the 
 specified point.
 
 
 TextHitInfohitTestChar(float x,
            float y,
            Rectangle2D bounds)
          Returns a TextHitInfo corresponding to the 
 specified point.
 
 
 booleanisLeftToRight()
          Returns true if this TextLayout has 
 a left-to-right base direction or false if it has
 a right-to-left base direction.
 
 
 booleanisVertical()
          Returns true if this TextLayout is vertical.
 
 
 StringtoString()
          Returns debugging information for this TextLayout.
 
 
Methods inherited from class java.lang.Object 
 
finalize, 
getClass, 
notify, 
notifyAll, 
wait, 
wait, 
wait
 
Field Detail 
DEFAULT_CARET_POLICY
public static final TextLayout.CaretPolicy DEFAULT_CARET_POLICY
CaretPolicy is used when a policy is not specified 
 by the client.  With this policy, a hit on a character whose direction
 is the same as the line direction is stronger than a hit on a
 counterdirectional character.  If the characters' directions are
 the same, a hit on the leading edge of a character is stronger
 than a hit on the trailing edge of a character.
 
Constructor Detail 
TextLayout
public TextLayout(String string,
                  Font font,
                  FontRenderContext frc)
TextLayout from a String
 and a Font.  All the text is styled using the specified
 Font.
 String must specify a single paragraph of text, 
 because an entire paragraph is required for the bidirectional
 algorithm.
str - the text to displayfont - a Font used to style the textfrc - contains the information needed to correctly measure the
       text
TextLayout
public TextLayout(String string,
                  Map attributes,
                  FontRenderContext frc)
TextLayout from a String
 and an attribute set.
 string must specify a single paragraph of text because an
 entire paragraph is required for the bidirectional algorithm.
str - the text to displayattributes - the attributes used to style the textfrc - contains the information needed to correctly measure the
       text
TextLayout
public TextLayout(AttributedCharacterIterator text,
                  FontRenderContext frc)
TextLayout from an iterator over styled text.
 
text - the styled text to displayfrc - contains the information needed to correctly measure the
       text
 
Method Detail 
clone
protected Object clone()
getJustifiedLayout
public TextLayout getJustifiedLayout(float justificationWidth)
TextLayout justified to the 
 specified width.
 TextLayout has already been justified, an
 exception is thrown.  If this TextLayout object's 
 justification ratio is zero, a TextLayout identical 
 to this TextLayout is returned.
justificationWidth - the width to use when justifying the line.
 For best results, it should not be too different from the current
 advance of the line.TextLayout justified to the specified width.
handleJustify
protected void handleJustify(float justificationWidth)
justificationWidth - the width to use when justifying the line.
 For best results, it should not be too different from the current
 advance of the line.getJustifiedLayout(float)
getBaseline
public byte getBaseline()
TextLayout.
 The baseline is one of the values defined in Font,
 which are roman, centered and hanging.  Ascent and descent are
 relative to this baseline.  The baselineOffsets
 are also relative to this baseline.
TextLayout.getBaselineOffsets(), 
Font
getBaselineOffsets
public float[] getBaselineOffsets()
TextLayout.
 Font, which are roman, centered and hanging.  The 
 values are relative to this TextLayout object's 
 baseline, so that getBaselineOffsets[getBaseline()] == 0.
 Offsets are added to the position of the TextLayout 
 object's baseline to get the position for the new baseline.
TextLayout.getBaseline(), 
Font
getAdvance
public float getAdvance()
TextLayout.
 The advance is the distance from the origin to the advance of the
 rightmost (bottommost) character measuring in the line direction.
TextLayout.
getVisibleAdvance
public float getVisibleAdvance()
TextLayout, minus trailing 
 whitespace.
TextLayout without the
      trailing whitespace.getAdvance()
getAscent
public float getAscent()
TextLayout.
 The ascent is the distance from the top (right) of the 
 TextLayout to the baseline.  It is always either 
 positive or zero.  The ascent is sufficient to
 accomodate superscripted text and is the maximum of the sum of the
 ascent, offset, and baseline of each glyph.
TextLayout.
getDescent
public float getDescent()
TextLayout.
 The descent is the distance from the baseline to the bottom (left) of
 the TextLayout.  It is always either positive or zero.  
 The descent is sufficient to accomodate subscripted text and is the 
 maximum of the sum of the descent, offset, and baseline of each glyph.
TextLayout.
getLeading
public float getLeading()
TextLayout.
 The leading is the suggested interline spacing for this 
 TextLayout.
 TextLayout.  The algorithm 
 is roughly as follows:
 
 maxD = 0;
 maxDL = 0;
 for (GlyphVector g in all glyphvectors) {
    maxD = max(maxD, g.getDescent() + offsets[g.getBaseline()]);
    maxDL = max(maxDL, g.getDescent() + g.getLeading() +
                       offsets[g.getBaseline()]);
 }
 return maxDL - maxD;
 
TextLayout.
getBounds
public Rectangle2D getBounds()
TextLayout.
 The bounds contains all of the pixels the TextLayout
 can draw.  It might not coincide exactly with the ascent, descent, 
 origin or advance of the TextLayout.
Rectangle2D that is the bounds of this
        TextLayout.
isLeftToRight
public boolean isLeftToRight()
true if this TextLayout has 
 a left-to-right base direction or false if it has
 a right-to-left base direction.  The TextLayout
 has a base direction of either left-to-right (LTR) or
 right-to-left (RTL).  The base direction is independent of the 
 actual direction of text on the line, which may be either LTR, 
 RTL, or mixed. Left-to-right layouts by default should position 
 flush left.  If the layout is on a tabbed line, the
 tabs run left to right, so that logically successive layouts position
 left to right.  The opposite is true for RTL layouts. By default they
 should position flush left, and tabs run right-to-left.
true if the base direction of this 
         TextLayout is left-to-right; false
         otherwise.
isVertical
public boolean isVertical()
true if this TextLayout is vertical.
true if this TextLayout is vertical;
      false otherwise.
getCharacterCount
public int getCharacterCount()
TextLayout.
TextLayout.
getCaretInfo
public float[] getCaretInfo(TextHitInfo hit,
                            Rectangle2D bounds)
hit.
 The first element of the array is the intersection of the caret with
 the baseline. The second element of the array is the slope (run/rise)
 of the caret.
 getCaretShapes.
hit - a hit on a character in this TextLayoutbounds - the bounds to which the caret info is constructedgetCaretShapes(int, Rectangle2D, TextLayout.CaretPolicy)
getCaretInfo
public float[] getCaretInfo(TextHitInfo hit)
hit.
 This method is a convenience overload of getCaretInfo and
 uses the natural bounds of this TextLayout.
hit - a hit on a character in this TextLayout
getNextRightHit
public TextHitInfo getNextRightHit(TextHitInfo hit)
null.
 If the hit character index is out of bounds, an 
 IllegalArgumentException is thrown.
hit - a hit on a character in this layoutnull.
getNextRightHit
public TextHitInfo getNextRightHit(int offset,
                                   TextLayout.CaretPolicy policy)
null.  The hit is to the right of 
 the strong caret at the specified offset, as determined by the
 specified policy.
 The returned hit is the stronger of the two possible
 hits, as determined by the specified policy.
offset - an insertion offset in this TextLayout.
 Cannot be less than 0 or greater than this TextLayout 
 object's character count.policy - the policy used to select the strong caretnull.
getNextRightHit
public TextHitInfo getNextRightHit(int offset)
null.  The hit is to the right of
 the strong caret at the specified offset, as determined by the 
 default policy.
 The returned hit is the stronger of the two possible
 hits, as determined by the default policy.
offset - an insertion offset in this TextLayout.
 Cannot be less than 0 or greater than the TextLayout
 object's character count.null.
getNextLeftHit
public TextHitInfo getNextLeftHit(TextHitInfo hit)
null.
 If the hit character index is out of bounds, an 
 IllegalArgumentException is thrown.
hit - a hit on a character in this TextLayout.null.
getNextLeftHit
public TextHitInfo getNextLeftHit(int offset,
                                  TextLayout.CaretPolicy policy)
null.  The hit is to the left of
 the strong caret at the specified offset, as determined by the
 specified policy.
 The returned hit is the stronger of the two possible
 hits, as determined by the specified policy.
offset - an insertion offset in this TextLayout.
 Cannot be less than 0 or greater than this TextLayout
 object's character count.policy - the policy used to select the strong caretnull.
getNextLeftHit
public TextHitInfo getNextLeftHit(int offset)
null.  The hit is to the left of
 the strong caret at the specified offset, as determined by the
 default policy.
 The returned hit is the stronger of the two possible
 hits, as determined by the default policy.
offset - an insertion offset in this TextLayout.  
 Cannot be less than 0 or greater than this TextLayout
 object's character count.null.
getVisualOtherHit
public TextHitInfo getVisualOtherHit(TextHitInfo hit)
hit - the specified hit
getCaretShape
public Shape getCaretShape(TextHitInfo hit,
                           Rectangle2D bounds)
Shape representing the caret at the specified 
 hit inside the specified bounds.
hit - the hit at which to generate the caretbounds - the bounds of the TextLayout to use 
 in generating the caret.Shape representing the caret.
getCaretShape
public Shape getCaretShape(TextHitInfo hit)
Shape representing the caret at the specified
 hit inside the natural bounds of this TextLayout.
hit - the hit at which to generate the caretShape representing the caret.
getCharacterLevel
public byte getCharacterLevel(int index)
index.  
 Indices -1 and characterCount are assigned the base
 level of this TextLayout.
index - the index of the character from which to get the level
getCaretShapes
public Shape[] getCaretShapes(int offset,
                              Rectangle2D bounds,
                              TextLayout.CaretPolicy policy)
offset - an offset in this TextLayoutbounds - the bounds to which to extend the caretspolicy - the specified CaretPolicynull.
getCaretShapes
public Shape[] getCaretShapes(int offset,
                              Rectangle2D bounds)
getCaretShapes
 that uses the default caret policy.
offset - an offset in this TextLayoutbounds - the bounds to which to extend the caretsDEFAULT_CARET_POLICY
getCaretShapes
public Shape[] getCaretShapes(int offset)
getCaretShapes
 that uses the default caret policy and this TextLayout
 object's natural bounds.
offset - an offset in this TextLayoutbounds - the bounds to which to extend the caretsDEFAULT_CARET_POLICY
getLogicalRangesForVisualSelection
public int[] getLogicalRangesForVisualSelection(TextHitInfo firstEndpoint,
                                                TextHitInfo secondEndpoint)
firstEndpoint - an endpoint of the visual rangesecondEndpoint - the other endpoint of the visual range.
 This endpoint can be less than firstEndpoint.getVisualHighlightShape(TextHitInfo, TextHitInfo, Rectangle2D)
getVisualHighlightShape
public Shape getVisualHighlightShape(TextHitInfo firstEndpoint,
                                     TextHitInfo secondEndpoint,
                                     Rectangle2D bounds)
bounds.
 bounds.  If the 
 selection includes the rightmost (bottommost) position, the selection
 is extended to the right (bottom) of the bounds.  The height 
 (width on vertical lines) of the selection is always extended to 
 bounds.
 getLogicalRangesForVisualSelection.  For example, 
 consider the text 'ABCdef' where capital letters indicate 
 right-to-left text, rendered on a right-to-left line, with a visual
 selection from 0L (the leading edge of 'A') to 3T (the trailing edge
 of 'd').  The text appears as follows, with bold underlined areas
 representing the selection:
 
    defCBA  
 
 The logical selection ranges are 0-3, 4-6 (ABC, ef) because the
 visually contiguous text is logically discontiguous.  Also note that
 since the rightmost position on the layout (to the right of 'A') is
 selected, the selection is extended to the right of the bounds.
firstEndpoint - one end of the visual selectionsecondEndpoint - the other end of the visual selectionbounds - the bounding rectangle to which to extend the selectionShape enclosing the selection.getLogicalRangesForVisualSelection(TextHitInfo, TextHitInfo), 
getLogicalHighlightShape(int, int, Rectangle2D)
getVisualHighlightShape
public Shape getVisualHighlightShape(TextHitInfo firstEndpoint,
                                     TextHitInfo secondEndpoint)
Shape enclosing the visual selection in the
 specified range, extended to the bounds.  This method is a
 convenience overload of getVisualHighlightShape that
 uses the natural bounds of this TextLayout.
firstEndpoint - one end of the visual selectionsecondEndpoint - the other end of the visual selectionShape enclosing the selection.
getLogicalHighlightShape
public Shape getLogicalHighlightShape(int firstEndpoint,
                                      int secondEndpoint,
                                      Rectangle2D bounds)
Shape enclosing the logical selection in the
 specified range, extended to the specified bounds.
 bounds before 
 the start of this TextLayout.  If the range includes
 the last logical character, the selection is extended to the portion
 of bounds after the end of this TextLayout.  
 The height (width on vertical lines) of the selection is always
 extended to bounds.
 
    defCBA  
 
 The selection is discontiguous because the selected characters are
 visually discontiguous. Also note that since the range includes the
 first logical character (A), the selection is extended to the portion
 of the bounds before the start of the layout, which in
 this case (a right-to-left line) is the right portion of the 
 bounds.
firstEndpoint - an endpoint in the range of characters to selectsecondEndpoint - the other endpoint of the range of characters
 to select. Can be less than firstEndpoint.  The range
 includes the character at min(firstEndpoint, secondEndpoint), but
 excludes max(firstEndpoint, secondEndpoint).bounds - the bounding rectangle to which to extend the selectiongetVisualHighlightShape(TextHitInfo, TextHitInfo, Rectangle2D)
getLogicalHighlightShape
public Shape getLogicalHighlightShape(int firstEndpoint,
                                      int secondEndpoint)
Shape enclosing the logical selection in the
 specified range, extended to the natural bounds of this
 TextLayout.  This method is a convenience overload of 
 getLogicalHighlightShape that uses the natural bounds of 
 this TextLayout.
firstEndpoint - an endpoint in the range of characters to selectsecondEndpoint - the other endpoint of the range of characters
 to select. Can be less than firstEndpoint.  The range
 includes the character at min(firstEndpoint, secondEndpoint), but
 excludes max(firstEndpoint, secondEndpoint).Shape enclosing the selection.
getBlackBoxBounds
public Shape getBlackBoxBounds(int firstEndpoint,
                               int secondEndpoint)
firstEndpoint - one end of the character rangesecondEndpoint - the other end of the character range.  Can be
 less than firstEndpoint.path enclosing the black box bounds.
hitTestChar
public TextHitInfo hitTestChar(float x,
                               float y,
                               Rectangle2D bounds)
TextHitInfo corresponding to the 
 specified point.
 Coordinates outside the bounds of the TextLayout
 map to hits on the leading edge of the first logical character, 
 or the trailing edge of the last logical character, as appropriate, 
 regardless of the position of that character in the line.  Only the
 direction along the baseline is used to make this evaluation.
x - the x offset from the origin of this 
		TextLayouty - the y offset from the origin of this
 		TextLayoutbounds - the bounds of the TextLayout
hitTestChar
public TextHitInfo hitTestChar(float x,
                               float y)
TextHitInfo corresponding to the 
 specified point.  This method is a convenience overload of 
 hitTestChar that uses the natural bounds of this 
 TextLayout.
x - the x offset from the origin of this TextLayouty - the y offset from the origin of this
		TextLayout
hashCode
public int hashCode()
TextLayout.
equals
public boolean equals(Object obj)
true if the specified Object is a 
 TextLayout object and if the specified Object
 equals this TextLayout.
equals
public boolean equals(TextLayout rhs)
true if the two layouts are equal.
 Two layouts are equal if they contain equal glyphvectors in the same order.
rhs - the TextLayout to compare to this 
       TextLayouttrue if the specified TextLayout
      equals this TextLayout.
toString
public String toString()
TextLayout.
draw
public void draw(Graphics2D g2,
                 float x,
                 float y)
TextLayout at the specified location in 
 the specified Graphics2D context.
 The origin of the layout is placed at x, y.  Rendering may touch
 any point within getBounds() of this position.  This 
 leaves the g2 unchanged.
g2 - the Graphics2D context into which to render
         the layoutx, y - the coordinates of the origin of this
          TextLayoutgetBounds()
getOutline
public Shape getOutline(AffineTransform tx)
Shape representing the outline of this
 TextLayout.
tx - an optional AffineTransform to apply to the
     outline of this TextLayout.x, y - the coordinates of the location of the outlineShape that is the outline of this
     TextLayout.
 
 
  
   
    Overview  
      Package  
    Class  
      Use  
      Tree  
      Deprecated  
      Index  
      Help  
  
Java Platform 1.2 
 
 PREV CLASS 
 NEXT CLASS 
  FRAMES   
 NO FRAMES 
 
  SUMMARY:  INNER | FIELD | CONSTR | METHOD 
DETAIL:  FIELD | CONSTR | METHOD 
Submit a bug or feature Version 1.2 of Java Platform API Specification
Java is a trademark or registered trademark of Sun Microsystems,  Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A.  All Rights Reserved.