de.esprit.common.gui.util

## Class GuiUtil

- java.lang.Object
- - de.esprit.common.gui.util.GuiUtil

-     public class GuiUtil
      extends java.lang.Object

  Utilities for GUI support.
  Author:
    Rainer Buesch

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `GuiUtil()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.awt.Point` | `centerOf(java.awt.Rectangle r)` Returns the center Point of the given rectangle.
    `static java.awt.Point` | `checkInRange(java.awt.Point point, java.awt.Dimension dim)` Checks whether the given Point is positioned within the given Dimension.
    `static void` | `checkIsEventDispatchThread()`
    `static void` | `exitLater(int exitCode)` Schedules a System.exit() call to the event dispatcher for delayed execution
    `static java.awt.Rectangle` | `getBoundsOf(java.awt.Point[] points)` Returns the Rectangle that encloses all given Points.
    `static java.awt.RenderingHints` | `getDefaultRenderingHints()`
    `static java.awt.Color` | `getLabelColorFor(java.awt.Color bg)` Returns either black or white as label color dependent on the lightness of the given background color.
    `static java.awt.Dimension` | `getMaximumScreenDimension()`
    `static java.awt.Window` | `getRootContainerOf(javax.swing.JComponent comp)` Finds out the root container in which the given component resides.
    `static int` | `getStringWidth(java.awt.Font font, java.lang.String str)`
    `static int` | `getStringWidth(javax.swing.JComponent comp, int numChars)`
    `static int` | `getStringWidth(javax.swing.JComponent comp, java.lang.String s)`
    `static boolean` | `isInSnapRange(java.awt.Point mousePoint, java.awt.Point posPoint, int snapRange)` Tells whether the given Points are within the given snap range.
    `static boolean` | `isPopupTrigger(java.awt.event.MouseEvent e)`
    `static boolean` | `isSelectionTrigger(java.awt.event.MouseEvent e)`
    `static void` | `locateWindow(ToolWindow win, java.awt.Component comp, WindowAlignment alignment)`
    `static void` | `locateWindow(java.awt.Window win, int newX, int newY)` Moves the given window by the given deltaX and deltaY values
    `static javax.swing.border.Border` | `marginizeBorder(javax.swing.border.Border border, java.awt.Insets ins)` Creates a compound border such that the given border is inlined with the given Insets.
    `static java.awt.Dimension` | `maxOf(java.awt.Dimension d1, java.awt.Dimension d2)` Returns a Dimension containing the maximum width and height of the given dimensions.
    `static void` | `popWindowToFrontOf(javax.swing.JComponent comp)`
    `static void` | `setFieldColor(java.awt.Component comp, java.awt.Color bg)` Sets the background for the given component and adapts the foreground such that a lable remains readable on it's background
    `static void` | `setToSameHeight(javax.swing.JComponent... components)` Ensures that all components have got the same hight, which is the height of the highest component in the array.
    `static void` | `setToSameSize(javax.swing.JComponent... components)` Sets the preferred size of all components to the one of the biggest in the array.
    `static void` | `setToSameWidth(javax.swing.JComponent... components)` Ensures that all components have got the same width, which is the width of the widest component in the array.
    `static void` | `shiftWindow(java.awt.Window win, int deltaX, int deltaY)` Moves the given window by the given deltaX and deltaY values
    `static java.awt.Point` | `validatePoint(java.awt.Point p)` Checks the validity of the given Point.
    `static java.awt.Rectangle` | `validateRect(java.awt.Rectangle r)` Checks the validity of the given Rectangle.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### GuiUtil

          public GuiUtil()

  - ### Method Detail

    - #### getDefaultRenderingHints

          public static java.awt.RenderingHints getDefaultRenderingHints()

    - #### isPopupTrigger

          public static boolean isPopupTrigger(java.awt.event.MouseEvent e)

    - #### isSelectionTrigger

          public static boolean isSelectionTrigger(java.awt.event.MouseEvent e)

    - #### centerOf

          public static java.awt.Point centerOf(java.awt.Rectangle r)

      Returns the center Point of the given rectangle.

    - #### getBoundsOf

          public static java.awt.Rectangle getBoundsOf(java.awt.Point[] points)

      Returns the Rectangle that encloses all given Points.

    - #### isInSnapRange

          public static boolean isInSnapRange(java.awt.Point mousePoint,
                              java.awt.Point posPoint,
                              int snapRange)

      Tells whether the given Points are within the given snap range.

    - #### validatePoint

          public static java.awt.Point validatePoint(java.awt.Point p)

      Checks the validity of the given Point.
      Note that the Graphics object has a limit for x/y values of 32000. It will throw tons of exceptions if this limit was exceeded. Therefore we must validate every point before painting and fix em to legal coordinates. This doesn't hurt because invalid points are far beyond the visible area anyway.

    - #### validateRect

          public static java.awt.Rectangle validateRect(java.awt.Rectangle r)

      Checks the validity of the given Rectangle.
      Note that the Graphics object has a limit for x/y values of 32000. It will throw tons of exceptions if this limit is exceeded. Therefore we must validate every Rectangle before painting and fix it to legal coordinates. This doesn't hurt because invalid Rectangles are far beyond the visible area anyway.

    - #### checkInRange

          public static java.awt.Point checkInRange(java.awt.Point point,
                                    java.awt.Dimension dim)

      Checks whether the given Point is positioned within the given Dimension.
      Throws:
        `java.lang.IllegalArgumentException` - if this is not the case

    - #### setToSameHeight

          public static void setToSameHeight(javax.swing.JComponent... components)

      Ensures that all components have got the same hight, which is the height of the highest component in the array.

    - #### setToSameWidth

          public static void setToSameWidth(javax.swing.JComponent... components)

      Ensures that all components have got the same width, which is the width of the widest component in the array.

    - #### setToSameSize

          public static void setToSameSize(javax.swing.JComponent... components)

      Sets the preferred size of all components to the one of the biggest in the array.

    - #### maxOf

          public static java.awt.Dimension maxOf(java.awt.Dimension d1,
                                 java.awt.Dimension d2)

      Returns a Dimension containing the maximum width and height of the given dimensions.

    - #### exitLater

          public static void exitLater(int exitCode)

      Schedules a System.exit() call to the event dispatcher for delayed execution

    - #### checkIsEventDispatchThread

          public static void checkIsEventDispatchThread()

    - #### popWindowToFrontOf

          public static void popWindowToFrontOf(javax.swing.JComponent comp)

    - #### marginizeBorder

          public static javax.swing.border.Border marginizeBorder(javax.swing.border.Border border,
                                                  java.awt.Insets ins)

      Creates a compound border such that the given border is inlined with the given Insets.

    - #### setFieldColor

          public static void setFieldColor(java.awt.Component comp,
                           java.awt.Color bg)

      Sets the background for the given component and adapts the foreground such that a lable remains readable on it's background
      See Also:
        `getLabelColorFor(Color)`

    - #### getLabelColorFor

          public static java.awt.Color getLabelColorFor(java.awt.Color bg)

      Returns either black or white as label color dependent on the lightness of the given background color. This is to ensure that a label is readable on the background.

    - #### getRootContainerOf

          public static java.awt.Window getRootContainerOf(javax.swing.JComponent comp)

      Finds out the root container in which the given component resides.
      Returns:
        either a JFrame or a JDialog object or null if none was found.

    - #### getStringWidth

          public static int getStringWidth(javax.swing.JComponent comp,
                           java.lang.String s)

    - #### getStringWidth

          public static int getStringWidth(javax.swing.JComponent comp,
                           int numChars)

    - #### getStringWidth

          public static int getStringWidth(java.awt.Font font,
                           java.lang.String str)

    - #### locateWindow

          public static void locateWindow(ToolWindow win,
                          java.awt.Component comp,
                          WindowAlignment alignment)

    - #### shiftWindow

          public static void shiftWindow(java.awt.Window win,
                         int deltaX,
                         int deltaY)

      Moves the given window by the given deltaX and deltaY values

    - #### locateWindow

          public static void locateWindow(java.awt.Window win,
                          int newX,
                          int newY)

      Moves the given window by the given deltaX and deltaY values

    - #### getMaximumScreenDimension

          public static java.awt.Dimension getMaximumScreenDimension()

Copyright © 2014 EsprIT-Systems. All Rights Reserved.