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.
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
           
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 createChooser(java.lang.String title, java.lang.String description, java.lang.String[] extensions)
          Creates a JFileChooser with given title, 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.lang.String getDisplayLanguage(java.util.Locale locale)
          Gets the display language for a given Locale.
static java.util.Locale[] getInstalledLocales()
          Gets Locales for languages that have properties files in the core library.
static java.io.File getJavaFile(java.lang.String jrePath)
          Gets the java executable file for a given jre path.
static java.lang.String getJREPath(java.io.File javaFile)
          Gets the java VM path for a given Java executable file.
static java.util.jar.JarFile getLaunchJar()
          Gets the jar from which the progam was launched.
static java.lang.String getLaunchJarBuildDate()
          Gets the launch jar build date.
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 int getVMBitness()
          Gets the bitness of the current Java VM.
static boolean hasJava3D()
          Determines if Java 3D has been installed by looking for j3dcore.jar in java extensions folder.
static boolean hasQTJava()
          Determines if Quick Time for Java has been installed by looking for QTJava.zip in java extensions folder.
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
equals, 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.


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.


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

hasJava3D

public static boolean hasJava3D()
Determines if Java 3D has been installed by looking for j3dcore.jar in java extensions folder.

Returns:
true if Java 3D found; false otherwise

hasQTJava

public static boolean hasQTJava()
Determines if Quick Time for Java has been installed by looking for QTJava.zip in java extensions folder.

Returns:
true if QTJava found; false otherwise

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

getLaunchJarBuildDate

public static java.lang.String getLaunchJarBuildDate()
Gets the launch jar build date.

Returns:
the build date, or null if not launched from a jar or date not known

getJavaFile

public static java.io.File getJavaFile(java.lang.String jrePath)
Gets the java executable file for a given jre path. May return null.

Parameters:
jrePath - the path to a java jre or jdk VM
Returns:
the Java executable

getVMBitness

public static int getVMBitness()
Gets the bitness of the current Java VM. Note this identifies only 32- and 64-bit VMs as of Jan 2011.

Returns:
64 if 64-bit VM, otherwise 32

getJREPath

public static java.lang.String getJREPath(java.io.File javaFile)
Gets the java VM path for a given Java executable file.

Parameters:
javaFile - the Java executable file
Returns:
the VM path

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[]

getDisplayLanguage

public static java.lang.String getDisplayLanguage(java.util.Locale locale)
Gets the display language for a given Locale. This returns the language name in the locale's own language, but substitutes the equivalent of SIMPLIFIED_CHINESE and TRADITIONAL_CHINESE for those locales.

Returns:
the display name

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 title,
                                                     java.lang.String description,
                                                     java.lang.String[] extensions)
Creates a JFileChooser with given title, description and extensions

Parameters:
title - the title
description - a description string
extensions - an array of allowed extensions
Returns:
the JFileChooser

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