Class GUIUtils

java.lang.Object
org.opensourcephysics.display.GUIUtils

public class GUIUtils extends Object
  • Method Details

    • parseTeX

      @Deprecated public static String parseTeX(String input)
      Deprecated.
      use TeXParser class.
      Converts TeX-like notation for Greek symbols to unicode characters.
      Parameters:
      input -
      Returns:
    • removeSubscripting

      @Deprecated public static String removeSubscripting(String input)
      Deprecated.
      use TeXParser class.
      Removes TeX subscripting from the input.
      Parameters:
      input -
      Returns:
    • findInstance

      public static Component findInstance(Container container, Class<?> c)
      Finds an instance of a class in the given container.
      Parameters:
      container - Container
      c - 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 if clearAll<\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

      public static void closeAndDisposeOSPFrames(Frame frame)
      Disposes all OSP frames except the given frame. Usually invoked when the control window is being closed.
      Parameters:
      frame - will not be disposed
    • showSaveDialog

      public static File showSaveDialog(Component parent)
      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 be null; see showDialog in class JFileChooser for details
      Returns:
      the file or null if an error occurred:
    • showSaveDialog

      public static File showSaveDialog(Component parent, String title)
      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 be null; see showDialog in class JFileChooser for details
      title -
      Returns:
      the file or null if an error occurred:
    • showOpenDialog

      public static File showOpenDialog(Component parent)
      Shows a file chooser and opens a file when running in Java. Not applicable when running in JavaScrpipt.
      Parameters:
      parent -
      Returns:
    • getEnabledTextColor

      public static Color getEnabledTextColor()
      Returns the enabled text color.
      Returns:
      the enabled color
    • getDisabledTextColor

      public static Color getDisabledTextColor()
      Returns the disabled text color.
      Returns:
      the disabled color
    • timingTest

      public static void timingTest(Drawable drawable)
      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 file
      outputFileFormat - output file format. One of eps, gif, jpeg, or png
      Throws:
      IOException
    • saveImage

      public static void saveImage(JComponent component, String outputFileFormat, Component parent)
      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 component
      outputFileFormat - output file format. One of eps, jpeg, or png
      parent - 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 Image
      hotspot - the position of the cursor hotspot
      name - the name of the cursor
      predefinedCursorType - one of the predefined Cursor types
    • newJTextPane

      public static JTextPane newJTextPane()
    • checkScrollPage

      protected static boolean checkScrollPage(JTextPane pane, URL url)
      Don't reload the page if local and we are just scrolling
      Parameters:
      pane -
      url -
      Returns:
    • newJTextArea

      public static JTextArea newJTextArea()
    • getParentToolBar

      public static JToolBar getParentToolBar(Container c)
    • getParentOrSelfToolBar

      public static JToolBar getParentOrSelfToolBar(Container c)
    • getParentViewport

      public static JViewport getParentViewport(Container c)
    • 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