Home
Categories
Dictionary
Download
Project Details
Changes Log
FAQ
License

geom



The geom package contains additional classes which work with the Java geom package.

Shape classes

  • The Polygon2D class allows to create a Java2D Shape which uses float coordinates instead of int coordinates
  • The Polyline2D class allows to create a Java2D Shape identical to a which uses org.mdiutil.geom.Polygon2D except that the figure is not closed. This kind of class does not exist in the Java2D API
  • The Vector2D class allows to create a Vector class. This class has also additional useful methods, allowing for example to:
    • Create the inverse of a Vector
    • Create the intersection of two Vectors
    • Create the norm of a Vector
    • Create the normal of a Vector
    • etc..

Shape utility classes

ClippableShape

The ClippableShape class allows to wrap a Shape to clip it, as it is possible to do with an Area. The resulting Shape will not contain Bezier Curves[1]
Bezier Curves will be converted to list of Arcs
but only:
  • Lines
  • Arcs
  • Polygon2D
  • Polyline2D
This class is mostly useful for converting to graphic formats that don't deal well with clipping paths (for example, the WMF format). Note that this class correctly takes into account disconnected paths in the Shape.

ShapeNormalizer

The ShapeNormalizer class converts a Shape to a list of simple Shapes[1]
Bezier Curves will be converted to list of Arcs
:
  • Lines
  • Arcs
  • Polygon2D
  • Polyline2D
Note that this class correctly takes into account disconnected paths in the Shape.

Graphics2DWrapper

The Graphics2DWrapper class wraps another Graphics2D, filtering all graphics orders.

The AffineTransform set on this wrapper at initialization will wrap all the transformations set on the underlying Graphics2D. For example, if you want to provide an additional scale on all graphic orders, you can do the following:
  AffineTransform tr = AffineTransform.getScaleInstance(scale, scale);
  Graphics2DWrapper wrapper = new Graphics2DWrapper(g2d, tr);
or:
   Graphics2DWrapper wrapper = new Graphics2DWrapper(g2d, scale);
or even:
   Graphics2DWrapper wrapper = new Graphics2DWrapper(g2d);
   wrapper.setScale(scale);

Other useful Shape utilities

The GeometryRuler class computes the area or perimeter of any Shape.

Notes

  1. ^ [1] [2] Bezier Curves will be converted to list of Arcs

Categories: geom | packages

Copyright 2006-2024 Herve Girod. All Rights Reserved. Documentation and source under the LGPL v2 and Apache 2.0 licences