OSDN Git Service

refactor quality to be int
authorJohn Hoford <hoford@google.com>
Tue, 12 Feb 2013 19:55:50 +0000 (11:55 -0800)
committerJohn Hoford <hoford@google.com>
Tue, 12 Feb 2013 20:11:35 +0000 (12:11 -0800)
Change-Id: I0470abdbe75cf48c5228e80b9dc060ae6f3d8bbd

res/menu/filtershow_menu_draw.xml
res/values/filtershow_strings.xml
src/com/android/gallery3d/filtershow/filters/FilterDrawRepresentation.java
src/com/android/gallery3d/filtershow/presets/ImagePreset.java

index 9455f70..2960c1f 100644 (file)
@@ -33,6 +33,9 @@
         <item
             android:id="@+id/draw_menu_color"
             android:title="@string/draw_color"/>
+        <item
+            android:id="@+id/draw_menu_clear"
+            android:title="@string/draw_clear"/>
     </group>
 
 </menu>
\ No newline at end of file
index cf6e80d..66fb390 100644 (file)
     <string name="draw_style_brush_spatter">Marker</string>
     <!--  Label for the Spatter brush style of drawing in [CHAR LIMIT=14] -->
     <string name="draw_style_brush_marker">Spatter</string>
+    <!--  Label for the removing drawing from screen [CHAR LIMIT=14] -->
+    <string name="draw_clear">Clear</string>
 
     <!--  Label for the select the color [CHAR LIMIT=30] -->
     <string name="color_pick_select">Choose custom color</string>
index b8fa0a3..b2e1ed3 100644 (file)
@@ -17,6 +17,8 @@
 package com.android.gallery3d.filtershow.filters;
 
 import android.graphics.Path;
+import android.util.Log;
+
 import com.android.gallery3d.R;
 import com.android.gallery3d.filtershow.editors.EditorDraw;
 
@@ -30,7 +32,7 @@ public class FilterDrawRepresentation extends FilterRepresentation {
         public Path mPath;
         public float mRadius;
         public int mColor;
-
+        public int noPoints = 0;
         @Override
         public String toString() {
             return "stroke(" + mType + ", path(" + (mPath) + "), " + mRadius + " , "
@@ -57,7 +59,8 @@ public class FilterDrawRepresentation extends FilterRepresentation {
     @Override
     public String toString() {
         return getName() + " : strokes=" + mDrawing.size()
-                + ((mCurrent == null) ? " no current " : ("current=" + mCurrent.mType));
+                + ((mCurrent == null) ? " no current "
+                        : ("draw=" + mCurrent.mType + " " + mCurrent.noPoints));
     }
 
     public Vector<StrokeData> getDrawing() {
@@ -95,6 +98,8 @@ public class FilterDrawRepresentation extends FilterRepresentation {
             } catch (CloneNotSupportedException e) {
                 e.printStackTrace();
             }
+        } else {
+            Log.v(LOGTAG, "cannot use parameters from " + a);
         }
     }
 
@@ -104,8 +109,18 @@ public class FilterDrawRepresentation extends FilterRepresentation {
             return false;
         }
         if (representation instanceof FilterDrawRepresentation) {
-            // FIXME!
-            return true;
+            FilterDrawRepresentation fdRep = (FilterDrawRepresentation) representation;
+            if (fdRep.mDrawing.size() != mDrawing.size())
+                return false;
+            if (fdRep.mCurrent == null && mCurrent.mPath == null) {
+                return true;
+            }
+            if (fdRep.mCurrent != null && mCurrent.mPath != null) {
+                if (fdRep.mCurrent.noPoints == mCurrent.noPoints) {
+                    return true;
+                }
+                return false;
+            }
         }
         return false;
     }
@@ -117,14 +132,17 @@ public class FilterDrawRepresentation extends FilterRepresentation {
         mCurrent.mType = type;
         mCurrent.mPath = new Path();
         mCurrent.mPath.moveTo(x, y);
+        mCurrent.noPoints = 0;
     }
 
     public void addPoint(float x, float y) {
+        mCurrent.noPoints++;
         mCurrent.mPath.lineTo(x, y);
     }
 
     public void endSection(float x, float y) {
         mCurrent.mPath.lineTo(x, y);
+        mCurrent.noPoints++;
         mDrawing.add(mCurrent);
         mCurrent = null;
     }
index c7d14e8..adea9de 100644 (file)
@@ -35,7 +35,10 @@ public class ImagePreset {
 
     private FilterRepresentation mBorder = null;
     private float mScaleFactor = 1.0f;
-    private boolean mIsHighQuality = false;
+    public static final int QUALITY_ICON = 0;
+    public static final int QUALITY_PREVIEW = 1;
+    public static final int QUALITY_FINAL = 2;
+    private int mQuality = QUALITY_PREVIEW;
     private ImageLoader mImageLoader = null;
 
     private Vector<FilterRepresentation> mFilters = new Vector<FilterRepresentation>();
@@ -380,14 +383,14 @@ public class ImagePreset {
     public Bitmap applyGeometry(Bitmap bitmap) {
         // Apply any transform -- 90 rotate, flip, straighten, crop
         // Returns a new bitmap.
-        return mGeoData.apply(bitmap, mScaleFactor, mIsHighQuality);
+        return mGeoData.apply(bitmap, mScaleFactor, mQuality);
     }
 
     public Bitmap applyBorder(Bitmap bitmap) {
         if (mBorder != null && mDoApplyGeometry) {
             ImageFilter filter = FiltersManager.getManager().getFilterForRepresentation(mBorder);
             filter.useRepresentation(mBorder);
-            bitmap = filter.apply(bitmap, mScaleFactor, mIsHighQuality);
+            bitmap = filter.apply(bitmap, mScaleFactor, mQuality);
         }
         return bitmap;
     }
@@ -408,7 +411,7 @@ public class ImagePreset {
                 }
                 ImageFilter filter = FiltersManager.getManager().getFilterForRepresentation(representation);
                 filter.useRepresentation(representation);
-                bitmap = filter.apply(bitmap, mScaleFactor, mIsHighQuality);
+                bitmap = filter.apply(bitmap, mScaleFactor, mQuality);
             }
         }
 
@@ -429,12 +432,12 @@ public class ImagePreset {
         return mScaleFactor;
     }
 
-    public boolean isHighQuality() {
-        return mIsHighQuality;
+    public int getQuality() {
+        return mQuality;
     }
 
-    public void setIsHighQuality(boolean value) {
-        mIsHighQuality = value;
+    public void setQuality(int value) {
+        mQuality = value;
     }
 
     public void setScaleFactor(float value) {