API java : TextHitInfo


java.awt.font
Class TextHitInfo

java.lang.Object
  extended by java.awt.font.TextHitInfo

public final class TextHitInfo
extends Object

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

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

See Also:
TextLayout

Method Summary
static TextHitInfo afterOffset(int offset)
          Creates a TextHitInfo at the specified offset, associated with the character after the offset.
static TextHitInfo beforeOffset(int offset)
          Creates a TextHitInfo at the specified offset, associated with the character before the offset.
 boolean equals(Object obj)
          Returns true if the specified Object is a TextHitInfo and equals this TextHitInfo.
 boolean equals(TextHitInfo hitInfo)
          Returns true if the specified TextHitInfo has the same charIndex and isLeadingEdge as this TextHitInfo.
 int getCharIndex()
          Returns the index of the character hit.
 int getInsertionIndex()
          Returns the insertion index.
 TextHitInfo getOffsetHit(int delta)
          Creates a TextHitInfo whose character index is offset by delta from the charIndex of this TextHitInfo.
 TextHitInfo getOtherHit()
          Creates a TextHitInfo on the other side of the insertion point.
 int hashCode()
          Returns the hash code.
 boolean isLeadingEdge()
          Returns true if the leading edge of the character was hit.
static TextHitInfo leading(int charIndex)
          Creates a TextHitInfo on the leading edge of the character at the specified charIndex.
 String toString()
          Returns a String representing the hit for debugging use only.
static TextHitInfo trailing(int charIndex)
          Creates a hit on the trailing edge of the character at the specified charIndex.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getCharIndex

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

Returns:
the index of the character hit.

isLeadingEdge

public boolean isLeadingEdge()
Returns true if the leading edge of the character was hit.

Returns:
true if the leading edge of the character was hit; false otherwise.

getInsertionIndex

public int getInsertionIndex()
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.

Returns:
the insertion index.

hashCode

public int hashCode()
Returns the hash code.

Overrides:
hashCode in class Object
Returns:
the hash code of this TextHitInfo, which is also the charIndex of this TextHitInfo.
See Also:
Object.equals(java.lang.Object), Hashtable

equals

public boolean equals(Object obj)
Returns true if the specified Object is a TextHitInfo and equals this TextHitInfo.

Overrides:
equals in class Object
Parameters:
obj - the Object to test for equality
Returns:
true if the specified Object equals this TextHitInfo; false otherwise.
See Also:
Object.hashCode(), Hashtable

equals

public boolean equals(TextHitInfo hitInfo)
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
Returns:
true if the specified TextHitInfo has the same charIndex and isLeadingEdge as this TextHitInfo.

toString

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

Overrides:
toString in class Object
Returns:
a String representing this TextHitInfo.

leading

public static TextHitInfo leading(int charIndex)
Creates a TextHitInfo on the leading edge of the character at the specified charIndex.

Parameters:
charIndex - the index of the character hit
Returns:
a TextHitInfo on the leading edge of the character at the specified charIndex.

trailing

public static TextHitInfo trailing(int charIndex)
Creates a hit on the trailing edge of the character at the specified charIndex.

Parameters:
charIndex - the index of the character hit
Returns:
a TextHitInfo on the trailing edge of the character at the specified charIndex.

beforeOffset

public static TextHitInfo beforeOffset(int offset)
Creates a TextHitInfo at the specified offset, associated with the character before the offset.

Parameters:
offset - an offset associated with the character before the offset
Returns:
a TextHitInfo at the specified offset.

afterOffset

public static TextHitInfo afterOffset(int offset)
Creates a TextHitInfo at the specified offset, associated with the character after the offset.

Parameters:
offset - an offset associated with the character after the offset
Returns:
a TextHitInfo at the specified offset.

getOtherHit

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

Returns:
a TextHitInfo on the other side of the insertion point.

getOffsetHit

public TextHitInfo getOffsetHit(int delta)
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
Returns:
a TextHitInfo whose charIndex is offset by delta from the charIndex of this TextHitInfo.

Ces informations proviennent du site de http://java.sun.com

Remarques

Contenu

Le contenu de cette page provient du site de Sun, et est généré depuis un cache sur l'infobrol après certains traitements automatisés. La présentation peut donc différer du document original, mais le contenu aussi. Vous pouvez utiliser ce bouton pour afficher la page originale du site de Sun :

Quels sont les motivations de cette démarche?

Maintenir les pages en cache sur différents sites peut offrir plus de disponibilité.

Chaque page est indexée dans la base de donnée, ce qui permet de retrouver facilement les informations, au moyen des sommaires, du moteur de recherche interne, etc.

Des facilités sont mises en place pour que les membres de l'infobrol puissent effectuer des traductions en français des différents documents. Ceci devrait permettre aux débutants en programmation Java de consulter les API en français s'ils maîtrisent moins bien la langue de Shakespeare. Dans le cas où une traduction a été soumise, elle est disponible au moyen d'un lien en bas de page. Si la traduction a été validée, la page s'affiche par défaut en français, et un lien en bas de page permet d'atteindre la version en anglais.

Le code sur l'infobrol est automatiquement coloré selon la syntaxe, et les différents mots clés sont transformés en liens pour accéder rapidement aux informations.

Vous avez la possibilité de partager vos expériences en proposant vos propres extraits de code en utilisant le bouton "ajouter un commentaire" en bas de page. Si vous visitez simplement l'infobrol, vous avez déjà accès à cette fonction, mais si vous étes membre du brol, vous pouvez en plus utiliser des boutons supplémentaires de mise en forme, dont la coloration automatique de vos extraits de codes.

Réseaux sociaux

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher les interactions avec les réseaux sociaux sur ces pages.

 

Nuage de mots clés

7 mots clés dont 0 définis manuellement (plus d'information...).

Avertissement

Cette page ne possède pas encore de mots clés manuels, ceci est donc un exemple automatique (les niveaux de pertinence sont fictifs, mais les liens sont valables). Pour tester le nuage avec une page qui contient des mots définis manuellement, vous pouvez cliquer ici.

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher le nuage de mots clés.

 

Astuce pour imprimer les couleurs des cellules de tableaux : http://www.gaudry.be/ast-rf-450.html
Aucun commentaire pour cette page

© Ce document issu de l′infobrol est enregistré sous le certificat Cyber PrInterDeposit Digital Numbertection. Enregistrement IDDN n° 5329-1470
Document créé le 30/08/06 00:50, dernière modification le Vendredi 17 Juin 2011, 12:12
Source du document imprimé : http://www.gaudry.be/java-api-rf-java/awt/font/TextHitInfo.html Document affiché 1 fois ce mois de Juin.
St.Gaudry©07.01.02
Outils (masquer)
||
Recherche (afficher)
Recherche :

Utilisateur (masquer)
Apparence (afficher)
Stats (afficher)
15832 documents
452 astuces.
549 niouzes.
3099 definitions.
447 membres.
8115 messages.

Document genere en :
0,97 seconde

Mises à jour :
Mises à jour du site
Citation (masquer)
A vaincre sans péril, on évite des ennuis !

René Goscinny
 
l'infobrol
Nous sommes le Vendredi 01 Juin 2012, 14:45, toutes les heures sont au format GMT+1.00 Heure, heure d'été (+1)