ch.aplu.util
Class GPanel

java.lang.Object
  extended by ch.aplu.util.GPanel

public class GPanel
extends java.lang.Object

Simple graphics window of default size 501x501 pixels (client drawing area) using a coordinate system with x-axis from left to right, y-axis from bottom to top (called window coordinates, default range 0..1, 0..1). The drawing methods perform all drawings in an offscreen buffer and automatically repaint it on the screen, so the graphics is shown step-by-step.

A current graph position is used, that remembers the end position of the last drawing process and where new drawings start.

By default the window may be resized by mouse dragging as long as resizable(false) isn't called. Resizing transforms the current graphics content through an affine transformation from the offscreen buffer. In this process, some graphics resolution is lost.

If pixel accuracy is needed, set the window coordinates to 500, 500.

Clicking the title bar's close button will terminate the application by calling System.exit(0) unless an ExitListener is registered.

More than one GPanel may be instantiated. They are automatically positioned two-by-two.

All constructors and Swing methods are invoked by the Event Dispatch Thread (EDT). Therefore GPanel is no longer derived from JPanel, but contains a JPanel now (has-a relation). If you need some special methods from the internal JPanel, call getPane().

Some library defaults of the GPanel window can be modified by using a Java properties file aplu_util.properties. For more details consult aplu_util.properties file found in the distribution.

When the close button of the GPanel window title bar is hit, System.exit(0) is executed that terminates the JVM, but you can modifiy this behavior by registering your own implementation of the ExitListener interface or by using the key GPanelClosingMode in aplu_util.properties.

Do not mix with Graphics or Graphics2D methods. Use GWindow instead.

See Also:
GPane, GWindow

Nested Class Summary
static class GPanel.ClosingMode
           
 
Field Summary
static int APPLETFRAME
          Mode for a GPanel used as standalone window in a applet.
static int EMBEDDED
          Mode for a GPanel embedded in a top-level window (no longer supported).
static Fullscreen FULLSCREEN
          Instance of class Fullscreen.
static int NOTITLEBAR
          Mode for a GPanel with no title bar.
static int STANDARD
          Mode for a standard GPanel.
 
Constructor Summary
GPanel()
          Construct a GPanel and show the window.
GPanel(boolean visible)
          Same as GPanel() with given visibility.
GPanel(double xmin, double xmax, double ymin, double ymax)
          Construct a GPanel with given window coordinates
GPanel(double xmin, double xmax, double ymin, double ymax, boolean visible)
          Same as GPanel() with given window coordinates and visibility.
GPanel(int mode)
          Construct a GPanel for special purposes.
GPanel(int mode, Size size)
          Same as GPanel() with given mode and window size (client area).
GPanel(javax.swing.JMenuBar menuBar)
          Same as GPanel() but show given menuBar.
GPanel(javax.swing.JMenuBar menuBar, boolean visible)
          Same as GPanel() with given menuBar and visibility.
GPanel(javax.swing.JMenuBar menuBar, double xmin, double xmax, double ymin, double ymax)
          Same as GPanel(xmin, xmax, ymin, ymax) with given menuBar.
GPanel(javax.swing.JMenuBar menuBar, double xmin, double xmax, double ymin, double ymax, boolean visible)
          Same as GPanel() with given menuBar, window coordinates and visibility.
GPanel(Size size)
          Same as GPanel() with given window size (client area).
GPanel(Size size, java.lang.String title, javax.swing.JMenuBar menuBar, double xmin, double xmax, double ymin, double ymax, boolean visible)
          Same as GPanel() with given window size (client area), title, menuBar, window coordinates and visibility.
GPanel(java.lang.String title)
          Same as GPanel() with given title.
GPanel(java.lang.String title, boolean visible)
          Same as GPanel() with given title and visibility.
GPanel(java.lang.String title, double xmin, double xmax, double ymin, double ymax)
          Same as GPanel(xmin, xmax, ymin, ymax) with given title.
GPanel(java.lang.String title, double xmin, double xmax, double ymin, double ymax, boolean visible)
          Same as GPanel() with given title, window coordinates and visibility.
GPanel(java.lang.String title, javax.swing.JMenuBar menuBar)
          Same as GPanel() with given title and menuBar.
GPanel(java.lang.String title, javax.swing.JMenuBar menuBar, boolean visible)
          Same as GPanel() with given title, menuBar and visibility.
GPanel(java.lang.String title, javax.swing.JMenuBar menuBar, double xmin, double xmax, double ymin, double ymax)
          Same as GPanel(xmin, xmax, ymin, ymax) with given title and menuBar.
GPanel(java.lang.String title, javax.swing.JMenuBar menuBar, double xmin, double xmax, double ymin, double ymax, boolean visible)
          Same as GPanel() with given title, menuBar, window coordinates and visibility.
 
Method Summary
 void _delay(int time)
          Non-static version of delay().
 void add(java.awt.Component comp)
          Same as addComponent() (deprecated).
 void addComponent(java.awt.Component comp)
          Append the specified component to the container.
 void addExitListener(ExitListener exitListener)
          Register an ExitListener to get a notification when the close button is clicked.
 void addMouseListener(java.awt.event.MouseListener listener)
          Invoke the internal JPanels addMouseListener().
 void addMouseMotionListener(java.awt.event.MouseMotionListener listener)
          Invoke the internal JPanels addMouseMotionListener().
 void addMouseWheelListener(java.awt.event.MouseWheelListener listener)
          Invoke the internal JPanels addMouseWheelListener().
 void addStatusBar(int height)
          Add a status window attached at the bottom of the GPanel window.
 void applyTransform(java.awt.geom.AffineTransform at)
          Apply the given AffineTransform to offscreen buffer.
 void arc(double radius, double startAngle, double extendAngle)
          Draw an arc with center at the current graph position and given radius in window coordinates.
 java.awt.Color bgColor(java.awt.Color color)
          Set the background color.
 java.awt.Color bgColor(java.lang.String colorStr)
          Set the background color using the given X11 color name.
 void circle(double radius)
          Draw a circle with center at the current graph position and given radius in horizontal window coordinates.
 void clear()
          Clear the graphics window (fully paint with background color) (and the offscreen buffer used by the window).
 void clearStore(java.awt.Color color)
          Clear store buffer by uniformly painting it with with given color.
 void clearStore(java.lang.String colorStr)
          Clear store buffer by uniformly painting it with with the given X11 color name.
 java.awt.Color color(java.awt.Color color)
          Same as setColor(Color color) (deprecated).
 java.awt.Color color(java.lang.String colorStr)
          Same as setColor(String colorStr) (deprecated).
 void cubicBezier(double x1, double y1, double xc1, double yc1, double xc2, double yc2, double x2, double y2)
          Draw a cubic bezier curve.
 void cubicBezier(java.awt.geom.Point2D.Double pt1, java.awt.geom.Point2D.Double ptc1, java.awt.geom.Point2D.Double ptc2, java.awt.geom.Point2D.Double pt2)
          Draw a cubic bezier curve.
