support for simplified parameters in filter

Change-Id: I623e6fb90e8175c7e5e2dfc146f927eecba29817
diff --git a/src/com/android/gallery3d/filtershow/controller/BasicParameterInt.java b/src/com/android/gallery3d/filtershow/controller/BasicParameterInt.java
new file mode 100644
index 0000000..777bc43
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/controller/BasicParameterInt.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2013 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.controller;
+
+import android.util.Log;
+
+public class BasicParameterInt implements ParameterInteger {
+    protected String mParameterName;
+    protected Control mControl;
+    protected int mMaximum = 100;
+    protected int mMinimum = 0;
+    protected int mDefaultValue;
+    protected int mValue;
+    public final int ID;
+    protected FilterView mEditor;
+    private final String LOGTAG = "BasicParameterInt";
+
+    @Override
+    public void copyFrom(Parameter src) {
+        if (!(src instanceof BasicParameterInt)) {
+            throw new IllegalArgumentException(src.getClass().getName());
+        }
+        BasicParameterInt p = (BasicParameterInt) src;
+        mMaximum = p.mMaximum;
+        mMinimum = p.mMinimum;
+        mDefaultValue = p.mDefaultValue;
+        mValue = p.mValue;
+    }
+
+    public BasicParameterInt(int id, int value) {
+        ID = id;
+        mValue = value;
+    }
+    @Override
+    public String getParameterName() {
+        return mParameterName;
+    }
+
+    @Override
+    public String getParameterType() {
+        return sParameterType;
+    }
+
+    @Override
+    public String getValueString() {
+        return mParameterName + mValue;
+    }
+
+    @Override
+    public void setController(Control control) {
+        mControl = control;
+    }
+
+    @Override
+    public int getMaximum() {
+        return mMaximum;
+    }
+
+    @Override
+    public int getMinimum() {
+        return mMinimum;
+    }
+
+    @Override
+    public int getDefaultValue() {
+        return mDefaultValue;
+    }
+
+    @Override
+    public int getValue() {
+        return mValue;
+    }
+
+    @Override
+    public void setValue(int value) {
+        mValue = value;
+        if (mEditor != null) {
+            mEditor.commitLocalRepresentation();
+        }
+    }
+
+    @Override
+    public String toString() {
+        return getValueString();
+    }
+
+    @Override
+    public void setFilterView(FilterView editor) {
+        mEditor = editor;
+    }
+}
diff --git a/src/com/android/gallery3d/filtershow/controller/BasicParameterStyle.java b/src/com/android/gallery3d/filtershow/controller/BasicParameterStyle.java
new file mode 100644
index 0000000..633e41f
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/controller/BasicParameterStyle.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2013 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.controller;
+
+import android.content.Context;
+import android.util.Log;
+
+import com.android.gallery3d.filtershow.cache.RenderingRequestCaller;
+
+public class BasicParameterStyle implements ParameterStyles {
+    protected String mParameterName;
+    protected int mSelectedStyle;
+    protected int mNumberOfStyles;
+    protected int mDefaultStyle = 0;
+    protected Control mControl;
+    protected FilterView mEditor;
+    public final int ID;
+    private final String LOGTAG = "BasicParameterStyle";
+
+    @Override
+    public void copyFrom(Parameter src) {
+        if (!(src instanceof BasicParameterStyle)) {
+            throw new IllegalArgumentException(src.getClass().getName());
+        }
+        BasicParameterStyle p = (BasicParameterStyle) src;
+        mNumberOfStyles = p.mNumberOfStyles;
+        mSelectedStyle = p.mSelectedStyle;
+        mDefaultStyle = p.mDefaultStyle;
+    }
+
+    public BasicParameterStyle(int id, int numberOfStyles) {
+        ID = id;
+        mNumberOfStyles = numberOfStyles;
+    }
+
+    @Override
+    public String getParameterName() {
+        return mParameterName;
+    }
+
+    @Override
+    public String getParameterType() {
+        return sParameterType;
+    }
+
+    @Override
+    public String getValueString() {
+        return mParameterName + mSelectedStyle;
+    }
+
+    @Override
+    public void setController(Control control) {
+        mControl = control;
+    }
+
+    @Override
+    public int getNumberOfStyles() {
+        return mNumberOfStyles;
+    }
+
+    @Override
+    public int getDefaultSelected() {
+        return mDefaultStyle;
+    }
+
+    @Override
+    public int getSelected() {
+        return mSelectedStyle;
+    }
+
+    @Override
+    public void setSelected(int selectedStyle) {
+        mSelectedStyle = selectedStyle;
+        if (mEditor != null) {
+            mEditor.commitLocalRepresentation();
+        }
+    }
+
+    @Override
+    public void getIcon(int index, RenderingRequestCaller caller) {
+        Log.v(LOGTAG, "############ " + ID + " getIcon " + index);
+
+        mEditor.computeIcon(index, caller);
+    }
+
+    @Override
+    public String getStyleTitle(int index, Context context) {
+        return "";
+    }
+
+    @Override
+    public String toString() {
+        return getValueString();
+    }
+
+    @Override
+    public void setFilterView(FilterView editor) {
+        mEditor = editor;
+    }
+
+}
diff --git a/src/com/android/gallery3d/filtershow/controller/FilterView.java b/src/com/android/gallery3d/filtershow/controller/FilterView.java
new file mode 100644
index 0000000..2be7f36
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/controller/FilterView.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2013 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.controller;
+
+import com.android.gallery3d.filtershow.cache.RenderingRequestCaller;
+
+public interface FilterView {
+    public void computeIcon(int index, RenderingRequestCaller caller);
+
+    public void commitLocalRepresentation();
+}
diff --git a/src/com/android/gallery3d/filtershow/controller/Parameter.java b/src/com/android/gallery3d/filtershow/controller/Parameter.java
index 1e8694a..8f4d5c0 100644
--- a/src/com/android/gallery3d/filtershow/controller/Parameter.java
+++ b/src/com/android/gallery3d/filtershow/controller/Parameter.java
@@ -16,6 +16,8 @@
 
 package com.android.gallery3d.filtershow.controller;
 
