org.eclipse.gef.fx.utils

## Class Shape2Geometry

- java.lang.Object
- - org.eclipse.gef.fx.utils.Shape2Geometry

    public class Shape2Geometry
    extends Object

The utility class `Shape2Geometry` provides methods for the conversion of JavaFX `Shape` implementations to `IGeometry` implementations.

### Constructor Summary

Constructors
Constructor and Description
`Shape2Geometry()`

### Method Summary

All Methods Static Methods Concrete Methods
`static Arc` `toArc(Arc arc)` Converts the given JavaFX `Arc` to a `Arc`.
`static CubicCurve` `toCubicCurve(CubicCurve cubic)` Converts the given JavaFX `CubicCurve` to a `CubicCurve`.
`static Ellipse` `toEllipse(Circle circle)` Converts the given JavaFX `Circle` to a `Ellipse`.
`static Ellipse` `toEllipse(Ellipse ellipse)` Converts the given JavaFX `Ellipse` to a `Ellipse`.
`static IGeometry` `toGeometry(Shape visual)` Returns an `IGeometry` that describes the geometric outline of the given `Shape`, i.e. excluding the stroke.
`static Line` `toLine(Line line)` Converts the given JavaFX `Line` to a `Line`.
`static Path` `toPath(Path path)` Converts the given JavaFX `Path` to a `Path`.
`static Polygon` `toPolygon(Polygon polygon)` Converts the given JavaFX `Polygon` to a `Polygon`.
`static Polyline` `toPolyline(Polyline polyline)` Converts the given JavaFX `Polyline` to a `Polyline`.
`static QuadraticCurve` `toQuadraticCurve(QuadCurve quad)` Converts the given JavaFX `QuadCurve` to a `QuadraticCurve`.
`static Rectangle` `toRectangle(Rectangle rect)` Converts the given JavaFX `Rectangle` to a `Rectangle`.
`static RoundedRectangle` `toRoundedRectangle(Rectangle rect)` Converts the given JavaFX `Rectangle` to a `RoundedRectangle`.

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

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

### Constructor Detail

#### Shape2Geometry

    public Shape2Geometry()

### Method Detail

#### toArc

    public static Arc toArc(Arc arc)

Converts the given JavaFX `Arc` to a `Arc`.

Parameters:
  `arc` - The JavaFX `Arc` to convert.
Returns:
  The newly created `Arc` that describes the given `Arc`.

#### toCubicCurve

    public static CubicCurve toCubicCurve(CubicCurve cubic)

Converts the given JavaFX `CubicCurve` to a `CubicCurve`.

Parameters:
  `cubic` - The JavaFX `CubicCurve` to convert.
Returns:
  The newly created `CubicCurve` that describes the given `CubicCurve`.

#### toEllipse

    public static Ellipse toEllipse(Circle circle)

Converts the given JavaFX `Circle` to a `Ellipse`.

Parameters:
  `circle` - The JavaFX `Circle` to convert.
Returns:
  The newly created `Ellipse` that describes the given `Circle`.

#### toEllipse

    public static Ellipse toEllipse(Ellipse ellipse)

Converts the given JavaFX `Ellipse` to a `Ellipse`.

Parameters:
  `ellipse` - The JavaFX `Ellipse` to convert.
Returns:
  The newly created `Ellipse` that describes the given `Ellipse`.

#### toGeometry

    public static IGeometry toGeometry(Shape visual)

Returns an `IGeometry` that describes the geometric outline of the given `Shape`, i.e. excluding the stroke.

The conversion is supported for the following `Shape`s:

- `Arc`
- `Circle`
- `CubicCurve`
- `Ellipse`
- `Line`
- `Path`
- `Polygon`
- `Polyline`
- `QuadCurve`
- `Rectangle`

The following `Shape`s cannot be converted, yet:

- `Text`
- `SVGPath`

Parameters:
  `visual` - The `Shape` for which an `IGeometry` is determined.
Returns:
  The newly created `IGeometry` that best describes the geometric outline of the given `Shape`.
Throws:
  `IllegalStateException` - if the given `Shape` is not supported.

#### toLine

    public static Line toLine(Line line)

Converts the given JavaFX `Line` to a `Line`.

Parameters:
  `line` - The JavaFX `Line` to convert.
Returns:
  The newly created `Line` that describes the given `Line`.

#### toPath

    public static final Path toPath(Path path)

Converts the given JavaFX `Path` to a `Path`.

Parameters:
  `path` - The JavaFX `Path` to convert.
Returns:
  The newly created `Path` that describes the given `Path`.

#### toPolygon

    public static Polygon toPolygon(Polygon polygon)

Converts the given JavaFX `Polygon` to a `Polygon`.

Parameters:
  `polygon` - The JavaFX `Polygon` to convert.
Returns:
  The newly created `Polygon` that describes the given `Polygon`.

#### toPolyline

    public static Polyline toPolyline(Polyline polyline)

Converts the given JavaFX `Polyline` to a `Polyline`.

Parameters:
  `polyline` - The JavaFX `Polyline` to convert.
Returns:
  The newly created `Polyline` that describes the given `Polyline`.

#### toQuadraticCurve

    public static QuadraticCurve toQuadraticCurve(QuadCurve quad)

Converts the given JavaFX `QuadCurve` to a `QuadraticCurve`.

Parameters:
  `quad` - The JavaFX `QuadCurve` to convert.
Returns:
  The newly created `QuadraticCurve` that describes the given `QuadCurve`.

#### toRectangle

    public static Rectangle toRectangle(Rectangle rect)

Converts the given JavaFX `Rectangle` to a `Rectangle`. Note, that the arc-width and arc-height of the given `Rectangle` will not be preserved in the resulting geometry.

Parameters:
  `rect` - The JavaFX `Rectangle` to convert.
Returns:
  The newly created `Rectangle` that describes the given `Rectangle` (without its arc-width and arc-height).

#### toRoundedRectangle

    public static RoundedRectangle toRoundedRectangle(Rectangle rect)

Converts the given JavaFX `Rectangle` to a `RoundedRectangle`.

Parameters:
  `rect` - The JavaFX `Rectangle` to convert.
Returns:
  The newly created `RoundedRectangle` that describes the given `Rectangle`.