coordinateoverview text    

2D Graphics
Lesson: Overview of the Java 2D API
Shapes The classes in the java.awt.geom package define common graphics primitives, such as points, lines, curves, arcs, rectangles, and ellipses.

Classes in the java.awt.geom Package

Arc2D Ellipse2D QuadCurve2D
Area GeneralPath Rectangle2D
CubicCurve2D Line2D RectangularShape
Dimension2D Point2D RoundRectangle2D

Except for Point2D and Dimension2D, each of the geometry classes (geometries) implements the Shape interface, which provides a common set of methods for describing and inspecting two-dimensional geometric objects.

With these classes you can create virtually any geometric shape and render it through Graphics2D by calling the draw method or the fill method. For example, the geometric shapes in the following ShapesDemo2D applet are defined by using basic Java 2D geometries.

If you're curious, the code for this program, is in ShapesDemo2D.javasourceIcon (in a .java source file) How to draw and fill shapes is described in the next lesson, display/index Displaying Graphics with Graphics2D

2d/2D-12 top2d/2D-12 460165ALIGNNATURALSIZEFLAG3
This figure has been reduced to fit on the page.
Click the image to view it at its natural size.

Rectangular Shapes

The Rectangle2D, RoundRectangle2D, Arc2D, and Ellipse2D primitives are all derived from RectangularShape, which defines methods for Shape objects that can be described by a rectangular bounding box. The geometry of a RectangularShape can be extrapolated from a rectangle that completely encloses the outline of the Shape.

2d/2D-13 45687ALIGNNATURALSIZEFLAG3

QuadCurve2D and CubicCurve2D

The QuadCurve2D class allows you to create quadratic parametric curve segments. A quadratic curve is defined by two endpoints and one control point.

The CubicCurve2D class allows you to create cubic parametric curve segments. A cubic curve is defined by two endpoints and two control points. The following figures demonstrate examples of quadratic and cubic curves. See display/strokeandfillStroking and Filling Graphics Primitives to see implementations of cubic and quadratic curves.

2d/2D-14 178138ALIGNNATURALSIZEFLAG3

2d/2D-15 290152ALIGNNATURALSIZEFLAG3

GeneralPath

The GeneralPath class enables you to construct an arbitrary shape by specifying a series of positions along the shape's boundary. These positions can be connected by line segments, quadratic curves, or cubic (Bézier) curves. The shape pictured below can be created with three line segments and a cubic curve. See display/strokeandfillStroking and Filling Graphics Primitives to see the implementation of this shape.

2d/PolyShape 15075ALIGNNATURALSIZEFLAG3

Areas

With the Area class you can perform boolean operations, such as union, intersection, and subtraction, on any two Shape objects. This technique, often referred to as constructive area geometry, enables you to quickly create complex Shape objects without having to describe each line segment or curve.
coordinateoverview text    

Bhopal news
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

India website designer web development India php ecommerce developer | Web design India, Ecommerce web design | India web hosting website host india | Windows hosting India web hosting | Software development India | Flash web designer india