001: /*
002: * $Header: /cvs/j3dfly/J3dEditor/src/org/jdesktop/j3dedit/locationeditor/LocationEditor.java,v 1.1 2005/04/20 22:20:35 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.locationeditor;
019:
020: import javax.media.j3d.Node;
021: import javax.media.j3d.PathInterpolator;
022: import com.sun.j3d.utils.behaviors.interpolators.KBRotPosScaleSplinePathInterpolator;
023: import org.jdesktop.j3dedit.J3dEdit;
024: import org.jdesktop.j3dedit.locationeditor.ViewFrame;
025: import org.jdesktop.j3dedit.event.NamedObjectSelectionEvent;
026: import org.jdesktop.j3dfly.utils.developmenttools.DevelopmentLocale;
027: import org.jdesktop.j3dfly.event.FlyEventListener;
028:
029: /**
030: *
031: * @author paulby
032: * @version
033: */
034: public class LocationEditor implements FlyEventListener {
035:
036: private J3dEdit j3dEdit;
037: private ViewFrame xView = null;
038: private ViewFrame yView = null;
039: private ViewFrame zView = null;
040: private InterpolatorControlPanel interpolatorControlPanel = null;
041: private DevelopmentLocale locale;
042:
043: private PointScaleFrame pointScale = null;
044:
045: private ViewFrameGroup viewGroup;
046:
047: /** Creates new AnimationEditorModule */
048: public LocationEditor(J3dEdit j3dEdit, DevelopmentLocale locale) {
049: this .j3dEdit = j3dEdit;
050: this .locale = locale;
051: viewGroup = new ViewFrameGroup();
052: }
053:
054: /**
055: * Activate/Deactive this module.
056: *
057: * When a module is activated this method will create, display and
058: * arrange all the windows.
059: *
060: * When deactived the windows are hidden and possibly destroyed
061: */
062: public void setActive(boolean active) {
063: if (active) {
064: activate();
065: j3dEdit.getContext().getEventProcessor().addListener(this ,
066: NamedObjectSelectionEvent.class);
067: } else {
068: xView.setVisible(false);
069: yView.setVisible(false);
070: zView.setVisible(false);
071: j3dEdit.getContext().getEventProcessor().removeListener(
072: this , NamedObjectSelectionEvent.class);
073: }
074:
075: //universe.setLive( false );
076: xView.setActive(active);
077: yView.setActive(active);
078: zView.setActive(active);
079: //universe.setLive( true );
080: }
081:
082: private void activate() {
083: java.awt.Dimension screenSize = java.awt.Toolkit
084: .getDefaultToolkit().getScreenSize();
085:
086: int viewWidth = 420;
087: int viewHeight = 380;
088:
089: int minY = j3dEdit.getSize().height; // Top of available area
090: int midY = screenSize.height / 2 + minY / 2; // Mid point Y of available area
091: java.awt.GraphicsConfiguration config = com.sun.j3d.utils.universe.SimpleUniverse
092: .getPreferredConfiguration();
093:
094: if (xView == null) {
095: xView = new ViewFrame(config, locale, 0, viewGroup);
096: xView.setTitle("Right Side");
097: xView.setBounds(screenSize.width - viewWidth * 2, minY,
098: viewWidth, viewHeight);
099: }
100:
101: if (yView == null) {
102: yView = new ViewFrame(config, locale, 1, viewGroup);
103: yView.setTitle("Top");
104: yView.setBounds(screenSize.width - viewWidth * 2, minY
105: + viewHeight, viewWidth, viewHeight);
106: }
107:
108: if (zView == null) {
109: zView = new ViewFrame(config, locale, 2, viewGroup);
110: zView.setTitle("Front");
111: zView.setBounds(screenSize.width - viewWidth, minY
112: + viewHeight, viewWidth, viewHeight);
113: }
114:
115: /*
116: * TODO Implement the backend of the interpolator control panel. The
117: * GUI is in reasonable state, just uncoment this code
118: if (interpolatorControlPanel==null) {
119: interpolatorControlPanel = new InterpolatorControlPanel();
120: javax.swing.JFrame alphaFrame = new javax.swing.JFrame();
121: //alphaFrame.setUndecorated( true );
122: alphaFrame.getContentPane().add( interpolatorControlPanel, java.awt.BorderLayout.CENTER );
123: alphaFrame.setBounds( 0, minY+viewHeight*2, screenSize.width, screenSize.height-(minY+viewHeight*2) );
124: alphaFrame.setVisible( true );
125: }
126: */
127:
128: xView.setVisible(true);
129: yView.setVisible(true);
130: zView.setVisible(true);
131:
132: if (interpolatorControlPanel != null)
133: interpolatorControlPanel.setVisible(true);
134: }
135:
136: private void edit(KBRotPosScaleSplinePathInterpolator node) {
137: System.out.println("Editing KBRotoPOs...");
138: }
139:
140: private void edit(PathInterpolator node) {
141: }
142:
143: /**
144: * Called by EventProcessor when an event occurs for which this
145: * listener has registered interest
146: */
147: public void processFlyEvent(org.jdesktop.j3dfly.event.FlyEvent evt) {
148: System.out.println(evt);
149: if (evt instanceof NamedObjectSelectionEvent
150: && ((NamedObjectSelectionEvent) evt).getType() == NamedObjectSelectionEvent.BEHAVIOR) {
151: Node n = (Node) j3dEdit
152: .getContext()
153: .getNameControl()
154: .getNamedObject(
155: ((NamedObjectSelectionEvent) evt).getName());
156: if (n instanceof KBRotPosScaleSplinePathInterpolator)
157: edit((KBRotPosScaleSplinePathInterpolator) n);
158: }
159: }
160:
161: }
|