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.filtershow.editors.ImageOnlyEditor;
21 public class FilterFxRepresentation extends FilterRepresentation {
22 private static final String LOGTAG = "FilterFxRepresentation";
23 // TODO: When implementing serialization, we should find a unique way of
24 // specifying bitmaps / names (the resource IDs being random)
25 private int mBitmapResource = 0;
26 private int mNameResource = 0;
28 public FilterFxRepresentation(String name, int bitmapResource, int nameResource) {
30 setFilterClass(ImageFilterFx.class);
31 mBitmapResource = bitmapResource;
32 mNameResource = nameResource;
33 setFilterType(FilterRepresentation.TYPE_FX);
34 setTextId(nameResource);
35 setEditorId(ImageOnlyEditor.ID);
36 setShowParameterValue(false);
37 setSupportsPartialRendering(true);
41 public String toString() {
42 return "FilterFx: " + hashCode() + " : " + getName() + " bitmap rsc: " + mBitmapResource;
46 public synchronized FilterRepresentation clone() throws CloneNotSupportedException {
47 FilterFxRepresentation representation = (FilterFxRepresentation) super.clone();
48 representation.setName(getName());
49 representation.setBitmapResource(getBitmapResource());
50 representation.setNameResource(getNameResource());
51 return representation;
55 public synchronized void useParametersFrom(FilterRepresentation a) {
56 if (a instanceof FilterFxRepresentation) {
57 FilterFxRepresentation representation = (FilterFxRepresentation) a;
58 setName(representation.getName());
59 setSerializationName(representation.getSerializationName());
60 setBitmapResource(representation.getBitmapResource());
61 setNameResource(representation.getNameResource());
66 public boolean equals(FilterRepresentation representation) {
67 if (!super.equals(representation)) {
70 if (representation instanceof FilterFxRepresentation) {
71 FilterFxRepresentation fx = (FilterFxRepresentation) representation;
72 if (fx.mNameResource == mNameResource
73 && fx.mBitmapResource == mBitmapResource) {
81 public boolean same(FilterRepresentation representation) {
82 if (!super.same(representation)) {
85 return equals(representation);
89 public boolean allowsMultipleInstances() {
93 public int getNameResource() {
97 public void setNameResource(int nameResource) {
98 mNameResource = nameResource;
101 public int getBitmapResource() {
102 return mBitmapResource;
105 public void setBitmapResource(int bitmapResource) {
106 mBitmapResource = bitmapResource;