001: /*
002: * $Header: /cvs/j3dfly/J3dFly/src/org/jdesktop/j3dfly/J3dFlyContext.java,v 1.1 2005/04/20 21:04:20 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 Java 3D(tm) Fly Through.
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.j3dfly;
019:
020: import javax.media.j3d.VirtualUniverse;
021: import com.sun.j3d.utils.universe.SimpleUniverse;
022: import org.jdesktop.j3dfly.utils.developmenttools.DevelopmentLocale;
023: import org.jdesktop.j3dfly.event.EventProcessor;
024: import org.jdesktop.j3dfly.namecontrol.NameControl;
025: import org.jdesktop.j3dfly.plugins.PluginPreferenceControl;
026: import org.jdesktop.j3dfly.J3dFly;
027:
028: import java.util.ArrayList;
029: import javax.swing.JMenuBar;
030: import javax.swing.JPanel;
031:
032: /**
033: * This object incapsulates all the unique objects required to render and
034: * manipulate a universe
035: *
036: * @author Paul Byrne
037: * @version $Revision: 1.1 $
038: */
039: public class J3dFlyContext {
040:
041: //protected DevelopmentLocale locale=null;
042: protected SimpleUniverse universe = null;
043: protected NameControl nameControl = null;
044: protected EventProcessor eventProcessor = null;
045: protected PluginPreferenceControl pluginPrefControl = null;
046: protected J3dFly j3dFly = null;
047: protected ArrayList locales = new ArrayList();
048: protected JMenuBar mainMenuBar = null;
049: protected JPanel toolBarPanel = null;
050:
051: protected J3dFlyContext() {
052: }
053:
054: /** Creates new J3dFlyContext */
055: public J3dFlyContext(DevelopmentLocale locale, J3dFly j3dFly) {
056: this .j3dFly = j3dFly;
057: this .mainMenuBar = j3dFly.getMainMenuBar();
058: this .toolBarPanel = j3dFly.getToolBarPanel();
059:
060: locales.add(locale);
061:
062: // If check is a hack for the interposer.
063: // TODO - Rearchitect
064: if (locale.getVirtualUniverse() instanceof SimpleUniverse)
065: this .universe = (SimpleUniverse) locale
066: .getVirtualUniverse();
067: else
068: this .universe = null;
069: }
070:
071: public SimpleUniverse getUniverse() {
072: return universe;
073: }
074:
075: /**
076: * Used to set the universe when the interposer is being used
077: */
078: void setUniverse(SimpleUniverse universe) {
079: this .universe = universe;
080: }
081:
082: /**
083: * Returns the first locale.
084: *
085: * @deprecated use getLocale( index )
086: */
087: public DevelopmentLocale getLocale() {
088: return (DevelopmentLocale) locales.get(0);
089: }
090:
091: public NameControl getNameControl() {
092: if (nameControl == null)
093: nameControl = new NameControl();
094:
095: return nameControl;
096: }
097:
098: public EventProcessor getEventProcessor() {
099: if (eventProcessor == null)
100: eventProcessor = new EventProcessor();
101:
102: return eventProcessor;
103: }
104:
105: /**
106: * Returns the Plugin Preferences for this Universe
107: */
108: public PluginPreferenceControl getPluginPreferenceControl() {
109: if (pluginPrefControl == null)
110: pluginPrefControl = new PluginPreferenceControl();
111:
112: return pluginPrefControl;
113: }
114:
115: public J3dFly getJ3dFly() {
116: return j3dFly;
117: }
118:
119: public void addLocale(DevelopmentLocale locale) {
120: locales.add(locale);
121: }
122:
123: public int numLocales() {
124: if (locales == null)
125: return 0;
126:
127: return locales.size();
128: }
129:
130: public DevelopmentLocale getLocale(int index) {
131: return (DevelopmentLocale) locales.get(index);
132: }
133:
134: /**
135: * Returns the menu bar for j3dFly
136: *
137: * The menu created when the main window is created but it has
138: * no submenus be default. Each plugin will call this method and
139: * add itself to the set of menus
140: */
141: public JMenuBar getMainMenuBar() {
142: return mainMenuBar;
143: }
144:
145: public JPanel getToolBarPanel() {
146: return toolBarPanel;
147: }
148:
149: }
|