static void delay(int time)
          Delay execution for the given amount of time ( in ms ).
 void disableClose(boolean b)
          Disable/enable the title bar's closing button.
 void dispose()
          Release all used system resources (offscreen buffer, graphics context) and unblock getKeyWait() and getKeyCodeWait() and waiting Monitor.putSleep().
 void draw(double x, double y)
          Draw a line from current graph position to given window coordinates and set the graph position to the endpoint.
 void draw(java.awt.geom.Point2D.Double pt)
          Draw a line from current graph position to given point (in window coordinates) and set the graph position to the endpoint.
 void ellipse(double a, double b)
          Draw an ellipse with center at the current graph position and given horizontal and vertical axes.
 boolean enableRepaint(boolean doRepaint)
          Enable or disable the automatic repaint in graphics methods.
 void erase()
          Same as clear() but let the current graph position unchanged.
 void fill(double x, double y, java.awt.Color color, java.awt.Color replacement)
          Change the color of the bounded region with the given internal point to the replacement color using the flood fill algorithm.
 void fill(double x, double y, java.lang.String colorStr, java.lang.String replacementStr)
          Change the color of the bounded region with the given internal point to the replacement color using the flood fill algorithm.
 void fill(java.awt.geom.Point2D.Double pt, java.awt.Color color, java.awt.Color replacement)
          Change the color of the bounded region with the given internal point to the replacement color using the flood fill algorithm.
 void fill(java.awt.geom.Point2D.Double pt, java.lang.String colorStr, java.lang.String replacementStr)
          Change the color of the bounded region with the given internal point to the replacement color using the flood fill algorithm.
 void fillArc(double radius, int startAngle, int extendAngle)
          Draw a filled arc with center at the current graph position and given radius in window coordinates.
 void fillCircle(double radius)
          Draw a filled circle with center at the current graph position and given radius in window coordinates using the current color.
 void fillEllipse(double a, double b)
          Draw a filled ellipse with center at the current graph position and given horizontal and vertical axes.
 void fillGeneralPath(java.awt.geom.GeneralPath gp)
          Fill a figure defined by the given GeneralPath (using window coordinates) using the current color.
 void fillPolygon(double[] x, double[] y)
          Draw a filled polygon with given corner coordinates in window coordinates using the current color.
 void fillPolygon(java.awt.geom.Point2D.Double[] corner)
          Draw a filled polygon with given corner points in window coordinates using the current color.
 void fillRectangle(double width, double height)
          Draw a filled rectangle with center at the current graph position and given width and height in window coordinates using the current color.
 void fillRectangle(double x1, double y1, double x2, double y2)
          Draw a filled rectangle with given opposite corners in window coordinates using the current color.
 void fillRectangle(java.awt.geom.Point2D.Double pt1, java.awt.geom.Point2D.Double pt2)
          Draw a filled rectangle with given opposite corner points in window coordinates using the current color.
 void fillTriangle(double x1, double y1, double x2, double y2, double x3, double y3)
          Draw a filled triangle with given corner coordinates in window coordinates using the current color.
 void fillTriangle(java.awt.geom.Point2D.Double pt1, java.awt.geom.Point2D.Double pt2, java.awt.geom.Point2D.Double pt3)
          Draw a filled triangle with given corners in window coordinates using the current color.
 void font(java.awt.Font font)
          Select the given font for all following text operations.
 void generalPath(java.awt.geom.GeneralPath gp)
          Draw a figure defined by the given GeneralPath (using window coordinates).
static java.lang.String getAbout()
          Return copywrite information.
 java.awt.Color getBgColor()
          Return the current background color.
 java.lang.String getBgColorStr()
          Return the current background X11 color name.
static java.awt.geom.Point2D.Double getDividingPoint(java.awt.geom.Point2D.Double pt1, java.awt.geom.Point2D.Double pt2, double ratio)
          Returns the point on the line through the point pt1 and the point pt2 that is in distance ratio times the length from pt1 to pt2 from pt1.
static GBitmap getImage(java.lang.String imagePath)
          Retrieve the image either from the jar resource, from local drive or from a internet server.
 char getKey()
          Return the unicode character associated with last key typed.
 int getKeyCode()
          Return the keycode associated with last key pressed.
 int getKeyCodeWait()
          Wait until a key is typed and return the keycode associated with last key pressed.
 char getKeyWait()
          Wait until a key is typed and return the unicode character associated with it.
 int getModifiers()
          Return the modifiers associated with last key pressed.
 java.lang.String getModifiersText()
          Return the modifiers text description associated with last key pressed.
 java.awt.Graphics2D getOffG2D()
          Return the Graphics2D context of the offscreen buffer
 GPane getPane()
          Return the GPane container that holds the graphics.
 java.awt.Color getPixelColor(double x, double y)
          Return the color of the pixel at given window coordinates.
 java.awt.Color getPixelColor(java.awt.geom.Point2D.Double pt)
          Return the color of the pixel at given point (in window coordinates).
 java.lang.String getPixelColorStr(double x, double y)
          Return the X11 color name of the pixel at given window coordinates.
 java.lang.String getPixelColorStr(java.awt.geom.Point2D.Double pt)
          Return the X11 color name of the pixel at given point (in window coordinates).
 java.awt.geom.Point2D.Double getPos()
          Return reference to point of current graph position (in window coordinates).
 double getPosX()
          Return window coordinate x of current graph position.
 double getPosY()
          Return window coordinate y of current graph position.
