org.opensourcephysics.display
Class OSPRuntime

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

public class OSPRuntime
extends java.lang.Object

This class defines static methods related to the runtime environment.

Version:
1.0
Author:
Douglas Brown, Wolfgang Christian

Field Summary
static java.lang.Boolean antiAliasText
          True if text components should try and anti-alias text.
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.lang.String CROSS_PLATFORM_LF
           
static java.lang.String DEFAULT_LF
           
static javax.swing.LookAndFeel DEFAULT_LOOK_AND_FEEL
           
static boolean DEFAULT_LOOK_AND_FEEL_DECORATIONS
           
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 java.lang.String GTK_LF
           
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 boolean loadDataTool
          Load Data Tool, if available.
static boolean loadExportTool
          Load Export Tool, if available.
static boolean loadFourierTool
          Load Fourier Tool, if available.
static boolean loadOSPLog
          Load OSP Log, if available.
static boolean loadTranslatorTool
          Load Translator Tool, if available.
static boolean loadVideoTool
          Load Video Tool, if available.
static java.util.HashMap<java.lang.String,java.lang.String> LOOK_AND_FEEL_TYPES
           
static java.lang.String METAL_LF
           
static java.lang.String MOTIF_LF
           
static java.lang.String NIMBUS_LF
           
static java.lang.String OSP_ICON_FILE
          Location of OSP icon.
static java.lang.String SYSTEM_LF
           
static boolean webStart
          True if launched by WebStart.
static java.lang.String WINDOWS_LF
           
 
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 description and extensions
static javax.swing.JFileChooser createChooser(java.lang.String description, java.lang.String[] extensions, java.io.File homeDir)
          Creates a JFileChooser with given description 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 name, 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 isDefaultLookAndFeelDecorated()
          Returns true if newly created JFrames or JDialogs should have their Window decorations provided by the current look and feel.
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 isPopupTrigger(java.awt.event.InputEvent e)
          Determines if an InputEvent is a popup trigger.
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 boolean setLookAndFeel(boolean useDefaultLnFDecorations, java.lang.String lookAndFeel)
          Sets the look and feel of the user interface.
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.


loadVideoTool

public static boolean loadVideoTool
Load Video Tool, if available.


loadExportTool

public static boolean loadExportTool
Load Export Tool, if available.


loadDataTool

public static boolean loadDataTool
Load Data Tool, if available.


loadFourierTool

public static boolean loadFourierTool
Load Fourier Tool, if available.


loadTranslatorTool

public static boolean loadTranslatorTool
Load Translator Tool, if available.


loadOSPLog

public static boolean loadOSPLog
Load OSP Log, 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.


antiAliasText

public static java.lang.Boolean antiAliasText
True if text components should try and anti-alias text.


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.


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).


CROSS_PLATFORM_LF

public static final java.lang.String CROSS_PLATFORM_LF
See Also:
Constant Field Values

NIMBUS_LF

public static final java.lang.String NIMBUS_LF
See Also:
Constant Field Values

SYSTEM_LF

public static final java.lang.String SYSTEM_LF
See Also:
Constant Field Values

METAL_LF

public static final java.lang.String METAL_LF
See Also:
Constant Field Values

GTK_LF

public static final java.lang.String GTK_LF
See Also:
Constant Field Values

MOTIF_LF

public static final java.lang.String MOTIF_LF
See Also:
Constant Field Values

WINDOWS_LF

public static final java.lang.String WINDOWS_LF
See Also:
Constant Field Values

DEFAULT_LF

public static final java.lang.String DEFAULT_LF
See Also:
Constant Field Values

DEFAULT_LOOK_AND_FEEL

public static final javax.swing.LookAndFeel DEFAULT_LOOK_AND_FEEL

DEFAULT_LOOK_AND_FEEL_DECORATIONS

public static final boolean DEFAULT_LOOK_AND_FEEL_DECORATIONS

LOOK_AND_FEEL_TYPES

public static final java.util.HashMap<java.lang.String,java.lang.String> LOOK_AND_FEEL_TYPES
Method Detail

showAboutDialog

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


setLookAndFeel

public static boolean setLookAndFeel(boolean useDefaultLnFDecorations,
                                     java.lang.String lookAndFeel)
Sets the look and feel of the user interface. Look and feel user interfaces are: NIMBUS_LF: com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel METAL_LF: javax.swing.plaf.metal.MetalLookAndFeel GTK_LF: com.sun.java.swing.plaf.gtk.GTKLookAndFeel MOTIF_LF: com.sun.java.swing.plaf.motif.MotifLookAndFeel WINDOWS_LF: com.sun.java.swing.plaf.windows.WindowsLookAndFeel DEFAULT_LF: the default look and feel in effect when this class was loaded CROSS_PLATFORM_LF: the cross platform look and feel; usually METAL_LF SYSTEM_LF: the operating system look and feel

Parameters:
useDefaultLnFDecorations -
lookAndFeel -
Returns:
true if successful

isDefaultLookAndFeelDecorated

public static boolean isDefaultLookAndFeelDecorated()
Returns true if newly created JFrames or JDialogs should have their Window decorations provided by the current look and feel. This is only a hint, as certain look and feels may not support this feature.

Returns:
true if look and feel should provide Window decorations.
Since:
1.4

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

isPopupTrigger

public static boolean isPopupTrigger(java.awt.event.InputEvent e)
Determines if an InputEvent is a popup trigger.

Returns:
true if event is a popup trigger

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 name, 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. Locales are returned with english first, then in alphabetical order.

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 description and extensions

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

createChooser

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

Parameters:
description - String A description string
extensions - String[] An array of allowed extensions
homeDir - File The target directory when the user clicks the home icon
Returns:
JFileChooser