# ArrayList Plotting Points

• October 18th, 2011, 03:10 PM
ArrayList Plotting Points
Hey Guys.. making a convex hull here with 100 random squares..or asterisks... but i wanted to first graph all of the radom points and start figuring out grahams scan algorithm by measuring the angles.

Any help?

Code :

```import java.awt.*; import java.util.ArrayList; import java.util.Random; import javax.swing.*;       public class Convex extends JFrame {   public static int WIDTH = 500; public static int HEIGHT = 500; public static int POINTS = 100;     public static void main (String [] args) { Random r = new Random(); ArrayList <Point> points = new ArrayList <Point>(); for ( int i = 0; i<POINTS; i++){ points.add(new Point(r.nextInt(WIDTH), r.nextInt(HEIGHT)));   }     // make the window     JFrame frame = new JFrame("Convex"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Graph g = new Graph(WIDTH, HEIGHT, POINTS);   frame.getContentPane().add(g); frame.pack(); frame.setVisible(true);   }         }```

Code :

```  import java.awt.Color; import java.awt.Graphics; import java.awt.Point;   import javax.swing.JPanel;   import java.awt.*; import java.util.ArrayList;   import javax.swing.*;   public class Graph extends JPanel {   public int WIDTH, HEIGHT, POINTS; public Color BACKGROUND = Color.WHITE; public Color POINTCOLOR = Color.blue;   public Graph(int i, int j, int p) { WIDTH = i; HEIGHT = j; POINTS = p;   setPreferredSize(new Dimension(i,j));   }         public void paintComponent(Graphics g) {   super.paintComponent(g); g.setColor(BACKGROUND); g.fillRect(0, 0, WIDTH, HEIGHT);       }       }```
• October 18th, 2011, 03:59 PM
copeg
Re: ArrayList Plotting Points
Quote:

Any help?
Help with what? Where are you stuck? I suggest you have a look at the Getting Help link in my signature