JavaView® v2.12

jv.object
Class PsConfig

java.lang.Object
  |
  +--jv.object.PsConfig

public final class PsConfig
extends java.lang.Object

Static configuration class of JavaView with global static variables. The class must be initialized with current applet and frame. Initialization is automatically done in PvViewer when PvViewer instance is created in the top applet. If applet does not create an instance of PvViewer then applet must initialize this class directly using its init method. Information about version, authors etc. is parsed during generation of jar file to be included as manifest information (currently, the information is just added as a file _jarVersion.txt to the archive).

Version:
08.10.01, 3.50 revised (kp) Store codebase in init() in applet mode.
10.08.00, 3.21 revised (kp) Renamed to get/setLanguage() from get/setBundle().
10.08.00, 3.20 revised (kp) Removed method setBundle(ResourceBundle).
01.05.00, 3.10 revised (sk) Internationalization added.
20.02.00, 3.00 revised (kp) Resource modifications incl. font handling.
29.10.99, 2.50 revised (kp) List of projects added.
12.06.99, 2.20 revised (kp) New instance variable m_viewer added.
12.06.99, 2.10 revised (kp) PsMainFrame used instead of Frame to enable uniform key handling.
20.05.99, 2.00 revised (kp) Console instance variable moved to PsDebug.
00.00.97, 1.00 created (kp)
Author:
Konrad Polthier

Field Summary
static java.lang.String[] AUTHOR
          Deprecated. use method getAuthors() to access list of authors.
static java.lang.String[] CONTRIBUTOR
          Deprecated. use method getContributors() to access list of contributors.
static java.lang.String EMAIL
          Email address for contact.
static int FONT_FIXED
          Identifier of fixed (i.e. non-proportional) text font used in panels.
static int FONT_HEADER2
          Identifier of header font used in panels.
static int FONT_HEADER4
          Identifier of sub header font used in panels.
static int FONT_MENU
          Identifier of menu font used in panels.
static int FONT_TEXT
          Identifier of text font used in panels.
static java.lang.String FONTS_HTML
          Page with an applet showing available system fonts.
static java.lang.String HELP_HTML
          Help page of JavaView in Html format.
static java.lang.String HOMEPAGE
          Homepage of JavaView.
static int m_osId
          Identifier of current operating system.
static int OS_IRIX
          Identifier of Silicon Graphics Irix operating system.
static int OS_LINUX
          Identifier of Linux operating system.
static int OS_OTHER
          Identifier of unknown other operating system.
static int OS_SOLARIS
          Identifier of Sun Solaris operating system.
static int OS_WIN
          Identifier of Microsoft Windows operating systems.
 
Constructor Summary
PsConfig()
           
 
Method Summary
static java.applet.Applet getApplet()
          Get applet if run as applet.
static java.lang.String getAuthors()
          Get author names separated by comma as single string
static java.lang.String getCodeBase()
          Get codebase of current applet or application.
static java.lang.String[] getContributors()
          Get list of contributors as array of strings.
static java.lang.String getCopyright()
          Get copyright notice as string.
static java.lang.String getEmail()
          Get email contact address of JavaView as string.
static char getFileSeparator()
          Always return "/", and do not use system file separator.
static java.awt.Font getFont(int type)
          Get font for specific textual application type, like FONT_TEXT, FONT_HEADER2 etc.
static java.awt.Frame getFrame()
          Get frame to be used as parent frame for dialogs.
static java.lang.String getHomepage()
          Get homepage of JavaView as string.
static java.lang.String getLanguage()
          Get the current language used in localizations.
static java.lang.String getMessage(java.lang.String key)
          Get localized translation of message.
static int getOSId()
          Get index of current operating system.
static java.lang.String getOSName()
          Get name of operating system as string.
static java.lang.String getProgram()
          Get name of program as string.
static java.lang.String getProject()
          Get name of project as string.
static java.util.Hashtable getProperties()
          Get JavaView and system properties.
static java.lang.String getTopic()
          Get topic of current version as string.
static java.lang.String getVersion()
          Get version number as string.
static PsViewerIf getViewer()
          Get viewer.
static void init(java.applet.Applet applet, java.awt.Frame frame)
          Initialize this configuration class.
static void init(java.applet.Applet applet, PsViewerIf viewer, java.awt.Frame frame)
          Initialize this configuration class.
static boolean isApplication()
          Returns true if run as application, else false.
static void setCodeBase(java.lang.String aCodeBase)
          Set codebase of current applet or application.
static boolean setFont(int os, int type, java.lang.String name, int style, int size)
          Set font for specific textual application type, like FONT_TEXT, FONT_HEADER2 etc.
static void setLanguage(java.lang.String language)
          Set the current language used in localizations.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AUTHOR

public static final java.lang.String[] AUTHOR
Deprecated. use method getAuthors() to access list of authors.

Array of author names.

CONTRIBUTOR

public static java.lang.String[] CONTRIBUTOR
Deprecated. use method getContributors() to access list of contributors.

Array of contributor names.

HOMEPAGE

public static final java.lang.String HOMEPAGE
Homepage of JavaView.

EMAIL

public static final java.lang.String EMAIL
Email address for contact.

HELP_HTML

public static final java.lang.String HELP_HTML
Help page of JavaView in Html format.

FONTS_HTML

public static final java.lang.String FONTS_HTML
Page with an applet showing available system fonts.

OS_WIN

public static final int OS_WIN
Identifier of Microsoft Windows operating systems.

OS_IRIX

public static final int OS_IRIX
Identifier of Silicon Graphics Irix operating system.

OS_SOLARIS

public static final int OS_SOLARIS
Identifier of Sun Solaris operating system.

OS_LINUX

public static final int OS_LINUX
Identifier of Linux operating system.

OS_OTHER

public static final int OS_OTHER
Identifier of unknown other operating system.

m_osId

public static int m_osId
Identifier of current operating system.

FONT_TEXT

public static final int FONT_TEXT
Identifier of text font used in panels.

FONT_FIXED

public static final int FONT_FIXED
Identifier of fixed (i.e. non-proportional) text font used in panels.

FONT_MENU

public static final int FONT_MENU
Identifier of menu font used in panels.

FONT_HEADER2

public static final int FONT_HEADER2
Identifier of header font used in panels.

FONT_HEADER4

public static final int FONT_HEADER4
Identifier of sub header font used in panels.
Constructor Detail

PsConfig

public PsConfig()
Method Detail

isApplication

public static boolean isApplication()
Returns true if run as application, else false. E.g. applet.stub is not initialized when applet does not run in browser. This information is used e.g. in PsDebug when displaying status messages.

JavaView runs as application if and only if the argument frame != null in PsConfig.init. Therefore it is essential to call PsConfig.init. Usually, this initialization is automatically done in the contructor of PvViewer, but it can be done by hand, if no PvViewer is created.

See Also:
init(Applet, PsViewerIf, Frame), PvViewer.PvViewer(Applet, Frame)

getApplet

public static java.applet.Applet getApplet()
Get applet if run as applet.

getFrame

public static java.awt.Frame getFrame()
Get frame to be used as parent frame for dialogs. If a frame has been specified as argument of PsConfig.init this frame is return. Otherwise an invisible new frame is generated upon the first invocation.

getViewer

public static PsViewerIf getViewer()
Get viewer. Viewer manages the 3d-displays, control window, and list of projects. It is the central class in JavaView, and usually created at the beginning of an applet or application. This instance variable gives access to PvViewer, e.g. to show/hide dialogs and panels.
See Also:
PsViewerIf, PvViewerIf, PvViewer.PvViewer(Applet, Frame)

init

public static void init(java.applet.Applet applet,
                        PsViewerIf viewer,
                        java.awt.Frame frame)
Initialize this configuration class.
See Also:
PvViewer.PvViewer(Applet, Frame), init(Applet, Frame)

init

public static void init(java.applet.Applet applet,
                        java.awt.Frame frame)
Initialize this configuration class.

If argument frame == null and applet != null then program runs as applet, and applet is used to access codebase etc. Otherwise, the program runs as application.

Initialization must be done as soon as possible in an applet or application since system properties are parsed and evaluated. Usually, method is called automatically in the constructor of PvViewer.


getLanguage

public static java.lang.String getLanguage()
Get the current language used in localizations.
Returns:
wo letter id of language in {"de", "en", ...}

setLanguage

public static void setLanguage(java.lang.String language)
Set the current language used in localizations. Any subsequent call of getMessage(String) will return a message in the selected language.

