summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2015-03-26 19:50:49 +0900
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-03-30 09:23:50 +0200
commitb1def00ac3ba1cb4eeafab9c5791382222da1d0a (patch)
treed626929024742ea0e6a11fdba04539d53018aa41 /android
parentba93e70c9f3a70ca5644c30b8ed423db73ac52d7 (diff)
android: introduce CanvasElement interface
Change-Id: Ic3cb636e397c110af54974159892b32b6c4c33c1
Diffstat (limited to 'android')
-rw-r--r--android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/CanvasElement.java25
-rw-r--r--android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionCanvasElement.java6
-rw-r--r--android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionHandleCanvasElement.java6
3 files changed, 35 insertions, 2 deletions
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/CanvasElement.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/CanvasElement.java
new file mode 100644
index 000000000000..154d4cec50ca
--- /dev/null
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/CanvasElement.java
@@ -0,0 +1,25 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+package org.libreoffice.canvas;
+
+import android.graphics.Canvas;
+
+/**
+ * Canvas element is an element (or part) that is drawn canvas and can
+ * potentially be interacted with.
+ */
+public interface CanvasElement {
+ /**
+ * Called when the element needs to be draw no the canvas.
+ * @param canvas - the canvas
+ */
+ void draw(Canvas canvas);
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionCanvasElement.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionCanvasElement.java
index 909d8080a09e..a205c678e575 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionCanvasElement.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionCanvasElement.java
@@ -23,7 +23,7 @@ import static org.libreoffice.canvas.GraphicSelectionHandleCanvasElement.HandleP
* This class is responsible to draw and reposition the selection
* rectangle.
*/
-public class GraphicSelectionCanvasElement {
+public class GraphicSelectionCanvasElement implements CanvasElement {
private final Paint mPaint;
public RectF mRectangle = new RectF();
public RectF mScaledRectangle = new RectF();
@@ -74,6 +74,10 @@ public class GraphicSelectionCanvasElement {
return mScaledRectangle.contains(x, y);
}
+ /**
+ * @see org.libreoffice.canvas.CanvasElement#draw(android.graphics.Canvas)
+ */
+ @Override
public void draw(Canvas canvas) {
canvas.drawRect(mDrawRectangle, mPaint);
for (GraphicSelectionHandleCanvasElement handle : mHandles) {
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionHandleCanvasElement.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionHandleCanvasElement.java
index 62b6bc1c550f..5bf544c15d24 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionHandleCanvasElement.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionHandleCanvasElement.java
@@ -19,7 +19,7 @@ import android.graphics.RectF;
* position and perform a hit test to determine if the selection handle was
* touched.
*/
-public class GraphicSelectionHandleCanvasElement {
+public class GraphicSelectionHandleCanvasElement implements CanvasElement {
private final HandlePosition mHandlePosition;
public PointF mPosition = new PointF();
private float mRadius = 20.0f;
@@ -47,6 +47,10 @@ public class GraphicSelectionHandleCanvasElement {
return mHandlePosition;
}
+ /**
+ * @see org.libreoffice.canvas.CanvasElement#draw(android.graphics.Canvas)
+ */
+ @Override
public void draw(Canvas canvas) {
if (mSelected) {
drawFilledCircle(canvas, mPosition.x, mPosition.y, mRadius, mStrokePaint, mSelectedFillPaint);