/*****************************************************************************
 *                        Web3d.org Copyright (c) 2001-2007
 *                               Java Source
 *
 * This source is licensed under the BSD license.
 * Please read docs/BSD.txt for the text of the license.
 *
 * This software comes with the standard NO WARRANTY disclaimer for any
 * purpose. Use it at your own risk. If there's a problem you get to fix it.
 *
 ****************************************************************************/

import java.awt.*;
import java.util.*;
import javax.swing.*;

import org.web3d.x3d.sai.*;

/**
 * An example of how to change the appearance of an Xj3D component
 *
 * @author Alan Hudson
 * @version
 */
public class Xj3DAppearanceDemo extends JFrame {

    /**
     * Constructor for the demo.
     */
    public Xj3DAppearanceDemo() {
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        Container contentPane = getContentPane();


        Properties skinProperties = new Properties();
        skinProperties.setProperty("touchSensor.cursor", "CursorFly.gif");
        skinProperties.setProperty("OPEN.button", "CursorFly.gif");

        HashMap params = new HashMap();
        params.put("Xj3D_Skin_Properties", skinProperties);

        params.put("Xj3D_OpenButtonShown", Boolean.TRUE);

        // Create an SAI component
        X3DComponent x3dComp = BrowserFactory.createX3DComponent(params);

        // Add the component to the UI
        JComponent x3dPanel = (JComponent)x3dComp.getImplementation();
        contentPane.add(x3dPanel, BorderLayout.CENTER);

        // Get an external browser
        ExternalBrowser x3dBrowser = x3dComp.getBrowser();

        setSize(600,500);
        setVisible(true);


        // Create an X3D scene by loading a file.  Blocks till the world is loaded.
        X3DScene mainScene = x3dBrowser.createX3DFromURL(new String[] { "touchy_box.x3dv" });

        // Replace the current world with the new one
        x3dBrowser.replaceWorld(mainScene);
    }

    /**
     * Main method.
     *
     * @param args None handled
     */
    public static void main(String[] args) {

        Xj3DAppearanceDemo demo = new Xj3DAppearanceDemo();
    }
}
