org.opensourcephysics.display
Class OSPRuntime

java.lang.Object
  extended by org.opensourcephysics.display.OSPRuntime

public class OSPRuntime
extends java.lang.Object

This defines static methods related to the runtime environment.

Version:
1.0
Author:
Douglas Brown, Wolfgang Chrstian

Field Summary
static javax.swing.JApplet applet
          Static reference to an applet for document/code base access.
static boolean appletMode
          True if running as an applet.
protected static boolean authorMode
          True if users allowed to author internal parameters such as Locale strings.
static java.lang.String chooserDir
          File Chooser starting directory.
static java.util.Locale[] defaultLocales
          Array of default OSP Locales.
static boolean disableAllDrawing
          Disables drawing for faster start-up and to avoid screen flash in Drawing Panels.
static boolean javaLookAndFeel
          Look and feel property for the graphical user interface.
protected static boolean launcherMode
          Set true if a program is being run within Launcher.
static boolean launchingInSingleVM
          True if always launching in single vm (applet mode, etc).
static java.lang.String OSP_ICON_FILE
          Location of OSP icon.
static Translator translator
          Shared Translator, if available.
static boolean webStart
          True if launched by WebStart.
 
Method Summary
static java.lang.String chooseFilename(javax.swing.JFileChooser chooser)
          Uses a JFileChooser to ask for a name.
static java.lang.String chooseFilename(javax.swing.JFileChooser chooser, java.awt.Component parent, boolean toSave)
          Uses a JFileChooser to ask for a name.
static javax.swing.JFileChooser createChooser(java.lang.String description, java.lang.String[] extensions)
          Creates a JFileChooser with given desription and extensions
static javax.swing.JFileChooser getChooser()
          Gets a file chooser.
static java.util.Locale[] getDefaultLocales()
          Gets Locales for languages that have properties files in the core library.
static java.util.Locale[] getInstalledLocales()
          Gets Locales for languages that have properties files in the core library.
static java.util.jar.JarFile getLaunchJar()
          Gets the jar from which the progam was launched.
static java.lang.String getLaunchJarDirectory()
          Gets the launch jar directory, if any.
static java.lang.String getLaunchJarName()
          Gets the launch jar nsme, if any.
static java.lang.String getLaunchJarPath()
          Gets the launch jar path, if any.
static Translator getTranslator()
          Gets the translator, if any.
static boolean isAppletMode()
          Determines if running as an applet
static boolean isAuthorMode()
          Determines if running in author mode
static boolean isLauncherMode()
          Gets the launcherMode property.
static boolean isLinux()
          Determines if OS is Linux
static boolean isMac()
          Determines if OS is Mac
static boolean isVista()
          Determines if OS is Vista
static boolean isWebStart()
          Determines if launched by WebStart
static boolean isWindows()
          Determines if OS is Windows
static void setAuthorMode(boolean b)
          Sets the authorMode property.
static void setLauncherMode(boolean b)
          Sets the launcherMode property.
static void setLaunchJarPath(java.lang.String path)
          Sets the launch jar path.
static void showAboutDialog(java.awt.Component parent)
          Shows the about dialog.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

disableAllDrawing

public static volatile boolean disableAllDrawing
Disables drawing for faster start-up and to avoid screen flash in Drawing Panels.


translator

public static Translator translator
Shared Translator, if available.


defaultLocales

public static java.util.Locale[] defaultLocales
Array of default OSP Locales.


launcherMode

protected static boolean launcherMode
Set true if a program is being run within Launcher.


appletMode

public static boolean appletMode
True if running as an applet.


applet

public static javax.swing.JApplet applet
Static reference to an applet for document/code base access.


webStart

public static boolean webStart
True if launched by WebStart.


authorMode

protected static boolean authorMode
True if users allowed to author internal parameters such as Locale strings.


javaLookAndFeel

public static boolean javaLookAndFeel
Look and feel property for the graphical user interface.


chooserDir

