Keine Cache-Version

Caching deaktiviert Standardeinstellung für diese Seite:aktiviert (code LNG204)
Wenn die Anzeige zu langsam ist, können Sie den Benutzermodus deaktivieren, um die zwischengespeicherte Version anzuzeigen.
java.awt.font

Class 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

     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 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.
      • 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(), HashMap
      • 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.

Deutsche Übersetzung

Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.

Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.

Vielen Dank im Voraus.

Dokument erstellt 11/06/2005, zuletzt geändert 04/03/2020
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-rf-java/awt/font/texthitinfo.html

Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.

Referenzen

  1. Zeigen Sie - html-Dokument Sprache des Dokuments:fr Manuel PHP : https://docs.oracle.com

Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor Diese Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.

Inhaltsverzeichnis Haut