package com.nucleus.renderer;

import com.nucleus.J2SEWindow;
import com.nucleus.SimpleLogger;

/**
 * The size of the renderable area, this is a singleton class since only one instance of GL is supported.
 * Alse keeps a reference to create J2SEWindow if created on the platform.
 * 
 * @author Richard Sahlin
 *
 */
public class Window {

    private static Window window = null;

    int width;
    int height;
    J2SEWindow platformWindow;

    /**
     * The display resolution, ie the full resolution of the display
     */
    int[] screenSize;

    /**
     * Hide instantiation from clients.
     */
    private Window() {
    }

    /**
     * Returns the Window instance, this will always be the same.
     * 
     * @return Window instance (singleton)
     */
    public static Window getInstance() {
        if (window == null) {
            window = new Window();
        }
        return window;
    }

    /**
     * Sets the size of the window area, ie the renderable area. This is an internal method.
     * 
     * @param width
     * @param height
     */
    protected void setSize(int width, int height) {
        SimpleLogger.d(getClass(), "setSize() " + width + ", " + height);
        this.width = width;
        this.height = height;
    }

    /**
     * Sets the size of the screen, ie total number of pixels on display - may be bigger than window size.
     * Do not call this method directly, it is initialized by implementations (JOGL, Android, LWJGL)
     * 
     * @param width
     * @param height
     */
    public void setScreenSize(int width, int height) {
        SimpleLogger.d(getClass(), "setScreenSize() " + width + ", " + height);
        this.screenSize = new int[] { width, height };
    }

    /**
     * Sets the window created on the platform, not valid for Android
     * 
     * @param platformWindow
     */
    public void setPlatformWindow(J2SEWindow platformWindow) {
        this.platformWindow = platformWindow;
    }

    /**
     * Sets the title of the platform window
     * 
     * @param title
     */
    public void setTitle(String title) {
        if (platformWindow != null) {
            platformWindow.setWindowTitle(title);
        }
    }

    /**
     * Returns the width of the visible window
     * 
     * @return Width in pixels.
     */
    public int getWidth() {
        return width;
    }

    /**
     * Returns the height of the visible window
     * 
     * @return Height in pixels
     */
    public int getHeight() {
        return height;
    }

    /**
     * Returns the total display size
     * 
     * @return
     */
    public int[] getScreenSize() {
        return screenSize;
    }

}

@@ -87,16 +87,69 @@
 eLogger;
+%0Aimport com.nucleus.resource.ResourceBias.RESOLUTION;
 %0A%0A/**%0A *
@@ -598,16 +598,144 @@
 eenSize;
+%0A    /**%0A     * Best fit resolution for the display - use this to figure out image scale bias%0A     */%0A    RESOLUTION resolution;
 %0A%0A    /*
@@ -1905,16 +1905,71 @@
 ight %7D;%0A
+        resolution = RESOLUTION.getResolution(height);%0A
     %7D%0A%0A 
@@ -2910,10 +2910,191 @@
 %0A    %7D%0A%0A
+    /**%0A     * Returns the resolution of display, use this for image scale bias%0A     * @return%0A     */%0A    public RESOLUTION getResolution() %7B%0A        return resolution;%0A    %7D%0A    %0A
 %7D%0A

Use resolution in Windows for display size