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.content.Context;
20d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford
21ce9ceff5776a9b0479c30cbeb2a9388b44df1865nicolasroardimport com.android.gallery3d.filtershow.pipeline.RenderingRequestCaller;
22d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford
23d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hofordpublic class BasicParameterStyle implements ParameterStyles {
24d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    protected String mParameterName;
25d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    protected int mSelectedStyle;
26d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    protected int mNumberOfStyles;
27d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    protected int mDefaultStyle = 0;
28d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    protected Control mControl;
29d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    protected FilterView mEditor;
30d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    public final int ID;
31d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    private final String LOGTAG = "BasicParameterStyle";
32d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford
33d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    @Override
34d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    public void copyFrom(Parameter src) {
35d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        if (!(src instanceof BasicParameterStyle)) {
36d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford            throw new IllegalArgumentException(src.getClass().getName());
37d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        }
38d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        BasicParameterStyle p = (BasicParameterStyle) src;
39d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        mNumberOfStyles = p.mNumberOfStyles;
40d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        mSelectedStyle = p.mSelectedStyle;
41d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        mDefaultStyle = p.mDefaultStyle;
42d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    }
43d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford
44d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    public BasicParameterStyle(int id, int numberOfStyles) {
45d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        ID = id;
46d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        mNumberOfStyles = numberOfStyles;
47d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    }
48d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford
49d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    @Override
50d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    public String getParameterName() {
51d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        return mParameterName;
52d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    }
53d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford
54d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    @Override
55d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    public String getParameterType() {
56d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        return sParameterType;
57d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    }
58d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford
59d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    @Override
60d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    public String getValueString() {
61d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        return mParameterName + mSelectedStyle;
62d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    }
63d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford
64d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    @Override
65d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    public void setController(Control control) {
66d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        mControl = control;
67d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    }
68d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford
69d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    @Override
70d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    public int getNumberOfStyles() {
71d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        return mNumberOfStyles;
72d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    }
73d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford
74d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    @Override
75d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    public int getDefaultSelected() {
76d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        return mDefaultStyle;
77d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    }
78d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford
79d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    @Override
80d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    public int getSelected() {
81d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        return mSelectedStyle;
82d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    }
83d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford
84d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    @Override
85d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    public void setSelected(int selectedStyle) {
86d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        mSelectedStyle = selectedStyle;
87d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        if (mEditor != null) {
88d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford            mEditor.commitLocalRepresentation();
89d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        }
90d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    }
91d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford
92d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    @Override
93f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford    public void getIcon(int index, BitmapCaller caller) {
94d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        mEditor.computeIcon(index, caller);
95d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    }
96d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford
97d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    @Override
98d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    public String getStyleTitle(int index, Context context) {
99d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        return "";
100d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    }
101d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford
102d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    @Override
103d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    public String toString() {
104d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        return getValueString();
105d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    }
106d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford
107d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    @Override
108d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    public void setFilterView(FilterView editor) {
109d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford        mEditor = editor;
110d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford    }
111d2f5fe607ee6d7b5f79862b495495e2f6024cdabJohn Hoford}
112