Package java.awt.font

Examples of java.awt.font.TextHitInfo


  public float getWrapWidth(){
    return wrapWidth;
  }

  public TextLayoutHitInfo calculateFromXY(Graphics2D g2d, float px, float py){
    TextHitInfo thi = null;
    TextLayoutInfo tli = null;
    TextLayoutHitInfo tlhi = null;
    if(invalidLayout)
      getLines(g2d);
    if(px < 0) px = 0;
View Full Code Here


  /**
   * Move caret left by one character.
   * @return true if caret was moved else false
   */
  protected boolean moveCaretLeft(TextLayoutHitInfo currPos){
    TextHitInfo nthi = currPos.tli.layout.getNextLeftHit(currPos.thi);
    if(nthi == null){
      return false;
    }
    else {
      // Move the caret to the left of current position
View Full Code Here

  /**
   * Move caret right by one character.
   * @return true if caret was moved else false
   */
  protected boolean moveCaretRight(TextLayoutHitInfo currPos){
    TextHitInfo nthi = currPos.tli.layout.getNextRightHit(currPos.thi);
    if(nthi == null){
      return false;
    }
    else {
      currPos.thi = nthi;
View Full Code Here

      pos += adjust;
      // Force update of lines since they have changed
      stext.getLines(buffer.g2);
     
      TextLayoutInfo tli;
      TextHitInfo thi = null, thiRight;

      tli = stext.getTLIforCharNo(pos);

      int posInLine = pos - tli.startCharIndex;
View Full Code Here

        Point2D p = new Point2D.Float(x, y);
        try {
        transform.inverseTransform(p, p);
        } catch (java.awt.geom.NoninvertibleTransformException nite) {;}
        TextHitInfo hit = layout.hitTestChar((float) p.getX(),
                                             (float) p.getY());
        // put this in to be consistent with GlyphLayout
        if (hit.getCharIndex() == -1) {
            return null;
        }
        aci.setIndex(hit.getCharIndex() + aci.getBeginIndex());
        int charIndex = ((Integer)aci.getAttribute(
            GVTAttributedCharacterIterator.TextAttribute.CHAR_INDEX)).intValue();
        return new TextHit(charIndex, hit.isLeadingEdge());
    }
View Full Code Here

        Point2D p = new Point2D.Float(x, y);
        try {
        transform.inverseTransform(p, p);
        } catch (java.awt.geom.NoninvertibleTransformException nite) {;}
        TextHitInfo hit = layout.hitTestChar((float) p.getX(),
                                             (float) p.getY());
        // put this in to be consistent with GlyphLayout
        if (hit.getCharIndex() == -1) {
            return null;
        }
        aci.setIndex(hit.getCharIndex() + aci.getBeginIndex());
        int charIndex = ((Integer)aci.getAttribute(
            GVTAttributedCharacterIterator.TextAttribute.CHAR_INDEX)).intValue();
        return new TextHit(charIndex, hit.isLeadingEdge());
    }
View Full Code Here

            // vector when the view is created so we don't need to rebuild it
            // every time
            int offset;
            if (text.length() > 0) {
                TextLayout textLayout = new TextLayout(text, font, fontRenderContext);
                TextHitInfo textHitInfo = textLayout.hitTestChar(x, y);
                offset = textHitInfo.getInsertionIndex();
            } else {
                offset = -1;
            }

            return offset + start;
View Full Code Here

        return text;
    }

    protected int getInsertionIndex(String text, int x) {
        TextLayout textLayout = new TextLayout(text, font, fontRenderContext);
        TextHitInfo textHitInfo = textLayout.hitTestChar(x + scrollLeft - padding.left - 1, 0);
        int index = textHitInfo.getInsertionIndex();

        return index;
    }
View Full Code Here

TOP

Related Classes of java.awt.font.TextHitInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.