Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "GEF/GEF4/Geometry"

< GEF‎ | GEF4
m
m
Line 21: Line 21:
 
This diagram depicts the interface hierarchy which underlies the individual geometry classes. It classifies the geometry classes mainly into either being ICurves or IShapes. An ICurve is a one dimensional geometry, i.e. the result that you get by drawing a continuous line with a pencil. It has a start and an end point, it is continuous and you can approximate it by a series of Bézier curves. On the other hand, an IShape is a two dimensional geometry, i.e. it continuously encloses a region on the drawing area, without holes. You can retrieve the outline of an IShape, which is an IPolyCurve, a special case of an ICurve. It defines a curve that is composed of multiple continuous ICurves and its purpose is to combine such a set of continuous curves to be able to operate on them as a whole.
 
This diagram depicts the interface hierarchy which underlies the individual geometry classes. It classifies the geometry classes mainly into either being ICurves or IShapes. An ICurve is a one dimensional geometry, i.e. the result that you get by drawing a continuous line with a pencil. It has a start and an end point, it is continuous and you can approximate it by a series of Bézier curves. On the other hand, an IShape is a two dimensional geometry, i.e. it continuously encloses a region on the drawing area, without holes. You can retrieve the outline of an IShape, which is an IPolyCurve, a special case of an ICurve. It defines a curve that is composed of multiple continuous ICurves and its purpose is to combine such a set of continuous curves to be able to operate on them as a whole.
  
