gumbo.graphic.impl.swing
Class SwingGraphics

java.lang.Object
  |
  +--gumbo.graphic.impl.swing.SwingGraphics

public class SwingGraphics
extends java.lang.Object

Constants and utilities that are commonly used by Swing/AWT adapters.

Data type conversions are between Swing mouse coordinates (X increasing left in display, Y increasing down, integer precision) and Gumbo right-hand coordinates. Conversions, in either direction, do not affect the origin. Conversions to Swing ignore the Gumbo Z value and perform rounding. Conversions from Swing set the Gumbo Z value to zero.

Version:
$Revision: 1.2 $
Author:
Jon Barrilleaux (jonb@jmbaai.com) of JMB and Associates Inc.

Method Summary
static java.awt.Point centerPoint(java.awt.Dimension size, java.awt.Point retVal)
          Returns the center point of a box.
static java.awt.Point centerPoint(java.awt.Rectangle bounds, java.awt.Point retVal)
          Returns the center point of a box.
static java.awt.Rectangle contentBounds(java.awt.Container cont, java.awt.Rectangle retVal)
          Returns the bounds exclosing a container's visible contents.
static Tuple3 fromDimension(java.awt.Dimension size, Tuple3 retVal)
          Converts a Dimension to a Tuple3.
static Tuple3 fromPoint(java.awt.Point point, Tuple3 retVal)
          Converts a Point to a Tuple3.
static AxisBound3 fromRectangle(java.awt.Rectangle rect, AxisBound3 retVal)
          Converts a Rectangle to a AxisBound3.
static java.awt.Point originPoint(java.awt.Point center, java.awt.Dimension size, java.awt.Point retVal)
          Returns the origin point of a box, given the box center and size.
static void prepareGraphicPresence(java.util.Collection types, java.awt.Container cont)
          Calls prepareGraphicPresence() on each GraphicPresence component in a container that matches one of the specified types.
static void realizeGraphicPresence(java.util.Collection types, java.awt.Container cont)
          Calls realizeGraphicPresence() on each GraphicPresence component in a container that matches one of the specified types.
static java.awt.Dimension toDimension(Tuple3 tuple, java.awt.Dimension retVal)
          Converts a Tuple3 to a Dimension.
static java.awt.Point toPoint(Tuple3 tuple, java.awt.Point retVal)
          Converts a Tuple3 to a Point.
static java.awt.Rectangle toRectangle(AxisBound3 bound, java.awt.Rectangle retVal)
          Converts a AxisBound3 to a Rectangle.
static java.awt.Rectangle usableBounds(java.awt.Container comp, java.awt.Rectangle retVal)
          Returns the usable bounds of a component, which is the bounds minus any room reserved for borders.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

toPoint

public static java.awt.Point toPoint(Tuple3 tuple,
                                     java.awt.Point retVal)
Converts a Tuple3 to a Point.

Parameters:
tuple - Tuple to convert. Never null.
retVal - Return value object. Never null.
Returns:
Reference to retVal. Never null.

fromPoint

public static Tuple3 fromPoint(java.awt.Point point,
                               Tuple3 retVal)
Converts a Point to a Tuple3.

Parameters:
point - Point to convert. Never null.
retVal - Return value object. Never null.
Returns:
Reference to retVal. Never null.

toDimension

public static java.awt.Dimension toDimension(Tuple3 tuple,
                                             java.awt.Dimension retVal)
Converts a Tuple3 to a Dimension.

Parameters:
tuple - Tuple to convert. Never null.
retVal - Return value object. Never null.
Returns:
Reference to retVal. Never null.

fromDimension

public static Tuple3 fromDimension(java.awt.Dimension size,
                                   Tuple3 retVal)
Converts a Dimension to a Tuple3.

Parameters:
size - Dimension to convert. Never null.
retVal - Return value object. Never null.
Returns:
Reference to retVal. Never null.

toRectangle

public static java.awt.Rectangle toRectangle(AxisBound3 bound,
                                             java.awt.Rectangle retVal)
Converts a AxisBound3 to a Rectangle.

Parameters:
bound - AxisBound3 to convert. Never null.
retVal - Return value object. Never null.
Returns:
Reference to retVal. Never null.

fromRectangle

public static AxisBound3 fromRectangle(java.awt.Rectangle rect,
                                       AxisBound3 retVal)
Converts a Rectangle to a AxisBound3.

Parameters:
retVal - Return value object. Never null.
Returns:
Reference to retVal. Never null.

centerPoint

public static java.awt.Point centerPoint(java.awt.Dimension size,
                                         java.awt.Point retVal)
Returns the center point of a box.

Parameters:
size - Size of the box. Possibly zero. Never null.
retVal - Return value object. The center point, relative to (0, 0). Never null.
Returns:
Reference to retVal. Never null.

centerPoint

public static java.awt.Point centerPoint(java.awt.Rectangle bounds,
                                         java.awt.Point retVal)
Returns the center point of a box.

Parameters:
bounds - Position and size of the box. Possibly zero. Never null.
retVal - Return value object. The center point, in the same space as the bounds. Never null.
Returns:
Reference to retVal. Never null.

originPoint

public static java.awt.Point originPoint(java.awt.Point center,
                                         java.awt.Dimension size,
                                         java.awt.Point retVal)
Returns the origin point of a box, given the box center and size.

Parameters:
center - Center point of the box. Never null.
size - Size of the box. Possibly zero. Never null.
retVal - Return value object. The origin point, in the same space as the center point. Never null.
Returns:
Reference to retVal. Never null.

usableBounds

public static java.awt.Rectangle usableBounds(java.awt.Container comp,
                                              java.awt.Rectangle retVal)
Returns the usable bounds of a component, which is the bounds minus any room reserved for borders.

Parameters:
comp - Target component. Never null.
retVal - Return value object. The usable bounds. Never null.
Returns:
Reference to retVal. Never null.

contentBounds

public static java.awt.Rectangle contentBounds(java.awt.Container cont,
                                               java.awt.Rectangle retVal)
Returns the bounds exclosing a container's visible contents.

Parameters:
cont - Target container. Never null.
retVal - Return value object. The contents bounds. Never null.
Returns:
Reference to retVal. Never null.

prepareGraphicPresence

public static void prepareGraphicPresence(java.util.Collection types,
                                          java.awt.Container cont)
Calls prepareGraphicPresence() on each GraphicPresence component in a container that matches one of the specified types.

Parameters:
types - Types (Class) of components to prepare. If null, all types are validated.
cont - Target container. Never null.

realizeGraphicPresence

public static void realizeGraphicPresence(java.util.Collection types,
                                          java.awt.Container cont)
Calls realizeGraphicPresence() on each GraphicPresence component in a container that matches one of the specified types.

Parameters:
types - Types (Class) of components to refresh. If null, all types are validated.
cont - Target container. Never null.