|
|||||||||
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
Class to define a simple screen window
with an event handler to exit the application when
clicking the close button in the title bar.
Subclass of JFrame.
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
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, width and height of the embedded component and show the window Default width: 500 pixels Default height: 500 pixels |
|
GWindow(java.lang.String title)
Construct a GWindow with given title and show the window |
|
GWindow(java.lang.String title,
Position position,
Size size)
Construct a GWindow with given title, size of the embedded component, position and show the window. |
|
GWindow(java.lang.String title,
Size size)
Construct a GWindow with given title and size of the embedded component and show the 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 |
componentHidden(java.awt.event.ComponentEvent e)
For internal use |
void |
componentMoved(java.awt.event.ComponentEvent e)
For internal use |
void |
componentResized(java.awt.event.ComponentEvent e)
For internal use |
void |
componentShown(java.awt.event.ComponentEvent e)
For internal use |
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(int x,
int y,
boolean lowerLeft)
Draw the last loaded image into offscreen buffer (x, y) coordindates of 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. |
java.awt.image.BufferedImage |
getBufferedImage()
Return a reference to the offscreen buffer created by GWindow's constructor |
int |
getCurrentHeight()
Return the current height of the window in user coordinates |
int |
getCurrentWidth()
Return the current width of the window in user coordinates |
static java.lang.String[] |
getDesktopProperties()
Return the property names of available system properties. |
int |
getImageHeight()
Return the height (vertical size) of the last loaded GIF or JPEG image (in device coordinates). |
int |
getImageHeight(java.awt.Image image)
Return the height (vertical size) of the given GIF or JPEG image (in device coordinates). |
int |
getImageHeight(java.lang.String imagePath)
Return the height (vertical size) of the GIF or JPEG image from the given path (in device coordinates). |
int |
getImageHeight(java.net.URL imageUrl)
Return the height (vertical size) of the GIF or JPEG image from the given URL (in device coordinates). |
int |
getImageWidth()
Return the width (horizontal size) of the last loaded GIF or JPEG image (in device coordinates). |
int |
getImageWidth(java.awt.Image image)
Return the width (horizontal size) of the given GIF or JPEG image (in device coordinates). |
int |
getImageWidth(java.lang.String imagePath)
Return the width (horizontal size) of the GIF or JPEG image from the given path (in device coordinates). |
int |
getImageWidth(java.net.URL imageUrl)
Return the width (horizontal size) of the GIF or JPEG image from the given URL (in device coordinates). |
java.awt.Graphics2D |
getOffG2D()
Return the Graphics2D context of the offscreen buffer created by GWindow's constructor |
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 |
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 |
loadImage(java.awt.Image image)
Load the given GIF or JPEG image and set the current image's width and height. |
static Position |
position(int ulx,
int uly)
Return a Position ref with specified upperleft x and y coordinates May be used in constructor to avoid the keyword new |
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)
|
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 (in device coordinates) |
void |
setWinPosition(Position position)
Set the position of the window (in device coordinates) |
void |
setWinSize(int width,
int height)
Set the size of the embedded component (in device coordinates) (User coordinates 0..width-1, 0..height-1, origin at uppler left corner) |
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 May be used in constructor to avoid the keyword new |
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) Increment is always positive |
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) Increment is always positive |
int |
toUserX(double windowX)
Convert window coordinate to user coordinate (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) Increment is always positive |
double |
toWindowWidth(int userWidth)
Convert user coordinates increment to window coordinates increment (horizontal) Increment is always positive |
double |
toWindowX(int userX)
Convert user coordinates to window coordinates (horizontal) |
double |
toWindowY(int userY)
Convert user coordinates to window coordinates (vertical) |
Methods inherited from class javax.swing.JFrame |
getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, update |
Methods inherited from class java.awt.Frame |
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setIconImage, 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, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isFocusableWindow, isFocusCycleRoot, isFocused, isShowing, pack, postEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationRelativeTo, 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, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, remove, removeAll, removeContainerListener, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, 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, isOpaque, 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, repaint, requestFocus, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, 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)
size
- a ref to a Size object (width, height)(User coordinates 0..width-1, 0..height-1, origin at uppler left corner)
public GWindow(java.lang.String title, Position position, Size size)
position
- a ref to a Position objectsize
- a ref to a Size object (width, height)Position
,
(User coordinates 0..width-1, 0..height-1, origin at upper left corner)
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)
position
- a ref to a Position object (upper left corner)Position
public void setWinPosition(int ulx, int uly)
ulx
- x-coordinate of upper left corneruly
- y-coordinate of upper left cornerpublic void setWinSize(Size size)
size
- a ref to a Size object (width, height)(User coordinates 0..width-1, 0..height-1, origin at uppler left corner)
public void setWinSize(int width, int height)
public void setWinCenter(Size size)
size
- a ref to a Size object (width, height)(User coordinates 0..width-1, 0..height-1, origin at uppler left corner)
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 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 toUserX(double windowX)
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 void componentHidden(java.awt.event.ComponentEvent e)
componentHidden
in interface java.awt.event.ComponentListener
public void componentMoved(java.awt.event.ComponentEvent e)
componentMoved
in interface java.awt.event.ComponentListener
public void componentResized(java.awt.event.ComponentEvent e)
componentResized
in interface java.awt.event.ComponentListener
public void componentShown(java.awt.event.ComponentEvent e)
componentShown
in interface java.awt.event.ComponentListener
public static void delay(int time)
public void clearBuf()
public void clear()
public boolean loadImage(java.awt.Image image)
public void drawImage(int x, int y, boolean lowerLeft)
public int getImageWidth(java.lang.String imagePath)
public int getImageWidth(java.net.URL imageUrl)
public int getImageWidth(java.awt.Image image)
public int getImageHeight(java.lang.String imagePath)
public int getImageHeight(java.net.URL imageUrl)
public int getImageHeight(java.awt.Image image)
public int getImageWidth()
public int getImageHeight()
public static java.lang.String[] getDesktopProperties()
public void disableClose(boolean b)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |