App

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

- File List
- File Members

CurvesPopUpFragment.java
Go to the documentation of this file.
1 package mhr.app.fragments.toolbox.pointops;
2
3
4 import android.view.View;
5 import android.widget.RadioGroup;
6 import android.widget.RadioGroup.OnCheckedChangeListener;
7 import mhr.app.R;
8 import mhr.app.fragments.toolbox.CancellableToolPopUpFragment;
9 import mhr.appandroid.views.CurvesView;
10 import mhr.appandroid.views.LabelledSeekBar;
11 import mhr.appandroid.views.CurvesView.CurvesViewChangeListener;
12 import mhr.appandroid.views.LabelledSeekBar.LabelledSBChangeListener;
13 import mhr.appcore.commands.toolcommands.CancelableToolUpdateCommand;
14 import mhr.appcore.tools.Tool;
15 import mhr.appcore.tools.actiondata.CancelableToolActionData;
16 import mhr.appcore.tools.actiondata.CancelableToolActionData.Action;
17 import mhr.appcore.tools.actiondata.CurvesLUTCancelableToolActionData;
18 import mhr.appcore.tools.actiondata.GammaLUTCancelableToolActionData;
19 import mhr.appcore.tools.cancelable.lut.CurvesLUTCancelableTool;
20 import mhr.appcore.tools.cancelable.lut.GammaLUTCancelableTool;
21
25 public class CurvesPopUpFragment extends CancellableToolPopUpFragment implements CurvesViewChangeListener, OnCheckedChangeListener{
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 RadioGroup ChRG;
40
41 protected CurvesView selected;
42
43 protected float[][] defVals = new float[][] {
44 {0.0f, 1.0f},
45 {0.0f, 1.0f}
46 };
47
48 //----- PUBLIC ------------------------------------------------------------------------------------------------------------------------------//
49
50 //===== CONSTRUCTORS, DESTRUCTORS, RELATED METHODS ==========================================================================================//
51 //----- NON-PUBLIC --------------------------------------------------------------------------------------------------------------------------//
52 @Override
53 protected void onInitView() {
54 ChRG = (RadioGroup) root.findViewById(R.id.ChannelRG);
55 ChRG.setOnCheckedChangeListener(this);
56
57 MV = (CurvesView) root.findViewById(R.id.CurvesMaster);
58 MV.setCurvesChangeListener(this);
59 selected = MV;
60
61 RV = (CurvesView) root.findViewById(R.id.CurvesRed);
62 RV.setCurvesChangeListener(this);
63
64 GV = (CurvesView) root.findViewById(R.id.CurvesGreen);
65 GV.setCurvesChangeListener(this);
66
67 BV = (CurvesView) root.findViewById(R.id.CurvesBlue);
68 BV.setCurvesChangeListener(this);
69
70 AV = (CurvesView) root.findViewById(R.id.CurvesAplha);
71 AV.setCurvesChangeListener(this);
72
73 }
74 //----- PUBLIC ------------------------------------------------------------------------------------------------------------------------------//
75 public CurvesPopUpFragment() {
76
77 }
78
79 //===== METHODS =============================================================================================================================//
80 //----- NON-PUBLIC --------------------------------------------------------------------------------------------------------------------------//
81 @Override
82 protected Tool getTool() {
83
84 return new CurvesLUTCancelableTool();
85 }
86
87 @Override
88 protected CancelableToolActionData getUpdateToolData() {
89 return new CurvesLUTCancelableToolActionData(Action.UPDATE_PREVIEW, MV.getPoints(), RV.getPoints(), GV.getPoints(), BV.getPoints(), AV.getPoints());
90 }
91
92
93 @Override
94 protected int getLayoutId() {
95 return R.layout.fragment_point_operation_tool_curves_settings;
96 }
97
98 @Override
99 protected void onCancel() {
100 MV.setPoints(defVals);
101 RV.setPoints(defVals);
102 GV.setPoints(defVals);
103 BV.setPoints(defVals);
104 AV.setPoints(defVals);
105 }
106
107 //----- PUBLIC ------------------------------------------------------------------------------------------------------------------------------//
108
109 //===== CALLBACKS ===========================================================================================================================//
110
111
112 @Override
113 public void onCurvesChange(CurvesView v) {
114 if (livePreviewOn) {
115 activity.addCommand(new CancelableToolUpdateCommand(getUpdateToolData()));
116 }
117
118 }
119 @Override
120 public void onCurvesChangeStart(CurvesView v) {
121 }
122 @Override
123 public void onCurvesChangeStop(CurvesView v) {
124 }
125 @Override
126 public void onCheckedChanged(RadioGroup group, int checkedId) {
127 selected.setVisibility(View.GONE);
128 switch (checkedId) {
129 case R.id.MChannelRB:
130 selected = MV;
131 break;
132 case R.id.RChannelRB:
133 selected = RV;
134 break;
135 case R.id.GChannelRB:
136 selected = GV;
137 break;
138 case R.id.BChannelRB:
139 selected = BV;
140 break;
141 case R.id.AChannelRB:
142 selected = AV;
143 break;
144 }
145 selected.setVisibility(View.VISIBLE);
146 }
147 }