private void calcLevels() {
		int i;
		if (!autoLevels)
			return;

		if (levels == null)
			levels = new double[NLEVELS];

		zrange();

		if (logLevels) {
			double inc = Math.log(zmax - zmin) / (levels.length + 1);
			try {
				for (i = 0; i < levels.length; i++)
					levels[i] = zmin + Math.exp((i + 1) * inc);
			}
			catch (Exception e) {
				System.out.println("Error calculateing Log levels!");
				System.out.println("... calculating linear levels instead");
				logLevels = false;
				calcLevels();
			}
		}
		else if (expLevels) {
			double inc = Math.exp(zmax - zmin) / (levels.length + 1);
			for (i = 0; i < levels.length; i++)
				levels[i] = zmin + Math.log((i + 1) * inc);
		}
		else {
			double inc = (zmax - zmin) / (levels.length + 1);
			for (i = 0; i < levels.length; i++)
				levels[i] = zmin + (i + 1) * inc;
		}

	}