📄 virtualuniverse.java
字号:
cv.eventCatcher.disableMouseMotionEvents(); } } } } } void enableMouseMotionEvents() { Enumeration cvs; Canvas3D cv; View views[]; ViewPlatformRetained vp; Object[] vps = getViewPlatformList(); enableMouseMotion = true; if (vps != null) { for (int i=0; i<vps.length; i++) { vp =(ViewPlatformRetained)vps[i]; views = vp.getViewList(); for (int j=views.length-1; j>=0; j--) { cvs = views[j].getAllCanvas3Ds(); while(cvs.hasMoreElements()) { cv = (Canvas3D) cvs.nextElement(); // offscreen canvas does not have event catcher if (cv.eventCatcher != null) cv.eventCatcher.enableMouseMotionEvents(); } } } } } void disableMouseWheelEvents() { Enumeration cvs; Canvas3D cv; View views[]; ViewPlatformRetained vp; Object[] vps = getViewPlatformList(); enableMouseWheel = false; if (vps != null) { for (int i=0; i<vps.length; i++) { vp =(ViewPlatformRetained)vps[i]; views = vp.getViewList(); for (int j=views.length-1; j>=0; j--) { cvs = views[j].getAllCanvas3Ds(); while(cvs.hasMoreElements()) { cv = (Canvas3D) cvs.nextElement(); // offscreen canvas does not have event catcher if (cv.eventCatcher != null) cv.eventCatcher.disableMouseWheelEvents(); } } } } } void enableMouseWheelEvents() { Enumeration cvs; Canvas3D cv; View views[]; ViewPlatformRetained vp; Object[] vps = getViewPlatformList(); enableMouseWheel = true; if (vps != null) { for (int i=0; i<vps.length; i++) { vp =(ViewPlatformRetained)vps[i]; views = vp.getViewList(); for (int j=views.length-1; j>=0; j--) { cvs = views[j].getAllCanvas3Ds(); while(cvs.hasMoreElements()) { cv = (Canvas3D) cvs.nextElement(); // offscreen canvas does not have event catcher if (cv.eventCatcher != null) cv.eventCatcher.enableMouseWheelEvents(); } } } } } /** * Sets the "current" view (during view activation) for this virtual * universe. * @param last activated view */ final void setCurrentView(View view) { this.currentView = view; } /** * Returns the "current" view (the last view activated for this virtual * universe. * @return last activated view */ final View getCurrentView() { return this.currentView; } /** * Method to return the root thread group. This must be called from * within a doPrivileged block. */ static ThreadGroup getRootThreadGroup() { return rootThreadGroup; } /** * return true if all Locales under it don't have branchGroup * attach to it. */ boolean isEmpty() { Enumeration elm = listOfLocales.elements(); while (elm.hasMoreElements()) { Locale loc = (Locale) elm.nextElement(); if (!loc.branchGroups.isEmpty()) { return false; } } return true; } void resetWaitMCFlag() { synchronized (waitLock) { regViewWaiting = null; unRegViewWaiting = null; isSceneGraphLock = true; } } void waitForMC() { synchronized (waitLock) { if (unRegViewWaiting != null) { if ((regViewWaiting == null) || (regViewWaiting != unRegViewWaiting)) { while (!unRegViewWaiting.doneUnregister) { MasterControl.threadYield(); } unRegViewWaiting.doneUnregister = false; unRegViewWaiting = null; } } if (regViewWaiting != null) { while (!VirtualUniverse.mc.isRegistered(regViewWaiting)) { MasterControl.threadYield(); } regViewWaiting = null; } isSceneGraphLock = false; } } /** * Adds the specified GraphStructureChangeListener to the set of listeners * that will be notified when the graph structure is changed on a live * scene graph. If the specifed listener is null no action is taken and no * exception is thrown. * * @param listener the listener to add to the set. * * @since Java 3D 1.4 */ public void addGraphStructureChangeListener(GraphStructureChangeListener listener) { if (listener == null) { return; } if (structureChangeListenerSet == null) { structureChangeListenerSet = new HashSet(); } synchronized(structureChangeListenerSet) { structureChangeListenerSet.add(listener); } } /** * Removes the specified GraphStructureChangeListener from the set of listeners. This * method performs no function, nor does it throw an exception if the specified listener * is not currently in the set or is null. * * @param listener the listener to remove from the set. * * @since Java 3D 1.4 */ public void removeGraphStructureChangeListener(GraphStructureChangeListener listener) { if (structureChangeListenerSet == null) { return; } synchronized(structureChangeListenerSet) { structureChangeListenerSet.remove(listener); } } /** * Processes all live BranchGroup add and removes and notifies * any registered listeners. Used for add and remove */ void notifyStructureChangeListeners(boolean add, Object parent, BranchGroup child) { if (structureChangeListenerSet == null) { return; } synchronized(structureChangeListenerSet) { Iterator<GraphStructureChangeListener> it = structureChangeListenerSet.iterator(); while(it.hasNext()) { GraphStructureChangeListener listener = it.next(); try { if (add) { listener.branchGroupAdded(parent, child); } else { listener.branchGroupRemoved(parent, child); } } catch (RuntimeException e) { System.err.println("Exception occurred in GraphStructureChangeListener:"); e.printStackTrace(); } catch (Error e) { // Issue 264 - catch Error System.err.println("Error occurred in GraphStructureChangeListener:"); e.printStackTrace(); } } } } /** * Processes all live BranchGroup moves and notifies * any registered listeners. Used for moveTo */ void notifyStructureChangeListeners(Object oldParent, Object newParent, BranchGroup child) { if (structureChangeListenerSet == null) { return; } synchronized(structureChangeListenerSet) { Iterator<GraphStructureChangeListener> it = structureChangeListenerSet.iterator(); while(it.hasNext()) { GraphStructureChangeListener listener = it.next(); try { listener.branchGroupMoved(oldParent, newParent, child); } catch (RuntimeException e) { System.err.println("Exception occurred in GraphStructureChangeListener:"); e.printStackTrace(); } catch (Error e) { // Issue 264 - catch Error System.err.println("Error occurred in GraphStructureChangeListener:"); e.printStackTrace(); } } } } /** * Adds the specified ShaderErrorListener to the set of listeners * that will be notified when a programmable shader error is * detected on a live scene graph. If the specifed listener is * null no action is taken and no exception is thrown. * If a shader error occurs, the listeners will be called * asynchronously from a separate notification thread. The Java 3D * renderer and behavior scheduler will continue to run as if the * error had not occurred, except that shading will be disabled * for the objects in error. If applications desire to detach or * modify the scene graph as a result of the error, they should * use a behavior post if they want that change to be * synchronous with the renderer. * * @param listener the listener to add to the set. * * @since Java 3D 1.4 */ public void addShaderErrorListener(ShaderErrorListener listener) { if (listener == null) { return; } if (shaderErrorListenerSet == null) { shaderErrorListenerSet = new HashSet(); } synchronized(shaderErrorListenerSet) { shaderErrorListenerSet.add(listener); } } /** * Removes the specified ShaderErrorListener from the set of * listeners. This method performs no function, nor does it throw * an exception if the specified listener is not currently in the * set or is null. * * @param listener the listener to remove from the set. * * @since Java 3D 1.4 */ public void removeShaderErrorListener(ShaderErrorListener listener) { if (shaderErrorListenerSet == null) { return; } synchronized(shaderErrorListenerSet) { shaderErrorListenerSet.remove(listener); } } /** * Notifies all listeners of a shader error. If no listeners exist, a default * listener is notified. */ void notifyShaderErrorListeners(ShaderError error) { boolean errorReported = false; // Notify all error listeners in the set if (shaderErrorListenerSet != null) { synchronized(shaderErrorListenerSet) { Iterator<ShaderErrorListener> it = shaderErrorListenerSet.iterator(); while(it.hasNext()) { ShaderErrorListener listener = it.next(); try { listener.errorOccurred(error); } catch (RuntimeException e) { System.err.println("Exception occurred in ShaderErrorListener:"); e.printStackTrace(); } catch (Error e) { // Issue 264 - catch Error System.err.println("Error occurred in ShaderErrorListener:"); e.printStackTrace(); } errorReported = true; } } } // Notify the default error listener if the set is null or empty if (!errorReported) { defaultShaderErrorListener.errorOccurred(error); } } // Issue 260 : rendering error listeners. /** * Adds the specified RenderingErrorListener to the set of listeners * that will be notified when a rendering error is detected. * If the specifed listener is null no action is taken and no exception * is thrown. * If a rendering error occurs, the listeners will be called * asynchronously from a separate notification thread. If the set * of listeners is empty, a default listener is notified. The * default listener prints the error information to System.err and * then calls System.exit(). * * @param listener the listener to add to the set. * * @since Java 3D 1.5 */ public static void addRenderingErrorListener(RenderingErrorListener listener) { if (listener == null) { return; } if (renderingErrorListenerSet == null) { renderingErrorListenerSet = new HashSet(); } synchronized(renderingErrorListenerSet) { renderingErrorListenerSet.add(listener); } } /** * Removes the specified RenderingErrorListener from the set of * listeners. This method performs no function, nor does it throw * an exception if the specified listener is not currently in the * set or is null. * * @param listener the listener to remove from the set. * * @since Java 3D 1.5 */ public static void removeRenderingErrorListener(RenderingErrorListener listener) { if (renderingErrorListenerSet == null) { return; } synchronized(renderingErrorListenerSet) { renderingErrorListenerSet.remove(listener); } } /** * Notifies all listeners of a rendering error. If no listeners exist, * a default listener is notified. */ static void notifyRenderingErrorListeners(RenderingError error) { boolean errorReported = false; // Notify all error listeners in the set if (renderingErrorListenerSet != null) { synchronized(renderingErrorListenerSet) { Iterator<RenderingErrorListener> it = renderingErrorListenerSet.iterator(); while(it.hasNext()) { RenderingErrorListener listener = it.next(); try { listener.errorOccurred(error); } catch (RuntimeException e) { System.err.println("Exception occurred in RenderingErrorListener:"); e.printStackTrace(); } catch (Error e) { // Issue 264 - catch Error System.err.println("Error occurred in RenderingErrorListener:"); e.printStackTrace(); } errorReported = true; } } } // Notify the default error listener if the set is null or empty if (!errorReported) { defaultRenderingErrorListener.errorOccurred(error); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -