Java Doc for TextHitInfo.java in  » 6.0-JDK-Core » AWT » java » awt » font » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » AWT » java.awt.font 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.awt.font.TextHitInfo

TextHitInfo
final public class TextHitInfo (Code)
The TextHitInfo class represents a character position in a text model, and a bias, or "side," of the character. Biases are either leading (the left edge, for a left-to-right character) or trailing (the right edge, for a left-to-right character). Instances of TextHitInfo are used to specify caret and insertion positions within text.

For example, consider the text "abc". TextHitInfo.trailing(1) corresponds to the right side of the 'b' in the text.

TextHitInfo is used primarily by TextLayout and clients of TextLayout. Clients of TextLayout query TextHitInfo instances for an insertion offset, where new text is inserted into the text model. The insertion offset is equal to the character position in the TextHitInfo if the bias is leading, and one character after if the bias is trailing. The insertion offset for TextHitInfo.trailing(1) is 2.

Sometimes it is convenient to construct a TextHitInfo with the same insertion offset as an existing one, but on the opposite character. The getOtherHit method constructs a new TextHitInfo with the same insertion offset as an existing one, with a hit on the character on the other side of the insertion offset. Calling getOtherHit on trailing(1) would return leading(2). In general, getOtherHit for trailing(n) returns leading(n+1) and getOtherHit for leading(n) returns trailing(n-1).

Example:

Converting a graphical point to an insertion point within a text model

 TextLayout layout = ...;
 Point2D.Float hitPoint = ...;
 TextHitInfo hitInfo = layout.hitTestChar(hitPoint.x, hitPoint.y);
 int insPoint = hitInfo.getInsertionIndex();
 // insPoint is relative to layout;  may need to adjust for use 
 // in a text model
 

See Also:   TextLayout




Method Summary
public static  TextHitInfoafterOffset(int offset)
     Creates a TextHitInfo at the specified offset, associated with the character after the offset.
public static  TextHitInfobeforeOffset(int offset)
     Creates a TextHitInfo at the specified offset, associated with the character before the offset.
public  booleanequals(Object obj)
     Returns true if the specified Object is a TextHitInfo and equals this TextHitInfo.
public  booleanequals(TextHitInfo hitInfo)
     Returns true if the specified TextHitInfo has the same charIndex and isLeadingEdge as this TextHitInfo.
public  intgetCharIndex()
     Returns the index of the character hit.
public  intgetInsertionIndex()
     Returns the insertion index.
public  TextHitInfogetOffsetHit(int delta)
     Creates a TextHitInfo whose character index is offset by delta from the charIndex of this TextHitInfo.
public  TextHitInfogetOtherHit()
     Creates a TextHitInfo on the other side of the insertion point.
public  inthashCode()
     Returns the hash code.
public  booleanisLeadingEdge()
     Returns true if the leading edge of the character was hit.
public static  TextHitInfoleading(int charIndex)
     Creates a TextHitInfo on the leading edge of the character at the specified charIndex.
public  StringtoString()
     Returns a String representing the hit for debugging use only.
public static  TextHitInfotrailing(int charIndex)
     Creates a hit on the trailing edge of the character at the specified charIndex.



Method Detail
afterOffset
public static TextHitInfo afterOffset(int offset)(Code)
Creates a TextHitInfo at the specified offset, associated with the character after the offset.
Parameters:
  offset - an offset associated with the character afterthe offset a TextHitInfo at the specified offset.



beforeOffset
public static TextHitInfo beforeOffset(int offset)(Code)
Creates a TextHitInfo at the specified offset, associated with the character before the offset.
Parameters:
  offset - an offset associated with the character beforethe offset a TextHitInfo at the specified offset.



equals
public boolean equals(Object obj)(Code)
Returns true if the specified Object is a TextHitInfo and equals this TextHitInfo.
Parameters:
  obj - the Object to test for equality true if the specified Objectequals this TextHitInfo; false otherwise.



equals
public boolean equals(TextHitInfo hitInfo)(Code)
Returns true if the specified TextHitInfo has the same charIndex and isLeadingEdge as this TextHitInfo. This is not the same as having the same insertion offset.
Parameters:
  hitInfo - a specified TextHitInfo true if the specified TextHitInfohas the same charIndex and isLeadingEdgeas this TextHitInfo.



getCharIndex
public int getCharIndex()(Code)
Returns the index of the character hit. the index of the character hit.



getInsertionIndex
public int getInsertionIndex()(Code)
Returns the insertion index. This is the character index if the leading edge of the character was hit, and one greater than the character index if the trailing edge was hit. the insertion index.



getOffsetHit
public TextHitInfo getOffsetHit(int delta)(Code)
Creates a TextHitInfo whose character index is offset by delta from the charIndex of this TextHitInfo. This TextHitInfo remains unchanged.
Parameters:
  delta - the value to offset this charIndex a TextHitInfo whose charIndex isoffset by delta from the charIndex of this TextHitInfo.



getOtherHit
public TextHitInfo getOtherHit()(Code)
Creates a TextHitInfo on the other side of the insertion point. This TextHitInfo remains unchanged. a TextHitInfo on the other side of the insertion point.



hashCode
public int hashCode()(Code)
Returns the hash code. the hash code of this TextHitInfo, which isalso the charIndex of this TextHitInfo.



isLeadingEdge
public boolean isLeadingEdge()(Code)
Returns true if the leading edge of the character was hit. true if the leading edge of the character washit; false otherwise.



leading
public static TextHitInfo leading(int charIndex)(Code)
Creates a TextHitInfo on the leading edge of the character at the specified charIndex.
Parameters:
  charIndex - the index of the character hit a TextHitInfo on the leading edge of thecharacter at the specified charIndex.



toString
public String toString()(Code)
Returns a String representing the hit for debugging use only. a String representing thisTextHitInfo.



trailing
public static TextHitInfo trailing(int charIndex)(Code)
Creates a hit on the trailing edge of the character at the specified charIndex.
Parameters:
  charIndex - the index of the character hit a TextHitInfo on the trailing edge of thecharacter at the specified charIndex.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.