⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 viewer.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
    /**     * Set the ViewingPlatform object used by this Viewer.     *     * @param platform The ViewingPlatform object to set for this     *  Viewer object.  Use null to unset the current value and     *  not assign assign a new ViewingPlatform object.     */    public void setViewingPlatform(ViewingPlatform platform) {	if (viewingPlatform != null) {	    viewingPlatform.removeViewer(this);	}        viewingPlatform = platform;        if (platform != null) {            view.attachViewPlatform(platform.getViewPlatform());            platform.addViewer(this);            if (avatar != null)                viewingPlatform.setAvatar(this, avatar);        }        else            view.attachViewPlatform(null);    }    /**     * Get the ViewingPlatform object used by this Viewer.     *     * @return The ViewingPlatform object used by this     *  Viewer object.      */    public ViewingPlatform getViewingPlatform() {	return viewingPlatform;    }    /**     * Sets the geometry to be associated with the viewer's avatar.  The     * avatar is the geometry used to represent the viewer in the virtual     * world.     *     * @param avatar The geometry to associate with this Viewer object.     *  Passing in null will cause any geometry associated with the Viewer     *  to be removed from the scen graph.     */    public void setAvatar(ViewerAvatar avatar) {        // Just return if trying to set the same ViewerAvatar object.        if (this.avatar == avatar)            return;        this.avatar = avatar;        if (viewingPlatform != null)            viewingPlatform.setAvatar(this, this.avatar);    }    /**     * Gets the geometry associated with the viewer's avatar.  The     * avatar is the geometry used to represent the viewer in the virtual     * world.     *     * @return The root of the scene graph that is used to represent the     *  viewer's avatar.     */    public ViewerAvatar getAvatar() {        return avatar;    }    /**     * Returns the PhysicalBody object associated with the Viewer object.     *     * @return A reference to the PhysicalBody object.     */    public PhysicalBody getPhysicalBody() {        return physicalBody;    }    /**     * Returns the PhysicalEnvironment object associated with the Viewer     * object.     *     * @return A reference to the PhysicalEnvironment object.     */    public PhysicalEnvironment getPhysicalEnvironment() {        return physicalEnvironment;    }    /**     * Returns the 0th Canvas3D object associated with this Viewer object     *     * @return a reference to the 0th Canvas3D object associated with this     *  Viewer object     * @since Java3D 1.3     */    public Canvas3D getCanvas3D() {        return canvases[0];    }    /**     * Returns the Canvas3D object at the specified index associated with     * this Viewer object.     *     * @param canvasNum the index of the Canvas3D object to retrieve;     *  if there is no Canvas3D object for the given index, null is returned     * @return a reference to a Canvas3D object associated with this     *  Viewer object     * @since Java3D 1.3     */    public Canvas3D getCanvas3D(int canvasNum) {	if (canvasNum > canvases.length) {	    return null;	}        return canvases[canvasNum];    }    /**     * Returns all the Canvas3D objects associated with this Viewer object.     *     * @return an array of references to the Canvas3D objects associated with     *  this Viewer object     * @since Java3D 1.3     */    public Canvas3D[] getCanvas3Ds() {	Canvas3D[] ret = new Canvas3D[canvases.length];	for (int i = 0; i < canvases.length; i++) {	    ret[i] = canvases[i];	}        return ret;    }    /**     * Returns the canvas associated with this Viewer object.     * @deprecated superceded by getCanvas3D()     */    public Canvas3D getCanvases() {        return getCanvas3D();    }    /**     * This method is no longer supported since Java 3D 1.3.     * @exception UnsupportedOperationException if called.     * @deprecated AWT Frame components are no longer created by the     *  Viewer class.     */    public Frame getFrame() {        throw new UnsupportedOperationException(                "AWT Frame components are not created by the Viewer class");    }    /**     * Returns the JFrame object created by this Viewer object at the     * specified index.  If a Viewer is constructed without any Canvas3D     * objects then the Viewer object will create a Canva3D object, a JPanel     * containing the Canvas3D object, and a JFrame to place the JPanel in.     * <p>     * NOTE: When running under JDK 1.4 or newer, the JFrame always directly     * contains the JPanel which contains the Canvas3D.  When running under     * JDK 1.3.1 and creating a borderless full screen through a configuration     * file, the JFrame will instead contain a JWindow which will contain the     * JPanel and Canvas3D.     * <p>     * @param frameNum the index of the JFrame object to retrieve;     *  if there is no JFrame object for the given index, null is returned     * @return a reference to JFrame object created by this Viewer object     * @since Java3D 1.3     */    public JFrame getJFrame(int frameNum) {	if (j3dJFrames == null || frameNum > j3dJFrames.length) {	    return(null);	}        return j3dJFrames[frameNum];    }    /**     * Returns all the JFrames created by this Viewer object.  If a Viewer is     * constructed without any Canvas3D objects then the Viewer object will     * create a Canva3D object, a JPanel containing the Canvas3D object, and a     * JFrame to place the JPanel in.<p>     *      * NOTE: When running under JDK 1.4 or newer, the JFrame always directly     * contains the JPanel which contains the Canvas3D.  When running under     * JDK 1.3.1 and creating a borderless full screen through a configuration     * file, the JFrame will instead contain a JWindow which will contain the     * JPanel and Canvas3D.<p>     *     * @return an array of references to the JFrame objects created by     *  this Viewer object, or null if no JFrame objects were created     * @since Java3D 1.3     */    public JFrame[] getJFrames() {	if (j3dJFrames == null)	    return null;	JFrame[] ret = new JFrame[j3dJFrames.length];	for (int i = 0; i < j3dJFrames.length; i++) {	    ret[i] = j3dJFrames[i];	}        return ret;    }    /**     * This method is no longer supported since Java 3D 1.3.     * @exception UnsupportedOperationException if called.     * @deprecated AWT Panel components are no longer created by the     * Viewer class.     */    public Panel getPanel() {        throw new UnsupportedOperationException(                "AWT Panel components are not created by the Viewer class");    }    /**     * Returns the JPanel object created by this Viewer object at the     * specified index.  If a Viewer is constructed without any Canvas3D     * objects then the Viewer object will create a Canva3D object and a     * JPanel into which to place the Canvas3D object.     *     * @param panelNum the index of the JPanel object to retrieve;     *  if there is no JPanel object for the given index, null is returned     * @return a reference to a JPanel object created by this Viewer object     * @since Java3D 1.3     */    public JPanel getJPanel(int panelNum) {	if (j3dJPanels == null || panelNum > j3dJPanels.length) {	    return(null);	}        return j3dJPanels[panelNum];    }    /**     * Returns all the JPanel objects created by this Viewer object.  If a     * Viewer is constructed without any Canvas3D objects then the Viewer     * object will create a Canva3D object and a JPanel into which to place     * the Canvas3D object.     *     * @return an array of references to the JPanel objects created by     *  this Viewer object, or null or no JPanel objects were created     * @since Java3D 1.3     */    public JPanel[] getJPanels() {	if (j3dJPanels == null)	    return null;	JPanel[] ret = new JPanel[j3dJPanels.length];	for (int i = 0; i < j3dJPanels.length; i++) {	    ret[i] = j3dJPanels[i];	}        return ret;    }    /**     * Used to create and initialize a default AudioDevice3D used for sound     * rendering.     *     * @return reference to created AudioDevice, or null if error occurs.     */    public AudioDevice createAudioDevice() {	if (physicalEnvironment == null) {	    System.err.println("Java 3D: createAudioDevice: physicalEnvironment is null");	    return null;	}	try {	    String audioDeviceClassName =		(String) java.security.AccessController.doPrivileged(		    new java.security.PrivilegedAction() {			public Object run() {			    return System.getProperty("j3d.audiodevice");			}		    });	    if (audioDeviceClassName == null) {		throw new UnsupportedOperationException("No AudioDevice specified");	    }            // Issue 341: try the current class loader first before trying the            // system class loader	    Class audioDeviceClass = null;            try {                audioDeviceClass = Class.forName(audioDeviceClassName);            } catch (ClassNotFoundException ex) {                // Ignore excpetion and try system class loader            }            if (audioDeviceClass == null) {                ClassLoader audioDeviceClassLoader =                    (ClassLoader) java.security.AccessController.doPrivileged(                        new java.security.PrivilegedAction() {                            public Object run() {                                return ClassLoader.getSystemClassLoader();                            }                        });                if (audioDeviceClassLoader == null) {                    throw new IllegalStateException("System ClassLoader is null");                }                audioDeviceClass = Class.forName(audioDeviceClassName, true, audioDeviceClassLoader);            }	    Class physEnvClass = PhysicalEnvironment.class;	    Constructor audioDeviceConstructor =		    audioDeviceClass.getConstructor(new Class[] {physEnvClass});	    PhysicalEnvironment[] args = new PhysicalEnvironment[] { physicalEnvironment };	    AudioEngine3DL2 mixer =		(AudioEngine3DL2) audioDeviceConstructor.newInstance((Object[])args);	    mixer.initialize();	    return mixer;	}	catch (Throwable e) {	    e.printStackTrace();	    physicalEnvironment.setAudioDevice(null);	    System.err.println("Java 3D: audio is disabled");	    return null;	}    }    /**     * Returns the Universe to which this Viewer is attached     *     * @return the Universe to which this Viewer is attached     * @since Java 3D 1.3     */    public SimpleUniverse getUniverse() {        return getViewingPlatform().getUniverse();    }    /*     * Exit if run as an application     */    void addWindowCloseListener(Window win) {	SecurityManager sm = System.getSecurityManager();	boolean doExit = true;	if (sm != null) {	    try {		sm.checkExit(0);	    } catch (SecurityException e) {		doExit = false;	    }	}	final boolean _doExit = doExit;	win.addWindowListener(new WindowAdapter() {            public void windowClosing(WindowEvent winEvent) {		Window w = winEvent.getWindow();		w.setVisible(false);		try {		    w.dispose();		} catch (IllegalStateException e) {}		if (_doExit) {		    System.exit(0);		}	    }	});    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -