summaryrefslogtreecommitdiff
path: root/android/experimental
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2015-03-31 18:43:00 +0900
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-04-07 09:18:06 +0200
commit8f6b3d6421efb8cc0a22aafa5cbf0312006749cc (patch)
treea1a7faa6d5299e176655385f7c9784e343a65c22 /android/experimental
parent7a53938342c784ac39576e459481a2d6ea49dbe7 (diff)
android: use onDraw for element drawing in CanvasElement interface
Use onDraw to override the drawing to canvas. CommonCanvasElement uses the draw method to call onDraw depending on visibility. Change-Id: Id98991935168caab9d39665e72f33cfb3a91d8dc
Diffstat (limited to 'android/experimental')
-rw-r--r--android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/CanvasElement.java12
-rw-r--r--android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/CommonCanvasElement.java9
-rw-r--r--android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelection.java2
-rw-r--r--android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionHandle.java2
4 files changed, 22 insertions, 3 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
index da3ff6eaaf27..322cb99066d2 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/CanvasElement.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/CanvasElement.java
@@ -17,12 +17,22 @@ import android.graphics.Canvas;
*/
public interface CanvasElement {
/**
- * Called when the element needs to be draw no the canvas.
+ * Called when the element needs to be draw no the canvas. This method
+ * should call onDraw when conditions to draw are satisfied.
+ *
* @param canvas - the canvas
*/
void draw(Canvas canvas);
/**
+ * Called inside draw if the element is visible. Override this method to
+ * draw the element on the canvas.
+ *
+ * @param canvas - the canvas
+ */
+ void onDraw(Canvas canvas);
+
+ /**
* Hit test - returns true if the object has been hit
* @param x - x coordinate of the
* @param y - y coordinate of the
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/CommonCanvasElement.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/CommonCanvasElement.java
index 45cbf10b0769..dd7316250ae4 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/CommonCanvasElement.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/CommonCanvasElement.java
@@ -1,5 +1,7 @@
package org.libreoffice.canvas;
+import android.graphics.Canvas;
+
/**
* Common implementation to canvas elements.
*/
@@ -16,4 +18,11 @@ public abstract class CommonCanvasElement implements CanvasElement {
public void setVisible(boolean visible) {
mVisible = visible;
}
+
+ @Override
+ public void draw(Canvas canvas) {
+ if (isVisible()) {
+ onDraw(canvas);
+ }
+ }
}
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelection.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelection.java
index cb5f9fefd14b..0cdd53bd1697 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelection.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelection.java
@@ -103,7 +103,7 @@ public class GraphicSelection extends CommonCanvasElement {
* @see org.libreoffice.canvas.CanvasElement#draw(android.graphics.Canvas)
*/
@Override
- public void draw(Canvas canvas) {
+ public void onDraw(Canvas canvas) {
canvas.drawRect(mDrawRectangle, mPaintStroke);
if (mType != DragType.NONE) {
canvas.drawRect(mDrawRectangle, mPaintFill);
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionHandle.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionHandle.java
index 4eebfe9352e3..b8b22fc4f30f 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionHandle.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/GraphicSelectionHandle.java
@@ -71,7 +71,7 @@ public class GraphicSelectionHandle extends CommonCanvasElement {
* @see org.libreoffice.canvas.CanvasElement#draw(android.graphics.Canvas)
*/
@Override
- public void draw(Canvas canvas) {
+ public void onDraw(Canvas canvas) {
if (mSelected) {
drawFilledCircle(canvas, mPosition.x, mPosition.y, mRadius, mStrokePaint, mSelectedFillPaint);
} else {