|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container java.awt.Window java.awt.Frame javax.swing.JFrame ch.aplu.util.GWindow
public class GWindow
Simple screen window with an event handler to exit the application when
clicking the close button in the title bar.
The exit handler will call the dispose method for the graphic context
in order to release system resources automatically.
Defaut background is white, default drawing color is black.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.BaselineResizeBehavior |
Field Summary |
---|
Fields inherited from class javax.swing.JFrame |
---|
EXIT_ON_CLOSE |
Fields inherited from class java.awt.Frame |
---|
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface javax.swing.WindowConstants |
---|
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
GWindow()
Construct a GWindow with default title and size. |
|
GWindow(Position position,
Size size,
boolean noTitlebar)
Same as GWindow(), but titlebar may be omited. |
|
GWindow(java.lang.String title)
Same as GWindow() with given title. |
|
GWindow(java.lang.String title,
Position position,
Size size)
Same as GWindow() with given title, position and size of client window. |
|
GWindow(java.lang.String title,
Size size)
Same as GWindow() with given title and size of client window. |
Method Summary | |
---|---|
void |
addExitListener(ExitListener exitListener)
Register an ExitListener to get a notification when the close button is clicked. |
void |
adjust()
Actualize the conversion between window und user coordinates according to the current component size. |
void |
clear()
Clear the screen graphics (without calling repaint). |
void |
clearBuf()
Clear the graphics offline buffer (without calling repaint). |
void |
clearStore(java.awt.Color color)
Clear store buffer by uniformly painting it with given color. |
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 |
drawImage(java.awt.image.BufferedImage bi,
int x,
int y,
boolean lowerLeft)
Draw the given BufferedImage into offscreen buffer at (x, y) coordinates of upper left corner. |
java.lang.String |
getAbout()
Return copywrite information. |
java.awt.geom.AffineTransform |
getAffineScale()
Perform scaling of the offscreen buffer to fit the image to the current window dimension. |
java.awt.Color |
getBgColor()
Return the current background color. |
int |
getBottomInset()
Return the bottom inset of the window (border width) in pixels. |
java.awt.image.BufferedImage |
getBufferedImage()
Return a reference to the offscreen buffer created by GWindow's constructor. |
int |
getCurrentHeight()
Return the height of the client area in user coordinates. |
int |
getCurrentWidth()
Return the width of the client area in user coordinates. |
static java.lang.String[] |
getDesktopProperties()
Return the property names of available system properties. |
int |
getLeftInset()
Return the left inset of the window (border width) in pixels. |
java.awt.Graphics2D |
getOffG2D()
Return the Graphics2D context of the offscreen buffer created by GWindow's constructor. |
java.awt.Color |
getPixelColor(double x,
double y)
Return the color of the screen pixel at given location. |
int |
getPopupHeight()
Return the height of the window in user coordinates when it was created. |
int |
getPopupWidth()
Return the width of the window in user coordinates when it was created. |
int |
getRightInset()
Return the right inset of the window (border width) in pixels. |
double |
getScaleX()
Return the current magnification factor of horizontal window size. |
double |
getScaleY()
Return the current magnification factor of vertical window size. |
static int |
getScreenHeight()
Get the height of the screen (in pixels). |
static int |
getScreenWidth()
Get the width of the screen (in pixels). |
java.lang.String |
getVersion()
Return version information. |
boolean |
isDisposed()
Return true, if the window was disposed or released. |
static Position |
position(int ulx,
int uly)
Return a Position ref with specified upperleft x and y coordinates. |
void |
recallGraphics()
Copy the store buffer to the offscreen buffer. |
java.awt.Color |
setBgColor(java.awt.Color color)
Set the background color of the window and offscreen buffer and show the window. |
void |
setOffG2D(java.awt.Graphics2D g2D)
Set the Graphics2D context of the offscreen buffer. |
void |
setTitle(java.lang.String title)
Set the title in the window's title bar. |
void |
setWinCenter()
Set window to screen center. |
void |
setWinCenter(Size size)
Set window to screen center with given size of the embedded component. |
void |
setWindow(double xmin,
double xmax,
double ymin,
double ymax)
Set window coordinate system left_x, right_x, bottom_y, top_y |
void |
setWinPosition(int ulx,
int uly)
Set the position of the window (x-y-coordinates of upper left corner in device coordinates). |
void |
setWinPosition(Position position)
Set the position of the window (position of uppler left corner in device coordinates). |
void |
setWinSize(int width,
int height)
Set the size of the embedded component (in device coordinates) to given width and heigth. |
void |
setWinSize(Size size)
Set the size of the embedded component (in device coordinates). |
void |
showComponent(javax.swing.JComponent component)
Add the component to the frame's contentPane and show the window with default background color. |
void |
showComponent(javax.swing.JComponent component,
boolean visible)
Same as showComponent(JComponent component) but set visibilty to the given value. |
void |
showComponent(javax.swing.JComponent component,
java.awt.Color bgColor)
Add a component to the frame's contentPane and show the window with the given background color. |
void |
showComponent(javax.swing.JComponent component,
java.awt.Color bgColor,
boolean visible)
Same as showComponent(JComponent component, Color bgColor) but set visibilty to the given value. |
static Size |
size(int width,
int height)
Return a Size ref with specified width and height. |
void |
storeGraphics()
Copy the offscreen buffer to a store buffer. |
int |
topLeftInset()
Return the top inset of the window (title bar + border) in pixels. |
java.awt.Shape |
toUser(java.awt.Shape shape)
Convert the given shape from window coordinates to user coordinates. |
int |
toUserHeight(double windowHeight)
Convert window coordinates increment to user coordinates increment (vertical). |
java.awt.geom.AffineTransform |
toUserTransform()
Create an affine transform to convert a shape from window coordinates to user coordinates and return it. |
int |
toUserWidth(double windowWidth)
Convert window coordinates increment to user coordinates increment (horizontal). |
int |
toUserY(double windowY)
Convert window coordinate to user coordinate (vertical). |
double |
toWindowHeight(int userHeight)
Convert user coordinates increment to window coordinates increment (vertical). |
double |
toWindowWidth(int userWidth)
Convert user coordinates increment to window coordinates increment (horizontal). |
double |
toWindowX(int userX)
Convert user coordinates to window coordinates (horizontal). |
double |
toWindowY(int userY)
Convert user coordinates to window coordinates (vertical). |
void |
transformGraphics(java.awt.geom.AffineTransform at)
Transform offscreen buffer with given affine transformation. |
Methods inherited from class javax.swing.JFrame |
---|
getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setTransferHandler, update |
Methods inherited from class java.awt.Frame |
---|
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setUndecorated |
Methods inherited from class java.awt.Window |
---|
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, paint, postEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, show, toBack, toFront |
Methods inherited from class java.awt.Container |
---|
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate |
Methods inherited from class java.awt.Component |
---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.awt.MenuContainer |
---|
getFont, postEvent |
Constructor Detail |
---|
public GWindow()
public GWindow(java.lang.String title)
public GWindow(java.lang.String title, Size size)
public GWindow(java.lang.String title, Position position, Size size)
public GWindow(Position position, Size size, boolean noTitlebar)
Method Detail |
---|
public void addExitListener(ExitListener exitListener)
public static Position position(int ulx, int uly)
new
public static Size size(int width, int height)
public static int getScreenWidth()
public static int getScreenHeight()
public java.awt.Color setBgColor(java.awt.Color color)
public java.awt.Color getBgColor()
public void setWinPosition(Position position)
public void setWinPosition(int ulx, int uly)
public void setWinSize(Size size)
public void setWinSize(int width, int height)
public void setWinCenter(Size size)
public void setWinCenter()
public void showComponent(javax.swing.JComponent component)
public void showComponent(javax.swing.JComponent component, boolean visible)
public void showComponent(javax.swing.JComponent component, java.awt.Color bgColor)
public void showComponent(javax.swing.JComponent component, java.awt.Color bgColor, boolean visible)
public java.awt.image.BufferedImage getBufferedImage()
public java.awt.Graphics2D getOffG2D()
public void setOffG2D(java.awt.Graphics2D g2D)
public int getCurrentWidth()
public int getCurrentHeight()
public int getLeftInset()
public int getRightInset()
public int topLeftInset()
public int getBottomInset()
public double getScaleX()
public double getScaleY()
public int getPopupWidth()
public int getPopupHeight()
public java.awt.geom.AffineTransform getAffineScale()
public void setTitle(java.lang.String title)
setTitle
in class java.awt.Frame
public int toUserY(double windowY)
public int toUserWidth(double windowWidth)
public int toUserHeight(double windowHeight)
public double toWindowX(int userX)
public double toWindowY(int userY)
public double toWindowWidth(int userWidth)
public double toWindowHeight(int userHeight)
public void setWindow(double xmin, double xmax, double ymin, double ymax)
public java.awt.Shape toUser(java.awt.Shape shape)
public java.awt.geom.AffineTransform toUserTransform()
public java.lang.String getVersion()
public java.lang.String getAbout()
public void adjust()
public static void delay(int time)
public void clearBuf()
public void clear()
public static java.lang.String[] getDesktopProperties()
public void disableClose(boolean b)
public void storeGraphics()
public void recallGraphics()
public void clearStore(java.awt.Color color)
public void transformGraphics(java.awt.geom.AffineTransform at)
public java.awt.Color getPixelColor(double x, double y)
public boolean isDisposed()
public void drawImage(java.awt.image.BufferedImage bi, int x, int y, boolean lowerLeft)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |