maspack.widgets
Class GuiUtilities

java.lang.Object
  extended by maspack.widgets.GuiUtilities

public class GuiUtilities
extends java.lang.Object


Field Summary
static int ABOVE
          Place one component above another.
static int BELOW
          Place one component below another.
static int BOTTOM_EDGES
          Align bottom edges.
static int CENTER
          Align centers.
static int LEFT
          Place one component completely to the left of another.
static int LEFT_EDGES
          Align left edges.
static int RIGHT
          Place one component completely to the right of another.
static int RIGHT_EDGES
          Align right edges.
static int TOP_EDGES
          Align top edges.
 
Method Summary
static boolean containsComponent(java.awt.Container parent, java.awt.Component comp)
           
static boolean containsMenuComponent(javax.swing.JMenu parent, java.awt.Component comp)
           
static java.awt.Component createBoxFiller()
           
static javax.swing.JMenuItem createMenuItem(java.awt.event.ActionListener listener, java.lang.String cmd, java.lang.String toolTip)
           
static javax.swing.border.TitledBorder createTitledPanelBorder(java.lang.String title)
           
static java.awt.Rectangle getScreenBounds(java.awt.Component ref)
          Gets the current screen bounds of a component.
static java.awt.Point getScreenLocation(java.awt.Component ref, double xr, double yr)
          Gets the current screen location of a specified point within a reference component.
static java.awt.Rectangle getVirtualScreenBounds()
           
static int indexOfComponent(java.awt.Container parent, java.awt.Component comp)
           
static int indexOfMenuComponent(javax.swing.JMenu parent, java.awt.Component comp)
           
static javax.swing.ImageIcon loadIcon(java.lang.Object ref, java.lang.String path)
           
static void locateAbove(java.awt.Window win, java.awt.Component ref)
          Locates a window above the window containing a specified reference component.
static void locateBelow(java.awt.Window win, java.awt.Component ref)
          Locates a window below the window containing a specified reference component.
static void locateCenter(java.awt.Window win, java.awt.Component ref)
          Center a window on the window containing a specified reference component.
static void locateHorizontally(java.awt.Window win, java.awt.Component ref, int location)
          Sets the horizonal position of a window relative to another component.
static void locateLeft(java.awt.Window win, java.awt.Component ref)
          Locates a window to the left of the window containing a specified reference component.
static void locateRelative(java.awt.Window win, java.awt.Rectangle bounds, double px, double py, double wx, double wy)
          Locates a window relative to a given set of screen bounds.
static void locateRight(java.awt.Window win, java.awt.Component ref)
          Locates a window to the right of the window containing a specified reference component.
static void locateVertically(java.awt.Window win, java.awt.Component ref, int location)
          Sets the vertical position of a window relative to another component.
static void repackComponentWindow(java.awt.Component c)
           
static void setFixedHeight(java.awt.Component comp, int h)
          Sets the height of a component to a rigidly fixed value
static void setFixedSize(java.awt.Component comp, java.awt.Dimension size)
          Sets the size of a component to be a rigidly fixed as we possibly can.
static void setFixedSize(java.awt.Component comp, int w, int h)
          Sets the size of a component to be a rigidly fixed as we possibly can.
static void setFixedWidth(java.awt.Component comp, int w)
          Sets the width of a component to a rigidly fixed value
static void setItalicFont(javax.swing.JComponent jcomp)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CENTER

public static final int CENTER
Align centers.

See Also:
Constant Field Values

LEFT_EDGES

public static final int LEFT_EDGES
Align left edges.

See Also:
Constant Field Values

RIGHT_EDGES

public static final int RIGHT_EDGES
Align right edges.

See Also:
Constant Field Values

LEFT

public static final int LEFT
Place one component completely to the left of another.

See Also:
Constant Field Values

RIGHT

public static final int RIGHT
Place one component completely to the right of another.

See Also:
Constant Field Values

TOP_EDGES

public static final int TOP_EDGES
Align top edges.

See Also:
Constant Field Values

BOTTOM_EDGES

public static final int BOTTOM_EDGES
Align bottom edges.

See Also:
Constant Field Values

ABOVE

public static final int ABOVE
Place one component above another.

See Also:
Constant Field Values

BELOW

public static final int BELOW
Place one component below another.

See Also:
Constant Field Values
Method Detail

setFixedSize

public static void setFixedSize(java.awt.Component comp,
                                java.awt.Dimension size)
Sets the size of a component to be a rigidly fixed as we possibly can.


setFixedSize

public static void setFixedSize(java.awt.Component comp,
                                int w,
                                int h)
Sets the size of a component to be a rigidly fixed as we possibly can.


setFixedWidth

public static void setFixedWidth(java.awt.Component comp,
                                 int w)
Sets the width of a component to a rigidly fixed value


setFixedHeight

public static void setFixedHeight(java.awt.Component comp,
                                  int h)
Sets the height of a component to a rigidly fixed value


createBoxFiller

public static java.awt.Component createBoxFiller()

getScreenLocation

public static java.awt.Point getScreenLocation(java.awt.Component ref,
                                               double xr,
                                               double yr)
Gets the current screen location of a specified point within a reference component. This can then be used for positioning windows relative to that component. The location of the point relative to the component is specified using coordinates xr and yr. These are normalized for the component's size, so that (0,0) indicates the top left, (1,1) indicates the lower right, etc.

Parameters:
ref - reference component
xr - normalized horizontal point location
yr - normalized vertical point location
Returns:
point location in screen coordinates

getScreenBounds

public static java.awt.Rectangle getScreenBounds(java.awt.Component ref)
Gets the current screen bounds of a component.


locateHorizontally

public static void locateHorizontally(java.awt.Window win,
                                      java.awt.Component ref,
                                      int location)
Sets the horizonal position of a window relative to another component. The vertical position is unchanged. The relative location is specified by either LEFT, RIGHT, CENTER, LEFT_EDGES, or RIGHT_EDGES. This placement may be altered in order to keep the window on the screen.

Parameters:
win - window to be located
ref - reference component
location - desired horizonal location of the window relative to the component

locateVertically

public static void locateVertically(java.awt.Window win,
                                    java.awt.Component ref,
                                    int location)
Sets the vertical position of a window relative to another component. The horizontal position is unchanged. The relative location is specified by either ABOVE, BELOW, CENTER, TOP_EDGES, or BOTTOM_EDGES. This placement may be altered in order to keep the window on the screen.

Parameters:
win - window to be located
ref - reference component
location - desired horizonal location of the window relative to the component

locateRelative

public static void locateRelative(java.awt.Window win,
                                  java.awt.Rectangle bounds,
                                  double px,
                                  double py,
                                  double wx,
                                  double wy)
Locates a window relative to a given set of screen bounds. The location is set so that point (wx, wy) in the window maps to point (bx, by) in tne bounds. Both sets of points are normalized to relative to the window and bounds sizes, so that (0, 0) corresponds to the upper left corner, (0.5, 0.5) is the center, (1, 1) is the lower right, etc.


locateCenter

public static void locateCenter(java.awt.Window win,
                                java.awt.Component ref)
Center a window on the window containing a specified reference component.


locateRight

public static void locateRight(java.awt.Window win,
                               java.awt.Component ref)
Locates a window to the right of the window containing a specified reference component. The top edges of the window and the reference component are aligned. Final placement may be altered slightly to keep the window fully on the screen.


locateLeft

public static void locateLeft(java.awt.Window win,
                              java.awt.Component ref)
Locates a window to the left of the window containing a specified reference component. The top edges of the window and the reference component are aligned. Final placement may be altered slightly to keep the window fully on the screen.


locateAbove

public static void locateAbove(java.awt.Window win,
                               java.awt.Component ref)
Locates a window above the window containing a specified reference component. The left edges of the window and the reference component are aligned. Final placement may be altered slightly to keep the window fully on the screen.


locateBelow

public static void locateBelow(java.awt.Window win,
                               java.awt.Component ref)
Locates a window below the window containing a specified reference component. The left edges of the window and the reference component are aligned. Final placement may be altered slightly to keep the window fully on the screen.


getVirtualScreenBounds

public static java.awt.Rectangle getVirtualScreenBounds()

loadIcon

public static javax.swing.ImageIcon loadIcon(java.lang.Object ref,
                                             java.lang.String path)

indexOfComponent

public static int indexOfComponent(java.awt.Container parent,
                                   java.awt.Component comp)

containsComponent

public static boolean containsComponent(java.awt.Container parent,
                                        java.awt.Component comp)

indexOfMenuComponent

public static int indexOfMenuComponent(javax.swing.JMenu parent,
                                       java.awt.Component comp)

containsMenuComponent

public static boolean containsMenuComponent(javax.swing.JMenu parent,
                                            java.awt.Component comp)

setItalicFont

public static void setItalicFont(javax.swing.JComponent jcomp)

repackComponentWindow

public static void repackComponentWindow(java.awt.Component c)

createTitledPanelBorder

public static javax.swing.border.TitledBorder createTitledPanelBorder(java.lang.String title)

createMenuItem

public static javax.swing.JMenuItem createMenuItem(java.awt.event.ActionListener listener,
                                                   java.lang.String cmd,
                                                   java.lang.String toolTip)