1 package org
.libreoffice
.canvas
;
3 import android
.graphics
.Canvas
;
4 import android
.graphics
.Color
;
5 import android
.graphics
.Paint
;
6 import android
.graphics
.RectF
;
9 * Handles the cursor drawing on the canvas.
11 public class Cursor
extends CommonCanvasElement
{
12 private static final float CURSOR_WIDTH
= 2f
;
13 private final Paint mCursorPaint
= new Paint();
14 public RectF mPosition
= new RectF();
15 public RectF mScaledPosition
= new RectF();
18 * Construct the cursor and set the default values.
21 mCursorPaint
.setColor(Color
.BLACK
);
22 mCursorPaint
.setAlpha(0xFF);
26 * Hit test for cursor, always false.
29 public boolean onHitTest(float x
, float y
) {
37 public void onDraw(Canvas canvas
) {
38 canvas
.drawRect(mScaledPosition
, mCursorPaint
);
42 * Reposition the cursor on screen.
44 public void reposition(RectF rect
) {
45 mScaledPosition
= rect
;
46 mScaledPosition
.right
= mScaledPosition
.left
+ CURSOR_WIDTH
;
50 * Cycle the alpha color of the cursor, makes the
52 public void cycleAlpha() {
53 mCursorPaint
.setAlpha(mCursorPaint
.getAlpha() == 0 ?
0xFF : 0);