org.eclipse.gef.geometry.convert.awt

## Class Geometry2AWT

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

    public class Geometry2AWT
    extends java.lang.Object

Utility class to support conversions between GEF's geometry API and AWT Java2D's geometry API.

### Method Summary

All Methods Static Methods Concrete Methods
`static java.awt.geom.AffineTransform` `toAWTAffineTransform(AffineTransform t)` Converts a GEF `AffineTransform` into an AWT `AffineTransform`.
`static java.awt.geom.Line2D.Double` `toAWTLine(Line l)` Converts a GEF `Line` into an AWT `Line2D`.
`static java.awt.geom.Path2D.Double` `toAWTPath(Path p)` Converts a `Path` into an equivalent AWT `Path2D`.
`static java.awt.geom.Point2D.Double` `toAWTPoint(Point p)` Converts a GEF `Point` into an AWT `Point2D` with double precision (`Point2D.Double`).
`static java.awt.geom.Point2D.Double[]` `toAWTPoints(Point[] pts)` Converts a given array of GEF `Point`s into an array of AWT `Point2D`s with double precision ( `Point2D.Double`).
`static java.awt.geom.Rectangle2D.Double` `toAWTRectangle(Rectangle r)` Converts a GEF `Rectangle` into an AWT `Rectangle2D`.
`static java.awt.geom.RoundRectangle2D.Double` `toAWTRoundRectangle(RoundedRectangle r)` Converts a GEF `RoundedRectangle` into an AWT `RoundRectangle2D`.

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

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

### Method Detail

#### toAWTAffineTransform

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

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

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

#### toAWTLine

    public static java.awt.geom.Line2D.Double toAWTLine(Line l)

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

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

#### toAWTPath

    public static java.awt.geom.Path2D.Double toAWTPath(Path p)

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

Parameters:
  `p` - the `Path` to convert
Returns:
  a new `PathIterator` representing the same path

#### toAWTPoint

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

Converts a GEF `Point` into an AWT `Point2D` with double precision (`Point2D.Double`).

Parameters:
  `p` - the `Point` to convert
Returns:
  a new `Point2D` with double precision ( `Point2D.Double`), which is constructed using the x and y coordinates of the provided `Point`

#### toAWTPoints

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

Converts a given array of GEF `Point`s into an array of AWT `Point2D`s with double precision ( `Point2D.Double`).

Parameters:
  `pts` - the array of `Point`s to convert
Returns:
  an array of new `Point2D`s with double precision ( `Point2D.Double`), which are constructed using the x and y coordinates of the provided `Point`s

#### toAWTRectangle

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

Converts a GEF `Rectangle` into an AWT `Rectangle2D`. Note that the new `Rectangle2D` is simply constructed by using the values of the passed-in `Rectangle`, 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 passed-in `Rectangle` object as follows:
`rectangle2d = Geometry2AWT.toAWTRectangle(rectangle.getExpanded(0, 0, 1, 1));`
(see also `AbstractRectangleBasedGeometry.getExpanded(double, double, double, double)`)

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

#### toAWTRoundRectangle

    public static java.awt.geom.RoundRectangle2D.Double toAWTRoundRectangle(RoundedRectangle r)

Converts a GEF `RoundedRectangle` into an AWT `RoundRectangle2D`. Note that the new `RoundRectangle2D` is simply constructed by using the values of the passed in `RoundedRectangle`, 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 passed-in `RoundedRectangle` object as follows:
`roundRectangle2d = Geometry2AWT.toAWTRoundRectangle(roundedRectangle.getExpanded(0, 0, 1, 1));`
(see also `AbstractRectangleBasedGeometry.getExpanded(double, double, double, double)`)

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