1a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford/*
2a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford * Copyright (C) 2012 The Android Open Source Project
3a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford *
4a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford * Licensed under the Apache License, Version 2.0 (the "License");
5a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford * you may not use this file except in compliance with the License.
6a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford * You may obtain a copy of the License at
7a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford *
8a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford *      http://www.apache.org/licenses/LICENSE-2.0
9a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford *
10a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford * Unless required by applicable law or agreed to in writing, software
11a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford * distributed under the License is distributed on an "AS IS" BASIS,
12a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford * See the License for the specific language governing permissions and
14a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford * limitations under the License.
15a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford */
16a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford
17a93d5ee9c409e2328dcbe2326591436f8ac23146John Hofordpackage com.android.gallery3d.filtershow.filters;
18a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford
1937f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hofordimport android.util.JsonReader;
2037f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hofordimport android.util.JsonWriter;
2137f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford
22a93d5ee9c409e2328dcbe2326591436f8ac23146John Hofordimport com.android.gallery3d.R;
2337f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hofordimport com.android.gallery3d.filtershow.controller.BasicParameterInt;
2437f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hofordimport com.android.gallery3d.filtershow.controller.Parameter;
25a93d5ee9c409e2328dcbe2326591436f8ac23146John Hofordimport com.android.gallery3d.filtershow.editors.EditorVignette;
26a93d5ee9c409e2328dcbe2326591436f8ac23146John Hofordimport com.android.gallery3d.filtershow.imageshow.Oval;
27a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford
2837f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hofordimport java.io.IOException;
2937f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford
3037f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hofordpublic class FilterVignetteRepresentation extends FilterRepresentation implements Oval {
31a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    private static final String LOGTAG = "FilterVignetteRepresentation";
3237f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford
3337f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    private float mCenterX = .5f;
3437f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    private float mCenterY = .5f;
3537f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    private float mRadiusX = .5f;
3637f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    private float mRadiusY = .5f;
3737f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    public static final int MODE_VIGNETTE = 0;
3837f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    public static final int MODE_EXPOSURE = 1;
3937f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    public static final int MODE_SATURATION = 2;
4037f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    public static final int MODE_CONTRAST = 3;
4137f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    public static final int MODE_FALLOFF = 4;
4237f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    private static int MIN = -100;
4337f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    private static int MAX = 100;
4437f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    private static int MAXFALLOF = 200;
4537f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford
46edf4b095a1d904df6c02d49e3ec575c5c3c9c749nicolasroard    private BasicParameterInt mParamVignette = new BasicParameterInt(MODE_VIGNETTE, 50, MIN, MAX);
4737f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    private BasicParameterInt mParamExposure = new BasicParameterInt(MODE_EXPOSURE, 0, MIN, MAX);
4837f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    private BasicParameterInt mParamSaturation = new BasicParameterInt(MODE_SATURATION, 0, MIN, MAX);
4937f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    private BasicParameterInt mParamContrast = new BasicParameterInt(MODE_CONTRAST, 0, MIN, MAX);
5037f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    private BasicParameterInt mParamFalloff = new BasicParameterInt(MODE_FALLOFF, 40, 0, MAXFALLOF);
5137f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    private BasicParameterInt[] mAllParam = {
5237f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford            mParamVignette,
5337f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford            mParamExposure,
5437f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford            mParamSaturation,
5537f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford            mParamContrast,
5637f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford            mParamFalloff};
5737f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    private int mParameterMode;
58a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford
59a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    public FilterVignetteRepresentation() {
6037f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        super("Vignette");
61afa8ed9d46e760d4b0c0331cfcb4bb49ef6ba280John Hoford        setSerializationName("VIGNETTE");
62a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        setShowParameterValue(true);
633cb106ddd7ad0f8494ac9c7a33660831c1694295Ruben Brunk        setFilterType(FilterRepresentation.TYPE_VIGNETTE);
64a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        setTextId(R.string.vignette);
65a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        setEditorId(EditorVignette.ID);
66a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        setName("Vignette");
67a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        setFilterClass(ImageFilterVignette.class);
68a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    }
69a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford
70a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    @Override
71a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    public void useParametersFrom(FilterRepresentation a) {
72a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        super.useParametersFrom(a);
7337f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        FilterVignetteRepresentation rep = (FilterVignetteRepresentation) a;
7437f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        mCenterX = rep.mCenterX;
7537f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        mCenterY = rep.mCenterY;
7637f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        mRadiusX = rep.mRadiusX;
7737f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        mRadiusY = rep.mRadiusY;
7837f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        mParamVignette.setValue(rep.mParamVignette.getValue());
7937f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        mParamExposure.setValue(rep.mParamExposure.getValue());
8037f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        mParamSaturation.setValue(rep.mParamSaturation.getValue());
8137f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        mParamContrast.setValue(rep.mParamContrast.getValue());
8237f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        mParamFalloff.setValue(rep.mParamFalloff.getValue());
8337f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    }
8437f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford
8537f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    public int getValue(int mode) {
8637f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        return mAllParam[mode].getValue();
8737f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    }
8837f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford
8937f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    public void setValue(int mode, int value) {
9037f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        mAllParam[mode].setValue(value);
91a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    }
92a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford
93a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    @Override
943cd6fc8e632e406628b5977ee47c191523552500nicolasroard    public String toString() {
953cd6fc8e632e406628b5977ee47c191523552500nicolasroard        return getName() + " : " + mCenterX + ", " + mCenterY + " radius: " + mRadiusX;
963cd6fc8e632e406628b5977ee47c191523552500nicolasroard    }
973cd6fc8e632e406628b5977ee47c191523552500nicolasroard
983cd6fc8e632e406628b5977ee47c191523552500nicolasroard    @Override
993f0034140c165b86fbaf5c0369f39431548308e9John Hoford    public FilterRepresentation copy() {
1003f0034140c165b86fbaf5c0369f39431548308e9John Hoford        FilterVignetteRepresentation representation = new FilterVignetteRepresentation();
1013f0034140c165b86fbaf5c0369f39431548308e9John Hoford        copyAllParameters(representation);
102a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        return representation;
103a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    }
104a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford
105a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    @Override
1063f0034140c165b86fbaf5c0369f39431548308e9John Hoford    protected void copyAllParameters(FilterRepresentation representation) {
1073f0034140c165b86fbaf5c0369f39431548308e9John Hoford        super.copyAllParameters(representation);
1083f0034140c165b86fbaf5c0369f39431548308e9John Hoford        representation.useParametersFrom(this);
1093f0034140c165b86fbaf5c0369f39431548308e9John Hoford    }
1103f0034140c165b86fbaf5c0369f39431548308e9John Hoford
1113f0034140c165b86fbaf5c0369f39431548308e9John Hoford    @Override
112a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    public void setCenter(float centerX, float centerY) {
113a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        mCenterX = centerX;
114a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        mCenterY = centerY;
115a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    }
116a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford
117a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    @Override
118a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    public float getCenterX() {
119a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        return mCenterX;
120a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    }
121a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford
122a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    @Override
123a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    public float getCenterY() {
124a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        return mCenterY;
125a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    }
126a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford
127a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    @Override
128a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    public void setRadius(float radiusX, float radiusY) {
129a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        mRadiusX = radiusX;
130a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        mRadiusY = radiusY;
131a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    }
132a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford
133a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    @Override
134a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    public void setRadiusX(float radiusX) {
135a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        mRadiusX = radiusX;
136a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    }
137a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford
138a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    @Override
139a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    public void setRadiusY(float radiusY) {
140a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        mRadiusY = radiusY;
141a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    }
142a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford
143a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    @Override
144a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    public float getRadiusX() {
145a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        return mRadiusX;
146a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    }
147a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford
148a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    @Override
149a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    public float getRadiusY() {
150a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        return mRadiusY;
151a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    }
152a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford
153a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    public boolean isCenterSet() {
154a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        return mCenterX != Float.NaN;
155a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    }
156a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford
157a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    @Override
158a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    public boolean isNil() {
15937f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        return false;
160a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    }
161afa8ed9d46e760d4b0c0331cfcb4bb49ef6ba280John Hoford
1628e33c2b402983070eb0cc9ace16ecfa4b9728447nicolasroard    @Override
1638e33c2b402983070eb0cc9ace16ecfa4b9728447nicolasroard    public boolean equals(FilterRepresentation representation) {
1648e33c2b402983070eb0cc9ace16ecfa4b9728447nicolasroard        if (!super.equals(representation)) {
1658e33c2b402983070eb0cc9ace16ecfa4b9728447nicolasroard            return false;
1668e33c2b402983070eb0cc9ace16ecfa4b9728447nicolasroard        }
1678e33c2b402983070eb0cc9ace16ecfa4b9728447nicolasroard        if (representation instanceof FilterVignetteRepresentation) {
1688e33c2b402983070eb0cc9ace16ecfa4b9728447nicolasroard            FilterVignetteRepresentation rep = (FilterVignetteRepresentation) representation;
16937f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford            for (int i = 0; i < mAllParam.length; i++) {
17037f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford                if (mAllParam[i].getValue() != rep.mAllParam[i].getValue())
17137f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford                    return false;
17237f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford            }
1738e33c2b402983070eb0cc9ace16ecfa4b9728447nicolasroard            if (rep.getCenterX() == getCenterX()
1748e33c2b402983070eb0cc9ace16ecfa4b9728447nicolasroard                    && rep.getCenterY() == getCenterY()
1758e33c2b402983070eb0cc9ace16ecfa4b9728447nicolasroard                    && rep.getRadiusX() == getRadiusX()
1768e33c2b402983070eb0cc9ace16ecfa4b9728447nicolasroard                    && rep.getRadiusY() == getRadiusY()) {
1778e33c2b402983070eb0cc9ace16ecfa4b9728447nicolasroard                return true;
1788e33c2b402983070eb0cc9ace16ecfa4b9728447nicolasroard            }
1798e33c2b402983070eb0cc9ace16ecfa4b9728447nicolasroard        }
1808e33c2b402983070eb0cc9ace16ecfa4b9728447nicolasroard        return false;
1818e33c2b402983070eb0cc9ace16ecfa4b9728447nicolasroard    }
1828e33c2b402983070eb0cc9ace16ecfa4b9728447nicolasroard
18337f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    private static final String ELLIPSE = "ellipse";
18437f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    private static final String ARGS = "adjust";
18537f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    @Override
18637f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    public void serializeRepresentation(JsonWriter writer) throws IOException {
18737f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        writer.beginObject();
18837f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        writer.name(ELLIPSE);
18937f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        writer.beginArray();
19037f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        writer.value(mCenterX);
19137f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        writer.value(mCenterY);
19237f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        writer.value(mRadiusX);
19337f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        writer.value(mRadiusY);
19437f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        writer.endArray();
19537f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford
19637f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        writer.name(ARGS);
19737f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        writer.beginArray();
19837f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        writer.value(mParamVignette.getValue());
19937f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        writer.value(mParamExposure.getValue());
20037f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        writer.value(mParamSaturation.getValue());
20137f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        writer.value(mParamContrast.getValue());
20237f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        writer.value(mParamFalloff.getValue());
20337f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        writer.endArray();
20437f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        writer.endObject();
20537f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    }
20637f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford
20737f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford
20837f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    @Override
20937f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    public void deSerializeRepresentation(JsonReader sreader) throws IOException {
21037f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        sreader.beginObject();
21137f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford
21237f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        while (sreader.hasNext()) {
21337f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford            String name = sreader.nextName();
21437f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford            if (name.startsWith(ELLIPSE)) {
21537f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford                sreader.beginArray();
21637f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford                sreader.hasNext();
21737f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford                mCenterX = (float) sreader.nextDouble();
21837f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford                sreader.hasNext();
21937f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford                mCenterY = (float) sreader.nextDouble();
22037f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford                sreader.hasNext();
22137f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford                mRadiusX = (float) sreader.nextDouble();
22237f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford                sreader.hasNext();
22337f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford                mRadiusY = (float) sreader.nextDouble();
22437f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford                sreader.hasNext();
22537f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford                sreader.endArray();
22637f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford            } else if (name.startsWith(ARGS)) {
22737f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford                sreader.beginArray();
22837f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford                sreader.hasNext();
22937f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford                mParamVignette.setValue(sreader.nextInt());
23037f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford                sreader.hasNext();
23137f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford                mParamExposure.setValue(sreader.nextInt());
23237f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford                sreader.hasNext();
23337f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford                mParamSaturation.setValue(sreader.nextInt());
23437f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford                sreader.hasNext();
23537f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford                mParamContrast.setValue(sreader.nextInt());
23637f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford                sreader.hasNext();
23737f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford                mParamFalloff.setValue(sreader.nextInt());
23837f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford                sreader.hasNext();
23937f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford                sreader.endArray();
24037f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford            } else  {
24137f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford                sreader.skipValue();
242afa8ed9d46e760d4b0c0331cfcb4bb49ef6ba280John Hoford            }
243afa8ed9d46e760d4b0c0331cfcb4bb49ef6ba280John Hoford        }
24437f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        sreader.endObject();
24537f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    }
24637f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    public int getParameterMode() {
24737f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        return mParameterMode;
248afa8ed9d46e760d4b0c0331cfcb4bb49ef6ba280John Hoford    }
24937f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford
25037f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    public void setParameterMode(int parameterMode) {
25137f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        mParameterMode = parameterMode;
25237f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    }
25337f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford
25437f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    public int getCurrentParameter() {
25537f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        return getValue(mParameterMode);
25637f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    }
25737f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford
25837f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    public void setCurrentParameter(int value) {
25937f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        setValue(mParameterMode, value);
26037f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    }
26137f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford
26237f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    public BasicParameterInt getFilterParameter(int index) {
26337f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford        return mAllParam[index];
26437f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford    }
26537f8e432f4eb94d0ab483bfdc2a1fa024508e85fJohn Hoford
266a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford}
267