static java.lang.String getVersion()
          Return version information.
 GWindow getWindow()
          Return a reference to the GWindow used by the GPanel.
 boolean image(java.awt.image.BufferedImage bi, double x, double y)
          Show the GIF image from given BufferedImage at x, y window coordinates (specifies lowerleft corner of image).
 boolean image(java.awt.image.BufferedImage bi, java.awt.geom.Point2D.Double pt)
          Show the GIF image from given BufferedImage at given point(in window coordinates) (specifies lowerleft corner of image).
 boolean image(java.lang.String imagePath, double x, double y)
          Show the GIF image from given file path at given window coordinates (specifies lowerleft corner of image).
 boolean image(java.lang.String imagePath, java.awt.geom.Point2D.Double pt)
          Show the GIF image from given file path at given point(in window coordinates) (specifies lowerleft corner of image).
 double imageHeight(java.lang.String imagePath)
          Return the height (vertical size) of the GIF image from the given path (in window coordinates).
 double imageWidth(java.lang.String imagePath)
          Return the width (horizontal size) of the GIF image from the given path (in window coordinates).
 boolean isDisposed()
          Return true, if the window was disposed or released.
 boolean isReady()
          Test if GPanel is fully initialized.
 boolean kbhit()
          Return true, if a key was typed since the last call of getKey(), getKeyWait(), getKeyCode(), getKeyCodeWait().
 void line(double x1, double y1, double x2, double y2)
          Draw a line with given window coordinates and set the graph position to the endpoint.
 void line(java.awt.geom.Point2D.Double pt1, java.awt.geom.Point2D.Double pt2)
          Draw a line with given points (in window coordinates) and set the graph position to the endpoint.
 void lineWidth(int width)
          Set the current line width in pixels.
 void move(double x, double y)
          Set the current graph position to given window coordinates (without drawing anything).
 void move(int x, int y)
          Same as move(double x, double y)
 void move(java.awt.geom.Point2D.Double pt)
          Set the current graph position to given point (in window coordinates) (without drawing anything).
 void point(double x, double y)
          Draw a single point at the given window coordinates.
 void point(java.awt.geom.Point2D.Double pt)
          Draw a single point at the given pt (in window coordinates).
 void polygon(double[] x, double[] y)
          Draw a polygon with given corner coordinates in window coordinates.
 void polygon(java.awt.geom.Point2D.Double[] corner)
          Draw a polygon with given corner points in window coordinates.
 void pos(double x, double y)
          Same as move(double x, double y).
 void pos(java.awt.geom.Point2D.Double pt)
          Same as move(Point2D.Double pt).
 boolean print(GPrintable gp)
          Same as print(GPrintable gp, double scale) with scale = 1.
 boolean print(GPrintable gp, double scale)
          Print the graphics context to an attached printer with the given magnification scale factor.
 boolean printScreen()
          Same printScreen(double scale) with scale = 1.
 boolean printScreen(double scale)
          Print the current screen view to an attached printer with the given magnification scale factor.
 void quadraticBezier(double x1, double y1, double xc, double yc, double x2, double y2)
          Draw a quadratic bezier curve.
 void quadraticBezier(java.awt.geom.Point2D.Double pt1, java.awt.geom.Point2D.Double ptc, java.awt.geom.Point2D.Double pt2)
          Draw a quadratic bezier curve.
 void recallGraphics()
          Copy graphics from store buffer to offscreen buffer and render it on the screen window (if enableRepaint(true)).
 void rectangle(double width, double height)
          Draw a rectangle with center at the current graph position and given width and height in window coordinates.
 void rectangle(double x1, double y1, double x2, double y2)
          Draw a rectangle with given opposite corners in window coordinates.
 void rectangle(java.awt.geom.Point2D.Double pt1, java.awt.geom.Point2D.Double pt2)
          Draw a rectangle with given opposite corner points in window coordinates.
 void repaint()
          Invoke the internal JPanels repaint().
 void resizable(boolean b)
          Enable/disable resizing of the window by mouse dragging.
 void setClosingMode(GPanel.ClosingMode mode)
          Determines what happens when the title bar close button is hit.
 java.awt.Color setColor(java.awt.Color color)
          Set the given new color and return the previous color
 java.awt.Color setColor(java.lang.String colorStr)
          Set the color to the given X11 color name.
 void setEnableResize(boolean enable)
          Enable/disable resizing.
 void setFocusable(boolean focusable)
          Set the focusable state to the specified value.
 void setPaintMode()
          Set the paint mode of the graphics context to overwrite with current color.
 void setStatusText(java.lang.String text)
          Replace the text in the status bar by the given text using the current JOptionPane font and color.
 void setStatusText(java.lang.String text, java.awt.Font font, java.awt.Color color)
          Replace the text in the status bar by the given text using the given font and text color.
 void setXORMode(java.awt.Color c)
          Sets the paint mode to alternate between the current color and the given color.
 void setXORMode(java.lang.String colorStr)
          Same as setXORMode(Color c), but using the given X11 color name.
 void showStatusBar(boolean show)
          Show or hide the status bar.
 void storeGraphics()
          Create a store buffer and copy current graphics to it.
 void text(char c)
          Draw a char at the current graph position.
 void text(double x, double y, char c)
          Draw a char at the given position.
 void text(double x, double y, java.lang.String str)
          Draw a string at the given position.
 void text(double x, double y, java.lang.String str, java.awt.Font font, java.awt.Color textColor, java.awt.Color bgColor)
          Draw a string at the given position with extended text attributes.
 void text(double x, double y, java.lang.String str, java.awt.Font font, java.lang.String textColorStr, java.lang.String bgColorStr)
          Draw a string at the given position with extended text attributes using X11 color names.
 void text(java.awt.geom.Point2D.Double pt, char c)
          Draw a char at the given position.
 void text(java.awt.geom.Point2D.Double pt, java.lang.String str)
          Draw a string at the given position.
 void text(java.awt.geom.Point2D.Double pt, java.lang.String str, java.awt.Font font, java.awt.Color textColor, java.awt.Color bgColor)
          Draw a string at the given position with extended text attributes.
 void text(java.awt.geom.Point2D.Double pt, java.lang.String str, java.awt.Font font, java.lang.String textColorStr, java.lang.String bgColorStr)
          Draw a string at the given position with extended text attributes using X11 color names.
 void text(java.lang.String str)
          Draw a string at the current graph position.
 void title(java.lang.String title)
          Set the title in the window's title bar.
static java.awt.Color toColor(java.lang.String colorStr)
          Return the Color reference for the given color as string.
 java.awt.Point toUser(double windowX, double windowY)
          Return reference to point in user coordinate of given window coordinates.
 java.awt.Point toUser(java.awt.geom.Point2D.Double windowPt)
          Return reference to point in user coordinate of given point in window coordinate.
 int toUserHeight(double windowHeight)
          Return user coordinates increment y of given window coordinates increment y.
 int toUserWidth(double windowWidth)
          Return user coordinates increment x of given window coordinates increment x.
 int toUserX(double windowX)
          Return user coordinate x of given window coordinate x.
 int toUserY(double windowY)
          Return user coordinate y of given window coordinate y.
 java.awt.geom.Point2D.Double toWindow(int userX, int userY)
          Return reference to point in window coordinates of given user coordinates.
 java.awt.geom.Point2D.Double toWindow(java.awt.Point userPt)
          Return reference to point in window coordinates of given point in user coordinates.
 double toWindowHeight(int userHeight)
          Return window coordinates increment y of given user coordinates increment y.
 double toWindowWidth(int userWidth)
          Return window coordinates increment x of given user coordinates increment x.
 double toWindowX(int userX)
          Return window coordinate x of given user coordinate x.
 double toWindowY(int userY)
          Return window coordinate y of given user coordinate y.
 void triangle(double x1, double y1, double x2, double y2, double x3, double y3)
          Draw a triangle with given corner coordinates in window coordinates.
 void triangle(java.awt.geom.Point2D.Double pt1, java.awt.geom.Point2D.Double pt2, java.awt.geom.Point2D.Double pt3)
          Draw a triangle with given corners in window coordinates.
 void validate()
          Validate the container.
 void visible(boolean isVisible)
          Select if GPanel's window is visible or not.
 void window(double xmin, double xmax, double ymin, double ymax)
          Set window coordinates.
 void windowCenter()
          Set the window position to the center of the screen.
 void windowPosition(int ulx, int uly)
          Set the window position (upper left corner in device coordinates).
 void windowSize(int width, int height)
          Set the size of the entire window (including title bar and borders) in device coordinates.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STANDARD

