2 * Copyright (C) 2013 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.android.gallery3d.filtershow.filters;
19 import com.android.gallery3d.app.Log;
20 import com.android.gallery3d.filtershow.editors.BasicEditor;
22 public class FilterRepresentation implements Cloneable {
23 private static final String LOGTAG = "FilterRepresentation";
24 private static final boolean DEBUG = false;
26 private int mPriority = TYPE_NORMAL;
27 private Class mFilterClass;
28 private boolean mSupportsPartialRendering = false;
29 private int mTextId = 0;
30 private int mEditorId = BasicEditor.ID;
31 private int mButtonId = 0;
32 private int mOverlayId = 0;
33 private boolean mOverlayOnly = false;
34 private boolean mShowEditingControls = true;
35 private boolean mShowParameterValue = true;
36 private boolean mShowUtilityPanel = true;
38 public static final byte TYPE_BORDER = 1;
39 public static final byte TYPE_FX = 2;
40 public static final byte TYPE_WBALANCE = 3;
41 public static final byte TYPE_VIGNETTE = 4;
42 public static final byte TYPE_NORMAL = 5;
43 public static final byte TYPE_TINYPLANET = 6;
45 private FilterRepresentation mTempRepresentation = null;
47 public FilterRepresentation(String name) {
52 public FilterRepresentation clone() throws CloneNotSupportedException {
53 FilterRepresentation representation = (FilterRepresentation) super.clone();
54 representation.setName(getName());
55 representation.setPriority(getPriority());
56 representation.setFilterClass(getFilterClass());
57 representation.setSupportsPartialRendering(supportsPartialRendering());
58 representation.setTextId(getTextId());
59 representation.setEditorId(getEditorId());
60 representation.setButtonId(getButtonId());
61 representation.setOverlayId(getOverlayId());
62 representation.setOverlayOnly(getOverlayOnly());
63 representation.setShowEditingControls(showEditingControls());
64 representation.setShowParameterValue(showParameterValue());
65 representation.setShowUtilityPanel(showUtilityPanel());
66 representation.mTempRepresentation =
67 mTempRepresentation != null ? mTempRepresentation.clone() : null;
69 Log.v(LOGTAG, "cloning from <" + this + "> to <" + representation + ">");
71 return representation;
74 public boolean equals(FilterRepresentation representation) {
75 if (representation == null) {
78 if (representation.mFilterClass == representation.mFilterClass
79 && representation.mName.equalsIgnoreCase(mName)
80 && representation.mPriority == mPriority
81 && representation.mSupportsPartialRendering == mSupportsPartialRendering
82 && representation.mTextId == mTextId
83 && representation.mEditorId == mEditorId
84 && representation.mButtonId == mButtonId
85 && representation.mOverlayId == mOverlayId
86 && representation.mOverlayOnly == mOverlayOnly
87 && representation.mShowEditingControls == mShowEditingControls
88 && representation.mShowParameterValue == mShowParameterValue
89 && representation.mShowUtilityPanel == mShowUtilityPanel) {
95 public String toString() {
99 public void setName(String name) {
103 public String getName() {
107 public void setPriority(int priority) {
108 mPriority = priority;
111 public int getPriority() {
115 public boolean isNil() {
119 public boolean supportsPartialRendering() {
120 return mSupportsPartialRendering;
123 public void setSupportsPartialRendering(boolean value) {
124 mSupportsPartialRendering = value;
127 public void useParametersFrom(FilterRepresentation a) {
130 public void clearTempRepresentation() {
131 mTempRepresentation = null;
134 public synchronized void updateTempParametersFrom(FilterRepresentation representation) {
135 if (mTempRepresentation == null) {
137 mTempRepresentation = representation.clone();
138 } catch (CloneNotSupportedException e) {
142 mTempRepresentation.useParametersFrom(representation);
146 public synchronized void synchronizeRepresentation() {
147 if (mTempRepresentation != null) {
148 useParametersFrom(mTempRepresentation);
152 public boolean allowsMultipleInstances() {
156 public Class getFilterClass() {
160 public void setFilterClass(Class filterClass) {
161 mFilterClass = filterClass;
164 public boolean same(FilterRepresentation b) {
168 return getFilterClass() == b.getFilterClass();
171 public int getTextId() {
175 public void setTextId(int textId) {
179 public int getButtonId() {
183 public void setButtonId(int buttonId) {
184 mButtonId = buttonId;
187 public int getOverlayId() {
191 public void setOverlayId(int overlayId) {
192 mOverlayId = overlayId;
195 public boolean getOverlayOnly() {
199 public void setOverlayOnly(boolean value) {
200 mOverlayOnly = value;
203 final public int getEditorId() {
207 public int[] getEditorIds() {
212 public void setEditorId(int editorId) {
213 mEditorId = editorId;
216 public boolean showEditingControls() {
217 return mShowEditingControls;
220 public void setShowEditingControls(boolean showEditingControls) {
221 mShowEditingControls = showEditingControls;
224 public boolean showParameterValue() {
225 return mShowParameterValue;
228 public void setShowParameterValue(boolean showParameterValue) {
229 mShowParameterValue = showParameterValue;
232 public boolean showUtilityPanel() {
233 return mShowUtilityPanel;
236 public void setShowUtilityPanel(boolean showUtilityPanel) {
237 mShowUtilityPanel = showUtilityPanel;
240 public String getStateRepresentation() {