FilterVignetteRepresentation.java revision a93d5ee9c409e2328dcbe2326591436f8ac23146
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
19a93d5ee9c409e2328dcbe2326591436f8ac23146John Hofordimport com.android.gallery3d.R;
20a93d5ee9c409e2328dcbe2326591436f8ac23146John Hofordimport com.android.gallery3d.filtershow.editors.EditorVignette;
21a93d5ee9c409e2328dcbe2326591436f8ac23146John Hofordimport com.android.gallery3d.filtershow.imageshow.Oval;
22a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford
23a93d5ee9c409e2328dcbe2326591436f8ac23146John Hofordpublic class FilterVignetteRepresentation extends FilterBasicRepresentation implements Oval {
24a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    private static final String LOGTAG = "FilterVignetteRepresentation";
25a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    private float mCenterX = Float.NaN;
26a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    private float mCenterY;
27a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    private float mRadiusX = Float.NaN;
28a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    private float mRadiusY;
29a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford
30a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    public FilterVignetteRepresentation() {
31a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        super("Vignette", -100, 50, 100);
32a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        setShowParameterValue(true);
33a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        setPriority(FilterRepresentation.TYPE_VIGNETTE);
34a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        setTextId(R.string.vignette);
35a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        setButtonId(R.id.vignetteEditor);
36a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        setEditorId(EditorVignette.ID);
37a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        setName("Vignette");
38a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        setFilterClass(ImageFilterVignette.class);
39a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford
40a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        setMinimum(-100);
41a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        setMaximum(100);
42a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        setDefaultValue(0);
43a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    }
44a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford
45a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    @Override
46a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    public void useParametersFrom(FilterRepresentation a) {
47a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        super.useParametersFrom(a);
48a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        mCenterX = ((FilterVignetteRepresentation) a).mCenterX;
49a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        mCenterY = ((FilterVignetteRepresentation) a).mCenterY;
50a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        mRadiusX = ((FilterVignetteRepresentation) a).mRadiusX;
51a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        mRadiusY = ((FilterVignetteRepresentation) a).mRadiusY;
52a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    }
53a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford
54a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    @Override
55a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    public FilterRepresentation clone() throws CloneNotSupportedException {
56a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        FilterVignetteRepresentation representation = (FilterVignetteRepresentation) super
57a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford                .clone();
58a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        representation.mCenterX = mCenterX;
59a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        representation.mCenterY = mCenterY;
60a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford
61a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        return representation;
62a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    }
63a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford
64a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    @Override
65a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    public void setCenter(float centerX, float centerY) {
66a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        mCenterX = centerX;
67a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        mCenterY = centerY;
68a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    }
69a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford
70a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    @Override
71a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    public float getCenterX() {
72a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        return mCenterX;
73a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    }
74a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford
75a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    @Override
76a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    public float getCenterY() {
77a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        return mCenterY;
78a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    }
79a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford
80a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    @Override
81a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    public void setRadius(float radiusX, float radiusY) {
82a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        mRadiusX = radiusX;
83a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        mRadiusY = radiusY;
84a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    }
85a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford
86a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    @Override
87a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    public void setRadiusX(float radiusX) {
88a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        mRadiusX = radiusX;
89a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    }
90a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford
91a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    @Override
92a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    public void setRadiusY(float radiusY) {
93a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        mRadiusY = radiusY;
94a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    }
95a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford
96a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    @Override
97a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    public float getRadiusX() {
98a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        return mRadiusX;
99a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    }
100a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford
101a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    @Override
102a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    public float getRadiusY() {
103a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        return mRadiusY;
104a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    }
105a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford
106a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    public boolean isCenterSet() {
107a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        return mCenterX != Float.NaN;
108a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    }
109a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford
110a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    @Override
111a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    public boolean isNil() {
112a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford        return getValue() == 0;
113a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford    }
114a93d5ee9c409e2328dcbe2326591436f8ac23146John Hoford}
115