This method does not change any existing labels or menu items which must be done by hand at other place.

Parameters:
language - Two letter id of language in {"de", "en", ...}

getMessage

public static java.lang.String getMessage(java.lang.String key)
Get localized translation of message. Never set an interface label or menu entry directly with a string but always call this method to obtain the localized version of the current locale.
Parameters:
key - message identifier whose localized text is requested
Returns:
message message in localized form for use as label etc

getAuthors

public static java.lang.String getAuthors()
Get author names separated by comma as single string

getContributors

public static java.lang.String[] getContributors()
Get list of contributors as array of strings.

getEmail

public static java.lang.String getEmail()
Get email contact address of JavaView as string.

getHomepage

public static java.lang.String getHomepage()
Get homepage of JavaView as string.

getTopic

public static java.lang.String getTopic()
Get topic of current version as string.

getCopyright

public static java.lang.String getCopyright()
Get copyright notice as string.

getVersion

public static java.lang.String getVersion()
Get version number as string.

getProgram

public static java.lang.String getProgram()
Get name of program as string.

getProject

public static java.lang.String getProject()
Get name of project as string.

getOSName

public static java.lang.String getOSName()
Get name of operating system as string. Might not be available because of security restrictions.
Returns:
name of operating system, or null if not identified.
See Also:
getOSId()

getOSId

public static int getOSId()
Get index of current operating system. Index determines the behaviour of JavaView such as font names and sizes. If operating system could not be identified, for example, because of security restrictions, then OS_WIN is used as default. Use method getOSName() to check whether system could be identified.
Returns:
name of operating system, or OS_WIN if not identified.
See Also:
getOSName()

getProperties

public static java.util.Hashtable getProperties()
Get JavaView and system properties. Call 'System.getProperties()' led to a security exception. Replace by single direct calls 'System.getProperty(String)'

getCodeBase

public static java.lang.String getCodeBase()
Get codebase of current applet or application. Previously, the file separator of system properties was used, but since Java gives the separator of the client instead of the server this behaviour led to problems. Since on windows systems "/" seems to work we use it as default separator.

This method just returns the codebase as string. The codebase was most likely automatically determined in init, or it was assigned using setCodeBase(String).

If JavaView runs as application then the codeBase ends with current file separator.

See Also:
init(java.applet.Applet, jv.object.PsViewerIf, java.awt.Frame), getFileSeparator()

setCodeBase

public static void setCodeBase(java.lang.String aCodeBase)
Set codebase of current applet or application. Usually the codebase is automatically determined by JavaView.

If JavaView runs as application then the codeBase ends with current file separator.

If JavaView is running locally within a web page then some browser use the the "file:" protocol to access local files. In this case, some browsers, notably IE, modify the codebase and replace blanks with %20. This leads to a FileNotFoundException when later reading a local file. I solved this problem by replacing any %20 in a codebase argument of this method if the codebase starts with "file:".

Parameters:
new - codebase
See Also:
getFileSeparator()

getFileSeparator

public static char getFileSeparator()
Always return "/", and do not use system file separator. Previously. the file separator of system properties was used, but since Java gives the separator of the client instead of the server this behaviour led to problems. Since on windows systems "/" seems to work we use it as default.

getFont

public static java.awt.Font getFont(int type)
Get font for specific textual application type, like FONT_TEXT, FONT_HEADER2 etc. Selected font size and name depends on current operating system.

setFont

public static boolean setFont(int os,
                              int type,
                              java.lang.String name,
                              int style,
                              int size)
Set font for specific textual application type, like FONT_TEXT, FONT_HEADER2 etc. Only those gui widgets are affected which are constructed AFTER this call, so this method should probably be called right after JavaView starts. Note, that in general only a rather small set of fonts and font characteristics are supported. Especially, fonts supported on one OS may not be supported on other systems.

Use JavaView applet SystemFonts to show a list all available fonts.

Parameters:
os - identifier of operating system among OS_WIN etc. If os==-1 use current osId.
type - identifier among FONT_TEXT, FONT_HEADER2 etc.
name - name of font such as Helvetica, Courier etc. If name==null ignore name.
style - use among Font.PLAIN, Font.BOLD etc. If style==-1 ignore style.
size - any size which is supported by Java and operating system.

JavaView® v2.12

The software JavaView® is copyright protected. All Rights Reserved.