Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: ArrayList Plotting Points

  1. #1
    Junior Member
    Join Date
    Dec 2010
    Thanked 0 Times in 0 Posts

    Default 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?

    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");
    		Graph g = new Graph(WIDTH, HEIGHT, POINTS);

    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)
    		g.fillRect(0, 0, WIDTH, HEIGHT);

  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Thanked 827 Times in 770 Posts
    Blog Entries

    Default Re: ArrayList Plotting Points

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

Similar Threads

  1. Plotting updated graph continuously
    By sudhan in forum Java Theory & Questions
    Replies: 0
    Last Post: October 17th, 2011, 09:28 PM
  2. I like plotting points :) HI!
    By fractalorbit in forum Member Introductions
    Replies: 1
    Last Post: September 5th, 2011, 10:49 AM
  3. Getting all points in line
    By Mike in forum Java Theory & Questions
    Replies: 7
    Last Post: September 13th, 2010, 11:59 AM
  4. Plotting w/JFreeCharts
    By Javajava in forum What's Wrong With My Code?
    Replies: 0
    Last Post: May 12th, 2010, 10:02 AM
  5. Creating a class for points in three dimensions.
    By joachim89 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: January 8th, 2010, 06:13 PM