001: /*
002: * $Header: /cvs/j3dfly/J3dEditor/src/org/jdesktop/j3dedit/editormodules/SceneGraphEditorModule.java,v 1.1 2005/04/20 22:20:30 paulby Exp $
003: *
004: * Sun Public License Notice
005: *
006: * The contents of this file are subject to the Sun Public License Version
007: * 1.0 (the "License"). You may not use this file except in compliance with
008: * the License. A copy of the License is available at http://www.sun.com/
009: *
010: * The Original Code is the Java 3D(tm) Scene Graph Editor.
011: * The Initial Developer of the Original Code is Paul Byrne.
012: * Portions created by Paul Byrne are Copyright (C) 2002.
013: * All Rights Reserved.
014: *
015: * Contributor(s): Paul Byrne.
016: *
017: **/
018: package org.jdesktop.j3dedit.editormodules;
019:
020: import org.jdesktop.j3dedit.J3dEdit;
021: import org.jdesktop.j3dedit.J3dEditContext;
022: import org.jdesktop.j3dedit.scenegrapheditor.Editor;
023: import org.jdesktop.j3dedit.scenegrapheditor.J3dTreePanel;
024: import org.jdesktop.j3dedit.scenegrapheditor.ConfigLoader;
025:
026: import javax.swing.JRadioButtonMenuItem;
027: import javax.swing.ButtonGroup;
028: import org.jdesktop.j3dedit.scenegraph.SGObject;
029:
030: /**
031: *
032: * @author paulby
033: * @version
034: */
035: public class SceneGraphEditorModule extends AbstractEditorModule {
036:
037: private Editor sgEditor = null;
038: private J3dFlyEditorModule j3dFlyModule;
039: private J3dEdit j3dEdit;
040:
041: /** Creates new AnimationEditorModule */
042: public SceneGraphEditorModule(J3dEdit j3dEdit,
043: J3dFlyEditorModule j3dFlyModule) {
044: this .j3dFlyModule = j3dFlyModule;
045: this .j3dEdit = j3dEdit;
046: sgEditor = new Editor(j3dFlyModule.getContext(), false);
047: j3dEdit.getLeftToolbarPanel().add(
048: j3dFlyModule.getContext().getConfigLoader()
049: .getJ3dNodesToolbar().getTabPane());
050:
051: // Add packer to tab pane to force it to put all tabs on one line
052: javax.swing.JPanel p = new javax.swing.JPanel();
053: p.setPreferredSize(new java.awt.Dimension(250, 10));
054: ((javax.swing.JPanel) j3dFlyModule.getContext()
055: .getConfigLoader().getJ3dNodesToolbar().getTabPane()
056: .getComponentAt(0)).add(p);
057:
058: }
059:
060: /**
061: * Return the name of the module.
062: *
063: * The name will be used in the mode button for selecting this
064: * module
065: */
066: public String getModuleName() {
067: return "SceneGraph Editor";
068: }
069:
070: /**
071: * Activate/Deactive this module.
072: *
073: * When a module is activated this method will create, display and
074: * arrange all the windows.
075: *
076: * When deactived the windows are hidden and possibly destroyed
077: */
078: public void setActive(boolean active) {
079: System.out.println("SceneGraph Editor active:" + active);
080: if (active)
081: activate();
082: else
083: deactivate();
084: }
085:
086: private void activate() {
087: java.awt.Dimension screenSize = java.awt.Toolkit
088: .getDefaultToolkit().getScreenSize();
089:
090: int controlFrameEdge = j3dEdit.getEditorControlFrame()
091: .getWidth();
092:
093: int minY = j3dEdit.getSize().height; // Top of available area
094: int midY = screenSize.height / 2 + minY / 2; // Mid point Y of available area
095:
096: int flyX = controlFrameEdge + 600;
097:
098: if (j3dFlyModule != null) {
099: j3dFlyModule.setBounds(flyX, minY + 350, screenSize.width
100: - flyX, midY - minY);
101: j3dFlyModule.setVisible(true);
102: }
103:
104: sgEditor.getTreeFrame().setBounds(controlFrameEdge, minY, 600,
105: 600);
106:
107: sgEditor.getEditorFrame().setBounds(flyX, minY,
108: screenSize.width - flyX, 350);
109:
110: sgEditor.setActive(true);
111: }
112:
113: private void deactivate() {
114: sgEditor.setActive(false);
115: }
116:
117: /**
118: * Called when the module is added to the editor. The module should
119: * add any menu items it requires to the menus in the menu bar.
120: *
121: */
122: public void populateMenuBar(javax.swing.JMenuBar menuBar) {
123: javax.swing.JMenu viewMenu = getMenu(j3dFlyModule, "View");
124: sgEditor.updateViewMenu(viewMenu);
125: }
126:
127: /**
128: * Make preperations to save a project
129: *
130: * The scenegraph will not be live when this method is called
131: */
132: public void prepareToSave() {
133: sgEditor.prepareToSave();
134: }
135:
136: /**
137: * Save operation is complete, return system to runtime state
138: */
139: public void saveComplete() {
140: sgEditor.saveComplete();
141: }
142:
143: public SGObject getRoot() {
144: return ((J3dEditContext) j3dFlyModule.getContext())
145: .getSceneGraphControl().getViewRoot();
146: }
147: }
|