One of the earlier programs I wrote, all it does is graph equations.

read more

equationGrapher.java

			
public class equationGrapher {

	/**
	 * @param args
	 * @throws InterruptedException 
	 */
	public static void main(String[] args) throws InterruptedException {
		// TODO Auto-generated method stub

		int [] xCoordinates = new int[5000];
		int [] yCoordinates = new int[5000];
		int y;
		int pointCounter=0;
		grapher function = new grapher();
		function.intWindowGenerator();
		function.getDotSize(1);
		function.getAxisLocation(true, 0);
		
		for(int a=1; a<10; a++){
			
		

			for(int i=-250;i<250;i++){
				y=a*(i);
				
			
				xCoordinates[pointCounter]=i;
				yCoordinates[pointCounter]=y;
				pointCounter++;
				
			}
			function.inputIntPoints(xCoordinates, yCoordinates);
	//		Thread.sleep(1000);
		}
		
	}
	}

grapher.java

import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.util.Scanner;
import javax.swing.JSlider;
import javax.swing.JFrame;
import javax.swing.JPanel;

@SuppressWarnings("serial")
public class grapher extends JFrame implements ActionListener {

	public pointCreatorDouble doubleInstance = new pointCreatorDouble();
	public JFrame window = new JFrame();
	public pointCreatorInt intInstance = new pointCreatorInt();
	public Scanner scan = new Scanner(System.in);
	double[] xCoordinates;
	double[] yCoordinates;
	int[] xIntCoordinates;
	int[] yIntCoordinates;
	boolean axisDraw;
	double xMin;
	double xMax;
	double yMin;
	double yMax;
	int dotSize;
	int numberOfPoints;
	boolean hasPoints = false;

	public void doubleWindowGenerator() {

		window.setSize(1000, 10000);
		window.setVisible(true);
		window.add(doubleInstance);
	}

	public void intWindowGenerator(){
		window.setSize(1000, 10000);
		window.setVisible(true);
		window.add(intInstance);
		
		
	}

	public void inputDoublePoints(double xs[], double ys[]) {
		// This is taking application specific data and allows any local method
		// to access it
		xCoordinates = xs;
		yCoordinates = ys;
		numberOfPoints = xs.length;
		hasPoints = true;
		repaint();
	}

	public void inputIntPoints(int xs[], int ys[]) {
		xIntCoordinates = xs;
		yIntCoordinates = ys;
		numberOfPoints = xs.length;
		hasPoints = true;
		repaint();
	}

	public void getDotSize(int size) {
		dotSize = size;
		repaint();
	}


	public void setCoordinatePlane(double xmin, double xmax, double ymin,
			double ymax) {
		// This is taking application specific data and allows any local method
		// to access it
		xMin = xmin;
		xMax = xmax;
		yMin = ymin;
		yMax = ymax;
		repaint();

	}

	public void getAxisLocation(boolean axis, int quadrant){
		if (axis){
			axisDraw=true;
		}
		if(quadrant==0){
			
		}
		if(quadrant==1){
			
		}
		
	}
	
	public double evaluateAtPoint(double a, double x){
		return(Math.pow(a, x));
	}

	public int getYPixCoord(double yCoord) {
		return (int) (yMax/2+getHeight() - ((yCoord - yMin) * getHeight() / (yMax - yMin)));
	}

	public int getXPixCoord(double xCoord) {
		return (int) (+(xMax/2)+(xCoord - xMin) * getHeight() / (xMax - xMin));
	}

	public double getXCoord(int xPixCoord) {
		return xMin + (xPixCoord) * (xMax - xMin) / getWidth();
	}

	public double getYCoord(int yPixCoord) {
		return yMax - (yPixCoord) * (yMax - yMin) / getHeight();
	}

	public class pointCreatorDouble extends JPanel {
		public void paintComponent(Graphics g) {
			if (hasPoints) {

				for (int i = 0; i < xCoordinates.length; i++) {
					int pixX = getXPixCoord(xCoordinates[i]);
					int pixY = getYPixCoord(yCoordinates[i]);
					if (pixX >= 0 && pixY >= 0 && pixX < getWidth()
							&& pixY < getHeight()) {
						g.fillRect(pixX, pixY, dotSize, dotSize);
					}
				}
			}
		}

	}

	public class pointCreatorInt extends JPanel {
		public void paintComponent(Graphics g) {
			System.out.println("in here");
			if(axisDraw){
				g.drawLine(getWidth()/2, 0, getWidth()/2, getHeight());
				g.drawLine(0, getHeight()/2, getWidth(), getHeight()/2);
			}
			if(hasPoints&&axisDraw){
				for (int i = 0; i < xIntCoordinates.length; i++) {
					g.fillRect(xIntCoordinates[i]+(getWidth()/2), (-1)*
							(yIntCoordinates[i])+getHeight()/2, dotSize,
							dotSize);
			}
			if (hasPoints&&axisDraw==false) {
				for (int i = 0; i < xIntCoordinates.length; i++) {
					g.fillRect(xIntCoordinates[i], getHeight()-yIntCoordinates[i], dotSize,
							dotSize);
				}
			}
		}
	}
	}
	


	public String setTitle() {
		String name;
		System.out.println("What would you like your window to be named?");
		name = scan.nextLine();
		return name;

	}

	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub

	}

}