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.xmlrpc; 21 22 import camera3d.*; 23 import java.io.*; 24 import javax.swing.*; 25 import java.awt.*; 26 27 /*** 28 * This class encapsulates camera3d.VcApplication so it can receive XML-RPC calls. 29 * Some methods that would normally return void and/or require no parameters were 30 * modified to return/receive an int, as it was not possible to get XML-RPC working 31 * with void methods. 32 * 33 * @author Carlos da Silva dos Santos 34 * @version 1.0 35 */ 36 37 public class RPCVirtualCamera extends JPanel implements Serializable { 38 39 transient camera3d.VcApplication vcApplication; 40 transient camera3d.GUIControl guiControl; 41 JLabel jLabel1 = new JLabel(); 42 BorderLayout borderLayout1 = new BorderLayout(); 43 44 public RPCVirtualCamera() { 45 try { 46 jbInit(); 47 } 48 catch(Exception e) { 49 e.printStackTrace(); 50 } 51 } 52 53 /*** 54 * Creates a new VcApplication Object 55 * @ param lookAndFeel Specifies the look and feel to be used 56 * @ param internalFrames Specifies whether viewports will be created as internal frames 57 */ 58 public int initialize(int lookAndFeel, int internalFrames){ 59 System.out.println("initialize: "+lookAndFeel+" "+internalFrames); 60 if (internalFrames ==0){ 61 GUIControl.viewportsInJInternalFrames = false; 62 } else { 63 GUIControl.viewportsInJInternalFrames = true; 64 } 65 66 return initialize1(lookAndFeel); 67 } 68 69 70 /*** 71 * Creates a new VcApplication Object 72 * @param lookAndFeel Specifies the look and feel to be used 73 */ 74 public int initialize1(int lookAndFeel){ 75 switch (lookAndFeel){ 76 case 0: 77 try { 78 //UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 79 UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); 80 } 81 catch(Exception e) { 82 e.printStackTrace(); 83 } 84 break; 85 case 1: 86 try { 87 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 88 //UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); 89 } 90 catch(Exception e) { 91 e.printStackTrace(); 92 } 93 break; 94 default: 95 try { 96 //UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 97 UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); 98 } 99 catch(Exception e) { 100 e.printStackTrace(); 101 } 102 break; 103 } 104 jLabel1.setText("Please wait"); 105 if(vcApplication==null){ 106 vcApplication = new VcApplication(); 107 vcApplication.setBeanMode(true); 108 this.guiControl = vcApplication.getGUIControl(); 109 jLabel1.setText("Virtual Camera"); 110 } 111 return 0; 112 } 113 114 private void jbInit() throws Exception { 115 jLabel1.setText("Virtual Camera"); 116 this.setLayout(borderLayout1); 117 this.setBorder(BorderFactory.createEtchedBorder()); 118 this.setMaximumSize(new Dimension(100, 20)); 119 this.setMinimumSize(new Dimension(100, 20)); 120 this.setPreferredSize(new Dimension(100, 20)); 121 this.add(jLabel1, BorderLayout.CENTER); 122 } 123 124 /*** 125 * Closes the vcApplication object 126 * @param x It has no effect, just used to comply with xml-rpc spec 127 */ 128 public int close(int x){ 129 vcApplication.close(); 130 //guiControl = null; 131 //vcApplication = null; 132 //System.exit(0); 133 return 0; 134 } 135 136 /*** 137 * Loads a VRML file 138 * @param filePath Complete path of the file to be opened 139 */ 140 public int loadFile(String filePath){ 141 // candidate for synchronous method 142 guiControl.loadFile(filePath); 143 return 0; 144 } 145 146 /*** 147 * Adds a viewport which will show the Default View 148 * @param x It has no effect, just used to comply with xml-rpc spec 149 */ 150 public int addViewport(int x){ 151 // candidate for synchronous method 152 guiControl.addViewport(); 153 return x; 154 } 155 156 /*** 157 * Adds a view with specified name 158 * @param view Name of the view to be added 159 */ 160 public int addView(String view){ 161 guiControl.addView(view); 162 return 0; 163 } 164 165 166 167 /*** 168 * Adds a viewport showing the specified view 169 * @param view Name of the view to be added 170 */ 171 public int addViewport(String view){ 172 guiControl.addViewport(view); 173 return 0; 174 } 175 176 /*** 177 * Finds the viewport called viewportName and sets it to display the view called 178 * view 179 */ 180 public int changeViewInViewport(String viewportName, String view){ 181 guiControl.changeViewInViewport(viewportName, view); 182 return 0; 183 } 184 185 public int renameVcObject(String oldName, String newName){ 186 guiControl.renameVcObject(oldName, newName); 187 return 0; 188 } 189 190 public int toggleHelpingGrid(int x){ 191 guiControl.toggleHelpingGrid(); 192 return x; 193 } 194 195 public int translateX(String mode, String object, double value){ 196 guiControl.translateX(mode, object, value); 197 return 0; 198 } 199 200 public int translateY(String mode, String object, double value){ 201 guiControl.translateY(mode, object, value); 202 return 0; 203 } 204 205 public int translateZ(String mode, String object, double value){ 206 guiControl.translateZ(mode, object, value); 207 return 0; 208 } 209 210 public int rotateX(String mode, String object, double value){ 211 guiControl.rotateX(mode, object, value); 212 return 0; 213 } 214 215 public int rotateY(String mode, String object, double value){ 216 guiControl.rotateY(mode, object, value); 217 return 0; 218 } 219 220 public int rotateZ(String mode, String object, double value){ 221 guiControl.rotateZ(mode, object, value); 222 return 0; 223 } 224 225 public int scaleX(String mode, String object, double value){ 226 guiControl.scaleX(mode, object, value); 227 return 0; 228 } 229 230 public int scaleY(String mode, String object, double value){ 231 guiControl.scaleY(mode, object, value); 232 return 0; 233 } 234 235 public int scaleZ(String mode, String object, double value){ 236 guiControl.scaleZ(mode, object, value); 237 return 0; 238 } 239 240 public int scale(String mode, String object, double value){ 241 guiControl.scale(mode, object, value); 242 return 0; 243 } 244 245 public int changeProjectionPolicy(String strView, String strPolicy){ 246 guiControl.changeProjectionPolicy(strView, strPolicy); 247 return 0; 248 } 249 250 public int changeMovementPolicy(String strView, String strPolicy){ 251 guiControl.changeMovementPolicy(strView, strPolicy); 252 return 0; 253 } 254 255 public int changeResizePolicy(String strView, String strPolicy){ 256 guiControl.changeResizePolicy(strView, strPolicy); 257 return 0; 258 } 259 260 public int setFieldOfView(String strView, double d){ 261 guiControl.setFieldOfView(strView, d); 262 return 0; 263 } 264 265 public int addLight(String type, String name){ 266 guiControl.addLight(type, name); 267 return 0; 268 } 269 270 public int changeLightColor(String light, int red, int green, int blue){ 271 guiControl.changeLightColor(light, red, green, blue); 272 return 0; 273 } 274 275 public int changeLightState(String light, int state){ 276 guiControl.changeLightState(light, state); 277 return 0; 278 } 279 280 public int changeSpotSpreadAngle(String spotName, double angle){ 281 guiControl.changeSpotSpreadAngle(spotName, angle); 282 return 0; 283 } 284 285 public int changeSpotConcentration(String spotName, double angle){ 286 guiControl.changeSpotConcentration(spotName, angle); 287 return 0; 288 } 289 290 public int takeJPGSnapshot(String viewname, String filename){ 291 //guiControl.saveJPGFileSync(viewname, filename); 292 guiControl.saveJPGFile(viewname, filename); 293 System.out.println("view: "+viewname); 294 System.out.println("file: "+filename); 295 return 0; 296 } 297 298 299 public int takeJPGSnapshot(String filename){ 300 guiControl.saveJPGFileSync(filename); 301 //guiControl.saveJPGFile(filename); 302 return 0; 303 } 304 305 306 public int frameObjectsInView(String view){ 307 guiControl.frameObjectsInView(view); 308 return 0; 309 } 310 311 public int lookAt(String camera, String object){ 312 guiControl.lookAt(camera, object); 313 return 0; 314 } 315 316 public int addMeasurer(int x){ 317 guiControl.addDistanceMeasurer(); 318 return x; 319 } 320 321 public int setMeasurerDirection(String name, int direction, String axis){ 322 guiControl.setMeasurerDirection(name, direction, axis); 323 return 0; 324 } 325 326 /* public void wait(int milliseconds){ 327 guiControl.wait(); 328 } 329 */ 330 331 public double getMeasuredDistance(String measurer){ 332 double dist = guiControl.getMeasuredDistance(measurer); 333 return dist; 334 } 335 }

This page was automatically generated by Maven