19.09.2015 Views

Prentice.Hall.Introduction.to.Java.Programming,.Brief.Version.9th.(2014).[sharethefiles.com]

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Java</strong> 2D provides facilities <strong>to</strong> construct basic shapes and <strong>to</strong> <strong>com</strong>bine<br />

them <strong>to</strong> form more <strong>com</strong>plex shapes. Figure 49.1 shows various shapes<br />

supported in <strong>Java</strong> 2D.<br />

«interface»<br />

Shape<br />

Line2D<br />

Line2D.Double<br />

RectangularShape<br />

Polygon<br />

Area<br />

GeneralPath<br />

QuadCurve2D<br />

CubicCurve2D<br />

Line2D.Float<br />

Rectangle2D<br />

RoundRectangule2D<br />

Ellipse2D<br />

Arc2D<br />

QuadCurve2D.Double<br />

QuadCurve2D.Float<br />

CubicCurve2D.Double<br />

CubicCurve2D.Float<br />

Rectangle2D.Double<br />

Rectangle2D.Float<br />

Rectangle<br />

RoundRectangle2D.Double<br />

RoundRectangle2D.Float<br />

Ellipse2D.Double<br />

Ellipse2D.Float<br />

Arc2D.Double<br />

Arc2D.Float<br />

Path2D Path2D.Double<br />

Path2D.Float<br />

Figure 49.1<br />

<strong>Java</strong> 2D defines various shapes.<br />

<br />

The Shape interface defines the <strong>com</strong>mon features for shapes and<br />

provides the contains method <strong>to</strong> test whether a point or a<br />

rectangle is inside a shape, and the intersects method <strong>to</strong> test<br />

whether the shape overlaps with a rectangle, as shown in Figure<br />

49.2. These methods are often useful in geometrical programming.<br />

3

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!