by Dinesh Thakur Category: Java 2D Example

Point2D class does not draw anything; it is the representation of points Java2D. But yes you can draw shapes from points. Following is at able that lists some of the Constructors and methods of Point2D class:

 
by Dinesh Thakur Category: Java 2D Example

Another way is to build figures using GeneralPath class, which but also inherits from Shapeisan interface, but a class. This class allows  define a shape by a sequence oflines that can be established through  functions in the following table:

 
by Dinesh Thakur Category: Java 2D Example

The QuadCurve2D class lets build a curved segment based on mathematical equations. The curve generated is also called curve quadratic Bezier and based on a very simple idea is to establish two points that define the ends of a curved segment and a third point, called checkpoint that allows "stretching" more or less the curvature of the segment.

 
by Dinesh Thakur Category: Java 2D Example

The class that is used to draw rectangles and squares is the Rectangle2D. The constructor specifies the first two parameters of the corner position upper left relative to the coordinate system of the window.

 
by Dinesh Thakur Category: Java 2D Example

With this code we will study how text is drawn on a any image.

 
by Dinesh Thakur Category: Java 2D Example

Draw a straight line is one of the easiest things to do with Java2D. This is achieved through the Line2D class, whose constructor accepts four parameters, namely the coordinates of the start and end respectively.

 
by Dinesh Thakur Category: Java 2D Example

The ellipses or ovals are drawn by Ellipse2D class.This requires you defined to be a rectangle enclosing the boundaries between the ellipse.There the concept of a circle, so that it must be obtained by an ellipse enclosed in a square.

 
by Dinesh Thakur Category: Java 2D Example

This code can be seen as built a clipping path with the content of the text area of the word "Java " located in the middle of the window.In the drawn area can be seen as the image is painted behind the chain. As seen, the effect is very colorful and easy to perform.

 
by Dinesh Thakur Category: Java 2D Example

The class allows Arc2D draw an arc of an ellipse or a circle. For this, first the rectangle that contains the ellipse whose arc you want to draw is defined ; then assuming that the center of the rectangle sets the point (0,0) of a Cartesian coordinate axis , the angles start and end are specified the arc in degrees . Finally , indicate whether you want to close the bow joining ends or not. This closure can be of three types :

 
by Dinesh Thakur Category: Java 2D Example

much more powerful mechanism for drawing text is provided  the TextLayout class.This class not only allows you to draw text in a similar way  to as was done be fore but also provides a number of methods that  let youk now what is specific to draw features.

 

Page 1 of 2

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Search Content