1d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford/*
2d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford * Copyright (C) 2013 The Android Open Source Project
3d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford *
4d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford * Licensed under the Apache License, Version 2.0 (the "License");
5d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford * you may not use this file except in compliance with the License.
6d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford * You may obtain a copy of the License at
7d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford *
8d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford *      http://www.apache.org/licenses/LICENSE-2.0
9d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford *
10d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford * Unless required by applicable law or agreed to in writing, software
11d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford * distributed under the License is distributed on an "AS IS" BASIS,
12d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford * See the License for the specific language governing permissions and
14d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford * limitations under the License.
15d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford */
16d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford
17d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hofordpackage com.android.gallery3d.filtershow.controller;
18d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford
19d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hofordimport android.util.Log;
20d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford
21d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hofordpublic class BasicParameterInt implements ParameterInteger {
22d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    protected String mParameterName;
23d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    protected Control mControl;
24d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    protected int mMaximum = 100;
25d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    protected int mMinimum = 0;
26d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    protected int mDefaultValue;
27d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    protected int mValue;
28d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    public final int ID;
29d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    protected FilterView mEditor;
30d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    private final String LOGTAG = "BasicParameterInt";
31d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford
32d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    @Override
33d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    public void copyFrom(Parameter src) {
34d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        if (!(src instanceof BasicParameterInt)) {
35d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford            throw new IllegalArgumentException(src.getClass().getName());
36d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        }
37d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        BasicParameterInt p = (BasicParameterInt) src;
38d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        mMaximum = p.mMaximum;
39d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        mMinimum = p.mMinimum;
40d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        mDefaultValue = p.mDefaultValue;
41d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        mValue = p.mValue;
42d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    }
43d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford
44d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    public BasicParameterInt(int id, int value) {
45d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        ID = id;
46d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        mValue = value;
47d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    }
48bc8e077e77cf6f0dda8efd8318b8a8e7eda16f61John Hoford
49bc8e077e77cf6f0dda8efd8318b8a8e7eda16f61John Hoford    public BasicParameterInt(int id, int value, int min, int max) {
50bc8e077e77cf6f0dda8efd8318b8a8e7eda16f61John Hoford        ID = id;
51bc8e077e77cf6f0dda8efd8318b8a8e7eda16f61John Hoford        mValue = value;
52bc8e077e77cf6f0dda8efd8318b8a8e7eda16f61John Hoford        mMinimum = min;
53bc8e077e77cf6f0dda8efd8318b8a8e7eda16f61John Hoford        mMaximum = max;
54bc8e077e77cf6f0dda8efd8318b8a8e7eda16f61John Hoford    }
55bc8e077e77cf6f0dda8efd8318b8a8e7eda16f61John Hoford
56d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    @Override
57d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    public String getParameterName() {
58d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        return mParameterName;
59d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    }
60d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford
61d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    @Override
62d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    public String getParameterType() {
63d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        return sParameterType;
64d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    }
65d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford
66d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    @Override
67d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    public String getValueString() {
68d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        return mParameterName + mValue;
69d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    }
70d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford
71d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    @Override
72d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    public void setController(Control control) {
73d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        mControl = control;
74d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    }
75d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford
76d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    @Override
77d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    public int getMaximum() {
78d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        return mMaximum;
79d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    }
80d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford
81d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    @Override
82d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    public int getMinimum() {
83d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        return mMinimum;
84d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    }
85d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford
86d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    @Override
87d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    public int getDefaultValue() {
88d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        return mDefaultValue;
89d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    }
90d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford
91d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    @Override
92d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    public int getValue() {
93d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        return mValue;
94d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    }
95d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford
96d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    @Override
97d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    public void setValue(int value) {
98d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        mValue = value;
99d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        if (mEditor != null) {
100d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford            mEditor.commitLocalRepresentation();
101d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        }
102d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    }
103d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford
104d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    @Override
105d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    public String toString() {
106d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        return getValueString();
107d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    }
108d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford
109d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    @Override
110d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    public void setFilterView(FilterView editor) {
111d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        mEditor = editor;
112d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    }
113d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford}
114