public class Geometry2AWT extends Object
Modifier and Type | Method and Description |
---|---|
static AffineTransform |
toAWTAffineTransform(AffineTransform t)
Converts a GEF
AffineTransform into an AWT
AffineTransform . |
static Line2D.Double |
toAWTLine(Line l)
|
static Path2D.Double |
toAWTPath(Path p)
|
static Point2D.Double |
toAWTPoint(Point p)
|
static 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 Rectangle2D.Double |
toAWTRectangle(Rectangle r)
Converts a GEF
Rectangle into an AWT Rectangle2D . |
static RoundRectangle2D.Double |
toAWTRoundRectangle(RoundedRectangle r)
Converts a GEF
RoundedRectangle into an AWT
RoundRectangle2D . |
public static AffineTransform toAWTAffineTransform(AffineTransform t)
AffineTransform
into an AWT
AffineTransform
.t
- the AffineTransform
to transformAffineTransform
representing an
identical transformationpublic static Line2D.Double toAWTLine(Line l)
l
- the Line
to transformLine2D
, which is constructed by using the start (
BezierCurve.getP1()
) and end (BezierCurve.getP2()
)
Point
s of the passed-in Line
public static Path2D.Double toAWTPath(Path p)
p
- the Path
to convertPathIterator
representing the same pathpublic static final Point2D.Double toAWTPoint(Point p)
p
- the Point
to convertPoint2D
with double precision (
Point2D.Double
), which is constructed using
the x and y coordinates of the provided Point
public static Point2D.Double[] toAWTPoints(Point[] pts)
Point
s into an array of AWT
Point2D
s with double precision (
Point2D.Double
).pts
- the array of Point
s to convertPoint2D
s with double precision (
Point2D.Double
), which are constructed
using the x and y coordinates of the provided Point
spublic static final 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)
)
r
- the Rectangle
to convertRectangle2D
, which is constructed using the x, y,
width, and height values of the passed-in Rectangle
.public static 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)
)
r
- the RoundedRectangle
to convertRoundRectangle2D
, which is constructed using the x,
y, width, height, arcWidth, and arcHeight values of the passed in
RoundedRectangle
Copyright (c) 2014 itemis AG, and others. All rights reserved.