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 /*
23 * Title: Câmera Virtual - LIVES
24 * Description: Câmera Virtual para Controle via LabVIEW
25 * Copyright: Copyright (c) 2001
26 * Company: Centro de Educação em Informática - SENAC - SP
27 */
28
29 import javax.swing.*;
30 import java.awt.*;
31 import java.awt.event.*;
32 import camera3d.event.*;
33 import camera3d.GUIControl;
34 import camera3d.DistanceMeasurer;
35 import camera3d.VcObjectChangeListener;
36
37
38 /***
39 * A pane for changing the position of a DistanceMeasurer's target.
40 *
41 * @author Carlos da Silva dos Santos, Fábio Roberto de Miranda
42 * @version 1.0
43 */
44
45 class DistanceMeasurerPane extends JPanel implements VcObjectChangeListener{
46
47 private GUIControl guiControl;
48
49 DistanceMeasurer distanceMeasurer;
50 JLabel jLabel1 = new JLabel();
51 JButton distanceBtn = new JButton();
52 JLabel jLabel2 = new JLabel();
53 JTextField distanceTxt = new JTextField();
54 JButton xBtn = new JButton();
55 JButton yBtn = new JButton();
56 JButton zBtn = new JButton();
57 JLabel jLabel3 = new JLabel();
58 JCheckBox invertCheck = new JCheckBox();
59 JCheckBox boundCheck = new JCheckBox();
60 GridBagLayout gridBagLayout1 = new GridBagLayout();
61
62 public DistanceMeasurerPane() {
63 try {
64 jbInit();
65 }
66 catch(Exception e) {
67 e.printStackTrace();
68 }
69 }
70
71 public void setDistanceMeasurer(DistanceMeasurer measurer){
72 if(distanceMeasurer!=null) distanceMeasurer.removeChangeListener(this);
73 this.distanceMeasurer = measurer;
74 measurer.addChangeListener(this);
75 }
76
77 public void updateData(){
78 //distanceTxt.setText(distanceMeasurer);
79 }
80
81
82 private void jbInit() throws Exception {
83 jLabel1.setText("Distance Measurer");
84 this.setLayout(gridBagLayout1);
85 distanceBtn.setText("compute distance");
86 distanceBtn.addActionListener(new java.awt.event.ActionListener() {
87 public void actionPerformed(ActionEvent e) {
88 distanceBtn_actionPerformed(e);
89 }
90 });
91 jLabel2.setFont(new java.awt.Font("Dialog", 1, 11));
92 jLabel2.setForeground(Color.black);
93 jLabel2.setText("distance");
94 xBtn.setText("X");
95 xBtn.addActionListener(new java.awt.event.ActionListener() {
96 public void actionPerformed(ActionEvent e) {
97 xBtn_actionPerformed(e);
98 }
99 });
100 yBtn.addActionListener(new java.awt.event.ActionListener() {
101 public void actionPerformed(ActionEvent e) {
102 yBtn_actionPerformed(e);
103 }
104 });
105 yBtn.setText("Y");
106 zBtn.addActionListener(new java.awt.event.ActionListener() {
107 public void actionPerformed(ActionEvent e) {
108 zBtn_actionPerformed(e);
109 }
110 });
111 zBtn.setText("Z");
112 jLabel3.setFont(new java.awt.Font("Dialog", 1, 11));
113 jLabel3.setForeground(Color.black);
114 jLabel3.setText("direction");
115 invertCheck.setText("Invert");
116 invertCheck.setFont(new java.awt.Font("Dialog", 1, 10));
117 boundCheck.setText("bound");
118 boundCheck.addActionListener(new java.awt.event.ActionListener() {
119 public void actionPerformed(ActionEvent e) {
120 boundCheck_actionPerformed(e);
121 }
122 });
123 this.add(jLabel2, new GridBagConstraints(0, 1, 2, 1, 0.0, 0.0
124 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(27, 20, 0, 0), 8, 1));
125 this.add(distanceTxt, new GridBagConstraints(2, 1, 2, 1, 1.0, 0.0
126 ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(24, 7, 0, 31), 67, 0));
127 this.add(distanceBtn, new GridBagConstraints(0, 2, 4, 1, 0.0, 0.0
128 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(34, 18, 0, 33), 0, -5));
129 this.add(jLabel1, new GridBagConstraints(0, 0, 4, 1, 0.0, 0.0
130 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(16, 7, 0, 55), 18, 0));
131 this.add(jLabel3, new GridBagConstraints(0, 3, 2, 1, 0.0, 0.0
132 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(27, 14, 0, 6), 6, 1));
133 this.add(xBtn, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0
134 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 14, 55, 0), 1, 1));
135 this.add(invertCheck, new GridBagConstraints(0, 4, 2, 1, 0.0, 0.0
136 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(6, 16, 0, 0), 2, 2));
137 this.add(yBtn, new GridBagConstraints(1, 5, 2, 1, 0.0, 0.0
138 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 55, 0), 3, 1));
139 this.add(boundCheck, new GridBagConstraints(2, 3, 2, 1, 0.0, 0.0
140 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(20, 19, 0, 15), 15, -3));
141 this.add(zBtn, new GridBagConstraints(3, 5, 1, 1, 0.0, 0.0
142 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 55, 39), 3, 1));
143 }
144
145 public void setGUIControl(GUIControl guiControl){
146 this.guiControl = guiControl;
147 }
148
149 void xBtn_actionPerformed(ActionEvent e) {
150 if (invertCheck.isSelected()){
151 distanceMeasurer.setNegativeX();
152 } else {
153 distanceMeasurer.setPositiveX();
154 }
155 }
156
157 void yBtn_actionPerformed(ActionEvent e) {
158 if (invertCheck.isSelected()){
159 distanceMeasurer.setNegativeY();
160 } else {
161 distanceMeasurer.setPositiveY();
162 }
163 }
164
165 void zBtn_actionPerformed(ActionEvent e) {
166 if (invertCheck.isSelected()){
167 distanceMeasurer.setNegativeZ();
168 } else {
169 distanceMeasurer.setPositiveZ();
170 }
171 }
172
173 void distanceBtn_actionPerformed(ActionEvent e) {
174 //distanceMeasurer.measureDistance();
175 guiControl.measureDistance(distanceMeasurer);
176 }
177
178
179 public void vcObjectChanged(VcObjectEvent event){
180 if(event.getSource()==distanceMeasurer){
181 if(event.getType()==VcObjectEvent.DISTANCE_MEASURER_CHANGED){
182 double dis = distanceMeasurer.getDistance();
183 distanceTxt.setText(""+dis);
184 }
185 }
186 }
187
188
189 void boundCheck_actionPerformed(ActionEvent e) {
190 if( boundCheck.isSelected()){
191 distanceMeasurer.setBound(true);
192 } else {
193 distanceMeasurer.setBound(false);
194 }
195 }
196
197 }
This page was automatically generated by Maven