View Javadoc
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 * Title: Câmera Virtual - LIVES 23 * Description: Câmera Virtual para Controle via LabVIEW 24 * Copyright: Copyright (c) 2001 25 * Company: Centro de Educação em Informática - SENAC - SP 26 */ 27 import java.awt.*; 28 import javax.swing.*; 29 import javax.swing.colorchooser.*; 30 import camera3d.gui.*; 31 import camera3d.*; 32 import javax.vecmath.*; 33 import java.awt.event.*; 34 import javax.swing.event.*; 35 36 /*** 37 * A panel for editing VcLight parameters. 38 * 39 * @author Fábio Roberto de Miranda 40 * @version 1.0 41 * @see camera3d.VcLight 42 */ 43 class VcLightEditionPane extends JPanel { 44 private JLabel jLabel1 = new JLabel(); 45 private JColorChooser jColorChooser1 = new JColorChooser(); 46 private JCheckBox lightEnabledCheckBox = new JCheckBox(); 47 private JLabel jLabel2 = new JLabel(); 48 private GUIControl guiControl; 49 private ColorSelectionModel colorModel; 50 private VcLight vcLight; 51 private JScrollPane jScrollPane1 = new JScrollPane(); 52 private GridBagLayout gridBagLayout1 = new GridBagLayout(); 53 54 /*** 55 * Creates panel. 56 */ 57 VcLightEditionPane() { 58 try { 59 jbInit(); 60 } 61 catch(Exception e) { 62 e.printStackTrace(); 63 } 64 } 65 66 private void jbInit() throws Exception { 67 jLabel1.setText("Light Parameters"); 68 this.setMinimumSize(new Dimension(150, 350)); 69 this.setPreferredSize(new Dimension(150, 350)); 70 this.setLayout(gridBagLayout1); 71 jColorChooser1.setToolTipText("Use this to select the color of the light"); 72 colorModel = jColorChooser1.getSelectionModel(); 73 lightEnabledCheckBox.setSelected(true); 74 lightEnabledCheckBox.setText("Light on"); 75 lightEnabledCheckBox.setToolTipText("When this checkbox is unchecked light is turned off"); 76 lightEnabledCheckBox.addActionListener(new java.awt.event.ActionListener() { 77 public void actionPerformed(ActionEvent e) { 78 lightEnabledCheckBox_actionPerformed(e); 79 } 80 }); 81 jLabel2.setText("Color selection"); 82 colorModel.addChangeListener(new javax.swing.event.ChangeListener() { 83 public void stateChanged(ChangeEvent e) { 84 colorModel_stateChanged(e); 85 } 86 }); 87 this.add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 88 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(22, 8, 0, 86), 16, 0)); 89 this.add(lightEnabledCheckBox, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 90 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(12, 8, 0, 107), 23, 0)); 91 jColorChooser1.setPreviewPanel(new JPanel()); 92 this.add(jLabel2, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 93 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(24, 8, 0, 116), 0, -1)); 94 this.add(jScrollPane1, new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0 95 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 8, 9, 2), -233, 2)); 96 jScrollPane1.getViewport().add(jColorChooser1, null); 97 98 } 99 100 /*** 101 * Sets light whose parameters are shown to be edited. 102 * @param light VcLight shown on the panel. 103 */ 104 void setVcLight(VcLight light){ 105 this.vcLight = light; 106 if (light.isEnabled()){ 107 lightEnabledCheckBox.setSelected(true); 108 } 109 jColorChooser1.setColor((int)(light.getRed()*255), (int)(light.getGreen()*255), (int)(light.getBlue()*255)); 110 } 111 112 /*** 113 * Sets GUIControl object which receives requests from this object. 114 */ 115 void setGUIControl(GUIControl guiControl){ 116 this.guiControl = guiControl; 117 } 118 119 void lightEnabledCheckBox_actionPerformed(ActionEvent e) { 120 // Trigger actions that turn lights on or off 121 guiControl.changeLightState(vcLight, lightEnabledCheckBox.isSelected()); 122 } 123 124 void colorModel_stateChanged(ChangeEvent e) { 125 Color newColor = jColorChooser1.getColor(); 126 guiControl.changeLightColor(vcLight, newColor.getRed(), newColor.getGreen(), newColor.getBlue()); 127 debugln("State changed in colorModel"); 128 } 129 130 void debugln(String s){ 131 if (GUIControl.debugflag){ 132 System.out.println(s); 133 } 134 } 135 }

This page was automatically generated by Maven