Package org.opensourcephysics.display
Class GUIUtils
java.lang.Object
org.opensourcephysics.display.GUIUtils
-
Method Summary
Modifier and TypeMethodDescriptionprotected static boolean
checkScrollPage
(JTextPane pane, URL url) Don't reload the page if local and we are just scrollingstatic void
clearDrawingFrameData
(boolean clearAll) Clears the data in animated DrawingFrames and repaints the frame's content.static void
closeAndDisposeOSPFrames
(Frame frame) Disposes all OSP frames except the given frame.static Cursor
createCustomCursor
(Image image, Point hotspot, String name, int predefinedCursorType) Creates a custom cursor from an image.static void
enableMenubars
(boolean enable) Enables and disables the menu bars in DrawingFrames and DrawingFrame3D.static Component
findInstance
(Container container, Class<?> c) Finds an instance of a class in the given container.static Color
Returns the disabled text color.static Color
Returns the enabled text color.static JToolBar
static JToolBar
static JViewport
static JTextArea
static JTextPane
static String
Deprecated.use TeXParser class.static String
removeSubscripting
(String input) Deprecated.use TeXParser class.static void
Renders all OSPFrames whose animated property is true.static void
Repaints all OSPFrames whose animated property is true.static void
Repaints all OSPFrames.static void
saveImage
(JComponent comp, File outputFile, String outputFileFormat) Saves the contents of the specified component in the given file format.static void
saveImage
(JComponent component, String outputFileFormat, Component parent) Saves the contents of the specified component in the given file format.static void
saveImageAs
(JComponent component, String type, String title, String description, String[] extensions) static void
setAnimatedFrameIgnoreRepaint
(boolean ignoreRepaint) Sets the IgnorRepaint for all animated frames to the given value.static void
Shows all drawing and table frames.static String
showInputDialog
(Component c, String message, String title, int messageType, String value) Allow a simple prompt in JavaScriptstatic File
showOpenDialog
(Component parent) Shows a file chooser and opens a file when running in Java.static File
showSaveDialog
(Component parent) Pops up a "Save File" file chooser dialog and takes user through process of saving a file.static File
showSaveDialog
(Component parent, String title) Pops up a "Save File" file chooser dialog and takes user through process of saving a file.static void
timingTest
(Drawable drawable) Test the time to render a drawable component.
-
Method Details
-
parseTeX
Deprecated.use TeXParser class.Converts TeX-like notation for Greek symbols to unicode characters.- Parameters:
input
-- Returns:
-
removeSubscripting
Deprecated.use TeXParser class.Removes TeX subscripting from the input.- Parameters:
input
-- Returns:
-
findInstance
Finds an instance of a class in the given container.- Parameters:
container
- Containerc
- Class- Returns:
- Component
-
showDrawingAndTableFrames
public static void showDrawingAndTableFrames()Shows all drawing and table frames. Usually invoked when a model is initialized but may be invoked at other times to show frames that have been closed. -
renderAnimatedFrames
public static void renderAnimatedFrames()Renders all OSPFrames whose animated property is true. Usually invoked by an animation thread after every animation step. -
repaintAnimatedFrames
public static void repaintAnimatedFrames()Repaints all OSPFrames whose animated property is true. Usually invoked by a control's single-step button. -
repaintOSPFrames
public static void repaintOSPFrames()Repaints all OSPFrames. -
clearDrawingFrameData
public static void clearDrawingFrameData(boolean clearAll) Clears the data in animated DrawingFrames and repaints the frame's content. All frames are cleared ifclearAll<\code> is true; otherwise only frames whose
autoClear<\code> flag is true will be cleared.
- Parameters:
clearAll
- clears all frames if true
-
setAnimatedFrameIgnoreRepaint
public static void setAnimatedFrameIgnoreRepaint(boolean ignoreRepaint) Sets the IgnorRepaint for all animated frames to the given value.- Parameters:
ignoreRepaint
- boolean
-
enableMenubars
public static void enableMenubars(boolean enable) Enables and disables the menu bars in DrawingFrames and DrawingFrame3D. Usually invoked when a model is initialized but may be invoked at other times. -
closeAndDisposeOSPFrames
Disposes all OSP frames except the given frame. Usually invoked when the control window is being closed.- Parameters:
frame
- will not be disposed
-
showSaveDialog
Pops up a "Save File" file chooser dialog and takes user through process of saving a file.- Parameters:
parent
- the parent component of the dialog, can benull
; seeshowDialog
in class JFileChooser for details- Returns:
- the file or null if an error occurred:
-
showSaveDialog
Pops up a "Save File" file chooser dialog and takes user through process of saving a file.- Parameters:
parent
- the parent component of the dialog, can benull
; seeshowDialog
in class JFileChooser for detailstitle
-- Returns:
- the file or null if an error occurred:
-
showOpenDialog
Shows a file chooser and opens a file when running in Java. Not applicable when running in JavaScrpipt.- Parameters:
parent
-- Returns:
-
getEnabledTextColor
Returns the enabled text color.- Returns:
- the enabled color
-
getDisabledTextColor
Returns the disabled text color.- Returns:
- the disabled color
-
timingTest
Test the time to render a drawable component.- Parameters:
drawable
-
-
saveImage
public static void saveImage(JComponent comp, File outputFile, String outputFileFormat) throws IOException Saves the contents of the specified component in the given file format. Note method requires Java 1.4- Parameters:
comp
-outputFile
- the output fileoutputFileFormat
- output file format. One of eps, gif, jpeg, or png- Throws:
IOException
-
saveImage
Saves the contents of the specified component in the given file format. Pops open a save file dialog to allow the user to select the output file. Note method requires Java 1.4- Parameters:
component
- comp the componentoutputFileFormat
- output file format. One of eps, jpeg, or pngparent
- dialog parent
-
saveImageAs
public static void saveImageAs(JComponent component, String type, String title, String description, String[] extensions) -
createCustomCursor
public static Cursor createCustomCursor(Image image, Point hotspot, String name, int predefinedCursorType) Creates a custom cursor from an image. If an exception occurs, a predefined cursor is returned.- Parameters:
image
- the Imagehotspot
- the position of the cursor hotspotname
- the name of the cursorpredefinedCursorType
- one of the predefined Cursor types
-
newJTextPane
-
checkScrollPage
Don't reload the page if local and we are just scrolling- Parameters:
pane
-url
-- Returns:
-
newJTextArea
-
getParentToolBar
-
getParentOrSelfToolBar
-
getParentViewport
-
showInputDialog
public static String showInputDialog(Component c, String message, String title, int messageType, String value) throws HeadlessException Allow a simple prompt in JavaScript- Parameters:
c
-message
-title
-messageType
-value
-- Returns:
- Throws:
HeadlessException
-