import java.awt.*;
import javax.swing.*;

class Database {
  final int maxnp = 10000;
  final int PtSize = 5;
  int[] x = new int[maxnp];
  int[] y = new int[maxnp];
  Color [] pointColors = new Color[maxnp];

  int np;
  int xsiz, ysiz;
  Color col;
  boolean lockflag = false;

  public Database(int xSize, int ySize, Color Col) {
    xsiz = xSize;
    ysiz = ySize;
    col = Col;
    np = 0;
  }
  
  public void paint(Graphics g) {
    	g.setColor(col);
    	for(int i = 0; i < np; i++) {
      	if (pointColors[i] != null) g.setColor(pointColors[i]);  
	    	g.fillRect(x[i]-PtSize/2,y[i]-PtSize/2,PtSize,PtSize);
    	} 
  }

  public void paint(Graphics g, Color [] _pointColors) {
     	for(int i = 0; i < np; i++) {
      	g.setColor(_pointColors[i]);
		g.fillRect(x[i]-PtSize/2,y[i]-PtSize/2,PtSize,PtSize);
    	} 
  }

  public void push(int newx, int newy) {
    if(np < maxnp) {
      x[np] = newx;
      y[np] = newy;
      np++;
    }
  }

  public void push(int newx, int newy, Color _newColor) {
    if(np < maxnp) {
      x[np] = newx;
      y[np] = newy;
	pointColors[np] = _newColor;
      np++;
    }
  }

  public void clearPoints() {
    np = 0;
  }

  public void randomPoints(int n) {
    for(int i = 0; i < n; i++)
      push((int) (xsiz * Math.random()), (int) (ysiz * Math.random()), col);
  }

  public int nPoints() {
    return np;
  }

  public int xVal(int i) {
    return x[i];
  }

  public int yVal(int i) {
    return y[i];
  }

  public Color getPointColor(int i) {
    return pointColors[i];
  }
 
  public void setPointColor(int i, Color _newColor) {
    pointColors[i] = _newColor;
  }

}
