tileWidth = Math.round((width / TILE_SIZE) + 0.5f); tileHeight = Math.round((height / TILE_SIZE) + 0.5f);  tiles = new Tile[tileWidth * tileHeight];  MAX_RESIDENT_TILES = settings.getIntegerProperty("tilecache.maxtiles"); String pathToCache = settings.getStringProperty("tilecache.location");  try { tempFile = File.createTempFile( "evolvoCache" + this.hashCode(), null, new File(pathToCache)); } catch (IOException ioe) { System.err.println("Could not create temporary file:"); ioe.printStackTrace(); }  tempFile.deleteOnExit();  try { file = new RandomAccessFile(tempFile, "rw"); } catch (FileNotFoundException fnfe) { System.err.println("Cache file not found."); }    try { file.setLength((tileWidth * tileHeight) * (TILE_SIZE * TILE_SIZE) * 3); } catch (IOException ioe) { System.err.println("Could not set file length: "); ioe.printStackTrace(); }  int foffset = 0; int foffset_inc = 3 * TILE_SIZE * TILE_SIZE;  int yoffset;  for (int tiley = 0; tiley < tileHeight; tiley++) { yoffset = tiley * tileWidth;  for (int tilex = 0; tilex < tileWidth; tilex++) { tiles[yoffset + tilex] = new Tile(tilex, tiley, file, foffset); foffset += foffset_inc; } }  this.source = source;
raster = new TiledRaster(width, height); cm = new DirectColorModel(24, 0xFF0000, 0xFF00, 0xFF, 0x0);
   public TiledImage(int width, int height, ImageProducer source)   {      this.width = width;      this.height = height;      tileWidth = Math.round((width / TILE_SIZE) + 0.5f);      tileHeight = Math.round((height / TILE_SIZE) + 0.5f);      tiles = new Tile[tileWidth * tileHeight];      MAX_RESIDENT_TILES = settings.getIntegerProperty("tilecache.maxtiles");      String pathToCache = settings.getStringProperty("tilecache.location");      try      {         tempFile =            File.createTempFile(               "evolvoCache" + this.hashCode(),               null,               new File(pathToCache));      }      catch (IOException ioe)      {         System.err.println("Could not create temporary file:");         ioe.printStackTrace();      }      tempFile.deleteOnExit();      try      {         file = new RandomAccessFile(tempFile, "rw");      }      catch (FileNotFoundException fnfe)      {         System.err.println("Cache file not found.");      }      // grow the file large enough to hold the entire image      // the image is 3 bytes per pixel, made up of tileWidth * tileHeight tiles, each of which contains TILE_SIZE x TILE_SIZE pixels      try      {         file.setLength((tileWidth * tileHeight) * (TILE_SIZE * TILE_SIZE) * 3);      }      catch (IOException ioe)      {         System.err.println("Could not set file length: ");         ioe.printStackTrace();      }      int foffset = 0;      int foffset_inc = 3 * TILE_SIZE * TILE_SIZE;      // each tile takes 3 * TILE_SIZExTILE_SIZE bytes      int yoffset;      for (int tiley = 0; tiley < tileHeight; tiley++)      {         yoffset = tiley * tileWidth;         for (int tilex = 0; tilex < tileWidth; tilex++)         {            tiles[yoffset + tilex] = new Tile(tilex, tiley, file, foffset);            foffset += foffset_inc;         }      }      this.source = source;   }