X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2FPlatform.java;h=2e086da07d9fed3835b62fa27d54059e330c6725;hb=7e9239a7088d4cd772a31a76e1a53e1c681638bc;hp=f8937cadc4204307bfd7dfa9082a969e06103fce;hpb=214fe5c02d3f0fb9c3c61128a100e6a3cb01668e;p=org.ibex.core.git
diff --git a/src/org/xwt/Platform.java b/src/org/xwt/Platform.java
index f8937ca..2e086da 100644
--- a/src/org/xwt/Platform.java
+++ b/src/org/xwt/Platform.java
@@ -1,4 +1,4 @@
-// Copyright 2003 Adam Megacz, see the COPYING file for licensing [GPL]
+// Copyright 2004 Adam Megacz, see the COPYING file for licensing [GPL]
package org.xwt;
import java.lang.reflect.*;
@@ -17,32 +17,21 @@ import org.xwt.util.*;
* it in the org.xwt.plat package, and add code to this file's static
* block to detect the new platform.
*/
-public class Platform {
+public abstract class Platform {
- // Static Data /////////////////////////////////////////////////////////////////////////////////////
-
- /**
- * set to true during the delivery of a KeyPressed:C-v/A-v or Press3; it is safe to use a
- * 'global' here, since message delivery is single-threaded and non-preemptable
- */
- static boolean clipboardReadEnabled = false;
-
- /** The appropriate Platform object for this JVM */
- static Platform platform = null;
+ public Platform() { platform = this; }
- /** true if proxy autodetection has already been run */
- static boolean alreadyDetectedProxy = false;
-
- /** the result of proxy autodetection */
- static org.xwt.HTTP.Proxy cachedProxyInfo = null;
+ // Static Data /////////////////////////////////////////////////////////////////////////////////////
- /** the current build */
- public static String build = "unknown";
+ static boolean clipboardReadEnabled = false; ///< true iff inside a C-v/A-v/Press3 trap handler
+ static Platform platform = null; ///< The appropriate Platform object for this JVM
+ static boolean alreadyDetectedProxy = false; ///< true if proxy autodetection has already been run
+ static org.xwt.HTTP.Proxy cachedProxyInfo = null; ///< the result of proxy autodetection
+ public static String build = "unknown"; ///< the current build
// VM Detection Logic /////////////////////////////////////////////////////////////////////
- /** do-nothing method that forces <clinit> to run */
- public static void forceLoad() { }
+ public static void forceLoad() { } ///< do-nothing method that forces <clinit> to run
// If you create a new subclass of Platform, you should add logic
// here to detect it. Do not reference your class directly -- use
@@ -65,86 +54,74 @@ public class Platform {
else if (version.startsWith("1.1") && vendor.startsWith("Microsoft")) platform_class = "Microsoft";
else if (!version.startsWith("1.0") && !version.startsWith("1.1")) platform_class = "Java2";
- /*
- // Disable 2d hardware acceleration on Jaguar
- if (os_name.equals("Mac OS X") && os_version.startsWith("10.2")) System.setProperty("com.apple.hwaccel", "false");
- */
+ // Disable 2d hardware acceleration on Jaguar (do we need this?)
+ // if (os_name.equals("Mac OS X") && os_version.startsWith("10.2")) System.setProperty("com.apple.hwaccel", "false");
+ //System.setProperty("com.apple.hwaccel", "false");
- if (platform_class != null) {
- platform = (Platform)Class.forName("org.xwt.plat." + platform_class).newInstance();
- platform.init();
- }
+ if (platform_class != null)
+ Class.forName("org.xwt.plat." + platform_class).newInstance();
+ String term = Platform.getEnv("TERM");
+ Log.color = term != null && term.length() != 0 && !term.equals("cygwin");
+
try {
build = (String)Class.forName("org.xwt.Build").getField("build").get(null);
} catch (ClassNotFoundException cnfe) {
} catch (Exception e) {
- if (Log.on) Log.log(Platform.class, "exception while detecting build:");
- if (Log.on) Log.log(Platform.class, e);
+ if (Log.on) Log.info(Platform.class, "exception while detecting build:");
+ if (Log.on) Log.info(Platform.class, e);
}
- if (Log.on) Log.log(Platform.class, "XWT build: " + build);
+ if (Log.on) Log.diag(Platform.class, "XWT build: " + build);
- if (Log.on) Log.log(Platform.class, "XWT VM detection: vendor = " + vendor);
- if (Log.on) Log.log(Platform.class, " version = " + version);
- if (Log.on) Log.log(Platform.class, " os = " + os_name + " [version " + os_version + "]");
+ if (Log.on) Log.diag(Platform.class, "XWT VM detection: vendor = " + vendor);
+ if (Log.on) Log.diag(Platform.class, " version = " + version);
+ if (Log.on) Log.diag(Platform.class, " os = " + os_name + " [version " + os_version + "]");
if (platform_class == null) {
- if (Log.on) Log.log(Platform.class, "Unable to detect JVM");
- new Platform().criticalAbort("Unable to detect JVM");
+ if (Log.on) Log.info(Platform.class, "Unable to detect JVM");
+ criticalAbort("Unable to detect JVM");
}
- if (Log.on) Log.log(Platform.class, " platform = " + platform.getDescriptiveName());
- if (Log.on) Log.log(Platform.class, " class = " + platform.getClass().getName());
+ if (Log.on) Log.diag(Platform.class, " platform = " + platform.getDescriptiveName());
+ if (Log.on) Log.diag(Platform.class, " class = " + platform.getClass().getName());
platform.postInit();
} catch (Exception e) {
- if (Log.on) Log.log(Platform.class, "Exception while trying to detect JVM");
- if (Log.on) Log.log(Platform.class, e);
- new Platform().criticalAbort("Unable to detect JVM");
+ if (Log.on) Log.info(Platform.class, "Exception while trying to detect JVM");
+ if (Log.on) Log.info(Platform.class, e);
+ criticalAbort("Unable to detect JVM");
}
}
- // Methods to be Overridden ////////////////////////////////////////////////////////////////////
+ // Methods to be Overridden ///////////////////////////////////////////////////////////////////
/** a string describing the VM */
protected String getDescriptiveName() { return "Generic Java 1.1 VM"; }
- /** this initializes the platform; code in here can invoke methods on Platform since Platform.platform has already been set */
- protected void init() { }
+ /** invoked after initialization messages have been printed; useful for additional platform detection log messages */
protected void postInit() { }
- /** creates and returns a doublebuffer 'belonging' to owner; we need to associate PixelBuffers to surfaces
- * due to AWT 1.1 requirements (definately for Navigator, possibly also for MSJVM).
- */
- public static PixelBuffer createPixelBuffer(int w, int h, Surface s) { return platform._createPixelBuffer(w, h, s); }
+ protected Surface _createSurface(Box b, boolean framed) { return null; }
+ protected Picture _createPicture(Stream r) { return null; }
protected PixelBuffer _createPixelBuffer(int w, int h, Surface owner) { return null; }
-
- /** creates and returns a picture */
- public static Picture createPicture(int[] data, int w, int h) { return platform._createPicture(data, w, h); }
- public static Picture createAlphaOnlyPicture(byte[] data, int w, int h) { return platform._createAlphaOnlyPicture(data, w, h); }
-
- protected Picture _createPicture(int[] b, int w, int h) { return null; }
- protected Picture _createAlphaOnlyPicture(byte[] b, int w, int h) {
- int[] b2 = new int[b.length];
- for(int i=0;i