public static java.lang.String chooserDir
File Chooser starting directory.


OSP_ICON_FILE

public static final java.lang.String OSP_ICON_FILE
Location of OSP icon.

See Also:
Constant Field Values

launchingInSingleVM

public static boolean launchingInSingleVM
True if always launching in single vm (applet mode, etc).

Method Detail

showAboutDialog

public static void showAboutDialog(java.awt.Component parent)
Shows the about dialog.


isWindows

public static boolean isWindows()
Determines if OS is Windows

Returns:
true if Windows

isMac

public static boolean isMac()
Determines if OS is Mac

Returns:
true if Mac

isLinux

public static boolean isLinux()
Determines if OS is Linux

Returns:
true if Linux

isVista

public static boolean isVista()
Determines if OS is Vista

Returns:
true if Vistsa

isWebStart

public static boolean isWebStart()
Determines if launched by WebStart

Returns:
true if launched by WebStart

isAppletMode

public static boolean isAppletMode()
Determines if running as an applet

Returns:
true if running as an applet

isAuthorMode

public static boolean isAuthorMode()
Determines if running in author mode

Returns:
true if running in author mode

setAuthorMode

public static void setAuthorMode(boolean b)
Sets the authorMode property. AuthorMode allows users to author internal parameters such as Locale strings.

Parameters:
b - boolean

setLauncherMode

public static void setLauncherMode(boolean b)
Sets the launcherMode property. LauncherMode disables access to propertes, such as Locale, that affect the VM.

Parameters:
b - boolean

isLauncherMode

public static boolean isLauncherMode()
Gets the launcherMode property. LauncherMode disables access to propertes, such as Locale, that affect the VM.

Returns:
boolean

setLaunchJarPath

public static void setLaunchJarPath(java.lang.String path)
Sets the launch jar path. param path the path


getLaunchJarName

public static java.lang.String getLaunchJarName()
Gets the launch jar nsme, if any.

Returns:
launch jar path, or null if not launched from a jar

getLaunchJarPath

public static java.lang.String getLaunchJarPath()
Gets the launch jar path, if any.

Returns:
launch jar path, or null if not launched from a jar

getLaunchJarDirectory

public static java.lang.String getLaunchJarDirectory()
Gets the launch jar directory, if any.

Returns:
path to the directory containing the launch jar. May be null.

getLaunchJar

public static java.util.jar.JarFile getLaunchJar()
Gets the jar from which the progam was launched.

Returns:
JarFile

getDefaultLocales

public static java.util.Locale[] getDefaultLocales()
Gets Locales for languages that have properties files in the core library.

Returns:
Locale[]

getInstalledLocales

public static java.util.Locale[] getInstalledLocales()
Gets Locales for languages that have properties files in the core library.

Returns:
Locale[]

getTranslator

public static Translator getTranslator()
Gets the translator, if any.

Returns:
translator, or null if none available

getChooser

public static javax.swing.JFileChooser getChooser()
Gets a file chooser. The choose is static and will therefore be the same for all OSPFrames.

Returns:
the chooser

chooseFilename

public static java.lang.String chooseFilename(javax.swing.JFileChooser chooser)
Uses a JFileChooser to ask for a name.

Parameters:
chooser - JFileChooser
Returns:
String The absolute pah of the filename. Null if cancelled

chooseFilename

public static java.lang.String chooseFilename(javax.swing.JFileChooser chooser,
                                              java.awt.Component parent,
                                              boolean toSave)
Uses a JFileChooser to ask for a name.

Parameters:
chooser - JFileChooser
parent - Parent component for messages
toSave - true if we will save to the chosen file, false if we will read from it
Returns:
String The absolute pah of the filename. Null if cancelled

createChooser

public static javax.swing.JFileChooser createChooser(java.lang.String description,
                                                     java.lang.String[] extensions)
Creates a JFileChooser with given desription and extensions

Parameters:
description - String A description string
extensions - String[] An array of allowed extensions
Returns:
JFileChooser