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; 21 22 import java.io.*; 23 import javax.swing.UIManager; 24 import java.awt.Dimension; 25 import java.awt.Toolkit; 26 import javax.swing.JDesktopPane; 27 import camera3d.gui.*; 28 import camera3d.action.ActionExecutor; 29 import camera3d.action.ActionQueue; 30 31 /*** 32 * Virtual Camera main application. 33 */ 34 public class VcApplication { 35 36 boolean packFrame = false; 37 boolean beanMode = false; 38 39 /* input queue for new actions */ 40 private ActionQueue queue = new ActionQueue(); 41 /* output queue for actions already executed */ 42 private ActionQueue outputQueue = new ActionQueue(); 43 44 45 private J3DBase base = new J3DBase(); 46 private GUIControl guiControl = new GUIControl(base,queue); 47 private ActionExecutor executor = new ActionExecutor(queue, outputQueue, base, guiControl); 48 49 private ViewportWindowManager viewportManager; 50 private ViewportsEventHandler viewportsEventHandler; 51 52 private SelectionList list = new SelectionList(); 53 //SelectionListPane listPane; 54 private JDesktopPane desktopPane; 55 //EditionPane editionPane; 56 private VcFrame frame; 57 58 /*** 59 * Constructs the application. 60 */ 61 public VcApplication() { 62 //guiControl.setJ3DBase(base); 63 queue.setOptimized(true); 64 outputQueue.setOptimized(false); 65 66 // allow only one object to be selected at a time 67 list.setSingleObjectSelectionMode(true); 68 69 // only available after JDK1.4 70 //javax.swing.JFrame.setDefaultLookAndFeelDecorated(true); 71 frame = new VcFrame(); 72 73 desktopPane = frame.getDesktopPane(); 74 //listPane = frame.getSelectionListPane(); 75 //editionPane = frame.getEditionPane(); 76 77 //frame.getEditionPane().setGUIControl(guiControl); 78 frame.setGUIControl(guiControl); 79 frame.setSelectionList(list); 80 81 viewportManager = new ViewportWindowManager(desktopPane, base, guiControl, list); 82 viewportsEventHandler = new ViewportsEventHandler(guiControl); 83 viewportManager.setViewportsEventHandler(viewportsEventHandler); 84 85 /* makes listPane and editionPane aware of changes in the selected objects. 86 */ 87 //listPane.setSelectionList(list); 88 //editionPane.setSelectionList(list); 89 90 // adds objects interesting in changes made to the list of objects in the 91 // scene 92 base.addSceneObjectsChangeListener(list); 93 //base.addSceneObjectsChangeListener(listPane); 94 base.addSceneObjectsChangeListener(viewportManager); 95 96 // Allows only one object to be selected at a time 97 list.setSingleObjectSelectionMode(true); 98 99 list.addSelectionChangeListener(viewportsEventHandler); 100 101 102 103 guiControl.addViewport(base.getDefaultView()); 104 105 106 // Validate frames that have preset sizes 107 // Pack frames that have useful preferred size info, e.g. from their layout 108 if (packFrame) { 109 frame.pack(); 110 } 111 else { 112 frame.validate(); 113 } 114 //Center the window 115 Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); 116 Dimension frameSize = frame.getSize(); 117 118 if (frameSize.height > screenSize.height) { 119 frameSize.height = screenSize.height; 120 } 121 if (frameSize.width > screenSize.width) { 122 frameSize.width = screenSize.width; 123 } 124 125 //frame.setSize(screenSize.height-50,screenSize.height-50); 126 //frameSize.height = screenSize.height; 127 //frameSize.width = screenSize.height; 128 129 frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); 130 frame.setVisible(true); 131 132 executor.start(); 133 134 /* 135 * CursorManager is being instanced now to avoid delays at a later time 136 */ 137 CursorManager.getCursorManager(); 138 } 139 140 /*** 141 * Returns the GUIControl object responsible for processing users requests. 142 */ 143 public GUIControl getGUIControl(){ 144 return this.guiControl; 145 } 146 147 148 /*** 149 * Gets VcApplication running. 150 */ 151 public static void main(String[] args) { 152 153 try { 154 //UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 155 UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); 156 //UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); 157 // uncomment to use skins 158 //Skin skin = SkinLookAndFeel.loadThemePack(camera3d.VcApplication.class.getResource("aquathemepack.zip")); 159 //SkinLookAndFeel.setSkin(skin); 160 //UIManager.setLookAndFeel("com.l2fprod.gui.plaf.skin.SkinLookAndFeel"); 161 } 162 catch(Exception e) { 163 e.printStackTrace(); 164 } 165 //java.util.Properties prop = System.getProperties(); 166 //prop.list(System.out); 167 168 new VcApplication(); 169 } 170 171 /*** 172 * Terminates the application. 173 */ 174 public void close(){ 175 if (beanMode){ 176 executor.stopRun(); 177 frame.setVisible(false); 178 frame.dispose(); 179 } else { 180 System.exit(0); 181 } 182 } 183 184 public void setVisible(boolean visible){ 185 this.frame.setVisible(true); 186 } 187 188 public void setBeanMode(boolean mode){ 189 this.beanMode = mode; 190 //? 191 this.frame.setBeanMode(true); 192 } 193 }

This page was automatically generated by Maven