public FilterRepresentation createFilterFromName(String name) {
try {
- return mRepresentationLookup.get(name).clone();
+ return mRepresentationLookup.get(name).copy();
} catch (Exception e) {
Log.v(LOGTAG, "unable to generate a filter representation for \"" + name + "\"");
e.printStackTrace();
}
@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;
}
@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;
}
@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
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);
}
}
@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();
}
}
@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;
}
@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;
}
@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() {
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++) {
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;
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());
representation.setShowParameterValue(showParameterValue());
representation.mSerializationName = mSerializationName;
- if (DEBUG) {
- Log.v(LOGTAG, "cloning from <" + this + "> to <" + representation + ">");
- }
- return representation;
}
public boolean equals(FilterRepresentation representation) {
}
@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);
}
@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;
public HistoryItem(ImagePreset preset, FilterRepresentation representation) {
mImagePreset = new ImagePreset(preset);
- try {
- if (representation != null) {
- mFilterRepresentation = representation.clone();
- }
- } catch (CloneNotSupportedException e) {
- Log.e(LOGTAG, "clone not supported", e);
+ if (representation != null) {
+ mFilterRepresentation = representation.copy();
}
}
import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.RectF;
-import android.util.Log;
import com.android.gallery3d.filtershow.cache.ImageLoader;
import com.android.gallery3d.filtershow.crop.CropExtras;
import com.android.gallery3d.filtershow.filters.FilterRepresentation;
import com.android.gallery3d.filtershow.filters.ImageFilterGeometry;
-import java.util.Arrays;
import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.List;
public class GeometryMetadata extends FilterRepresentation {
public static final String SERIALIZATION_NAME = "GEOM";
}
@Override
- public FilterRepresentation clone() throws CloneNotSupportedException {
- GeometryMetadata representation = (GeometryMetadata) super.clone();
- representation.useParametersFrom(this);
+ public FilterRepresentation copy() {
+ GeometryMetadata representation = new GeometryMetadata();
+ copyAllParameters(representation);
return representation;
}
+ @Override
+ protected void copyAllParameters(FilterRepresentation representation) {
+ super.copyAllParameters(representation);
+ representation.useParametersFrom(this);
+ }
+
private static final String[] sParams = {
"Name", "ScaleFactor", "Rotation", "StraightenRotation", "CropBoundsLeft",
"CropBoundsTop", "CropBoundsRight", "CropBoundsBottom", "PhotoBoundsLeft",
}
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;
}
}
FilterRepresentation representation = mFilters.elementAt(position);
if (representation != null) {
- try {
- representation = representation.clone();
- } catch (CloneNotSupportedException e) {
- e.printStackTrace();
- }
+ representation = representation.copy();
}
return representation;
}