Shape Primitives

So far we have only drawn rectangles in our examples, but there are, in fact, nine shape primitives available to us. These shapes are contained almost entirely in the java.awt.geom package and can be used to draw pretty much anything in two dimensions. All shape primitives implement the Shape interface, a set of methods for describing shapes that is part of the java.awt package. In addition, all shape primitives implement the PathIterator object that specifies the outline of the shape. Before explaining the PathIterator interface, we will introduce the shape primitives:

  • Arc2D

  • Area

  • CubicCurve2D

  • Ellipse2D

  • GeneralPath

  • Line2D

  • QuadCurve2D

  • Rectangle2D

  • RoundRectangle2D

This set of primitives can be divided into four categories based on their ...

Get Java™ Media APIs: Cross-Platform Imaging, Media, and Visualization now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.