001: /*
002: * Copyright (c) 2000 Silvere Martin-Michiellot All Rights Reserved.
003: *
004: * Silvere Martin-Michiellot grants you ("Licensee") a non-exclusive,
005: * royalty free, license to use, modify and redistribute this
006: * software in source and binary code form,
007: * provided that i) this copyright notice and license appear on all copies of
008: * the software; and ii) Licensee does not utilize the software in a manner
009: * which is disparaging to Silvere Martin-Michiellot.
010: *
011: * This software is provided "AS IS," without a warranty of any kind. ALL
012: * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
013: * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
014: * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. Silvere Martin-Michiellot
015: * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
016: * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
017: * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
018: * Silvere Martin-Michiellot OR ITS LICENSORS BE LIABLE
019: * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
020: * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
021: * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
022: * OR INABILITY TO USE SOFTWARE, EVEN IF Silvere Martin-Michiellot HAS BEEN
023: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
024: *
025: * This software is not designed or intended for use in on-line control of
026: * aircraft, air traffic, aircraft navigation or aircraft communications; or in
027: * the design, construction, operation or maintenance of any nuclear
028: * facility. Licensee represents and warrants that it will not use or
029: * redistribute the Software for such purposes.
030: *
031: */
032:
033: package com.db.utils.fullscreen;
034:
035: import java.awt.Dimension;
036: import java.io.InputStream;
037: import java.io.IOException;
038: import java.util.Properties;
039:
040: // This code is based upon the code from Jeremy
041: // Site http://www.computerbooth.com/j3d/
042: // Email jeremy@computerbooth.com
043:
044: public class ScreenProperties {
045:
046: private static final String FULLSCREEN = "true";
047: private static final String WINDOWED = "false";
048: private Properties properties = new Properties();
049:
050: /** Creates new ScreenProperties */
051: public ScreenProperties() {
052:
053: properties.setProperty("fullscreen", WINDOWED);
054: properties.setProperty("screen_resolution.width", "640");
055: properties.setProperty("screen_resolution.height", "480");
056: properties.setProperty("colour_depth", "32");
057: properties.setProperty("refresh_rate", "75");
058:
059: }
060:
061: public boolean isFullscreen() {
062:
063: return (properties.getProperty("fullscreen"))
064: .equals(FULLSCREEN);
065:
066: }
067:
068: public Dimension getResolutionDimension() {
069:
070: try {
071: return new Dimension(Integer.parseInt(properties
072: .getProperty("screen_resolution.width")), Integer
073: .parseInt(properties
074: .getProperty("screen_resolution.height")));
075: } catch (NumberFormatException e) {
076: System.out
077: .println("Screen resolution is not valid in properties: "
078: + e.getMessage());
079: return new Dimension(640, 480);
080: }
081:
082: }
083:
084: public int getResolutionWidth() {
085:
086: try {
087: return Integer.parseInt(properties
088: .getProperty("screen_resolution.width"));
089: } catch (NumberFormatException e) {
090: return 640;
091: }
092:
093: }
094:
095: public int getResolutionHeight() {
096:
097: try {
098: return Integer.parseInt(properties
099: .getProperty("screen_resolution.height"));
100: } catch (NumberFormatException e) {
101: return 480;
102: }
103:
104: }
105:
106: public int getRefreshRate() {
107:
108: try {
109: return Integer.parseInt(properties
110: .getProperty("refresh_rate"));
111: } catch (NumberFormatException e) {
112: return 60;
113: }
114:
115: }
116:
117: public int getColourDepth() {
118:
119: try {
120: return Integer.parseInt(properties
121: .getProperty("colour_depth"));
122: } catch (NumberFormatException e) {
123: return 16;
124: }
125:
126: }
127:
128: public void load(InputStream inStream) throws IOException {
129:
130: properties.load(inStream);
131:
132: }
133:
134: }
|