Drawing a Point
by, 03-06-2012 at 08:45 PM (490 Views)
Point class creates location presenting x,y coordinate space. Point class consist of these sub classes.
Double precision and float are provided by these given classes to store the point’s coordinates, respectively.
For creation of coordinate along with 0,0, default constructor Point 2D.Double can be used.Java Code://Create Point2D.Double Point2D.Double point = new Point2D.Double(x, y);
Point’s position is being set by using method setLocation, as it is given below.
- setLocation(double x, double y) –For setting the point defining coordinates location as double values.
- setLocation(Point2D p) –Coordinates of other point are used for setting up the point’s location.
These methods are supported by the point2D.
- Distance b/w point with coordinates & current point is calculated.
- Distance b/w 2 points are calculated.