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.controller;
18
19import android.util.Log;
20
21public class BasicParameterInt implements ParameterInteger {
22    protected String mParameterName;
23    protected Control mControl;
24    protected int mMaximum = 100;
25    protected int mMinimum = 0;
26    protected int mDefaultValue;
27    protected int mValue;
28    public final int ID;
29    protected FilterView mEditor;
30    private final String LOGTAG = "BasicParameterInt";
31
32    @Override
33    public void copyFrom(Parameter src) {
34        if (!(src instanceof BasicParameterInt)) {
35            throw new IllegalArgumentException(src.getClass().getName());
36        }
37        BasicParameterInt p = (BasicParameterInt) src;
38        mMaximum = p.mMaximum;
39        mMinimum = p.mMinimum;
40        mDefaultValue = p.mDefaultValue;
41        mValue = p.mValue;
42    }
43
44    public BasicParameterInt(int id, int value) {
45        ID = id;
46        mValue = value;
47    }
48
49    public BasicParameterInt(int id, int value, int min, int max) {
50        ID = id;
51        mValue = value;
52        mMinimum = min;
53        mMaximum = max;
54    }
55
56    @Override
57    public String getParameterName() {
58        return mParameterName;
59    }
60
61    @Override
62    public String getParameterType() {
63        return sParameterType;
64    }
65
66    @Override
67    public String getValueString() {
68        return mParameterName + mValue;
69    }
70
71    @Override
72    public void setController(Control control) {
73        mControl = control;
74    }
75
76    @Override
77    public int getMaximum() {
78        return mMaximum;
79    }
80
81    @Override
82    public int getMinimum() {
83        return mMinimum;
84    }
85
86    @Override
87    public int getDefaultValue() {
88        return mDefaultValue;
89    }
90
91    @Override
92    public int getValue() {
93        return mValue;
94    }
95
96    @Override
97    public void setValue(int value) {
98        mValue = value;
99        if (mEditor != null) {
100            mEditor.commitLocalRepresentation();
101        }
102    }
103
104    @Override
105    public String toString() {
106        return getValueString();
107    }
108
109    @Override
110    public void setFilterView(FilterView editor) {
111        mEditor = editor;
112    }
113}
114