diff options
author | John Hoford <hoford@google.com> | 2013-02-14 15:08:28 -0800 |
---|---|---|
committer | John Hoford <hoford@google.com> | 2013-02-14 15:33:30 -0800 |
commit | 6fc682025b6cee8af6d6d48242d2591dfa4d4a55 (patch) | |
tree | 3748735a288ef83bfe1639f279b5ba5eac672487 /src | |
parent | c96c311aacb2ca7f9123244d3d2bb044e4a4b242 (diff) | |
download | android_packages_apps_Snap-6fc682025b6cee8af6d6d48242d2591dfa4d4a55.tar.gz android_packages_apps_Snap-6fc682025b6cee8af6d6d48242d2591dfa4d4a55.tar.bz2 android_packages_apps_Snap-6fc682025b6cee8af6d6d48242d2591dfa4d4a55.zip |
refactor to support many filter based on RedEye
Change-Id: I92ff19d8f750f5bf4c188129580e22990874501e
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/gallery3d/filtershow/filters/FilterPointRepresentation.java | 87 | ||||
-rw-r--r-- | src/com/android/gallery3d/filtershow/filters/FilterRedEyeRepresentation.java | 69 |
2 files changed, 91 insertions, 65 deletions
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterPointRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterPointRepresentation.java new file mode 100644 index 000000000..fc01650ae --- /dev/null +++ b/src/com/android/gallery3d/filtershow/filters/FilterPointRepresentation.java @@ -0,0 +1,87 @@ +/* + * 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.filters; + +import java.util.Vector; + +public abstract class FilterPointRepresentation extends FilterRepresentation { + private static final String LOGTAG = "FilterPointRepresentation"; + private Vector<FilterPoint> mCandidates = new Vector<FilterPoint>(); + + public FilterPointRepresentation(String type, int textid, int editorID) { + super(type); + setFilterClass(ImageFilterRedEye.class); + setPriority(FilterRepresentation.TYPE_NORMAL); + setTextId(textid); + setEditorId(editorID); + } + + @Override + public FilterRepresentation clone() throws CloneNotSupportedException { + FilterPointRepresentation representation = (FilterPointRepresentation) super + .clone(); + representation.mCandidates = (Vector<FilterPoint>) mCandidates.clone(); + return representation; + } + + public boolean hasCandidates() { + return mCandidates != null; + } + + public Vector<FilterPoint> getCandidates() { + return mCandidates; + } + + @Override + public boolean isNil() { + if (getCandidates() != null && getCandidates().size() > 0) { + return false; + } + return true; + } + + public Object getCandidate(int index) { + return this.mCandidates.get(index); + } + + public void addCandidate(FilterPoint c) { + this.mCandidates.add(c); + } + + @Override + public void useParametersFrom(FilterRepresentation a) { + if (a instanceof FilterPointRepresentation) { + FilterPointRepresentation representation = (FilterPointRepresentation) a; + mCandidates.clear(); + for (FilterPoint redEyeCandidate : representation.mCandidates) { + mCandidates.add(redEyeCandidate); + } + } + } + + public void removeCandidate(RedEyeCandidate c) { + this.mCandidates.remove(c); + } + + public void clearCandidates() { + this.mCandidates.clear(); + } + + public int getNumberOfCandidates() { + return mCandidates.size(); + } +} diff --git a/src/com/android/gallery3d/filtershow/filters/FilterRedEyeRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterRedEyeRepresentation.java index 7779211df..70d016f69 100644 --- a/src/com/android/gallery3d/filtershow/filters/FilterRedEyeRepresentation.java +++ b/src/com/android/gallery3d/filtershow/filters/FilterRedEyeRepresentation.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 The Android Open Source Project + * 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. @@ -24,80 +24,19 @@ import com.android.gallery3d.filtershow.editors.EditorRedEye; import java.util.Vector; -public class FilterRedEyeRepresentation extends FilterRepresentation { +public class FilterRedEyeRepresentation extends FilterPointRepresentation { private static final String LOGTAG = "FilterRedEyeRepresentation"; - private Vector<RedEyeCandidate> mCandidates = new Vector<RedEyeCandidate>(); public FilterRedEyeRepresentation() { - super("RedEye"); + super("RedEye",R.string.redeye,EditorRedEye.ID); setFilterClass(ImageFilterRedEye.class); - setPriority(FilterRepresentation.TYPE_NORMAL); - setTextId(R.string.redeye); - setEditorId(EditorRedEye.ID); setOverlayId(R.drawable.photoeditor_effect_redeye); } - @Override - public FilterRepresentation clone() throws CloneNotSupportedException { - FilterRedEyeRepresentation representation = (FilterRedEyeRepresentation) super - .clone(); - representation.mCandidates = (Vector<RedEyeCandidate>) mCandidates.clone(); - return representation; - } - - public boolean hasCandidates() { - return mCandidates != null; - } - - public Vector<RedEyeCandidate> getCandidates() { - return mCandidates; - } - - public void setCandidates(Vector<RedEyeCandidate> mCandidates) { - this.mCandidates = mCandidates; - } - - public RedEyeCandidate getCandidate(int index) { - return this.mCandidates.get(index); - } - - public void addCandidate(RedEyeCandidate c) { - this.mCandidates.add(c); - } - - @Override - public void useParametersFrom(FilterRepresentation a) { - if (a instanceof FilterRedEyeRepresentation) { - FilterRedEyeRepresentation representation = (FilterRedEyeRepresentation) a; - mCandidates.clear(); - for (RedEyeCandidate redEyeCandidate : representation.mCandidates) { - mCandidates.add(redEyeCandidate); - } - } - } - - public void removeCandidate(RedEyeCandidate c) { - this.mCandidates.remove(c); - } - - public void clearCandidates() { - this.mCandidates.clear(); - } - - public int getNumberOfCandidates() { - if (mCandidates == null) { - return 0; - } - return mCandidates.size(); - } - public void addRect(RectF rect, RectF bounds) { - if (!hasCandidates()) { - setCandidates(new Vector<RedEyeCandidate>()); - } Vector<RedEyeCandidate> intersects = new Vector<RedEyeCandidate>(); for (int i = 0; i < getCandidates().size(); i++) { - RedEyeCandidate r = getCandidate(i); + RedEyeCandidate r = (RedEyeCandidate) getCandidate(i); if (r.intersect(rect)) { intersects.add(r); } |