Class QuickUtils
- java.lang.Object
-
- com.metsci.glimpse.core.support.QuickUtils
-
public class QuickUtils extends Object
A collection of functions for quickly creating plots and showing them in windows.The goal of this class is not to be polished, but to make it extremely easy to pop up a quick data plot. This can be useful during development -- e.g. to examine data for debugging purposes, or to plot timing results.
In terms of design aesthetics, the core module might not be the ideal place for this class. However, keeping it in core allows it to be used without adding an extra dependency, which is a practically significant improvement in ease of use.
- Author:
- hogye
-
-
Constructor Summary
Constructors Constructor Description QuickUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
checkGlimpseModuleAccess()
static com.jogamp.opengl.GLProfile
glProfileOrNull(String glProfileName)
static void
initGlimpseCanvas(NewtSwingEDTGlimpseCanvas canvas, GlimpseLayout layout, LookAndFeel laf, com.jogamp.opengl.GLAnimatorControl animator)
static com.jogamp.opengl.GLProfile
initGlimpseOrExitJvm(String appName, String glProfileName)
Does several things that are typically done at application startup: CallsinitStandardGlimpseApp()
Warns the user if the namedGLProfile
is not available If the user chooses to continue anyway, returns null If the user chooses NOT to continue, callsSystem.exit(int)
static void
initStandardGlimpseApp()
Performs several init operations that are desirable for most Glimpse applications:checkGlimpseModuleAccess()
PlatformFixes.fixPlatformQuirks()
Use heavyweight popup menus, which are visible over top of glimpse canvases Show tooltips reliably, even if the focus manager gets confused by a glimpse canvasstatic SwingEDTAnimator
quickDefaultAnimator()
static AbstractLookAndFeel
quickDefaultLaf()
static Dimension
quickDefaultSize()
static JFrame
quickGlimpseApp(String appName, String glProfileName, GlimpseLayout layout)
static JFrame
quickGlimpseApp(String appName, String glProfileName, GlimpseLayout layout, int width, int height)
static JFrame
quickGlimpseApp(String appName, String glProfileName, GlimpseLayout layout, int width, int height, LookAndFeel laf)
static JFrame
quickGlimpseApp(String appName, String glProfileName, GlimpseLayout layout, LookAndFeel laf)
static JFrame
quickGlimpseApp(String appName, String glProfileName, GlimpseLayout layout, Dimension size)
static JFrame
quickGlimpseApp(String appName, String glProfileName, GlimpseLayout layout, Dimension size, LookAndFeel laf)
Similar to#quickGlimpseWindow(String, String, double, GlimpseLayout)
, but with behavior suitable for a single-window application.static NewtSwingEDTGlimpseCanvas
quickGlimpseCanvas(com.jogamp.opengl.GLContext glContext, GlimpseLayout layout)
static NewtSwingEDTGlimpseCanvas
quickGlimpseCanvas(com.jogamp.opengl.GLContext glContext, GlimpseLayout layout, LookAndFeel laf)
static NewtSwingEDTGlimpseCanvas
quickGlimpseCanvas(com.jogamp.opengl.GLContext glContext, GlimpseLayout layout, LookAndFeel laf, com.jogamp.opengl.GLAnimatorControl animator)
static NewtSwingEDTGlimpseCanvas
quickGlimpseCanvas(com.jogamp.opengl.GLProfile glProfile, GlimpseLayout layout)
static NewtSwingEDTGlimpseCanvas
quickGlimpseCanvas(com.jogamp.opengl.GLProfile glProfile, GlimpseLayout layout, LookAndFeel laf)
static NewtSwingEDTGlimpseCanvas
quickGlimpseCanvas(com.jogamp.opengl.GLProfile glProfile, GlimpseLayout layout, LookAndFeel laf, com.jogamp.opengl.GLAnimatorControl animator)
static NewtSwingEDTGlimpseCanvas
quickGlimpseCanvas(String glProfileName, GlimpseLayout layout)
static NewtSwingEDTGlimpseCanvas
quickGlimpseCanvas(String glProfileName, GlimpseLayout layout, LookAndFeel laf)
static JFrame
quickGlimpseWindow(String title, NewtSwingEDTGlimpseCanvas canvas)
static JFrame
quickGlimpseWindow(String title, NewtSwingEDTGlimpseCanvas canvas, int width, int height)
static JFrame
quickGlimpseWindow(String title, NewtSwingEDTGlimpseCanvas canvas, Dimension size)
static MultiAxisPlot2D
quickXyPlot(GlimpsePainter... painters)
Creates aMultiAxisPlot2D
layout with contents that are desirable for most XY plots: X and Y axes GridPainter CrosshairPainter (with selection box disabled) BorderPainter.static void
requireSwingThread()
static boolean
showGLWarningDialog(String progName)
static void
swingInvokeLater(ThrowingRunnable runnable)
LikeSwingUtilities.invokeLater(Runnable)
, but allows the runnable to throw checked exceptions.
-
-
-
Method Detail
-
initStandardGlimpseApp
public static void initStandardGlimpseApp()
Performs several init operations that are desirable for most Glimpse applications:checkGlimpseModuleAccess()
PlatformFixes.fixPlatformQuirks()
- Use heavyweight popup menus, which are visible over top of glimpse canvases
- Show tooltips reliably, even if the focus manager gets confused by a glimpse canvas
This method is for convenience only. It is perfectly acceptable for an application to perform some or all of these init operations piecemeal, instead of calling this method.
NOTE: This method should be called near the beginning of main, after the Swing LookAndFeel has been set, but before any UI components get created.
-
checkGlimpseModuleAccess
public static void checkGlimpseModuleAccess()
-
requireSwingThread
public static void requireSwingThread()
-
swingInvokeLater
public static void swingInvokeLater(ThrowingRunnable runnable)
LikeSwingUtilities.invokeLater(Runnable)
, but allows the runnable to throw checked exceptions. If a checked exception is thrown, it will be caught and wrapped in a newRuntimeException
, which will then be thrown.
-
glProfileOrNull
public static com.jogamp.opengl.GLProfile glProfileOrNull(String glProfileName)
-
showGLWarningDialog
public static boolean showGLWarningDialog(String progName)
-
quickXyPlot
public static MultiAxisPlot2D quickXyPlot(GlimpsePainter... painters)
Creates aMultiAxisPlot2D
layout with contents that are desirable for most XY plots:- X and Y axes
- GridPainter
- CrosshairPainter (with selection box disabled)
- BorderPainter.
This method is for convenience only. It is perfectly acceptable for an application to perform some or all of these init operations piecemeal, instead of calling this method.
-
quickDefaultLaf
public static AbstractLookAndFeel quickDefaultLaf()
-
quickDefaultAnimator
public static SwingEDTAnimator quickDefaultAnimator()
-
quickDefaultSize
public static Dimension quickDefaultSize()
-
quickGlimpseApp
public static JFrame quickGlimpseApp(String appName, String glProfileName, GlimpseLayout layout)
-
quickGlimpseApp
public static JFrame quickGlimpseApp(String appName, String glProfileName, GlimpseLayout layout, LookAndFeel laf)
-
quickGlimpseApp
public static JFrame quickGlimpseApp(String appName, String glProfileName, GlimpseLayout layout, int width, int height)
-
quickGlimpseApp
public static JFrame quickGlimpseApp(String appName, String glProfileName, GlimpseLayout layout, int width, int height, LookAndFeel laf)
-
quickGlimpseApp
public static JFrame quickGlimpseApp(String appName, String glProfileName, GlimpseLayout layout, Dimension size)
-
quickGlimpseApp
public static JFrame quickGlimpseApp(String appName, String glProfileName, GlimpseLayout layout, Dimension size, LookAndFeel laf)
Similar to#quickGlimpseWindow(String, String, double, GlimpseLayout)
, but with behavior suitable for a single-window application. In particular, starts by callinginitStandardGlimpseApp()
, and warns the user if the namedGLProfile
is not available.This method is for convenience only. It is perfectly acceptable for an application to perform some or all of these init operations piecemeal, instead of calling this method.
NOTE: If the named
GLProfile
is not available, and the user chooses to quit rather than continue, this method callsSystem.exit(int)
!
-
initGlimpseOrExitJvm
public static com.jogamp.opengl.GLProfile initGlimpseOrExitJvm(String appName, String glProfileName)
Does several things that are typically done at application startup:- Calls
initStandardGlimpseApp()
- Warns the user if the named
GLProfile
is not available - If the user chooses to continue anyway, returns null
- If the user chooses NOT to continue, calls
System.exit(int)
- Calls
-
quickGlimpseCanvas
public static NewtSwingEDTGlimpseCanvas quickGlimpseCanvas(String glProfileName, GlimpseLayout layout)
-
quickGlimpseCanvas
public static NewtSwingEDTGlimpseCanvas quickGlimpseCanvas(String glProfileName, GlimpseLayout layout, LookAndFeel laf)
-
quickGlimpseCanvas
public static NewtSwingEDTGlimpseCanvas quickGlimpseCanvas(com.jogamp.opengl.GLProfile glProfile, GlimpseLayout layout)
-
quickGlimpseCanvas
public static NewtSwingEDTGlimpseCanvas quickGlimpseCanvas(com.jogamp.opengl.GLProfile glProfile, GlimpseLayout layout, LookAndFeel laf)
-
quickGlimpseCanvas
public static NewtSwingEDTGlimpseCanvas quickGlimpseCanvas(com.jogamp.opengl.GLContext glContext, GlimpseLayout layout)
-
quickGlimpseCanvas
public static NewtSwingEDTGlimpseCanvas quickGlimpseCanvas(com.jogamp.opengl.GLContext glContext, GlimpseLayout layout, LookAndFeel laf)
-
quickGlimpseCanvas
public static NewtSwingEDTGlimpseCanvas quickGlimpseCanvas(com.jogamp.opengl.GLProfile glProfile, GlimpseLayout layout, LookAndFeel laf, com.jogamp.opengl.GLAnimatorControl animator)
-
quickGlimpseCanvas
public static NewtSwingEDTGlimpseCanvas quickGlimpseCanvas(com.jogamp.opengl.GLContext glContext, GlimpseLayout layout, LookAndFeel laf, com.jogamp.opengl.GLAnimatorControl animator)
-
initGlimpseCanvas
public static void initGlimpseCanvas(NewtSwingEDTGlimpseCanvas canvas, GlimpseLayout layout, LookAndFeel laf, com.jogamp.opengl.GLAnimatorControl animator)
-
quickGlimpseWindow
public static JFrame quickGlimpseWindow(String title, NewtSwingEDTGlimpseCanvas canvas)
-
quickGlimpseWindow
public static JFrame quickGlimpseWindow(String title, NewtSwingEDTGlimpseCanvas canvas, int width, int height)
-
quickGlimpseWindow
public static JFrame quickGlimpseWindow(String title, NewtSwingEDTGlimpseCanvas canvas, Dimension size)
-
-