1 /*****************************************************************************
2 * Virtual Mockup for Machine Vision
3 * Copyright (C) 2001-2003 Fabio R. de Miranda, João E. Kogler Jr.,
4 * Carlos S. Santos.
5 * Virtual Mockup for Machine Vision Project funded by SENAC-SP
6 *
7 * Permission is granted to redistribute and/or modify this
8 * software under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License (http://www.gnu.org/copyleft/lesser.html)
16 * for more details.
17 *
18 *****************************************************************************/
19
20 package camera3d.gui;
21
22 import camera3d.*;
23 import camera3d.event.*;
24 import java.awt.*;
25 import javax.swing.*;
26 import java.awt.event.*;
27
28 /*
29 * Title: Câmera Virtual - LIVES
30 * Description: Câmera Virtual para Controle via LabVIEW
31 * Copyright: Copyright (c) 2001
32 * Company: Centro de Educação em Informática - SENAC - SP
33 */
34
35 /***
36 * Pane for editing view specific parameters.
37 *
38 * @author Fábio Roberto de Miranda
39 * @version 1.0
40 */
41 class VcViewEditionPane extends JPanel implements VcObjectChangeListener, DoubleValueChangeListener {
42
43 GUIControl guiControl;
44 VcView vcView;
45 JLabel jLabel1 = new JLabel();
46 JLabel projLabel = new JLabel();
47 ButtonGroup projectionPolicyGroup = new ButtonGroup();
48 JRadioButton parallelRadio = new JRadioButton();
49 JRadioButton perspectiveRadio = new JRadioButton();
50 JLabel movementLabel = new JLabel();
51 JLabel screenLabel = new JLabel();
52 ButtonGroup movementGroup = new ButtonGroup();
53 ButtonGroup resizeGroup = new ButtonGroup();
54 JRadioButton virtualMovementRadio = new JRadioButton();
55 JRadioButton physicalMovementRadio = new JRadioButton();
56 JRadioButton virtualResizeRadio = new JRadioButton();
57 JRadioButton physicalResizeRadio = new JRadioButton();
58 JLabel jLabel2 = new JLabel();
59 DoubleDigitalControl fovControl = new DoubleDigitalControl();
60
61 VcViewEditionPane(GUIControl guiControl) {
62 this();
63 this.guiControl = guiControl;
64 }
65
66 VcViewEditionPane(){
67 try {
68 jbInit();
69 }
70 catch(Exception e) {
71 e.printStackTrace();
72 }
73 }
74
75 void setVcView(VcView view){
76 releaseObjects();
77 this.vcView = view;
78 updateData();
79 }
80
81 private void jbInit() throws Exception {
82 jLabel1.setText("View parameters");
83 jLabel1.setBounds(new Rectangle(2, 2, 258, 17));
84 this.setLayout(null);
85 this.setBorder(BorderFactory.createEtchedBorder());
86 this.setMinimumSize(new Dimension(150, 320));
87 this.setPreferredSize(new Dimension(150, 320));
88 projLabel.setText("Projection type:");
89 projLabel.setBounds(new Rectangle(7, 37, 96, 23));
90 parallelRadio.setText("Parallel");
91 parallelRadio.setBounds(new Rectangle(115, 38, 84, 25));
92 parallelRadio.addActionListener(new java.awt.event.ActionListener() {
93 public void actionPerformed(ActionEvent e) {
94 radio_actionPerformed(e);
95 }
96 });
97
98 perspectiveRadio.setSelected(true);
99 perspectiveRadio.setText("Perspective");
100 perspectiveRadio.setBounds(new Rectangle(113, 61, 92, 32));
101 perspectiveRadio.addActionListener(new java.awt.event.ActionListener() {
102 public void actionPerformed(ActionEvent e) {
103 radio_actionPerformed(e);
104 }
105 });
106 movementLabel.setText("Window movement:");
107 movementLabel.setBounds(new Rectangle(7, 102, 121, 22));
108 screenLabel.setText("Screen resizing:");
109 screenLabel.setBounds(new Rectangle(7, 171, 104, 19));
110 virtualMovementRadio.setText("Virtual");
111 virtualMovementRadio.setBounds(new Rectangle(112, 126, 97, 15));
112 virtualMovementRadio.addActionListener(new java.awt.event.ActionListener() {
113 public void actionPerformed(ActionEvent e) {
114 movementRadio_actionPerformed(e);
115 }
116 });
117 physicalMovementRadio.setSelected(true);
118 physicalMovementRadio.setText("Just physical");
119 physicalMovementRadio.setBounds(new Rectangle(111, 143, 104, 25));
120 physicalMovementRadio.addActionListener(new java.awt.event.ActionListener() {
121 public void actionPerformed(ActionEvent e) {
122 movementRadio_actionPerformed(e);
123 }
124 });
125 virtualResizeRadio.setText("Virtual");
126 virtualResizeRadio.setBounds(new Rectangle(107, 194, 103, 22));
127 virtualResizeRadio.addActionListener(new java.awt.event.ActionListener() {
128 public void actionPerformed(ActionEvent e) {
129 resizeRadio_actionPerformed(e);
130 }
131 });
132 physicalResizeRadio.setSelected(true);
133 physicalResizeRadio.setText("Just physical");
134 physicalResizeRadio.setBounds(new Rectangle(108, 218, 119, 20));
135 physicalResizeRadio.addActionListener(new java.awt.event.ActionListener() {
136 public void actionPerformed(ActionEvent e) {
137 resizeRadio_actionPerformed(e);
138 }
139 });
140 jLabel2.setText("Field of View:");
141 jLabel2.setBounds(new Rectangle(10, 273, 85, 15));
142 fovControl.setBounds(new Rectangle(109, 265, 72, 35));
143 fovControl.setIncrementStep(0.5);
144 this.add(jLabel1, null);
145 this.add(projLabel, null);
146 this.add(parallelRadio, null);
147 this.add(perspectiveRadio, null);
148 this.add(movementLabel, null);
149 this.add(virtualMovementRadio, null);
150 this.add(physicalMovementRadio, null);
151 this.add(screenLabel, null);
152 this.add(virtualResizeRadio, null);
153 this.add(physicalResizeRadio, null);
154 this.add(fovControl, null);
155 this.add(jLabel2, null);
156 projectionPolicyGroup.add(perspectiveRadio);
157 projectionPolicyGroup.add(parallelRadio);
158 movementGroup.add(virtualMovementRadio);
159 movementGroup.add(physicalMovementRadio);
160 resizeGroup.add(virtualResizeRadio);
161 resizeGroup.add(physicalResizeRadio);
162 fovControl.addValueChangeListener(this);
163 }
164
165 void setGUIControl(GUIControl guiControl){
166 this.guiControl = guiControl;
167 }
168
169 void updateData(){
170 switch (vcView.getProjectionPolicy()){
171 case VcView.PARALLEL_PROJECTION:
172 parallelRadio.setSelected(true);
173 break;
174 default:
175 perspectiveRadio.setSelected(true);
176 break;
177 }
178 fovControl.setValue(vcView.getFieldOfView());
179 switch (vcView.getWindowMovementPolicy()){
180 case VcView.PHYSICAL_WORLD:
181 physicalMovementRadio.setSelected(true);
182 break;
183 case VcView.VIRTUAL_WORLD:
184 virtualMovementRadio.setSelected(true);
185 break;
186 }
187 switch (vcView.getWindowResizePolicy()){
188 case VcView.PHYSICAL_WORLD:
189 physicalResizeRadio.setSelected(true);
190 break;
191 case VcView.VIRTUAL_WORLD:
192 virtualResizeRadio.setSelected(true);
193 break;
194 }
195
196 }
197
198
199
200 /*
201 * Removes itself from all objects whose list of listeners constains this object
202 */
203 private void releaseObjects(){
204 if(vcView!=null){
205 vcView.removeChangeListener(this);
206 }
207 }
208
209
210 void changePerspective(){
211 if (parallelRadio.isSelected()){
212 // Trigger command to change projection to parallel
213 debugln("VcViewEditionPane:Parallel projection selected");
214 guiControl.changeProjectionPolicy(vcView, VcView.PARALLEL_PROJECTION);
215 } else if (perspectiveRadio.isSelected()){
216 // Trigger command to change projection to "perspective"
217 debugln("VcViewEditionPane:Perspective projection selected");
218 guiControl.changeProjectionPolicy(vcView, VcView.PERSPECTIVE_PROJECTION);
219 }
220 }
221
222 void changeMovement(){
223 if (virtualMovementRadio.isSelected()){
224 debugln("VcViewEditionPane:Virtual movement selected");
225 guiControl.changeMovementPolicy(vcView, VcView.VIRTUAL_WORLD);
226 } else if (physicalMovementRadio.isSelected()){
227 debugln("VcViewEditionPane:Physical");
228 guiControl.changeMovementPolicy(vcView, VcView.PHYSICAL_WORLD);
229 }
230 }
231
232 void changeResize(){
233 if (virtualResizeRadio.isSelected()){
234 debugln("VcViewEditionPane:Virtual movement selected");
235 guiControl.changeResizePolicy(vcView, VcView.VIRTUAL_WORLD);
236 } else if (physicalResizeRadio.isSelected()){
237 debugln("VcViewEditionPane:Physical");
238 guiControl.changeResizePolicy(vcView, VcView.PHYSICAL_WORLD);
239 }
240 }
241
242
243 public void vcObjectChanged(VcObjectEvent event){
244 if (event.getSource()==this.vcView){
245 if(event.getType()==VcObjectEvent.VCVIEW_CHANGED){
246 updateData();
247 }
248 }
249 }
250
251
252 void debugln(String s){
253 if (GUIControl.debugflag){
254 System.out.println(s);
255 }
256 }
257
258 void radio_actionPerformed(ActionEvent e) {
259 changePerspective();
260 }
261
262 void movementRadio_actionPerformed(ActionEvent e) {
263 changeMovement();
264 }
265
266 void resizeRadio_actionPerformed(ActionEvent e) {
267 changeResize();
268 }
269
270 public void valueChanged(DoubleChangeEvent ev){
271 if (ev.getSource()==fovControl){
272 guiControl.setFieldOfView(vcView, fovControl.getValue());
273 }
274 }
275 }
This page was automatically generated by Maven