Colour coding


The following show the components of a real chunk of code, namely:

comments
import statements
class declaration and brackets
instance variables
method declaration and brackets
return statements
method variables
if-statements and brackets
for-loops and brackets

/**
* --Copyright notice--
*
* Copyright (c) School of Geography, University of Leeds.
* http://www.geog.leeds.ac.uk/
* This software is licensed under 'The Artistic License' which can be found at
* the Open Source Initiative website at...
* http://www.opensource.org/licenses/artistic-license.php
* Please note that the optional Clause 8 does not apply to this code.
*
* The Standard Version source code, and associated documentation can be found at...
* [online] http://mass.leeds.ac.uk/
*
*
* --End of Copyright notice--
*
*/


import java.awt.image.*;
import java.awt.*;


/**
* Holds data as a raster.
* @version 1.0
* @author <A href="http://www.geog.leeds.ac.uk/people/a.evans/">Andy Evans</A>
*/

public class Storage {

   /** Width of environment. */
   private int width = 300;

   /** Height of environment. */
   private int height = 200;



   /**
   * Gets the width, as one might expect.
   * @return current environment width
   */
   public int getWidth() {
      return width;
   }



   /**
   * Gets the height, as one might expect.
   * @return current environment height
   */
   public int getHeight() {
      return height;
   }



   /**
   * Method to find the rerange data in the data array.
   * @param newMinimum new minimum for range
   * @param newMaximum new maximum for range
   * @return reranged data
   */
   double[][] getRerangedData (double newMinimum, double newMaximum) {

      double currentMaximum = 1000;
      double currentMinimum = 1;

      double[][] tempArray = new double[data.length][data[0].length];

      if ((currentMaximum - currentMinimum) == 0.0) {
         return tempArray;
      }

      for (int i = 0; i < getHeight(); i++) {
         for (int j = 0; j < getWidth(); j++) {
            tempArray[i][j] = data[i][j];
            tempArray[i][j] = tempArray[i][j] - currentMinimum;
            tempArray[i][j] = tempArray[i][j] / (currentMaximum - currentMinimum);
            tempArray[i][j] = tempArray[i][j] * (newMaximum - newMinimum);
            tempArray[i][j] = tempArray[i][j] + newMinimum;
         }
      }

      return tempArray;

   }

}