Package org.opensourcephysics.controls
Class OSPLog
java.lang.Object
org.opensourcephysics.controls.OSPLog
This is a viewable file-based message log for a java package. It displays log
records in a text pane and saves them in a temp file.
- Version:
- 1.0
- Author:
- Douglas Brown, Wolfgang Christian
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static Styleprotected static Styleprotected static final Colorprotected static final Colorprotected static final Colorprotected static Styleprotected static Stylestatic final Level[]protected static booleanprotected static Styleprotected intstatic final PrintStreamprotected static Style -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an OSPLog for a specified class.Constructs an OSPLog for a specified class and resource bundle.Constructs an OSPLog for a specified package.Constructs an OSPLog for a specified package and resource bundle. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddPropertyChangeListener(PropertyChangeListener propertyChangeListener) static voidaddPropertyChangeListener(String name, PropertyChangeListener propertyChangeListener) voidclear()Clears the log.static voidclearLog()Clears the Log.static voidLogs a configuration message.protected voidCreates the GUI.protected LoggerCreates and initializes the logger.protected voidCreates the popup menu.static voidstatic voidstatic voidLogs a fine debugging message.static voidLogs a finer debugging message.static voidLogs a finest debugging message.protected voidfirePropertyChange(String propertyName, Object oldValue, Object newValue) Fires a property change event.protected static JFileChooserGets a file chooser.protected HandlerGets the file handler using lazy instantiation.static JFramegetFrame()static intGets the logger level value.Gets the directory where the log file will be saved if logging is enabled.Gets the logger.Gets the log panel so it can be displayed in a dialog or other container.static OSPLogGets the OSPLog that can be shared by multiple OSP packages.static voidgetOSPLog(boolean useFrame) static voidLogs an information message.static booleanGets whether console messages are logged.static booleanDetermines if the shared log is visible.booleanDetermines if the log is visible.static voidvoidopen()Opens a text file selected with a chooser and writes the contents to the log.voidOpens a text file specified by name and writes the contents to the log.static LevelparseLevel(String level) Returns the Level with the specified name, or null if none.protected StringReads a file.static voidremovePropertyChangeListener(PropertyChangeListener propertyChangeListener) Saves the log to a text file specified by name.Saves a log to a text file selected with a chooser.Saves the xml-formatted log records to a file specified by name.Saves the xml-formatted log records to a file selected with a chooser.static voidsetConsoleMessagesLogged(boolean log) Sets whether console messages are logged.static voidsetFonts(int level) static voidSets the logger level.voidSets the directory where the log file will be saved if logging is enabled.voidsetLogToFileAction(boolean enable) Enables logging to a file.voidsetVisible(boolean visible) Sets the visibility of this log.static voidLogs a severe error message.static JFrameshowLog()Shows the log when it is invoked from the event queue.static voidShows the log.static voidLogs a warning message.
-
Field Details
-
realSysout
-
black
-
red
-
blue
-
green
-
magenta
-
gray
-
DARK_GREEN
-
DARK_BLUE
-
DARK_RED
-
levels
-
logConsole
protected static boolean logConsole -
myPopupFontLevel
protected int myPopupFontLevel
-
-
Constructor Details
-
OSPLog
Constructs an OSPLog for a specified package.- Parameters:
pkg- the package
-
OSPLog
Constructs an OSPLog for a specified package and resource bundle.- Parameters:
pkg- the packageresourceBundleName- the name of the resource bundle
-
OSPLog
Constructs an OSPLog for a specified class.- Parameters:
type- the class
-
OSPLog
Constructs an OSPLog for a specified class and resource bundle.- Parameters:
type- the classresourceBundleName- the name of the resource bundle
-
-
Method Details
-
getOSPLog
Gets the OSPLog that can be shared by multiple OSP packages.- Returns:
- the shared OSPLog
-
getOSPLog
public static void getOSPLog(boolean useFrame) -
setLogDir
Sets the directory where the log file will be saved if logging is enabled.- Parameters:
dir- String
-
getLogDir
Gets the directory where the log file will be saved if logging is enabled.- Parameters:
dir- String
-
isLogVisible
public static boolean isLogVisible()Determines if the shared log is visible.- Returns:
- true if visible
-
setVisible
public void setVisible(boolean visible) Sets the visibility of this log.- Parameters:
true- to set visible
-
isVisible
public boolean isVisible()Determines if the log is visible.- Returns:
- true if visible
-
showLog
Shows the log when it is invoked from the event queue. -
showLogInvokeLater
public static void showLogInvokeLater()Shows the log. -
getLevelValue
public static int getLevelValue()Gets the logger level value.- Returns:
- the current level value
-
setLevel
Sets the logger level.- Parameters:
level- the Level
-
parseLevel
Returns the Level with the specified name, or null if none.- Parameters:
level- the Level
-
severe
Logs a severe error message.- Parameters:
msg- the message
-
warning
Logs a warning message.- Parameters:
msg- the message
-
info
Logs an information message.- Parameters:
msg- the message
-
config
Logs a configuration message.- Parameters:
msg- the message
-
fine
Logs a fine debugging message.- Parameters:
msg- the message
-
clearLog
public static void clearLog()Clears the Log.- Parameters:
msg- the message
-
finer
Logs a finer debugging message.- Parameters:
msg- the message
-
finest
Logs a finest debugging message.- Parameters:
msg- the message
-
setConsoleMessagesLogged
public static void setConsoleMessagesLogged(boolean log) Sets whether console messages are logged.- Parameters:
log- true to log console messages
-
isConsoleMessagesLogged
public static boolean isConsoleMessagesLogged()Gets whether console messages are logged.- Returns:
- true if console messages are logged
-
getLogPanel
Gets the log panel so it can be displayed in a dialog or other container.- Returns:
- a JPanel containing the log
-
clear
public void clear()Clears the log. -
saveLog
Saves the log to a text file specified by name.- Parameters:
fileName- the file name- Returns:
- the name of the file
-
saveLogAs
Saves a log to a text file selected with a chooser.- Returns:
- the name of the file
-
saveXML
Saves the xml-formatted log records to a file specified by name.- Parameters:
fileName- the file name- Returns:
- the name of the file
-
saveXMLAs
Saves the xml-formatted log records to a file selected with a chooser.- Returns:
- the name of the file
-
open
public void open()Opens a text file selected with a chooser and writes the contents to the log. -
open
Opens a text file specified by name and writes the contents to the log.- Parameters:
fileName- the file name
-
getLogger
Gets the logger.- Returns:
- the logger
-
setLogToFileAction
public void setLogToFileAction(boolean enable) Enables logging to a file.- Parameters:
enable- true to log to a file
-
firePropertyChange
Fires a property change event. Needed to expose protected method. -
createGUI
protected void createGUI()Creates the GUI. -
createLogger
Creates and initializes the logger.- Returns:
- the logger
-
getFileHandler
Gets the file handler using lazy instantiation.- Returns:
- the Handler
-
createMenus
protected void createMenus()Creates the popup menu. -
getChooser
Gets a file chooser.- Returns:
- the chooser
-
read
Reads a file.- Parameters:
fileName- the name of the file- Returns:
- the file contents as a String
-
debug
-
setFonts
public static void setFonts(int level) -
finalized
-
notify
-
getFrame
-
addPropertyChangeListener
-
removePropertyChangeListener
-
addPropertyChangeListener
public static void addPropertyChangeListener(String name, PropertyChangeListener propertyChangeListener)
-