1 package com.android.gallery3d.filtershow.filters; 2 3 import android.util.Log; 4 5 import com.android.gallery3d.R; 6 import com.android.gallery3d.filtershow.ui.Spline; 7 8 /** 9 * TODO: Insert description here. (generated by hoford) 10 */ 11 public class FilterCurvesRepresentation extends FilterRepresentation { 12 private static final String LOGTAG = "FilterCurvesRepresentation"; 13 14 private Spline[] mSplines = new Spline[4]; 15 16 public FilterCurvesRepresentation() { 17 super("Curves"); 18 setFilterClass(ImageFilterCurves.class); 19 setTextId(R.string.curvesRGB); 20 setButtonId(R.id.curvesButtonRGB); 21 setOverlayId(R.drawable.filtershow_button_colors_curve); 22 setEditorId(R.id.imageCurves); 23 setShowEditingControls(false); 24 setShowParameterValue(false); 25 setShowUtilityPanel(true); 26 setSupportsPartialRendering(true); 27 reset(); 28 } 29 30 @Override 31 public FilterRepresentation clone() throws CloneNotSupportedException { 32 FilterCurvesRepresentation rep = new FilterCurvesRepresentation(); 33 rep.useParametersFrom(this); 34 return rep; 35 } 36 37 @Override 38 public void useParametersFrom(FilterRepresentation a) { 39 if (!(a instanceof FilterCurvesRepresentation)) { 40 Log.v(LOGTAG, "cannot use parameters from " + a); 41 return; 42 } 43 FilterCurvesRepresentation representation = (FilterCurvesRepresentation) a; 44 Spline[] spline = new Spline[4]; 45 for (int i = 0; i < spline.length; i++) { 46 Spline sp = representation.mSplines[i]; 47 if (sp != null) { 48 spline[i] = new Spline(sp); 49 } else { 50 spline[i] = new Spline(); 51 } 52 } 53 mSplines = spline; 54 } 55 56 public boolean isNil() { 57 for (int i = 0; i < 4; i++) { 58 if (getSpline(i) != null && !getSpline(i).isOriginal()) { 59 return false; 60 } 61 } 62 return true; 63 } 64 65 public void reset() { 66 Spline spline = new Spline(); 67 68 spline.addPoint(0.0f, 1.0f); 69 spline.addPoint(1.0f, 0.0f); 70 71 for (int i = 0; i < 4; i++) { 72 mSplines[i] = new Spline(spline); 73 } 74 } 75 76 public void setSpline(int splineIndex, Spline s) { 77 mSplines[splineIndex] = s; 78 } 79 public Spline getSpline(int splineIndex) { 80 return mSplines[splineIndex]; 81 } 82 } 83