Package com.metsci.glimpse.core.support
Class FrameUtils
- java.lang.Object
-
- com.metsci.glimpse.core.support.FrameUtils
-
public class FrameUtils extends Object
-
-
Constructor Summary
Constructors Constructor Description FrameUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addWindowListenerFirst(Window window, WindowListener firstListener)
WindowListeners are normally run in the order that Window.addWindowListener was called.static void
centerFrame(Frame frame)
Size the frame, and center it on the screen (usually the screen of the primary monitor, but may vary based on the platform's window manager).static void
centerFrame(Frame frame, double screenExtentFraction)
Size the frame, and center it on the screen (usually the screen of the primary monitor, but may vary based on the platform's window manager).static void
centerFrame(Frame frame, int width, int height)
Size the frame, and center it on the screen (usually the screen of the primary monitor, but may vary based on the platform's window manager).static void
centerFrame(Frame frame, Dimension size)
Size the frame, and center it on the screen (usually the screen of the primary monitor, but may vary based on the platform's window manager).static WindowListener
destroyOnWindowClosing(Window window, com.jogamp.opengl.GLAutoDrawable drawable)
Adds a window-closing listener that destroys the drawable.static WindowListener
disposeOnWindowClosing(Window window, GlimpseCanvas canvas)
Adds a window-closing listener that disposes of the canvas.static void
fireWindowClosing(Window w)
Dispatch a window-closing event for the given window.static JFrame
newFrame(String title, Container contentPane, int closeOperation)
static Dimension
screenFracSize(double screenFrac)
static List<GraphicsDevice>
screens()
static void
showFrameCentered(Frame frame)
Size the frame, center it, and make it visible.static void
showFrameCentered(Frame frame, double screenExtentFraction)
Size the frame, center it, and make it visible.static void
showFrameCentered(Frame frame, int width, int height)
Size the frame, center it, and make it visible.static void
showFrameFullscreen(Frame frame)
Make the frame fullscreen across all screens, and make it visible.static void
showFrameFullscreen(Frame frame, boolean allScreens)
Make the frame fullscreen, and make it visible.static void
showFrameFullscreen(Frame frame, GraphicsDevice screen)
Make the frame fullscreen on the screen indicated by screenIndex, and make it visible.static WindowListener
stopOnWindowClosing(Window window, com.jogamp.opengl.GLAnimatorControl animator)
Adds a window-closing listener that stops the animator.
-
-
-
Method Detail
-
fireWindowClosing
public static void fireWindowClosing(Window w)
Dispatch a window-closing event for the given window. Unlike a call toWindow.dispose()
, this will invoke the window's window-closing listeners.This is the programmatic equivalent of clicking the close-window "X" button. It may or may not cause the window to actually close, depending on the window- closing listeners involved, and on the window's default close operation (see
JFrame.setDefaultCloseOperation(int)
).
-
stopOnWindowClosing
public static WindowListener stopOnWindowClosing(Window window, com.jogamp.opengl.GLAnimatorControl animator)
Adds a window-closing listener that stops the animator. This is helpful for programs that end when a window gets closed. Typical setup sequence is: JFrame frame = newFrame( "Title", canvas, DISPOSE_ON_CLOSE ); stopOnWindowClosing( frame, animator ); disposeOnWindowClosing( frame, canvas ); destroyOnWindowClosing( frame, sharedDrawable ); showFrameCentered( frame );
-
disposeOnWindowClosing
public static WindowListener disposeOnWindowClosing(Window window, GlimpseCanvas canvas)
Adds a window-closing listener that disposes of the canvas. This is helpful for programs that end when a window gets closed. Typical setup sequence is: JFrame frame = newFrame( "Title", canvas, DISPOSE_ON_CLOSE ); stopOnWindowClosing( frame, animator ); disposeOnWindowClosing( frame, canvas ); destroyOnWindowClosing( frame, sharedDrawable ); showFrameCentered( frame );
-
destroyOnWindowClosing
public static WindowListener destroyOnWindowClosing(Window window, com.jogamp.opengl.GLAutoDrawable drawable)
Adds a window-closing listener that destroys the drawable. This is helpful for programs that end when a window gets closed. Typical setup sequence is: JFrame frame = newFrame( "Title", canvas, DISPOSE_ON_CLOSE ); stopOnWindowClosing( frame, animator ); disposeOnWindowClosing( frame, canvas ); destroyOnWindowClosing( frame, sharedDrawable ); showFrameCentered( frame );
-
addWindowListenerFirst
public static void addWindowListenerFirst(Window window, WindowListener firstListener)
WindowListeners are normally run in the order that Window.addWindowListener was called. This helper method inserts a WindowListener at the front of the list of listeners by removing all the existing listeners, inserting the new listener, and re-adding all the other listener in order.
-
showFrameCentered
public static void showFrameCentered(Frame frame)
Size the frame, center it, and make it visible. The frame is sized to take up 85% of available horizontal and vertical space.- See Also:
centerFrame(Frame)
-
showFrameCentered
public static void showFrameCentered(Frame frame, double screenExtentFraction)
Size the frame, center it, and make it visible.- See Also:
centerFrame(Frame, double)
-
showFrameCentered
public static void showFrameCentered(Frame frame, int width, int height)
Size the frame, center it, and make it visible.- See Also:
centerFrame(Frame, int, int)
-
centerFrame
public static void centerFrame(Frame frame)
Size the frame, and center it on the screen (usually the screen of the primary monitor, but may vary based on the platform's window manager). Does not make the frame visible. The frame is sized to take up 85% of available horizontal and vertical space.- See Also:
centerFrame(Frame, double)
-
centerFrame
public static void centerFrame(Frame frame, double screenExtentFraction)
Size the frame, and center it on the screen (usually the screen of the primary monitor, but may vary based on the platform's window manager). Does not make the frame visible. The frame is sized to take up the given fraction of available horizontal and vertical space. In most cases, available space will not include system bars and such, but it is ultimately up to the platform's window manager.
-
screenFracSize
public static Dimension screenFracSize(double screenFrac)
-
centerFrame
public static void centerFrame(Frame frame, Dimension size)
Size the frame, and center it on the screen (usually the screen of the primary monitor, but may vary based on the platform's window manager). Does not make the frame visible.
-
centerFrame
public static void centerFrame(Frame frame, int width, int height)
Size the frame, and center it on the screen (usually the screen of the primary monitor, but may vary based on the platform's window manager). Does not make the frame visible.
-
showFrameFullscreen
public static void showFrameFullscreen(Frame frame)
Make the frame fullscreen across all screens, and make it visible. NOTE: This functionality is subject to the whims of the platform's window manager.
-
showFrameFullscreen
public static void showFrameFullscreen(Frame frame, boolean allScreens)
Make the frame fullscreen, and make it visible. The allScreens flag indicates whether all screens should be used, or only the primary monitor. NOTE: This functionality is subject to the whims of the platform's window manager.
-
screens
public static List<GraphicsDevice> screens()
-
showFrameFullscreen
public static void showFrameFullscreen(Frame frame, GraphicsDevice screen)
Make the frame fullscreen on the screen indicated by screenIndex, and make it visible. NOTE: This functionality is subject to the whims of the platform's window manager.
-
-