org.xwt
Class Platform

java.lang.Object
  extended byorg.xwt.Platform
Direct Known Subclasses:
GCJ, JVM, PalmOS

public class Platform
extends java.lang.Object

Abstracts away the small irregularities in JVM implementations. The default Platform class supports a vanilla JDK 1.1 JVM. Subclasses are provided for other VMs. Methods whose names start with an underscore are meant to be overridden by subclasses. If you create a subclass of Platform, you should put it in the org.xwt.plat package, and add code to this file's static block to detect the new platform.


Field Summary
static java.lang.String build
          the current build
 
Constructor Summary
Platform()
           
 
Method Summary
protected  java.lang.String _altKeyName()
           
protected  Picture _createAlphaOnlyPicture(byte[] b, int w, int h)
           
protected  Picture _createPicture(int[] b, int w, int h)
           
protected  PixelBuffer _createPixelBuffer(int w, int h, Surface owner)
           
protected  Surface _createSurface(Box b, boolean framed)
          this method invokes the platform _createSurface() method and then enforces a few post-call invariants
protected  void _criticalAbort(java.lang.String message)
          used to notify the user of very serious failures; usually used when logging is not working or unavailable
protected  Picture _decodeJPEG(java.io.InputStream is, java.lang.String name)
           
protected  HTTP.Proxy _detectProxy()
          detects proxy settings
protected  java.lang.String _fileDialog(java.lang.String suggestedFileName, boolean write)
          displays a platform-specific "open file" dialog and returns the chosen filename, or null if the user hit cancel
protected  java.io.InputStream _getBuiltinInputStream()
           
protected  java.lang.String _getClipBoard()
           
protected  java.lang.String _getEnv(java.lang.String key)
           
protected  Scheduler _getScheduler()
          returns a Scheduler instance; used to implement platform-specific schedulers
protected  int _getScreenHeight()
           
protected  int _getScreenWidth()
           
protected  java.net.Socket _getSocket(java.lang.String host, int port, boolean ssl, boolean negotiate)
           
protected  void _inputStreamToByteArray(java.io.InputStream is, Callback c)
          read an input stream into a byte array and invoke callback when ready
protected  boolean _isCaseSensitive()
           
protected  int _maxThreads()
           
protected  boolean _needsAutoClick()
           
protected  boolean _needsAutoDoubleClick()
           
protected  void _newBrowserWindow(java.lang.String url)
          default implementation is Eric Albert's BrowserLauncher.java
 void _running()
           
protected  void _setClipBoard(java.lang.String s)
           
protected  boolean _supressDirtyOnResize()
           
static java.lang.String altKeyName()
          the human-readable name of the key mapped to XWT's 'alt' key
static Picture createAlphaOnlyPicture(byte[] data, int w, int h)
           
static Picture createPicture(int[] data, int w, int h)
          creates and returns a picture
static PixelBuffer createPixelBuffer(int w, int h, Surface s)
          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).
static Surface createSurface(Box b, boolean framed, boolean refreshable)
           
static void criticalAbort(java.lang.String message)
          used to notify the user of very serious failures; usually used when logging is not working or unavailable
static Picture decodeJPEG(java.io.InputStream is, java.lang.String name)
          convert a JPEG into an Image
static HTTP.Proxy detectProxy()
           
static java.lang.String fileDialog(java.lang.String suggestedFileName, boolean write)
           
static void forceLoad()
          do-nothing method that forces <clinit> to run
static java.io.InputStream getBuiltinInputStream()
          returns an InputStream to the builtin xwar
static java.lang.Object getClipBoard()
          returns the contents of the clipboard
protected  java.lang.String getDescriptiveName()
          a string describing the VM
static java.lang.String getEnv(java.lang.String key)
          returns the value of the environment variable key, or null if no such key exists
static Scheduler getScheduler()
           
static int getScreenHeight()
          returns the height of the screen, in pixels
static int getScreenWidth()
          returns the width of the screen, in pixels
static java.net.Socket getSocket(java.lang.String host, int port, boolean ssl, boolean negotiate)
          creates a socket object
protected  void init()
          this initializes the platform; code in here can invoke methods on Platform since Platform.platform has already been set
static void inputStreamToByteArray(java.io.InputStream is, Callback c)
           
static boolean isCaseSensitive()
          returns true iff the platform has a case-sensitive filesystem
static int maxThreads()
          returns the maximum number of threads that the XWT engine can create without adversely affecting the host OS
static boolean needsAutoClick()
          if true, org.xwt.Surface will generate a Click automatically after a press and a release
static boolean needsAutoDoubleClick()
          if true, org.xwt.Surface will generate a DoubleClick automatically after recieving two clicks in a short period of time
static void newBrowserWindow(java.lang.String url)
          opens a new browser window
protected  void postInit()
           
static void running()
           
static void setClipBoard(java.lang.String s)
          sets the contents of the clipboard
static boolean supressDirtyOnResize()
          should return true if it is safe to supress full-surface dirties immediately after a window resize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

build

public static java.lang.String build
the current build

Constructor Detail

Platform

public Platform()
Method Detail

forceLoad

public static void forceLoad()
do-nothing method that forces <clinit> to run


getDescriptiveName

protected java.lang.String getDescriptiveName()
a string describing the VM


init

protected void init()
this initializes the platform; code in here can invoke methods on Platform since Platform.platform has already been set


