BasicEditor.java revision f5eedf1635eba7edfa7d41fd4e991cced978c4b2
1/*
2 * Copyright (C) 2013 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.gallery3d.filtershow.editors;
18
19import android.content.Context;
20
21import com.android.gallery3d.R;
22import com.android.gallery3d.filtershow.controller.Control;
23import com.android.gallery3d.filtershow.controller.FilterView;
24import com.android.gallery3d.filtershow.controller.Parameter;
25import com.android.gallery3d.filtershow.controller.ParameterInteger;
26import com.android.gallery3d.filtershow.filters.FilterBasicRepresentation;
27import com.android.gallery3d.filtershow.filters.FilterRepresentation;
28
29
30/**
31 * The basic editor that all the one parameter filters
32 */
33public class BasicEditor extends ParametricEditor implements ParameterInteger {
34    public static int ID = R.id.basicEditor;
35    private final String LOGTAG = "BasicEditor";
36
37    public BasicEditor() {
38        super(ID, R.layout.filtershow_default_editor, R.id.basicEditor);
39    }
40
41    protected BasicEditor(int id) {
42        super(id, R.layout.filtershow_default_editor, R.id.basicEditor);
43    }
44
45    protected BasicEditor(int id, int layoutID, int viewID) {
46        super(id, layoutID, viewID);
47    }
48
49    @Override
50    public void reflectCurrentFilter() {
51        super.reflectCurrentFilter();
52        if (getLocalRepresentation() != null && getLocalRepresentation() instanceof FilterBasicRepresentation) {
53            FilterBasicRepresentation interval = (FilterBasicRepresentation) getLocalRepresentation();
54        }
55    }
56
57    private FilterBasicRepresentation getBasicRepresentation() {
58        FilterRepresentation tmpRep = getLocalRepresentation();
59        if (tmpRep != null && tmpRep instanceof FilterBasicRepresentation) {
60            return (FilterBasicRepresentation) tmpRep;
61
62        }
63        return null;
64    }
65
66    @Override
67    public int getMaximum() {
68        FilterBasicRepresentation rep = getBasicRepresentation();
69        if (rep == null) {
70            return 0;
71        }
72        return rep.getMaximum();
73    }
74
75    @Override
76    public int getMinimum() {
77        FilterBasicRepresentation rep = getBasicRepresentation();
78        if (rep == null) {
79            return 0;
80        }
81        return rep.getMinimum();
82    }
83
84    @Override
85    public int getDefaultValue() {
86        return 0;
87    }
88
89    @Override
90    public int getValue() {
91        FilterBasicRepresentation rep = getBasicRepresentation();
92        if (rep == null) {
93            return 0;
94        }
95        return rep.getValue();
96    }
97
98    @Override
99    public String getValueString() {
100        return null;
101    }
102
103    @Override
104    public void setValue(int value) {
105        FilterBasicRepresentation rep = getBasicRepresentation();
106        if (rep == null) {
107            return;
108        }
109        rep.setValue(value);
110        commitLocalRepresentation();
111    }
112
113    @Override
114    public String getParameterName() {
115        FilterBasicRepresentation rep = getBasicRepresentation();
116        return mContext.getString(rep.getTextId());
117    }
118
119    @Override
120    public String getParameterType() {
121        return sParameterType;
122    }
123
124    @Override
125    public void setController(Control c) {
126    }
127
128    @Override
129    public void setFilterView(FilterView editor) {
130
131    }
132
133    @Override
134    public void copyFrom(Parameter src) {
135
136    }
137}
138