Especially important for clipping, another class of planar geometries is introduced: the IPolyShapes. Other than the relationship between ICurve and IPolyCurve, an IPolyShape is not an IShape. An IPolyShape is a (possibly) non-continuous set of IShapes. A well known example for an IPolyShape is the [[Linkhttp://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fswt%2Fgraphics%2Fpackage-summary.html:|SWT Region]]. The GEF 4 Geometry API provides a corresponding class.
+
Especially important for clipping, another class of planar geometries is introduced: the IPolyShapes. Other than the relationship between ICurve and IPolyCurve, an IPolyShape is not an IShape. An IPolyShape is a (possibly) non-continuous set of IShapes. A well known example for an IPolyShape is the [http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fswt%2Fgraphics%2Fpackage-summary.html: SWT Region]. The GEF 4 Geometry API provides a corresponding class.
  
 
This diagram depicts the interface hierarchy which underlies the individual geometry classes. In turn, the inheritance hierarchy classifies the figures by their construction type, so that many operations are generalized in a few abstract classes. Additionally, the different planar geometry objects provide extra functionality, for example, computing the area of a Polygon, or unifying two Rectangles.
 
This diagram depicts the interface hierarchy which underlies the individual geometry classes. In turn, the inheritance hierarchy classifies the figures by their construction type, so that many operations are generalized in a few abstract classes. Additionally, the different planar geometry objects provide extra functionality, for example, computing the area of a Polygon, or unifying two Rectangles.

Revision as of 08:27, 22 March 2012

Description

This is the documentation of the GEF4 Geometry API. You can find a small tutorial for the API here.

Geometric primitives

Angle, Dimension, and Point

The API uses a small number of "primitives" which are globally used to build up, introspect and modify complex objects. These primitives are the Point, Angle and Dimension classes. Presumably, the most important class of the three is the Point class, because you will encounter it very often while working with the API. Point objects represent a point in two dimensional space.(1) From a list of Point objects, you can build up every planar geometry object.

Considering rotation and the angular relationship of two straight lines, Angle objects come into play. They abstract over two angle units: degrees and radians. The user has to specify the unit of the value an Angle object is constructed from. Moreover, the user can read the value of an Angle object in either degrees or radians. Therefore, the use of Angle objects assures that correct values are used in calculations. This indirection is done, due to an inconsistency of several APIs, for example, org.eclipse.swt.graphics.Transform vs. org.eclipse.draw2d.geometry.Transform. Keep in mind that the GEF 4 Geometry API is not yet finished. Maybe, this indirection will be eliminated in a future version.

The Dimension class is the pendant of the draw2d.Dimension class.

(1) For the purpose of imagination, you can assume the coordinate system to be originated in the top left corner of your drawing area, expanding to the right and to the bottom.

Planar geometry

Interface hierarchy

This diagram depicts the interface hierarchy which underlies the individual geometry classes. It classifies the geometry classes mainly into either being ICurves or IShapes. An ICurve is a one dimensional geometry, i.e. the result that you get by drawing a continuous line with a pencil. It has a start and an end point, it is continuous and you can approximate it by a series of Bézier curves. On the other hand, an IShape is a two dimensional geometry, i.e. it continuously encloses a region on the drawing area, without holes. You can retrieve the outline of an IShape, which is an IPolyCurve, a special case of an ICurve. It defines a curve that is composed of multiple continuous ICurves and its purpose is to combine such a set of continuous curves to be able to operate on them as a whole.

Especially important for clipping, another class of planar geometries is introduced: the IPolyShapes. Other than the relationship between ICurve and IPolyCurve, an IPolyShape is not an IShape. An IPolyShape is a (possibly) non-continuous set of IShapes. A well known example for an IPolyShape is the SWT Region. The GEF 4 Geometry API provides a corresponding class.

This diagram depicts the interface hierarchy which underlies the individual geometry classes. In turn, the inheritance hierarchy classifies the figures by their construction type, so that many operations are generalized in a few abstract classes. Additionally, the different planar geometry objects provide extra functionality, for example, computing the area of a Polygon, or unifying two Rectangles.

IGeometry

IGeometry

The IGeometry interface defines the functionality that every planar geometriy object implements.

  • IGeometry.contains(Point) : boolean

The contains(Point) method tests if the given Point lies on/in the particular IGeometry.

  • IGeometry.getBounds() : Rectangle

The getBounds() method computes a bounding box for the particular IGeometry. The bounding box is the smallest Rectangle that contains this IGeometry.

  • IGeometry.touches(IGeometry) : boolean

The touches(IGeometry) method tests the given other IGeometry for at least one Point in common with this IGeometry. touches(IGeometry) works differently for ICurves and IShapes. For the latter ones, only the particular IShape's outline is regarded.

  • IGeometry.getTransformed(AffineTransform) : IGeometry

The getTransformed(AffineTransform) method applies an AffineTransform to this IGeometry and returns a new IGeometry that reflects the particular transformation. The resulting IGeometry is not necessarily of the same type as the original IGeometry, because some transformations - for example the rotation of an Ellipse - yield geometric figures that are not representable by the original IGeometry.

  • IGeometry.toPath() : Path

The toPath() method creates a Path representing this IGeometry. A Path implements Therefore, the Path is the general IGeometry that is used when you have to burst the boundaries of the other classes.

  • IGeometry.getCopy() : IGeometry

The getCopy() method returns a newly constructed IGeometry of same type that is equal to the original IGeometry.

ICurve

ICurve

Line

Line

QuadraticCurve

QuadraticCurve

CubicCurve

CubicCurve

BezierCurve

BezierCurve

Arc

Arc

IPolyCurve

IPolyCurve

Polyline

Polyline

PolyBezier

PolyBezier

IShape

IShape

Rectangle

Rectangle

RoundedRectangle

RoundedRectangle

Polygon

Polygon

Ellipse

Ellipse

Pie

Pie

IPolyShape

IPolyShape

Region

Region

Ring

Ring

Path

Path

Conversions

From Geometry to SWT

via the toSWT...() methods

AWT2Geometry

Geometry2AWT

SWT2AWT

Affine transformations

Via projective geometry. All transformations are combined before applying them to the particular shape.

Translation

Rotation

Scaling

Shearing

Euclidean geometry

Vector

Vector

Straight

Straight

Projective geometry

Vector3D

Vector3D

Straight3D

Straight3D

Back to the top