public static int STANDARD
Mode for a standard GPanel.


EMBEDDED

public static int EMBEDDED
Mode for a GPanel embedded in a top-level window (no longer supported). Use a GPane instance instead.


APPLETFRAME

public static int APPLETFRAME
Mode for a GPanel used as standalone window in a applet.


NOTITLEBAR

public static int NOTITLEBAR
Mode for a GPanel with no title bar.


FULLSCREEN

public static Fullscreen FULLSCREEN
Instance of class Fullscreen.

Constructor Detail

GPanel

public GPanel(int mode)
Construct a GPanel for special purposes.

Use parameter GPanel.APPLETFRAME for an Applet in its own frame.

Use parameter GPanel.NOTITLEBAR for GPanel which has no title bar. Does not show until visible(true) is called.

To embed a GPanel in a top-level window (JFrame, JDialog, Browswer window, etc.) use class GPane instead.


GPanel

public GPanel(int mode,
              Size size)
Same as GPanel() with given mode and window size (client area). Default window size is 501/501 (user coordinates 0..500/0..500.
If size is an instance of Fullscreen, the size is set to the current screen width/height.


GPanel

public GPanel()
Construct a GPanel and show the window. Window coordinates are 0, 1, 0, 1. (0, 0) is at lower left corner which is the current graph cursor position.


GPanel

public GPanel(boolean visible)
Same as GPanel() with given visibility.


GPanel

public GPanel(Size size)
Same as GPanel() with given window size (client area). User coordinates (pixels) in range 0..width-1/0..height-1
Default window size is 501/501 (user coordinates 0..500/0..500.
Use GPanel(new Size(width, height)) to set size to width/height.
If size is an instance of Fullscreen, the size is set to the current screen width/height and the window is positioned at upper left corner.


GPanel

public GPanel(javax.swing.JMenuBar menuBar)
Same as GPanel() but show given menuBar.


GPanel

public GPanel(javax.swing.JMenuBar menuBar,
              boolean visible)
Same as GPanel() with given menuBar and visibility.


GPanel

public GPanel(java.lang.String title)
Same as GPanel() with given title.


GPanel

public GPanel(java.lang.String title,
              boolean visible)
Same as GPanel() with given title and visibility.


GPanel

public GPanel(java.lang.String title,
              javax.swing.JMenuBar menuBar)
Same as GPanel() with given title and menuBar.


GPanel

public GPanel(java.lang.String title,
              javax.swing.JMenuBar menuBar,
              boolean visible)
Same as GPanel() with given title, menuBar and visibility.


GPanel

public GPanel(double xmin,
              double xmax,
              double ymin,
              double ymax)
Construct a GPanel with given window coordinates. (0, 0) is lower left If you need to draw as accurate as possible on pixels use GPanel(0, 500, 0, 500). Set the current graph position to (0, 0).


GPanel

public GPanel(double xmin,
              double xmax,
              double ymin,
              double ymax,
              boolean visible)
Same as GPanel() with given window coordinates and visibility.


GPanel

public GPanel(javax.swing.JMenuBar menuBar,
              double xmin,
              double xmax,
              double ymin,
              double ymax)
Same as GPanel(xmin, xmax, ymin, ymax) with given menuBar.


GPanel

public GPanel(javax.swing.JMenuBar menuBar,
              double xmin,
              double xmax,
              double ymin,
              double ymax,
              boolean visible)
Same as GPanel() with given menuBar, window coordinates and visibility.


GPanel

public GPanel(java.lang.String title,
              double xmin,
              double xmax,
              double ymin,
              double ymax)
Same as GPanel(xmin, xmax, ymin, ymax) with given title.


GPanel

public GPanel(java.lang.String title,
              double xmin,
              double xmax,
              double ymin,
              double ymax,
              boolean visible)
Same as GPanel() with given title, window coordinates and visibility.


GPanel

public GPanel(java.lang.String title,
              javax.swing.JMenuBar menuBar,
              double xmin,
              double xmax,
              double ymin,
              double ymax)
Same as GPanel(xmin, xmax, ymin, ymax) with given title and menuBar.


GPanel

public GPanel(java.lang.String title,
              javax.swing.JMenuBar menuBar,
              double xmin,
              double xmax,
              double ymin,
              double ymax,
              boolean visible)
Same as GPanel() with given title, menuBar, window coordinates and visibility.


GPanel

public GPanel(Size size,
              java.lang.String title,
              javax.swing.JMenuBar menuBar,
              double xmin,
              double xmax,
              double ymin,
              double ymax,
              boolean visible)
Same as GPanel() with given window size (client area), title, menuBar, window coordinates and visibility.
User coordinates (pixels) in range 0..width-1/0..height-1
Default window size is 501/501.
Set menuBar = null, if no menu is used.
If size is an instance of Fullscreen, the size is set to the current screen width/height.

Method Detail

addExitListener

public void addExitListener(ExitListener exitListener)
Register an ExitListener to get a notification when the close button is clicked. After registering the automatic termination is disabled. To terminate the application, System.exit() can be called.


window

public void window(double xmin,
                   double xmax,
                   double ymin,
                   double ymax)
Set window coordinates. left_x, right_x, bottom_y, top_y


visible

public void visible(boolean isVisible)
Select if GPanel's window is visible or not. (You may draw into an invisible GPanel and show it afterwards.)


getWindow

public GWindow getWindow()
Return a reference to the GWindow used by the GPanel. Can be used to access the surrounding JFrame because GWindow is derived from JFrame.


isReady

public boolean isReady()
Test if GPanel is fully initialized. Only used for GPanel.EMBEDDED.
(If GPanel is embedded in an other component, any graphics drawing operation must be postponed until the parent component is shown because the GPanel's size is only known at this time.)
Because yield() is called, it can be used in a narrow loop.


print

public boolean print(GPrintable gp,
                     double scale)
Print the graphics context to an attached printer with the given magnification scale factor. scale = 1 will print on standard A4 format paper. The given gp must implement the GPrintable interface, e.g. the single method void draw(), where all the drawing into the GPanel must occur. A standard printer dialog is shown before printing is started.
Return false, if printing is canceled in this dialog, return true, when print data is sent to the printer spooler. (On some platforms the Java Virtual Machine crashes when changing the printer in this dialog. Use the default printer)
Example:

import ch.aplu.util.*;

public class PrintEx extends GPanel implements GPrintable
{
  public PrintEx()
  {
    draw(); // Draw on screen
    print(this); // Draw on printer
  }

  public void draw()
  {
    move(0, 0);
    draw(1, 0);
    draw(1, 1);
    draw(0, 1);
    draw(0, 0);

    line(0, 1, 1, 0);
    line(0, 0, 1, 1);
  }

  public static void main(String[] args)
  {
    new PrintEx();
  }
}


print

public boolean print(GPrintable gp)
Same as print(GPrintable gp, double scale) with scale = 1.


printScreen

public boolean printScreen(double scale)
Print the current screen view to an attached printer with the given magnification scale factor. A standard printer dialog is shown before printing is started.
Return false, if printing is canceled in this dialog, return true, when print data is sent to the printer spooler.


printScreen

public boolean printScreen()
Same printScreen(double scale) with scale = 1.


bgColor

public java.awt.Color bgColor(java.awt.Color color)
Set the background color. All drawing are erased. Alpha channel is ignored. Return the previous color.


bgColor

public java.awt.Color bgColor(java.lang.String colorStr)
Set the background color using the given X11 color name. All drawing are erased. If the given name is not one of the predefined values, the color is not modified. Return the previous color.


getBgColor

public java.awt.Color getBgColor()
Return the current background color.


getBgColorStr

public java.lang.String getBgColorStr()
Return the current background X11 color name. The name is lowercase and has no blanks. Colors containing 'grey' are returned with 'gray'. The name is lowercase and has no blanks.


title

public void title(java.lang.String title)
Set the title in the window's title bar.


toUserX

public int toUserX(double windowX)
Return user coordinate x of given window coordinate x.


toUserY

public int toUserY(double windowY)
Return user coordinate y of given window coordinate y.


toUser

public java.awt.Point toUser(java.awt.geom.Point2D.Double windowPt)
Return reference to point in user coordinate of given point in window coordinate.


toUser

public java.awt.Point toUser(double windowX,
                             double windowY)
Return reference to point in user coordinate of given window coordinates.


toUserWidth

public int toUserWidth(double windowWidth)
Return user coordinates increment x of given window coordinates increment x. Increment is always positive.


toUserHeight

public int toUserHeight(double windowHeight)
Return user coordinates increment y of given window coordinates increment y. Increment is always positive.


toWindowX

public double toWindowX(int userX)
Return window coordinate x of given user coordinate x.


toWindowY

public double toWindowY(int userY)
Return window coordinate y of given user coordinate y.


toWindow

public java.awt.geom.Point2D.Double toWindow(java.awt.Point userPt)
Return reference to point in window coordinates of given point in user coordinates.


toWindow

public java.awt.geom.Point2D.Double toWindow(int userX,
                                             int userY)
Return reference to point in window coordinates of given user coordinates.


toWindowWidth

public double toWindowWidth(int userWidth)
Return window coordinates increment x of given user coordinates increment x. Increment is always positive.


toWindowHeight

public double toWindowHeight(int userHeight)
Return window coordinates increment y of given user coordinates increment y. Increment is always positive.


lineWidth

public void lineWidth(int width)
Set the current line width in pixels.


color

public java.awt.Color color(java.awt.Color color)
Same as setColor(Color color) (deprecated).


setColor

public java.awt.Color setColor(java.awt.Color color)
Set the given new color and return the previous color


color

public java.awt.Color color(java.lang.String colorStr)
Same as setColor(String colorStr) (deprecated).


setColor

public java.awt.Color setColor(java.lang.String colorStr)
Set the color to the given X11 color name. If the given name is not one of the predefined values, the color is not modified. Return the previous color.


line

public void line(double x1,
                 double y1,
                 double x2,
                 double y2)
Draw a line with given window coordinates and set the graph position to the endpoint.


line

public void line(java.awt.geom.Point2D.Double pt1,
                 java.awt.geom.Point2D.Double pt2)
Draw a line with given points (in window coordinates) and set the graph position to the endpoint.


draw

public void draw(double x,
                 double y)
Draw a line from current graph position to given window coordinates and set the graph position to the endpoint.


draw

public void draw(java.awt.geom.Point2D.Double pt)
Draw a line from current graph position to given point (in window coordinates) and set the graph position to the endpoint.


move

public void move(double x,
                 double y)
Set the current graph position to given window coordinates (without drawing anything).


move

public void move(int x,
                 int y)
Same as move(double x, double y). ( Override java.component.move(int x, int y) )


pos

public void pos(double x,
                double y)
Same as move(double x, double y).


move

public void move(java.awt.geom.Point2D.Double pt)
Set the current graph position to given point (in window coordinates) (without drawing anything).


pos

public void pos(java.awt.geom.Point2D.Double pt)
Same as move(Point2D.Double pt).


getPosX

public double getPosX()
Return window coordinate x of current graph position.


getPosY

public double getPosY()
Return window coordinate y of current graph position.


getPos

public java.awt.geom.Point2D.Double getPos()
Return reference to point of current graph position (in window coordinates).


clear

public void clear()
Clear the graphics window (fully paint with background color) (and the offscreen buffer used by the window). Set the current graph position to (0, 0).
If enableRepaint(false) only clear the offscreen buffer.


erase

public void erase()
Same as clear() but let the current graph position unchanged.


circle

public void circle(double radius)
Draw a circle with center at the current graph position and given radius in horizontal window coordinates. The graph position is unchanged.


fillCircle

public void fillCircle(double radius)
Draw a filled circle with center at the current graph position and given radius in window coordinates using the current color. The graph position is unchanged.


ellipse

public void ellipse(double a,
                    double b)
Draw an ellipse with center at the current graph position and given horizontal and vertical axes. The graph position is unchanged.


fillEllipse

public void fillEllipse(double a,
                        double b)
Draw a filled ellipse with center at the current graph position and given horizontal and vertical axes. The graph position is unchanged.


rectangle

public void rectangle(double width,
                      double height)
Draw a rectangle with center at the current graph position and given width and height in window coordinates. The graph position is unchanged.


rectangle

public void rectangle(double x1,
                      double y1,
                      double x2,
                      double y2)
Draw a rectangle with given opposite corners in window coordinates. The graph position is unchanged.


rectangle

public void rectangle(java.awt.geom.Point2D.Double pt1,
                      java.awt.geom.Point2D.Double pt2)
Draw a rectangle with given opposite corner points in window coordinates. The graph position is unchanged.


fillRectangle

public void fillRectangle(double width,
                          double height)
Draw a filled rectangle with center at the current graph position and given width and height in window coordinates using the current color. The graph position is unchanged.


fillRectangle

public void fillRectangle(double x1,
                          double y1,
                          double x2,
                          double y2)
Draw a filled rectangle with given opposite corners in window coordinates using the current color. The graph position is unchanged.


fillRectangle

public void fillRectangle(java.awt.geom.Point2D.Double pt1,
                          java.awt.geom.Point2D.Double pt2)
Draw a filled rectangle with given opposite corner points in window coordinates using the current color. The graph position is unchanged.


arc

public void arc(double radius,
                double startAngle,
                double extendAngle)
Draw an arc with center at the current graph position and given radius in window coordinates. Start angle and extend angle in degrees (zero to east, positive counterclockwise). The graph position is unchanged.


fillArc

public void fillArc(double radius,
                    int startAngle,
                    int extendAngle)
Draw a filled arc with center at the current graph position and given radius in window coordinates. Start angle and extend angle in degrees (zero to east, positive counterclockwise). The graph position is unchanged.


polygon

public void polygon(double[] x,
                    double[] y)
Draw a polygon with given corner coordinates in window coordinates. (Both arrays must be of equal size.) The graph position is unchanged.


polygon

public void polygon(java.awt.geom.Point2D.Double[] corner)
Draw a polygon with given corner points in window coordinates. The graph position is unchanged.


fillPolygon

public void fillPolygon(double[] x,
                        double[] y)
Draw a filled polygon with given corner coordinates in window coordinates using the current color. (Both arrays must be of equal size.) The graph position is unchanged.


fillPolygon

public void fillPolygon(java.awt.geom.Point2D.Double[] corner)
Draw a filled polygon with given corner points in window coordinates using the current color. The graph position is unchanged.


quadraticBezier

public void quadraticBezier(java.awt.geom.Point2D.Double pt1,
                            java.awt.geom.Point2D.Double ptc,
                            java.awt.geom.Point2D.Double pt2)
Draw a quadratic bezier curve. A quadratic bezier curve is a Bezier curve of degree 2 and is defined by 3 points: pt1, pt2, ptc (control point). The curve first endpoint is pt1, the second endpoint is pt2. The line ptc-pt1 is the tangent of the curve in point pt1. The line ptc-pt2 is the tangent of the curve in point pt2. The graph position is unchanged.


quadraticBezier

public void quadraticBezier(double x1,
                            double y1,
                            double xc,
                            double yc,
                            double x2,
                            double y2)
Draw a quadratic bezier curve. A quadratic bezier curve is a Bezier curve of degree 2 and is defined by 3 points: pt1, pt2, ptc (control point). The curve first endpoint is pt1, the second endpoint is pt2. The line ptc-pt1 is the tangent of the curve in point pt1. The line ptc-pt2 is the tangent of the curve in point pt2. The graph position is unchanged.


cubicBezier

public void cubicBezier(java.awt.geom.Point2D.Double pt1,
                        java.awt.geom.Point2D.Double ptc1,
                        java.awt.geom.Point2D.Double ptc2,
                        java.awt.geom.Point2D.Double pt2)
Draw a cubic bezier curve. A cubic bezier curve is a Bezier curve of degree 3 and is defined by 4 points: pt1, pt2, and the control points ptc1, ptc2. The curve first endpoint is pt1, the second endpoint is pt2. The line ptc1-pt1 is the tangent of the curve in point pt1. The line ptc2-pt2 is the tangent of the curve in point pt2. The graph position is unchanged.


cubicBezier

public void cubicBezier(double x1,
                        double y1,
                        double xc1,
                        double yc1,
                        double xc2,
                        double yc2,
                        double x2,
                        double y2)
Draw a cubic bezier curve. A cubic bezier curve is a Bezier curve of degree 3 and is defined by 4 points: pt1, pt2, and the control points ptc1, ptc2. The curve first endpoint is pt1, the second endpoint is pt2. The line ptc1-pt1 is the tangent of the curve in point pt1. The line ptc2-pt2 is the tangent of the curve in point pt2. The graph position is unchanged.


triangle

public void triangle(double x1,
                     double y1,
                     double x2,
                     double y2,
                     double x3,
                     double y3)
Draw a triangle with given corner coordinates in window coordinates. The graph position is unchanged.


triangle

public void triangle(java.awt.geom.Point2D.Double pt1,
                     java.awt.geom.Point2D.Double pt2,
                     java.awt.geom.Point2D.Double pt3)
Draw a triangle with given corners in window coordinates. The graph position is unchanged.


fillTriangle

public void fillTriangle(double x1,
                         double y1,
                         double x2,
                         double y2,
                         double x3,
                         double y3)
Draw a filled triangle with given corner coordinates in window coordinates using the current color. The graph position is unchanged.


fillTriangle

public void fillTriangle(java.awt.geom.Point2D.Double pt1,
                         java.awt.geom.Point2D.Double pt2,
                         java.awt.geom.Point2D.Double pt3)
Draw a filled triangle with given corners in window coordinates using the current color. The graph position is unchanged.


generalPath

public void generalPath(java.awt.geom.GeneralPath gp)
Draw a figure defined by the given GeneralPath (using window coordinates). The graph position is unchanged.


fillGeneralPath

public void fillGeneralPath(java.awt.geom.GeneralPath gp)
Fill a figure defined by the given GeneralPath (using window coordinates) using the current color. The graph position is unchanged.


text

public void text(java.lang.String str)
Draw a string at the current graph position. The graph position is unchanged.


text

public void text(char c)
Draw a char at the current graph position. The graph position is unchanged.


text

public void text(double x,
                 double y,
                 java.lang.String str)
Draw a string at the given position. The graph position is unchanged.


text

public void text(java.awt.geom.Point2D.Double pt,
                 java.lang.String str)
Draw a string at the given position. The graph position is unchanged.


text

public void text(double x,
                 double y,
                 char c)
Draw a char at the given position. The graph position is unchanged.


text

public void text(java.awt.geom.Point2D.Double pt,
                 char c)
Draw a char at the given position. The graph position is unchanged.


text

public void text(double x,
                 double y,
                 java.lang.String str,
                 java.awt.Font font,
                 java.awt.Color textColor,
                 java.awt.Color bgColor)
Draw a string at the given position with extended text attributes. The graph position is unchanged.


text

public void text(double x,
                 double y,
                 java.lang.String str,
                 java.awt.Font font,
                 java.lang.String textColorStr,
                 java.lang.String bgColorStr)
Draw a string at the given position with extended text attributes using X11 color names. The graph position is unchanged.


text

public void text(java.awt.geom.Point2D.Double pt,
                 java.lang.String str,
                 java.awt.Font font,
                 java.awt.Color textColor,
                 java.awt.Color bgColor)
Draw a string at the given position with extended text attributes. The graph position is unchanged.


text

public void text(java.awt.geom.Point2D.Double pt,
                 java.lang.String str,
                 java.awt.Font font,
                 java.lang.String textColorStr,
                 java.lang.String bgColorStr)
Draw a string at the given position with extended text attributes using X11 color names. The graph position is unchanged.


font

public void font(java.awt.Font font)
Select the given font for all following text operations.


point

public void point(double x,
                  double y)
Draw a single point at the given window coordinates. The graph position is set to the given point.


point

public void point(java.awt.geom.Point2D.Double pt)
Draw a single point at the given pt (in window coordinates). The graph position is set to the given point.


fill

public void fill(java.awt.geom.Point2D.Double pt,
                 java.awt.Color color,
                 java.awt.Color replacement)
Change the color of the bounded region with the given internal point to the replacement color using the flood fill algorithm.


fill

public void fill(java.awt.geom.Point2D.Double pt,
                 java.lang.String colorStr,
                 java.lang.String replacementStr)
Change the color of the bounded region with the given internal point to the replacement color using the flood fill algorithm.


fill

public void fill(double x,
                 double y,
                 java.awt.Color color,
                 java.awt.Color replacement)
Change the color of the bounded region with the given internal point to the replacement color using the flood fill algorithm.


fill

public void fill(double x,
                 double y,
                 java.lang.String colorStr,
                 java.lang.String replacementStr)
Change the color of the bounded region with the given internal point to the replacement color using the flood fill algorithm.


image

public boolean image(java.lang.String imagePath,
                     double x,
                     double y)
Show the GIF image from given file path at given window coordinates (specifies lowerleft corner of image).

From the given filename the image file is searched in the following order:
- if application is packed into a jar archive, relative to the root of the jar archive
- relative or absolute to current application directory
- if filename starts with http://, from the given URL
- add prefix _ and search relative to the root of the jar archive Return true if successful. If enableRepaint(false), the image is drawn in offscreen buffer only.


image

public boolean image(java.lang.String imagePath,
                     java.awt.geom.Point2D.Double pt)
Show the GIF image from given file path at given point(in window coordinates) (specifies lowerleft corner of image).

From the given imagePath the image file is searched in the following order:
- if application is packed into a jar archive, relative to the root of the jar archive
- relative to current application directory or absolute
- if imagePath starts with http://, from the given URL
- add prefix _ and search relative to the root of the jar archive Return true if successful. If enableRepaint(false), the image is drawn in offscreen buffer only.


image

public boolean image(java.awt.image.BufferedImage bi,
                     double x,
                     double y)
Show the GIF image from given BufferedImage at x, y window coordinates (specifies lowerleft corner of image). Return true if successful. If enableRepaint(false), the image is drawn in offscreen buffer only.


image

public boolean image(java.awt.image.BufferedImage bi,
                     java.awt.geom.Point2D.Double pt)
Show the GIF image from given BufferedImage at given point(in window coordinates) (specifies lowerleft corner of image). Return true if successful. If enableRepaint(false), the image is drawn in offscreen buffer only.


imageWidth

public double imageWidth(java.lang.String imagePath)
Return the width (horizontal size) of the GIF image from the given path (in window coordinates). Return 0, if GIF image is invalid.


imageHeight

public double imageHeight(java.lang.String imagePath)
Return the height (vertical size) of the GIF image from the given path (in window coordinates). Return 0, if GIF image is invalid.


applyTransform

public void applyTransform(java.awt.geom.AffineTransform at)
Apply the given AffineTransform to offscreen buffer.


enableRepaint

public boolean enableRepaint(boolean doRepaint)
Enable or disable the automatic repaint in graphics methods. Return the current state of repainting.
When automatic repaint is disabled, the method repaint() must be called to show the image on the screen.
Useful to avoid flickering while animating an image. If repainting is disabled clear() will only erase the offscreen buffer and not the screen. repaint() should be called after drawing the new situation in order to copy the offscreen buffer to the screen.
While printing, repainting is disabled.


setPaintMode

public void setPaintMode()
Set the paint mode of the graphics context to overwrite with current color.


setXORMode

public void setXORMode(java.awt.Color c)
Sets the paint mode to alternate between the current color and the given color. This specifies that logical pixel operations are performed in the XOR mode, which alternates pixels between the current color and a specified XOR color. When drawing operations are performed, pixels which are the current color are changed to the specified color, and vice versa. Pixels that are of colors other than those two colors are changed in an unpredictable but reversible manner; if the same figure is drawn twice, then all pixels are restored to their original values.


setXORMode

public void setXORMode(java.lang.String colorStr)
Same as setXORMode(Color c), but using the given X11 color name. If the given name is not one of the predefined values, the color is not modified.


windowPosition

public void windowPosition(int ulx,
                           int uly)
Set the window position (upper left corner in device coordinates).


windowCenter

public void windowCenter()
Set the window position to the center of the screen.


windowSize

public void windowSize(int width,
                       int height)
Set the size of the entire window (including title bar and borders) in device coordinates.
The window coordinates are unchanged.
Due to rescaling some graphics resolution is lost. To avoid this, use size parameters when instantiating the GPanel.


resizable

public void resizable(boolean b)
Enable/disable resizing of the window by mouse dragging.


getOffG2D

public java.awt.Graphics2D getOffG2D()
Return the Graphics2D context of the offscreen buffer


dispose

public void dispose()
Release all used system resources (offscreen buffer, graphics context) and unblock getKeyWait() and getKeyCodeWait() and waiting Monitor.putSleep(). After calling, don't use the GPanel instance anymore.


disableClose

public void disableClose(boolean b)
Disable/enable the title bar's closing button.
(Even a registered ExitListener will not be called.)


storeGraphics

public void storeGraphics()
Create a store buffer and copy current graphics to it.

See Also:
recallGraphics(), clearStore(java.awt.Color)

recallGraphics

public void recallGraphics()
Copy graphics from store buffer to offscreen buffer and render it on the screen window (if enableRepaint(true)).

See Also:
storeGraphics(), clearStore(java.awt.Color)

clearStore

public void clearStore(java.awt.Color color)
Clear store buffer by uniformly painting it with with given color.

See Also:
storeGraphics(), recallGraphics()

clearStore

public void clearStore(java.lang.String colorStr)
Clear store buffer by uniformly painting it with with the given X11 color name. If the given name is not one of the predefined values, nothing is done.

See Also:
storeGraphics(), recallGraphics()

getVersion

public static java.lang.String getVersion()
Return version information.


getAbout

public static java.lang.String getAbout()
Return copywrite information.


getPixelColor

public java.awt.Color getPixelColor(double x,
                                    double y)
Return the color of the pixel at given window coordinates.


getPixelColor

public java.awt.Color getPixelColor(java.awt.geom.Point2D.Double pt)
Return the color of the pixel at given point (in window coordinates).


getPixelColorStr

public java.lang.String getPixelColorStr(double x,
                                         double y)
Return the X11 color name of the pixel at given window coordinates. The name is lowercase and has no blanks. Colors containing 'grey' are returned with 'gray'.


getPixelColorStr

public java.lang.String getPixelColorStr(java.awt.geom.Point2D.Double pt)
Return the X11 color name of the pixel at given point (in window coordinates). The name is lowercase and has no blanks. Colors containing 'grey' are returned with 'gray'.


setFocusable

public void setFocusable(boolean focusable)
Set the focusable state to the specified value.


repaint

public void repaint()
Invoke the internal JPanels repaint().


addMouseListener

public void addMouseListener(java.awt.event.MouseListener listener)
Invoke the internal JPanels addMouseListener().


addMouseMotionListener

public void addMouseMotionListener(java.awt.event.MouseMotionListener listener)
Invoke the internal JPanels addMouseMotionListener().


addMouseWheelListener

public void addMouseWheelListener(java.awt.event.MouseWheelListener listener)
Invoke the internal JPanels addMouseWheelListener().


kbhit

public boolean kbhit()
Return true, if a key was typed since the last call of getKey(), getKeyWait(), getKeyCode(), getKeyCodeWait(). The one-character buffer is not changed. Put the current thread to sleep for 1 ms, to improve response time when used in a loop.


getKey

public char getKey()
Return the unicode character associated with last key typed. The one-character buffer is cleared. Return KeyEvent.CHAR_UNDEFINED if the buffer is empty.


getKeyCode

public int getKeyCode()
Return the keycode associated with last key pressed. The one-character buffer is cleared. Return (int)KeyEvent.CHAR_UNDEFINED, if the buffer is empty.


getKeyWait

public char getKeyWait()
Wait until a key is typed and return the unicode character associated with it. Unblocked and returning KeyEvent.CHAR_UNDEFINED by calling dispose() (unless in mode RELEASE_ON_CLOSE).


getKeyCodeWait

public int getKeyCodeWait()
Wait until a key is typed and return the keycode associated with last key pressed. Unblocked and returning KeyEvent.VK_UNDEFINED by calling dispose() (unless in mode RELEASE_ON_CLOSE).


getModifiers

public int getModifiers()
Return the modifiers associated with last key pressed.


getModifiersText

public java.lang.String getModifiersText()
Return the modifiers text description associated with last key pressed.


addComponent

public void addComponent(java.awt.Component comp)
Append the specified component to the container.


add

public void add(java.awt.Component comp)
Same as addComponent() (deprecated).


validate

public void validate()
Validate the container.


getPane

public GPane getPane()
Return the GPane container that holds the graphics.


_delay

public void _delay(int time)
Non-static version of delay(). Checks if GPanel is disposed and throws RuntimeException.


delay

public static void delay(int time)
Delay execution for the given amount of time ( in ms ).


addStatusBar

public void addStatusBar(int height)
Add a status window attached at the bottom of the GPanel window. The dialog has no decoration, the same width as the GPanel and the given height in pixels. If the GPanel is full screen or EMBEDDED, no status bar is attached.


setStatusText

public void setStatusText(java.lang.String text)
Replace the text in the status bar by the given text using the current JOptionPane font and color. The text is left-justified, vertical-centered and may be multi-line. If there is no status bar, nothing happens.


setStatusText

public void setStatusText(java.lang.String text,
                          java.awt.Font font,
                          java.awt.Color color)
Replace the text in the status bar by the given text using the given font and text color. The text is left-justified, vertical-centered and may be multi-line. If there is no status bar, nothing happens.


showStatusBar

public void showStatusBar(boolean show)
Show or hide the status bar. If there is no status bar, nothing happens.


toColor

public static java.awt.Color toColor(java.lang.String colorStr)
Return the Color reference for the given color as string. The X11 color names are supported.

Returns:
the Color reference or null, if the given color is not one of the predefined values

isDisposed

public boolean isDisposed()
Return true, if the window was disposed or released.


setEnableResize

public void setEnableResize(boolean enable)
Enable/disable resizing.


getImage

public static GBitmap getImage(java.lang.String imagePath)
Retrieve the image either from the jar resource, from local drive or from a internet server.

From the given imagePath the image file is searched in the following order:
- if application is packed into a jar archive, relative to the root of the jar archive
- relative to current application directory or absolute
- if imagePath starts with http://, from the given URL
- add prefix _ and search relative to the root of the jar archive

Parameters:
imagePath - the file name or url
Returns:
the buffered image or null, if the image search fails

getDividingPoint

public static java.awt.geom.Point2D.Double getDividingPoint(java.awt.geom.Point2D.Double pt1,
                                                            java.awt.geom.Point2D.Double pt2,
                                                            double ratio)
Returns the point on the line through the point pt1 and the point pt2 that is in distance ratio times the length from pt1 to pt2 from pt1. For ratio < 0 the point is in the opposite direction.

Parameters:
pt1 - the start point of the line section
pt2 - the end point of the line section
ratio - the distance ratio (any negative or positive double value)
Returns:
the dividing point

setClosingMode

public void setClosingMode(GPanel.ClosingMode mode)
Determines what happens when the title bar close button is hit. Values: On of the enums in ClosingMode:
TerminateOnClose -> Terminating and shutting down JRE by System.exit(0)
ClearOnClose -> Clears the graphics content
AskOnClose -> Shows confirmation dialog asking for termination
DisposeOnClose -> Closes the graphics window, but does not shutdown JRE
ReleaseOnClose -> Like DisposeOnClose, but throws runtime exception when graphics methods are called
NothingOnClose -> Does nothing
Default value: TerminateOnClose or value read from aplu_utils.properties