|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.openbp.swing.SwingUtil
public class SwingUtil
This class contains various static utility methods.
| Field Summary | |
|---|---|
static int |
BOTTOM
Flag for drawMultilineString(Graphics, String, int, Rectangle, boolean): Indicates that the text should be displayed at the bottom of the drawing area . |
static int |
CENTER
Flag for drawMultilineString(Graphics, String, int, Rectangle, boolean): Indicates that the text should be centered. |
static int |
LEFT
Flag for drawMultilineString(Graphics, String, int, Rectangle, boolean): Indicates that the text should be left justified. |
static int |
MIDDLE
Flag for drawMultilineString(Graphics, String, int, Rectangle, boolean): Indicates that the text should be displayed at the middle of the drawing area . |
static java.lang.String |
RESOURCE_COMMON
Name of the resource component for general client resources |
static int |
RIGHT
Flag for drawMultilineString(Graphics, String, int, Rectangle, boolean): Indicates that the text should be right justified. |
static int |
TOP
Flag for drawMultilineString(Graphics, String, int, Rectangle, boolean): Indicates that the text should be displayed at the top of the drawing area . |
| Method Summary | |
|---|---|
static int |
applyScale(int coordinate,
boolean scaleToDoc,
Scalable view)
Applies the current scale factor of the view to a coordinate. |
static java.awt.Point |
applyScale(java.awt.Point p,
boolean scaleToDoc,
Scalable view)
Applies the current scale factor of the view to a point. |
static java.awt.Rectangle |
applyScale(java.awt.Rectangle r,
boolean scaleToDoc,
Scalable view)
Applies the current scale factor of the view to a rectangle. |
static void |
computeMultilineStringBounds(java.awt.FontMetrics fm,
java.lang.String s,
int alignment,
java.awt.Rectangle r)
Calculates the dimensions of the text. |
static boolean |
containsListener(javax.swing.event.EventListenerList listenerList,
java.lang.Class type,
java.util.EventListener listener)
Checks if the specified listener is already registered as listener of the specified type in a listener list. |
static java.awt.Rectangle |
convertBoundsToGlassCoords(java.awt.Component comp)
Converts the given, component local rectangle into coordinates relative to an objects glassPane. |
static java.awt.Point |
convertFromGlassCoords(java.awt.Point p,
java.awt.Component comp)
Converts the given, component local coordinates into coordinates relative to an objects glassPane. |
static java.awt.Rectangle |
convertRectToGlassCoords(java.awt.Rectangle r,
java.awt.Component comp)
Converts the component local rectangle into coordinates relative to an objects glassPane. |
static java.awt.Point |
convertToGlassCoords(java.awt.Point p,
java.awt.Component comp)
Converts the given, component local coordinates into coordinates relative to an objects glassPane. |
static void |
drawMultilineString(java.awt.Graphics g,
java.lang.String s,
int alignment,
java.awt.Rectangle r,
boolean print)
Draws a multi line text and/or calculates the dimensions of the text when drawn into the given Graphics object. |
static void |
drawString(java.awt.Graphics g,
java.lang.String s,
int alignment,
java.awt.Rectangle r)
Draws a string into a Graphics object. |
static boolean |
focusComponent(java.awt.Component comp)
Tries to focus the given component. |
static void |
forceMouseMove(java.awt.Point pos)
Forces a mouse movement by 1 pixel to the right and back that will generate mouse movement events. |
static java.awt.Dialog |
getDialog(java.awt.Component c)
Gets the dialog that contains the given component. |
static java.awt.Component |
getGlassPane(java.awt.Component comp)
Returns the GlassPane that belongs to a given Component. |
static javax.swing.RootPaneContainer |
getRootPaneContainer(java.awt.Component c)
Gets the root pane container of a component. |
static javax.swing.JScrollPane |
getScrollPaneAncestor(java.awt.Component c)
Gets the scroll pane that wraps a given component. |
static void |
inflateRectangle(java.awt.Rectangle r,
int x,
int y)
Inflates the rectangle by the specified x/y value. |
static void |
processPendingEvents()
Processes any events pending in the event queue. |
static void |
show(javax.swing.JDialog dlg)
Shows a modal dialog. |
static void |
show(javax.swing.JFrame frame)
Shows a frame. |
static void |
show(javax.swing.JWindow window)
Shows a window. |
static void |
startApplication(java.awt.Window mainWindow,
boolean provideExitHandler)
Displays the main frame of an application in the center of the screen. |
static void |
waitCursorOff(java.awt.Component comp)
Turns the waits cursor off. |
static void |
waitCursorOn(java.awt.Component comp)
Turns the waits cursor on. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String RESOURCE_COMMON
public static final int LEFT
drawMultilineString(Graphics, String, int, Rectangle, boolean): Indicates that the text should be left justified.
public static final int CENTER
drawMultilineString(Graphics, String, int, Rectangle, boolean): Indicates that the text should be centered.
public static final int RIGHT
drawMultilineString(Graphics, String, int, Rectangle, boolean): Indicates that the text should be right justified.
public static final int TOP
drawMultilineString(Graphics, String, int, Rectangle, boolean): Indicates that the text should be displayed at the top of the drawing area .
public static final int MIDDLE
drawMultilineString(Graphics, String, int, Rectangle, boolean): Indicates that the text should be displayed at the middle of the drawing area .
public static final int BOTTOM
drawMultilineString(Graphics, String, int, Rectangle, boolean): Indicates that the text should be displayed at the bottom of the drawing area .
| Method Detail |
|---|
public static void startApplication(java.awt.Window mainWindow,
boolean provideExitHandler)
mainWindow - Main application window (usually a JFrame or JDialog)provideExitHandler - true Automatically provides a WindowClosing handler that exits the application.public static void processPendingEvents()
public static boolean focusComponent(java.awt.Component comp)
comp - The component to receive the focus
public static java.awt.Point convertToGlassCoords(java.awt.Point p,
java.awt.Component comp)
p - Coordinates to convert or null for (0/0)comp - Component the coordinates are relative to
public static java.awt.Point convertFromGlassCoords(java.awt.Point p,
java.awt.Component comp)
p - Coordinates to convert or null for (0/0)comp - Component the coordinates should be relative to
public static java.awt.Rectangle convertRectToGlassCoords(java.awt.Rectangle r,
java.awt.Component comp)
r - Coordinates to convertcomp - Component the coordinates are relative to
public static java.awt.Rectangle convertBoundsToGlassCoords(java.awt.Component comp)
comp - Component
public static java.awt.Component getGlassPane(java.awt.Component comp)
comp - Component
public static java.awt.Rectangle applyScale(java.awt.Rectangle r,
boolean scaleToDoc,
Scalable view)
r - rectangle to be scaledscaleToDoc - true Assumes that the coordinates are component coordinates that should be translated to document coordinates.
false Assumes that the coordinates are document coordinates that should be translated to component coordinates.view - Scalable view that provides the scaling factor
public static java.awt.Point applyScale(java.awt.Point p,
boolean scaleToDoc,
Scalable view)
p - Point to be scaledscaleToDoc - true Assumes that the coordinates are component coordinates that should be translated to document coordinates.
false Assumes that the coordinates are document coordinates that should be translated to component coordinates.view - Scalable view that provides the scaling factor
public static int applyScale(int coordinate,
boolean scaleToDoc,
Scalable view)
coordinate - X or Y coordinate to be scaledscaleToDoc - true Assumes that the coordinates are component coordinates that should be translated to document coordinates.
false Assumes that the coordinates are document coordinates that should be translated to component coordinates.view - Scalable view that provides the scaling factor
public static void waitCursorOn(java.awt.Component comp)
waitCursorOff(java.awt.Component). Subsequent calls of waitCursorOn do not
overwrite the saved state, waitCursorOff will reset the glass pane to the first
saved state.
comp - Component that can be used to determine the glass panepublic static void waitCursorOff(java.awt.Component comp)
waitCursorOn(java.awt.Component).
If there is not information present about the previous state of the glass pane
(i. e. because waitCursorOff has already been called), the method will do nothing.
comp - Component that can be used to determine the glass panepublic static void forceMouseMove(java.awt.Point pos)
pos - Current mouse positon in screen coordinates
public static boolean containsListener(javax.swing.event.EventListenerList listenerList,
java.lang.Class type,
java.util.EventListener listener)
listenerList - Listener list to searchtype - Type of the listener to be addedlistener - Listener to be added
public static void drawMultilineString(java.awt.Graphics g,
java.lang.String s,
int alignment,
java.awt.Rectangle r,
boolean print)
g - Graphics context to paint intos - Text to drawalignment - Text alignment (LEFT/CENTER/RIGHT | TOP/MIDDLE/BOTTOM)r - Rectangle containing the drawing regionprint - true Draws the text
public static void computeMultilineStringBounds(java.awt.FontMetrics fm,
java.lang.String s,
int alignment,
java.awt.Rectangle r)
fm - Font metrics of the current fonts - Text to drawalignment - Text alignment (LEFT/CENTER/RIGHT | TOP/MIDDLE/BOTTOM)r - Rectangle containing the drawing region
The method writes the width of the longest line back into r.width.
public static void drawString(java.awt.Graphics g,
java.lang.String s,
int alignment,
java.awt.Rectangle r)
g - Graphics context to paint intos - Text to drawalignment - Text alignment (LEFT/CENTER/RIGHT)r - Bounding rectangle (width has to be greater 0 when the alignment is CENTER or RIGHT)public static void show(javax.swing.JDialog dlg)
dlg - Dialog to displaypublic static void show(javax.swing.JFrame frame)
frame - Dialog to displaypublic static void show(javax.swing.JWindow window)
window - Dialog to displaypublic static javax.swing.RootPaneContainer getRootPaneContainer(java.awt.Component c)
c - The component
public static javax.swing.JScrollPane getScrollPaneAncestor(java.awt.Component c)
c - Given component
public static java.awt.Dialog getDialog(java.awt.Component c)
c - The component
public static void inflateRectangle(java.awt.Rectangle r,
int x,
int y)
r - Rectangle to enlargex - Horizontal value; if negative, the rectangle will be deflatedy - Vertical value; if negative, the rectangle will be deflated
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||