summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohn Hoford <hoford@google.com>2013-02-07 17:39:06 -0800
committerJohn Hoford <hoford@google.com>2013-02-08 16:08:07 -0800
commit1bc931c09606f8a00fd8b41706e918a766389b20 (patch)
tree1118ab2af30ca65f0da7ed780707a07dcde87040 /src
parentb4e6733731e751afe7dcf2a3b9803d2f720cb253 (diff)
downloadandroid_packages_apps_Snap-1bc931c09606f8a00fd8b41706e918a766389b20.tar.gz
android_packages_apps_Snap-1bc931c09606f8a00fd8b41706e918a766389b20.tar.bz2
android_packages_apps_Snap-1bc931c09606f8a00fd8b41706e918a766389b20.zip
Fix tiny planet to work with the new framework
Change-Id: I57e87ade6f2cfdfee1b237cdfdf5914244ee98aa
Diffstat (limited to 'src')
-rw-r--r--src/com/android/gallery3d/filtershow/FilterShowActivity.java2
-rw-r--r--src/com/android/gallery3d/filtershow/editors/EditorTinyPlanet.java55
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterTinyPlanetRepresentation.java54
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterDraw.java1
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java73
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/ImageTinyPlanet.java27
6 files changed, 195 insertions, 17 deletions
diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
index 051ffaf4a..bf17a6543 100644
--- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java
+++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
@@ -65,6 +65,7 @@ import com.android.gallery3d.filtershow.editors.BasicEditor;
import com.android.gallery3d.filtershow.editors.EditorDraw;
import com.android.gallery3d.filtershow.editors.EditorManager;
import com.android.gallery3d.filtershow.editors.ImageOnlyEditor;
+import com.android.gallery3d.filtershow.editors.EditorTinyPlanet;
import com.android.gallery3d.filtershow.filters.*;
import com.android.gallery3d.filtershow.imageshow.ImageCrop;
import com.android.gallery3d.filtershow.imageshow.ImageDraw;
@@ -225,6 +226,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
mEditorPlaceHolder.addEditor(new EditorDraw());
mEditorPlaceHolder.addEditor(new BasicEditor());
mEditorPlaceHolder.addEditor(new ImageOnlyEditor());
+ mEditorPlaceHolder.addEditor(new EditorTinyPlanet());
EditorManager.addEditors(mEditorPlaceHolder);
mEditorPlaceHolder.setOldViews(mImageViews);
mEditorPlaceHolder.setImageLoader(mImageLoader);
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorTinyPlanet.java b/src/com/android/gallery3d/filtershow/editors/EditorTinyPlanet.java
new file mode 100644
index 000000000..4f30dc1d7
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/editors/EditorTinyPlanet.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.gallery3d.filtershow.editors;
+
+import android.content.Context;
+import android.util.Log;
+import android.widget.FrameLayout;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.filters.FilterRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterTinyPlanetRepresentation;
+import com.android.gallery3d.filtershow.imageshow.ImageTinyPlanet;
+
+public class EditorTinyPlanet extends BasicEditor {
+ public static final int ID = R.id.tinyPlanetEditor;
+ private static final String LOGTAG = "EditorTinyPlanet";
+ ImageTinyPlanet mImageTinyPlanet;
+
+ public EditorTinyPlanet() {
+ super(ID, R.layout.filtershow_tiny_planet_editor, R.id.imageTinyPlanet);
+ }
+
+ @Override
+ public void createEditor(Context context, FrameLayout frameLayout) {
+ super.createEditor(context, frameLayout);
+ mImageTinyPlanet = (ImageTinyPlanet) mImageShow;
+ mImageTinyPlanet.setEditor(this);
+ }
+
+ @Override
+ public void reflectCurrentFilter() {
+ super.reflectCurrentFilter();
+
+ FilterRepresentation rep = getLocalRepresentation();
+ if (rep != null && getLocalRepresentation() instanceof FilterTinyPlanetRepresentation) {
+ FilterTinyPlanetRepresentation drawRep = (FilterTinyPlanetRepresentation) rep;
+
+ mImageTinyPlanet.setRepresentation(drawRep);
+ }
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterTinyPlanetRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterTinyPlanetRepresentation.java
new file mode 100644
index 000000000..640a57f3b
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/FilterTinyPlanetRepresentation.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.gallery3d.filtershow.filters;
+
+import android.util.Log;
+
+public class FilterTinyPlanetRepresentation extends FilterBasicRepresentation {
+ private static final String LOGTAG = "FilterTinyPlanetRepresentation";
+ private float mAngle = 0;
+
+ public FilterTinyPlanetRepresentation() {
+ super("TinyPlanet", 0, 50, 100);
+ setShowParameterValue(true);
+ }
+
+ @Override
+ public FilterRepresentation clone() throws CloneNotSupportedException {
+ FilterTinyPlanetRepresentation representation = (FilterTinyPlanetRepresentation) super
+ .clone();
+ representation.mAngle = mAngle;
+ representation.setZoom(getZoom());
+ return representation;
+ }
+
+ public void setAngle(float angle) {
+ mAngle = angle;
+ }
+
+ public float getAngle() {
+ return mAngle;
+ }
+
+ public int getZoom() {
+ return getValue();
+ }
+
+ public void setZoom(int zoom) {
+ setValue(zoom);
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterDraw.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterDraw.java
index 05efd4a4f..3613cb893 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterDraw.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterDraw.java
@@ -66,6 +66,7 @@ public class ImageFilterDraw extends ImageFilter {
public boolean hasDefaultRepresentation() {
return true;
}
+
@Override
public FilterRepresentation getDefaultRepresentation() {
FilterDrawRepresentation representation = new FilterDrawRepresentation();
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java
index a6075daa1..558af8730 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java
@@ -18,22 +18,26 @@ package com.android.gallery3d.filtershow.filters;
import android.graphics.Bitmap;
import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.graphics.Rect;
import android.graphics.RectF;
import com.adobe.xmp.XMPException;
import com.adobe.xmp.XMPMeta;
import com.android.gallery3d.R;
import com.android.gallery3d.app.Log;
+import com.android.gallery3d.filtershow.editors.EditorTinyPlanet;
import com.android.gallery3d.filtershow.presets.ImagePreset;
/**
* An image filter which creates a tiny planet projection.
*/
public class ImageFilterTinyPlanet extends SimpleImageFilter {
- private float mAngle = 0;
- private static final String TAG = ImageFilterTinyPlanet.class.getSimpleName();
+
+ private static final String LOGTAG = ImageFilterTinyPlanet.class.getSimpleName();
public static final String GOOGLE_PANO_NAMESPACE = "http://ns.google.com/photos/1.0/panorama/";
+ FilterTinyPlanetRepresentation mParameters = new FilterTinyPlanetRepresentation();
public static final String CROPPED_AREA_IMAGE_WIDTH_PIXELS =
"CroppedAreaImageWidthPixels";
@@ -51,25 +55,40 @@ public class ImageFilterTinyPlanet extends SimpleImageFilter {
public ImageFilterTinyPlanet() {
setFilterType(TYPE_TINYPLANET);
mName = "TinyPlanet";
- mAngle = 0;
}
@Override
- public int getButtonId() {
- return R.id.tinyplanetButton;
+ public int getEditingViewId() {
+ return EditorTinyPlanet.ID;
}
@Override
- public int getTextId() {
- return R.string.tinyplanet;
+ public boolean hasDefaultRepresentation() {
+ return true;
+ }
+
+ @Override
+ public void useRepresentation(FilterRepresentation representation) {
+ FilterTinyPlanetRepresentation parameters = (FilterTinyPlanetRepresentation) representation;
+ mParameters = parameters;
+ }
+
+ @Override
+ public FilterRepresentation getDefaultRepresentation() {
+ FilterTinyPlanetRepresentation representation = new FilterTinyPlanetRepresentation();
+ representation.setName("TinyPlanet");
+ representation.setFilterClass(ImageFilterTinyPlanet.class);
+ return representation;
}
- public void setAngle(float angle) {
- mAngle = angle;
+ @Override
+ public int getButtonId() {
+ return R.id.tinyplanetButton;
}
- public float getAngle() {
- return mAngle;
+ @Override
+ public int getTextId() {
+ return R.string.tinyplanet;
}
public boolean isNil() {
@@ -104,11 +123,38 @@ public class ImageFilterTinyPlanet extends SimpleImageFilter {
} catch (java.lang.OutOfMemoryError e) {
System.gc();
outputSize /= 2;
- Log.v(TAG, "No memory to create Full Tiny Planet create half");
+ Log.v(LOGTAG, "No memory to create Full Tiny Planet create half");
}
}
nativeApplyFilter(bitmapIn, bitmapIn.getWidth(), bitmapIn.getHeight(), mBitmapOut,
- outputSize, getParameters().getValue() / 100f, mAngle);
+ outputSize, mParameters.getZoom() / 100f, mParameters.getAngle());
+
+ if (true) {
+ // TODO(hoford): FIXME and remove this section
+ String text = "Tiny Planet Not Working";
+ int w2 = bitmapIn.getWidth() / 2;
+ int h2 = bitmapIn.getHeight() / 2;
+ Canvas c = new Canvas(bitmapIn);
+ Paint p = new Paint();
+ Rect src = new Rect(0, 0, mBitmapOut.getWidth(), mBitmapOut.getHeight());
+ Rect dst = new Rect(0, 0, bitmapIn.getWidth(), bitmapIn.getHeight());
+ c.drawBitmap(mBitmapOut, 0, 0, p);
+ float size = Math.min(w2, h2) / 4f;
+ p.setTextSize(size);
+ p.setColor(0xFF000000);
+ p.setStyle(Paint.Style.STROKE);
+ p.setStrokeWidth(20);
+ Rect bounds = new Rect();
+ p.getTextBounds(text, 0, text.length(), bounds);
+ int tw = bounds.width() / 2;
+ c.drawText(text, w2 - tw, h2, p);
+
+ p.setColor(0xFFFF0000);
+ p.setStyle(Paint.Style.FILL);
+ p.setStrokeWidth(0);
+
+ c.drawText(text, w2 - tw, h2, p);
+ }
return mBitmapOut;
}
@@ -137,7 +183,6 @@ public class ImageFilterTinyPlanet extends SimpleImageFilter {
} catch (java.lang.OutOfMemoryError e) {
System.gc();
scale /= 2;
- Log.v(TAG, "No memory to create Full Tiny Planet create half");
}
}
Canvas paddedCanvas = new Canvas(paddedBitmap);
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageTinyPlanet.java b/src/com/android/gallery3d/filtershow/imageshow/ImageTinyPlanet.java
index 82d87214f..3e95d4e15 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageTinyPlanet.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageTinyPlanet.java
@@ -17,9 +17,14 @@
package com.android.gallery3d.filtershow.imageshow;
import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.MotionEvent;
+import com.android.gallery3d.filtershow.editors.EditorTinyPlanet;
+import com.android.gallery3d.filtershow.filters.FilterCurvesRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterTinyPlanetRepresentation;
import com.android.gallery3d.filtershow.filters.ImageFilterTinyPlanet;
public class ImageTinyPlanet extends ImageShow {
@@ -31,6 +36,8 @@ public class ImageTinyPlanet extends ImageShow {
private float mCenterX = 0;
private float mCenterY = 0;
private float mStartAngle = 0;
+ private FilterTinyPlanetRepresentation mTinyPlanetRep;
+ private EditorTinyPlanet mEditorTinyPlanet;
public ImageTinyPlanet(Context context) {
super(context);
@@ -60,7 +67,6 @@ public class ImageTinyPlanet extends ImageShow {
@Override
public boolean onTouchEvent(MotionEvent event) {
- ImageFilterTinyPlanet filter = (ImageFilterTinyPlanet) getCurrentFilter();
float x = event.getX();
float y = event.getY();
mCurrentX = x;
@@ -71,15 +77,30 @@ public class ImageTinyPlanet extends ImageShow {
case (MotionEvent.ACTION_DOWN):
mTouchCenterX = x;
mTouchCenterY = y;
- mStartAngle = filter.getAngle();
+ mStartAngle = mTinyPlanetRep.getAngle();
break;
case (MotionEvent.ACTION_UP):
case (MotionEvent.ACTION_MOVE):
- filter.setAngle(mStartAngle + getCurrentTouchAngle());
+ mTinyPlanetRep.setAngle(mStartAngle + getCurrentTouchAngle());
break;
}
resetImageCaches(this);
invalidate();
+ mEditorTinyPlanet.commitLocalRepresentation();
return true;
}
+
+ public void setRepresentation(FilterTinyPlanetRepresentation tinyPlanetRep) {
+ mTinyPlanetRep = tinyPlanetRep;
+ }
+
+ public void setEditor(EditorTinyPlanet editorTinyPlanet) {
+ mEditorTinyPlanet = editorTinyPlanet;
+ }
+
+ @Override
+ public void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+ }
+
}