From d2f5fe607ee6d7b5f79862b495495e2f6024cdab Mon Sep 17 00:00:00 2001 From: John Hoford Date: Wed, 10 Apr 2013 14:58:05 -0700 Subject: [PATCH] support for simplified parameters in filter Change-Id: I623e6fb90e8175c7e5e2dfc146f927eecba29817 --- .../filtershow/controller/BasicParameterInt.java | 105 +++++++++++++++++++ .../filtershow/controller/BasicParameterStyle.java | 115 +++++++++++++++++++++ .../filtershow/controller/FilterView.java | 25 +++++ .../gallery3d/filtershow/controller/Parameter.java | 6 ++ .../filtershow/controller/ParameterSet.java | 23 +++++ .../gallery3d/filtershow/editors/BasicEditor.java | 11 ++ .../filters/FilterBasicRepresentation.java | 11 ++ 7 files changed, 296 insertions(+) create mode 100644 src/com/android/gallery3d/filtershow/controller/BasicParameterInt.java create mode 100644 src/com/android/gallery3d/filtershow/controller/BasicParameterStyle.java create mode 100644 src/com/android/gallery3d/filtershow/controller/FilterView.java create mode 100644 src/com/android/gallery3d/filtershow/controller/ParameterSet.java 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 000000000..777bc4382 --- /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 000000000..633e41ff6 --- /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 000000000..2be7f36a9 --- /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 1e8694ab7..8f4d5c0a5 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 @@ public interface Parameter { 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 000000000..6b50a4d0b --- /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 d9e97242f..987b499bf 100644 --- a/src/com/android/gallery3d/filtershow/editors/BasicEditor.java +++ b/src/com/android/gallery3d/filtershow/editors/BasicEditor.java @@ -20,6 +20,8 @@ import android.content.Context; 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 class BasicEditor extends ParametricEditor implements ParameterInteger { 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 34323c4bd..3ef1e09ed 100644 --- a/src/com/android/gallery3d/filtershow/filters/FilterBasicRepresentation.java +++ b/src/com/android/gallery3d/filtershow/filters/FilterBasicRepresentation.java @@ -18,6 +18,8 @@ package com.android.gallery3d.filtershow.filters; 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 class FilterBasicRepresentation extends FilterRepresentation implements P public String getParameterName() { return getName(); } + + @Override + public void setFilterView(FilterView editor) { + } + + @Override + public void copyFrom(Parameter src) { + useParametersFrom((FilterBasicRepresentation) src); + } } -- 2.11.0