postInit

protected void postInit()

createPixelBuffer

public static PixelBuffer createPixelBuffer(int w,
                                            int h,
                                            Surface s)
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).


_createPixelBuffer

protected PixelBuffer _createPixelBuffer(int w,
                                         int h,
                                         Surface owner)

createPicture

public static Picture createPicture(int[] data,
                                    int w,
                                    int h)
creates and returns a picture


createAlphaOnlyPicture

public static Picture createAlphaOnlyPicture(byte[] data,
                                             int w,
                                             int h)

_createPicture

protected Picture _createPicture(int[] b,
                                 int w,
                                 int h)

_createAlphaOnlyPicture

protected Picture _createAlphaOnlyPicture(byte[] b,
                                          int w,
                                          int h)

getSocket

public static java.net.Socket getSocket(java.lang.String host,
                                        int port,
                                        boolean ssl,
                                        boolean negotiate)
                                 throws java.io.IOException
creates a socket object

Throws:
java.io.IOException

_getSocket

protected java.net.Socket _getSocket(java.lang.String host,
                                     int port,
                                     boolean ssl,
                                     boolean negotiate)
                              throws java.io.IOException
Throws:
java.io.IOException

supressDirtyOnResize

public static boolean supressDirtyOnResize()
should return true if it is safe to supress full-surface dirties immediately after a window resize


_supressDirtyOnResize

protected boolean _supressDirtyOnResize()

altKeyName

public static java.lang.String altKeyName()
the human-readable name of the key mapped to XWT's 'alt' key


_altKeyName

protected java.lang.String _altKeyName()

getClipBoard

public static java.lang.Object getClipBoard()
returns the contents of the clipboard


_getClipBoard

protected java.lang.String _getClipBoard()

setClipBoard

public static void setClipBoard(java.lang.String s)
sets the contents of the clipboard


_setClipBoard

protected void _setClipBoard(java.lang.String s)

getScreenWidth

public static int getScreenWidth()
returns the width of the screen, in pixels


_getScreenWidth

protected int _getScreenWidth()

getScreenHeight

public static int getScreenHeight()
returns the height of the screen, in pixels


_getScreenHeight

protected int _getScreenHeight()

maxThreads

public static int maxThreads()
returns the maximum number of threads that the XWT engine can create without adversely affecting the host OS


_maxThreads

protected int _maxThreads()

_criticalAbort

protected void _criticalAbort(java.lang.String message)
used to notify the user of very serious failures; usually used when logging is not working or unavailable


needsAutoClick

public static boolean needsAutoClick()
if true, org.xwt.Surface will generate a Click automatically after a press and a release


_needsAutoClick

protected boolean _needsAutoClick()

needsAutoDoubleClick

public static boolean needsAutoDoubleClick()
if true, org.xwt.Surface will generate a DoubleClick automatically after recieving two clicks in a short period of time


_needsAutoDoubleClick

protected boolean _needsAutoDoubleClick()

isCaseSensitive

public static boolean isCaseSensitive()
returns true iff the platform has a case-sensitive filesystem


_isCaseSensitive

protected boolean _isCaseSensitive()

getBuiltinInputStream

public static java.io.InputStream getBuiltinInputStream()
returns an InputStream to the builtin xwar


_getBuiltinInputStream

protected java.io.InputStream _getBuiltinInputStream()

getEnv

public static java.lang.String getEnv(java.lang.String key)
returns the value of the environment variable key, or null if no such key exists


_getEnv

protected java.lang.String _getEnv(java.lang.String key)

decodeJPEG

public static Picture decodeJPEG(java.io.InputStream is,
                                 java.lang.String name)
convert a JPEG into an Image


_decodeJPEG

protected Picture _decodeJPEG(java.io.InputStream is,
                              java.lang.String name)

_fileDialog

protected java.lang.String _fileDialog(java.lang.String suggestedFileName,
                                       boolean write)
displays a platform-specific "open file" dialog and returns the chosen filename, or null if the user hit cancel


fileDialog

public static java.lang.String fileDialog(java.lang.String suggestedFileName,
                                          boolean write)

_newBrowserWindow

protected void _newBrowserWindow(java.lang.String url)
default implementation is Eric Albert's BrowserLauncher.java


newBrowserWindow

public static void newBrowserWindow(java.lang.String url)
opens a new browser window


criticalAbort

public static void criticalAbort(java.lang.String message)
used to notify the user of very serious failures; usually used when logging is not working or unavailable


_createSurface

protected Surface _createSurface(Box b,
                                 boolean framed)
this method invokes the platform _createSurface() method and then enforces a few post-call invariants


createSurface

public static Surface createSurface(Box b,
                                    boolean framed,
                                    boolean refreshable)

_detectProxy

protected HTTP.Proxy _detectProxy()
detects proxy settings


detectProxy

public static HTTP.Proxy detectProxy()

_getScheduler

protected Scheduler _getScheduler()
returns a Scheduler instance; used to implement platform-specific schedulers


getScheduler

public static Scheduler getScheduler()

_inputStreamToByteArray

protected void _inputStreamToByteArray(java.io.InputStream is,
                                       Callback c)
read an input stream into a byte array and invoke callback when ready


inputStreamToByteArray

public static void inputStreamToByteArray(java.io.InputStream is,
                                          Callback c)

running

public static void running()

_running

public void _running()