X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2FPlatform.java;fp=src%2Forg%2Fxwt%2FPlatform.java;h=45e303c784e1a79c905b52b7f9befc49788d7f30;hb=2ccad2219888c9942f62ae8b4d4207f655690948;hp=aada999373cee2cb23da0b653ca5972127b01ee1;hpb=c191f0122fbd24c2df21c41affb0c039d59f16d8;p=org.ibex.core.git diff --git a/src/org/xwt/Platform.java b/src/org/xwt/Platform.java index aada999..45e303c 100644 --- a/src/org/xwt/Platform.java +++ b/src/org/xwt/Platform.java @@ -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,16 +54,12 @@ 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"); - */ - System.setProperty("com.apple.hwaccel", "true"); + // 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", "true"); - 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(); try { build = (String)Class.forName("org.xwt.Build").getField("build").get(null); @@ -91,7 +76,7 @@ public class Platform { if (platform_class == null) { if (Log.on) Log.log(Platform.class, "Unable to detect JVM"); - new Platform().criticalAbort("Unable to detect JVM"); + criticalAbort("Unable to detect JVM"); } if (Log.on) Log.log(Platform.class, " platform = " + platform.getDescriptiveName()); @@ -101,41 +86,39 @@ public class Platform { } 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"); + 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(Res 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