Runtime

## org.eclipse.gmf.runtime.draw2d.ui.figures
Class FigureUtilities

    java.lang.Object
      org.eclipse.draw2d.FigureUtilities
          org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities

public class FigureUtilities
extends FigureUtilities

A set of methods that are useful when manipulating figures. These are often used in the paint routines or locators of IFigure implementors to do complex geometry calculations that may be common across different parts of a hierarchy.

Constructor Summary
`FigureUtilities()`

Method Summary
`static java.lang.Integer` `colorToInteger(Color c)` Method colorToInteger.
`static Point` `getLocation(int pos, Dimension dim, Rectangle constraint)` Return the location within the supplied constraint of an object of dimension dim according to the alignment parameter.
`static Point` `getLocation(int pos, Rectangle topos, Rectangle constraint)` Return the location within the supplied constraint the supplied rectangle requires to be positioned according to the alignment parameter pos.
`static Color` `integerToColor(java.lang.Integer i)` Method integerToColor.
`static RGB` `integerToRGB(java.lang.Integer color)` Method integerToRGB converts from an Integer to an RGB representation
`static void` `paintGridWithStyle(Graphics g, IFigure f, Point origin, int distanceX, int distanceY, int lineStyle, int[] dashes)` Helper method to paint a grid.
`static java.lang.Integer` `RGBToInteger(RGB rgb)` Method RGBToInteger converts from an RGB to an Integer representation

Methods inherited from class org.eclipse.draw2d.FigureUtilities
`darker, findCommonAncestor, getFontMetrics, getGC, getRoot, getStringDimension, getStringExtents, getTextDimension, getTextExtents, getTextExtents, getTextWidth, isAncestor, lighter, makeGhostShape, mixColors, mixColors, paintEtchedBorder, paintEtchedBorder, paintGrid, setFont`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### FigureUtilities

    public FigureUtilities()

Method Detail

### colorToInteger

    public static java.lang.Integer colorToInteger(Color c)

  Method colorToInteger. converts from a Color to an Integer representation

  Parameters:
    `c` -
  Returns:
    Integer

### integerToColor

    public static Color integerToColor(java.lang.Integer i)

  Method integerToColor. converts from an Integer to a Color representation Note: Normally, colors should be instantiated using the AbstractResourceManager.

  Parameters:
    `i` -
  Returns:
    Color

### RGBToInteger

    public static java.lang.Integer RGBToInteger(RGB rgb)

  Method RGBToInteger converts from an RGB to an Integer representation

  Parameters:
    `rgb` -
  Returns:
    Integer

### integerToRGB

    public static RGB integerToRGB(java.lang.Integer color)

  Method integerToRGB converts from an Integer to an RGB representation

  Parameters:
    `color` -
  Returns:
    RGB

### getLocation

    public static Point getLocation(int pos,
                                    Rectangle topos,
                                    Rectangle constraint)

  Return the location within the supplied constraint the supplied rectangle requires to be positioned according to the alignment parameter pos.

       NW-----N------NE
       |              |
       W    NS/EW     E
       |              |
       SW-----S------SE

  Parameters:
    `pos` - a geographic PositionConstant (N,E,W,S,NW,NW,NS,EW)
    `topos` - the rectangle to be (re)positioned.
    `constraint` - the containing bounds.
  Returns:
    a new location.

### getLocation

    public static Point getLocation(int pos,
                                    Dimension dim,
                                    Rectangle constraint)

  Return the location within the supplied constraint of an object of dimension dim according to the alignment parameter.

  Parameters:
    `pos` - a geographic PositionConstant (N,E,W,S,NW,NW,NS,EW)
    `dim` - some dimension.
    `constraint` - the containing bounds.
  Returns:
    a new location.
  See Also:
    `FigureUtilities.getLocation(int, Rectangle, Rectangle)`

### paintGridWithStyle

    public static void paintGridWithStyle(Graphics g,
                                          IFigure f,
                                          Point origin,
                                          int distanceX,
                                          int distanceY,
                                          int lineStyle,
                                          int[] dashes)

  Helper method to paint a grid. Painting is optimized as it is restricted to the Graphics' clip.

  Parameters:
    `g` - The Graphics object to be used for painting
    `f` - The figure in which the grid is to be painted
    `origin` - Any point where the grid lines are expected to intersect
    `distanceX` - Distance between vertical grid lines; if 0 or less, vertical grid lines will not be drawn
    `distanceY` - Distance between horizontal grid lines; if 0 or less, horizontal grid lines will not be drawn
    `lineStyle` - Line style to be used for painting the grid lines
    `dashes` - Dash pattern to be used for the grid line (ignored if lineStyle != LINE_CUSTOM)

Runtime

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp., Borland Software Corp., and others 2005,2006. All rights reserved.