org.eclipse.gef.geometry.convert.awt

## Class AWT2Geometry

- java.lang.Object
- - org.eclipse.gef.geometry.convert.awt.AWT2Geometry

    public class AWT2Geometry
    extends java.lang.Object

Utility class to support conversions from AWT's geometry API to GEF's geometry API.

### Method Summary

All Methods Static Methods Concrete Methods
`static AffineTransform` `toAffineTransform(java.awt.geom.AffineTransform t)` Converts an AWT `AffineTransform` into a GEF `AffineTransform`
`static Line` `toLine(java.awt.geom.Line2D l)` Converts an AWT `Line2D` into a GEF `Line`.
`static Path` `toPath(java.awt.geom.Path2D p)` Converts an AWT `Path2D` into a GEF `Path`.
`static Point` `toPoint(java.awt.geom.Point2D p)` Converts an AWT `Point2D` into a GEF `Point`.
`static Point[]` `toPoints(java.awt.geom.Point2D[] pts)` Converts a given array of AWT `Point2D`s into a an array of GEF `Point`s.
`static Rectangle` `toRectangle(java.awt.geom.Rectangle2D r)` Converts an AWT `Rectangle2D` into a GEF `Rectangle`.
`static RoundedRectangle` `toRoundedRectangle(java.awt.geom.RoundRectangle2D r)` Converts an AWT `RoundRectangle2D` into a GEF `RoundedRectangle`.

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

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

### Method Detail

#### toAffineTransform

    public static AffineTransform toAffineTransform(java.awt.geom.AffineTransform t)

Converts an AWT `AffineTransform` into a GEF `AffineTransform`

Parameters:
  `t` - the `AffineTransform` to transform
Returns:
  a new `AffineTransform` representing an identical transformation

#### toLine

    public static final Line toLine(java.awt.geom.Line2D l)

Converts an AWT `Line2D` into a GEF `Line`.

Parameters:
  `l` - the `Line2D` to convert
Returns:
  a new `Line`, which is constructed by using the start ( `Line2D.getP1()`) and end (`Line2D.getP2()`) points of the passed-in `Line2D`

#### toPath

    public static Path toPath(java.awt.geom.Path2D p)

Converts an AWT `Path2D` into a GEF `Path`.

Parameters:
  `p` - the `Path2D` to convert
Returns:
  a new `Path`, which is constructed with the same winding rule and segments as the passed in `Path2D`.

#### toPoint

    public static final Point toPoint(java.awt.geom.Point2D p)

Converts an AWT `Point2D` into a GEF `Point`.

Parameters:
  `p` - the `Point2D` to transform
Returns:
  a new `Point`, which is constructed using the x and y coordinates of the passed-in `Point2D`

#### toPoints

    public static Point[] toPoints(java.awt.geom.Point2D[] pts)

Converts a given array of AWT `Point2D`s into a an array of GEF `Point`s.

Parameters:
  `pts` - the array of `Point2D`s to transform
Returns:
  an array containing new `Point`s, which are constructed by using the x and y coordinates of the passed-in `Point2D`s

#### toRectangle

    public static final Rectangle toRectangle(java.awt.geom.Rectangle2D r)

Converts an AWT `Rectangle2D` into a GEF `Rectangle`. Note that the new `Rectangle` is simply constructed by using the values of the passed-in `Rectangle2D`, not compensating the fact that the width and height of a rectangle are interpreted differently in Java2D and GEF.

In Java2D, the width and height of a `Rectangle2D` are oversized by exactly 1, i.e. the right and bottom edges of a `Rectangle2D` are not regarded to belong to the visual object.

If you wish to retain this interpretation, you have to modify the resulting GEF `Rectangle` object as follows:
`rectangle.shrink(0, 0, 1, 1);`
(see also `AbstractRectangleBasedGeometry.shrink(double, double, double, double)`, `AbstractRectangleBasedGeometry.getShrinked(double, double, double, double)`)

Parameters:
  `r` - the `Rectangle2D` to convert
Returns:
  a new `Rectangle`, which is constructed using the x, y, width, and height values of the passed-in `Rectangle2D`.

#### toRoundedRectangle

    public static RoundedRectangle toRoundedRectangle(java.awt.geom.RoundRectangle2D r)

Converts an AWT `RoundRectangle2D` into a GEF `RoundedRectangle`. Note that the new `RoundedRectangle` is simply constructed by using the values of the passed-in `RoundRectangle2D`, not compensating the fact that the width and height of a rectangle are interpreted differently in Java2D and GEF.

In Java2D, the width and height of a `RoundRectangle2D` are oversized by exactly 1, i.e. the right and bottom edges of a `RoundRectangle2D` are not regarded to belong to the visual object.

If you wish to retain this interpretation, you have to modify the resulting GEF `RoundedRectangle` object as follows:
`roundedRectangle.shrink(0, 0, 1, 1);`
(see also `AbstractRectangleBasedGeometry.shrink(double, double, double, double)` , `AbstractRectangleBasedGeometry.getShrinked(double, double, double, double)`)

Parameters:
  `r` - the `RoundRectangle2D` to convert
Returns:
  a new `RoundedRectangle`, which is constructed using the x, y, width, height, arcWidth, and arcHeight values of the passed in `RoundRectangle2D`