Search in sources :

Example 1 with TextAreaPainter

use of processing.app.syntax.TextAreaPainter in project processing by processing.

the class CompositionTextManager method getCaretLocation.

private Point getCaretLocation() {
    Point loc = new Point();
    TextAreaPainter painter = textArea.getPainter();
    FontMetrics fm = painter.getFontMetrics();
    int offsetY = fm.getHeight() - COMPOSING_UNDERBAR_HEIGHT;
    int lineIndex = textArea.getCaretLine();
    loc.y = lineIndex * fm.getHeight() + offsetY;
    int offsetX = textArea.getCaretPosition() - textArea.getLineStartOffset(lineIndex);
    loc.x = textArea.offsetToX(lineIndex, offsetX);
    return loc;
}
Also used : TextAreaPainter(processing.app.syntax.TextAreaPainter) FontMetrics(java.awt.FontMetrics) Point(java.awt.Point) Point(java.awt.Point)

Example 2 with TextAreaPainter

use of processing.app.syntax.TextAreaPainter in project processing by processing.

the class CompositionTextManager method getCaretRectangle.

private Rectangle getCaretRectangle(int x, int y) {
    TextAreaPainter painter = textArea.getPainter();
    Point origin = painter.getLocationOnScreen();
    int height = painter.getFontMetrics().getHeight();
    return new Rectangle(origin.x + x, origin.y + y, 0, height);
}
Also used : TextAreaPainter(processing.app.syntax.TextAreaPainter) Rectangle(java.awt.Rectangle) Point(java.awt.Point) Point(java.awt.Point)

Example 3 with TextAreaPainter

use of processing.app.syntax.TextAreaPainter in project chipKIT32-MAX by chipKIT32.

the class CompositionTextManager method getCaretLocation.

private Point getCaretLocation() {
    Point loc = new Point();
    TextAreaPainter painter = textArea.getPainter();
    FontMetrics fm = painter.getFontMetrics();
    int offsetY = fm.getHeight() - COMPOSING_UNDERBAR_HEIGHT;
    int lineIndex = textArea.getCaretLine();
    loc.y = lineIndex * fm.getHeight() + offsetY;
    int offsetX = textArea.getCaretPosition() - textArea.getLineStartOffset(lineIndex);
    loc.x = textArea.offsetToX(lineIndex, offsetX);
    return loc;
}
Also used : TextAreaPainter(processing.app.syntax.TextAreaPainter) FontMetrics(java.awt.FontMetrics) Point(java.awt.Point) Point(java.awt.Point)

Example 4 with TextAreaPainter

use of processing.app.syntax.TextAreaPainter in project chipKIT32-MAX by chipKIT32.

the class CompositionTextManager method getCaretRectangle.

private Rectangle getCaretRectangle(int x, int y) {
    TextAreaPainter painter = textArea.getPainter();
    Point origin = painter.getLocationOnScreen();
    int height = painter.getFontMetrics().getHeight();
    return new Rectangle(origin.x + x, origin.y + y, 0, height);
}
Also used : TextAreaPainter(processing.app.syntax.TextAreaPainter) Rectangle(java.awt.Rectangle) Point(java.awt.Point) Point(java.awt.Point)

Example 5 with TextAreaPainter

use of processing.app.syntax.TextAreaPainter in project chipKIT32-MAX by chipKIT32.

the class CompositionTextPainter method getCaretLocation.

private Point getCaretLocation() {
    Point loc = new Point();
    TextAreaPainter painter = textArea.getPainter();
    FontMetrics fm = painter.getFontMetrics();
    int offsetY = fm.getHeight() - CompositionTextManager.COMPOSING_UNDERBAR_HEIGHT;
    int lineIndex = textArea.getCaretLine();
    loc.y = lineIndex * fm.getHeight() + offsetY;
    int offsetX = composedBeginCaretPosition - textArea.getLineStartOffset(lineIndex);
    loc.x = textArea.offsetToX(lineIndex, offsetX);
    return loc;
}
Also used : TextAreaPainter(processing.app.syntax.TextAreaPainter) FontMetrics(java.awt.FontMetrics) Point(java.awt.Point) Point(java.awt.Point)

Aggregations

TextAreaPainter (processing.app.syntax.TextAreaPainter)7 Point (java.awt.Point)5 FontMetrics (java.awt.FontMetrics)3 Font (java.awt.Font)2 Graphics2D (java.awt.Graphics2D)2 Rectangle (java.awt.Rectangle)2 FontRenderContext (java.awt.font.FontRenderContext)2 TextLayout (java.awt.font.TextLayout)2 AttributedString (java.text.AttributedString)2 Color (java.awt.Color)1 TextAreaDefaults (processing.app.syntax.TextAreaDefaults)1