public class AWT2Geometry
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
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 . |
public static AffineTransform toAffineTransform(java.awt.geom.AffineTransform t)
AffineTransform
into a GEF
AffineTransform
t
- the AffineTransform
to transformAffineTransform
representing an identical
transformationpublic static final Line toLine(java.awt.geom.Line2D l)
Line2D
into a GEF Line
.l
- the Line2D
to convertLine
, which is constructed by using the start (
Line2D.getP1()
) and end (Line2D.getP2()
) points
of the passed-in Line2D
public static Path toPath(java.awt.geom.Path2D p)
Path2D
into a GEF Path
.p
- the Path2D
to convertPath
, which is constructed with the same winding
rule and segments as the passed in Path2D
.public static final Point toPoint(java.awt.geom.Point2D p)
Point2D
into a GEF Point
.p
- the Point2D
to transformPoint
, which is constructed using the x and y
coordinates of the passed-in Point2D
public static Point[] toPoints(java.awt.geom.Point2D[] pts)
Point2D
s into a an array of GEF
Point
s.pts
- the array of Point2D
s to transformPoint
s, which are constructed by
using the x and y coordinates of the passed-in Point2D
spublic 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)
)
r
- the Rectangle2D
to convertRectangle
, which is constructed using the x, y,
width, and height values of the passed-in Rectangle2D
.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)
)
r
- the RoundRectangle2D
to convertRoundedRectangle
, which is constructed using the x,
y, width, height, arcWidth, and arcHeight values of the passed in
RoundRectangle2D
Copyright (c) 2014 itemis AG, and others. All rights reserved.