Package java.awt.font

Examples of java.awt.font.TextHitInfo


          TextLayout layout = measurer.nextLayout(textWidth);
          bottomBoundary = topBoundary + lineHeight;

          if ((clickY > topBoundary) && (clickY < bottomBoundary)) {
            // Get the character position of the mouse click.
            TextHitInfo currentHit = layout.hitTestChar((float)clickX, (float)clickY);
            if (currentHit != null) {
              this.currentText = (StringBuffer)buffers.elementAt(i);
              cursorIndex += currentHit.getInsertionIndex();
              return;
            }
          } else {
            cursorIndex = measurer.getPosition();
          }
View Full Code Here


        int currentFeedback;
        int nextFeedback;
        int startOffset = 0;
        int currentOffset;
        int visiblePosition = 0;
        TextHitInfo visiblePositionInfo = null;

        rawFeedbacks.rewind();
        currentFeedback = rawFeedbacks.getNext();
        rawFeedbacks.unget();
        while ((nextFeedback = rawFeedbacks.getNext()) != -1) {
View Full Code Here

                originalCaret = caret;
                // Sets composed text caret
                exchangeCaret(originalCaret, composedTextCaret);
            }

            TextHitInfo caretPos = e.getCaret();
            if (caretPos != null) {
                int index = caretPos.getInsertionIndex();
                dot += index;
                if (index == 0) {
                    // Scroll the component if needed so that the composed text
                    // becomes visible.
                    try {
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

            // 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

            tx = advance;
        }
        //System.out.println("Testing point: "+(x+tx)+",; "+y);
        //System.out.println("    in layout "+layout.getBounds());
        //System.out.println("    with advance: "+layout.getAdvance());
        TextHitInfo textHit =
            layout.hitTestChar((float) (x+tx), (float) y, layout.getBounds());
        //if (textHit != null) System.out.println("HIT : "+textHit);
        return new BasicTextPainter.Mark(x, y, layout, textHit);
    }
View Full Code Here

  protected boolean moveCaretUp(TextLayoutHitInfo currPos){
    if(currPos.tli.lineNo == 0)
      return false;
    TextLayoutInfo ntli = stext.getTLIforLineNo(currPos.tli.lineNo - 1)
    TextHitInfo nthi = ntli.layout.hitTestChar(caretX, 0);
    currPos.tli = ntli;
    currPos.thi = nthi;
    return true;
  }
View Full Code Here

  protected boolean moveCaretDown(TextLayoutHitInfo currPos){
    if(currPos.tli.lineNo == stext.getNbrLines() - 1)
      return false;
    TextLayoutInfo ntli = stext.getTLIforLineNo(currPos.tli.lineNo + 1)
    TextHitInfo nthi = ntli.layout.hitTestChar(caretX, 0);
    currPos.tli = ntli;
    currPos.thi = nthi;
    return true;
  }
View Full Code Here

   * Move caret left by one character. If necessary move to the end of the line above
   * @return true if caret was moved else false
   */
  protected boolean moveCaretLeft(TextLayoutHitInfo currPos){
    TextLayoutInfo ntli;
    TextHitInfo nthi = currPos.tli.layout.getNextLeftHit(currPos.thi);
    if(nthi == null){
      // Move the caret to the end of the previous line
      if(currPos.tli.lineNo == 0)
        // Can't goto previous line because this is the first line
        return false;
View Full Code Here

   * Move caret left by one character. If necessary move to the end of the line above
   * @return true if caret was moved else false
   */
  protected boolean moveCaretRight(TextLayoutHitInfo currPos){
    TextLayoutInfo ntli;
    TextHitInfo nthi = currPos.tli.layout.getNextRightHit(currPos.thi);
    if(nthi == null){
      // Move the caret to the end of the previous line
      if(currPos.tli.lineNo >= stext.getNbrLines() - 1)
        // Can't goto next line because this is the last line
        return false;
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.