Update git submodules
[LibreOffice.git] / android / source / src / java / org / libreoffice / canvas / Cursor.java
blob42875f992b5fe0f2a5194198f5ec73d52af1fd4e
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;
8 /**
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();
17 /**
18 * Construct the cursor and set the default values.
20 public Cursor() {
21 mCursorPaint.setColor(Color.BLACK);
22 mCursorPaint.setAlpha(0xFF);
25 /**
26 * Hit test for cursor, always false.
28 @Override
29 public boolean onHitTest(float x, float y) {
30 return false;
33 /**
34 * Draw the cursor.
36 @Override
37 public void onDraw(Canvas canvas) {
38 canvas.drawRect(mScaledPosition, mCursorPaint);
41 /**
42 * Reposition the cursor on screen.
44 public void reposition(RectF rect) {
45 mScaledPosition = rect;
46 mScaledPosition.right = mScaledPosition.left + CURSOR_WIDTH;
49 /**
50 * Cycle the alpha color of the cursor, makes the
52 public void cycleAlpha() {
53 mCursorPaint.setAlpha(mCursorPaint.getAlpha() == 0 ? 0xFF : 0);