App

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

CurvesLayerSettingsFragment.java
Go to the documentation of this file.
1 package mhr.app.fragments.layers.lut;
2
3 import mhr.app.R;
4 import mhr.app.fragments.layers.LayerSettingsFragment;
5 import mhr.appandroid.views.CurvesView;
6 import mhr.appandroid.views.LabelledSeekBar;
7
8 import mhr.appcore.image.layers.LayerSpecificPresentation;
9 import mhr.appcore.image.layers.lut.CurvesLUTLayerSpecificPresentation;
10 import mhr.appcore.image.layers.lut.GammaLUTLayerSpecificPresentation;
11
12 import android.os.Bundle;
13 import android.view.LayoutInflater;
14 import android.view.View;
15 import android.view.View.OnClickListener;
16 import android.view.ViewGroup;
17 import android.widget.AdapterView;
18 import android.widget.ArrayAdapter;
19 import android.widget.Spinner;
20 import android.widget.AdapterView.OnItemSelectedListener;
21
25 public class CurvesLayerSettingsFragment extends LayerSettingsFragment implements OnClickListener {
26
27
28 //===== INTERFACES, CLASSES, ENUMS ==========================================================================================================//
29 //----- NON-PUBLIC --------------------------------------------------------------------------------------------------------------------------//
30 //----- PUBLIC ------------------------------------------------------------------------------------------------------------------------------//
31
32 //===== FIELDS ==============================================================================================================================//
33 //----- NON-PUBLIC --------------------------------------------------------------------------------------------------------------------------//
34 protected CurvesView MV;
35 protected CurvesView RV;
36 protected CurvesView GV;
37 protected CurvesView BV;
38 protected CurvesView AV;
39 protected Spinner ChSp;
40
41 protected CurvesView selected;
42
43 protected float[][] defVals = new float[][] {
44 {0.0f, 1.0f},
45 {0.0f, 1.0f}
46 };
47 //----- PUBLIC ------------------------------------------------------------------------------------------------------------------------------//
48
49 //===== CONSTRUCTORS, DESTRUCTORS, RELATED METHODS ==========================================================================================//
50 //----- NON-PUBLIC --------------------------------------------------------------------------------------------------------------------------//
51 @Override
52 protected View initView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
53 root = inflater.inflate(R.layout.fragment_curves_layer_settings, container, false);
54
55 ChSp = (Spinner) root.findViewById(R.id.ChannelSp);
56
57 ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(activity, R.array.CurvesChannelNames, android.R.layout.simple_spinner_item);
58 adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
59 ChSp.setAdapter(adapter);
60 ChSp.setOnItemSelectedListener( new OnItemSelectedListener() {
61
62 @Override
63 public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
64 selected.setVisibility(View.GONE);
65 switch (position) {
66 case 0:
67 selected = MV;
68 break;
69 case 1:
70 selected = RV;
71 break;
72 case 2:
73 selected = GV;
74 break;
75 case 3:
76 selected = BV;
77 break;
78 case 4:
79 selected = AV;
80 break;
81 }
82 selected.setVisibility(View.VISIBLE);
83 }
84
85 @Override
86 public void onNothingSelected(AdapterView<?> parent) {
87 }
88 });
89
90 MV = (CurvesView) root.findViewById(R.id.CurvesMaster);
91 RV = (CurvesView) root.findViewById(R.id.CurvesRed);
92 GV = (CurvesView) root.findViewById(R.id.CurvesGreen);
93 BV = (CurvesView) root.findViewById(R.id.CurvesBlue);
94 AV = (CurvesView) root.findViewById(R.id.CurvesAplha);
95 selected = MV;
96
97 root.findViewById(R.id.CurvesCancelBtn).setOnClickListener(new OnClickListener() {
98
99 @Override
100 public void onClick(View v) {
101 MV.setPoints(defVals);
102 RV.setPoints(defVals);
103 GV.setPoints(defVals);
104 BV.setPoints(defVals);
105 AV.setPoints(defVals);
106 }
107 });
108
109 root.findViewById(R.id.CurvesSelectBtn).setOnClickListener(new OnClickListener() {
110
111 @Override
112 public void onClick(View v) {
113 onSelectBtnClicked();
114 }
115 });
116 return root;
117 }
118 //----- PUBLIC ------------------------------------------------------------------------------------------------------------------------------//
119
120 //===== METHODS =============================================================================================================================//
121 //----- NON-PUBLIC --------------------------------------------------------------------------------------------------------------------------//
122 @Override
123 protected void updateFromPresentation(LayerSpecificPresentation pres) {
124 CurvesLUTLayerSpecificPresentation p = (CurvesLUTLayerSpecificPresentation) pres;
125 MV.setPoints(p.M);
126 RV.setPoints(p.R);
127 GV.setPoints(p.G);
128 BV.setPoints(p.B);
129 AV.setPoints(p.A);
130 }
131
132 @Override
133 protected void updatePresentation(LayerSpecificPresentation pres) {
134 CurvesLUTLayerSpecificPresentation p = (CurvesLUTLayerSpecificPresentation) pres;
135 p.M = MV.getPoints();
136 p.R = RV.getPoints();
137 p.G = GV.getPoints();
138 p.B = BV.getPoints();
139 p.A = AV.getPoints();
140 }
141
142 //----- PUBLIC ------------------------------------------------------------------------------------------------------------------------------//
143
144 //===== CALLBACKS ===========================================================================================================================//
145 @Override
146 public void onClick(View v) {
147 switch (v.getId()) {
148 default:
149 super.onClick(v);
150 break;
151 }
152 }
153
154 //----- LIFE CYCLE --------------------------------------------------------------------------------------------------------------------------//
155
156 // @Override
157 // public void onAttach(Activity activity) {
158 // super.onAttach(activity);
159 // /*
160 // * called once the fragment is associated with its activity.
161 // */
162 // }
163
164 // @Override
165 // public void onCreate(Bundle savedInstanceState) {
166 // super.onCreate(savedInstanceState);
167 // /*
168 // * called to do initial creation of the fragment.
169 // *
170 // * The system calls this when creating the fragment. Within your implementation, you should initialize essential components of the fragment that you want
171 // * to retain when the fragment is paused or stopped, then resumed.
172 // */
173 // }
174
175 // @Override
176 // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
177 // return super.onCreateView(inflater, container, savedInstanceState);
178 // /*
179 // * creates and returns the view hierarchy associated with the fragment.
180 // *
181 // * The system calls this when it's time for the fragment to draw its user interface for the first time. To draw a UI for your fragment, you must return a
182 // * View from this method that is the root of your fragment's layout. You can return null if the fragment does not provide a UI.
183 // *
184 // * Zde začíná životní cyklus při návratu z backstacku
185 // */
186 // }
187
188 // @Override
189 // public void onActivityCreated(Bundle savedInstanceState) {
190 // super.onActivityCreated(savedInstanceState);
191 // /*
192 // * tells the fragment that its activity has completed its own Activity.onCreate().
193 // */
194 // }
195
196 // @Override // Vyžaduje API 17
197 // public void onViewStateRestored(Bundle savedInstanceState) {
198 // super.onViewStateRestored(savedInstanceState);
199 // /*
200 // * tells the fragment that all of the saved state of its view hierarchy has been restored.
201 // */
202 // }
203
204 // @Override
205 // public void onStart() {
206 // super.onStart();
207 // /*
208 // * makes the fragment visible to the user (based on its containing activity being started).
209 // */
210 // }
211 //
212 // @Override
213 // public void onResume() {
214 // super.onResume();
215 // /*
216 // * makes the fragment interacting with the user (based on its containing activity being resumed).
217 // */
218 // }
219
220 // @Override
221 // public void onPause() {
222 // super.onPause();
223 // /*
224 // * fragment is no longer interacting with the user either because its activity is being paused or a fragment operation is modifying it in the activity.
225 // *
226 // * The system calls this method as the first indication that the user is leaving the fragment (though it does not always mean the fragment is being destroyed).
227 // * This is usually where you should commit any changes that should be persisted beyond the current user session (because the user might not come back).
228 // */
229 // }
230
231 // @Override
232 // public void onStop() {
233 // super.onStop();
234 // /*
235 // * fragment is no longer visible to the user either because its activity is being stopped or a fragment operation is modifying it in the activity.
236 // */
237 // }
238
239 // @Override
240 // public void onDestroyView() {
241 // super.onDestroyView();
242 // /*
243 // * allows the fragment to clean up resources associated with its View.
244 // *
245 // * Zde končí životní cyklus při umístění do backstacku
246 // */
247 // }
248
249 // @Override
250 // public void onDestroy() {
251 // super.onDestroy();
252 // /*
253 // * called to do final cleanup of the fragment's state.
254 // */
255 // }
256
257 // @Override
258 // public void onDetach() {
259 // super.onDetach();
260 // /*
261 // * called immediately prior to the fragment no longer being associated with its activity.
262 // */
263 // }
264 }