001: /*
002: * $Header: /cvs/j3dfly/J3dEditor/src/org/jdesktop/j3dedit/editormodules/J3dFlyEditorModule.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.j3dfly.J3dFly;
021: import org.jdesktop.j3dfly.J3dFlyContext;
022: import org.jdesktop.j3dedit.J3dEdit;
023: import org.jdesktop.j3dedit.J3dEditContext;
024: import org.jdesktop.j3dfly.J3dFlyController;
025: import javax.media.j3d.Transform3D;
026: import com.sun.j3d.utils.universe.SimpleUniverse;
027:
028: /**
029: * This module is a special module and does not follow the normal module
030: * rules. For example the module even when not active is used by other
031: * modules to display the universe.
032: *
033: * @author paulby
034: * @version $Id: J3dFlyEditorModule.java,v 1.1 2005/04/20 22:20:30 paulby Exp $
035: */
036: public class J3dFlyEditorModule extends AbstractEditorModule {
037:
038: protected J3dFly j3dFly;
039: protected J3dEdit j3dEdit;
040:
041: /** Creates new J3dFlyEditorModule */
042: public J3dFlyEditorModule(J3dEdit j3dEdit,
043: javax.swing.JPanel toolbarPanel) {
044: this (j3dEdit, toolbarPanel, null);
045: }
046:
047: /**
048: *
049: * @params universe When using the interposer this will contain the users universe
050: * otherwise it should be null
051: */
052: public J3dFlyEditorModule(J3dEdit j3dEdit,
053: javax.swing.JPanel toolbarPanel, SimpleUniverse universe) {
054: j3dFly = new J3dFly(
055: j3dEdit.getMainMenuBar(),
056: toolbarPanel,
057: false,
058: null,
059: J3dEditContext.class,
060: new org.jdesktop.j3dedit.scenegrapheditor.VisualToolManager(),
061: universe);
062: this .j3dEdit = j3dEdit;
063: j3dFly.getController().setCollisionEnabled(false);
064: Transform3D initialPos = new Transform3D();
065: initialPos.set(1.0, new javax.vecmath.Vector3d(0, 0, 20));
066: j3dFly.getUniverse().getViewingPlatform()
067: .getViewPlatformTransform().setTransform(initialPos);
068: }
069:
070: protected J3dFlyEditorModule() {
071: }
072:
073: /**
074: * Return the name of the module.
075: *
076: * The name will be used in the mode button for selecting this
077: * module
078: */
079: public String getModuleName() {
080: return "View Universe";
081: }
082:
083: /**
084: * Activate/Deactive this module.
085: *
086: * When a module is activated this method will create, display and
087: * arrange all the windows.
088: *
089: * When deactived the windows are hidden and possibly destroyed
090: */
091: public void setActive(boolean active) {
092: System.out.println("J3dFlyEditorModule active:" + active);
093: if (active) {
094: java.awt.Container container = j3dFly.getContainer();
095: java.awt.Dimension screenSize = container.getToolkit()
096: .getScreenSize();
097: int controlFrameEdge = j3dEdit.getEditorControlFrame()
098: .getWidth();
099:
100: container.setLocation(controlFrameEdge,
101: j3dEdit.getSize().height);
102: container.setSize(screenSize.width - controlFrameEdge,
103: screenSize.height - j3dEdit.getSize().height);
104: container.setVisible(true);
105: }
106: }
107:
108: /**
109: * Set the visible propert of the J3dFly window
110: */
111: public void setVisible(boolean visible) {
112: j3dFly.getContainer().setVisible(visible);
113: }
114:
115: /**
116: * Get the controller class for J3dFly
117: */
118: public J3dFlyController getController() {
119: return j3dFly.getController();
120: }
121:
122: /**
123: * Get the Universe
124: */
125: public J3dEditContext getContext() {
126: return (J3dEditContext) j3dFly.getCurrentContext();
127: }
128:
129: /**
130: * Set the bounds of the window
131: */
132: public void setBounds(int x, int y, int width, int height) {
133: j3dFly.getContainer().setBounds(x, y, width, height);
134: }
135: }
|