Package org.digibots.deployment

Source Code of org.digibots.deployment.StandAloneApp

/**
* "Digibots" sourcecode is licensed under the
* CeCILL license
*
* Made early 2007 by Amos Wenger, Olivier Charvet
* and Quentin Merleau
*/
package org.digibots.deployment;

import java.awt.Dimension;

import javax.swing.JFrame;

import org.digibots.application.Application;
import org.digibots.application.DigiBotsApplication;
import org.xith3d.loop.RenderLoop;
import org.xith3d.loop.RenderLoopListener;
import org.xith3d.loop.UpdatingThread.TimingMode;

/**
* Main Digibot class (application)
*
* @author Amos Wenger (aka BlueSky)
*/
public class StandAloneApp implements RenderLoopListener {
   
    private JFrame frame;
    private Application app;
   
    public void onRenderLoopStarted(RenderLoop rl)
    {
        frame.setVisible(true);
       
        final int dw = frame.getWidth() - app.getCanvas().getWidth();
        final int dh = frame.getHeight() - app.getCanvas().getHeight();
        frame.setSize( frame.getWidth() + dw, frame.getHeight() + dh );
       
        rl.removeRenderLoopListener(this);
    }
   
    public void onRenderLoopPaused(RenderLoop rl, long gameTime, TimingMode timingMode, int pauseMode) {
    }
   
    public void onRenderLoopResumed(RenderLoop rl, long gameTime, TimingMode timingMode, int pauseMode) {
    }
   
    public void onRenderLoopStopped(RenderLoop rl, long gameTime, TimingMode timingMode, float averageFPS) {
    }
   
    private StandAloneApp() throws Exception {
       
        System.out.println("StandAloneApp constructor...");
       
        /*
         * Frame
         */
        this.frame = new JFrame("Digibots");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Dimension size = new Dimension(810, 625);
        frame.setSize(size);
        frame.setLocationRelativeTo(null);
       
        this.app = new DigiBotsApplication(frame.getContentPane(), size.width, size.height, this);
       
    }
   
    /**
     * Main method
     * @param argv
     */
    public static void main(String argv[]) throws Exception {
       
        new StandAloneApp();
       
    }
}
TOP

Related Classes of org.digibots.deployment.StandAloneApp

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.