2 Copyright (C) 2001, 2006 United States Government
3 as represented by the Administrator of the
4 National Aeronautics and Space Administration.
7 package gov
.nasa
.worldwind
.awt
;
9 import gov
.nasa
.worldwind
.*;
11 import javax
.media
.opengl
.*;
14 public class WorldWindowGLJPanel
extends GLJPanel
implements WorldWindow
16 private final WorldWindowGLAutoDrawable wwd
; // everything delegates to wwd
17 private gov
.nasa
.worldwind
.InputHandler inputHandler
;
20 * Constructs a new <code>WorldWindowGLCanvas</code> window on the default graphics device.
22 public WorldWindowGLJPanel()
26 this.wwd
= new WorldWindowGLAutoDrawable(this); // TODO: Make class configurable
28 this.createDefaultEventSource();
32 String message
= WorldWind
.retrieveErrMsg("awt.WorldWindowGLSurface.UnabletoCreateWindow");
33 WorldWind
.logger().log(java
.util
.logging
.Level
.FINE
, message
);
34 throw new gov
.nasa
.worldwind
.WWRuntimeException(message
, e
);
39 * Constructs a new <code>WorldWindowGLJPanel</code> window on the default graphics device that will share graphics
40 * resources with another <code>WorldWindowGLJPanel</code> window. The other window, <code>sharewith</code>, may not be
43 * @param shareWith a <code>WorldWindowGLJPanel</code> with which to share graphics resources.
44 * @throws NullPointerException if shareWith is null
45 * @see GLCanvas#GLCanvas(GLCapabilities,GLCapabilitiesChooser,GLContext,GraphicsDevice)
47 public WorldWindowGLJPanel(WorldWindowGLCanvas shareWith
)
49 super(null, null, shareWith
.getContext());
52 this.wwd
= new WorldWindowGLAutoDrawable(this);
54 this.createDefaultEventSource();
58 String message
= WorldWind
.retrieveErrMsg("awt.WorldWindowGLSurface.UnabletoCreateWindow");
59 WorldWind
.logger().log(java
.util
.logging
.Level
.FINE
, message
);
60 throw new gov
.nasa
.worldwind
.WWRuntimeException(message
, e
);
65 * Constructs a new <code>WorldWindowGLJPanel</code> window that will share graphics resources with another
66 * <code>WorldWindowGLJPanel</code> window. The new window is created on the specified graphics device. Neither <code>
67 * shareWith</code> or <code>device</code> may be null.
69 * @param shareWith a <code>WorldWindowGLCanvas</code> with which to share graphics resources.
70 * @param device the <code>GraphicsDevice</code> on which to create the window.
71 * @throws NullPointerException if <code>shareWith</code> is null
72 * @throws IllegalArgumentException if <code>deevice</code> is null
73 * @see GLCanvas#GLCanvas(GLCapabilities,GLCapabilitiesChooser,GLContext,GraphicsDevice)
75 public WorldWindowGLJPanel(WorldWindowGLCanvas shareWith
, java
.awt
.GraphicsDevice device
)
77 super(null, null, shareWith
.getContext());
81 String msg
= WorldWind
.retrieveErrMsg("nullValue.DeviceIsNull");
82 WorldWind
.logger().log(java
.util
.logging
.Level
.FINE
, msg
);
83 throw new IllegalArgumentException(msg
);
87 this.wwd
= new WorldWindowGLAutoDrawable(this);
89 this.createDefaultEventSource();
93 String message
= WorldWind
.retrieveErrMsg("awt.WorldWindowGLSurface.UnabletoCreateWindow");
94 WorldWind
.logger().log(java
.util
.logging
.Level
.FINE
, message
);
95 throw new WWRuntimeException(message
, e
);
99 private void createView()
101 this.setView((View
) WorldWind
.createConfigurationComponent(AVKey
.VIEW_CLASS_NAME
));
104 private void createDefaultEventSource()
106 this.inputHandler
= new gov
.nasa
.worldwind
.awt
.AWTInputHandler();
107 this.inputHandler
.setEventSource(this);
110 public InputHandler
getInputHandler()
115 public void setInputHandler(InputHandler eventSource
)
117 if (this.inputHandler
!= null)
118 this.inputHandler
.setEventSource(null); // remove this window as a source of events
120 this.inputHandler
= eventSource
;
121 if (this.inputHandler
!= null)
122 this.inputHandler
.setEventSource(this);
125 public SceneController
getSceneController()
127 return this.wwd
.getSceneController();
130 public PickedObjectList
pick(java
.awt
.Point pickPoint
)
132 return this.wwd
.pick(pickPoint
);
135 public void setModel(Model model
)
137 // null models are permissible
138 this.wwd
.setModel(model
);
141 public Model
getModel()
143 return this.wwd
.getModel();
146 public void setView(View view
)
148 // null views are permissible
150 this.wwd
.setView(view
);
153 public View
getView()
155 return this.wwd
.getView();
158 public void setModelAndView(Model model
, View view
)
159 { // null models/views are permissible
160 this.setModel(model
);
164 public void addRenderingListener(RenderingListener listener
)
166 this.wwd
.addRenderingListener(listener
);
169 public void removeRenderingListener(RenderingListener listener
)
171 this.wwd
.removeRenderingListener(listener
);
174 public void addSelectListener(SelectListener listener
)
176 this.inputHandler
.addSelectListener(listener
);
179 public void removeSelectListener(SelectListener listener
)
181 this.inputHandler
.removeSelectListener(listener
);
184 public void addPositionListener(PositionListener listener
)
188 public void removePositionListener(PositionListener listener
)