+import com.android.gallery3d.filtershow.editors.Editor;
+
 public interface Parameter {
     String getParameterName();
 
@@ -24,4 +26,8 @@
     String getValueString();
 
     public void setController(Control c);
+
+    public void setFilterView(FilterView editor);
+
+    public void copyFrom(Parameter src);
 }
diff --git a/src/com/android/gallery3d/filtershow/controller/ParameterSet.java b/src/com/android/gallery3d/filtershow/controller/ParameterSet.java
new file mode 100644
index 0000000..6b50a4d
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/controller/ParameterSet.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2013 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.controller;
+
+public interface ParameterSet {
+    int getNumberOfParameters();
+
+    Parameter getFilterParameter(int index);
+}
diff --git a/src/com/android/gallery3d/filtershow/editors/BasicEditor.java b/src/com/android/gallery3d/filtershow/editors/BasicEditor.java
index d9e9724..987b499 100644
--- a/src/com/android/gallery3d/filtershow/editors/BasicEditor.java
+++ b/src/com/android/gallery3d/filtershow/editors/BasicEditor.java
@@ -20,6 +20,8 @@
 
 import com.android.gallery3d.R;
 import com.android.gallery3d.filtershow.controller.Control;
+import com.android.gallery3d.filtershow.controller.FilterView;
+import com.android.gallery3d.filtershow.controller.Parameter;
 import com.android.gallery3d.filtershow.controller.ParameterInteger;
 import com.android.gallery3d.filtershow.filters.FilterBasicRepresentation;
 import com.android.gallery3d.filtershow.filters.FilterRepresentation;
@@ -126,4 +128,13 @@
     public void setController(Control c) {
     }
 
+    @Override
+    public void setFilterView(FilterView editor) {
+
+    }
+
+    @Override
+    public void copyFrom(Parameter src) {
+
+    }
 }
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterBasicRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterBasicRepresentation.java
index 34323c4..3ef1e09 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterBasicRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterBasicRepresentation.java
@@ -18,6 +18,8 @@
 
 import com.android.gallery3d.app.Log;
 import com.android.gallery3d.filtershow.controller.Control;
+import com.android.gallery3d.filtershow.controller.FilterView;
+import com.android.gallery3d.filtershow.controller.Parameter;
 import com.android.gallery3d.filtershow.controller.ParameterInteger;
 
 public class FilterBasicRepresentation extends FilterRepresentation implements ParameterInteger {
@@ -154,4 +156,13 @@
     public String getParameterName() {
         return getName();
     }
+
+    @Override
+    public void setFilterView(FilterView editor) {
+    }
+
+    @Override
+    public void copyFrom(Parameter src) {
+        useParametersFrom((FilterBasicRepresentation) src);
+    }
 }