public void paintComponent(Graphics g) {
		//clears graph.
		g.setColor(Color.gray);
		g.fillRect(0,0,width,height);
		
		//draws grid.
		g.setColor(new Color(230, 230, 230));//greyish
		if (restrictedRange) {
			yStart = (int)(yAxisLoc-(scale*range1));
			yEnd = (int)(yAxisLoc+(scale*range2));
		} else {
			yStart = yAxisLoc%scale;//to line up the x axis with the background grid.
			yEnd = height;
		}
		
		//clears graphing area.
		g.setColor(Color.white);
		g.fillRect(0, yStart, width, yEnd-yStart);
		
		g.setColor(new Color(230, 230, 230));//greyish
		for (int x = 0;x <= width;x+=scale)
			g.drawLine(x+xAxisLoc%scale, yStart, x+xAxisLoc%scale, yEnd);
		for (int y = yStart;y <= yEnd;y+=scale)
			g.drawLine(0, y, width, y);
		
		//draws x and y axis.
		g.setColor(Color.black);
		//g.drawLine(xAxisLoc, 0, xAxisLoc, height);//y axis.
		g.drawLine(0, yAxisLoc, width, yAxisLoc);//x axis.
		
		//draw points
		g.setColor(Color.red);
		for (int i = 0;i < points.length;i++) {
			int x = (int)(xAxisLoc+(points[i][0]*scale));
			int y = (int)(yAxisLoc-(points[i][1]*scale));
			//g.fillOval(x-scale/6, y-scale/6, scale/3, scale/3);//draws a dot at each point.
			if (i < points.length-1)
				g.drawLine(x, y, (int)(xAxisLoc+(points[i+1][0]*scale)), (int)(yAxisLoc-(points[i+1][1]*scale)));
		}
		
		//draws box next to mouse showing points.
		/*g.setColor(Color.black);
		double x = (xAxisLoc-mouseX)/(double)scale;
		double y = (yAxisLoc-mouseY)/(double)scale;
		g.drawString("("+round(x, 2) + ", ", mouseX, mouseY);
		g.drawString(round(y, 2)+")", mouseX+60, mouseY);*/
	}