📄 sceneeditorapplication.java
字号:
{ JPanel statusBarPanel; statusMessage = new JLabel(gui.getMessage("IDM_INTRO_MESSAGE")); Border border = BorderFactory.createLoweredBevelBorder(); statusMessage.setBorder(border); statusBarPanel = new JPanel(); statusBarPanel.setLayout(new GridLayout()); border = BorderFactory.createEmptyBorder(3, 3, 3, 3); statusBarPanel.setBorder(border); statusBarPanel.add(statusMessage); return statusBarPanel; } private JTabbedPane createPanel() { JTabbedPane container; JPanel panel; JButton button; JScrollPane sp; container = new JTabbedPane(); container.getModel().addChangeListener(new MyChangeListener(this)); //----------------------------------------------------------------- panel = new ButtonsPanel(this, 1); sp = new JScrollPane(panel); container.addTab(gui.getMessage("IDM_CREATION_TAB"), null, sp, "Object creation operations"); //----------------------------------------------------------------- modifyPanel = new ModifyPanel(this); sp = new JScrollPane(modifyPanel); container.addTab(gui.getMessage("IDM_MODIFY_TAB"), null, sp, "Modify selected body"); //----------------------------------------------------------------- panel = new ButtonsPanel(this, 2); sp = new JScrollPane(panel); container.addTab(gui.getMessage("IDM_GUI_TAB"), null, sp, "GUI Control"); //----------------------------------------------------------------- panel = new ButtonsPanel(this, 3); sp = new JScrollPane(panel); container.addTab(gui.getMessage("IDM_OTHERS_TAB"), null, sp, "Control the scene components"); //----------------------------------------------------------------- panel = new ButtonsPanel(this, 4); sp = new JScrollPane(panel); container.addTab(gui.getMessage("IDM_RENDER_TAB"), null, sp, "Control the scene components"); //----------------------------------------------------------------- return container; } private void createGUI() { //- Configure the application Look & feel ------------------------- try { UIManager.setLookAndFeel(lookAndFeel); } catch (Exception e) { System.err.println("Warning: Can not set " + lookAndFeel + "look and feel"); } JFrame.setDefaultLookAndFeelDecorated(true); //- Configure this JFrame ----------------------------------------- mainWindowWidget = new JFrame("VITRAL Scene Editor"); mainWindowWidget.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Toolkit tk = mainWindowWidget.getToolkit(); Dimension d = tk.getScreenSize(); //----------------------------------------------------------------- try { gui = GuiCachePersistence.importAquynzaGui( new FileReader(languageGuiFile) ); } catch (Exception e) { System.err.println("Fatal error: can not open GUI file"); System.exit(0); } //System.out.println(gui); //----------------------------------------------------------------- executorPanel = new ButtonsPanel(this, 101); //----------------------------------------------------------------- JMenuBar menubar; menubar = SwingGuiCacheRenderer.buildMenubar(gui, null, executorPanel); //----------------------------------------------------------------- JSplitPane splitPane; statusBarPanel = createStatusBar(); drawingArea = new JoglDrawingArea(theScene, statusMessage, this); Component left = drawingArea.getCanvas(); Component right = createPanel(); Dimension minleft = new Dimension(160, 120); Dimension minright = new Dimension(320, 120); JPanel iconsAndWorkAreasPanel; splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left, right); left.setMinimumSize(minleft); right.setMinimumSize(minright); splitPane.setResizeWeight(1.0); Dimension dd = splitPane.getMaximumSize(); dd.width = Short.MAX_VALUE; splitPane.setAlignmentX(0.5f); splitPane.setMaximumSize(dd); iconsAndWorkAreasPanel = new JPanel(); iconsAndWorkAreasPanel.setLayout( new BoxLayout(iconsAndWorkAreasPanel, BoxLayout.Y_AXIS)); iconsAndWorkAreasPanel.add(executorPanel); iconsAndWorkAreasPanel.add(splitPane); mainWindowWidget.add(iconsAndWorkAreasPanel, BorderLayout.CENTER); mainWindowWidget.add(statusBarPanel, BorderLayout.SOUTH); mainWindowWidget.setJMenuBar(menubar); //----------------------------------------------------------------- int ancho_panel; if ( d.width < 640 ) ancho_panel = 320; ancho_panel = d.width - 320; splitPane.setDividerLocation(ancho_panel); mainWindowWidget.setPreferredSize(d); mainWindowWidget.pack(); mainWindowWidget.setVisible(true); drawingArea.getCanvas().requestFocusInWindow(); //----------------------------------------------------------------- imageControlWindow = null; selectorDialog = null; modifyPanelSelected = false; } private void destroyGUI() { mainWindowWidget.setVisible(false); mainWindowWidget.dispose(); System.gc(); mainWindowWidget = null; System.gc(); } public SceneEditorApplication(String[] args) { lookAndFeel = "javax.swing.plaf.metal.MetalLookAndFeel"; languageGuiFile = "./etc/english.gui"; createModel(); createGUI(); int i; for ( i = 0; i < args.length; i++ ) { if ( args[i].equals("-s") ) { networkServer = new VitralEditorServer(this); } } } public void doRaytracedImage() { raytracedImage.init(raytracedImageWidth, raytracedImageHeight); if ( theScene.selectedBackground == 1 ) { ImageProcessing.resize(theScene.fixedBackground.getImage(), raytracedImage); } theScene.raytrace(raytracedImage); } public void switchVoiceCommandClient() { String ip, port; if ( networkCommandClient == null ) { ip = (String)JOptionPane.showInputDialog( mainWindowWidget, // Component parentComponent gui.getMessage("IDM_VOICECOMMAND_IPQUESTION"), // Object message gui.getMessage("IDM_VOICECOMMAND_TITLE"), // String title JOptionPane.QUESTION_MESSAGE, // int messageType null, // Icon icon null, // Object[] selectionValues currentNetworkCommandClientIp // Object initialSelectionValue ); if ( ip == null ) { statusMessage.setText( gui.getMessage("IDM_OPERATION_CANCELLED_BY_USER") + " - " + gui.getMessage("IDM_VOICECOMMAND_DISABLED")); return; } currentNetworkCommandClientIp = ip; port = (String)JOptionPane.showInputDialog( mainWindowWidget, // Component parentComponent gui.getMessage("IDM_VOICECOMMAND_PORTQUESTION"), // Object message gui.getMessage("IDM_VOICECOMMAND_TITLE"), // String title JOptionPane.QUESTION_MESSAGE, // int messageType null, // Icon icon null, // Object[] selectionValues currentNetworkCommandClientPort // Object initialSelectionValue ); if ( port == null ) { statusMessage.setText( gui.getMessage("IDM_OPERATION_CANCELLED_BY_USER") + " - " + gui.getMessage("IDM_VOICECOMMAND_DISABLED")); return; } currentNetworkCommandClientPort = port; networkCommandClient = new VitralCommandClient(this, currentNetworkCommandClientIp, Integer.parseInt(currentNetworkCommandClientPort)); Thread ct = new Thread(networkCommandClient); ct.start(); statusMessage.setText( gui.getMessage("IDM_VOICECOMMAND_ENABLED")); } else { networkCommandClient.running = false; statusMessage.setText( gui.getMessage("IDM_VOICECOMMAND_DISABLED")); networkCommandClient = null; } } public void closeApplication() { if ( networkCommandClient != null ) { networkCommandClient.end(); } System.exit(0); } public void externalCommand(String label) { executorPanel.executeCommand(label); } public static void main(String[] args) { // Note that this is a thread-safe invocation of the GUI MainThread mt = new MainThread(args); javax.swing.SwingUtilities.invokeLater(mt); }}//===========================================================================//= EOF =//===========================================================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -