/* Class641 - Decompiled by JODE
 * Visit http://jode.sourceforge.net/
 */
import java.awt.DisplayMode;
import java.awt.Frame;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.lang.reflect.Field;

public class Class641
{
    GraphicsDevice aGraphicsDevice8219;
    DisplayMode aDisplayMode8220;
    public static Class662_Sub10 aClass662_Sub10_8221;
    
    int[] method7632(int i) {
	DisplayMode[] displaymodes
	    = ((Class641) this).aGraphicsDevice8219.getDisplayModes();
	int[] is = new int[displaymodes.length << 2];
	for (int i_0_ = 0; i_0_ < displaymodes.length; i_0_++) {
	    is[i_0_ << 2] = displaymodes[i_0_].getWidth();
	    is[1 + (i_0_ << 2)] = displaymodes[i_0_].getHeight();
	    is[(i_0_ << 2) + 2] = displaymodes[i_0_].getBitDepth();
	    is[(i_0_ << 2) + 3] = displaymodes[i_0_].getRefreshRate();
	}
	return is;
    }
    
    int[] method7633() {
	DisplayMode[] displaymodes
	    = ((Class641) this).aGraphicsDevice8219.getDisplayModes();
	int[] is = new int[displaymodes.length << 2];
	for (int i = 0; i < displaymodes.length; i++) {
	    is[i << 2] = displaymodes[i].getWidth();
	    is[1 + (i << 2)] = displaymodes[i].getHeight();
	    is[(i << 2) + 2] = displaymodes[i].getBitDepth();
	    is[(i << 2) + 3] = displaymodes[i].getRefreshRate();
	}
	return is;
    }
    
    void method7634(Frame frame, int i, int i_1_, int i_2_, int i_3_,
		    byte i_4_) {
	((Class641) this).aDisplayMode8220
	    = ((Class641) this).aGraphicsDevice8219.getDisplayMode();
	if (((Class641) this).aDisplayMode8220 == null)
	    throw new NullPointerException();
	frame.setUndecorated(true);
	frame.enableInputMethods(false);
	method7636(frame, 34840);
	if (0 == i_3_) {
	    int i_5_ = ((Class641) this).aDisplayMode8220.getRefreshRate();
	    DisplayMode[] displaymodes
		= ((Class641) this).aGraphicsDevice8219.getDisplayModes();
	    boolean bool = false;
	    for (int i_6_ = 0; i_6_ < displaymodes.length; i_6_++) {
		if (displaymodes[i_6_].getWidth() == i
		    && displaymodes[i_6_].getHeight() == i_1_
		    && displaymodes[i_6_].getBitDepth() == i_2_) {
		    int i_7_ = displaymodes[i_6_].getRefreshRate();
		    if (!bool
			|| Math.abs(i_7_ - i_5_) < Math.abs(i_3_ - i_5_)) {
			i_3_ = i_7_;
			bool = true;
		    }
		}
	    }
	    if (!bool)
		i_3_ = i_5_;
	}
	((Class641) this).aGraphicsDevice8219
	    .setDisplayMode(new DisplayMode(i, i_1_, i_2_, i_3_));
    }
    
    void method7635(int i) {
	if (null != ((Class641) this).aDisplayMode8220) {
	    DisplayMode[] displaymodes
		= ((Class641) this).aGraphicsDevice8219.getDisplayModes();
	    boolean bool = false;
	    DisplayMode[] displaymodes_8_ = displaymodes;
	    for (int i_9_ = 0; i_9_ < displaymodes_8_.length; i_9_++) {
		DisplayMode displaymode = displaymodes_8_[i_9_];
		if (displaymode.equals(((Class641) this).aDisplayMode8220)) {
		    ((Class641) this).aGraphicsDevice8219
			.setDisplayMode(((Class641) this).aDisplayMode8220);
		    bool = true;
		    break;
		}
	    }
	    if (!bool) {
		try {
		    Field field = Class.forName
				      ("sun.awt.Win32GraphicsDevice")
				      .getDeclaredField("defaultDisplayMode");
		    field.setAccessible(true);
		    field.set(((Class641) this).aGraphicsDevice8219, null);
		} catch (Throwable throwable) {
		    /* empty */
		}
	    }
	    ((Class641) this).aDisplayMode8220 = null;
	}
	method7636(null, 34840);
    }
    
    public Class641() throws Exception {
	GraphicsEnvironment graphicsenvironment
	    = GraphicsEnvironment.getLocalGraphicsEnvironment();
	((Class641) this).aGraphicsDevice8219
	    = graphicsenvironment.getDefaultScreenDevice();
	if (!((Class641) this).aGraphicsDevice8219.isFullScreenSupported()) {
	    GraphicsDevice[] graphicsdevices
		= graphicsenvironment.getScreenDevices();
	    GraphicsDevice[] graphicsdevices_10_ = graphicsdevices;
	    for (int i = 0; i < graphicsdevices_10_.length; i++) {
		GraphicsDevice graphicsdevice = graphicsdevices_10_[i];
		if (null != graphicsdevice
		    && graphicsdevice.isFullScreenSupported()) {
		    ((Class641) this).aGraphicsDevice8219 = graphicsdevice;
		    return;
		}
	    }
	    throw new Exception();
	}
    }
    
    void method7636(Frame frame, int i) {
	boolean bool = false;
	try {
	    Field field = Class.forName("sun.awt.Win32GraphicsDevice")
			      .getDeclaredField("valid");
	    field.setAccessible(true);
	    boolean bool_11_
		= ((Boolean) field.get(((Class641) this).aGraphicsDevice8219))
		      .booleanValue();
	    if (bool_11_) {
		field.set(((Class641) this).aGraphicsDevice8219,
			  Boolean.FALSE);
		bool = true;
	    }
	} catch (Throwable throwable) {
	    /* empty */
	}
	try {
	    ((Class641) this).aGraphicsDevice8219.setFullScreenWindow(frame);
	    if (bool) {
		try {
		    Field field = Class.forName
				      ("sun.awt.Win32GraphicsDevice")
				      .getDeclaredField("valid");
		    field.set(((Class641) this).aGraphicsDevice8219,
			      Boolean.TRUE);
		} catch (Throwable throwable) {
		    /* empty */
		}
	    }
	} catch (Exception object) {
	    if (bool) {
		try {
		    Field field = Class.forName
				      ("sun.awt.Win32GraphicsDevice")
				      .getDeclaredField("valid");
		    field.set(((Class641) this).aGraphicsDevice8219,
			      Boolean.TRUE);
		} catch (Throwable throwable) {
		    /* empty */
		}
	    }
	    throw object;
	}
    }
}
