01: /*
02: * $Header: /cvs/j3dfly/J3dEditor/src/org/jdesktop/j3dedit/editormodules/AnimationEditorModule.java,v 1.2 2005/04/22 18:35:32 paulby Exp $
03: *
04: * Sun Public License Notice
05: *
06: * The contents of this file are subject to the Sun Public License Version
07: * 1.0 (the "License"). You may not use this file except in compliance with
08: * the License. A copy of the License is available at http://www.sun.com/
09: *
10: * The Original Code is the Java 3D(tm) Scene Graph Editor.
11: * The Initial Developer of the Original Code is Paul Byrne.
12: * Portions created by Paul Byrne are Copyright (C) 2002.
13: * All Rights Reserved.
14: *
15: * Contributor(s): Paul Byrne.
16: *
17: **/
18: package org.jdesktop.j3dedit.editormodules;
19:
20: import org.jdesktop.j3dedit.J3dEdit;
21:
22: /**
23: *
24: * @author paulby
25: * @version
26: */
27: public class AnimationEditorModule extends AbstractEditorModule {
28:
29: private org.jdesktop.j3dfly.animation.statecontrol.StateEditor stateEditor = null;
30: private J3dFlyEditorModule j3dFlyModule;
31: private J3dEdit j3dEdit;
32:
33: /** Creates new AnimationEditorModule */
34: public AnimationEditorModule(J3dEdit j3dEdit,
35: J3dFlyEditorModule j3dFlyModule) {
36: this .j3dFlyModule = j3dFlyModule;
37: this .j3dEdit = j3dEdit;
38: }
39:
40: /**
41: * Return the name of the module.
42: /*
43: * The name will be used in the mode button for selecting this
44: * module
45: */
46: public String getModuleName() {
47: return "Animation Editor";
48: }
49:
50: /**
51: * Activate/Deactive this module.
52: *
53: * When a module is activated this method will create, display and
54: * arrange all the windows.
55: *
56: * When deactived the windows are hidden and possibly destroyed
57: */
58: public void setActive(boolean active) {
59: System.out.println("Animation Editor active:" + active);
60: if (active)
61: activate();
62: else
63: deactive();
64: }
65:
66: private void activate() {
67: if (stateEditor == null)
68: stateEditor = new org.jdesktop.j3dfly.animation.statecontrol.StateEditor(
69: j3dFlyModule.getContext());
70:
71: java.awt.Dimension screenSize = java.awt.Toolkit
72: .getDefaultToolkit().getScreenSize();
73:
74: int minY = j3dEdit.getSize().height; // Top of available area
75: int midY = screenSize.height / 2 + minY / 2; // Mid point Y of available area
76:
77: j3dFlyModule.setBounds(screenSize.width / 2, minY,
78: screenSize.width / 2, midY - minY);
79: stateEditor.setBounds(0, midY, screenSize.width,
80: screenSize.height - midY);
81: stateEditor.setVisible(true);
82: }
83:
84: private void deactive() {
85: // TODO Ask user to save changes ?
86: stateEditor.setVisible(false);
87: }
88: }
|