summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Hoford <hoford@google.com>2013-07-15 17:44:31 -0700
committerJohn Hoford <hoford@google.com>2013-07-17 18:28:31 +0000
commitb1d3cca173277658c1906477af6582e573d5d98c (patch)
treece4b8f6e5ee8b2f0df19596b89653a00800031c6
parent6380a393458e362f35b6e6e25a0734c719face92 (diff)
downloadandroid_packages_apps_Snap-b1d3cca173277658c1906477af6582e573d5d98c.tar.gz
android_packages_apps_Snap-b1d3cca173277658c1906477af6582e573d5d98c.tar.bz2
android_packages_apps_Snap-b1d3cca173277658c1906477af6582e573d5d98c.zip
remove clone
Change-Id: Ia9f4c1778e06416018eeb07be657bcdd0af1496b
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterBasicRepresentation.java17
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterColorBorderRepresentation.java16
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterCurvesRepresentation.java14
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterDirectRepresentation.java13
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterDrawRepresentation.java11
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterFxRepresentation.java14
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterImageBorderRepresentation.java14
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterPointRepresentation.java11
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterRedEyeRepresentation.java13
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java16
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterTinyPlanetRepresentation.java14
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterVignetteRepresentation.java15
-rw-r--r--src/com/android/gallery3d/filtershow/pipeline/ImagePreset.java43
13 files changed, 131 insertions, 80 deletions
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterBasicRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterBasicRepresentation.java
index 368e5c029..1eebdb571 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterBasicRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterBasicRepresentation.java
@@ -48,18 +48,19 @@ public class FilterBasicRepresentation extends FilterRepresentation implements P
}
@Override
- public FilterRepresentation clone() throws CloneNotSupportedException {
- FilterBasicRepresentation representation = (FilterBasicRepresentation) super.clone();
- representation.setMinimum(getMinimum());
- representation.setMaximum(getMaximum());
- representation.setValue(getValue());
- if (mLogVerbose) {
- Log.v(LOGTAG, "cloning from <" + this + "> to <" + representation + ">");
- }
+ public FilterRepresentation copy() {
+ FilterBasicRepresentation representation = new FilterBasicRepresentation(getName(),0,0,0);
+ copyAllParameters(representation);
return representation;
}
@Override
+ protected void copyAllParameters(FilterRepresentation representation) {
+ super.copyAllParameters(representation);
+ representation.useParametersFrom(this);
+ }
+
+ @Override
public void useParametersFrom(FilterRepresentation a) {
if (a instanceof FilterBasicRepresentation) {
FilterBasicRepresentation representation = (FilterBasicRepresentation) a;
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterColorBorderRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterColorBorderRepresentation.java
index d9e211723..94eb20631 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterColorBorderRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterColorBorderRepresentation.java
@@ -40,16 +40,18 @@ public class FilterColorBorderRepresentation extends FilterRepresentation {
}
@Override
- public FilterRepresentation clone() throws CloneNotSupportedException {
- setFilterClass(ImageFilterParametricBorder.class);
- FilterColorBorderRepresentation representation = (FilterColorBorderRepresentation) super.clone();
- representation.setName(getName());
- representation.setColor(getColor());
- representation.setBorderSize(getBorderSize());
- representation.setBorderRadius(getBorderRadius());
+ public FilterRepresentation copy() {
+ FilterColorBorderRepresentation representation = new FilterColorBorderRepresentation(0,0,0);
+ copyAllParameters(representation);
return representation;
}
+ @Override
+ protected void copyAllParameters(FilterRepresentation representation) {
+ super.copyAllParameters(representation);
+ representation.useParametersFrom(this);
+ }
+
public void useParametersFrom(FilterRepresentation a) {
if (a instanceof FilterColorBorderRepresentation) {
FilterColorBorderRepresentation representation = (FilterColorBorderRepresentation) a;
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterCurvesRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterCurvesRepresentation.java
index 569ead957..a264f44fe 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterCurvesRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterCurvesRepresentation.java
@@ -33,10 +33,16 @@ public class FilterCurvesRepresentation extends FilterRepresentation {
}
@Override
- public FilterRepresentation clone() throws CloneNotSupportedException {
- FilterCurvesRepresentation rep = new FilterCurvesRepresentation();
- rep.useParametersFrom(this);
- return rep;
+ public FilterRepresentation copy() {
+ FilterCurvesRepresentation representation = new FilterCurvesRepresentation();
+ copyAllParameters(representation);
+ return representation;
+ }
+
+ @Override
+ protected void copyAllParameters(FilterRepresentation representation) {
+ super.copyAllParameters(representation);
+ representation.useParametersFrom(this);
}
@Override
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterDirectRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterDirectRepresentation.java
index 9c986a685..ac0cb7492 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterDirectRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterDirectRepresentation.java
@@ -18,6 +18,19 @@ package com.android.gallery3d.filtershow.filters;
public class FilterDirectRepresentation extends FilterRepresentation {
+ @Override
+ public FilterRepresentation copy() {
+ FilterDirectRepresentation representation = new FilterDirectRepresentation(getName());
+ copyAllParameters(representation);
+ return representation;
+ }
+
+ @Override
+ protected void copyAllParameters(FilterRepresentation representation) {
+ super.copyAllParameters(representation);
+ representation.useParametersFrom(this);
+ }
+
public FilterDirectRepresentation(String name) {
super(name);
}
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterDrawRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterDrawRepresentation.java
index dcc325d6e..977dbeac5 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterDrawRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterDrawRepresentation.java
@@ -74,12 +74,19 @@ public class FilterDrawRepresentation extends FilterRepresentation {
}
@Override
- public FilterRepresentation clone() throws CloneNotSupportedException {
- FilterDrawRepresentation representation = (FilterDrawRepresentation) super.clone();
+ public FilterRepresentation copy() {
+ FilterDrawRepresentation representation = new FilterDrawRepresentation();
+ copyAllParameters(representation);
return representation;
}
@Override
+ protected void copyAllParameters(FilterRepresentation representation) {
+ super.copyAllParameters(representation);
+ representation.useParametersFrom(this);
+ }
+
+ @Override
public boolean isNil() {
return getDrawing().isEmpty();
}
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterFxRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterFxRepresentation.java
index a7efbca20..e5a6fdd23 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterFxRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterFxRepresentation.java
@@ -43,15 +43,19 @@ public class FilterFxRepresentation extends FilterRepresentation {
}
@Override
- public synchronized FilterRepresentation clone() throws CloneNotSupportedException {
- FilterFxRepresentation representation = (FilterFxRepresentation) super.clone();
- representation.setName(getName());
- representation.setBitmapResource(getBitmapResource());
- representation.setNameResource(getNameResource());
+ public FilterRepresentation copy() {
+ FilterFxRepresentation representation = new FilterFxRepresentation(getName(),0,0);
+ copyAllParameters(representation);
return representation;
}
@Override
+ protected void copyAllParameters(FilterRepresentation representation) {
+ super.copyAllParameters(representation);
+ representation.useParametersFrom(this);
+ }
+
+ @Override
public synchronized void useParametersFrom(FilterRepresentation a) {
if (a instanceof FilterFxRepresentation) {
FilterFxRepresentation representation = (FilterFxRepresentation) a;
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterImageBorderRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterImageBorderRepresentation.java
index c32f7ccdc..f310a2be1 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterImageBorderRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterImageBorderRepresentation.java
@@ -37,13 +37,19 @@ public class FilterImageBorderRepresentation extends FilterRepresentation {
}
@Override
- public FilterRepresentation clone() throws CloneNotSupportedException {
- FilterImageBorderRepresentation representation = (FilterImageBorderRepresentation) super.clone();
- representation.setName(getName());
- representation.setDrawableResource(getDrawableResource());
+ public FilterRepresentation copy() {
+ FilterImageBorderRepresentation representation =
+ new FilterImageBorderRepresentation(mDrawableResource);
+ copyAllParameters(representation);
return representation;
}
+ @Override
+ protected void copyAllParameters(FilterRepresentation representation) {
+ super.copyAllParameters(representation);
+ representation.useParametersFrom(this);
+ }
+
public void useParametersFrom(FilterRepresentation a) {
if (a instanceof FilterImageBorderRepresentation) {
FilterImageBorderRepresentation representation = (FilterImageBorderRepresentation) a;
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterPointRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterPointRepresentation.java
index aa5289393..9bd1699d9 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterPointRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterPointRepresentation.java
@@ -31,11 +31,12 @@ public abstract class FilterPointRepresentation extends FilterRepresentation {
}
@Override
- public FilterRepresentation clone() throws CloneNotSupportedException {
- FilterPointRepresentation representation = (FilterPointRepresentation) super
- .clone();
- representation.mCandidates = (Vector<FilterPoint>) mCandidates.clone();
- return representation;
+ public abstract FilterRepresentation copy();
+
+ @Override
+ protected void copyAllParameters(FilterRepresentation representation) {
+ super.copyAllParameters(representation);
+ representation.useParametersFrom(this);
}
public boolean hasCandidates() {
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterRedEyeRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterRedEyeRepresentation.java
index 8a878415c..dd06a9760 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterRedEyeRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterRedEyeRepresentation.java
@@ -34,6 +34,19 @@ public class FilterRedEyeRepresentation extends FilterPointRepresentation {
setOverlayOnly(true);
}
+ @Override
+ public FilterRepresentation copy() {
+ FilterRedEyeRepresentation representation = new FilterRedEyeRepresentation();
+ copyAllParameters(representation);
+ return representation;
+ }
+
+ @Override
+ protected void copyAllParameters(FilterRepresentation representation) {
+ super.copyAllParameters(representation);
+ representation.useParametersFrom(this);
+ }
+
public void addRect(RectF rect, RectF bounds) {
Vector<RedEyeCandidate> intersects = new Vector<RedEyeCandidate>();
for (int i = 0; i < getCandidates().size(); i++) {
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
index e6018bb75..ca9587c28 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
@@ -25,7 +25,7 @@ import com.android.gallery3d.filtershow.editors.BasicEditor;
import java.io.IOException;
import java.util.ArrayList;
-public class FilterRepresentation implements Cloneable {
+public class FilterRepresentation {
private static final String LOGTAG = "FilterRepresentation";
private static final boolean DEBUG = false;
private String mName;
@@ -51,9 +51,13 @@ public class FilterRepresentation implements Cloneable {
mName = name;
}
- @Override
- public FilterRepresentation clone() throws CloneNotSupportedException {
- FilterRepresentation representation = (FilterRepresentation) super.clone();
+ public FilterRepresentation copy(){
+ FilterRepresentation representation = new FilterRepresentation(mName);
+ representation.useParametersFrom(this);
+ return representation;
+ }
+
+ protected void copyAllParameters(FilterRepresentation representation) {
representation.setName(getName());
representation.setFilterClass(getFilterClass());
representation.setFilterType(getFilterType());
@@ -65,10 +69,6 @@ public class FilterRepresentation implements Cloneable {
representation.setShowParameterValue(showParameterValue());
representation.mSerializationName = mSerializationName;
- if (DEBUG) {
- Log.v(LOGTAG, "cloning from <" + this + "> to <" + representation + ">");
- }
- return representation;
}
public boolean equals(FilterRepresentation representation) {
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterTinyPlanetRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterTinyPlanetRepresentation.java
index b03751e7c..be1812957 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterTinyPlanetRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterTinyPlanetRepresentation.java
@@ -37,15 +37,19 @@ public class FilterTinyPlanetRepresentation extends FilterBasicRepresentation {
}
@Override
- public FilterRepresentation clone() throws CloneNotSupportedException {
- FilterTinyPlanetRepresentation representation = (FilterTinyPlanetRepresentation) super
- .clone();
- representation.mAngle = mAngle;
- representation.setZoom(getZoom());
+ public FilterRepresentation copy() {
+ FilterTinyPlanetRepresentation representation = new FilterTinyPlanetRepresentation();
+ copyAllParameters(representation);
return representation;
}
@Override
+ protected void copyAllParameters(FilterRepresentation representation) {
+ super.copyAllParameters(representation);
+ representation.useParametersFrom(this);
+ }
+
+ @Override
public void useParametersFrom(FilterRepresentation a) {
FilterTinyPlanetRepresentation representation = (FilterTinyPlanetRepresentation) a;
super.useParametersFrom(a);
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterVignetteRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterVignetteRepresentation.java
index 06a9953b1..b666e6325 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterVignetteRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterVignetteRepresentation.java
@@ -51,16 +51,19 @@ public class FilterVignetteRepresentation extends FilterBasicRepresentation impl
}
@Override
- public FilterRepresentation clone() throws CloneNotSupportedException {
- FilterVignetteRepresentation representation = (FilterVignetteRepresentation) super
- .clone();
- representation.mCenterX = mCenterX;
- representation.mCenterY = mCenterY;
-
+ public FilterRepresentation copy() {
+ FilterVignetteRepresentation representation = new FilterVignetteRepresentation();
+ copyAllParameters(representation);
return representation;
}
@Override
+ protected void copyAllParameters(FilterRepresentation representation) {
+ super.copyAllParameters(representation);
+ representation.useParametersFrom(this);
+ }
+
+ @Override
public void setCenter(float centerX, float centerY) {
mCenterX = centerX;
mCenterY = centerY;
diff --git a/src/com/android/gallery3d/filtershow/pipeline/ImagePreset.java b/src/com/android/gallery3d/filtershow/pipeline/ImagePreset.java
index 2b9e3701f..cc4938c60 100644
--- a/src/com/android/gallery3d/filtershow/pipeline/ImagePreset.java
+++ b/src/com/android/gallery3d/filtershow/pipeline/ImagePreset.java
@@ -61,33 +61,28 @@ public class ImagePreset {
}
public ImagePreset(ImagePreset source) {
- try {
- for (int i = 0; i < source.mFilters.size(); i++) {
- FilterRepresentation representation = null;
- FilterRepresentation sourceRepresentation = source.mFilters.elementAt(i);
- if (sourceRepresentation instanceof GeometryMetadata) {
- GeometryMetadata geoData = new GeometryMetadata();
- GeometryMetadata srcGeo = (GeometryMetadata) sourceRepresentation;
- geoData.set(srcGeo);
- representation = geoData;
- } else {
- // TODO: get rid of clone()...
- representation = sourceRepresentation.clone();
- }
- addFilter(representation);
+
+ for (int i = 0; i < source.mFilters.size(); i++) {
+ FilterRepresentation representation = null;
+ FilterRepresentation sourceRepresentation = source.mFilters.elementAt(i);
+ if (sourceRepresentation instanceof GeometryMetadata) {
+ GeometryMetadata geoData = new GeometryMetadata();
+ GeometryMetadata srcGeo = (GeometryMetadata) sourceRepresentation;
+ geoData.set(srcGeo);
+ representation = geoData;
+ } else {
+ representation = sourceRepresentation.copy();
}
- } catch (java.lang.CloneNotSupportedException e) {
- Log.v(LOGTAG, "Exception trying to clone: " + e);
+ addFilter(representation);
}
+
}
public FilterRepresentation getFilterRepresentation(int position) {
FilterRepresentation representation = null;
- try {
- representation = mFilters.elementAt(position).clone();
- } catch (CloneNotSupportedException e) {
- e.printStackTrace();
- }
+
+ representation = mFilters.elementAt(position).copy();
+
return representation;
}
@@ -129,11 +124,7 @@ public class ImagePreset {
}
FilterRepresentation representation = mFilters.elementAt(position);
if (representation != null) {
- try {
- representation = representation.clone();
- } catch (CloneNotSupportedException e) {
- e.printStackTrace();
- }
+ representation = representation.copy();
}
return representation;
}