Professional Documents
Culture Documents
package positioning;
import java.awt.*;
import javax.swing.*;
import java.util.List;
import java.util.*;
while((--count) >= 0)
{
i1 = intersection.get(count);
System.out.println(i1.getX1() + " " + i1.getY1() + " " + i1.getX2() + " " +
i1.getY2());
}
}
public void paintComponent(Graphics g)
{
super.paintComponent(g);
Graphics2D g2D = (Graphics2D)g;
Point p;
Points p1;
int x, y;
g2D.drawLine(0, 0, 570, 0);
g2D.drawLine(570, 0, 565, 5);
g2D.drawLine(0, 0, 0, 565);
g2D.drawLine(0, 565, 5, 560);
//To display the points in the 2D-Plane
for(int i = 0; i < list.size(); i++)
{
p = list.get(i);
x = (int)p.getX();
y = (int)p.getY();
g2D.fillOval(x, y, 4, 4);
g2D.drawOval(x-r, y-r, 2*r, 2*r);
}
//To find the intersection of the circles
for(int i = 0; i < intersection.size(); i++)
{
p1 = intersection.get(i);
g2D.setColor(Color.RED);
g2D.fillOval(p1.getX1(), p1.getY1(), 3, 3);
g2D.fillOval(p1.getX2(), p1.getY2(), 3, 3);
g2D.drawLine(p1.getX1(), p1.getY1(), p1.getX2(), p1.getY2());
}
}
public static void main(String args[])
{
getcoordinates();
getIntersectionPoints();
SwingUtilities.invokeLater(new Runnable() {
public void run()
{
JFrame f = new JFrame("POINTS PLOTTING");
f.getContentPane().add(new Positioning());
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(600, 600);
f.setVisible(true);
}
});
}
}
Points class
package positioning;
import java.awt.Point;
Points() {}
Points getPoint()
{
return this;
}
int getX1()
{
return this.x1;
}
int getX2()
{
return this.x2;
}
int getY1()
{
return this.y1;
}
int getY2()
{
return this.y2;
}
}