public static void drawDottedLine(Graphics g, int fromX, int fromY, int toX, int toY) {
		int dx = toX - fromX;
		int dy = toY - fromY;
		if(dx == 0 && dy == 0) {
			return;
		}
		boolean swapped = false;
		if(Math.abs(dx) < Math.abs(dy)) {
			int temp = fromX; fromX = fromY; fromY = temp;
			temp = toX; toX = toY; toY = temp;
			temp = dy; dy = dx; dx = temp;
			swapped = true;
		}
		if(dx < 0) { // swap 'from' and 'to' 
			int temp = fromX; fromX = toX; toX = temp;
			temp = fromY; fromY = toY; toY = temp;
			dx = -dx; dy = -dy;
		}
		double delta = ((double) dy) / dx;
		boolean paint = true;
		for(int i=0; i<= dx; i++) {
			int y = fromY + (int) (i * delta);
			if(paint) {
				if(swapped) {
					g.fillRect(y, i+fromX, 1, 1); // only a single dot
				} else {
					g.fillRect(i+fromX, y, 1, 1); // only a single dot
				}
			}
			paint = !paint;
		}
	}