Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/resources/META-INF/services/org.gvsig.tools.library.Library	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/resources/META-INF/services/org.gvsig.tools.library.Library	(revision 3222)
@@ -0,0 +1 @@
+org.gvsig.raster.cache.tile.TileCacheLibrary
\ No newline at end of file
Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/pool/TilePipe.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/pool/TilePipe.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/pool/TilePipe.java	(revision 3222)
@@ -0,0 +1,56 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.tile.pool;
+
+
+/**
+ * This class manages transactions between the producer and the consumer. The
+ * producer download tiles from a server and the consumer is a tile provider
+ * which will return downloaded tiles.
+ *
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public interface TilePipe {
+	
+	/**
+	 * Sets a tile in the pipe
+	 * @param tile
+	 */
+	public void setAtomicTask(AtomicTask tile);
+
+	/**
+	 * Gets a tile from the pipe
+	 * @return
+	 */
+	public AtomicTask getAtomicTask();
+	
+	/**
+	 * Returns the number of elements in the queue
+	 * @return
+	 */
+	public int getSize();
+	
+	/**
+	 * Cleans the queue
+	 */
+	public void clear();
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/pool/TilePipe.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/pool/package.html
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/pool/package.html	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/pool/package.html	(revision 3222)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<title>org.gvsig.raster.cache.tile.pool package documentation</title>
+</head>
+<body>
+
+	<p>API to build a pool of threads of tasks</p>
+	
+	<p>
+	</p>
+
+</body>
+</html>
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/pool/package.html
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/pool/AtomicTask.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/pool/AtomicTask.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/pool/AtomicTask.java	(revision 3222)
@@ -0,0 +1,46 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.tile.pool;
+
+/**
+ * Task with priorities
+ *
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public interface AtomicTask extends Runnable, Comparable<AtomicTask> {
+	/**
+	 * Gets the priority of this task
+	 * @return
+	 */
+	public int getPriority();
+	
+	/**
+	 * Sets the priority of this task
+	 * @param priority
+	 */
+	public void setPriority(int priority);
+	
+	/**
+	 * Cancels this current task
+	 */
+	public void cancelTask();
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/pool/AtomicTask.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/pool/ThreadPool.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/pool/ThreadPool.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/pool/ThreadPool.java	(revision 3222)
@@ -0,0 +1,57 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.tile.pool;
+
+import java.util.LinkedList;
+
+
+/**
+ * Pool of threads. This class contains a list of tasks and a limited number
+ * of threads to execute them. When a thread is free will execute the next task 
+ * in the list. 
+ *
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public interface ThreadPool {
+	/**
+	 * Stops all threads in the list and sets the list to null
+	 */
+	public void destroyPool();
+
+	/**
+	 * Adds a new task to the list
+	 * @param task
+	 */
+	public void addTask(AtomicTask task);
+	
+	/**
+	 * Gets the list of input tasks
+	 * @return
+	 */
+	public LinkedList<AtomicTask> getInputTaskList();
+	
+	/**
+	 * Gets the list of output tiles
+	 * @return
+	 */
+	public TilePipe getTilePipe();
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/pool/ThreadPool.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/disk/ITileFileSystemStrategy.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/disk/ITileFileSystemStrategy.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/disk/ITileFileSystemStrategy.java	(revision 3222)
@@ -0,0 +1,67 @@
+/* TileRasterCache, a library to download tiles from several sources.
+ *
+ * Copyright (C) 2010 Prodevelop SL.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *  
+ *   Prodevelop Integraci�n de Tecnolog�as SL
+ *   Plaza don Juan de Vilarrasa , 14-5
+ *   46000 Valencia
+ *   Spain
+ *
+ *   +34 963 510 612
+ *   +34 963 510 968
+ *   gis@prodevelop.es
+ *   http://www.prodevelop.es
+ *   
+ *   author: Alberto Romeu Carrasco (aromeu@prodevelop.es)
+ */
+
+package org.gvsig.raster.cache.tile.disk;
+
+/**
+ * This interface allows to save/load tiles attending to different strategies, this means
+ * the way the tiles are stored on disk, using a quadkey, flat zoom level, etc.
+ *  
+ * @author aromeu
+ *
+ */
+public interface ITileFileSystemStrategy {
+	
+	public static final String FLATX = "flatx";
+	public static final String QUADKEY = "quadkey";
+	
+	/**
+	 * The relative path of the tile on disk
+	 * @param row 
+	 *        Row of the tile
+	 * @param col
+	 *        Column of the tile
+	 * @param zoomLevel 
+	 *        The zoom level
+	 * @param var
+	 *        Variable which is represented in this cache structure. This is useful for netcdf and other
+	 *        multidimensional formats
+	 * @param z
+	 *        Level of deep in the raster layer. This is useful for multidimensional formats
+	 * @param time
+	 *        A format which supports 4D needs to store different time moments y different directories
+	 * @return The path to append to the absolute path of the layer on disk
+	 */
+	public String getRelativeToLayerDirTilePath(int row, int col, int zoomLevel,
+			String var, String z, String time);
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/disk/ITileFileSystemStrategy.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/disk/package.html
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/disk/package.html	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/disk/package.html	(revision 3222)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<title>org.gvsig.raster.cache.tile.disk package documentation</title>
+</head>
+<body>
+
+	<p>Strategies to store tiles in disk</p>
+	
+	<p>
+	</p>
+
+</body>
+</html>
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/disk/package.html
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/provider/TileListener.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/provider/TileListener.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/provider/TileListener.java	(revision 3222)
@@ -0,0 +1,51 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.tile.provider;
+
+import org.gvsig.raster.cache.tile.Tile;
+import org.gvsig.raster.cache.tile.exception.TileGettingException;
+
+/**
+ * This interface will receive events when a new tile arrives. When the last tile is
+ * received then endReading will be called.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public interface TileListener {
+	
+	/**
+	 * A new tile is received
+	 * @param loadedTile 
+	 */
+	public void tileReady(Tile loadedTile) throws TileGettingException ;
+	
+	/**
+	 * The last tile is received
+	 */
+	public void endReading();
+	
+	/**
+	 * Returns true if the endReading wasn't be called yet
+	 */
+	public boolean isReading();
+
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/provider/TileListener.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/provider/TileServer.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/provider/TileServer.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/provider/TileServer.java	(revision 3222)
@@ -0,0 +1,64 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.tile.provider;
+
+
+
+
+/**
+ * This interface have to be implemented by a data provider. This will report
+ * the structure of its layers 
+ *
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public interface TileServer {
+	/**
+	 * Gets the cache structure
+	 * @return
+	 */
+	public CacheStruct getStruct();
+	
+	/**
+	 * Sets the cache structure. It builds the Downloader with the 
+	 * new structure.
+	 * @param struct
+	 */
+	public void setStruct(CacheStruct struct);
+	
+	/**
+	 * Gets the tile server
+	 * @return
+	 */
+	public Downloader getDownloader();
+	
+	/**
+	 * Gets the file extension to save tiles
+	 * @return
+	 */
+	public String getFileSuffix();
+	
+	/**
+	 * Assigns the extension of the output file
+	 * @param extension
+	 */
+	public void setFileSuffix(String extension);
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/provider/TileServer.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/provider/CacheStruct.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/provider/CacheStruct.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/provider/CacheStruct.java	(revision 3222)
@@ -0,0 +1,207 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.tile.provider;
+
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.util.List;
+
+import org.gvsig.raster.cache.tile.Tile;
+import org.gvsig.raster.cache.tile.exception.TileBuildException;
+
+/**
+ * Structure of a cache service
+ *
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public interface CacheStruct {
+	public static int    GEOGRAFIC   = 0;
+	public static int    FLAT        = 1;
+	
+	/**
+	 * Gets the number of resolution levels
+	 * @return
+	 */
+	public int getNumberOfLevels();
+	
+	/**
+	 * Gets the number of columns in a specific level
+	 * @param level
+	 * @return
+	 */
+	public long getWorldWidthOfTileMatrixByLevel(int level);
+	
+	/**
+	 * Gets the number of rows in a specific level
+	 * @param level
+	 * @return
+	 */
+	public long getWorldHeightOfTileMatrixByLevel(int level);
+	
+	/**
+	 * Gets the number of columns in a specific level
+	 * @param level
+	 * @return
+	 */
+	public int getLayerWidthOfTileMatrixByLevel(int level);
+	
+	/**
+	 * Gets the number of rows in a specific level
+	 * @param level
+	 * @return
+	 */
+	public int getLayerHeightOfTileMatrixByLevel(int level);
+	
+	/**
+	 * Gets the starting X position of the layer
+	 * @param level
+	 * @return
+	 */
+	public int getLayerInitXTilePositionByLevel(int level);
+	
+	/**
+	 * Gets the starting Y position of the layer
+	 * @param level
+	 * @return
+	 */
+	public int getLayerInitYTilePositionByLevel(int level);
+	
+	/**
+	 * Gets the tile size 
+	 * @param level
+	 * @return an array of two elements. The first element is the width in pixels and
+	 * the second the height.
+	 */
+	public int[] getTileSizeByLevel(int level);
+	
+	/**
+	 * Gets the tile size by level in world coordinates
+	 * @param level
+	 * @return width x height 
+	 */
+	public double[] getTileSizeInRealCoordsByLevel(int level);
+	
+	/**
+	 * Gets the pixel size of a level
+	 * @param level
+	 * @return
+	 */
+	public double getPixelSizeByLevel(int level);
+	
+	/**
+	 * Gets the extent of a tile
+	 * @param level
+	 * @param x
+	 * @param y
+	 * @return
+	 */
+	public Point2D[] getTileExtent(Tile tile);
+	
+	/**
+	 * Get the extent of an matrix element in a specific level
+	 * @param level
+	 * @param col
+	 * @param row
+	 * @return
+	 */
+	public Point2D[] getTileExtent(int level, int col, int row);
+	
+	/**
+	 * Builds a tile structure with all parameters that this kind of service needs. 
+	 * @param level
+	 * @param tileCol
+	 * @param tileRow
+	 * @return
+	 */
+	public Tile getTileStructure(int level, int tileCol, int tileRow, Point2D ul, Point2D lr) throws TileBuildException ;
+	
+	/**
+	 * Gets the list of tiles inside of selected area in pixels. This method is only valid
+	 * for the real level. Don't use with levels of resolution.
+	 * @param r
+	 * @return
+	 */
+	public List<Tile> getTileList(Rectangle2D r);
+	
+	/**
+	 * Gets the list of tiles inside of selected area
+	 * @param ul
+	 * @param lr
+	 * @param mtsPixelRequest
+	 * @return
+	 * @throws TileBuildException 
+	 */
+	public List<Tile> getTileList(Point2D ul, Point2D lr, double mtsPixelRequest) throws TileBuildException;
+	
+	/**
+	 * Gets the list of tiles inside of selected area
+	 * @param ul
+	 * @param lr
+	 * @param mtsPixelRequest
+	 * @param increaseResolution
+	 *        Set to true to get a level of resolution greater than the correct. 
+	 *        For the same area, we will get more tiles and won't improve the 
+	 *        quality because they will be rescaled in the drawn. In request 
+	 *        to remote services can be useful because it will give a better 
+	 *        level of detail.  
+	 * @return
+	 * @throws TileBuildException 
+	 */
+	//public List<Tile> getTileList(Point2D ul, Point2D lr, double mtsPixelRequest, boolean increaseResolution) throws TileBuildException;
+	
+	/**
+	 * Gets the layer name
+	 * @return
+	 */
+	public String getLayerName();
+	
+	/**
+	 * Gets the server URL
+	 * @return
+	 */
+	public String getServerURL();
+
+	/**
+	 * Gets the suffix which represents the image format
+	 * @return
+	 */
+	public String getFileSuffix();
+	
+	/**
+	 * Gets the EPSG code
+	 * @return
+	 */
+	public String getEPSG();
+	
+	/**
+	 * If the source is a file gets the size or 0 if is not a file
+	 * @return
+	 */
+	public String getFileSize();
+	
+	/**
+	 * Compares two structures and returns true if they are equals
+	 * @param struct
+	 * @return
+	 */
+	public boolean compare(CacheStruct struct);
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/provider/CacheStruct.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/provider/Downloader.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/provider/Downloader.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/provider/Downloader.java	(revision 3222)
@@ -0,0 +1,66 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.tile.provider;
+
+import org.gvsig.raster.cache.tile.Tile;
+import org.gvsig.raster.cache.tile.exception.TileGettingException;
+
+/**
+ * Tile cache uses this interface to get a tile and the data provider have to implement
+ * it to serve tiles.
+ *
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public interface Downloader {
+	
+	/**
+	 * Gets a tile from the data source. The parameter tile contains 
+	 * the information of the tile to download. If the provider is a remote
+	 * service this will have to download the tile from the server and if it 
+	 * is a file provider the source will be a file.
+	 * @param tile Tile information
+	 * @param param Additional parameter
+	 * @return Tile loaded
+	 */
+	public Tile downloadTile(Tile tile) throws TileGettingException;
+	
+	/**
+	 * Reads a tile from the tile cache. The path to the tile is in the Tile
+	 * object
+	 * @param tile
+	 * @return
+	 * @throws TileGettingException
+	 */
+	public Tile readTileFromDisk(Tile tile) throws TileGettingException;
+	
+	/**
+	 * Gets the image that represent a tile while is downloading
+	 * @return
+	 */
+	public Object[] getDownloadingImage(int w, int h);
+	
+	/**
+	 * Gets the image that represent a crash tile
+	 * @return
+	 */
+	public Object[] getCrashImage(int w, int h);
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/provider/Downloader.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/provider/package.html
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/provider/package.html	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/provider/package.html	(revision 3222)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<title>org.gvsig.raster.cache.tile.provider package documentation</title>
+</head>
+<body>
+
+	<p>Cache structures</p>
+	
+	<p>
+	</p>
+
+</body>
+</html>
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/provider/package.html
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/TileCacheManager.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/TileCacheManager.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/TileCacheManager.java	(revision 3222)
@@ -0,0 +1,159 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.tile;
+
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+
+import org.gvsig.raster.cache.tile.pool.ThreadPool;
+import org.gvsig.raster.cache.tile.provider.CacheStruct;
+
+
+
+/**
+ * This class is responsible of the management of the library's business logic.
+ * It is the library's main entry point, and provides all the services to manage
+ * {@link TileCacheService}s.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ * @version $Id$
+ */
+public interface TileCacheManager {
+	/**
+	 * Builds a new entry point for a tile cache. The parameter is an identifier for a 
+	 * tile cache structured implemented inside of this library
+	 * @param baseDir
+	 * @return
+	 */
+	public TileCache getTileCache(String baseDir);
+	
+	/**
+	 * Creates a new tile structure
+	 * @param level
+	 * @param col
+	 *        Tile column
+	 * @param row
+	 *        Tile row
+	 * @return
+	 */
+	public Tile createTile(int level, int col, int row);
+	
+	/**
+	 * Creates a new tile structure
+	 * @param wPx
+	 *        Width in pixels
+	 * @param hPx
+	 *        Height in pixels
+	 * @param row
+	 *        Tile row
+	 * @param col
+	 *        Tile column
+	 * @param ul
+	 *        Upper left coordinate
+	 * @param lr
+	 *        Lower roght coordinate 
+	 * @return
+	 */
+	public Tile createTile(int wPx, int hPx, int row, int col, Point2D ul, Point2D lr);
+	
+	/**
+	 * Builds a standard cache structure 
+	 * @param typeOfCoords Constant defined in CacheStruct interface
+	 * @param levels Number of levels
+	 * @param layerExtent Bounding box of the layer
+	 * @param pixelSize Pixel size of the layer
+	 * @param tilePxWidth Width in pixels of a tile
+	 * @param tilePxHeight Height in pixels of a tile
+	 * @param uri server URL
+	 * @param layerName Layer name or identifier
+	 * @param strategy Strategy to store tiles in disk
+	 * @param baseDir path to this layer
+	 * @param fileSuffix File suffix
+	 * @param epsg 
+	 * @return
+	 */
+	public CacheStruct createCacheStructure(int typeOfCoords, 
+    		int levels, 
+    		Rectangle2D layerExtent, 
+    		double pixelSize,
+    		int tilePxWidth,
+    		int tilePxHeight,
+    		String uri,
+    		String layerName,
+    		String strategy,
+    		String baseDir,
+    		String fileSuffix,
+    		String epsg,
+    		long fileSize);
+	
+	/**
+	 * Builds a standard cache structure for local files
+	 * @param typeOfCoords Constant defined in CacheStruct interface
+	 * @param levels Number of levels
+	 * @param layerExtent Bounding box of the layer
+	 * @param pixelSize Pixel size of the layer
+	 * @param tilePxWidth Width in pixels of a tile
+	 * @param tilePxHeight Height in pixels of a tile
+	 * @param layerName Layer name or identifier
+	 * @param strategy Strategy to store tiles in disk
+	 * @param baseDir path to this layer
+	 * @param fileSuffix File suffix
+	 * @param epsg 
+	 * @return
+	 */
+	public CacheStruct createCacheStructure(int typeOfCoords, 
+    		int levels, 
+    		Rectangle2D layerExtent, 
+    		double pixelSize,
+    		int tilePxWidth,
+    		int tilePxHeight,
+    		String layerName,
+    		String strategy,
+    		String baseDir,
+    		String fileSuffix,
+    		String epsg,
+    		long fileSize);
+	
+	/**
+	 * Builds a new thread pool. This pool will use five threads by default
+	 * @return
+	 */
+	public ThreadPool createThreadPool(boolean priorityActive);
+	
+	/**
+	 * Builds a new thread pool selecting the number of threads
+	 * @return
+	 */
+	public ThreadPool createThreadPool(boolean priorityActive, int nThreads);
+	
+	/**
+	 * Sets the time out in milliseconds
+	 * @param ms
+	 */
+	public void setTileTimeOut(int ms);
+	
+	/**
+	 * Gets the time out in milliseconds
+	 * @return
+	 */
+	public int getTileTimeOut();
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/TileCacheManager.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/layer/TiledLayer.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/layer/TiledLayer.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/layer/TiledLayer.java	(revision 3222)
@@ -0,0 +1,73 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.tile.layer;
+
+import java.util.List;
+
+import org.gvsig.raster.cache.tile.Tile;
+import org.gvsig.raster.cache.tile.exception.TileGettingException;
+import org.gvsig.raster.cache.tile.provider.TileListener;
+import org.gvsig.tools.task.TaskStatus;
+
+/**
+ * API interface for a cached layer
+ *
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public interface TiledLayer {
+	
+	/**
+	 * Gets a tile
+	 * @param tile
+	 * @return
+	 * @throws TileGettingException 
+	 */
+	public Tile getTile(Tile tile) throws TileGettingException;
+	
+	/**
+	 * Gets a list of tiles
+	 * @param tiles
+	 * @param listener
+	 * @throws TileGettingException 
+	 */
+	public void getTiles(List<Tile> tiles, TileListener listener, TaskStatus status) throws TileGettingException;
+	
+	/**
+	 * Gets the base directory for this layer. This function builds an unique identifier
+	 * for a layer with a limited length.
+	 * @return
+	 */
+	public String getBaseLayerDirectory();
+	
+	/**
+	 * Returns the ID of this layer. 
+	 * The ID is the name of the directory where the tiles are stored.
+	 * @return
+	 */
+	public String getID();
+	
+	/**
+	 * Deletes the files of this layer 
+	 * @return Size of information that was deleted
+	 */
+	public long delete();
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/layer/TiledLayer.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/layer/package.html
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/layer/package.html	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/layer/package.html	(revision 3222)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<title>org.gvsig.raster.cache.tile.layer package documentation</title>
+</head>
+<body>
+
+	<p>Tile layer</p>
+	
+	<p>
+	</p>
+
+</body>
+</html>
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/layer/package.html
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/Tile.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/Tile.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/Tile.java	(revision 3222)
@@ -0,0 +1,298 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.tile;
+
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.io.File;
+
+import org.gvsig.raster.cache.tile.pool.AtomicTask;
+import org.gvsig.raster.cache.tile.pool.TilePipe;
+import org.gvsig.raster.cache.tile.provider.Downloader;
+import org.gvsig.compat.net.ICancellable;
+
+/**
+ * Tile structure for requests
+ *
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public interface Tile extends AtomicTask {
+	
+	/**
+	 * Gets the Variable that this tile belong to.This is useful when the source 
+	 * is a multidimensional container. If it is not then this variable will have
+	 * a default value. 
+	 * @return
+	 */
+	public String getVariable();
+	
+	/**
+	 * Gets the Z that this tile belong to. This is useful when the source 
+	 * is a multidimensional container. If it is not then this variable will have
+	 * a 0 value. 
+	 * @return
+	 */
+	public String getZ();
+	
+	/**
+	 * Gets the time instant that this tile belong to.This is useful when the source 
+	 * is a multidimensional container. If it is not then this variable will have
+	 * a 0 value. 
+	 * @return
+	 */
+	public String getTimeInstant();
+	
+	/**
+	 * Sets the Variable that this tile belong to.This is useful when the source 
+	 * is a multidimensional container. If it is not then this variable will have
+	 * a default value. 
+	 * @return
+	 */
+	public void setVariable(String var);
+	
+	/**
+	 * Sets the Z that this tile belong to. This is useful when the source 
+	 * is a multidimensional container. If it is not then this variable will have
+	 * a 0 value. 
+	 * @return
+	 */
+	public void setZ(String z);
+	
+	/**
+	 * Sets the time instant that this tile belong to.This is useful when the source 
+	 * is a multidimensional container. If it is not then this variable will have
+	 * a 0 value. 
+	 * @return
+	 */
+	public void setTimeInstant(String t);
+	
+	/**
+	 * Gets the column of this tile
+	 * @return
+	 */
+	public int getCol();
+	
+	/**
+	 * Gets the row of this tile
+	 * @return
+	 */
+	public int getRow();
+	
+	/**
+	 * Gets the resolution level of this tile
+	 * @return
+	 */
+	public int getLevel();
+	
+	/**
+	 * Sets the column of this tile in its level
+	 * @param col
+	 */
+	public void setCol(int col);
+	
+	/**
+	 * Sets the row of this tile in its level
+	 * @param col
+	 */
+	public void setRow(int row);
+	
+	/**
+	 * Sets the level of resolution of this tile
+	 * @param col
+	 */
+	public void setLevel(int level);
+	
+	/**
+	 * Gets the coordinates in pixels of this tile inside the layer.
+	 * This function is only for the real level. 
+	 * @return
+	 */
+	public Rectangle2D getCoordsPx();
+	
+	/**
+	 * Sets the coordinates ins pixels of this tile inside the layer.
+	 * This function is only for the real level.
+	 * @param r
+	 */
+	public void setCoordsPx(Rectangle2D r);
+	
+	/**
+	 * Gets the width in pixels of this tile
+	 * @return
+	 */
+	public int getWidthPx();
+
+	/**
+	 * Sets the width in pixels of this tile
+	 * @param widthPx
+	 */
+	public void setWidthPx(int widthPx);
+
+	/**
+	 * Gets the height in pixels of this tile
+	 * @return
+	 */
+	public int getHeightPx();
+
+	/**
+	 * Sets the height in pixels of this tile
+	 * @param heightPx
+	 */
+	public void setHeightPx(int heightPx);
+	
+	/**
+	 * Gets the bounding box
+	 * @return
+	 */
+	public Rectangle2D getExtent();
+
+	/**
+	 * Gets the upper left coordinate of this tile
+	 * @return
+	 */
+	public Point2D getUl();
+
+	/**
+	 * Sets the upper left coordinate of this tile
+	 * @return
+	 */
+	public void setUl(Point2D ul);
+
+	/**
+	 * Gets the lower right coordinate of this tile
+	 * @return
+	 */
+	public Point2D getLr();
+
+	/**
+	 * Sets the lower right coordinate of this tile
+	 * @return
+	 */
+	public void setLr(Point2D lr);
+
+	/**
+	 * Gets the file associated to this tile
+	 * @return
+	 */
+	public File getFile();
+
+	/**
+	 * Sets the file associated to this tile
+	 * @param file
+	 */
+	public void setFile(File file);
+	
+	/**
+	 * Gets an unique identifier to this tile
+	 * @return
+	 */
+	public String getId();
+	
+	/**
+	 * Gets the Downloader parameters
+	 * @return
+	 */
+	public Object getDownloaderParams(String key);
+
+	/**
+	 * Sets the Downloader parameters
+	 * @param downloaderParams
+	 */
+	public void setDownloaderParams(String key, Object downloaderParams);
+	
+	/**
+	 * Sets the data associated to this tile. In the most cases
+	 * will be only one element in the array of objects
+	 * @param data
+	 */
+	public void setData(Object[] data);
+	
+	/**
+	 * Gets the data associated to this tile. In the most cases
+	 * will be only one element in the array of objects
+	 * @return
+	 */
+	public Object[] getData();
+	
+	/**
+	 * Returns true if the buffer data is loaded
+	 * @return
+	 */
+	public boolean dataIsLoaded();	
+	
+	/**
+	 * Sets this flag to true if the data is corrupt
+	 * @param corrupt
+	 */
+	public void setCorrupt(boolean corrupt);
+	
+	/**
+	 * Returns true if the downloaded tile is corrupt, so this can't be sent to the client 
+	 * @return
+	 */
+	public boolean isCorrupt();
+	
+	/**
+	 * Sets the pipe of tiles
+	 * @param sharedPipe
+	 */
+	public void setSharedPipe(TilePipe sharedPipe);
+	
+	/**
+	 * Sets the downloader for this tile
+	 * @param downloader
+	 */
+	public void setDownloader(Downloader downloader);
+	
+	/**
+	 * Gets the image that represent a tile while is downloading
+	 * @return RGB image and an alpha band
+	 * @deprecated
+	 */
+	public Object[] getDownloadingImage();
+	
+	/**
+	 * Gets the image that represent a crash tile
+	 * @return RGB image and an alpha band
+	 * @deprecated
+	 */
+	public Object[] getCrashImage();
+	
+	/**
+	 * Gets the image that represent a tile while is downloading
+	 * @return ARGB image 
+	 */
+	public Object getDownloadingARGB();
+	
+	/**
+	 * Gets the image that represent a crash tile
+	 * @return ARGB image
+	 */
+	public Object getCrashARGB();
+	
+	/**
+	 * Returns true if downloading has been canceled. This is useful when a tile is taking
+	 * a lot of time. The task which will throw this action could cancel the process.
+	 * @return
+	 */
+	public ICancellable getCancelled();
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/Tile.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/exception/TileBuildException.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/exception/TileBuildException.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/exception/TileBuildException.java	(revision 3222)
@@ -0,0 +1,103 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.tile.exception;
+
+/**
+ * This exception is thrown when the pool of threads fails
+ *
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TileBuildException extends Exception {
+	private static final long serialVersionUID = 1L;
+	
+	String message;
+
+	public TileBuildException() {
+		super();
+	}
+
+	/**
+	 * Crea TileGettingException.
+	 *
+	 * @param message
+	 */
+	public TileBuildException(String message) {
+        super();
+        this.message = message;
+	}
+
+	/**
+	 * Crea TileGettingException.
+	 *
+	 * @param message
+	 * @param cause
+	 */
+	public TileBuildException(String message, Throwable cause) {
+		super(format(message, 200), cause);
+	}
+
+	/**
+	  * Crea TileGettingException.
+	 *
+	 * @param cause
+	 */
+	public TileBuildException(Throwable cause) {
+		super(cause);
+	}
+    
+    /**
+     * Cuts the message text to force its lines to be shorter or equal to 
+     * lineLength.
+     * @param message, the message.
+     * @param lineLength, the max line length in number of characters.
+     * @return the formated message.
+     */
+    private static String format(String message, int lineLength){
+        if (message.length() <= lineLength) return message;
+        String[] lines = message.split("\n");
+        String theMessage = "";
+        for (int i = 0; i < lines.length; i++) {
+            String line = lines[i].trim();
+            if (line.length()<lineLength)
+                theMessage += line+"\n";
+            else {
+                String[] chunks = line.split(" ");
+                String newLine = "";
+                for (int j = 0; j < chunks.length; j++) {
+                    int currentLength = newLine.length();
+                    chunks[j] = chunks[j].trim();
+                    if (chunks[j].length()==0)
+                        continue;
+                    if ((currentLength + chunks[j].length() + " ".length()) <= lineLength)
+                        newLine += chunks[j] + " ";
+                    else {
+                        newLine += "\n"+chunks[j]+" ";
+                        theMessage += newLine;
+                        newLine = "";
+                    }
+                }
+                
+            }
+        }
+        return theMessage;
+    }
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/exception/TileBuildException.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/exception/TileGettingException.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/exception/TileGettingException.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/exception/TileGettingException.java	(revision 3222)
@@ -0,0 +1,103 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.tile.exception;
+
+/**
+ * This exception is thrown when the pool of threads fails
+ *
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TileGettingException extends Exception {
+	private static final long serialVersionUID = 1L;
+	
+	String message;
+
+	public TileGettingException() {
+		super();
+	}
+
+	/**
+	 * Crea TileGettingException.
+	 *
+	 * @param message
+	 */
+	public TileGettingException(String message) {
+        super();
+        this.message = message;
+	}
+
+	/**
+	 * Crea TileGettingException.
+	 *
+	 * @param message
+	 * @param cause
+	 */
+	public TileGettingException(String message, Throwable cause) {
+		super(format(message, 200), cause);
+	}
+
+	/**
+	  * Crea TileGettingException.
+	 *
+	 * @param cause
+	 */
+	public TileGettingException(Throwable cause) {
+		super(cause);
+	}
+    
+    /**
+     * Cuts the message text to force its lines to be shorter or equal to 
+     * lineLength.
+     * @param message, the message.
+     * @param lineLength, the max line length in number of characters.
+     * @return the formated message.
+     */
+    private static String format(String message, int lineLength){
+        if (message.length() <= lineLength) return message;
+        String[] lines = message.split("\n");
+        String theMessage = "";
+        for (int i = 0; i < lines.length; i++) {
+            String line = lines[i].trim();
+            if (line.length()<lineLength)
+                theMessage += line+"\n";
+            else {
+                String[] chunks = line.split(" ");
+                String newLine = "";
+                for (int j = 0; j < chunks.length; j++) {
+                    int currentLength = newLine.length();
+                    chunks[j] = chunks[j].trim();
+                    if (chunks[j].length()==0)
+                        continue;
+                    if ((currentLength + chunks[j].length() + " ".length()) <= lineLength)
+                        newLine += chunks[j] + " ";
+                    else {
+                        newLine += "\n"+chunks[j]+" ";
+                        theMessage += newLine;
+                        newLine = "";
+                    }
+                }
+                
+            }
+        }
+        return theMessage;
+    }
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/exception/TileGettingException.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/exception/package.html
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/exception/package.html	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/exception/package.html	(revision 3222)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<title>org.gvsig.raster.cache.tile.exception package documentation</title>
+</head>
+<body>
+
+	<p>Exceptions which are thrown by a wrong access to tile structures</p>
+	
+	<p>
+	</p>
+
+</body>
+</html>
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/exception/package.html
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/exception/ThreadPoolException.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/exception/ThreadPoolException.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/exception/ThreadPoolException.java	(revision 3222)
@@ -0,0 +1,103 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.tile.exception;
+
+/**
+ * This exception is thrown when the pool of threads fails
+ *
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class ThreadPoolException extends Exception {
+	private static final long serialVersionUID = 1L;
+	
+	String message;
+
+	public ThreadPoolException() {
+		super();
+	}
+
+	/**
+	 * Crea ThreadPoolException.
+	 *
+	 * @param message
+	 */
+	public ThreadPoolException(String message) {
+        super();
+        this.message = message;
+	}
+
+	/**
+	 * Crea ThreadPoolException.
+	 *
+	 * @param message
+	 * @param cause
+	 */
+	public ThreadPoolException(String message, Throwable cause) {
+		super(format(message, 200), cause);
+	}
+
+	/**
+	  * Crea ThreadPoolException.
+	 *
+	 * @param cause
+	 */
+	public ThreadPoolException(Throwable cause) {
+		super(cause);
+	}
+    
+    /**
+     * Cuts the message text to force its lines to be shorter or equal to 
+     * lineLength.
+     * @param message, the message.
+     * @param lineLength, the max line length in number of characters.
+     * @return the formated message.
+     */
+    private static String format(String message, int lineLength){
+        if (message.length() <= lineLength) return message;
+        String[] lines = message.split("\n");
+        String theMessage = "";
+        for (int i = 0; i < lines.length; i++) {
+            String line = lines[i].trim();
+            if (line.length()<lineLength)
+                theMessage += line+"\n";
+            else {
+                String[] chunks = line.split(" ");
+                String newLine = "";
+                for (int j = 0; j < chunks.length; j++) {
+                    int currentLength = newLine.length();
+                    chunks[j] = chunks[j].trim();
+                    if (chunks[j].length()==0)
+                        continue;
+                    if ((currentLength + chunks[j].length() + " ".length()) <= lineLength)
+                        newLine += chunks[j] + " ";
+                    else {
+                        newLine += "\n"+chunks[j]+" ";
+                        theMessage += newLine;
+                        newLine = "";
+                    }
+                }
+                
+            }
+        }
+        return theMessage;
+    }
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/exception/ThreadPoolException.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/package.html
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/package.html	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/package.html	(revision 3222)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<title>org.gvsig.raster.cache.tile package documentation</title>
+</head>
+<body>
+
+	<p>Base classes to get tiles from raster layers</p>
+	
+	<p>
+	</p>
+
+</body>
+</html>
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/package.html
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/TileCache.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/TileCache.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/TileCache.java	(revision 3222)
@@ -0,0 +1,64 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.tile;
+
+import org.gvsig.raster.cache.tile.layer.TiledLayer;
+import org.gvsig.raster.cache.tile.provider.TileServer;
+
+/**
+ * Main API interface for the tile cache
+ *
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public interface TileCache {
+	/**
+	 * Builds a new layer
+	 * @param provider
+	 * @param diskStructure
+	 * @return
+	 */
+	public TiledLayer createLayer(TileServer provider, String diskStructure);
+	
+	/**
+	 * Removes a layer from list.
+	 * @param layer
+	 */
+	public void removeLayer(TiledLayer layer);
+	
+	/**
+	 * Returns true if the size of data in disk is greater than the MAX_CACHE_SIZE
+	 * @return
+	 */
+	public boolean isFullDiskCache();
+	
+	/**
+	 * Updates the string with the base directory
+	 * @param dir
+	 */
+	public void updateBaseDirectory(String dir);
+	
+	/**
+	 * Gets the configuration directory
+	 * @return
+	 */
+	public String getConfigurationDirectory();
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/TileCache.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/TileCacheLocator.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/TileCacheLocator.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/TileCacheLocator.java	(revision 3222)
@@ -0,0 +1,84 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.tile;
+
+import org.gvsig.tools.locator.BaseLocator;
+import org.gvsig.tools.locator.Locator;
+import org.gvsig.tools.locator.LocatorException;
+
+/**
+ * This locator is the entry point for the Raster library, providing
+ * access to all Raster services through the {@link TileCacheManager}
+ * .
+ * 
+ * @author gvSIG team
+ * @version $Id$
+ */
+public class TileCacheLocator extends BaseLocator {
+    public static final String             MANAGER_NAME            = "TileCache.manager";
+    public static final String             MANAGER_DESCRIPTION     = "TileCache Manager";
+    private static final String            LOCATOR_NAME            = "TileCache.locator";
+    private static final TileCacheLocator  INSTANCE                = new TileCacheLocator();
+
+    /**
+     * Return the singleton instance.
+     * 
+     * @return the singleton instance
+     */
+    public static TileCacheLocator getInstance() {
+        return INSTANCE;
+    }
+
+    /**
+     * Return the Locator's name.
+     * 
+     * @return a String with the Locator's name
+     */
+    public final String getLocatorName() {
+        return LOCATOR_NAME;
+    }
+
+    /**
+     * Return a reference to the RasterManager.
+     * 
+     * @return a reference to the RasterManager
+     * @throws LocatorException
+     *             if there is no access to the class or the class cannot be
+     *             instantiated
+     * @see Locator#get(String)
+     */
+    public static TileCacheManager getManager() throws LocatorException {
+        return (TileCacheManager) getInstance().get(MANAGER_NAME);
+    }
+
+    /**
+     * Registers the Class implementing the RasterManager interface.
+     * 
+     * @param clazz
+     *            implementing the RasterManager interface
+     */
+    public static void registerManager(
+        Class<? extends TileCacheManager> clazz) {
+        getInstance().register(MANAGER_NAME, MANAGER_DESCRIPTION, clazz);
+    }
+
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/TileCacheLocator.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/TileCacheLibrary.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/TileCacheLibrary.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/TileCacheLibrary.java	(revision 3222)
@@ -0,0 +1,63 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.tile;
+
+import org.gvsig.tools.library.AbstractLibrary;
+import org.gvsig.tools.library.LibraryException;
+import org.gvsig.tools.locator.ReferenceNotRegisteredException;
+
+
+/**
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TileCacheLibrary extends AbstractLibrary {
+	public static int                 DEFAULT_LEVELS       = 25; 
+	public static int                 DEFAULT_TILEWIDTH    = 256;
+	public static int                 DEFAULT_TILEHEIGHT   = 256;
+	public static int                 ALTERNATIVE_TILESIZE = 1024;
+	public static String              DEFAULT_STRUCTURE    = "FLATX";
+	
+	//One directory X dimension. The name of each tile is the Y coordinate. 
+	public static String              FLATX_STRUCT         = "FLATX";
+	public static String              QUADKEY_STRUCT       = "QUADKEY";
+	
+	public static int                 MAX_CACHE_SIZE       = 5000;
+	
+	public TileCacheLibrary() {
+        registerAsAPI(TileCacheLibrary.class);
+	}
+	
+	@Override
+    protected void doInitialize() throws LibraryException {
+    }
+
+    @Override
+    protected void doPostInitialize() throws LibraryException {
+        TileCacheManager manager = TileCacheLocator.getManager();
+        if (manager == null) {
+            throw new ReferenceNotRegisteredException(
+                TileCacheLocator.MANAGER_NAME, TileCacheLocator
+                    .getInstance());
+        }
+    }
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/tile/TileCacheLibrary.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferCacheManager.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferCacheManager.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferCacheManager.java	(revision 3222)
@@ -0,0 +1,283 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.buffer;
+
+import java.io.IOException;
+
+import org.gvsig.raster.cache.buffer.histogram.BufferHistogram;
+import org.gvsig.raster.cache.buffer.task.TaskEventManager;
+
+
+
+
+
+/**
+ * This class is responsible of the management of the library's business logic.
+ * It is the library's main entry point, and provides all the services to manage
+ * {@link BufferCacheService}s.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ * @version $Id$
+ */
+public interface BufferCacheManager {
+	public static int		      DONT_FORCE                 = 0;
+	public static int		      MEMORY_BUFFER              = 1;
+	public static int		      BAND_CACHE                 = 2;
+	public static int		      BAND_VERT_CACHE            = 3;
+	public static int		      READ_ONLY_CACHE            = 4;
+	
+	/**
+	 * Valor noData por defecto para la librer�a. En caso de no tener un valor asociado
+	 * al raster se usar� este.
+	 */
+	public static double            defaultNoDataValue       = -99999;
+	public static boolean           noDataValueEnable        = false;
+	
+	//*****************************************************
+	//BUFFER API
+	//*****************************************************
+	
+	/**
+	 * Genera instancias del buffer de datos adecuado al tama�o del raster. Si no hay muchos datos
+	 * (menos de cacheMemorySize) crear� un buffer en memoria. Si hay m�s de esta cantidad
+	 * entonces crearemos un buffer cacheado (RasterCache). A partir de la cantidad se�alada
+	 * por multicacheMemorySize haremos un buffer cacheado donde cada p�gina no ocupa todo
+	 * el ancho del raster ya que este ser� muy grande. La gesti�n de una cache donde cada
+	 * pagina ha de partir una l�nea lleva una complejidad a�adida.
+	 *  
+	 * @param params Par�metros de la carga
+	 * @return Objeto RasterBuffer
+	 */
+	public Buffer createBuffer(BufferParam params);
+	
+	/**
+	 * Genera una instancia del buffer de solo lectura. Este buffer consta de una cache y unos apuntadores
+	 * a las p�ginas en disco. Cuando se accede a los datos se carga en memoria la p�gina pedida.
+	 *  
+	 * @param  file 
+	 *         File to read data
+	 */
+	public Buffer createReadOnlyBuffer(String file);
+	
+	/**
+	 * Creates an instance of a memory buffer
+	 * 
+	 * @param dataType Tipo de dato
+	 * @param width Ancho
+	 * @param height Alto
+	 * @param bandNr Banda
+	 * @param flag En caso de buffers de memoria este flag a true significa que se reserva la memoria
+	 * para el buffer de forma normal y si est� a false no se reserva por lo que la reserva deber� ser
+	 * posterior. 
+	 */
+	public Buffer createMemoryBuffer(int dataType, int width, int height, int bandNr, boolean malloc);
+	
+	/**
+	 * Creates an instance of a memory buffer
+	 * 
+	 * @param params
+	 *        Parameters to instantiate this buffer
+	 */
+	public Buffer createMemoryBuffer(BufferParam params);
+	
+	/**
+	 * Creates a new instance of an interpolation object.
+	 * @param buf IRasterBuffer
+	 * @return IBufferInterpolation
+	 */
+	public BufferInterpolation createInterpolation(Buffer buf);
+	
+	/**
+	 * Builds a new parameter object
+	 * @param  x
+	 *         Upper left X position 
+	 * @param  y
+	 *         Upper left X position
+	 * @param  w
+	 *         Width
+	 * @param  h
+	 *         Height
+	 */
+	public BufferParam createBufferParams(int w, int h);
+	
+	/**
+	 * Creates a parameter object for building a buffer. The buffer type is read-write.
+	 * This type could be changed after the creation of a {@link BufferParam} object.
+	 * @param  w
+	 *         Width
+	 * @param  h
+	 *         Height
+	 * @param  bandCount
+	 * 		   Number of bands
+	 * @param  dataType
+	 *         Type of data        
+	 */
+	public BufferParam createBufferParams(int w, int h, int bandCount, int dataType);
+	
+	/**
+	 * Creates a parameter object for building a buffer. For this call the buffer type 
+	 * is read-only and the source will be a multifile. 
+	 * @param files
+	 *        File list in disk
+	 * @param x
+	 *        initial pixel
+	 * @param y
+	 *        initial pixel
+	 * @param w
+	 *        Width in pixels
+	 * @param h
+	 *        Height in pixels
+	 * @param bands
+	 *        bands to render
+	 * @return {@link BufferParam}
+	 * @throws IOException 
+	 */
+	public BufferParam createBufferParams(String[] files, int x, int y, int w, int h, int[] bands) throws IOException;
+	
+	/**
+	 * Creates a parameter object for building a buffer. For this call the buffer type 
+	 * is read-only. 
+	 * @param file
+	 *        File in disk
+	 * @param x
+	 *        initial pixel
+	 * @param y
+	 *        initial pixel
+	 * @param w
+	 *        Width in pixels
+	 * @param h
+	 *        Height in pixels
+	 * @param bands
+	 *        bands to render
+	 * @return {@link BufferParam}
+	 * @throws IOException 
+	 */
+	public BufferParam createBufferParams(String file, int x, int y, int w, int h, int[] bands) throws IOException;
+	
+	/**
+	 * Creates a parameter object for building a buffer. For this call the buffer type 
+	 * is read-only. 
+	 * @param file
+	 *        File in disk
+	 * @param x
+	 *        initial pixel
+	 * @param y
+	 *        initial pixel
+	 * @param w
+	 *        Width in pixels
+	 * @param h
+	 *        Height in pixels
+	 * @param bands
+	 *        bands to render
+	 * @return {@link BufferParam}
+	 * @throws IOException 
+	 */
+	public BufferParam createBufferParams(String file, int x, int y, int w, int h) throws IOException;
+	
+	//*****************************************************
+	//NODATA API
+	//*****************************************************
+	
+	/**
+	 * Builds a new NoData object
+	 * @param noData
+	 *        value to assign to all bands
+	 * @param nativeNoData
+	 *        The native is the original value
+	 *        saved in the head of the file or its metadata.
+	 * @param fileName
+	 *        Name of file owner of this nodata value. This string is useful to
+	 *        save the rmf file
+	 * @param bandCount
+	 *        Number of bands of the file
+	 * @return NoData
+	 */
+	public BufferNoData createNoData(Number noData, Number nativeNoData, String fileName, int bandCount);
+	
+	/**
+	 * Builds a new NoData for DEMs
+	 * @param noData
+	 *        value to assign to all bands
+	 * @param nativeNoData
+	 *        The native is the original value
+	 *        saved in the head of the file or its metadata.
+	 * @param fileName
+	 *        Name of file owner of this nodata value. This string is useful to
+	 *        save the rmf file
+	 * @return NoData
+	 */
+	public BufferNoData createNoData(Number noData, Number nativeNoData, String fileName);
+	
+	/**
+	 * Builds a new NoData for DEMs
+	 * @param dataType
+	 *        dataType of this NoData
+	 * @param bandCount
+	 *        Number of bands
+	 * @return NoData
+	 */
+	public BufferNoData createDefaultNoData(int bandCount, int dataType);
+	
+	//*****************************************************
+	//HISTOGRAM API
+	//*****************************************************
+	
+	/**
+	 * Creates a empty histogram
+	 * @param nBands
+	 * @param min
+	 * @param max
+	 * @param dataType
+	 * @param numberOfClasses
+	 * @return
+	 */
+	public BufferHistogram createHistogram(int nBands, double[] min, double[] max, int dataType, int numberOfClasses);
+	
+	/**
+	 * Creates a empty histogram
+	 * @param nBands
+	 * @param min
+	 * @param max
+	 * @param dataType
+	 * @param numberOfClasses
+	 * @return
+	 */
+	public BufferHistogram createHistogram(int nBands, int nClasses, double[] min, double[] max);
+	
+	//*****************************************************
+	//TASK API
+	//*****************************************************
+	
+	/**
+	 * Gets a register task. To get a task it will use the current thread ID
+	 * @return TaskEventManager
+	 */
+	public TaskEventManager getTask();
+	
+	/**
+	 * Registers the object as a task using the current thread ID. It returns
+	 * a TaskEventManager
+	 * @param process
+	 * @return
+	 */
+	public TaskEventManager createTask(Object process);
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferCacheManager.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferStats.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferStats.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferStats.java	(revision 3222)
@@ -0,0 +1,28 @@
+package org.gvsig.raster.cache.buffer;
+
+import java.util.ArrayList;
+
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+
+/**
+ * This class is used to calculate basic statistics in a buffer.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public interface BufferStats {
+	/**
+	 * Calculate statistics
+	 */
+	public void calculate();
+	
+    public double[] getLimits() throws ProcessInterruptedException;
+    
+    public double[][] getAllBandsLimits() throws ProcessInterruptedException;
+    
+    /**
+     * Gets the band list. Each band contains the statistics using
+     * {@link StatsValues}
+     * @return
+     */
+    public ArrayList<Band> getBandList();
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferStats.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferParam.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferParam.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferParam.java	(revision 3222)
@@ -0,0 +1,182 @@
+package org.gvsig.raster.cache.buffer;
+
+import java.awt.geom.Rectangle2D;
+
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+
+/**
+ * Buffer parameters. This class contains generic parameters. 
+ * Basic information to fill: x, y, w, h, datatype and bandcount. If
+ * the buffer is RasterReadOnlyBuffer is necessary a IBufferDataSource too.
+ * 02/11/2008
+ * @author Nacho Brodin nachobrodin@gmail.com
+ */
+public interface BufferParam {
+	/**
+	 * Get a interest area
+	 * @return Rectangle2D
+	 */
+	public Rectangle2D getAreaOfInterest();
+	
+	/**
+	 * Set a interest area
+	 * @param selection
+	 */
+	public void setAreaOfInterest(Rectangle2D selection);
+	
+	/**
+	 * Get the file reference
+	 * @return
+	 */
+	public String getReference();
+	
+	/**
+	 * Set the file reference
+	 * @param ref
+	 */
+	public void setReference(String ref);
+	
+	/**
+	 * Set the data source
+	 * @param dataSource
+	 */
+	public void setDataSource(BufferDataSource dataSource);
+
+	/**
+	 * Get the data source
+	 * @return
+	 */
+	public BufferDataSource getDataSource();
+	
+	/**
+	 * Returns the width in pixels
+	 * @return Width in pixels of this raster
+	 */
+	public int getWidth();
+
+	/**
+	 * Sets the width in pixels
+	 * @param  width
+	 *         Width in pixels of this raster
+	 */
+	public void setWidth(int width);
+
+	/**
+	 * Returns the height in pixels
+	 * @return Height in pixels of this raster
+	 */
+	public int getHeight();
+
+	/**
+	 * Sets the height in pixels
+	 * @param  height
+	 *         Height in pixels of this raster 
+	 */
+	public void setHeight(int height);
+
+	/**
+	 * Returns the X upper left coordinate
+	 * @return X upper left coordinate in pixels
+	 */
+	public int getX();
+
+	/**
+	 * Sets the X upper left coordinate
+	 * @params  x
+	 *          X upper left coordinate in pixels
+	 */
+	public void setX(int x);
+
+	/**
+	 * Returns the Y upper left coordinate
+	 * @return Y upper left coordinate in pixels
+	 */
+	public int getY();
+
+	/**
+	 * Sets the Y upper left coordinate
+	 * @params  y
+	 *          Y upper left coordinate in pixels
+	 */
+	public void setY(int y);
+
+	/**
+	 * Gets the data type
+	 * @return
+	 */
+	public int getDataType();
+
+	/**
+	 * Sets the data type
+	 * @param dataType
+	 */
+	public void setDataType(int dataType);
+
+	/**
+	 * Gets number of bands
+	 * @return
+	 */
+	public int getBandCount();
+
+	/**
+	 * Sets number of bands
+	 * @param bandCount
+	 */
+	public void setBandCount(int bandCount);
+	
+	/**
+	 * Adds one to the band counter
+	 */
+	public void bandPlusPlus();
+	
+	/**
+	 * Substracts one to the band counter
+	 */
+	public void bandLessLess();
+	
+	 /**
+     * Gets no data value
+     * @return double
+     */
+ 	public double getNoDataValue();
+ 	
+ 	/**
+ 	 * Sets no data value
+ 	 * @return double
+ 	 */
+ 	public void setNoDataValue(double noDataValue);
+	
+	/**
+	 * Gets the size of the data type in bytes
+	 * @return Size of the data type that is used
+	 */
+	public int getDataSize();
+    
+    /**
+	 * Gets the buffer size
+	 * @return buffer size
+	 */
+	public long sizeof();
+	
+	/**
+	 * Sets the type of access defined as constant in Buffer interface
+	 */
+	public void setAccessType(int accessType);
+	
+	/**
+	 * Gets the type of access defined as constant in Buffer interface
+	 */
+	public int getAccessType();
+	
+	/**
+	 * Sets the band list
+	 * @param file
+	 */
+	public void setBandList(int[] bands);
+
+	/**
+	 * Gets the band list
+	 * @return
+	 */
+	public int[] getBandList();
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferParam.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/RasterBase.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/RasterBase.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/RasterBase.java	(revision 3222)
@@ -0,0 +1,221 @@
+package org.gvsig.raster.cache.buffer;
+
+
+
+/**
+ * Base class for raster elements. This class contains methos for
+ * reading width, height, number of bands and other raster parameters 
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public abstract class RasterBase {
+	private static final long    serialVersionUID = 1L;
+	private int                  dataType         = Buffer.TYPE_UNDEFINED;
+	private int                  bandCount        = 0;
+	private int                  width            = 0;
+	private int                  height           = 0;
+	private int                  x                = 0;
+	private int                  y                = 0;
+	public double 			     noDataValue      = -99999.0;
+	
+	/**
+	 * Sets size and position values
+	 * @param  x
+	 *         Upper left X position 
+	 * @param  y
+	 *         Upper left X position
+	 * @param  w
+	 *         Width
+	 * @param  h
+	 *         Height
+	 */
+	public RasterBase(int x, int y, int w, int h) {
+		this.x = x;
+		this.y = y;
+		this.width = w;
+		this.height = h;
+	}
+	
+	/**
+	 * Sets size and position values
+	 * @param  x
+	 *         Upper left X position 
+	 * @param  y
+	 *         Upper left X position
+	 * @param  w
+	 *         Width
+	 * @param  h
+	 *         Height
+	 * @param  datatype
+	 * 	       Data type of this raster
+	 * @param  nBands
+	 * 	       Number of bands of this raster
+	 */
+	public RasterBase(int x, int y, int w, int h, int dataType, int nBands) {
+		this.x = x;
+		this.y = y;
+		this.width = w;
+		this.height = h;
+		this.dataType = dataType;
+		this.bandCount = nBands;
+	}
+	
+	/**
+	 * Returns the width in pixels
+	 * @return Width in pixels of this raster
+	 */
+	public int getWidth() {
+		return width;
+	}
+
+	/**
+	 * Sets the width in pixels
+	 * @param  width
+	 *         Width in pixels of this raster
+	 */
+	public void setWidth(int width) {
+		this.width = width;
+	}
+
+	/**
+	 * Returns the height in pixels
+	 * @return Height in pixels of this raster
+	 */
+	public int getHeight() {
+		return height;
+	}
+
+	/**
+	 * Sets the height in pixels
+	 * @param  height
+	 *         Height in pixels of this raster 
+	 */
+	public void setHeight(int height) {
+		this.height = height;
+	}
+
+	/**
+	 * Returns the X upper left coordinate
+	 * @return X upper left coordinate in pixels
+	 */
+	public int getX() {
+		return x;
+	}
+
+	/**
+	 * Sets the X upper left coordinate
+	 * @params  x
+	 *          X upper left coordinate in pixels
+	 */
+	public void setX(int x) {
+		this.x = x;
+	}
+
+	/**
+	 * Returns the Y upper left coordinate
+	 * @return Y upper left coordinate in pixels
+	 */
+	public int getY() {
+		return y;
+	}
+
+	/**
+	 * Sets the Y upper left coordinate
+	 * @params  y
+	 *          Y upper left coordinate in pixels
+	 */
+	public void setY(int y) {
+		this.y = y;
+	}
+
+	/**
+	 * Gets the data type
+	 * @return
+	 */
+	public int getDataType() {
+		return dataType;
+	}
+
+	/**
+	 * Sets the data type
+	 * @param dataType
+	 */
+	public void setDataType(int dataType) {
+		this.dataType = dataType;
+	}
+
+	/**
+	 * Gets number of bands
+	 * @return
+	 */
+	public int getBandCount() {
+		return bandCount;
+	}
+
+	/**
+	 * Sets number of bands
+	 * @param bandCount
+	 */
+	public void setBandCount(int bandCount) {
+		this.bandCount = bandCount;
+	}
+	
+	/**
+	 * Adds one to the band counter
+	 */
+	public void bandPlusPlus() {
+		this.bandCount ++;
+	}
+	
+	/**
+	 * Substracts one to the band counter
+	 */
+	public void bandLessLess() {
+		this.bandCount --;
+	}
+	
+	 /**
+     * Gets no data value
+     * @return double
+     */
+ 	public double getNoDataValue() {
+ 		return noDataValue;
+ 	}
+ 	
+ 	/**
+ 	 * Sets no data value
+ 	 * @return double
+ 	 */
+ 	public void setNoDataValue(double noDataValue) {
+ 		this.noDataValue = noDataValue;
+ 	}
+	
+	/**
+	 * Gets the size of the data type in bytes
+	 * @return Size of the data type that is used
+	 */
+	public int getDataSize() {
+		if (getDataType() == Buffer.TYPE_BYTE) {
+			return 1;
+		} else if ((getDataType() == Buffer.TYPE_SHORT) | (getDataType() == Buffer.TYPE_USHORT)) {
+			return 2;
+		} else if (getDataType() == Buffer.TYPE_INT) {
+			return 4;
+		}else if (getDataType() == Buffer.TYPE_FLOAT) {
+			return 8;
+		}else if (getDataType() == Buffer.TYPE_DOUBLE) {
+			return 16;
+		}
+
+		return 0;
+	}
+    
+    /**
+	 * Gets the buffer size
+	 * @return buffer size
+	 */
+	public long sizeof() {
+		return (long)(getDataSize() * getWidth() * getHeight() * getBandCount());
+	}
+
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/RasterBase.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferNoData.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferNoData.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferNoData.java	(revision 3222)
@@ -0,0 +1,160 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.buffer;
+
+/**
+ * This class represents the nodata value.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public interface BufferNoData {
+	public static byte           defaultByteNoDataValue     = -128;
+	public static short          defaultShortNoDataValue    = -32768;
+	public static int            defaultIntegerNoDataValue  = -99999;
+	public static float          defaultFloatNoDataValue    = -99999F;
+	public static double         defaultDoubleNoDataValue   = -99999D;
+	
+	/**
+	 * Gets a unique value for nodata. It doesn't take into account if the raster has
+	 * several bands. Returns the same value for all of them.
+	 * @return the noData
+	 */
+	public Number getValue();
+
+	/**
+	 * Sets a unique value for nodata. It doesn't take into account if the raster has
+	 * several bands. Assigns the same value for all of them.
+	 * @param noData the noData to set
+	 */
+	public void setValue(Number noData);
+	
+	/**
+	 * Returns true if getValue is defined and false if is null
+	 * @return
+	 */
+	public boolean isDefined();
+	
+	/**
+	 * Deletes the nodata value.
+	 */
+	public void delete();
+	
+	/**
+	 * Restores native value. The native is the original value
+	 * saved in the head of the file or its metadata. This value
+	 * has to be assign when NoData object is initialize. 
+	 */
+	public void restore();
+	
+	/**
+	 * The native is the original value
+	 * saved in the head of the file or its metadata. This value
+	 * has to be assign when NoData object is initialize
+	 * @return the noData
+	 */
+	public Number getNativeValue();
+	
+	/**
+	 * The native is the original value
+	 * saved in the head of the file or its metadata. This value
+	 * has to be assign when NoData object is initialize.
+	 * @param nativeNoDataValue
+	 */
+	public void setNativeValue(Number nativeNoDataValue);
+	
+	/**
+	 * Sets the file name
+	 * @param bandCount
+	 */
+	public void setFileName(String fileName);
+	
+	/**
+	 * Gets the file name
+	 * @return
+	 */
+	public String getFileName();
+	
+	/**
+	 * Flag to renderize nodata values as transparent
+	 * @return
+	 */
+	public boolean isNoDataTransparent();
+
+	/**
+	 * Flag to renderize nodata values as transparent
+	 * @param noDataAsTransparent
+	 */
+	public void setNoDataTransparent(boolean noDataAsTransparent);
+	
+	/**
+	 * Gets the NoData data type
+	 * @return
+	 */
+	public int getDataType();
+	
+	/**
+	 * Sets the datatype
+	 */
+	public void setDataType(int datatype);
+	
+	/**
+	 * Compares two NoData objects an returns true if contains the same values
+	 * @param noData
+	 * @return
+	 */
+	public boolean compare(BufferNoData noData);
+	
+	/**
+     * Creates and returns a copy of this object.
+	 * @return
+	 */
+	public Object clone();
+	
+	//***********************************************
+	//Only for file with more than one band
+	
+	/**
+	 * Gets the nodata value by band
+	 * @param nBand
+	 * @return
+	 */
+	public Number getValueByBand(int nBand);
+	
+	/**
+	 * Gets the number of bands
+	 * @return
+	 */
+	public int getBandCount();
+	
+	/**
+	 * Sets the number of bands
+	 * @param bandCount
+	 */
+	public void setBandCount(int bandCount);
+	
+	/**
+	 * Assigns one value in a band
+	 * @param noDataValue
+	 */
+	public void setValueByBand(Number noDataValue, int nBand);
+
+}
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferNoData.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/Band.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/Band.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/Band.java	(revision 3222)
@@ -0,0 +1,435 @@
+package org.gvsig.raster.cache.buffer;
+
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+
+
+/**
+ * Interface implemented by a raster band 
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ *
+ */
+public interface Band extends StatsValues {
+    public final static int TYPE_UNDEFINED = Buffer.TYPE_UNDEFINED;
+    public final static int TYPE_BYTE = Buffer.TYPE_BYTE;
+    public final static int TYPE_SHORT = Buffer.TYPE_SHORT;
+    public final static int TYPE_USHORT = Buffer.TYPE_USHORT;
+    public final static int TYPE_INT = Buffer.TYPE_INT;
+    public final static int TYPE_FLOAT = Buffer.TYPE_FLOAT;
+    public final static int TYPE_DOUBLE = Buffer.TYPE_DOUBLE;
+    public final static int TYPE_IMAGE = -1;
+    
+    /**
+     * Ancho de la banda
+     * @return Entero con el ancho de la banda
+     */
+    public int getWidth();
+
+    /**
+     * Alto de la banda
+     * @return Entero con el alto de la banda
+     */
+    public int getHeight();
+    
+    /**
+     * Obtiene el tipo de dato. Los tipos de dato posibles est�n definidos en IRaster.
+     * @return tipo de datos
+     */
+	public int getDataType();
+	
+	/**
+	 * Gets the height of each minimum data block. For instance, when you're using 
+	 * a cache the BlockSize is the height of one piece of cache. If it is a vertical
+	 * cache the BlockSize is the width of each block.
+	 * @return size of minimum data block
+	 */
+	public int getBlockSize();
+	
+	/**
+	 * Gets the number of blocks
+	 * @return integer that represents the number of blocks
+	 */
+	public int getNumberOfBlocks();
+	
+	/**
+	 * Returns true if the block is horizontal and false if is not
+	 * @return integer that represents the number of blocks
+	 */
+	public boolean isHorizontalBlock();
+	
+	/**
+	 * Assigns a new band number
+	 * @param  band New band number
+	 */
+	public void setBandNumber(int band);
+	
+	/**
+	 * Gets the band number
+	 * @return band number
+	 */
+	public int getBandNumber();
+	
+	//***********************************************
+    //Getting a block of data
+	
+	/**
+	 * Gets a minimum block of data. The height of this data block is getBlockHeight
+	 * pixels. 
+	 * @return Data buffer in memory. This is an array of two dimensions (width x heigth).
+	 */
+	public byte[][] getByteBlock(int block);
+	
+	/**
+	 * Gets a minimum block of data. The height of this data block is getBlockHeight
+	 * pixels. 
+	 * @return Data buffer in memory. This is an array of two dimensions (width x heigth).
+	 */
+	public short[][] getShortBlock(int block);
+	
+	/**
+	 * Gets a minimum block of data. The height of this data block is getBlockHeight
+	 * pixels. 
+	 * @return Data buffer in memory. This is an array of two dimensions (width x heigth).
+	 */
+	public int[][] getIntBlock(int block);
+	
+	/**
+	 * Gets a minimum block of data. The height of this data block is getBlockHeight
+	 * pixels. 
+	 * @return Data buffer in memory. This is an array of two dimensions (width x heigth).
+	 */
+	public float[][] getFloatBlock(int block);
+	
+	/**
+	 * Gets a minimum block of data. The height of this data block is getBlockHeight
+	 * pixels. 
+	 * @return Data buffer in memory. This is an array of two dimensions (width x heigth).
+	 */
+	public double[][] getDoubleBlock(int block);
+		
+	//***********************************************
+    //Obtiene una linea de datos
+    
+    /**
+     * Obtiene una l�nea de datos de esta banda para buffers con tipo
+	 * de dato byte.
+     * @param  line 
+     *         N�mero de l�nea del buffer a recuperar
+     * @return Array unidimensional que representa la l�nea de datos.
+     */
+    public byte[] getByteLine(int line) throws OperationNotSupportedException;
+
+    /**
+     * Obtiene una l�nea de datos de esta banda para buffers con tipo
+	 * de dato short.
+     * @param  line 
+     *         N�mero de l�nea del buffer a recuperar
+     * @return Array unidimensional que representa la l�nea de datos.
+     */
+    public short[] getShortLine(int line) throws OperationNotSupportedException;
+
+    /**
+     * Obtiene una l�nea de datos de esta banda para buffers con tipo
+	 * de dato int.
+     * @param  line 
+     *         N�mero de l�nea del buffer a recuperar
+     * @return Array unidimensional que representa la l�nea de datos.
+     */
+    public int[] getIntLine(int line) throws OperationNotSupportedException;
+        
+    /**
+     * Obtiene una l�nea de datos de esta banda para buffers con tipo
+	 * de dato float.
+     * @param  line 
+     *         N�mero de l�nea del buffer a recuperar
+     * @return Array unidimensional que representa la l�nea de datos.
+     */
+    public float[] getFloatLine(int line) throws OperationNotSupportedException;
+    
+    /**
+     * Obtiene una l�nea de datos de esta banda para buffers con tipo
+	 * de dato double.
+     * @param  line 
+     *         N�mero de l�nea del buffer a recuperar
+     * @return Array unidimensional que representa la l�nea de datos.
+     */
+    public double[] getDoubleLine(int line) throws OperationNotSupportedException;
+    
+    //***********************************************    
+    //Obtiene un elemento de la matriz
+    
+    /**
+     * Gets one element from the array if this is byte datatype
+     * @param  line 
+     *         Y position
+     * @param  col 
+     *         X position
+     * @param  band Number of band to read
+     * @return Readed element
+     */
+    public byte getElemByte(int line, int col);
+    
+    /**
+    * Gets one element from the array if this is short datatype
+    * @param  line 
+    *         Y position
+    * @param  col 
+    *         X position
+    * @param  band Number of band to read
+    * @return Readed element
+    */
+    public short getElemShort(int line, int col);
+    
+    /**
+     * Gets one element from the array if this is int datatype
+     * @param  line 
+     *         Y position
+     * @param  col 
+     *         X position
+     * @param  band 
+     *         Number of band to read
+     * @return Readed element
+     */
+    public int getElemInt(int line, int col);
+    
+    /**
+     * Gets one element from the array if this is float datatype
+     * @param  line 
+     *         Y position
+     * @param  col 
+     *         X position
+     * @param  band 
+     *         Number of band to read
+     * @return Readed element
+     */
+    public float getElemFloat(int line, int col);
+    
+    /**
+     * Gets one element from the array if this is double datatype
+     * @param  line 
+     *         Y position
+     * @param  col 
+     *         X position
+     * @param  band 
+     *         Number of band to read
+     * @return Readed element
+     */
+    public double getElemDouble(int line, int col);
+    
+    //***********************************************
+    //Asigna una linea de datos a una banda
+    
+    /**
+     * Sets one line of byte data
+     * @param  data 
+     *         line of data
+     * @param  line 
+     *         Number of line to set
+     * @throws OperationNotSupportedException 
+     */
+    public void setByteLine(byte[] data, int line) throws OperationNotSupportedException;
+
+    /**
+     * Sets one line of short data
+     * @param  data 
+     *         line of data
+     * @param  line 
+     *         Number of line to set
+     * @throws OperationNotSupportedException 
+     */
+    public void setShortLine(short[] data, int line) throws OperationNotSupportedException;
+
+    /**
+     * Sets one line of int data
+     * @param  data 
+     *         line of data
+     * @param  line 
+     *         Number of line to set
+     * @throws OperationNotSupportedException 
+     */
+    public void setIntLine(int[] data, int line) throws OperationNotSupportedException;
+       
+    /**
+     * Sets one line of float data
+     * @param  data 
+     *         line of data
+     * @param  line 
+     *         Number of line to set
+     * @throws OperationNotSupportedException 
+     */
+    public void setFloatLine(float[] data, int line) throws OperationNotSupportedException;
+    
+    /**
+     * Sets one line of double data
+     * @param  data 
+     *         line of data
+     * @param  line 
+     *         Number of line to set
+     * @throws OperationNotSupportedException 
+     */
+    public void setDoubleLine(double[] data, int line) throws OperationNotSupportedException;
+    
+    //**********************************************    
+    //Asigna un elemento de la matriz
+    
+    /**
+     * Sets one byte element
+     * @param  line 
+     *         Y position
+     * @param  col 
+     *         X position
+     * @param  data 
+     *         data value to set
+     * @throws OperationNotSupportedException 
+     */
+    public void setElem(int line, int col, byte data) throws OperationNotSupportedException;
+    
+    /**
+     * Sets one short element
+     * @param  line 
+     *         Y position
+     * @param  col 
+     *         X position
+     * @param  data 
+     *         data value to set
+     * @throws OperationNotSupportedException 
+     */
+    public void setElem(int line, int col, short data) throws OperationNotSupportedException;
+    
+    /**
+     * Sets one int element
+     * @param  line 
+     *         Y position
+     * @param  col 
+     *         X position
+     * @param  data 
+     *         data value to set
+     * @throws OperationNotSupportedException 
+     */
+    public void setElem(int line, int col, int data) throws OperationNotSupportedException;
+    
+    /**
+     * Sets one float element
+     * @param  line 
+     *         Y position
+     * @param  col 
+     *         X position
+     * @param  data 
+     *         data value to set
+     * @throws OperationNotSupportedException 
+     */
+    public void setElem(int line, int col, float data) throws OperationNotSupportedException;
+    
+    /**
+     * Sets one double element
+     * @param  line 
+     *         Y position
+     * @param  col 
+     *         X position
+     * @param  data 
+     *         data value to set
+     * @throws OperationNotSupportedException 
+     */
+    public void setElem(int line, int col, double data) throws OperationNotSupportedException;
+
+    //***********************************************
+    //Inicializa la banda al valor pasado por par�metro
+    
+    /**
+     * Sets all elements in this band to the parameter value
+     * @param  value 
+     *         Value to set
+     * @throws OperationNotSupportedException 
+     */
+    public void assign(byte value) throws OperationNotSupportedException;
+    
+    /**
+     * Sets all elements in this band to the parameter value
+     * @param  value 
+     *         Value to set
+     * @throws OperationNotSupportedException 
+     */
+    public void assign(short value) throws OperationNotSupportedException;
+    
+    /**
+     * Sets all elements in this band to the parameter value
+     * @param  value 
+     *         Value to set
+     * @throws OperationNotSupportedException 
+     */
+    public void assign(int value) throws OperationNotSupportedException;
+
+    /**
+     * Sets all elements in this band to the parameter value
+     * @param  value 
+     *         Value to set
+     * @throws OperationNotSupportedException 
+     */
+    public void assign(float value) throws OperationNotSupportedException;
+    
+    /**
+     * Sets all elements in this band to the parameter value
+     * @param  value 
+     *         Value to set
+     * @throws OperationNotSupportedException 
+     */
+    public void assign(double value) throws OperationNotSupportedException;
+    
+  //***********************************************
+    //Getting a block of data
+	
+	/**
+	 * Sets a minimum byte block. The height of this data block is getBlockHeight
+	 * pixels. 
+	 * @param  data 
+	 *         Data buffer in memory. This is an array of two dimensions (width x heigth).
+	 * @param  block 
+	 *         Number of block to assign
+	 * @throws OperationNotSupportedException 
+	 */
+	public void setByteBlock(byte[][] data, int block) throws OperationNotSupportedException;
+	
+	/**
+	 * Sets a minimum short block. The height of this data block is getBlockHeight
+	 * pixels. 
+	 * @param  data 
+	 *         Data buffer in memory. This is an array of two dimensions (width x heigth).
+	 * @param  block 
+	 *         Number of block to assign
+	 * @throws OperationNotSupportedException 
+	 */
+	public void setShortBlock(short[][] data, int block) throws OperationNotSupportedException;
+	
+	/**
+	 * Sets a minimum int block. The height of this data block is getBlockHeight
+	 * pixels. 
+	 * @param  data 
+	 *         Data buffer in memory. This is an array of two dimensions (width x heigth).
+	 * @param  block 
+	 *         Number of block to assign
+	 * @throws OperationNotSupportedException 
+	 */
+	public void setIntBlock(int[][] data, int block) throws OperationNotSupportedException;
+	
+	/**
+	 * Sets a minimum float block. The height of this data block is getBlockHeight
+	 * pixels. 
+	 * @param  data 
+	 *         Data buffer in memory. This is an array of two dimensions (width x heigth).
+	 * @param  block 
+	 *         Number of block to assign
+	 * @throws OperationNotSupportedException 
+	 */
+	public void setFloatBlock(float[][] data, int block) throws OperationNotSupportedException;
+	
+	/**
+	 * Sets a minimum double block. The height of this data block is getBlockHeight
+	 * pixels. 
+	 * @param  data 
+	 *         Data buffer in memory. This is an array of two dimensions (width x heigth).
+	 * @param  block 
+	 *         Number of block to assign
+	 * @throws OperationNotSupportedException 
+	 */
+	public void setDoubleBlock(double[][] data, int block) throws OperationNotSupportedException;
+}
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/Band.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/PxTile.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/PxTile.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/PxTile.java	(revision 3222)
@@ -0,0 +1,36 @@
+package org.gvsig.raster.cache.buffer;
+
+
+public abstract class PxTile extends RasterBase {
+	/**
+	 * Set size and position values
+	 * @param  x
+	 *         Upper left X position 
+	 * @param  y
+	 *         Upper left X position
+	 * @param  w
+	 *         Width
+	 * @param  h
+	 *         Height
+	 */
+	public PxTile(int x, int y, int w, int h) {
+		super(x, y, w, h);
+	}
+	
+	/**
+	 * Set size, position values and a file reference
+	 * @param  x
+	 *         Upper left X position 
+	 * @param  y
+	 *         Upper left X position
+	 * @param  w
+	 *         Width
+	 * @param  h
+	 *         Height
+	 * @param  ref
+	 *         file reference
+	 */
+	public PxTile(int x, int y, int w, int h, String ref) {
+		super(x, y, w, h);
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/PxTile.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/Buffer.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/Buffer.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/Buffer.java	(revision 3222)
@@ -0,0 +1,585 @@
+package org.gvsig.raster.cache.buffer;
+
+import java.awt.geom.Rectangle2D;
+import java.awt.image.DataBuffer;
+import java.io.IOException;
+import java.util.ArrayList;
+
+import org.gvsig.raster.cache.buffer.exception.BandNotCompatibleException;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.exception.WrongParameterException;
+import org.gvsig.raster.cache.buffer.histogram.Histogramable;
+
+/**
+ * Interfaz que contiene las operaciones que debe soportar un buffer de datos.
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ *
+ */
+public interface Buffer extends Histogramable {
+	public static boolean   noDataValueEnable = false;
+	public static double    defaultNoDataValue = -99999.0;
+	
+    public final static int TYPE_UNDEFINED = DataBuffer.TYPE_UNDEFINED;
+    public final static int TYPE_BYTE = DataBuffer.TYPE_BYTE;
+    public final static int TYPE_SHORT = DataBuffer.TYPE_SHORT;
+    public final static int TYPE_USHORT = DataBuffer.TYPE_USHORT;
+    public final static int TYPE_INT = DataBuffer.TYPE_INT;
+    public final static int TYPE_FLOAT = DataBuffer.TYPE_FLOAT;
+    public final static int TYPE_DOUBLE = DataBuffer.TYPE_DOUBLE;
+    
+    //Read type constants
+	public static final int      READ_ONLY             = 0;
+	public static final int      READ_WRITE            = 1;
+	//If the returned buffer is a cache buffer then it will have vertical stripes
+	public static final int      READ_WRITE_CVERT      = 2;
+        
+    //**************************************
+    //************GETTING INFO**************
+    //**************************************
+    
+    /**
+     * Ancho del raster
+     * @return Entero con el ancho del raster
+     */
+    public int getWidth();
+
+    /**
+     * Alto del raster
+     * @return Entero con el alto del raster
+     */
+    public int getHeight();
+
+    /**
+     * N�mero de bandas
+     * @return Entero con el n�mero de bandas
+     */
+    public int getBandCount();
+
+    /**
+     * Obtiene el tipo de dato. Los tipos de dato posibles est�n definidos en IRaster.
+     * @return tipo de datos
+     */
+	public int getDataType();
+	
+	/**
+	 * Asigna el tipo de dato. Los tipos de dato posibles est�n definidos en IRaster.
+	 * @param dataType Tipo de dato del buffer
+	 */
+	public void setDataType(int dataType);
+	
+	/**
+     * Get no data value
+     * @return double
+     */
+ 	public BufferNoData getNoDataValue();
+ 	
+    /**
+ 	 * Sets no data value
+ 	 * @return double
+ 	 */
+ 	public void setNoDataValue(BufferNoData noDataValue);
+    
+    /**
+     * Get true if current buffer is writable and false if is not.
+     * @return true or false 
+     */
+    public boolean isWritable();
+    
+    /**
+     * Obtiene true si el pixel pasado por par�metro cae dentro de los l�mites
+     * del rater y false si cae fuera. 
+     * @param x Posici�n X del pixel a averiguar
+     * @param y Posici�n Y del pixel a averiguar
+     * @return true si est� dentro y false si cae fuera.
+     */
+    public boolean isInside(int x, int y);
+    
+    /**
+	 * Gets a bouding box of this buffer
+	 * @return
+	 */
+	public Rectangle2D getDataExtent();
+	
+	/**
+	 * Sets the bounding box of this buffer
+	 * @param extent
+	 */
+	public void setDataExtent(Rectangle2D extent);
+        
+	/**
+	 * Libera el buffer de memoria
+	 * @throws IOException 
+	 */
+	public void free() throws IOException;
+	
+	/**
+	 * Sets the RasterDataStore reference
+	 * @param store
+	 */
+	public void setStore(Object store);
+	
+	/**
+	 * Gets the RasterDataStore reference
+	 * @return
+	 */
+	public Object getStore();
+
+    //**************************************
+    //************GETTING DATA**************
+    //**************************************
+	
+    //***********************************************
+    //Obtiene una linea de datos de todas las bandas
+    
+	/**
+	 * Obtiene una l�nea de datos con todas las bandas para buffers con tipo
+	 * de dato byte.
+	 * @param line N�mero de l�nea del buffer a recuperar
+	 * @return Array bidimensional conteniendo la l�nea de datos donde la primera
+	 * dimensi�n representa las bandas y la segunda la posici�n en la l�nea
+	 */    
+    public byte[][] getLineByte(int line) throws OperationNotSupportedException;
+
+    /**
+	 * Obtiene una l�nea de datos con todas las bandas para buffers con tipo
+	 * de dato short.
+	 * @param line N�mero de l�nea del buffer a recuperar
+	 * @return Array bidimensional conteniendo la l�nea de datos donde la primera
+	 * dimensi�n representa las bandas y la segunda la posici�n en la l�nea
+	 */  
+    public short[][] getLineShort(int line) throws OperationNotSupportedException;
+
+    /**
+	 * Obtiene una l�nea de datos con todas las bandas para buffers con tipo
+	 * de dato int.
+	 * @param line N�mero de l�nea del buffer a recuperar
+	 * @return Array bidimensional conteniendo la l�nea de datos donde la primera
+	 * dimensi�n representa las bandas y la segunda la posici�n en la l�nea
+	 */  
+    public int[][] getLineInt(int line) throws OperationNotSupportedException;
+        
+    /**
+	 * Obtiene una l�nea de datos con todas las bandas para buffers con tipo
+	 * de dato float.
+	 * @param line N�mero de l�nea del buffer a recuperar
+	 * @return Array bidimensional conteniendo la l�nea de datos donde la primera
+	 * dimensi�n representa las bandas y la segunda la posici�n en la l�nea
+	 */  
+    public float[][] getLineFloat(int line) throws OperationNotSupportedException;
+    
+    /**
+	 * Obtiene una l�nea de datos con todas las bandas para buffers con tipo
+	 * de dato double.
+	 * @param line N�mero de l�nea del buffer a recuperar
+	 * @return Array bidimensional conteniendo la l�nea de datos donde la primera
+	 * dimensi�n representa las bandas y la segunda la posici�n en la l�nea
+	 */  
+    public double[][] getLineDouble(int line) throws OperationNotSupportedException;
+    
+    //***********************************************
+    //Obtiene una linea de datos de una banda
+    
+    /**
+     * Obtiene una l�nea de datos de la banda solicitada para buffers con tipo
+	 * de dato byte.
+     * @param line N�mero de l�nea del buffer a recuperar
+     * @param band N�mero de banda a recuperar
+     * @return Array unidimensional que representa la l�nea de datos.
+     */
+    public byte[] getLineFromBandByte(int line, int band) throws OperationNotSupportedException;
+
+    /**
+     * Obtiene una l�nea de datos de la banda solicitada para buffers con tipo
+	 * de dato short.
+     * @param line N�mero de l�nea del buffer a recuperar
+     * @param band N�mero de banda a recuperar
+     * @return Array unidimensional que representa la l�nea de datos.
+     */
+    public short[] getLineFromBandShort(int line, int band) throws OperationNotSupportedException;
+
+    /**
+     * Obtiene una l�nea de datos de la banda solicitada para buffers con tipo
+	 * de dato int.
+     * @param line N�mero de l�nea del buffer a recuperar
+     * @param band N�mero de banda a recuperar
+     * @return Array unidimensional que representa la l�nea de datos.
+     */
+    public int[] getLineFromBandInt(int line, int band) throws OperationNotSupportedException;
+        
+    /**
+     * Obtiene una l�nea de datos de la banda solicitada para buffers con tipo
+	 * de dato float.
+     * @param line N�mero de l�nea del buffer a recuperar
+     * @param band N�mero de banda a recuperar
+     * @return Array unidimensional que representa la l�nea de datos.
+     */
+    public float[] getLineFromBandFloat(int line, int band) throws OperationNotSupportedException;
+    
+    /**
+     * Obtiene una l�nea de datos de la banda solicitada para buffers con tipo
+	 * de dato double.
+     * @param line N�mero de l�nea del buffer a recuperar
+     * @param band N�mero de banda a recuperar
+     * @return Array unidimensional que representa la l�nea de datos.
+     */
+    public double[] getLineFromBandDouble(int line, int band) throws OperationNotSupportedException;
+    
+    //***********************************************    
+    //Obtiene un elemento de la matriz
+    
+    /**
+     * Gets one element from the array if this is byte datatype
+     * @param line Y position
+     * @param col X position
+     * @param band Number of band to read
+     * @return Readed element
+     */
+    public byte getElemByte(int line, int col, int band);
+    
+    /**
+    * Gets one element from the array if this is short datatype
+    * @param line Y position
+    * @param col X position
+    * @param band Number of band to read
+    * @return Readed element
+    */
+    public short getElemShort(int line, int col, int band);
+    
+    /**
+     * Gets one element from the array if this is int datatype
+     * @param line Y position
+     * @param col X position
+     * @param band Number of band to read
+     * @return Readed element
+     */
+    public int getElemInt(int line, int col, int band);
+    
+    /**
+     * Gets one element from the array if this is float datatype
+     * @param line Y position
+     * @param col X position
+     * @param band Number of band to read
+     * @return Readed element
+     */
+    public float getElemFloat(int line, int col, int band);
+    
+    /**
+     * Gets one element from the array if this is double datatype
+     * @param line Y position
+     * @param col X position
+     * @param band Number of band to read
+     * @return Readed element
+     */
+    public double getElemDouble(int line, int col, int band);
+    
+    //***********************************************
+    //Copia un elemento de todas la bandas en el buffer pasado por par�metro
+    
+    /**
+     * Gets one element of each band from the array if this is byte datatype
+     * @param line Y position
+     * @param col X position
+     * @param data Each element of this array is a diferent band of the position line, col
+     */
+    public void getElemByte(int line, int col, byte[] data);
+    
+    /**
+     * Gets one element of each band from the array if this is short datatype
+     * @param line Y position
+     * @param col X position
+     * @param data Each element of this array is a diferent band of the position line, col
+     */
+    public void getElemShort(int line, int col, short[] data);
+    
+    /**
+     * Gets one element of each band from the array if this is int datatype
+     * @param line Y position
+     * @param col X position
+     * @param data Each element of this array is a diferent band of the position line, col
+     */
+    public void getElemInt(int line, int col, int[] data);
+    
+    /**
+     * Gets one element of each band from the array if this is float datatype
+     * @param line Y position
+     * @param col X position
+     * @param data Each element of this array is a diferent band of the position line, col
+     */
+    public void getElemFloat(int line, int col, float[] data);
+    
+    /**
+     * Gets one element of each band from the array if this is double datatype
+     * @param line Y position
+     * @param col X position
+     * @param data Each element of this array is a diferent band of the position line, col
+     */
+    public void getElemDouble(int line, int col, double[] data);
+    
+    //**************************************
+    //************SETTING DATA**************
+    //**************************************
+    
+    //***********************************************
+    //Asigna una linea de datos a una banda
+    
+    /**
+     * Sets a line of byte data
+     * @param data Array of data 
+     * @param line Y position
+     * @param band N�mber of band
+     * @throws OperationNotSupportedException 
+     */
+    public void setLineInBandByte(byte[] data, int line, int band) throws OperationNotSupportedException;
+
+    /**
+     * Sets a line of short data
+     * @param data Array of data 
+     * @param line Y position
+     * @param band N�mber of band
+     */
+    public void setLineInBandShort(short[] data, int line, int band) throws OperationNotSupportedException;
+
+    /**
+     * Sets a line of int data
+     * @param data Array of data 
+     * @param line Y position
+     * @param band N�mber of band
+     */
+    public void setLineInBandInt(int[] data, int line, int band) throws OperationNotSupportedException;
+       
+    /**
+     * Sets a line of float data
+     * @param data Array of data 
+     * @param line Y position
+     * @param band N�mber of band
+     */
+    public void setLineInBandFloat(float[] data, int line, int band) throws OperationNotSupportedException;
+    
+    /**
+     * Sets a line of double data
+     * @param data Array of data 
+     * @param line Y position
+     * @param band N�mber of band
+     */
+    public void setLineInBandDouble(double[] data, int line, int band) throws OperationNotSupportedException;
+    
+    //***********************************************
+    //Asigna una linea de datos a todas las bandas
+    
+    public void setLineByte(byte[][] data, int line) throws OperationNotSupportedException;
+
+    public void setLineShort(short[][] data, int line) throws OperationNotSupportedException;
+
+    public void setLineInt(int[][] data, int line) throws OperationNotSupportedException;
+        
+    public void setLineFloat(float[][] data, int line) throws OperationNotSupportedException;
+    
+    public void setLineDouble(double[][] data, int line) throws OperationNotSupportedException;
+    
+    //**********************************************    
+    //Asigna un elemento de la matriz
+    
+    public void setElem(int line, int col, int band, byte data) throws OperationNotSupportedException;
+    
+    public void setElem(int line, int col, int band, short data) throws OperationNotSupportedException;
+    
+    public void setElem(int line, int col, int band, int data) throws OperationNotSupportedException;
+    
+    public void setElem(int line, int col, int band, float data) throws OperationNotSupportedException;
+    
+    public void setElem(int line, int col, int band, double data) throws OperationNotSupportedException;
+    
+    //***********************************************
+    //Asigna un elemento a todas la bandas en el buffer pasado por par�metro
+    
+    public void setElemByte(int line, int col, byte[] data) throws OperationNotSupportedException;
+    
+    public void setElemShort(int line, int col, short[] data) throws OperationNotSupportedException;
+    
+    public void setElemInt(int line, int col, int[] data) throws OperationNotSupportedException;
+
+    public void setElemFloat(int line, int col, float[] data) throws OperationNotSupportedException;
+    
+    public void setElemDouble(int line, int col, double[] data) throws OperationNotSupportedException;
+    
+    //***********************************************
+    //Inicializa una banda a un valor pasado por par�metro
+    
+    public void assign(int band, byte value) throws OperationNotSupportedException;
+    
+    public void assign(int band, short value) throws OperationNotSupportedException;
+    
+    public void assign(int band, int value) throws OperationNotSupportedException;
+
+    public void assign(int band, float value) throws OperationNotSupportedException;
+    
+    public void assign(int band, double value) throws OperationNotSupportedException;
+    
+    //**************************************
+    //**********BANDS OPERATIONS************
+    //**************************************
+    
+    /**
+     * Removes a band from memory buffer
+     * @param band Number of band
+     */
+    public void removeBand(int pos) throws IOException ;
+    
+    /**
+     * Makes an empty band without initial value in the selected position
+     * @return IRasterBand New band
+     * @throws IOException 
+     */
+    public Band addBand(int pos) throws IOException;
+    
+    /**
+     * Sustituye una banda completa copiando los datos de la que se pasa por par�metro
+     * @param nBand N�mero de banda a sustituir
+     * @param banda a copiar
+     * @throws OperationNotSupportedException 
+     */
+    public void copyBand(int nBand, Band band) throws BandNotCompatibleException, OperationNotSupportedException;
+    
+    /**
+     * Creates a new band assigning other by reference. Owing to this fact, the band 
+     * assigned must be the same kind of buffer.
+     * @param  nBand 
+     *         band number to be assigned
+     * @param  banda 
+     *         Assigned band
+     * @throws IOException 
+     */
+    public void assignBand(int nBand, Band band) throws IOException, BandNotCompatibleException;
+    
+    /**
+     * Gets a band from raster by reference.
+     * @param  nBand 
+     *         Band number 
+     */
+    public Band getBand(int nBand);
+    
+    /**
+     * Gets a copy of one band from ra.
+     * @param  nBand 
+     *         Band number 
+     */
+    public Band getBandCopy(int nBand);
+    
+    /**
+     * Gets all bands in an IRasterBand array by reference.
+     * @return Array of IRasterBand
+     */
+    public Band[] getBands();
+    
+    /**
+     * Gets all bands in an IRasterBand array by reference.
+     * @return ArrayList of IRasterBand
+     */
+    public ArrayList<Band> getBandList();
+    
+    /**
+     * Gets a buffer with only one band. The number of this band is specified with the parameter.
+     * @param  nBand 
+     *         Band number
+     * @throws IOException 
+     * @throws OperationNotSupportedException 
+     */
+    public Buffer getBufferWithOneBand(int nBand) throws IOException, OperationNotSupportedException;
+    
+    /**
+     * This method create a new band with the value in selected in
+     * the parameter. Settings in the new band are readed from the existing 
+     * buffer.
+     * @param  defaultValue 
+     *         Default value in new band
+     * @throws OperationNotSupportedException 
+     */
+    public Band createBand(double defaultValue) throws OperationNotSupportedException;
+    
+    /**
+     * Replica la banda de una posici�n sobre otra. Si la banda de destino no existe
+     * se crea nueva. Si la posici�n de la banda de destino est� intercalada entre bandas 
+     * que ya existen las otras se desplazan hacia abajo, NO se machacan los datos de ninguna.
+     * Los datos se replican por referencia por lo que al modificar la banda original las
+     * del resto quedar�n afectadas.   
+     * @param orig. Posici�n de la banda de origen. 
+     * @param dest. Posici�n de la banda destino
+     * @throws IOException 
+     */   
+    public void replicateBand(int orig, int dest) throws IOException;
+    
+    /**
+     * Clona el buffer actual y devuelve el clone
+     * @return Buffer clonado
+     */
+    public Buffer cloneBuffer();
+    
+    /**
+     * Swap two bands.
+     * @param  band1 
+     *         band to swap with band2 
+     * @param  band2 
+     *         band to swap with band1
+     * @throws IOException 
+     * @throws WrongParameterException 
+     */
+    public void swapBands(int band1, int band2) throws WrongParameterException, IOException;
+    
+    /**
+     * Intercambia la posici�n de las bandas. La nueva posici�n viene dada por el vector
+     * pasado por par�metro. Cada posici�n del vector es una banda del buffer y el contenido de 
+     * esa posici�n es la banda que se dibujar� sobre ese buffer.
+	 * <P> 
+     * Por ejemplo un array con los valores:
+     * [2, 0, 1] significa que la banda que ocupa ahora la posici�n 2 pasar� a ocupar la 0, la que 
+     * tiene la posici�n 0 pasa a ocupar la 1 y la que tiene la posici�n 1 pasa a ocupar la 2.
+     * </P>
+     * @param bands  Array con la nueva distribuci�n de bandas
+     * @throws WrongParameterException 
+     * @throws IOException 
+     */
+    public void swapBands(int[] bands) throws WrongParameterException, IOException;
+    
+    /**
+     * Asigna el valor de no valido.
+     * @param value
+     */
+    public void setNotValidValue(double value);
+    
+    /**
+     * Obtiene el valor de no valido.
+     * @return value
+     */
+    public double getNotValidValue();
+    
+    /**
+     * Asigna una banda al valor especificado como no valido. Esta banda es com�n para todas las bandas
+     * del buffer, es decir se asigna por referencia. No tiene el mismo resultado que asignar una banda
+     * a un valor fijo.
+     * @param iBand N�mero de banda
+     * @throws OperationNotSupportedException 
+     */
+    public void assignBandToNotValid(int iBand) throws OperationNotSupportedException;
+    
+	/**
+	 * Gets the statistics object
+	 * @return BufferStats
+	 */
+	public BufferStats getStatistics();
+	
+	/**
+	 * Ajusta el �rea del grid a un ancho y un alto dado en pixeles. Este ajuste se har� 
+	 * en relaci�n a un m�todo de interpolaci�n definido en el par�metro.
+	 * @param w Ancho de la nueva imagen.
+	 * @param h Alto de la nueva imagen.
+	 * @param interpolation M�todo de interpolaci�n que se usar� en el ajuste.
+	 */
+	public Buffer getAdjustedWindow(int w, int h, int interpolationMethod) throws ProcessInterruptedException;
+    
+	/**
+	 * Selects bands for read-only buffers which referencing a image in disk
+	 * @param bands
+	 */
+	public void addDrawableBands(int[] bands);
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/Buffer.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:executable
   + *

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/histogram/BufferHistogram.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/histogram/BufferHistogram.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/histogram/BufferHistogram.java	(revision 3222)
@@ -0,0 +1,188 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.buffer.histogram;
+
+import org.gvsig.raster.cache.buffer.BufferNoData;
+
+/**
+ * Interfaz que representa un histograma.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public interface BufferHistogram {
+	/**
+	 * Obtiene el n�mero de bandas del histograma 
+	 * @return entero que representa el n�mero de bandas 
+	 */
+	public int getNumBands();
+	
+	/**
+	 * Obtiene la longitud (n�mero de valores) de una banda determinada
+	 * @param band Banda o obtener la longitud
+	 * @return entero con la longitud de la banda
+	 * rangos de valores y DataclassList.
+	 */
+	public int getBandLenght(int band);
+	
+	/**
+	 * Obtiene el tipo de datos del histograma original
+	 * @return
+	 */
+	public int getDataType();
+	
+	/**
+	 * Asigna un valor para una posici�n del histograma segun la posicion en las
+	 * clases
+	 * @param band Valor del pixel o clase a asignar
+	 * @param pos Posicion dentro de la clase. Ejemplo 0..63
+	 * @param value Valor a asignar
+	 */
+	public void setHistogramValueByPos(int band, int pos, long value);
+
+	/**
+	 * Obtiene un valor del histograma segun la posicion dentro de las clases
+	 * @param band N�mero de banda del valor a recuperar
+	 * @param px Pixel o valor de la clase del valor a recuperar
+	 * @return valor
+	 */
+	public double getHistogramValueByPos(int band, int pos);
+	
+	/**
+	 * Obtiene un valor del histograma
+	 * @param band N�mero de banda del valor a recuperar
+	 * @param px Pixel o valor de la clase del valor a recuperar
+	 * @return valor
+	 */
+	public double getHistogramValue(int band, double px);
+	
+	/**
+	 * Realiza la uni�n entre el histograma actual y el pasado 
+	 * por par�metro.
+	 * @param hist
+	 */
+	public boolean union(BufferHistogram hist);
+	
+	/**
+	 * Obtiene la tabla de valores
+	 * @return
+	 */
+	public long[][] getTable();
+	
+	/**
+	 * Asigna la tabla
+	 * @param t
+	 */
+	public void setTable(long[][] t);
+	
+	/**
+	 * Obtiene el histograma sin modificar
+	 * @return array bidimensional donde el primer elemento es el valor del pixel
+	 * o rango y el segundo el n�mero de elementos que aparecen.
+	 */
+	public HistogramClass[][] getHistogram();
+	
+	/**
+	 * Obtiene el histograma de la imagen negativa.
+	 * @return long[][]
+	 */
+	public long[][] getNegativeTable();
+	
+	/**
+	 * Devuelve el minimo valor del histograma
+	 * @return
+	 */
+	public double getMin(int band);
+
+	/**
+	 * Devuelve el maximo valor del histograma
+	 * @return
+	 */
+	public double getMax(int band);
+	
+	/**
+	 * Obtiene el n�mero de valores o clases del histograma
+	 * @return entero que representa el n�mero de valores o clases del histograma
+	 */
+	public int getNumValues();
+	
+	/**
+	 * Devuelve si un histograma esta en un rango RGB aceptable
+	 * @return
+	 */
+	public boolean isInRangeRGB();
+	
+	/**
+	 * Calculo de estad�sticas a partir de un histograma. El resultado de la funci�n es un array
+	 * bidimensional donde el primer �ndice inndica la estadistica y el segundo el n�mero de banda.
+	 * 
+	 * <UL>
+	 * <LI>m�nimo</LI>
+	 * <LI>m�ximo</LI>
+	 * <LI>media</LI>
+	 * <LI>mediana</LI>
+	 * <LI>N�mero de pixels</LI>
+	 * </UL>
+	 * @param histogram
+	 * @param beginPos Posici�n de inicio del histograma para contabilizar estadisticas
+	 * @param endPos Posici�n de fin del histograma para contabilizar estadisticas
+	 * @param bandas solicitadas. Cada elemento del vector representa una banda. Si est� a true se calcula la 
+	 * estadistica para esa banda y si est� a false no se calcular�.
+	 * @return
+	 */
+	public double[][] getBasicStats(double beginPos2, double endPos2, boolean[] bands);
+	
+	/**
+	 * Calculo de estad�sticas a partir de un histograma. El resultado de la funci�n es un array
+	 * bidimensional donde el primer �ndice inndica la estadistica y el segundo el n�mero de banda.
+	 * 
+	 * <UL>
+	 * <LI>m�nimo</LI>
+	 * <LI>m�ximo</LI>
+	 * <LI>media</LI>
+	 * <LI>mediana</LI>
+	 * <LI>N�mero de pixels</LI>
+	 * </UL>
+	 * @param histogram
+	 * @param bandas solicitadas. Cada elemento del vector representa una banda. Si est� a true se calcula la 
+	 * estadistica para esa banda y si est� a false no se calcular�.
+	 * @return
+	 */
+	public double[][] getBasicStats(boolean[] bands);
+	
+	/**
+	 * Adds a new table
+	 * @param table
+	 */
+	public void addTable(long[][] table);
+	
+	/**
+	 * Incrementa un valor de una posici�n del histograma
+	 * @param band N�mero de banda
+	 * @param px Pixel o valor de la clase
+	 */
+	public void incrementPxValue(int band, double px);
+	
+	/**
+	 * @param noDataValue the noDataValue to set
+	 */
+	public void setNoDataValue(BufferNoData noDataValue);
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/histogram/BufferHistogram.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/histogram/HistogramComputer.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/histogram/HistogramComputer.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/histogram/HistogramComputer.java	(revision 3222)
@@ -0,0 +1,68 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.buffer.histogram;
+
+import org.gvsig.raster.cache.buffer.exception.HistogramException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+
+/**
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public interface HistogramComputer {
+	
+	/**
+	 * Obtiene el minimo valor de las estadisticas de un histograma.
+	 * @return double
+	 */
+	public double getMinimum();
+
+	/**
+	 * Obtiene el maximo valor de las estadisticas de un histograma.
+	 * @return double
+	 */
+	public double getMaximum();
+	
+	/**
+	 * Obtiene el histograma. 
+	 * @return histograma 
+	 */
+	public BufferHistogram getBufferHistogram(int numberOfClasses) throws HistogramException, ProcessInterruptedException;
+
+	/**
+	 * Pone a cero el porcentaje de progreso del proceso de calculo de histograma
+	 */
+	public void resetPercent();
+
+	/**
+	 * Obtiene el porcentaje de progreso del proceso de calculo de histograma
+	 * @return porcentaje de progreso
+	 */
+	public int getPercent();
+	
+	/**
+	 * Force to recalculate the histogram next time that the method getBufferHistogram
+	 * be called 
+	 */
+	public void refreshHistogram();
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/histogram/HistogramComputer.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/histogram/package.html
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/histogram/package.html	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/histogram/package.html	(revision 3222)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<title>org.gvsig.raster.cache.buffer.histogram package documentation</title>
+</head>
+<body>
+
+	<p>Classes to get a buffer histogram</p>
+	
+	<p>
+	</p>
+
+</body>
+</html>
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/histogram/package.html
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/histogram/Histogramable.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/histogram/Histogramable.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/histogram/Histogramable.java	(revision 3222)
@@ -0,0 +1,44 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.buffer.histogram;
+
+import org.gvsig.raster.cache.buffer.exception.HistogramException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+
+
+/**
+ * This interface should be implemented for every class that is capable to
+ * provide an object to compute its histogram.
+ * 
+ * @version 27/03/2007
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ *
+ */
+public interface Histogramable {
+	
+	/**
+	 * Gets the object which computes the histogram
+	 * @return Histograma
+	 */
+	public HistogramComputer getHistogramComputer() throws HistogramException, ProcessInterruptedException;
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/histogram/Histogramable.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/histogram/HistogramClass.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/histogram/HistogramClass.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/histogram/HistogramClass.java	(revision 3222)
@@ -0,0 +1,92 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.buffer.histogram;
+
+
+/**
+ * Clase que define un intervalo de datos. Es util para cosas como el calculo de histogramas
+ * con tipo de datos en coma flotante en el cual hay que dividir los intervalos en
+ * clases. Las clases se tendr�n en cuenta como un intervalo el cual el menor es cerrado y el 
+ * mayor abierto, es decir
+ * <PRE>
+ * En las clases:
+ * 0-1000
+ * 1000-2000
+ * los intervalos son 
+ * [0, 1000 [  de 0-999.9p
+ * [1000, 2000[ de 1000-1999.9p
+ * </PRE>
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ *
+ */
+public interface HistogramClass {	
+	
+	/**
+	 * Comprueba si el valor pasado por par�metro est� dentro del intervalo
+	 * @param value Valor a comprobar
+	 * @return true si est� dentro del intervalo y false si no lo est�
+	 */
+	public boolean isIn(double value);
+	
+	/**
+	 * Obtiene el valor m�ximo de la clase
+	 * @return Entero que representa al valor m�ximo de la clase
+	 */
+	public double getMax();
+	
+	/**
+	 * Asigna el valor m�ximo de la clase
+	 * @param max Entero que representa al valor m�ximo de la clase
+	 */
+	public void setMax(double max);
+	
+	/**
+	 * Obtiene el valor m�nimo de la clase
+	 * @return Entero que representa al valor m�nimo de la clase
+	 */
+	public double getMin();
+	
+	/**
+	 * ASigna el valor m�nimo de la clase
+	 * @param min Entero que representa al valor m�nimo de la clase
+	 */
+	public void setMin(double min);
+
+	/**
+	 * Obtiene el valor de la clase
+	 * @return double con el valor
+	 */
+	public double getValue();
+
+	/**
+	 * Asigna el valor de la clase
+	 * @param double con el valor
+	 */
+	public void setValue(double value);
+	
+	/**
+	 * Incrementa en n el valor especificado
+	 * @param double n
+	 */
+	public void increment(double n);
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/histogram/HistogramClass.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/StatsValues.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/StatsValues.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/StatsValues.java	(revision 3222)
@@ -0,0 +1,135 @@
+package org.gvsig.raster.cache.buffer;
+
+/**
+ * Interface implemented by a raster band with statistics
+ * capabilities. 
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ *
+ */
+public interface StatsValues {
+	/**
+	 * Get the maximun value
+	 * @return double
+	 */
+	public double getMax();
+
+	/**
+	 * Set the maximun value
+	 * @param max
+	 */
+	public void setMax(double max);
+
+	/**
+	 * Get the minimun value
+	 * @return double
+	 */
+	public double getMin();
+
+	/**
+	 * Set the minimun value
+	 * @param max
+	 */
+	public void setMin(double min);
+
+	/**
+	 * Get the second maximun value
+	 * @return double
+	 */
+	public double getSecondMax();
+
+	/**
+	 * Set the second maximun value
+	 * @param max
+	 */
+	public void setSecondMax(double secondMax);
+
+	/**
+	 * Get the second minimun value
+	 * @return double
+	 */
+	public double getSecondMin();
+
+	/**
+	 * Set the second minimun value
+	 * @param max
+	 */
+	public void setSecondMin(double secondMin);
+
+	/**
+	 * Get the maximun value in a eight bits band.
+	 * A value of eight bits has a range betwen -127 and 128.
+	 * The maximun is readed in a range betwen 0 and 255.
+	 * @return
+	 */
+	public double getMaxRGB();
+
+	/**
+	 * Set the maximun value in a eight bits band.
+	 * A value of eight bits has a range betwen -127 and 128.
+	 * The maximun is writed in a range betwen 0 and 255.
+	 * @return
+	 */
+	public void setMaxRGB(double maxRGB);
+
+	/**
+	 * Get the minimun value in a eight bits band.
+	 * A value of eight bits has a range betwen -127 and 128.
+	 * The minimun is readed in a range betwen 0 and 255.
+	 * @return
+	 */
+	public double getMinRGB();
+
+	/**
+	 * Set the minimun value in a eight bits band.
+	 * A value of eight bits has a range betwen -127 and 128.
+	 * The minimun is readed in a range betwen 0 and 255.
+	 * @param  minRGB
+	 */
+	public void setMinRGB(double minRGB);
+
+	/**
+	 * Get the second maximun value in a eight bits band.
+	 * A value of eight bits has a range betwen -127 and 128.
+	 * The second maximun is readed in a range betwen 0 and 255.
+	 * @return
+	 */
+	public double getSecondMaxRGB();
+
+	/**
+	 * Set the second maximun value in a eight bits band.
+	 * A value of eight bits has a range betwen -127 and 128.
+	 * The second maximun is writed in a range betwen 0 and 255.
+	 * @return
+	 */
+	public void setSecondMaxRGB(double secondMaxRGB);
+
+	/**
+	 * Get the second minimun value in a eight bits band.
+	 * A value of eight bits has a range betwen -127 and 128.
+	 * The second minimun is readed in a range betwen 0 and 255.
+	 * @return
+	 */
+	public double getSecondMinRGB();
+
+	/**
+	 * Set the second minimun value in a eight bits band.
+	 * A value of eight bits has a range betwen -127 and 128.
+	 * The second minimun is readed in a range betwen 0 and 255.
+	 * @param  minRGB
+	 */
+	public void setSecondMinRGB(double secondMinRGB);
+
+	/**
+	 * Get the mean value in this band
+	 * @return
+	 */
+	public double getMean();
+
+	/**
+	 * Get the mean value in this band
+	 * @param mean
+	 */
+	public void setMean(double mean);
+	
+}
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/StatsValues.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/InvalidPageNumberException.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/InvalidPageNumberException.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/InvalidPageNumberException.java	(revision 3222)
@@ -0,0 +1,14 @@
+package org.gvsig.raster.cache.buffer.exception;
+
+/**
+ * Excepci�n lanzada cuando el n�mero de p�gina al que se intenta acceder no es valido.
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ *
+ */
+public class InvalidPageNumberException extends Exception {
+	private static final long serialVersionUID = -4312548276663417111L;
+
+	public InvalidPageNumberException(String msg){
+		super(msg);
+	}
+}
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/InvalidPageNumberException.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/HistogramException.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/HistogramException.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/HistogramException.java	(revision 3222)
@@ -0,0 +1,38 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.buffer.exception;
+/**
+ * Excepci�n lanzada por errores en el calculo de histogramas.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class HistogramException extends Exception {
+	private static final long serialVersionUID = 666908550965442025L;
+
+	public HistogramException(String msg, Throwable e) {
+		super(msg, e);
+	}
+	
+	public HistogramException(String msg){
+		super(msg);
+	}
+}
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/HistogramException.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/WrongParameterException.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/WrongParameterException.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/WrongParameterException.java	(revision 3222)
@@ -0,0 +1,15 @@
+package org.gvsig.raster.cache.buffer.exception;
+
+/**
+ * This exception is throwed when a parameter of a function is wrong.
+ * 
+ * 24/10/2008
+ * @author Nacho Brodin nachobrodin@gmail.com
+ */
+public class WrongParameterException  extends Exception {
+	private static final long serialVersionUID = -4312548276663417111L;
+
+	public WrongParameterException(String msg) {
+		super(msg);
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/WrongParameterException.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/package.html
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/package.html	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/package.html	(revision 3222)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<title>org.gvsig.raster.cache.buffer.exception package documentation</title>
+</head>
+<body>
+
+	<p>Exceptions which are thrown by a wrong buffer access</p>
+	
+	<p>
+	</p>
+
+</body>
+</html>
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/package.html
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/BufferInvalidException.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/BufferInvalidException.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/BufferInvalidException.java	(revision 3222)
@@ -0,0 +1,14 @@
+package org.gvsig.raster.cache.buffer.exception;
+
+/**
+ * Excepci�n lanzada cuando se detecta que un buffer de raster es incorrecto.
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ *
+ */
+public class BufferInvalidException extends Exception{
+	private static final long serialVersionUID = -1566113755637911586L;
+
+	public BufferInvalidException(String msg){
+		super(msg);
+	}
+}
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/BufferInvalidException.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/BufferInvalidAccessException.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/BufferInvalidAccessException.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/BufferInvalidAccessException.java	(revision 3222)
@@ -0,0 +1,16 @@
+package org.gvsig.raster.cache.buffer.exception;
+
+/**
+ * Excepci�n lanzada cuando se detecta un acceso a un tipo de datos incorrecto
+ * en un RasterBuffer.
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ *
+ */
+public class BufferInvalidAccessException extends Exception{
+
+	private static final long serialVersionUID = -3065331336250589153L;
+
+	public BufferInvalidAccessException(String msg){
+		super(msg);
+	}
+}
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/BufferInvalidAccessException.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/ProcessInterruptedException.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/ProcessInterruptedException.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/ProcessInterruptedException.java	(revision 3222)
@@ -0,0 +1,41 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.buffer.exception;
+
+import org.gvsig.tools.exception.BaseException;
+
+/**
+ * Excepci�n lanzada cuando se interrumpe un proceso
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class ProcessInterruptedException extends BaseException {
+	private static final long serialVersionUID = 666908550965442025L;
+
+	public ProcessInterruptedException(Throwable e){
+		super(e.getMessage(), e, "", 0);
+	}
+	
+	public ProcessInterruptedException(String msg){
+		super(msg, "", 0);
+	}
+}
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/ProcessInterruptedException.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/BandNotCompatibleException.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/BandNotCompatibleException.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/BandNotCompatibleException.java	(revision 3222)
@@ -0,0 +1,16 @@
+package org.gvsig.raster.cache.buffer.exception;
+
+/**
+ * This exception is throwed when a selected band is not compatible with other or
+ * with a databuffer.
+ * 
+ * 24/10/2008
+ * @author Nacho Brodin nachobrodin@gmail.com
+ */
+public class BandNotCompatibleException  extends Exception {
+	private static final long serialVersionUID = -4312548276663417111L;
+
+	public BandNotCompatibleException(String msg) {
+		super(msg);
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/BandNotCompatibleException.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/OperationNotSupportedException.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/OperationNotSupportedException.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/OperationNotSupportedException.java	(revision 3222)
@@ -0,0 +1,20 @@
+package org.gvsig.raster.cache.buffer.exception;
+
+/**
+ * This exception is throwed when a selected operation is not compatible with 
+ * the buffer
+ * 
+ * 24/10/2008
+ * @author Nacho Brodin nachobrodin@gmail.com
+ */
+public class OperationNotSupportedException  extends Exception {
+	private static final long serialVersionUID = -4312548276663417111L;
+
+	public OperationNotSupportedException(String message, Throwable cause) {
+       super(message, cause);
+    }
+	   
+	public OperationNotSupportedException(String msg) {
+		super(msg);
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/exception/OperationNotSupportedException.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/package.html
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/package.html	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/package.html	(revision 3222)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<title>org.gvsig.raster.cache.buffer package documentation</title>
+</head>
+<body>
+
+	<p>Basic API to access a buffer of raster data</p>
+	
+	<p>
+	</p>
+
+</body>
+</html>
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/package.html
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferCacheLocator.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferCacheLocator.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferCacheLocator.java	(revision 3222)
@@ -0,0 +1,84 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.buffer;
+
+import org.gvsig.tools.locator.BaseLocator;
+import org.gvsig.tools.locator.Locator;
+import org.gvsig.tools.locator.LocatorException;
+
+/**
+ * This locator is the entry point for the Raster library, providing
+ * access to all Raster services through the {@link BufferCacheManager}
+ * .
+ * 
+ * @author gvSIG team
+ * @version $Id$
+ */
+public class BufferCacheLocator extends BaseLocator {
+    public static final String               MANAGER_NAME            = "BufferCache.manager";
+    public static final String               MANAGER_DESCRIPTION     = "BufferCache Manager";
+    private static final String              LOCATOR_NAME            = "BufferCache.locator";
+    private static final BufferCacheLocator  INSTANCE                = new BufferCacheLocator();
+
+    /**
+     * Return the singleton instance.
+     * 
+     * @return the singleton instance
+     */
+    public static BufferCacheLocator getInstance() {
+        return INSTANCE;
+    }
+
+    /**
+     * Return the Locator's name.
+     * 
+     * @return a String with the Locator's name
+     */
+    public final String getLocatorName() {
+        return LOCATOR_NAME;
+    }
+
+    /**
+     * Return a reference to the RasterManager.
+     * 
+     * @return a reference to the RasterManager
+     * @throws LocatorException
+     *             if there is no access to the class or the class cannot be
+     *             instantiated
+     * @see Locator#get(String)
+     */
+    public static BufferCacheManager getManager() throws LocatorException {
+        return (BufferCacheManager) getInstance().get(MANAGER_NAME);
+    }
+
+    /**
+     * Registers the Class implementing the RasterManager interface.
+     * 
+     * @param clazz
+     *            implementing the RasterManager interface
+     */
+    public static void registerManager(
+        Class<? extends BufferCacheManager> clazz) {
+        getInstance().register(MANAGER_NAME, MANAGER_DESCRIPTION, clazz);
+    }
+
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferCacheLocator.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferInterpolation.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferInterpolation.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferInterpolation.java	(revision 3222)
@@ -0,0 +1,115 @@
+package org.gvsig.raster.cache.buffer;
+
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.task.IncrementableTask;
+
+/**
+ * Interface implemented by a buffer interpolation object 
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public interface BufferInterpolation extends IncrementableTask {
+	public final static int INTERPOLATION_Undefined        = 0;
+	public final static int INTERPOLATION_NearestNeighbour = 1;
+	public final static int INTERPOLATION_Bilinear         = 2;
+	public final static int INTERPOLATION_InverseDistance  = 3;
+	public final static int INTERPOLATION_Bicubic          = 4;
+	public final static int INTERPOLATION_BSpline          = 5;
+	
+	/**
+	 * Get the supersampled buffer on a IRasterBuffer
+	 * @return
+	 * @throws ProcessInterruptedException 
+	 */
+	public Buffer getSupersampledScrolledNearestNeighbour(double[] superSampStep, int w, int h) throws ProcessInterruptedException;
+	
+	public Buffer getSupersampledScrolledBilinearInterpolation(double[] superSampStep, int w, int h) throws ProcessInterruptedException;
+	
+	/**
+	 * Ajusta el raster al ancho y alto solicitado por el vecino m�s cercano. Promedia el valor de dos
+	 * pixeles contiguos.
+	 * @param w Nuevo ancho
+	 * @param h Nuevo alto
+	 */
+	public Buffer adjustRasterNearestNeighbourInterpolation(int w, int h) throws ProcessInterruptedException;
+
+	/**
+	 * Ajusta el raster al ancho y alto solicitado ajustando con una interpolaci�n bilineal. Promedia
+	 * el valor de cuatro pixeles adyacentes.
+	 * <P>
+	 * Para cada pixel del raster A:(x, y) obtiene el B:(x + 1, y), C:(x, y + 1), D:(x + 1, y + 1)
+	 * Para cada valor del kernel se calcula un valor 'd' que es un peso dependiendo de su posici�n.
+	 * Este peso depende de la posici�n del pixel destino dentro del origen. La posici�n del pixel destino
+	 * en el origen es un valor decimal que puede ir de 0 a 1. Si est� muy pegado a la esquina superior
+	 * izquierda estar� cercano a 0 y si est� muy pegado a la esquina inferior derecha estar� cercano a 1.
+	 * Este valor est� representado por 'dx' y 'dy'. 
+	 * </P>
+	 * <P>
+	 * Los pesos aplicados son a
+	 * <UL> 
+	 * <LI>A (1-dx) * (1-dy)</LI>
+	 * <LI>B dx * (1-dy)</LI>
+	 * <LI>C (1-dx) * dy</LI>
+	 * <LI>D dx * dy</LI>
+	 * </UL>
+	 * La variable 'z' contiene el valor acumulado de cada peso por el valor del pixel.
+	 * La variable 'n' contiene el valor acumulado de los pesos de los cuatro pixeles.
+	 * El valor final del pixel ser� 'z/n', es decir un promedio del valor de los cuatro teniendo
+	 * en cuenta el peso de cada uno.
+	 * </P>
+	 * @param w Nuevo ancho del buffer de salida
+	 * @param h Nuevo alto del buffer de salida
+	 */
+	public Buffer adjustRasterBilinearInterpolation(int w, int h) throws ProcessInterruptedException;
+
+	/**
+	 * Ajusta el raster al ancho y alto solicitado ajustando con una interpolaci�n de distancia inversa.
+	 * Asigna el valor de un pixel en funci�n inversa de la distancia.
+	 * <P>
+	 * Para cada pixel del raster A:(x, y) obtiene el B:(x + 1, y), C:(x, y + 1), D:(x + 1, y + 1)
+	 * Para cada valor del kernel se calcula un valor 'd' que es un peso dependiendo de su posici�n.
+	 * Este peso ser� dependiente de la posici�n del pixel destino dentro del origen. La posici�n del pixel destino
+	 * en el origen es un valor decimal que puede ir de 0 a 1. Si est� muy pegado a la esquina superior
+	 * izquierda estar� cercano a 0 y si est� muy pegado a la esquina inferior derecha estar� cercano a 1.
+	 * Este valor est� representado por 'dx' y 'dy'. En este caso, y a diferencia del m�todo
+	 * bilinear el peso vendr� representado por la inversa de la distancia entre la posici�n 
+	 * dentro del pixel y el origen del mismo.
+	 * </P>
+	 * <P>
+	 * Los pesos aplicados son a
+	 * <UL> 
+	 * <LI>A  1 / sqrt((1-dx) * (1-dy))</LI>
+	 * <LI>B  1 / sqrt(dx * (1-dy))</LI>
+	 * <LI>C  1 / sqrt((1-dx) * dy)</LI>
+	 * <LI>D  1 / sqrt(dx * dy)</LI>
+	 * </UL>
+	 * La variable 'z' contiene el valor acumulado de cada peso por el valor del pixel.
+	 * La variable 'n' contiene el valor acumulado de los pesos de los cuatro pixeles.
+	 * El valor final del pixel ser� 'z/n', es decir un promedio del valor de los cuatro teniendo
+	 * en cuenta el peso de cada uno.
+	 * </P>
+	 * @param w Nuevo ancho del buffer de salida
+	 * @param h Nuevo alto del buffer de salida
+	 */
+	public Buffer adjustRasterInverseDistanceInterpolation(int w, int h) throws ProcessInterruptedException;
+	/**
+	 * Ajusta el raster al ancho y alto solicitado ajustando con una interpolaci�n BSpline. Promedia
+	 * el valor de cuatro pixeles adyacentes.
+	 * @param w Nuevo ancho
+	 * @param h Nuevo alto
+	 */
+	public Buffer adjustRasterBSplineInterpolation(int w, int h) throws ProcessInterruptedException;
+
+	/**
+	 * Ajusta el raster al ancho y alto solicitado ajustando con una interpolaci�n de spline bicubica.
+	 * @param w Nuevo ancho
+	 * @param h Nuevo alto
+	 */
+	public Buffer adjustRasterBicubicSplineInterpolation(int w, int h) throws ProcessInterruptedException;
+
+	/**
+	 * Obtiene el porcentaje del proceso de interpolacion
+	 * @return
+	 */
+	public int getPercent();
+}
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferInterpolation.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/task/BaseIncrementableTask.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/task/BaseIncrementableTask.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/task/BaseIncrementableTask.java	(revision 3222)
@@ -0,0 +1,19 @@
+package org.gvsig.raster.cache.buffer.task;
+
+/**
+ * Base class for incrementable tasks
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public interface BaseIncrementableTask {
+
+	/**
+	 * Gets the increment
+	 * @return int
+	 */
+	public int getPercent();
+
+	/**
+	 * Sets the increment of this task 
+	 */
+	public void setPercent(int value);
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/task/BaseIncrementableTask.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/task/CancelEvent.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/task/CancelEvent.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/task/CancelEvent.java	(revision 3222)
@@ -0,0 +1,23 @@
+package org.gvsig.raster.cache.buffer.task;
+
+import java.util.EventObject;
+
+/**
+ * Evento de cancelaci�n a los procesos registrados en RasterTaskQueue.
+ * 
+ * @version 17/09/2007
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ *
+ */
+public class CancelEvent extends EventObject {
+
+	private static final long serialVersionUID = 7564626429497930401L;
+
+	/**
+	 * Construye un CancelEvent
+	 * @param source
+	 */
+	public CancelEvent(Object source) {
+		super(source);
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/task/CancelEvent.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/task/IncrementableTask.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/task/IncrementableTask.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/task/IncrementableTask.java	(revision 3222)
@@ -0,0 +1,30 @@
+package org.gvsig.raster.cache.buffer.task;
+
+/**
+ * This interface defines methods for common tasks 
+ * 
+ * @version 07/05/2007
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ *
+ */
+public interface IncrementableTask extends BaseIncrementableTask {
+	/**
+	 * Devuelve el contenido del log del IncrementableTask
+	 * @return String
+	 */
+	public String getLog();
+
+	/**
+	 * <p>Determines if this process can be canceled.</p>
+	 * 
+	 * @return <code>true</code> if this process can be canceled, otherwise <code>false</code>
+	 */
+	public boolean isCancelable();
+
+	/**
+	 * <p>Determines if this process can be paused.</p>
+	 * 
+	 * @return <code>true</code> if this process can be paused, otherwise <code>false</code>
+	 */
+	public boolean isPausable();
+}
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/task/IncrementableTask.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/task/package.html
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/task/package.html	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/task/package.html	(revision 3222)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<title>org.gvsig.raster.cache.buffer.task package documentation</title>
+</head>
+<body>
+
+	<p>Buffer tasks</p>
+	
+	<p>
+	</p>
+
+</body>
+</html>
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/task/package.html
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/task/TaskEventManager.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/task/TaskEventManager.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/task/TaskEventManager.java	(revision 3222)
@@ -0,0 +1,49 @@
+package org.gvsig.raster.cache.buffer.task;
+
+import java.util.EventObject;
+
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+
+
+/**
+ * Service to send events to a task. To register a new event you have to
+ * use the RasterManager
+ * <code>TaskEventManager task = manager.createRasterTask(this);</code>
+ * You can send events to the task 
+ * <code>task.sendEvent(new CancelEvent(this));</code>
+ * If you want recover a registered task to send it a event you'll have
+ * to use the RasterManager again. To get the task it will use the current
+ * thread ID.
+ * <code>TaskEventManager task = manager.getRasterTask()</code>
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public interface TaskEventManager {
+	
+	/**
+	 * Removes this task from the repository
+	 * @param 
+	 */
+	public void removeTask();
+	
+	/**
+	 * Sets a event. 
+	 * @param ev EventObject
+	 */
+	public void setEvent(EventObject ev);
+	
+	/**
+	 * Obtiene el evento
+	 * @return EventObject
+	 */
+	public EventObject getEvent();
+	
+	/**
+	 * Gesti�n de las se�ales. Este m�todo define las acciones por defecto para
+	 * cada se�al. No es necesario utilizar estas. Se puede en cada caso, hacer un m�todo
+	 * manageEvent en el que se gestione las acciones concretas de una se�al.
+	 * 
+	 * @param ev Evento a gestionar
+	 */
+	public void manageEvent(EventObject ev) throws ProcessInterruptedException;
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/task/TaskEventManager.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/task/Task.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/task/Task.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/task/Task.java	(revision 3222)
@@ -0,0 +1,39 @@
+package org.gvsig.raster.cache.buffer.task;
+
+import java.util.EventObject;
+/**
+ * A process have to contain a {@link Task} object. A process should be
+ * registered when this starts and removed from the register when this finishes or
+ * is canceled. This process has to do these actions.  
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public interface Task {
+
+	/**
+	 * Asigna el evento
+	 * @param ev EventObject
+	 */
+	public void setEvent(EventObject ev);
+	
+	/**
+	 * Obtiene el evento
+	 * @return EventObject
+	 */
+	public EventObject getEvent();
+	
+	/**
+	 * Obtiene el identificador �nico del proceso. 
+	 * @return Identificador del proceso
+	 */
+	public String getID();
+	
+	/**
+	 * Gesti�n de las se�ales. Este m�todo define las acciones por defecto para
+	 * cada se�al. No es necesario utilizar estas. Se puede en cada caso, hacer un m�todo
+	 * manageEvent en el que se gestione las acciones concretas de una se�al.
+	 * 
+	 * @param ev Evento a gestionar
+	 */
+	public  void manageEvent(EventObject ev) throws InterruptedException;
+}
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/task/Task.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferCacheLibrary.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferCacheLibrary.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferCacheLibrary.java	(revision 3222)
@@ -0,0 +1,52 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.buffer;
+
+import org.gvsig.tools.library.AbstractLibrary;
+import org.gvsig.tools.library.LibraryException;
+import org.gvsig.tools.locator.ReferenceNotRegisteredException;
+
+
+/**
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class BufferCacheLibrary extends AbstractLibrary {
+	
+	public BufferCacheLibrary() {
+        registerAsAPI(BufferCacheLibrary.class);
+	}
+	
+	@Override
+    protected void doInitialize() throws LibraryException {
+    }
+
+    @Override
+    protected void doPostInitialize() throws LibraryException {
+        BufferCacheManager manager = BufferCacheLocator.getManager();
+        if (manager == null) {
+            throw new ReferenceNotRegisteredException(
+                BufferCacheLocator.MANAGER_NAME, BufferCacheLocator
+                    .getInstance());
+        }
+    }
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferCacheLibrary.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferDataSource.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferDataSource.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferDataSource.java	(revision 3222)
@@ -0,0 +1,156 @@
+package org.gvsig.raster.cache.buffer;
+
+import java.io.IOException;
+
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+
+
+/**
+ * Data Server for read only buffers. 
+ * 02/11/2008
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public interface BufferDataSource {
+	/**
+	 * Get the path to image file
+	 * @return
+	 */
+	public String[] getPath();
+	
+	/**
+	 * Set the path to image file
+	 * @param  path
+	 *         path to the file
+	 */
+	public void setPath(String[] path);
+	
+	/**
+	 * Set the path to image file
+	 * @param  path
+	 *         path to the file
+	 */
+	public void setPath(String path);
+	
+	/**
+	 * Get the band selected to read for loadSelectedBand method
+	 * @return
+	 */
+	public int getSelectedBand();
+	
+	/**
+	 * Set the band selected to read for loadSelectedBand method
+	 * @param  band
+	 *         band to the file
+	 */
+	public void setSelectedBand(int path);
+	
+	/**
+	 * Get the width of the data source
+	 * @return
+	 */
+	public int getWidth();
+	
+	/**
+	 * Get the height of the data source
+	 * @return
+	 */
+	public int getHeight();
+	
+	/**
+	 * Get de number of bands
+	 * @return
+	 */
+	public int getBandCount();
+	
+	/**
+	 * Get the data type
+	 * @return
+	 */
+	public int getDataType();
+
+	/**
+	 * Load a page with data. 
+	 * @param  rb
+	 *         Page 
+	 * @param  stripe
+	 *         Object with the information about data read. This contains positional information.
+	 * @throws IOException
+	 * @throws InterruptedException
+	 * @throws OperationNotSupportedException
+	 */
+	public void loadPage(Buffer rb, PxTile stripe) throws IOException, ProcessInterruptedException, OperationNotSupportedException;
+	
+	/**
+	 * Load a one banded page with data. 
+	 * @param  rb
+	 *         Page 
+	 * @param  stripe
+	 *         Object with the information about data read. This contains positional information.
+	 * @param  iBand
+	 *         Band to load
+	 * @throws IOException
+	 * @throws InterruptedException
+	 * @throws OperationNotSupportedException
+	 */
+	public void loadPage(Buffer rb, PxTile stripe, int iBand) throws IOException, ProcessInterruptedException, OperationNotSupportedException;
+	
+	/**
+	 * Load a page with data. Only is loaded the band selected in the variable "selectedBand" 
+	 * @param  rb
+	 *         Page 
+	 * @param  stripe
+	 *         Object with the information about data read. This contains positional information.
+	 * @throws IOException
+	 * @throws OperationNotSupportedException
+	 * @throws ProcessInterruptedException 
+	 */
+	public void loadSelectedBand(Buffer rb, PxTile stripe) throws IOException, OperationNotSupportedException, ProcessInterruptedException;
+	
+	/**
+	 * Load a page of cache from the hard disk
+	 * @param RasterMemoryBuffer Data buffer to load in memory 
+	 * @param String File name
+	 */
+	public void loadPage(Buffer buf, String file) throws InterruptedException;
+	
+	/**
+	 * Save a page of cache to the hard disk   
+	 * @param RasterMemoryBuffer Data buffer to load in memory 
+	 * @param String File name
+	 * @throws IOException
+	 */
+	public void savePage(Buffer buf, String file)throws IOException;
+	
+	/**
+	 * Save a band of cache to the hard disk   
+	 * @param RasterMemoryBuffer Data buffer to load in memory 
+	 * @param String File name
+	 * @throws IOException
+	 */
+	public void saveBand(Band buf, String file)throws IOException;
+	
+	/**
+	 * Elimina la fuente de datos de disco
+	 * @throws IOException
+	 */
+	public void delete(String file)throws IOException;
+	
+	/**
+	 * Close the data source
+	 */
+	public void close() throws IOException;
+	
+	/**
+	 * Change the name of a file
+	 * @param oldName
+	 * @param newName
+	 */
+	public void changeFileName(String oldName, String newName);
+	
+	/**
+	 * Clone the datasource to be assigned to each band
+	 * @return
+	 */
+	public BufferDataSource clone();
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/src/main/java/org/gvsig/raster/cache/buffer/BufferDataSource.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/pom.xml
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/pom.xml	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/pom.xml	(revision 3222)
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<artifactId>org.gvsig.raster.cache.lib.api</artifactId>
+	<packaging>jar</packaging>
+	<name>org.gvsig.raster.cache.lib.api</name>
+	<parent>
+		<groupId>org.gvsig</groupId>
+		<artifactId>org.gvsig.raster.cache</artifactId>
+		<version>2.2.1</version>
+	</parent>
+	<dependencies>
+		<dependency>
+            <groupId>org.gvsig</groupId>
+            <artifactId>org.gvsig.tools.lib</artifactId>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.gvsig</groupId>
+            <artifactId>org.gvsig.compat.api</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.gvsig</groupId>
+            <artifactId>org.gvsig.compat.se</artifactId>
+            <scope>compile</scope>
+        </dependency>
+     </dependencies>
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-jar-plugin</artifactId>
+				<configuration>
+				</configuration>
+				<executions>
+				<!--
+				Generates a jar file only with the test classes
+				-->
+					<execution>
+						<goals>
+							<goal>test-jar</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+		</plugins>
+	</build>
+</project>

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api/pom.xml
___________________________________________________________________
Added: svn:mime-type
   + text/plain


Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.api
___________________________________________________________________
Added: svn:ignore
   + .project

.classpath

target

.settings


Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/pom.xml
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/pom.xml	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/pom.xml	(revision 3222)
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>org.gvsig.raster.cache</artifactId>
+    <packaging>pom</packaging>
+    <name>org.gvsig.raster.cache</name>
+    <description>Cache management for raster files</description>
+    <version>2.2.1</version>
+    <scm>
+        <connection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1</connection>
+        <developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1</developerConnection>
+        <url>https://devel.gvsig.org/redmine/projects/gvsig-raster/repository/show/org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1</url>
+    </scm>
+    
+    <repositories>
+      <repository>
+        <id>gvsig-public-http-repository</id>
+        <name>gvSIG maven public HTTP repository</name>
+        <url>http://devel.gvsig.org/m2repo/j2se</url>
+        <releases>
+          <enabled>true</enabled>
+          <updatePolicy>daily</updatePolicy>
+          <checksumPolicy>warn</checksumPolicy>
+        </releases>
+        <snapshots>
+          <enabled>true</enabled>
+          <updatePolicy>daily</updatePolicy>
+          <checksumPolicy>warn</checksumPolicy>
+        </snapshots>
+      </repository>
+    </repositories>
+    
+    <parent>
+      <groupId>org.gvsig</groupId>
+      <artifactId>org.gvsig.desktop</artifactId>
+      <version>2.0.89</version>
+    </parent>
+
+    <developers>
+        <developer>
+            <id>nbrodin</id>
+            <name>Nacho Brodin</name>
+            <email>nachobrodin@gmail.com</email>
+            <roles>
+                <role>Architect</role>
+                <role>Developer</role>
+            </roles>
+        </developer>
+    </developers>
+
+     <dependencyManagement>
+        <dependencies>
+
+      
+            <!--
+            Versions of child projects
+            -->
+            <dependency>
+                <groupId>org.gvsig</groupId>
+                <artifactId>org.gvsig.raster.cache.lib.api</artifactId>
+                <version>2.2.1</version>
+            </dependency>
+            <dependency>
+                <groupId>org.gvsig</groupId>
+                <artifactId>org.gvsig.raster.cache.lib.impl</artifactId>
+                <version>2.2.1</version>
+            </dependency>
+
+
+        </dependencies>
+    </dependencyManagement>
+    
+    <dependencies>
+        <dependency>
+            <groupId>org.gvsig</groupId>
+            <artifactId>org.gvsig.tools.lib</artifactId>
+            <scope>compile</scope>
+        </dependency>
+    </dependencies>
+    
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-release-plugin</artifactId>
+                <configuration>
+                    <tagBase>https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.cache/tags/</tagBase>
+                    <goals>deploy</goals>
+                </configuration>
+            </plugin>
+            <plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<configuration>
+					<source>1.5</source>
+					<target>1.5</target>
+				</configuration>
+			</plugin>
+			<plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>animal-sniffer-maven-plugin</artifactId>
+                <configuration>
+                    <skip>true</skip>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+    <modules>
+        <module>org.gvsig.raster.cache.lib.api</module>
+        <module>org.gvsig.raster.cache.lib.impl</module>
+    </modules>
+</project>

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/pom.xml
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/pom.xml
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/pom.xml	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/pom.xml	(revision 3222)
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<artifactId>org.gvsig.raster.cache.lib.impl</artifactId>
+	<packaging>jar</packaging>
+	<name>org.gvsig.raster.cache.lib.impl</name>
+	<parent>
+		<groupId>org.gvsig</groupId>
+		<artifactId>org.gvsig.raster.cache</artifactId>
+		<version>2.2.1</version>
+	</parent>
+	<dependencies>
+		<dependency>
+			<groupId>org.gvsig</groupId>
+			<artifactId>org.gvsig.raster.cache.lib.api</artifactId>
+            <scope>compile</scope>
+		</dependency>
+        <dependency>
+            <groupId>org.gvsig</groupId>
+            <artifactId>org.gvsig.fmap.dal.file.lib</artifactId>
+            <scope>compile</scope>
+        </dependency>
+		<dependency>
+            <groupId>org.gvsig</groupId>
+            <artifactId>org.gvsig.compat.api</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.gvsig</groupId>
+            <artifactId>org.gvsig.compat.se</artifactId>
+            <scope>compile</scope>
+        </dependency>
+ 
+	</dependencies>
+</project>

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/pom.xml
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/others/ArrayVsArrayList.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/others/ArrayVsArrayList.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/others/ArrayVsArrayList.java	(revision 3222)
@@ -0,0 +1,70 @@
+package org.gvsig.raster.cache.buffer.impl.others;
+
+import java.util.ArrayList;
+
+import org.gvsig.raster.cache.buffer.PxTile;
+import org.gvsig.raster.cache.buffer.impl.PxTileImpl;
+import org.gvsig.raster.cache.buffer.impl.rocache.ByteBand;
+import org.gvsig.raster.cache.buffer.impl.rocache.ReadOnlyCacheBand;
+
+/**
+ * This test compare the access time of an element in two cases. The first
+ * case is the access to an element in a simple array of objects. The second
+ * case is the access to an element in an ArrayList.
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ *
+ */
+public class ArrayVsArrayList {
+	public static int N = 500000;
+	/**
+	 * @param args
+	 */
+	public static void main(String[] args) {
+		ArrayVsArrayList p = new ArrayVsArrayList();
+		p.array();
+		p.arrayList();
+	}
+	
+	private void array() {
+		long t1 = System.currentTimeMillis();
+		ArrayList<PxTile> stripeList = new ArrayList<PxTile>();
+		for (int i = 0; i < 1; i++) 
+			stripeList.add(new PxTileImpl(0, 0, 0, 0));
+		
+		ReadOnlyCacheBand[] l = new ReadOnlyCacheBand[N];
+		for (int i = 0; i < N; i++) {
+			ByteBand b =  new ByteBand(stripeList, null, 15, 15, 15, 2345, 3244);
+			l[i] = b;
+		}
+		int z = 0;
+		for (int i = 0; i < N; i++) {
+			int y = l[i].getBandNumber();
+			z += y;
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Time Array with " + N + " elements: " + (t2 - t1) + " milisegundos" + z);
+		
+	}
+	
+	private void arrayList() {
+		long t1 = System.currentTimeMillis();
+		ArrayList<PxTile> stripeList = new ArrayList<PxTile>();
+		for (int i = 0; i < 1; i++) 
+			stripeList.add(new PxTileImpl(0, 0, 0, 0));
+		
+		ArrayList<ReadOnlyCacheBand> l = new ArrayList<ReadOnlyCacheBand>();
+		for (int i = 0; i < N; i++) {
+			ByteBand b =  new ByteBand(stripeList, null, 15, 15, 15, 2345, 3244);
+			l.add(b);
+		}
+		int z = 0;
+		for (int i = 0; i < N; i++) {
+			int y = l.get(i).getBandNumber();
+			z += y;
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Time ArrayList with " + N + " elements: " + (t2 - t1) + " milisegundos" + z);
+	}
+
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/others/ArrayVsArrayList.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/others/TestCacheVsMemory.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/others/TestCacheVsMemory.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/others/TestCacheVsMemory.java	(revision 3222)
@@ -0,0 +1,151 @@
+package org.gvsig.raster.cache.buffer.impl.others;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer;
+import org.gvsig.raster.cache.buffer.impl.stripecache.horizontal.RasterCacheBuffer;
+
+/**
+ * Performance Test: It loads a complete image of 65MB in a cached buffer and after read the
+ * same image in a memory buffer. For this test we use a small size of cache (2MB) and a size of
+ * one page of 0.2MB
+ *  
+ * REPEAT = 1
+ * Using setValues
+ * Time cached: 1538 ms
+ * Time memory: 1163 ms
+ * 
+ * REPEAT = 1
+ * Using setLines
+ * Time cached: 198 ms
+ * Time memory: 171 ms
+ *
+ * REPEAT = 10
+ * Using setValues
+ * Time cached: 14317 ms
+ * Time memory: 11168 ms
+ * 
+ * REPEAT = 10
+ * Using setLines
+ * Time cached: 1944 ms
+ * Time memory: 1209 ms
+ * 
+ * Intel(R) Core(TM)2 CPU E8400  @ 3.00GHz
+ * 2GB RAM DDR3 1066
+ * HDD ATA 133
+ * Linux Ubuntu 10.04 kernel 2.6.24
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestCacheVsMemory extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private static int REPEAT = 10;
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("CacheVsMemory running...");
+	}
+	
+	public void testStack() {
+		
+		try {
+			GdalRead input = null;
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 25;
+			BufferCacheManagerImpl.pageSize = 2;
+		
+			//****************CACHE**********************
+			long t1 = System.currentTimeMillis();
+			for (int iTimes = 0; iTimes < REPEAT; iTimes++) {
+
+				//Create Buffer
+				Buffer buf1 = new RasterCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+						input.getWidth(), 
+						input.getHeight(),
+						input.getBandCount());
+
+				//Set data to buffer
+				setValues(dataIn, buf1);
+				buf1.free();
+			}
+			
+			long t2 = System.currentTimeMillis();
+			System.out.println("Tiempo StripeCache : " + (t2 - t1) + " milisegundos");
+			//****************FIN CACHE******************
+			
+			//****************MEMO***********************
+			t1 = System.currentTimeMillis();
+			for (int iTimes = 0; iTimes < REPEAT; iTimes++) {
+
+				//Create Buffer
+				Buffer buf2 = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+						input.getWidth(), 
+						input.getHeight(),
+						input.getBandCount(),
+						true);
+
+				//Set data to buffer
+				setValues(dataIn, buf2);
+				buf2.free();
+			}
+			
+			t2 = System.currentTimeMillis();
+			System.out.println("Tiempo Memoria : " + (t2 - t1) + " milisegundos");
+			//****************FIN MEMO******************
+			
+			input.close();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		
+		
+	}
+	
+	public void setValues(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int band = 0; band < d.length; band++) {
+				for (int row = 0; row < d[band].length; row++) {
+					for (int col = 0; col < d[band][row].length; col++) {
+						buf.setElem(row, col, band, (byte)d[band][row][col]);
+					}
+				}
+			}
+    	}
+	}
+	
+	public void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/others/TestCacheVsMemory.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestCopyBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestCopyBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestCopyBand.java	(revision 3222)
@@ -0,0 +1,60 @@
+package org.gvsig.raster.cache.buffer.impl.rocache;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.impl.io.BufferDataSourceImpl;
+
+/**
+ * Copy the band 0 from a buffer over the band 2 in the same buffer using the
+ * method getBandCopy.  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestCopyBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("ROCache TestCopyBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+
+		try {			
+			BufferDataSource ds = null;
+			try {
+				ds = new BufferDataSourceImpl(rasterIn);
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+			Buffer buf = new RasterReadOnlyBuffer(ds);
+			
+			Band rb = buf.getBandCopy(0);
+						
+			Band band1 = buf.getBand(0);
+			for (int i = 0; i < band1.getHeight(); i++) {
+				for (int j = 0; j < band1.getWidth(); j++) {
+					byte b1 = band1.getElemByte(i, j);
+					byte b2 = rb.getElemByte(i, j);
+					assertEquals(b1, b2);
+				}
+			}
+			
+			buf.free();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo ROCache TestCopyBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestCopyBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestRemoveBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestRemoveBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestRemoveBand.java	(revision 3222)
@@ -0,0 +1,105 @@
+package org.gvsig.raster.cache.buffer.impl.rocache;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.io.BufferDataSourceImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer;
+
+/**
+ * This test read a RGB image and remove one band from the read buffer. Then compare 
+ * the bands that have not been removed with the source bands. As a result of this test a raster
+ * of two bands is created and saved in the hard disk
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestRemoveBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("ROCache TestRemoveBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		try {
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+
+			//Create Buffer
+			Buffer buf1 = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+					input.getWidth(), 
+					input.getHeight(),
+					input.getBandCount(),
+					true);
+
+			//Set data to buffer
+			setLines(dataIn, buf1);
+
+			BufferDataSource ds = null;
+			try {
+				ds = new BufferDataSourceImpl(rasterIn);
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+			Buffer buf2 = new RasterReadOnlyBuffer(ds);
+
+			//Remove bands
+			buf2.removeBand(1);
+			buf1.removeBand(1);
+			compareIRasterBuffer(buf1, buf2);
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo ROCache TestRemoveBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+	public void compareIRasterBuffer(Buffer b1, Buffer b2) {
+		for (int iBand = 0; iBand < b1.getBandCount(); iBand++) {
+			
+		for (int i = 0; i < b1.getHeight(); i++) {
+			for (int j = 0; j < b1.getWidth(); j++) {
+				byte b = b1.getElemByte(i, j, iBand);
+				byte c = b2.getElemByte(i, j, iBand);
+				if(b != c)
+					System.out.println("B:" + iBand + "" + i + " " + j);
+				assertEquals(c, b);
+			}
+		}
+		
+		}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestRemoveBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestSwapBands.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestSwapBands.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestSwapBands.java	(revision 3222)
@@ -0,0 +1,125 @@
+package org.gvsig.raster.cache.buffer.impl.rocache;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.exception.WrongParameterException;
+import org.gvsig.raster.cache.buffer.impl.io.BufferDataSourceImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer;
+
+/**
+ * This test swap several bands of a raster compare the result with a memory buffer
+ * swaped.
+ * <P>
+ * The array to test is {2, 0, 1}. That means the band 0 goes to the position two, the
+ * band one goes to the position zero and the band two goes to the position one. 
+ * When the swap operation is executed, this test will check comparing the result 
+ * bands with the input bands 
+ * </P>
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestSwapBands extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("ROCache TestSwapBands running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input1 = null;
+		try {
+			//Read input data
+			input1 = new GdalRead(rasterIn);
+			Object dataIn1 = input1.readBlock(0, 0, input1.getWidth(), input1.getHeight());
+
+			//Create Buffer						
+			Buffer buf2 = new RasterMemoryBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+					input1.getWidth(), 
+					input1.getHeight(),
+					input1.getBandCount(),
+					true);
+
+			//Set data to buffer
+			setLines(dataIn1, buf2);
+
+			BufferDataSource ds = null;
+			try {
+				ds = new BufferDataSourceImpl(rasterIn);
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+			RasterReadOnlyBuffer buf1 = new RasterReadOnlyBuffer(ds);
+			try {
+				buf2.swapBands(new int[]{2, 0, 1});
+				buf1.swapBands(new int[]{2, 0, 1});
+			} catch (WrongParameterException e) {
+				e.printStackTrace();
+			}
+			
+			//Write output file 
+						
+			Band band1 = buf1.getBand(0);
+			Band band2 = buf2.getBand(0);
+			compareBands(band1, band2);
+			
+			band1 = buf1.getBand(1);
+			band2 = buf2.getBand(1);
+			compareBands(band1, band2);
+			
+			band1 = buf1.getBand(2);
+			band2 = buf2.getBand(2);
+			compareBands(band1, band2);
+			
+			buf1.free();
+			buf2.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo ROCache TestSwapBands: " + (t2 - t1) + " milisegundos");
+	}
+	
+	public void compareBands(Band band1, Band band2) {
+		for (int i = 0; i < band1.getHeight(); i++) {
+			for (int j = 0; j < band1.getWidth(); j++) {
+				byte b1 = band1.getElemByte(i, j);
+				byte b2 = band2.getElemByte(i, j);
+				if(b1 != b2)
+					System.out.println(i + " " + j);
+				assertEquals(b1, b2);
+			}
+		}
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestSwapBands.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestReadWindowAndCompareData.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestReadWindowAndCompareData.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestReadWindowAndCompareData.java	(revision 3222)
@@ -0,0 +1,112 @@
+package org.gvsig.raster.cache.buffer.impl.rocache;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferParam;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.BufferParamImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer;
+
+/**
+ * Read a number from cache
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestReadWindowAndCompareData extends TestCase {
+	private String in = "./src/test/resources/image/001m09_1_0.tif";
+	private int    initX  = 200;
+	private int    initY  = 200;
+	private int    w      = 400;
+	private int    h      = 400;
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("ROCache TestReadTiffAndCompareData running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		
+		BufferCacheManagerImpl.cacheSize = 1;
+		BufferCacheManagerImpl.pageSize = 0.2;
+		
+		Buffer buf1 = null;
+		try {
+			input = new GdalRead(in);
+
+			Object dataIn = input.readBlock(initX, initY, w, h);
+
+			//Create Buffer
+			buf1 = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+											w, 
+											h,
+											input.getBandCount(),
+											true);
+
+			//Set data to buffer
+			setLines(dataIn, buf1);
+		} catch (GdalException e1) {
+			e1.printStackTrace();
+		} catch (IOException e1) {
+			e1.printStackTrace();
+		} catch (ProcessInterruptedException e1) {
+			e1.printStackTrace();
+		} catch (OperationNotSupportedException e1) {
+			e1.printStackTrace();
+		}
+		
+		RasterReadOnlyBuffer buf = null;
+		try {
+			BufferParam p = new BufferParamImpl(in, initX, initY, w, h, new int[]{0, 1, 2});
+			buf = new RasterReadOnlyBuffer(p);
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		
+				
+		for (int iBand = 0; iBand < buf.getBandCount(); iBand++) {
+			for (int row = 0; row < buf.getHeight(); row++) {
+				for (int col = 0; col < buf.getWidth(); col++) {
+					byte n = buf.getElemByte(row, col, iBand);
+					byte m = buf1.getElemByte(row, col, iBand);
+					if(n != m)
+						System.out.println(row + " " + col);
+					assertEquals(n, m);
+				}
+			}
+		}
+		
+		try {
+			buf.free();
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo ROCache TestRWOneValue: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestReadWindowAndCompareData.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestWindow.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestWindow.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestWindow.java	(revision 3222)
@@ -0,0 +1,107 @@
+package org.gvsig.raster.cache.buffer.impl.rocache;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.PxTileImpl;
+import org.gvsig.raster.cache.buffer.impl.io.BufferDataSourceImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer;
+
+/** 
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestWindow extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/window.tif";
+	private String compare = "./src/test/resources/image/clip_test_robufer.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("ROCache TestWindow running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalWrite output = null;
+		try {
+			
+			BufferDataSource ds = null;
+			try {
+				ds = new BufferDataSourceImpl(rasterIn, new PxTileImpl(100, 100, 500, 400));
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+			Buffer buf = new RasterReadOnlyBuffer(ds);
+			
+			GdalRead input1 = new GdalRead(compare);
+			output = new GdalWrite(rasterOut, 3, input1.getGdalTypeFromRasterBufType(ds.getDataType()), ds.getWidth(), ds.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			output.writeBands(buf.getBands());
+			output.close();
+			
+			//Read input data
+			
+			Object dataIn = input1.readBlock(0, 0, input1.getWidth(), input1.getHeight());
+			
+			//Create Buffer
+			Buffer buf1 = new RasterMemoryBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			setLines(dataIn, buf1);
+			for (int i = 0; i < buf.getBandCount(); i++) 
+				compareBands(buf.getBand(i), buf.getBand(i));
+			
+			buf.free();
+			buf1.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo ROCache TestWindow: " + (t2 - t1) + " milisegundos");
+	}
+	
+	
+	public void compareBands(Band band1, Band band2) {
+		for (int i = 0; i < band1.getHeight(); i++) {
+			for (int j = 0; j < band1.getWidth(); j++) {
+				byte b1 = band1.getElemByte(i, j);
+				byte b2 = band2.getElemByte(i, j);
+				assertEquals(b1, b2);
+			}
+		}
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestWindow.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestReadTiffAndCompareData.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestReadTiffAndCompareData.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestReadTiffAndCompareData.java	(revision 3222)
@@ -0,0 +1,108 @@
+package org.gvsig.raster.cache.buffer.impl.rocache;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.BufferDataSourceImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer;
+
+/**
+ * Read a number from cache
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestReadTiffAndCompareData extends TestCase {
+	private String in = "./src/test/resources/image/001m09_1_0.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("ROCache TestReadTiffAndCompareData running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		
+		BufferCacheManagerImpl.cacheSize = 1;
+		BufferCacheManagerImpl.pageSize = 0.2;
+		
+		Buffer buf1 = null;
+		try {
+			input = new GdalRead(in);
+
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+
+			//Create Buffer
+			buf1 = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+											input.getWidth(), 
+											input.getHeight(),
+											input.getBandCount(),
+											true);
+
+			//Set data to buffer
+			setLines(dataIn, buf1);
+		} catch (GdalException e1) {
+			e1.printStackTrace();
+		} catch (IOException e1) {
+			e1.printStackTrace();
+		} catch (ProcessInterruptedException e1) {
+			e1.printStackTrace();
+		} catch (OperationNotSupportedException e1) {
+			e1.printStackTrace();
+		}
+		
+		
+		BufferDataSource ds = null;
+		try {
+			ds = new BufferDataSourceImpl(in);
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		RasterReadOnlyBuffer buf = new RasterReadOnlyBuffer(ds);
+				
+		for (int iBand = 0; iBand < buf.getBandCount(); iBand++) {
+			for (int row = 0; row < buf.getHeight(); row++) {
+				for (int col = 0; col < buf.getWidth(); col++) {
+					byte n = buf.getElemByte(row, col, iBand);
+					byte m = buf1.getElemByte(row, col, iBand);
+					if(n != m)
+						System.out.println(row + " " + col);
+					assertEquals(n, m);
+				}
+			}
+		}
+		
+		try {
+			buf.free();
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo ROCache TestRWOneValue: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestReadTiffAndCompareData.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestAssignBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestAssignBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestAssignBand.java	(revision 3222)
@@ -0,0 +1,91 @@
+package org.gvsig.raster.cache.buffer.impl.rocache;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.exception.BandNotCompatibleException;
+import org.gvsig.raster.cache.buffer.impl.io.BufferDataSourceImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * Assign by reference a band in a Buffer
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestAssignBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-4bands.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("ROCache TestAssignBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input1 = null;
+
+		GdalWrite out = null;
+		try {
+						
+			//Read input data
+			input1 = new GdalRead(rasterIn);
+						
+			BufferDataSource ds = null;
+			try {
+				ds = new BufferDataSourceImpl(rasterIn);
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+			Buffer buf1 = new RasterReadOnlyBuffer(ds);
+			
+			BufferDataSource ds1 = null;
+			try {
+				ds1 = new BufferDataSourceImpl(rasterIn);
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+			Buffer buf2 = new RasterReadOnlyBuffer(ds1);
+			
+			Band rb = buf2.getBand(2);
+			try {
+				buf1.assignBand(1, rb);
+			} catch (BandNotCompatibleException e) {
+				e.printStackTrace();
+			}
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 4, input1.getDataType(), input1.getWidth(), input1.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out.writeBands(buf1.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(1);
+			Band band2 = buf1.getBand(3);
+			for (int i = 0; i < band1.getHeight(); i++) {
+				for (int j = 0; j < band1.getWidth(); j++) {
+					byte b1 = band1.getElemByte(i, j);
+					byte b2 = band2.getElemByte(i, j);
+					assertEquals(b1, b2);
+				}
+			}
+			
+			buf1.free();
+			buf2.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo ROCache TestAssignBand: " + (t2 - t1) + " milisegundos");
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestAssignBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestMultifile.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestMultifile.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestMultifile.java	(revision 3222)
@@ -0,0 +1,105 @@
+package org.gvsig.raster.cache.buffer.impl.rocache;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.BufferParam;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.impl.BufferParamImpl;
+import org.gvsig.raster.cache.buffer.impl.io.BufferDataSourceImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test gets bands from a raster with the method getBufferWithOneBand() and compare
+ * each band from original source with obtained bands 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestMultifile extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut1 = "/tmp/out-b1.tif";
+	private String rasterOut2 = "/tmp/out-b2.tif";
+	private String rasterOut3 = "/tmp/out-b3.tif";
+	private int    x      = 200;
+	private int    y      = 200;
+	private int    w      = 800;
+	private int    h      = 800;
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("ROCache TestGetBufferWithOneBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		try {
+			//Read input data
+			input = new GdalRead(rasterIn);
+			
+			BufferDataSource ds = null;
+			try {
+				ds = new BufferDataSourceImpl(rasterIn);
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+			Buffer buf = new RasterReadOnlyBuffer(ds);
+						
+			Buffer b0 = buf.getBufferWithOneBand(0);
+			Buffer b1 = buf.getBufferWithOneBand(1);
+			Buffer b2 = buf.getBufferWithOneBand(2);
+			
+			//Write output file 
+			GdalWrite out1 = new GdalWrite(rasterOut1, 1, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out1.writeBands(b0.getBands());
+			out1.close();
+			
+			GdalWrite out2 = new GdalWrite(rasterOut2, 1, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out2.writeBands(b1.getBands());
+			out2.close();
+			
+			GdalWrite out3 = new GdalWrite(rasterOut3, 1, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out3.writeBands(b2.getBands());
+			out3.close();
+			
+			BufferParam params = new BufferParamImpl(
+					new String[]{rasterOut1, rasterOut2, rasterOut3}, 
+					x, y, w, h, null);
+			RasterReadOnlyBuffer multiband = new RasterReadOnlyBuffer(params);
+						
+			for (int row = 0; row < multiband.getHeight(); row++) {
+				for (int col = 0; col < multiband.getWidth(); col++) {
+					byte b_0 = multiband.getElemByte(row, col, 0);
+					byte b_1 = multiband.getElemByte(row, col, 1);
+					byte b_2 = multiband.getElemByte(row, col, 2);
+					assertEquals(b_0, b0.getElemByte(row + y, col + x, 0));
+					assertEquals(b_1, b1.getElemByte(row + y, col + x, 0));
+					assertEquals(b_2, b2.getElemByte(row + y, col + x, 0));
+				}
+			}
+						
+			b0.free();
+			b1.free();
+			b2.free();
+			buf.free();
+				
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo ROCache TestGetBufferWithOneBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestMultifile.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/AllTests.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/AllTests.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/AllTests.java	(revision 3222)
@@ -0,0 +1,26 @@
+package org.gvsig.raster.cache.buffer.impl.rocache;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+	public static Test suite() {
+		TestSuite suite = new TestSuite("Test for org.fv.raster.buffer.rocache");
+		//$JUnit-BEGIN$
+		suite.addTestSuite(TestReplicateBand.class);
+		suite.addTestSuite(TestSwapBands.class);
+		suite.addTestSuite(TestReadTiffAndCompareData.class);
+		suite.addTestSuite(TestSwapTwoBands.class);
+		suite.addTestSuite(TestRemoveBand.class);
+		suite.addTestSuite(TestGetBufferWithOneBand.class);
+		suite.addTestSuite(TestReadWindowAndCompareData.class);
+		suite.addTestSuite(TestAssignBand.class);
+		suite.addTestSuite(TestCopyBand.class);
+		suite.addTestSuite(TestAddBand.class);
+		suite.addTestSuite(TestWindow.class);
+		//$JUnit-END$
+		return suite;
+	}
+
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/AllTests.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestGetBufferWithOneBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestGetBufferWithOneBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestGetBufferWithOneBand.java	(revision 3222)
@@ -0,0 +1,94 @@
+package org.gvsig.raster.cache.buffer.impl.rocache;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.impl.io.BufferDataSourceImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test gets bands from a raster with the method getBufferWithOneBand() and compare
+ * each band from original source with obtained bands 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestGetBufferWithOneBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut1 = "/tmp/out-b1.tif";
+	private String rasterOut2 = "/tmp/out-b2.tif";
+	private String rasterOut3 = "/tmp/out-b3.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("ROCache TestGetBufferWithOneBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		try {
+			//Read input data
+			input = new GdalRead(rasterIn);
+			
+			BufferDataSource ds = null;
+			try {
+				ds = new BufferDataSourceImpl(rasterIn);
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+			Buffer buf = new RasterReadOnlyBuffer(ds);
+						
+			Buffer b0 = buf.getBufferWithOneBand(0);
+			Buffer b1 = buf.getBufferWithOneBand(1);
+			Buffer b2 = buf.getBufferWithOneBand(2);
+			
+			//Write output file 
+			GdalWrite out1 = new GdalWrite(rasterOut1, 1, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out1.writeBands(b0.getBands());
+			out1.close();
+			
+			GdalWrite out2 = new GdalWrite(rasterOut2, 1, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out2.writeBands(b1.getBands());
+			out2.close();
+			
+			GdalWrite out3 = new GdalWrite(rasterOut3, 1, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out3.writeBands(b2.getBands());
+			out3.close();
+			
+			for (int row = 0; row < buf.getHeight(); row++) {
+				for (int col = 0; col < buf.getWidth(); col++) {
+					byte b_0 = buf.getElemByte(row, col, 0);
+					byte b_1 = buf.getElemByte(row, col, 1);
+					byte b_2 = buf.getElemByte(row, col, 2);
+					assertEquals(b_0, b0.getElemByte(row, col, 0));
+					assertEquals(b_1, b1.getElemByte(row, col, 0));
+					assertEquals(b_2, b2.getElemByte(row, col, 0));
+				}
+			}
+			
+			b0.free();
+			b1.free();
+			b2.free();
+			buf.free();
+				
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo ROCache TestGetBufferWithOneBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestGetBufferWithOneBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestSwapTwoBands.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestSwapTwoBands.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestSwapTwoBands.java	(revision 3222)
@@ -0,0 +1,88 @@
+package org.gvsig.raster.cache.buffer.impl.rocache;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.exception.WrongParameterException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.BufferDataSourceImpl;
+
+/**
+ * This test swap two bands of a raster and save the result in other file.
+ * Finally it compares the output bands with the input bands.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestSwapTwoBands extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("ROCache TestSwapTwoBands running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			BufferDataSource ds = null;
+			try {
+				ds = new BufferDataSourceImpl(rasterIn);
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+						
+			//Create Buffer
+			Buffer buf1 = new RasterReadOnlyBuffer(ds);
+
+			Buffer buf2 = new RasterReadOnlyBuffer(ds);
+
+			try {
+				buf2.swapBands(0, 2);
+			} catch (WrongParameterException e) {
+				e.printStackTrace();
+			}
+			
+			Band band1 = buf1.getBand(0);
+			Band band2 = buf2.getBand(2);
+			compareBands(band1, band2);
+			
+			band1 = buf1.getBand(2);
+			band2 = buf2.getBand(0);
+			compareBands(band1, band2);
+			
+			band1 = buf1.getBand(1);
+			band2 = buf2.getBand(1);
+			compareBands(band1, band2);
+			
+			buf1.free();
+			buf2.free();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo ROCache TestSwapTwoBands: " + (t2 - t1) + " milisegundos");
+	}
+	
+	public void compareBands(Band band1, Band band2) {
+		for (int i = 0; i < band1.getHeight(); i++) {
+			for (int j = 0; j < band1.getWidth(); j++) {
+				byte b1 = band1.getElemByte(i, j);
+				byte b2 = band2.getElemByte(i, j);
+				assertEquals(b1, b2);
+			}
+		}
+	}
+		
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestSwapTwoBands.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestAddBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestAddBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestAddBand.java	(revision 3222)
@@ -0,0 +1,61 @@
+package org.gvsig.raster.cache.buffer.impl.rocache;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.impl.io.BufferDataSourceImpl;
+
+/**
+ * This test add a band in a raster of 3 bands. As a result of this test a raster
+ * of four bands is created and saved in the hard disk. The value of additional band
+ * is zero in all its elements. Finally it gets the band added and compare each values 
+ * with 0. 
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestAddBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("ROCache TestAddBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		try {
+			//Read input data
+			
+			BufferDataSource ds = null;
+			try {
+				ds = new BufferDataSourceImpl(rasterIn);
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+			Buffer buf = new RasterReadOnlyBuffer(ds);
+			buf.addBand(1);
+						
+			Band band = buf.getBand(1);
+			for (int i = 0; i < band.getHeight(); i++) {
+				for (int j = 0; j < band.getWidth(); j++) {
+					byte b = band.getElemByte(i, j);
+					assertEquals(0, b);
+				}
+			}
+			
+			buf.free();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo ROCache TestAddBand: " + (t2 - t1) + " milisegundos");
+	}	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestAddBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestReplicateBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestReplicateBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestReplicateBand.java	(revision 3222)
@@ -0,0 +1,78 @@
+package org.gvsig.raster.cache.buffer.impl.rocache;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.impl.io.BufferDataSourceImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/** 
+ * This test insert one band at the end of the layer. The data of this new band is a copy 
+ * of the band in position zero. Finally data of band zero and band three are compared
+ * checking if both have the same values. 
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestReplicateBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-replicateBands.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("ROCache TestReplicateBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input1 = null;
+		GdalWrite out = null;
+		try {
+						
+			//Read input data
+			input1 = new GdalRead(rasterIn);
+			BufferDataSource ds = null;
+			try {
+				ds = new BufferDataSourceImpl(rasterIn);
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+			Buffer buf = new RasterReadOnlyBuffer(ds);
+						
+			buf.replicateBand(0, 3);
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 4, input1.getDataType(), input1.getWidth(), input1.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out.writeBands(buf.getBands());
+			out.close();	
+			
+			Band band1 = buf.getBand(0);
+			Band band2 = buf.getBand(3);
+			for (int i = 0; i < band1.getHeight(); i++) {
+				for (int j = 0; j < band1.getWidth(); j++) {
+					byte b1 = band1.getElemByte(i, j);
+					byte b2 = band2.getElemByte(i, j);
+					assertEquals(b1, b2);
+				}
+			}
+			
+			buf.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo ROCache TestReplicateBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/rocache/TestReplicateBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/io/TRWTIFFFullDataBuffer.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/io/TRWTIFFFullDataBuffer.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/io/TRWTIFFFullDataBuffer.java	(revision 3222)
@@ -0,0 +1,50 @@
+package org.gvsig.raster.cache.buffer.impl.io;
+import java.io.IOException;
+
+import org.gvsig.jgdal.GdalException;
+
+/**
+ * Common use of TIFFRead and TIFFWrite class for read and save full data buffers.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TRWTIFFFullDataBuffer {
+	
+	private String rasterOut = "/tmp/out.tif";
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	//private String rasterIn = "/home/nacho/images1/MultiplesFicheros/ComunidadValenciana/p198r033_7t20010601_z31_nn10.tif";
+	public static void main(String[] args) {
+		TRWTIFFFullDataBuffer t = new TRWTIFFFullDataBuffer();
+		t.save();
+	}
+	
+	public void save() {
+		long t1 = System.currentTimeMillis();
+		
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			input = new GdalRead(rasterIn);
+			Object data = input.readData(0, 0, input.getWidth(), input.getHeight());
+			
+			out = new GdalWrite(rasterOut, input.getBandCount(), input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			
+			if(data instanceof byte[][]) {
+				byte[][] d = (byte[][])data;
+				out.writeByteBands(d);
+				out.close();
+			}
+				
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (InterruptedException e) {
+			e.printStackTrace();
+		}
+	
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo: " + (t2 - t1) + " milisegundos");
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/io/TRWTIFFFullDataBuffer.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestRWOneValue.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestRWOneValue.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestRWOneValue.java	(revision 3222)
@@ -0,0 +1,65 @@
+package org.gvsig.raster.cache.buffer.impl.memory;
+
+import java.awt.image.DataBuffer;
+
+import junit.framework.TestCase;
+
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer;
+
+/**
+ * Escribe y lee un n�mero en la cache
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestRWOneValue extends TestCase {
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("MemoryBuffer TestRWOneValue running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		
+		BufferCacheManagerImpl.cacheSize = 1;
+		BufferCacheManagerImpl.pageSize = 0.2;
+		
+		RasterMemoryBuffer buf = new RasterMemoryBuffer(DataBuffer.TYPE_BYTE, 2571, 1942, 3, true);
+		
+		for (int iBand = 0; iBand < buf.getBandCount(); iBand++) {
+			for (int row = 0; row < buf.getHeight(); row++) {
+				for (int col = 0; col < buf.getWidth(); col++) {
+					byte n = (byte)(8 + iBand);
+					byte m = (byte)(34 + iBand);
+					if(row == 1001 && col == 1032)
+						buf.setElem(row, col, iBand, n);
+					else
+						buf.setElem(row, col, iBand, m);			
+				}
+			}
+		}
+		
+		for (int iBand = 0; iBand < buf.getBandCount(); iBand++) {
+			for (int row = 0; row < buf.getHeight(); row++) {
+				for (int col = 0; col < buf.getWidth(); col++) {
+					byte n = buf.getElemByte(row, col, iBand);
+					byte m = (byte)(34 + iBand); 
+					if(n != m)
+						;//System.out.println(n + " " + row + "," + col);
+					else
+						assertEquals(n, m);
+				}
+			}
+		}
+		
+		buf.free();
+		
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo MemoryBuffer TestRWOneValue: " + (t2 - t1) + " milisegundos");
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestRWOneValue.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestCreateBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestCreateBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestCreateBand.java	(revision 3222)
@@ -0,0 +1,85 @@
+package org.gvsig.raster.cache.buffer.impl.memory;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+
+/**
+ * This test add a band in a raster of 3 bands. As a result of this test a raster
+ * of four bands is created and saved in the hard disk. The value of additional band
+ * is zero in all its elements. Finally it gets the band added and compare each values 
+ * with 0. 
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestCreateBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("MemoryBuffer TestCreateBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		try {
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			setLines(dataIn, buf);
+			Band rb = buf.createBand((byte)100);
+
+			for (int i = 0; i < rb.getHeight(); i++) {
+				for (int j = 0; j < rb.getWidth(); j++) {
+					byte b = rb.getElemByte(i, j);
+					assertEquals((byte)100, b);
+				}
+			}
+			
+			buf.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo MemoryBuffer TestCreateBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestCreateBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestAssignBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestAssignBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestAssignBand.java	(revision 3222)
@@ -0,0 +1,112 @@
+package org.gvsig.raster.cache.buffer.impl.memory;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.BandNotCompatibleException;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestAssignBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-4bands.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("MemoryBuffer TestAssignBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input1 = null;
+		GdalRead input2 = null;
+		GdalWrite out = null;
+		try {
+			//Read input data
+			input1 = new GdalRead(rasterIn);
+			Object dataIn1 = input1.readBlock(0, 0, input1.getWidth(), input1.getHeight());
+			input2 = new GdalRead(rasterIn);
+			Object dataIn2 = input1.readBlock(0, 0, input2.getWidth(), input2.getHeight());
+			
+			//Create Buffer
+			Buffer buf1 = new RasterMemoryBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			setLines(dataIn1, buf1);
+			//Create Buffer
+			Buffer buf2 = new RasterMemoryBuffer(input2.getRasterBufTypeFromGdalType(input2.getDataType()), 
+														input2.getWidth(), 
+														input2.getHeight(),
+														input2.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			setLines(dataIn2, buf2);
+			
+			Band rb = buf2.getBand(2);
+			try {
+				buf1.assignBand(1, rb);
+			} catch (BandNotCompatibleException e) {
+				e.printStackTrace();
+			}
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 4, input1.getDataType(), input1.getWidth(), input1.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out.writeBands(buf1.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(1);
+			Band band2 = buf1.getBand(3);
+			for (int i = 0; i < band1.getHeight(); i++) {
+				for (int j = 0; j < band1.getWidth(); j++) {
+					byte b1 = band1.getElemByte(i, j);
+					byte b2 = band2.getElemByte(i, j);
+					assertEquals(b1, b2);
+				}
+			}
+			
+			buf1.free();
+			buf2.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		}  catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo MemoryBuffer TestAssignBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestAssignBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/AllTests.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/AllTests.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/AllTests.java	(revision 3222)
@@ -0,0 +1,29 @@
+package org.gvsig.raster.cache.buffer.impl.memory;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+	public static Test suite() {
+		TestSuite suite = new TestSuite(
+				"Test for org.gvsig.raster.buffer.memory");
+		//$JUnit-BEGIN$
+		suite.addTestSuite(TestSwapBands.class);
+		suite.addTestSuite(TestMemoryBuffer.class);
+		suite.addTestSuite(TestRemoveBand.class);
+		suite.addTestSuite(TestAddBand.class);
+		suite.addTestSuite(TestSwapTwoBands.class);
+		suite.addTestSuite(TestCopyBand.class);
+		suite.addTestSuite(TestGetBufferWithOneBand.class);
+		suite.addTestSuite(TestReplicateBand.class);
+		suite.addTestSuite(TestRWOneValue.class);
+		suite.addTestSuite(TestCopyBand2.class);
+		suite.addTestSuite(TestCreateBand.class);
+		suite.addTestSuite(TestAssignBand.class);
+		suite.addTestSuite(TestRWTiffAndCompareData.class);
+		//$JUnit-END$
+		return suite;
+	}
+
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/AllTests.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestGetBufferWithOneBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestGetBufferWithOneBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestGetBufferWithOneBand.java	(revision 3222)
@@ -0,0 +1,109 @@
+package org.gvsig.raster.cache.buffer.impl.memory;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test gets bands from a raster with the method getBufferWithOneBand() and compare
+ * each band from original source with obtained bands 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestGetBufferWithOneBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut1 = "/tmp/out-b1.tif";
+	private String rasterOut2 = "/tmp/out-b2.tif";
+	private String rasterOut3 = "/tmp/out-b3.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("MemoryBuffer TestGetBufferWithOneBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		try {
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			setLines(dataIn, buf);
+			
+			Buffer b0 = buf.getBufferWithOneBand(0);
+			Buffer b1 = buf.getBufferWithOneBand(1);
+			Buffer b2 = buf.getBufferWithOneBand(2);
+			
+			//Write output file 
+			GdalWrite out1 = new GdalWrite(rasterOut1, 1, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out1.writeBands(b0.getBands());
+			out1.close();
+			
+			GdalWrite out2 = new GdalWrite(rasterOut2, 1, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out2.writeBands(b1.getBands());
+			out2.close();
+			
+			GdalWrite out3 = new GdalWrite(rasterOut3, 1, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out3.writeBands(b2.getBands());
+			out3.close();
+						
+			for (int row = 0; row < buf.getHeight(); row++) {
+				for (int col = 0; col < buf.getWidth(); col++) {
+					byte b_0 = buf.getElemByte(row, col, 0);
+					byte b_1 = buf.getElemByte(row, col, 1);
+					byte b_2 = buf.getElemByte(row, col, 2);
+					assertEquals(b_0, b0.getElemByte(row, col, 0));
+					assertEquals(b_1, b1.getElemByte(row, col, 0));
+					assertEquals(b_2, b2.getElemByte(row, col, 0));
+				}
+			}
+			
+			b0.free();
+			b1.free();
+			b2.free();
+			buf.free();
+				
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo MemoryBuffer TestGetBufferWithOneBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestGetBufferWithOneBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestSwapTwoBands.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestSwapTwoBands.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestSwapTwoBands.java	(revision 3222)
@@ -0,0 +1,121 @@
+package org.gvsig.raster.cache.buffer.impl.memory;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.exception.WrongParameterException;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test swap two bands of a raster and save the result in other file.
+ * Finally it compares the output bands with the input bands.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestSwapTwoBands extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-swapedTwo.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("MemoryBuffer TestSwapTwoBands running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input1 = null;
+		GdalWrite out = null;
+		try {
+			//Read input data
+			input1 = new GdalRead(rasterIn);
+			Object dataIn1 = input1.readBlock(0, 0, input1.getWidth(), input1.getHeight());
+						
+			//Create Buffer
+			Buffer buf1 = new RasterMemoryBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			setLines(dataIn1, buf1);
+						
+			Buffer buf2 = new RasterMemoryBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount(),
+														true);
+
+			//Set data to buffer
+			setLines(dataIn1, buf2);
+			try {
+				buf2.swapBands(0, 2);
+			} catch (WrongParameterException e) {
+				e.printStackTrace();
+			}
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, input1.getBandCount(), input1.getDataType(), input1.getWidth(), input1.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf2.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(0);
+			Band band2 = buf2.getBand(2);
+			compareBands(band1, band2);
+			
+			band1 = buf1.getBand(2);
+			band2 = buf2.getBand(0);
+			compareBands(band1, band2);
+			
+			band1 = buf1.getBand(1);
+			band2 = buf2.getBand(1);
+			compareBands(band1, band2);
+			
+			buf1.free();
+			buf2.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo MemoryBuffer TestSwapTwoBands: " + (t2 - t1) + " milisegundos");
+	}
+	
+	public void compareBands(Band band1, Band band2) {
+		for (int i = 0; i < band1.getHeight(); i++) {
+			for (int j = 0; j < band1.getWidth(); j++) {
+				byte b1 = band1.getElemByte(i, j);
+				byte b2 = band2.getElemByte(i, j);
+				assertEquals(b1, b2);
+			}
+		}
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestSwapTwoBands.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestAddBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestAddBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestAddBand.java	(revision 3222)
@@ -0,0 +1,95 @@
+package org.gvsig.raster.cache.buffer.impl.memory;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test add a band in a raster of 3 bands. As a result of this test a raster
+ * of four bands is created and saved in the hard disk. The value of additional band
+ * is zero in all its elements. Finally it gets the band added and compare each values 
+ * with 0. 
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestAddBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-4bands.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("MemoryBuffer TestAddBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+	
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			setLines(dataIn, buf);
+			buf.addBand(1);
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 4, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out.writeBands(buf.getBands());
+			out.close();	
+			
+			Band band = buf.getBand(1);
+			for (int i = 0; i < band.getHeight(); i++) {
+				for (int j = 0; j < band.getWidth(); j++) {
+					byte b = band.getElemByte(i, j);
+					assertEquals(0, b);
+				}
+			}
+			
+			buf.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		}  catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo MemoryBuffer TestAddBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestAddBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestReplicateBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestReplicateBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestReplicateBand.java	(revision 3222)
@@ -0,0 +1,96 @@
+package org.gvsig.raster.cache.buffer.impl.memory;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/** 
+ * This test insert one band at the end of the layer. The data of this new band is a copy 
+ * of the band in position zero. Finally data of band zero and band three are compared
+ * checking if both have the same values. 
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestReplicateBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-replicateBands.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("MemoryBuffer TestReplicateBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input1 = null;
+		GdalWrite out = null;
+		try {
+			//Read input data
+			input1 = new GdalRead(rasterIn);
+			Object dataIn1 = input1.readBlock(0, 0, input1.getWidth(), input1.getHeight());
+			
+			//Create Buffer
+			Buffer buf1 = new RasterMemoryBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			setLines(dataIn1, buf1);
+						
+			buf1.replicateBand(0, 3);
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 4, input1.getDataType(), input1.getWidth(), input1.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out.writeBands(buf1.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(0);
+			Band band2 = buf1.getBand(3);
+			for (int i = 0; i < band1.getHeight(); i++) {
+				for (int j = 0; j < band1.getWidth(); j++) {
+					byte b1 = band1.getElemByte(i, j);
+					byte b2 = band2.getElemByte(i, j);
+					assertEquals(b1, b2);
+				}
+			}
+			
+			buf1.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo MemoryBuffer TestReplicateBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {  
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestReplicateBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestCopyBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestCopyBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestCopyBand.java	(revision 3222)
@@ -0,0 +1,102 @@
+package org.gvsig.raster.cache.buffer.impl.memory;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.BandNotCompatibleException;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * Copy the band 0 from a buffer over the band 2 in the same buffer using the
+ * method getBandCopy.  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestCopyBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-copyFirstBand.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("MemoryBuffer TestCopyBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf1 = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			setLines(dataIn, buf1);
+			
+			
+			Band rb = buf1.getBandCopy(0);
+			
+			try {
+				buf1.copyBand(2, rb);
+			} catch (BandNotCompatibleException e) {
+				e.printStackTrace();
+			}
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 3, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf1.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(0);
+			Band band2 = buf1.getBand(2);
+			for (int i = 0; i < band1.getHeight(); i++) {
+				for (int j = 0; j < band1.getWidth(); j++) {
+					byte b1 = band1.getElemByte(i, j);
+					byte b2 = band2.getElemByte(i, j);
+					assertEquals(b1, b2);
+				}
+			}
+			
+			buf1.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo MemoryBuffer TestCopyBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestCopyBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestCopyBand2.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestCopyBand2.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestCopyBand2.java	(revision 3222)
@@ -0,0 +1,112 @@
+package org.gvsig.raster.cache.buffer.impl.memory;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.BandNotCompatibleException;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+import org.gvsig.raster.cache.buffer.impl.stripecache.horizontal.RasterCacheBuffer;
+
+/**
+ * Copy the band 0 from a buffer over the band 2 of other buffer using the
+ * method getBand (reference).
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestCopyBand2 extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-copyFirstBand.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("MemoryBuffer TestCopyBand2 running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf1 = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			setLines(dataIn, buf1);
+			
+			//Create Buffer
+			Buffer buf2 = new RasterCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount());
+			
+			//Set data to buffer
+			setLines(dataIn, buf2);
+			
+			Band rb = buf1.getBand(0);
+			
+			try {
+				buf2.copyBand(2, rb);
+			} catch (BandNotCompatibleException e) {
+				e.printStackTrace();
+			}
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 3, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf2.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(0);
+			Band band2 = buf2.getBand(2);
+			for (int i = 0; i < band1.getHeight(); i++) {
+				for (int j = 0; j < band1.getWidth(); j++) {
+					byte b1 = band1.getElemByte(i, j);
+					byte b2 = band2.getElemByte(i, j);
+					assertEquals(b1, b2);
+				}
+			}
+			
+			buf1.free();
+			buf2.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo MemoryBuffer TestCopyBand2: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestCopyBand2.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestMemoryBuffer.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestMemoryBuffer.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestMemoryBuffer.java	(revision 3222)
@@ -0,0 +1,70 @@
+package org.gvsig.raster.cache.buffer.impl.memory;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestMemoryBuffer extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("MemoryBuffer TestMemoryBuffer running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			input = new GdalRead(rasterIn);
+			Object data = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			Buffer buf = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount(),
+														true);
+			
+			if(data instanceof byte[][][]) {
+	    		byte[][][] d = (byte[][][])data;
+	    		for (int i = 0; i < d.length; i++) {
+					for (int j = 0; j < d[i].length; j++) {
+						buf.setLineInBandByte(d[i][j], j, i);
+					}
+				}
+	    	}
+			out = new GdalWrite(rasterOut, input.getBandCount(), input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf.getBands());
+			out.close();	
+				
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo MemoryBuffer TestMemoryBuffer: " + (t2 - t1) + " milisegundos");
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestMemoryBuffer.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestRemoveBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestRemoveBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestRemoveBand.java	(revision 3222)
@@ -0,0 +1,107 @@
+package org.gvsig.raster.cache.buffer.impl.memory;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test read a RGB image and remove one band from the read buffer. Then compare 
+ * the bands that have not been removed with the source bands. As a result of this test a raster
+ * of two bands is created and saved in the hard disk
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestRemoveBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-2bands.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("MemoryBuffer TestRemoveBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			setLines(dataIn, buf);
+			buf.removeBand(1);
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 2, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out.writeBands(buf.getBands());
+			buf.free();
+			out.close();	
+			
+			//Open output file and compare
+			GdalRead newFile = new GdalRead(rasterOut);
+			Object dataOut = newFile.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			byte[][][] d1 = (byte[][][])dataOut;
+			byte[][][] d2 = (byte[][][])dataIn;
+			
+			for (int row = 0; row < buf.getHeight(); row++) {
+				for (int col = 0; col < buf.getWidth(); col++) {
+					if(d1[0][row][col] != d2[0][row][col])
+						System.out.println("BAND:" + 0 +" ROW:" + row + " COL:" + col + " " + d1[0][row][col] + " " + d2[0][row][col]);
+					assertEquals(d1[0][row][col], d2[0][row][col]);
+				}
+			}
+				
+			for (int row = 0; row < buf.getHeight(); row++) {
+				for (int col = 0; col < buf.getWidth(); col++) {
+					if(d1[1][row][col] != d2[2][row][col])
+						System.out.println("BAND:" + 1 +" ROW:" + row + " COL:" + col + " " + d1[1][row][col] + " " + d2[2][row][col]);
+					assertEquals(d1[1][row][col], d2[2][row][col]);
+				}
+			}
+			
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo MemoryBuffer TestRemoveBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestRemoveBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestSwapBands.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestSwapBands.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestSwapBands.java	(revision 3222)
@@ -0,0 +1,139 @@
+package org.gvsig.raster.cache.buffer.impl.memory;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.exception.WrongParameterException;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test swap several bands of a raster and save the result in other file.
+ * Finally it compares the output bands with the input bands.
+ * <P>
+ * The array to test is {2, 0, 1}. That means the band 0 goes to the position two, the
+ * band one goes to the position zero and the band two goes to the position one. 
+ * When the swap operation is executed, this test will check comparing the result 
+ * bands with the input bands 
+ * </P>
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestSwapBands extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-swaped.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("MemoryBuffer TestSwapBands running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input1 = null;
+		GdalWrite out = null;
+		try {
+			//Read input data
+			input1 = new GdalRead(rasterIn);
+			Object dataIn1 = input1.readBlock(0, 0, input1.getWidth(), input1.getHeight());
+						
+			//Create Buffer
+			Buffer buf1 = new RasterMemoryBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			setBytes(dataIn1, buf1);
+						
+			Buffer buf2 = new RasterMemoryBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount(),
+														true);
+
+			//Set data to buffer
+			setBytes(dataIn1, buf2);
+			try {
+				buf2.swapBands(new int[]{2, 0, 1});
+			} catch (WrongParameterException e) {
+				e.printStackTrace();
+			}
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, input1.getBandCount(), input1.getDataType(), input1.getWidth(), input1.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf2.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(0);
+			Band band2 = buf2.getBand(1);
+			compareBands(band1, band2);
+			
+			band1 = buf1.getBand(1);
+			band2 = buf2.getBand(2);
+			compareBands(band1, band2);
+			
+			band1 = buf1.getBand(2);
+			band2 = buf2.getBand(0);
+			compareBands(band1, band2);
+			
+			buf1.free();
+			buf2.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo MemoryBuffer TestSwapBands: " + (t2 - t1) + " milisegundos");
+	}
+	
+	public void compareBands(Band band1, Band band2) {
+		for (int i = 0; i < band1.getHeight(); i++) {
+			for (int j = 0; j < band1.getWidth(); j++) {
+				byte b1 = band1.getElemByte(i, j);
+				byte b2 = band2.getElemByte(i, j);
+				assertEquals(b1, b2);
+			}
+		}
+	}
+	
+//	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+//		if(dataIn instanceof byte[][][]) {
+//    		byte[][][] d = (byte[][][])dataIn;
+//    		for (int iBand = 0; iBand < d.length; iBand++) {
+//				for (int row = 0; row < d[iBand].length; row++) {
+//					buf.setLineInBandByte(d[iBand][row], row, iBand);
+//				}
+//			}
+//    	}
+//	}
+	
+	private void setBytes(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+    			for (int row = 0; row < d[iBand].length; row++) {
+    				for (int col = 0; col < d[iBand][0].length; col++) {
+						buf.setElem(row, col, iBand, d[iBand][row][col]);
+					}
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestSwapBands.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestRWTiffAndCompareData.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestRWTiffAndCompareData.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestRWTiffAndCompareData.java	(revision 3222)
@@ -0,0 +1,96 @@
+package org.gvsig.raster.cache.buffer.impl.memory;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test reads a Tiff from disk with the class TIFFRead and load data in
+ * a memory buffer. Then it saves those bytes in a new out file in the same format.
+ * Finally it compares the intput data with the output data to test if there are some
+ * diferences.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestRWTiffAndCompareData extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("MemoryBuffer TestRWTiffAndCompareData running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			if(dataIn instanceof byte[][][]) {
+	    		byte[][][] d = (byte[][][])dataIn;
+	    		for (int i = 0; i < d.length; i++) {
+					for (int j = 0; j < d[i].length; j++) {
+						buf.setLineInBandByte(d[i][j], j, i);
+					}
+				}
+	    	}
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, input.getBandCount(), input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf.getBands());
+			out.close();	
+			
+			//Open output file and compare
+			GdalRead newFile = new GdalRead(rasterOut);
+			Object dataOut = newFile.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			byte[][][] d1 = (byte[][][])dataIn;
+			byte[][][] d2 = (byte[][][])dataOut;
+			for (int iBand = 0; iBand < buf.getBandCount(); iBand++) {
+				for (int row = 0; row < buf.getHeight(); row++) {
+					for (int col = 0; col < buf.getWidth(); col++) {
+						if(d1[iBand][row][col] != d2[iBand][row][col])
+							System.out.println("BAND:" + iBand +" ROW:" + row + " COL:" + col + " " + d1[iBand][row][col] + " " + d2[iBand][row][col]);
+						assertEquals(d1[iBand][row][col], d2[iBand][row][col]);
+					}
+				}
+			}
+				
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo MemoryBuffer TestRWTiffAndCompareData: " + (t2 - t1) + " milisegundos");
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/memory/TestRWTiffAndCompareData.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestRWOneValue.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestRWOneValue.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestRWOneValue.java	(revision 3222)
@@ -0,0 +1,70 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.horizontal;
+
+import java.awt.image.DataBuffer;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+
+/**
+ * This test creates a buffer and write a number in each element of each band.
+ * Then, it reads from the buffer the numbers and check it.
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestRWOneValue extends TestCase {
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestRWOneValue running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		
+		//Reducimos el tama�o de la cache para una prueba con menos datos
+		BufferCacheManagerImpl.cacheSize = 2;
+		BufferCacheManagerImpl.pageSize = 0.2;
+		
+		RasterCacheBuffer buf = new RasterCacheBuffer(DataBuffer.TYPE_BYTE, 2571, 1942, 3);
+		
+		for (int iBand = 0; iBand < buf.getBandCount(); iBand++) {
+			for (int row = 0; row < buf.getHeight(); row++) {
+				for (int col = 0; col < buf.getWidth(); col++) {
+					byte n = (byte)(8 + iBand);
+					byte m = (byte)(34 + iBand);
+					if(row == 1001 && col == 1032)
+						buf.setElem(row, col, iBand, n);
+					else
+						buf.setElem(row, col, iBand, m);			
+				}
+			}
+		}
+		
+		for (int iBand = 0; iBand < buf.getBandCount(); iBand++) {
+			for (int row = 0; row < buf.getHeight(); row++) {
+				for (int col = 0; col < buf.getWidth(); col++) {
+					byte n = buf.getElemByte(row, col, iBand);
+					byte m = (byte)(34 + iBand); 
+					if(n != m)
+						;//System.out.println(n + " " + row + "," + col);
+					else
+						assertEquals(n, m);
+				}
+			}
+		}
+		try {
+			buf.free();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestRWOneValue: " + (t2 - t1) + " milisegundos");
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestRWOneValue.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestCreateBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestCreateBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestCreateBand.java	(revision 3222)
@@ -0,0 +1,89 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.horizontal;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+
+/**
+ * This test add a band in a raster of 3 bands. As a result of this test a raster
+ * of four bands is created and saved in the hard disk. The value of additional band
+ * is zero in all its elements. Finally it gets the band added and compare each values 
+ * with 0. 
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestCreateBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestCreateBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf = new RasterCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount());
+			
+			//Set data to buffer
+			setLines(dataIn, buf);
+			Band rb = buf.createBand((byte)100);
+
+			for (int i = 0; i < rb.getHeight(); i++) {
+				for (int j = 0; j < rb.getWidth(); j++) {
+					byte b = rb.getElemByte(i, j);
+					assertEquals((byte)100, b);
+				}
+			}
+			
+			buf.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestCreateBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestCreateBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestAssignBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestAssignBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestAssignBand.java	(revision 3222)
@@ -0,0 +1,115 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.horizontal;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.BandNotCompatibleException;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestAssignBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-4bands.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestAssignBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input1 = null;
+		GdalRead input2 = null;
+		GdalWrite out = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input1 = new GdalRead(rasterIn);
+			Object dataIn1 = input1.readBlock(0, 0, input1.getWidth(), input1.getHeight());
+			input2 = new GdalRead(rasterIn);
+			Object dataIn2 = input1.readBlock(0, 0, input2.getWidth(), input2.getHeight());
+			
+			//Create Buffer
+			Buffer buf1 = new RasterCacheBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount());
+			
+			//Set data to buffer
+			setLines(dataIn1, buf1);
+			//Create Buffer
+			Buffer buf2 = new RasterCacheBuffer(input2.getRasterBufTypeFromGdalType(input2.getDataType()), 
+														input2.getWidth(), 
+														input2.getHeight(),
+														input2.getBandCount());
+			
+			//Set data to buffer
+			setLines(dataIn2, buf2);
+			
+			Band rb = buf2.getBand(2);
+			try {
+				buf1.assignBand(1, rb);
+			} catch (BandNotCompatibleException e) {
+				e.printStackTrace();
+			}
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 4, input1.getDataType(), input1.getWidth(), input1.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out.writeBands(buf1.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(1);
+			Band band2 = buf1.getBand(3);
+			for (int i = 0; i < band1.getHeight(); i++) {
+				for (int j = 0; j < band1.getWidth(); j++) {
+					byte b1 = band1.getElemByte(i, j);
+					byte b2 = band2.getElemByte(i, j);
+					assertEquals(b1, b2);
+				}
+			}
+			
+			buf1.free();
+			buf2.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestAssignBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestAssignBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/AllTests.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/AllTests.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/AllTests.java	(revision 3222)
@@ -0,0 +1,28 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.horizontal;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+	public static Test suite() {
+		TestSuite suite = new TestSuite(
+				"Test for org.gvsig.raster.buffer.stripecache");
+		//$JUnit-BEGIN$
+		suite.addTestSuite(TestSwapTwoBands.class);
+		suite.addTestSuite(TestAssignBand.class);
+		suite.addTestSuite(TestCopyBand.class);
+		suite.addTestSuite(TestRemoveBand.class);
+		suite.addTestSuite(TestReplicateBand.class);
+		suite.addTestSuite(TestAddBand.class);
+		suite.addTestSuite(TestRWOneValue.class);
+		suite.addTestSuite(TestCreateBand.class);
+		suite.addTestSuite(TestRWTiffAndCompareData.class);
+		suite.addTestSuite(TestSwapBands.class);
+		suite.addTestSuite(TestCopyBand2.class);
+		suite.addTestSuite(TestGetBufferWithOneBand.class);
+		//$JUnit-END$
+		return suite;
+	}
+
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/AllTests.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestGetBufferWithOneBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestGetBufferWithOneBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestGetBufferWithOneBand.java	(revision 3222)
@@ -0,0 +1,113 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.horizontal;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test gets bands from a raster with the method getBufferWithOneBand() and compare
+ * each band from original source with obtained bands 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestGetBufferWithOneBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut1 = "/tmp/out-b1.tif";
+	private String rasterOut2 = "/tmp/out-b2.tif";
+	private String rasterOut3 = "/tmp/out-b3.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestGetBufferWithOneBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf = new RasterCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount());
+			
+			//Set data to buffer
+			setLines(dataIn, buf);
+			
+			Buffer b0 = buf.getBufferWithOneBand(0);
+			Buffer b1 = buf.getBufferWithOneBand(1);
+			Buffer b2 = buf.getBufferWithOneBand(2);
+			
+			//Write output file 
+			GdalWrite out1 = new GdalWrite(rasterOut1, 1, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out1.writeBands(b0.getBands());
+			out1.close();
+			
+			GdalWrite out2 = new GdalWrite(rasterOut2, 1, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out2.writeBands(b1.getBands());
+			out2.close();
+			
+			GdalWrite out3 = new GdalWrite(rasterOut3, 1, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out3.writeBands(b2.getBands());
+			out3.close();
+						
+			for (int row = 0; row < buf.getHeight(); row++) {
+				for (int col = 0; col < buf.getWidth(); col++) {
+					byte b_0 = buf.getElemByte(row, col, 0);
+					byte b_1 = buf.getElemByte(row, col, 1);
+					byte b_2 = buf.getElemByte(row, col, 2);
+					assertEquals(b_0, b0.getElemByte(row, col, 0));
+					assertEquals(b_1, b1.getElemByte(row, col, 0));
+					assertEquals(b_2, b2.getElemByte(row, col, 0));
+				}
+			}
+			
+			b0.free();
+			b1.free();
+			b2.free();
+			buf.free();
+				
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestGetBufferWithOneBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestGetBufferWithOneBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestSwapTwoBands.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestSwapTwoBands.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestSwapTwoBands.java	(revision 3222)
@@ -0,0 +1,124 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.horizontal;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.exception.WrongParameterException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test swap two bands of a raster and save the result in other file.
+ * Finally it compares the output bands with the input bands.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestSwapTwoBands extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-swapedTwo.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestSwapTwoBands running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input1 = null;
+		GdalWrite out = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input1 = new GdalRead(rasterIn);
+			Object dataIn1 = input1.readBlock(0, 0, input1.getWidth(), input1.getHeight());
+						
+			//Create Buffer
+			Buffer buf1 = new RasterCacheBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount());
+			
+			//Set data to buffer
+			setLines(dataIn1, buf1);
+						
+			Buffer buf2 = new RasterCacheBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount());
+
+			//Set data to buffer
+			setLines(dataIn1, buf2);
+			try {
+				buf2.swapBands(0, 2);
+			} catch (WrongParameterException e) {
+				e.printStackTrace();
+			}
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, input1.getBandCount(), input1.getDataType(), input1.getWidth(), input1.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf2.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(0);
+			Band band2 = buf2.getBand(2);
+			compareBands(band1, band2);
+			
+			band1 = buf1.getBand(2);
+			band2 = buf2.getBand(0);
+			compareBands(band1, band2);
+			
+			band1 = buf1.getBand(1);
+			band2 = buf2.getBand(1);
+			compareBands(band1, band2);
+			
+			buf1.free();
+			buf2.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestSwapTwoBands: " + (t2 - t1) + " milisegundos");
+	}
+	
+	public void compareBands(Band band1, Band band2) {
+		for (int i = 0; i < band1.getHeight(); i++) {
+			for (int j = 0; j < band1.getWidth(); j++) {
+				byte b1 = band1.getElemByte(i, j);
+				byte b2 = band2.getElemByte(i, j);
+				assertEquals(b1, b2);
+			}
+		}
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestSwapTwoBands.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestAddBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestAddBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestAddBand.java	(revision 3222)
@@ -0,0 +1,98 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.horizontal;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test add a band in a raster of 3 bands. As a result of this test a raster
+ * of four bands is created and saved in the hard disk. The value of additional band
+ * is zero in all its elements. Finally it gets the band added and compare each values 
+ * with 0. 
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestAddBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-4bands.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestAddBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf = new RasterCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount());
+			
+			//Set data to buffer
+			setLines(dataIn, buf);
+			buf.addBand(1);
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 4, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out.writeBands(buf.getBands());
+			out.close();	
+			
+			Band band = buf.getBand(1);
+			for (int i = 0; i < band.getHeight(); i++) {
+				for (int j = 0; j < band.getWidth(); j++) {
+					byte b = band.getElemByte(i, j);
+					assertEquals(0, b);
+				}
+			}
+			
+			buf.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestAddBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestAddBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestReplicateBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestReplicateBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestReplicateBand.java	(revision 3222)
@@ -0,0 +1,100 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.horizontal;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/** 
+ * This test insert one band at the end of the layer. The data of this new band is a copy 
+ * of the band in position zero. Finally data of band zero and band three are compared
+ * checking if both have the same values. 
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestReplicateBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-replicateBands.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestReplicateBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input1 = null;
+		GdalWrite out = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input1 = new GdalRead(rasterIn);
+			Object dataIn1 = input1.readBlock(0, 0, input1.getWidth(), input1.getHeight());
+			
+			//Create Buffer
+			Buffer buf1 = new RasterCacheBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount());
+			
+			//Set data to buffer
+			setLines(dataIn1, buf1);
+						
+			buf1.replicateBand(0, 3);
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 4, input1.getDataType(), input1.getWidth(), input1.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out.writeBands(buf1.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(0);
+			Band band2 = buf1.getBand(3);
+			for (int i = 0; i < band1.getHeight(); i++) {
+				for (int j = 0; j < band1.getWidth(); j++) {
+					byte b1 = band1.getElemByte(i, j);
+					byte b2 = band2.getElemByte(i, j);
+					assertEquals(b1, b2);
+				}
+			}
+			
+			buf1.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestReplicateBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {  
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestReplicateBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestCopyBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestCopyBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestCopyBand.java	(revision 3222)
@@ -0,0 +1,106 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.horizontal;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.BandNotCompatibleException;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * Copy the band 0 from a buffer over the band 2 in the same buffer using the
+ * method getBandCopy.  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestCopyBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-copyFirstBand.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestCopyBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf1 = new RasterCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount());
+			
+			//Set data to buffer
+			setLines(dataIn, buf1);
+			
+			
+			Band rb = buf1.getBandCopy(0);
+			
+			try {
+				buf1.copyBand(2, rb);
+			} catch (BandNotCompatibleException e) {
+				e.printStackTrace();
+			}
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 3, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf1.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(0);
+			Band band2 = buf1.getBand(2);
+			for (int i = 0; i < band1.getHeight(); i++) {
+				for (int j = 0; j < band1.getWidth(); j++) {
+					byte b1 = band1.getElemByte(i, j);
+					byte b2 = band2.getElemByte(i, j);
+					assertEquals(b1, b2);
+				}
+			}
+			
+			buf1.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestCopyBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestCopyBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestCopyBand2.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestCopyBand2.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestCopyBand2.java	(revision 3222)
@@ -0,0 +1,115 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.horizontal;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.BandNotCompatibleException;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * Copy the band 0 from a buffer over the band 2 of other buffer using the
+ * method getBand (reference).
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestCopyBand2 extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-copyFirstBand.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestCopyBand2 running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf1 = new RasterCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount());
+			
+			//Set data to buffer
+			setLines(dataIn, buf1);
+			
+			//Create Buffer
+			Buffer buf2 = new RasterCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount());
+			
+			//Set data to buffer
+			setLines(dataIn, buf2);
+			
+			Band rb = buf1.getBand(0);
+			
+			try {
+				buf2.copyBand(2, rb);
+			} catch (BandNotCompatibleException e) {
+				e.printStackTrace();
+			}
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 3, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf2.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(0);
+			Band band2 = buf2.getBand(2);
+			for (int i = 0; i < band1.getHeight(); i++) {
+				for (int j = 0; j < band1.getWidth(); j++) {
+					byte b1 = band1.getElemByte(i, j);
+					byte b2 = band2.getElemByte(i, j);
+					assertEquals(b1, b2);
+				}
+			}
+			
+			buf1.free();
+			buf2.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestCopyBand2: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestCopyBand2.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestRemoveBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestRemoveBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestRemoveBand.java	(revision 3222)
@@ -0,0 +1,111 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.horizontal;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test read a RGB image and remove one band from the read buffer. Then compare 
+ * the bands that have not been removed with the source bands. As a result of this test a raster
+ * of two bands is created and saved in the hard disk
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestRemoveBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-2bands.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestRemoveBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf = new RasterCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount());
+			
+			//Set data to buffer
+			setLines(dataIn, buf);
+			buf.removeBand(1);
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 2, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out.writeBands(buf.getBands());
+			buf.free();
+			out.close();	
+			
+			//Open output file and compare
+			GdalRead newFile = new GdalRead(rasterOut);
+			Object dataOut = newFile.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			byte[][][] d1 = (byte[][][])dataOut;
+			byte[][][] d2 = (byte[][][])dataIn;
+			
+			for (int row = 0; row < buf.getHeight(); row++) {
+				for (int col = 0; col < buf.getWidth(); col++) {
+					if(d1[0][row][col] != d2[0][row][col])
+						System.out.println("BAND:" + 0 +" ROW:" + row + " COL:" + col + " " + d1[0][row][col] + " " + d2[0][row][col]);
+					assertEquals(d1[0][row][col], d2[0][row][col]);
+				}
+			}
+				
+			for (int row = 0; row < buf.getHeight(); row++) {
+				for (int col = 0; col < buf.getWidth(); col++) {
+					if(d1[1][row][col] != d2[2][row][col])
+						System.out.println("BAND:" + 1 +" ROW:" + row + " COL:" + col + " " + d1[1][row][col] + " " + d2[2][row][col]);
+					assertEquals(d1[1][row][col], d2[2][row][col]);
+				}
+			}
+			
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestRemoveBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestRemoveBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestSwapBands.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestSwapBands.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestSwapBands.java	(revision 3222)
@@ -0,0 +1,142 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.horizontal;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.exception.WrongParameterException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test swap several bands of a raster and save the result in other file.
+ * Finally it compares the output bands with the input bands.
+ * <P>
+ * The array to test is {2, 0, 1}. That means the band 0 goes to the position two, the
+ * band one goes to the position zero and the band two goes to the position one. 
+ * When the swap operation is executed, this test will check comparing the result 
+ * bands with the input bands 
+ * </P>
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestSwapBands extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-swaped.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestSwapBands running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input1 = null;
+		GdalWrite out = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input1 = new GdalRead(rasterIn);
+			Object dataIn1 = input1.readBlock(0, 0, input1.getWidth(), input1.getHeight());
+						
+			//Create Buffer
+			Buffer buf1 = new RasterCacheBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount());
+			
+			//Set data to buffer
+			setBytes(dataIn1, buf1);
+						
+			Buffer buf2 = new RasterCacheBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount());
+
+			//Set data to buffer
+			setBytes(dataIn1, buf2);
+			try {
+				buf2.swapBands(new int[]{2, 0, 1});
+			} catch (WrongParameterException e) {
+				e.printStackTrace();
+			}
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, input1.getBandCount(), input1.getDataType(), input1.getWidth(), input1.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf2.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(0);
+			Band band2 = buf2.getBand(1);
+			compareBands(band1, band2);
+			
+			band1 = buf1.getBand(1);
+			band2 = buf2.getBand(2);
+			compareBands(band1, band2);
+			
+			band1 = buf1.getBand(2);
+			band2 = buf2.getBand(0);
+			compareBands(band1, band2);
+			
+			buf1.free();
+			buf2.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestSwapBands: " + (t2 - t1) + " milisegundos");
+	}
+	
+	public void compareBands(Band band1, Band band2) {
+		for (int i = 0; i < band1.getHeight(); i++) {
+			for (int j = 0; j < band1.getWidth(); j++) {
+				byte b1 = band1.getElemByte(i, j);
+				byte b2 = band2.getElemByte(i, j);
+				assertEquals(b1, b2);
+			}
+		}
+	}
+	
+	/*private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}*/
+	
+	private void setBytes(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+    			for (int row = 0; row < d[iBand].length; row++) {
+    				for (int col = 0; col < d[iBand][0].length; col++) {
+						buf.setElem(row, col, iBand, d[iBand][row][col]);
+					}
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestSwapBands.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestCachePerformance.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestCachePerformance.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestCachePerformance.java	(revision 3222)
@@ -0,0 +1,99 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.horizontal;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+
+/**
+ * Performance Test
+ * Time 9.3 - 10 seg 
+ * REPEAT = 10
+ * Intel(R) Core(TM)2 CPU E8400  @ 3.00GHz
+ * 2GB RAM DDR3 1066
+ * HDD ATA 133
+ * Linux Ubuntu 8.04 kernel 2.6.24
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestCachePerformance extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private static int REPEAT = 10;
+	public int aux = 0;
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestCachePerformance running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			for (int iTimes = 0; iTimes < REPEAT; iTimes++) {
+
+				//Read input data
+				input = new GdalRead(rasterIn);
+				Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+
+				//Create Buffer
+				Buffer buf1 = new RasterCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+						input.getWidth(), 
+						input.getHeight(),
+						input.getBandCount());
+
+				//Set data to buffer
+				setLines(dataIn, buf1);
+				
+				
+				for (int iBand = 0; iBand < buf1.getBandCount(); iBand++) {
+					for (int i = 0; i < buf1.getHeight(); i++) {
+						for (int j = 0; j < buf1.getWidth(); j++) {
+							byte b1 = buf1.getElemByte(i, j, iBand);
+							byte b2 = buf1.getElemByte(i, j, iBand);
+							aux = b1 * b2;
+						}
+					}
+				}
+				
+				buf1.free();
+			}
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestCachePerformance: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestCachePerformance.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestRWTiffAndCompareData.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestRWTiffAndCompareData.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestRWTiffAndCompareData.java	(revision 3222)
@@ -0,0 +1,104 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.horizontal;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test reads a Tiff from disk with the class TIFFRead and load data in
+ * a cache buffer. Then it saves those bytes in a new out file in the same format.
+ * Finally it compares the input data with the output data to test if there are some
+ * differences.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestRWTiffAndCompareData extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestRWTiffAndCompareData running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf = new RasterCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount());
+			
+			//Set data to buffer
+			setLines(dataIn, buf);
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, input.getBandCount(), input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf.getBands());
+			buf.free();
+			out.close();	
+			
+			//Open output file and compare
+			GdalRead newFile = new GdalRead(rasterOut);
+			Object dataOut = newFile.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			byte[][][] d1 = (byte[][][])dataIn;
+			byte[][][] d2 = (byte[][][])dataOut;
+			for (int iBand = 0; iBand < buf.getBandCount(); iBand++) {
+				for (int row = 0; row < buf.getHeight(); row++) {
+					for (int col = 0; col < buf.getWidth(); col++) {
+						if(d1[iBand][row][col] != d2[iBand][row][col])
+							System.out.println("BAND:" + iBand +" ROW:" + row + " COL:" + col + " " + d1[iBand][row][col] + " " + d2[iBand][row][col]);
+						assertEquals(d1[iBand][row][col], d2[iBand][row][col]);
+					}
+				}
+			}
+				
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestRWTiffAndCompareData: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/horizontal/TestRWTiffAndCompareData.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestCopyBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestCopyBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestCopyBand.java	(revision 3222)
@@ -0,0 +1,120 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.BandNotCompatibleException;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * Copy the band 0 from a buffer over the band 2 in the same buffer using the
+ * method getBandCopy.  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestCopyBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-copyFirstBand.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestCopyBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf1 = new RasterVertCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount());
+			
+			//Set data to buffer
+			setBytes(dataIn, buf1);
+			
+			//TODO: se ha comentado pq se para al cerrar las librer�as. Cuando se
+			//retome esta cach� deber�a ponerse en marcha
+			/*Band rb = buf1.getBandCopy(0);
+			
+			try {
+				buf1.copyBand(2, rb);
+			} catch (BandNotCompatibleException e) {
+				e.printStackTrace();
+			}
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 3, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf1.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(0);
+			Band band2 = buf1.getBand(2);
+			for (int j = 0; j < band1.getWidth(); j++) {
+				for (int i = 0; i < band1.getHeight(); i++) {
+					byte b1 = band1.getElemByte(i, j);
+					byte b2 = band2.getElemByte(i, j);
+					assertEquals(b1, b2);
+				}
+			}
+			
+			buf1.free();*/
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestCopyBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setBytes(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+    			for (int col = 0; col < d[iBand][0].length; col++) {
+    				for (int row = 0; row < d[iBand].length; row++) {
+						buf.setElem(row, col, iBand, d[iBand][row][col]);
+					}
+				}
+			}
+    	}
+	}
+	
+//	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+//		if(dataIn instanceof byte[][][]) {
+//    		byte[][][] d = (byte[][][])dataIn;
+//    		for (int iBand = 0; iBand < d.length; iBand++) {
+//				for (int row = 0; row < d[iBand].length; row++) {
+//					buf.setLineInBandByte(d[iBand][row], row, iBand);
+//				}
+//			}
+//    	}
+//	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestCopyBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestCopyBand2.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestCopyBand2.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestCopyBand2.java	(revision 3222)
@@ -0,0 +1,130 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.BandNotCompatibleException;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * Copy the band 0 from a buffer over the band 2 of other buffer using the
+ * method getBand (reference).
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestCopyBand2 extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-copyFirstBand.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestCopyBand2 running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf1 = new RasterVertCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount());
+			
+			//Set data to buffer
+			setBytes(dataIn, buf1);
+			
+			//Create Buffer
+			Buffer buf2 = new RasterVertCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount());
+			
+			//Set data to buffer
+			setBytes(dataIn, buf2);
+			
+			//TODO: se ha comentado pq se para al cerrar las librer�as. Cuando se
+			//retome esta cach� deber�a ponerse en marcha
+			/*Band rb = buf1.getBand(0);
+			
+			try {
+				buf2.copyBand(2, rb);
+			} catch (BandNotCompatibleException e) {
+				e.printStackTrace();
+			}
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 3, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf2.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(0);
+			Band band2 = buf2.getBand(2);
+			for (int j = 0; j < band1.getWidth(); j++) {
+				for (int i = 0; i < band1.getHeight(); i++) {
+					byte b1 = band1.getElemByte(i, j);
+					byte b2 = band2.getElemByte(i, j);
+					assertEquals(b1, b2);
+				}
+			}
+			
+			buf1.free();
+			buf2.free();*/
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestCopyBand2: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setBytes(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+    			for (int col = 0; col < d[iBand][0].length; col++) {
+    				for (int row = 0; row < d[iBand].length; row++) {
+						buf.setElem(row, col, iBand, d[iBand][row][col]);
+					}
+				}
+			}
+    	}
+	}
+	
+//	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+//		if(dataIn instanceof byte[][][]) {
+//    		byte[][][] d = (byte[][][])dataIn;
+//    		for (int iBand = 0; iBand < d.length; iBand++) {
+//				for (int row = 0; row < d[iBand].length; row++) {
+//					buf.setLineInBandByte(d[iBand][row], row, iBand);
+//				}
+//			}
+//    	}
+//	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestCopyBand2.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestRemoveBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestRemoveBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestRemoveBand.java	(revision 3222)
@@ -0,0 +1,124 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test read a RGB image and remove one band from the read buffer. Then compare 
+ * the bands that have not been removed with the source bands. As a result of this test a raster
+ * of two bands is created and saved in the hard disk
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestRemoveBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-2bands.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestRemoveBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf = new RasterVertCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount());
+			
+			//Set data to buffer
+			setBytes(dataIn, buf);
+			buf.removeBand(1);
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 2, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out.writeBands(buf.getBands());
+			buf.free();
+			out.close();	
+			
+			//Open output file and compare
+			GdalRead newFile = new GdalRead(rasterOut);
+			Object dataOut = newFile.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			byte[][][] d1 = (byte[][][])dataOut;
+			byte[][][] d2 = (byte[][][])dataIn;
+			
+			for (int row = 0; row < buf.getHeight(); row++) {
+				for (int col = 0; col < buf.getWidth(); col++) {
+					if(d1[0][row][col] != d2[0][row][col])
+						System.out.println("BAND:" + 0 +" ROW:" + row + " COL:" + col + " " + d1[0][row][col] + " " + d2[0][row][col]);
+					assertEquals(d1[0][row][col], d2[0][row][col]);
+				}
+			}
+				
+			for (int row = 0; row < buf.getHeight(); row++) {
+				for (int col = 0; col < buf.getWidth(); col++) {
+					if(d1[1][row][col] != d2[2][row][col])
+						System.out.println("BAND:" + 1 +" ROW:" + row + " COL:" + col + " " + d1[1][row][col] + " " + d2[2][row][col]);
+					assertEquals(d1[1][row][col], d2[2][row][col]);
+				}
+			}
+			
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestRemoveBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setBytes(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+    			for (int col = 0; col < d[iBand][0].length; col++) {
+    				for (int row = 0; row < d[iBand].length; row++) {
+						buf.setElem(row, col, iBand, d[iBand][row][col]);
+					}
+				}
+			}
+    	}
+	}
+	
+//	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+//		if(dataIn instanceof byte[][][]) {
+//    		byte[][][] d = (byte[][][])dataIn;
+//    		for (int iBand = 0; iBand < d.length; iBand++) {
+//				for (int row = 0; row < d[iBand].length; row++) {
+//					buf.setLineInBandByte(d[iBand][row], row, iBand);
+//				}
+//			}
+//    	}
+//	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestRemoveBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestSwapBands.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestSwapBands.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestSwapBands.java	(revision 3222)
@@ -0,0 +1,141 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.exception.WrongParameterException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test swap several bands of a raster and save the result in other file.
+ * Finally it compares the output bands with the input bands.
+ * <P>
+ * The array to test is {2, 0, 1}. That means the band 0 goes to the position two, the
+ * band one goes to the position zero and the band two goes to the position one. 
+ * When the swap operation is executed, this test will check comparing the result 
+ * bands with the input bands 
+ * </P>
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestSwapBands extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-swaped.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestSwapBands running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input1 = null;
+		GdalWrite out = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input1 = new GdalRead(rasterIn);
+			Object dataIn1 = input1.readBlock(0, 0, input1.getWidth(), input1.getHeight());
+						
+			//Create Buffer
+			Buffer buf1 = new RasterVertCacheBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount());
+			
+			//Set data to buffer
+			setBytes(dataIn1, buf1);
+						
+			Buffer buf2 = new RasterVertCacheBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount());
+
+			//Set data to buffer
+			setBytes(dataIn1, buf2);
+			try {
+				buf2.swapBands(new int[]{2, 0, 1});
+			} catch (WrongParameterException e) {
+				e.printStackTrace();
+			}
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, input1.getBandCount(), input1.getDataType(), input1.getWidth(), input1.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf2.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(0);
+			Band band2 = buf2.getBand(1);
+			compareBands(band1, band2);
+			
+			band1 = buf1.getBand(1);
+			band2 = buf2.getBand(2);
+			compareBands(band1, band2);
+			
+			band1 = buf1.getBand(2);
+			band2 = buf2.getBand(0);
+			compareBands(band1, band2);
+			
+			buf1.free();
+			buf2.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestSwapBands: " + (t2 - t1) + " milisegundos");
+	}
+	
+	public void compareBands(Band band1, Band band2) {
+		for (int j = 0; j < band1.getWidth(); j++) {
+			for (int i = 0; i < band1.getHeight(); i++) {
+				byte b1 = band1.getElemByte(i, j);
+				byte b2 = band2.getElemByte(i, j);
+				assertEquals(b1, b2);
+			}
+		}
+	}
+	
+	private void setBytes(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+    			for (int col = 0; col < d[iBand][0].length; col++) {
+    				for (int row = 0; row < d[iBand].length; row++) {
+						buf.setElem(row, col, iBand, d[iBand][row][col]);
+					}
+				}
+			}
+    	}
+	}
+//	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+//		if(dataIn instanceof byte[][][]) {
+//    		byte[][][] d = (byte[][][])dataIn;
+//    		for (int iBand = 0; iBand < d.length; iBand++) {
+//				for (int row = 0; row < d[iBand].length; row++) {
+//					buf.setLineInBandByte(d[iBand][row], row, iBand);
+//				}
+//			}
+//    	}
+//	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestSwapBands.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestCachePerformance.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestCachePerformance.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestCachePerformance.java	(revision 3222)
@@ -0,0 +1,112 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+
+/**
+ * Performance Test
+ * Time 9.3 - 10 seg 
+ * REPEAT = 10
+ * Intel(R) Core(TM)2 CPU E8400  @ 3.00GHz
+ * 2GB RAM DDR3 1066
+ * HDD ATA 133
+ * Linux Ubuntu 8.04 kernel 2.6.24
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestCachePerformance extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private static int REPEAT = 10;
+	public int aux = 0;
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestCachePerformance running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			for (int iTimes = 0; iTimes < REPEAT; iTimes++) {
+
+				//Read input data
+				input = new GdalRead(rasterIn);
+				Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+
+				//Create Buffer
+				Buffer buf1 = new RasterVertCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+						input.getWidth(), 
+						input.getHeight(),
+						input.getBandCount());
+
+				//Set data to buffer
+				setBytes(dataIn, buf1);
+				
+				
+				for (int iBand = 0; iBand < buf1.getBandCount(); iBand++) {
+					for (int j = 0; j < buf1.getWidth(); j++) {
+						for (int i = 0; i < buf1.getHeight(); i++) {
+							byte b1 = buf1.getElemByte(i, j, iBand);
+							byte b2 = buf1.getElemByte(i, j, iBand);
+							aux = b1 * b2;
+						}
+					}
+				}
+				
+				buf1.free();
+			}
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestCachePerformance: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setBytes(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+    			for (int col = 0; col < d[iBand][0].length; col++) {
+    				for (int row = 0; row < d[iBand].length; row++) {
+						buf.setElem(row, col, iBand, d[iBand][row][col]);
+					}
+				}
+			}
+    	}
+	}
+	
+//	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+//		if(dataIn instanceof byte[][][]) {
+//    		byte[][][] d = (byte[][][])dataIn;
+//    		for (int iBand = 0; iBand < d.length; iBand++) {
+//				for (int row = 0; row < d[iBand].length; row++) {
+//					buf.setLineInBandByte(d[iBand][row], row, iBand);
+//				}
+//			}
+//    	}
+//	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestCachePerformance.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestRWTiffAndCompareData.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestRWTiffAndCompareData.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestRWTiffAndCompareData.java	(revision 3222)
@@ -0,0 +1,108 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test reads a Tiff from disk with the class TIFFRead and load data in
+ * a cache buffer. Then it saves those bytes in a new out file in the same format.
+ * Finally it compares the input data with the output data to test if there are some
+ * differences.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestRWTiffAndCompareData extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestRWTiffAndCompareData running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf = new RasterVertCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount());
+			
+			//Set data to buffer
+			setValues(dataIn, buf);
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, input.getBandCount(), input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf.getBands());
+			buf.free();
+			out.close();	
+			
+			//Open output file and compare
+			GdalRead newFile = new GdalRead(rasterOut);
+			Object dataOut = newFile.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			byte[][][] d1 = (byte[][][])dataIn;
+			byte[][][] d2 = (byte[][][])dataOut;
+			for (int iBand = 0; iBand < buf.getBandCount(); iBand++) {
+				for (int col = 0; col < buf.getWidth(); col++) {
+					for (int row = 0; row < buf.getHeight(); row++) {
+						if(d1[iBand][row][col] != d2[iBand][row][col])
+							System.out.println("BAND:" + iBand +" ROW:" + row + " COL:" + col + " " + d1[iBand][row][col] + " " + d2[iBand][row][col]);
+						assertEquals(d1[iBand][row][col], d2[iBand][row][col]);
+					}
+				}
+			}
+				
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestRWTiffAndCompareData: " + (t2 - t1) + " milisegundos");
+	}
+	
+	public void setValues(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+			byte[][][] d = (byte[][][])dataIn;
+			for (int band = 0; band < d.length; band++) {
+				for (int col = 0; col < d[band][0].length; col++) {
+					if(col == 2560)
+						System.out.println();
+					for (int row = 0; row < d[band].length; row++) {
+						buf.setElem(row, col, band, (byte)d[band][row][col]);
+					}
+				}
+			}
+		}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestRWTiffAndCompareData.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestRWOneValue.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestRWOneValue.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestRWOneValue.java	(revision 3222)
@@ -0,0 +1,70 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import java.awt.image.DataBuffer;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+
+/**
+ * This test creates a buffer and write a number in each element of each band.
+ * Then, it reads from the buffer the numbers and check it.
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestRWOneValue extends TestCase {
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestRWOneValue running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		
+		//Reducimos el tama�o de la cache para una prueba con menos datos
+		BufferCacheManagerImpl.cacheSize = 2;
+		BufferCacheManagerImpl.pageSize = 0.2;
+		
+		RasterVertCacheBuffer buf = new RasterVertCacheBuffer(DataBuffer.TYPE_BYTE, 2571, 1942, 3);
+		
+		for (int iBand = 0; iBand < buf.getBandCount(); iBand++) {
+			for (int col = 0; col < buf.getWidth(); col++) {
+				for (int row = 0; row < buf.getHeight(); row++) {
+					byte n = (byte)(8 + iBand);
+					byte m = (byte)(34 + iBand);
+					if(row == 1001 && col == 1032)
+						buf.setElem(row, col, iBand, n);
+					else
+						buf.setElem(row, col, iBand, m);			
+				}
+			}
+		}
+		
+		for (int iBand = 0; iBand < buf.getBandCount(); iBand++) {
+			for (int col = 0; col < buf.getWidth(); col++) {
+				for (int row = 0; row < buf.getHeight(); row++) {
+					byte n = buf.getElemByte(row, col, iBand);
+					byte m = (byte)(34 + iBand); 
+					if(n != m)
+						;//System.out.println(n + " " + row + "," + col);
+					else
+						assertEquals(n, m);
+				}
+			}
+		}
+		try {
+			buf.free();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestRWOneValue: " + (t2 - t1) + " milisegundos");
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestRWOneValue.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestCreateBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestCreateBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestCreateBand.java	(revision 3222)
@@ -0,0 +1,102 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+
+/**
+ * This test add a band in a raster of 3 bands. As a result of this test a raster
+ * of four bands is created and saved in the hard disk. The value of additional band
+ * is zero in all its elements. Finally it gets the band added and compare each values 
+ * with 0. 
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestCreateBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestCreateBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf = new RasterVertCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount());
+			
+			//Set data to buffer
+			setBytes(dataIn, buf);
+			Band rb = buf.createBand((byte)100);
+
+			for (int j = 0; j < rb.getWidth(); j++) {
+				for (int i = 0; i < rb.getHeight(); i++) {
+					byte b = rb.getElemByte(i, j);
+					assertEquals((byte)100, b);
+				}
+			}
+			
+			buf.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestCreateBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setBytes(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+    			for (int col = 0; col < d[iBand][0].length; col++) {
+    				for (int row = 0; row < d[iBand].length; row++) {
+						buf.setElem(row, col, iBand, d[iBand][row][col]);
+					}
+				}
+			}
+    	}
+	}
+	
+//	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+//		if(dataIn instanceof byte[][][]) {
+//    		byte[][][] d = (byte[][][])dataIn;
+//    		for (int iBand = 0; iBand < d.length; iBand++) {
+//				for (int row = 0; row < d[iBand].length; row++) {
+//					buf.setLineInBandByte(d[iBand][row], row, iBand);
+//				}
+//			}
+//    	}
+//	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestCreateBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestAssignBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestAssignBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestAssignBand.java	(revision 3222)
@@ -0,0 +1,132 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.BandNotCompatibleException;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestAssignBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-4bands.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestAssignBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input1 = null;
+		GdalRead input2 = null;
+		GdalWrite out = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input1 = new GdalRead(rasterIn);
+			Object dataIn1 = input1.readBlock(0, 0, input1.getWidth(), input1.getHeight());
+			input2 = new GdalRead(rasterIn);
+			Object dataIn2 = input1.readBlock(0, 0, input2.getWidth(), input2.getHeight());
+			
+			//Create Buffer
+			Buffer buf1 = new RasterVertCacheBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount());
+			
+			//Set data to buffer
+			setBytes(dataIn1, buf1);
+			//Create Buffer
+			Buffer buf2 = new RasterVertCacheBuffer(input2.getRasterBufTypeFromGdalType(input2.getDataType()), 
+														input2.getWidth(), 
+														input2.getHeight(),
+														input2.getBandCount());
+			
+			//Set data to buffer
+			setBytes(dataIn2, buf2);
+			
+			Band rb = buf2.getBand(2);
+			try {
+				buf1.assignBand(1, rb);
+			} catch (BandNotCompatibleException e) {
+				e.printStackTrace();
+			}
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 4, input1.getDataType(), input1.getWidth(), input1.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			
+			//TODO: se ha comentarizado pq se para al cerrar las librer�as. Cuando se
+			//retome esta cach� deber�a ponerse en marcha
+			
+			/*out.writeBands(buf1.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(1);
+			Band band2 = buf1.getBand(3);
+			for (int j = 0; j < band1.getWidth(); j++) {
+				for (int i = 0; i < band1.getHeight(); i++) {
+					byte b1 = band1.getElemByte(i, j);
+					byte b2 = band2.getElemByte(i, j);
+					assertEquals(b1, b2);
+				}
+			}
+			
+			buf1.free();
+			buf2.free();*/
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestAssignBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setBytes(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+    			for (int col = 0; col < d[iBand][0].length; col++) {
+    				for (int row = 0; row < d[iBand].length; row++) {
+						buf.setElem(row, col, iBand, d[iBand][row][col]);
+					}
+				}
+			}
+    	}
+	}
+	
+	/*private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}*/
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestAssignBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/AllTests.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/AllTests.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/AllTests.java	(revision 3222)
@@ -0,0 +1,28 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+	public static Test suite() {
+		TestSuite suite = new TestSuite(
+				"Test for org.gvsig.raster.buffer.stripecache");
+		//$JUnit-BEGIN$
+		suite.addTestSuite(TestSwapTwoBands.class);
+		suite.addTestSuite(TestAssignBand.class);
+		suite.addTestSuite(TestCopyBand.class);
+		suite.addTestSuite(TestRemoveBand.class);
+		suite.addTestSuite(TestReplicateBand.class);
+		suite.addTestSuite(TestAddBand.class);
+		suite.addTestSuite(TestRWOneValue.class);
+		suite.addTestSuite(TestCreateBand.class);
+		suite.addTestSuite(TestRWTiffAndCompareData.class);
+		suite.addTestSuite(TestSwapBands.class);
+		suite.addTestSuite(TestCopyBand2.class);
+		suite.addTestSuite(TestGetBufferWithOneBand.class);
+		//$JUnit-END$
+		return suite;
+	}
+
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/AllTests.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestGetBufferWithOneBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestGetBufferWithOneBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestGetBufferWithOneBand.java	(revision 3222)
@@ -0,0 +1,131 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test gets bands from a raster with the method getBufferWithOneBand() and compare
+ * each band from original source with obtained bands 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestGetBufferWithOneBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut1 = "/tmp/out-b1.tif";
+	private String rasterOut2 = "/tmp/out-b2.tif";
+	private String rasterOut3 = "/tmp/out-b3.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestGetBufferWithOneBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf = new RasterVertCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount());
+			
+			//Set data to buffer
+			setBytes(dataIn, buf);
+			
+			Buffer b0 = buf.getBufferWithOneBand(0);
+			Buffer b1 = buf.getBufferWithOneBand(1);
+			Buffer b2 = buf.getBufferWithOneBand(2);
+			
+			//Write output file 
+			GdalWrite out1 = new GdalWrite(rasterOut1, 1, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out1.writeBands(b0.getBands());
+			out1.close();
+			
+			GdalWrite out2 = new GdalWrite(rasterOut2, 1, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out2.writeBands(b1.getBands());
+			out2.close();
+			
+			GdalWrite out3 = new GdalWrite(rasterOut3, 1, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			
+			//TODO: se ha comentarizado pq se para al cerrar las librer�as. Cuando se
+			//retome esta cach� deber�a ponerse en marcha
+			
+			/*out3.writeBands(b2.getBands());
+			out3.close();
+				
+			
+			for (int col = 0; col < buf.getWidth(); col++) {
+				for (int row = 0; row < buf.getHeight(); row++) {
+					byte b_0 = buf.getElemByte(row, col, 0);
+					byte b_1 = buf.getElemByte(row, col, 1);
+					byte b_2 = buf.getElemByte(row, col, 2);
+					assertEquals(b_0, b0.getElemByte(row, col, 0));
+					assertEquals(b_1, b1.getElemByte(row, col, 0));
+					assertEquals(b_2, b2.getElemByte(row, col, 0));
+				}
+			}
+			*/
+			b0.free();
+			b1.free();
+			b2.free();
+			buf.free();
+				
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestGetBufferWithOneBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setBytes(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+    			for (int col = 0; col < d[iBand][0].length; col++) {
+    				for (int row = 0; row < d[iBand].length; row++) {
+						buf.setElem(row, col, iBand, d[iBand][row][col]);
+					}
+				}
+			}
+    	}
+	}
+//	
+//	private void setlines(object datain, buffer buf) throws operationnotsupportedexception {
+//		if(datain instanceof byte[][][]) {
+//    		byte[][][] d = (byte[][][])datain;
+//    		for (int iband = 0; iband < d.length; iband++) {
+//				for (int row = 0; row < d[iband].length; row++) {
+//					buf.setlineinbandbyte(d[iband][row], row, iband);
+//				}
+//			}
+//    	}
+//	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestGetBufferWithOneBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestSwapTwoBands.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestSwapTwoBands.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestSwapTwoBands.java	(revision 3222)
@@ -0,0 +1,126 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.exception.WrongParameterException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test swap two bands of a raster and save the result in other file.
+ * Finally it compares the output bands with the input bands.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestSwapTwoBands extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-swapedTwo.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestSwapTwoBands running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input1 = null;
+		GdalWrite out = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input1 = new GdalRead(rasterIn);
+			Object dataIn1 = input1.readBlock(0, 0, input1.getWidth(), input1.getHeight());
+						
+			//Create Buffer
+			Buffer buf1 = new RasterVertCacheBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount());
+			
+			//Set data to buffer
+			setBytes(dataIn1, buf1);
+						
+			Buffer buf2 = new RasterVertCacheBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount());
+
+			//Set data to buffer
+			setBytes(dataIn1, buf2);
+			try {
+				buf2.swapBands(0, 2);
+			} catch (WrongParameterException e) {
+				e.printStackTrace();
+			}
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, input1.getBandCount(), input1.getDataType(), input1.getWidth(), input1.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf2.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(0);
+			Band band2 = buf2.getBand(2);
+			compareBands(band1, band2);
+			
+			band1 = buf1.getBand(2);
+			band2 = buf2.getBand(0);
+			compareBands(band1, band2);
+			
+			band1 = buf1.getBand(1);
+			band2 = buf2.getBand(1);
+			compareBands(band1, band2);
+			
+			buf1.free();
+			buf2.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestSwapTwoBands: " + (t2 - t1) + " milisegundos");
+	}
+	
+	public void compareBands(Band band1, Band band2) {
+		for (int j = 0; j < band1.getWidth(); j++) {
+			for (int i = 0; i < band1.getHeight(); i++) {
+				byte b1 = band1.getElemByte(i, j);
+				byte b2 = band2.getElemByte(i, j);
+				assertEquals(b1, b2);
+			}
+		}
+	}
+	
+	private void setBytes(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+    			for (int col = 0; col < d[iBand][0].length; col++) {
+    				for (int row = 0; row < d[iBand].length; row++) {
+						buf.setElem(row, col, iBand, d[iBand][row][col]);
+					}
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestSwapTwoBands.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestAddBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestAddBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestAddBand.java	(revision 3222)
@@ -0,0 +1,111 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test add a band in a raster of 3 bands. As a result of this test a raster
+ * of four bands is created and saved in the hard disk. The value of additional band
+ * is zero in all its elements. Finally it gets the band added and compare each values 
+ * with 0. 
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestAddBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-4bands.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestAddBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf = new RasterVertCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount());
+			
+			//Set data to buffer
+			setBytes(dataIn, buf);
+			buf.addBand(1);
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 4, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out.writeBands(buf.getBands());
+			out.close();	
+			
+			Band band = buf.getBand(1);
+			for (int j = 0; j < band.getWidth(); j++) {
+				for (int i = 0; i < band.getHeight(); i++) {
+					byte b = band.getElemByte(i, j);
+					assertEquals(0, b);
+				}
+			}
+			
+			buf.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestAddBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setBytes(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+    			for (int col = 0; col < d[iBand][0].length; col++) {
+    				for (int row = 0; row < d[iBand].length; row++) {
+						buf.setElem(row, col, iBand, d[iBand][row][col]);
+					}
+				}
+			}
+    	}
+	}
+	
+//	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+//		if(dataIn instanceof byte[][][]) {
+//    		byte[][][] d = (byte[][][])dataIn;
+//    		for (int iBand = 0; iBand < d.length; iBand++) {
+//				for (int row = 0; row < d[iBand].length; row++) {
+//					buf.setLineInBandByte(d[iBand][row], row, iBand);
+//				}
+//			}
+//    	}
+//	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestAddBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestReplicateBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestReplicateBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestReplicateBand.java	(revision 3222)
@@ -0,0 +1,116 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/** 
+ * This test insert one band at the end of the layer. The data of this new band is a copy 
+ * of the band in position zero. Finally data of band zero and band three are compared
+ * checking if both have the same values. 
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestReplicateBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-replicateBands.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestReplicateBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input1 = null;
+		GdalWrite out = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input1 = new GdalRead(rasterIn);
+			Object dataIn1 = input1.readBlock(0, 0, input1.getWidth(), input1.getHeight());
+			
+			//Create Buffer
+			Buffer buf1 = new RasterVertCacheBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount());
+			
+			//Set data to buffer
+			setBytes(dataIn1, buf1);
+						
+			buf1.replicateBand(0, 3);
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 4, input1.getDataType(), input1.getWidth(), input1.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			
+			//TODO: se ha comentado pq se para al cerrar las librer�as. Cuando se
+			//retome esta cach� deber�a ponerse en marcha
+			/*out.writeBands(buf1.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(0);
+			Band band2 = buf1.getBand(3);
+			for (int j = 0; j < band1.getWidth(); j++) {
+				for (int i = 0; i < band1.getHeight(); i++) {
+					byte b1 = band1.getElemByte(i, j);
+					byte b2 = band2.getElemByte(i, j);
+					assertEquals(b1, b2);
+				}
+			}
+			
+			buf1.free();*/
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestReplicateBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setBytes(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+    			for (int col = 0; col < d[iBand][0].length; col++) {
+    				for (int row = 0; row < d[iBand].length; row++) {
+						buf.setElem(row, col, iBand, d[iBand][row][col]);
+					}
+				}
+			}
+    	}
+	}
+	
+//	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {  
+//		if(dataIn instanceof byte[][][]) {
+//    		byte[][][] d = (byte[][][])dataIn;
+//    		for (int iBand = 0; iBand < d.length; iBand++) {
+//				for (int row = 0; row < d[iBand].length; row++) {
+//					buf.setLineInBandByte(d[iBand][row], row, iBand);
+//				}
+//			}
+//    	}
+//	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/vertical/TestReplicateBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationBilinearIncrease.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationBilinearIncrease.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationBilinearIncrease.java	(revision 3222)
@@ -0,0 +1,86 @@
+package org.gvsig.raster.cache.buffer.impl;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer;
+
+/**
+ * Copy the band 0 from a buffer over the band 2 in the same buffer using the
+ * method getBandCopy.  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestInterpolationBilinearIncrease extends TestCase {
+	private String         rasterIn  = "./src/test/resources/image/001m09_1_0.tif";
+	private String         rasterOut = "/tmp/out-interpBilinear.tif";
+	private static int     REL       = 2;
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("TestInterpolationBilinear running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			//Read input data
+			input = new GdalRead(rasterIn);
+			int readSize = 10;
+			Object dataIn = input.readBlock(0, 0, readSize, readSize);
+			
+			//Create Buffer
+			Buffer buf1 = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														readSize, 
+														readSize,
+														input.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			setLines(dataIn, buf1);
+			Buffer buf = buf1.getAdjustedWindow(readSize * REL, readSize * REL, BufferInterpolationImpl.INTERPOLATION_Bilinear);
+						
+			//Write output file 
+			out = new GdalWrite(rasterOut, 3, input.getDataType(), buf.getWidth(), buf.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf.getBands());
+			out.close();	
+			
+			buf1.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo TestInterpolationBilinear: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}
+

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationBilinearIncrease.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationBilinearReduction.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationBilinearReduction.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationBilinearReduction.java	(revision 3222)
@@ -0,0 +1,85 @@
+package org.gvsig.raster.cache.buffer.impl;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer;
+
+/**
+ * Copy the band 0 from a buffer over the band 2 in the same buffer using the
+ * method getBandCopy.  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestInterpolationBilinearReduction extends TestCase {
+	private String         rasterIn  = "./src/test/resources/image/001m09_1_0.tif";
+	private String         rasterOut = "/tmp/out-interpBilinearReduction.tif";
+	private static int     REL       = 5;
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("TestInterpolationBilinearReduction running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+						
+			//Create Buffer
+			Buffer buf1 = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			setLines(dataIn, buf1);
+			Buffer buf = buf1.getAdjustedWindow(input.getWidth() / REL, input.getHeight() / REL, BufferInterpolationImpl.INTERPOLATION_Bilinear);
+						
+			//Write output file 
+			out = new GdalWrite(rasterOut, 3, input.getDataType(), buf.getWidth(), buf.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf.getBands());
+			out.close();	
+			
+			buf1.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo TestInterpolationBilinearReduction: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}
+

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationBilinearReduction.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestAddBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestAddBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestAddBand.java	(revision 3222)
@@ -0,0 +1,98 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.horizontal;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test add a band in a raster of 3 bands. As a result of this test a raster
+ * of four bands is created and saved in the hard disk. The value of additional band
+ * is zero in all its elements. Finally it gets the band added and compare each values 
+ * with 0. 
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestAddBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-4bands.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestAddBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf = new RasterCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount());
+			
+			//Set data to buffer
+			setLines(dataIn, buf);
+			buf.addBand(1);
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 4, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out.writeBands(buf.getBands());
+			out.close();	
+			
+			Band band = buf.getBand(1);
+			for (int i = 0; i < band.getHeight(); i++) {
+				for (int j = 0; j < band.getWidth(); j++) {
+					byte b = band.getElemByte(i, j);
+					assertEquals(0, b);
+				}
+			}
+			
+			buf.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestAddBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestAddBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestReplicateBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestReplicateBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestReplicateBand.java	(revision 3222)
@@ -0,0 +1,100 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.horizontal;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/** 
+ * This test insert one band at the end of the layer. The data of this new band is a copy 
+ * of the band in position zero. Finally data of band zero and band three are compared
+ * checking if both have the same values. 
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestReplicateBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-replicateBands.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestReplicateBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input1 = null;
+		GdalWrite out = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input1 = new GdalRead(rasterIn);
+			Object dataIn1 = input1.readBlock(0, 0, input1.getWidth(), input1.getHeight());
+			
+			//Create Buffer
+			Buffer buf1 = new RasterCacheBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount());
+			
+			//Set data to buffer
+			setLines(dataIn1, buf1);
+						
+			buf1.replicateBand(0, 3);
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 4, input1.getDataType(), input1.getWidth(), input1.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out.writeBands(buf1.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(0);
+			Band band2 = buf1.getBand(3);
+			for (int i = 0; i < band1.getHeight(); i++) {
+				for (int j = 0; j < band1.getWidth(); j++) {
+					byte b1 = band1.getElemByte(i, j);
+					byte b2 = band2.getElemByte(i, j);
+					assertEquals(b1, b2);
+				}
+			}
+			
+			buf1.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestReplicateBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {  
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestReplicateBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestCopyBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestCopyBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestCopyBand.java	(revision 3222)
@@ -0,0 +1,106 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.horizontal;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.BandNotCompatibleException;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * Copy the band 0 from a buffer over the band 2 in the same buffer using the
+ * method getBandCopy.  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestCopyBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-copyFirstBand.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestCopyBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf1 = new RasterCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount());
+			
+			//Set data to buffer
+			setLines(dataIn, buf1);
+			
+			
+			Band rb = buf1.getBandCopy(0);
+			
+			try {
+				buf1.copyBand(2, rb);
+			} catch (BandNotCompatibleException e) {
+				e.printStackTrace();
+			}
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 3, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf1.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(0);
+			Band band2 = buf1.getBand(2);
+			for (int i = 0; i < band1.getHeight(); i++) {
+				for (int j = 0; j < band1.getWidth(); j++) {
+					byte b1 = band1.getElemByte(i, j);
+					byte b2 = band2.getElemByte(i, j);
+					assertEquals(b1, b2);
+				}
+			}
+			
+			buf1.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestCopyBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestCopyBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestCopyBand2.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestCopyBand2.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestCopyBand2.java	(revision 3222)
@@ -0,0 +1,115 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.horizontal;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.BandNotCompatibleException;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * Copy the band 0 from a buffer over the band 2 of other buffer using the
+ * method getBand (reference).
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestCopyBand2 extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-copyFirstBand.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestCopyBand2 running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf1 = new RasterCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount());
+			
+			//Set data to buffer
+			setLines(dataIn, buf1);
+			
+			//Create Buffer
+			Buffer buf2 = new RasterCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount());
+			
+			//Set data to buffer
+			setLines(dataIn, buf2);
+			
+			Band rb = buf1.getBand(0);
+			
+			try {
+				buf2.copyBand(2, rb);
+			} catch (BandNotCompatibleException e) {
+				e.printStackTrace();
+			}
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 3, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf2.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(0);
+			Band band2 = buf2.getBand(2);
+			for (int i = 0; i < band1.getHeight(); i++) {
+				for (int j = 0; j < band1.getWidth(); j++) {
+					byte b1 = band1.getElemByte(i, j);
+					byte b2 = band2.getElemByte(i, j);
+					assertEquals(b1, b2);
+				}
+			}
+			
+			buf1.free();
+			buf2.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestCopyBand2: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestCopyBand2.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestRemoveBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestRemoveBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestRemoveBand.java	(revision 3222)
@@ -0,0 +1,111 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.horizontal;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test read a RGB image and remove one band from the read buffer. Then compare 
+ * the bands that have not been removed with the source bands. As a result of this test a raster
+ * of two bands is created and saved in the hard disk
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestRemoveBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-2bands.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestRemoveBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf = new RasterCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount());
+			
+			//Set data to buffer
+			setLines(dataIn, buf);
+			buf.removeBand(1);
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 2, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out.writeBands(buf.getBands());
+			buf.free();
+			out.close();	
+			
+			//Open output file and compare
+			GdalRead newFile = new GdalRead(rasterOut);
+			Object dataOut = newFile.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			byte[][][] d1 = (byte[][][])dataOut;
+			byte[][][] d2 = (byte[][][])dataIn;
+			
+			for (int row = 0; row < buf.getHeight(); row++) {
+				for (int col = 0; col < buf.getWidth(); col++) {
+					if(d1[0][row][col] != d2[0][row][col])
+						System.out.println("BAND:" + 0 +" ROW:" + row + " COL:" + col + " " + d1[0][row][col] + " " + d2[0][row][col]);
+					assertEquals(d1[0][row][col], d2[0][row][col]);
+				}
+			}
+				
+			for (int row = 0; row < buf.getHeight(); row++) {
+				for (int col = 0; col < buf.getWidth(); col++) {
+					if(d1[1][row][col] != d2[2][row][col])
+						System.out.println("BAND:" + 1 +" ROW:" + row + " COL:" + col + " " + d1[1][row][col] + " " + d2[2][row][col]);
+					assertEquals(d1[1][row][col], d2[2][row][col]);
+				}
+			}
+			
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestRemoveBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestRemoveBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestSwapBands.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestSwapBands.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestSwapBands.java	(revision 3222)
@@ -0,0 +1,142 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.horizontal;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.exception.WrongParameterException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test swap several bands of a raster and save the result in other file.
+ * Finally it compares the output bands with the input bands.
+ * <P>
+ * The array to test is {2, 0, 1}. That means the band 0 goes to the position two, the
+ * band one goes to the position zero and the band two goes to the position one. 
+ * When the swap operation is executed, this test will check comparing the result 
+ * bands with the input bands 
+ * </P>
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestSwapBands extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-swaped.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestSwapBands running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input1 = null;
+		GdalWrite out = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input1 = new GdalRead(rasterIn);
+			Object dataIn1 = input1.readBlock(0, 0, input1.getWidth(), input1.getHeight());
+						
+			//Create Buffer
+			Buffer buf1 = new RasterCacheBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount());
+			
+			//Set data to buffer
+			setBytes(dataIn1, buf1);
+						
+			Buffer buf2 = new RasterCacheBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount());
+
+			//Set data to buffer
+			setBytes(dataIn1, buf2);
+			try {
+				buf2.swapBands(new int[]{2, 0, 1});
+			} catch (WrongParameterException e) {
+				e.printStackTrace();
+			}
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, input1.getBandCount(), input1.getDataType(), input1.getWidth(), input1.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf2.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(0);
+			Band band2 = buf2.getBand(1);
+			compareBands(band1, band2);
+			
+			band1 = buf1.getBand(1);
+			band2 = buf2.getBand(2);
+			compareBands(band1, band2);
+			
+			band1 = buf1.getBand(2);
+			band2 = buf2.getBand(0);
+			compareBands(band1, band2);
+			
+			buf1.free();
+			buf2.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestSwapBands: " + (t2 - t1) + " milisegundos");
+	}
+	
+	public void compareBands(Band band1, Band band2) {
+		for (int i = 0; i < band1.getHeight(); i++) {
+			for (int j = 0; j < band1.getWidth(); j++) {
+				byte b1 = band1.getElemByte(i, j);
+				byte b2 = band2.getElemByte(i, j);
+				assertEquals(b1, b2);
+			}
+		}
+	}
+	
+	/*private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}*/
+	
+	private void setBytes(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+    			for (int row = 0; row < d[iBand].length; row++) {
+    				for (int col = 0; col < d[iBand][0].length; col++) {
+						buf.setElem(row, col, iBand, d[iBand][row][col]);
+					}
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestSwapBands.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestCachePerformance.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestCachePerformance.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestCachePerformance.java	(revision 3222)
@@ -0,0 +1,99 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.horizontal;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+
+/**
+ * Performance Test
+ * Time 9.3 - 10 seg 
+ * REPEAT = 10
+ * Intel(R) Core(TM)2 CPU E8400  @ 3.00GHz
+ * 2GB RAM DDR3 1066
+ * HDD ATA 133
+ * Linux Ubuntu 8.04 kernel 2.6.24
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestCachePerformance extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private static int REPEAT = 10;
+	public int aux = 0;
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestCachePerformance running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			for (int iTimes = 0; iTimes < REPEAT; iTimes++) {
+
+				//Read input data
+				input = new GdalRead(rasterIn);
+				Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+
+				//Create Buffer
+				Buffer buf1 = new RasterCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+						input.getWidth(), 
+						input.getHeight(),
+						input.getBandCount());
+
+				//Set data to buffer
+				setLines(dataIn, buf1);
+				
+				
+				for (int iBand = 0; iBand < buf1.getBandCount(); iBand++) {
+					for (int i = 0; i < buf1.getHeight(); i++) {
+						for (int j = 0; j < buf1.getWidth(); j++) {
+							byte b1 = buf1.getElemByte(i, j, iBand);
+							byte b2 = buf1.getElemByte(i, j, iBand);
+							aux = b1 * b2;
+						}
+					}
+				}
+				
+				buf1.free();
+			}
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestCachePerformance: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestCachePerformance.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestRWTiffAndCompareData.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestRWTiffAndCompareData.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestRWTiffAndCompareData.java	(revision 3222)
@@ -0,0 +1,104 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.horizontal;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test reads a Tiff from disk with the class TIFFRead and load data in
+ * a cache buffer. Then it saves those bytes in a new out file in the same format.
+ * Finally it compares the input data with the output data to test if there are some
+ * differences.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestRWTiffAndCompareData extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestRWTiffAndCompareData running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf = new RasterCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount());
+			
+			//Set data to buffer
+			setLines(dataIn, buf);
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, input.getBandCount(), input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf.getBands());
+			buf.free();
+			out.close();	
+			
+			//Open output file and compare
+			GdalRead newFile = new GdalRead(rasterOut);
+			Object dataOut = newFile.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			byte[][][] d1 = (byte[][][])dataIn;
+			byte[][][] d2 = (byte[][][])dataOut;
+			for (int iBand = 0; iBand < buf.getBandCount(); iBand++) {
+				for (int row = 0; row < buf.getHeight(); row++) {
+					for (int col = 0; col < buf.getWidth(); col++) {
+						if(d1[iBand][row][col] != d2[iBand][row][col])
+							System.out.println("BAND:" + iBand +" ROW:" + row + " COL:" + col + " " + d1[iBand][row][col] + " " + d2[iBand][row][col]);
+						assertEquals(d1[iBand][row][col], d2[iBand][row][col]);
+					}
+				}
+			}
+				
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestRWTiffAndCompareData: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestRWTiffAndCompareData.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestRWOneValue.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestRWOneValue.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestRWOneValue.java	(revision 3222)
@@ -0,0 +1,70 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.horizontal;
+
+import java.awt.image.DataBuffer;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+
+/**
+ * This test creates a buffer and write a number in each element of each band.
+ * Then, it reads from the buffer the numbers and check it.
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestRWOneValue extends TestCase {
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestRWOneValue running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		
+		//Reducimos el tama�o de la cache para una prueba con menos datos
+		BufferCacheManagerImpl.cacheSize = 2;
+		BufferCacheManagerImpl.pageSize = 0.2;
+		
+		RasterCacheBuffer buf = new RasterCacheBuffer(DataBuffer.TYPE_BYTE, 2571, 1942, 3);
+		
+		for (int iBand = 0; iBand < buf.getBandCount(); iBand++) {
+			for (int row = 0; row < buf.getHeight(); row++) {
+				for (int col = 0; col < buf.getWidth(); col++) {
+					byte n = (byte)(8 + iBand);
+					byte m = (byte)(34 + iBand);
+					if(row == 1001 && col == 1032)
+						buf.setElem(row, col, iBand, n);
+					else
+						buf.setElem(row, col, iBand, m);			
+				}
+			}
+		}
+		
+		for (int iBand = 0; iBand < buf.getBandCount(); iBand++) {
+			for (int row = 0; row < buf.getHeight(); row++) {
+				for (int col = 0; col < buf.getWidth(); col++) {
+					byte n = buf.getElemByte(row, col, iBand);
+					byte m = (byte)(34 + iBand); 
+					if(n != m)
+						;//System.out.println(n + " " + row + "," + col);
+					else
+						assertEquals(n, m);
+				}
+			}
+		}
+		try {
+			buf.free();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestRWOneValue: " + (t2 - t1) + " milisegundos");
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestRWOneValue.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestCreateBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestCreateBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestCreateBand.java	(revision 3222)
@@ -0,0 +1,89 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.horizontal;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+
+/**
+ * This test add a band in a raster of 3 bands. As a result of this test a raster
+ * of four bands is created and saved in the hard disk. The value of additional band
+ * is zero in all its elements. Finally it gets the band added and compare each values 
+ * with 0. 
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestCreateBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestCreateBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf = new RasterCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount());
+			
+			//Set data to buffer
+			setLines(dataIn, buf);
+			Band rb = buf.createBand((byte)100);
+
+			for (int i = 0; i < rb.getHeight(); i++) {
+				for (int j = 0; j < rb.getWidth(); j++) {
+					byte b = rb.getElemByte(i, j);
+					assertEquals((byte)100, b);
+				}
+			}
+			
+			buf.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestCreateBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestCreateBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestAssignBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestAssignBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestAssignBand.java	(revision 3222)
@@ -0,0 +1,115 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.horizontal;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.BandNotCompatibleException;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestAssignBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-4bands.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestAssignBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input1 = null;
+		GdalRead input2 = null;
+		GdalWrite out = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input1 = new GdalRead(rasterIn);
+			Object dataIn1 = input1.readBlock(0, 0, input1.getWidth(), input1.getHeight());
+			input2 = new GdalRead(rasterIn);
+			Object dataIn2 = input1.readBlock(0, 0, input2.getWidth(), input2.getHeight());
+			
+			//Create Buffer
+			Buffer buf1 = new RasterCacheBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount());
+			
+			//Set data to buffer
+			setLines(dataIn1, buf1);
+			//Create Buffer
+			Buffer buf2 = new RasterCacheBuffer(input2.getRasterBufTypeFromGdalType(input2.getDataType()), 
+														input2.getWidth(), 
+														input2.getHeight(),
+														input2.getBandCount());
+			
+			//Set data to buffer
+			setLines(dataIn2, buf2);
+			
+			Band rb = buf2.getBand(2);
+			try {
+				buf1.assignBand(1, rb);
+			} catch (BandNotCompatibleException e) {
+				e.printStackTrace();
+			}
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 4, input1.getDataType(), input1.getWidth(), input1.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out.writeBands(buf1.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(1);
+			Band band2 = buf1.getBand(3);
+			for (int i = 0; i < band1.getHeight(); i++) {
+				for (int j = 0; j < band1.getWidth(); j++) {
+					byte b1 = band1.getElemByte(i, j);
+					byte b2 = band2.getElemByte(i, j);
+					assertEquals(b1, b2);
+				}
+			}
+			
+			buf1.free();
+			buf2.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestAssignBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestAssignBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/AllTests.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/AllTests.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/AllTests.java	(revision 3222)
@@ -0,0 +1,28 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.horizontal;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+	public static Test suite() {
+		TestSuite suite = new TestSuite(
+				"Test for org.gvsig.raster.buffer.stripecache");
+		//$JUnit-BEGIN$
+		suite.addTestSuite(TestSwapTwoBands.class);
+		suite.addTestSuite(TestAssignBand.class);
+		suite.addTestSuite(TestCopyBand.class);
+		suite.addTestSuite(TestRemoveBand.class);
+		suite.addTestSuite(TestReplicateBand.class);
+		suite.addTestSuite(TestAddBand.class);
+		suite.addTestSuite(TestRWOneValue.class);
+		suite.addTestSuite(TestCreateBand.class);
+		suite.addTestSuite(TestRWTiffAndCompareData.class);
+		suite.addTestSuite(TestSwapBands.class);
+		suite.addTestSuite(TestCopyBand2.class);
+		suite.addTestSuite(TestGetBufferWithOneBand.class);
+		//$JUnit-END$
+		return suite;
+	}
+
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/AllTests.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestGetBufferWithOneBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestGetBufferWithOneBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestGetBufferWithOneBand.java	(revision 3222)
@@ -0,0 +1,113 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.horizontal;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test gets bands from a raster with the method getBufferWithOneBand() and compare
+ * each band from original source with obtained bands 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestGetBufferWithOneBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut1 = "/tmp/out-b1.tif";
+	private String rasterOut2 = "/tmp/out-b2.tif";
+	private String rasterOut3 = "/tmp/out-b3.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestGetBufferWithOneBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf = new RasterCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount());
+			
+			//Set data to buffer
+			setLines(dataIn, buf);
+			
+			Buffer b0 = buf.getBufferWithOneBand(0);
+			Buffer b1 = buf.getBufferWithOneBand(1);
+			Buffer b2 = buf.getBufferWithOneBand(2);
+			
+			//Write output file 
+			GdalWrite out1 = new GdalWrite(rasterOut1, 1, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out1.writeBands(b0.getBands());
+			out1.close();
+			
+			GdalWrite out2 = new GdalWrite(rasterOut2, 1, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out2.writeBands(b1.getBands());
+			out2.close();
+			
+			GdalWrite out3 = new GdalWrite(rasterOut3, 1, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out3.writeBands(b2.getBands());
+			out3.close();
+						
+			for (int row = 0; row < buf.getHeight(); row++) {
+				for (int col = 0; col < buf.getWidth(); col++) {
+					byte b_0 = buf.getElemByte(row, col, 0);
+					byte b_1 = buf.getElemByte(row, col, 1);
+					byte b_2 = buf.getElemByte(row, col, 2);
+					assertEquals(b_0, b0.getElemByte(row, col, 0));
+					assertEquals(b_1, b1.getElemByte(row, col, 0));
+					assertEquals(b_2, b2.getElemByte(row, col, 0));
+				}
+			}
+			
+			b0.free();
+			b1.free();
+			b2.free();
+			buf.free();
+				
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestGetBufferWithOneBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestGetBufferWithOneBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestSwapTwoBands.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestSwapTwoBands.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestSwapTwoBands.java	(revision 3222)
@@ -0,0 +1,124 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.horizontal;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.exception.WrongParameterException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test swap two bands of a raster and save the result in other file.
+ * Finally it compares the output bands with the input bands.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestSwapTwoBands extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-swapedTwo.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestSwapTwoBands running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input1 = null;
+		GdalWrite out = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input1 = new GdalRead(rasterIn);
+			Object dataIn1 = input1.readBlock(0, 0, input1.getWidth(), input1.getHeight());
+						
+			//Create Buffer
+			Buffer buf1 = new RasterCacheBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount());
+			
+			//Set data to buffer
+			setLines(dataIn1, buf1);
+						
+			Buffer buf2 = new RasterCacheBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount());
+
+			//Set data to buffer
+			setLines(dataIn1, buf2);
+			try {
+				buf2.swapBands(0, 2);
+			} catch (WrongParameterException e) {
+				e.printStackTrace();
+			}
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, input1.getBandCount(), input1.getDataType(), input1.getWidth(), input1.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf2.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(0);
+			Band band2 = buf2.getBand(2);
+			compareBands(band1, band2);
+			
+			band1 = buf1.getBand(2);
+			band2 = buf2.getBand(0);
+			compareBands(band1, band2);
+			
+			band1 = buf1.getBand(1);
+			band2 = buf2.getBand(1);
+			compareBands(band1, band2);
+			
+			buf1.free();
+			buf2.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestSwapTwoBands: " + (t2 - t1) + " milisegundos");
+	}
+	
+	public void compareBands(Band band1, Band band2) {
+		for (int i = 0; i < band1.getHeight(); i++) {
+			for (int j = 0; j < band1.getWidth(); j++) {
+				byte b1 = band1.getElemByte(i, j);
+				byte b2 = band2.getElemByte(i, j);
+				assertEquals(b1, b2);
+			}
+		}
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/horizontal/TestSwapTwoBands.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestCachePerformance.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestCachePerformance.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestCachePerformance.java	(revision 3222)
@@ -0,0 +1,112 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+
+/**
+ * Performance Test
+ * Time 9.3 - 10 seg 
+ * REPEAT = 10
+ * Intel(R) Core(TM)2 CPU E8400  @ 3.00GHz
+ * 2GB RAM DDR3 1066
+ * HDD ATA 133
+ * Linux Ubuntu 8.04 kernel 2.6.24
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestCachePerformance extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private static int REPEAT = 10;
+	public int aux = 0;
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestCachePerformance running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			for (int iTimes = 0; iTimes < REPEAT; iTimes++) {
+
+				//Read input data
+				input = new GdalRead(rasterIn);
+				Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+
+				//Create Buffer
+				Buffer buf1 = new RasterVertCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+						input.getWidth(), 
+						input.getHeight(),
+						input.getBandCount());
+
+				//Set data to buffer
+				setBytes(dataIn, buf1);
+				
+				
+				for (int iBand = 0; iBand < buf1.getBandCount(); iBand++) {
+					for (int j = 0; j < buf1.getWidth(); j++) {
+						for (int i = 0; i < buf1.getHeight(); i++) {
+							byte b1 = buf1.getElemByte(i, j, iBand);
+							byte b2 = buf1.getElemByte(i, j, iBand);
+							aux = b1 * b2;
+						}
+					}
+				}
+				
+				buf1.free();
+			}
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestCachePerformance: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setBytes(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+    			for (int col = 0; col < d[iBand][0].length; col++) {
+    				for (int row = 0; row < d[iBand].length; row++) {
+						buf.setElem(row, col, iBand, d[iBand][row][col]);
+					}
+				}
+			}
+    	}
+	}
+	
+//	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+//		if(dataIn instanceof byte[][][]) {
+//    		byte[][][] d = (byte[][][])dataIn;
+//    		for (int iBand = 0; iBand < d.length; iBand++) {
+//				for (int row = 0; row < d[iBand].length; row++) {
+//					buf.setLineInBandByte(d[iBand][row], row, iBand);
+//				}
+//			}
+//    	}
+//	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestCachePerformance.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestRWTiffAndCompareData.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestRWTiffAndCompareData.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestRWTiffAndCompareData.java	(revision 3222)
@@ -0,0 +1,108 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test reads a Tiff from disk with the class TIFFRead and load data in
+ * a cache buffer. Then it saves those bytes in a new out file in the same format.
+ * Finally it compares the input data with the output data to test if there are some
+ * differences.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestRWTiffAndCompareData extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestRWTiffAndCompareData running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf = new RasterVertCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount());
+			
+			//Set data to buffer
+			setValues(dataIn, buf);
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, input.getBandCount(), input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf.getBands());
+			buf.free();
+			out.close();	
+			
+			//Open output file and compare
+			GdalRead newFile = new GdalRead(rasterOut);
+			Object dataOut = newFile.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			byte[][][] d1 = (byte[][][])dataIn;
+			byte[][][] d2 = (byte[][][])dataOut;
+			for (int iBand = 0; iBand < buf.getBandCount(); iBand++) {
+				for (int col = 0; col < buf.getWidth(); col++) {
+					for (int row = 0; row < buf.getHeight(); row++) {
+						if(d1[iBand][row][col] != d2[iBand][row][col])
+							System.out.println("BAND:" + iBand +" ROW:" + row + " COL:" + col + " " + d1[iBand][row][col] + " " + d2[iBand][row][col]);
+						assertEquals(d1[iBand][row][col], d2[iBand][row][col]);
+					}
+				}
+			}
+				
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestRWTiffAndCompareData: " + (t2 - t1) + " milisegundos");
+	}
+	
+	public void setValues(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+			byte[][][] d = (byte[][][])dataIn;
+			for (int band = 0; band < d.length; band++) {
+				for (int col = 0; col < d[band][0].length; col++) {
+					if(col == 2560)
+						System.out.println();
+					for (int row = 0; row < d[band].length; row++) {
+						buf.setElem(row, col, band, (byte)d[band][row][col]);
+					}
+				}
+			}
+		}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestRWTiffAndCompareData.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestRWOneValue.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestRWOneValue.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestRWOneValue.java	(revision 3222)
@@ -0,0 +1,70 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import java.awt.image.DataBuffer;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+
+/**
+ * This test creates a buffer and write a number in each element of each band.
+ * Then, it reads from the buffer the numbers and check it.
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestRWOneValue extends TestCase {
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestRWOneValue running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		
+		//Reducimos el tama�o de la cache para una prueba con menos datos
+		BufferCacheManagerImpl.cacheSize = 2;
+		BufferCacheManagerImpl.pageSize = 0.2;
+		
+		RasterVertCacheBuffer buf = new RasterVertCacheBuffer(DataBuffer.TYPE_BYTE, 2571, 1942, 3);
+		
+		for (int iBand = 0; iBand < buf.getBandCount(); iBand++) {
+			for (int col = 0; col < buf.getWidth(); col++) {
+				for (int row = 0; row < buf.getHeight(); row++) {
+					byte n = (byte)(8 + iBand);
+					byte m = (byte)(34 + iBand);
+					if(row == 1001 && col == 1032)
+						buf.setElem(row, col, iBand, n);
+					else
+						buf.setElem(row, col, iBand, m);			
+				}
+			}
+		}
+		
+		for (int iBand = 0; iBand < buf.getBandCount(); iBand++) {
+			for (int col = 0; col < buf.getWidth(); col++) {
+				for (int row = 0; row < buf.getHeight(); row++) {
+					byte n = buf.getElemByte(row, col, iBand);
+					byte m = (byte)(34 + iBand); 
+					if(n != m)
+						;//System.out.println(n + " " + row + "," + col);
+					else
+						assertEquals(n, m);
+				}
+			}
+		}
+		try {
+			buf.free();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestRWOneValue: " + (t2 - t1) + " milisegundos");
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestRWOneValue.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestCreateBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestCreateBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestCreateBand.java	(revision 3222)
@@ -0,0 +1,102 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+
+/**
+ * This test add a band in a raster of 3 bands. As a result of this test a raster
+ * of four bands is created and saved in the hard disk. The value of additional band
+ * is zero in all its elements. Finally it gets the band added and compare each values 
+ * with 0. 
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestCreateBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestCreateBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf = new RasterVertCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount());
+			
+			//Set data to buffer
+			setBytes(dataIn, buf);
+			Band rb = buf.createBand((byte)100);
+
+			for (int j = 0; j < rb.getWidth(); j++) {
+				for (int i = 0; i < rb.getHeight(); i++) {
+					byte b = rb.getElemByte(i, j);
+					assertEquals((byte)100, b);
+				}
+			}
+			
+			buf.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestCreateBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setBytes(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+    			for (int col = 0; col < d[iBand][0].length; col++) {
+    				for (int row = 0; row < d[iBand].length; row++) {
+						buf.setElem(row, col, iBand, d[iBand][row][col]);
+					}
+				}
+			}
+    	}
+	}
+	
+//	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+//		if(dataIn instanceof byte[][][]) {
+//    		byte[][][] d = (byte[][][])dataIn;
+//    		for (int iBand = 0; iBand < d.length; iBand++) {
+//				for (int row = 0; row < d[iBand].length; row++) {
+//					buf.setLineInBandByte(d[iBand][row], row, iBand);
+//				}
+//			}
+//    	}
+//	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestCreateBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestAssignBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestAssignBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestAssignBand.java	(revision 3222)
@@ -0,0 +1,132 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.BandNotCompatibleException;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestAssignBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-4bands.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestAssignBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input1 = null;
+		GdalRead input2 = null;
+		GdalWrite out = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input1 = new GdalRead(rasterIn);
+			Object dataIn1 = input1.readBlock(0, 0, input1.getWidth(), input1.getHeight());
+			input2 = new GdalRead(rasterIn);
+			Object dataIn2 = input1.readBlock(0, 0, input2.getWidth(), input2.getHeight());
+			
+			//Create Buffer
+			Buffer buf1 = new RasterVertCacheBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount());
+			
+			//Set data to buffer
+			setBytes(dataIn1, buf1);
+			//Create Buffer
+			Buffer buf2 = new RasterVertCacheBuffer(input2.getRasterBufTypeFromGdalType(input2.getDataType()), 
+														input2.getWidth(), 
+														input2.getHeight(),
+														input2.getBandCount());
+			
+			//Set data to buffer
+			setBytes(dataIn2, buf2);
+			
+			Band rb = buf2.getBand(2);
+			try {
+				buf1.assignBand(1, rb);
+			} catch (BandNotCompatibleException e) {
+				e.printStackTrace();
+			}
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 4, input1.getDataType(), input1.getWidth(), input1.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			
+			//TODO: se ha comentarizado pq se para al cerrar las librer�as. Cuando se
+			//retome esta cach� deber�a ponerse en marcha
+			
+			/*out.writeBands(buf1.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(1);
+			Band band2 = buf1.getBand(3);
+			for (int j = 0; j < band1.getWidth(); j++) {
+				for (int i = 0; i < band1.getHeight(); i++) {
+					byte b1 = band1.getElemByte(i, j);
+					byte b2 = band2.getElemByte(i, j);
+					assertEquals(b1, b2);
+				}
+			}
+			
+			buf1.free();
+			buf2.free();*/
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestAssignBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setBytes(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+    			for (int col = 0; col < d[iBand][0].length; col++) {
+    				for (int row = 0; row < d[iBand].length; row++) {
+						buf.setElem(row, col, iBand, d[iBand][row][col]);
+					}
+				}
+			}
+    	}
+	}
+	
+	/*private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}*/
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestAssignBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/AllTests.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/AllTests.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/AllTests.java	(revision 3222)
@@ -0,0 +1,28 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+	public static Test suite() {
+		TestSuite suite = new TestSuite(
+				"Test for org.gvsig.raster.buffer.stripecache");
+		//$JUnit-BEGIN$
+		suite.addTestSuite(TestSwapTwoBands.class);
+		suite.addTestSuite(TestAssignBand.class);
+		suite.addTestSuite(TestCopyBand.class);
+		suite.addTestSuite(TestRemoveBand.class);
+		suite.addTestSuite(TestReplicateBand.class);
+		suite.addTestSuite(TestAddBand.class);
+		suite.addTestSuite(TestRWOneValue.class);
+		suite.addTestSuite(TestCreateBand.class);
+		suite.addTestSuite(TestRWTiffAndCompareData.class);
+		suite.addTestSuite(TestSwapBands.class);
+		suite.addTestSuite(TestCopyBand2.class);
+		suite.addTestSuite(TestGetBufferWithOneBand.class);
+		//$JUnit-END$
+		return suite;
+	}
+
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/AllTests.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestGetBufferWithOneBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestGetBufferWithOneBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestGetBufferWithOneBand.java	(revision 3222)
@@ -0,0 +1,131 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test gets bands from a raster with the method getBufferWithOneBand() and compare
+ * each band from original source with obtained bands 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestGetBufferWithOneBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut1 = "/tmp/out-b1.tif";
+	private String rasterOut2 = "/tmp/out-b2.tif";
+	private String rasterOut3 = "/tmp/out-b3.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestGetBufferWithOneBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf = new RasterVertCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount());
+			
+			//Set data to buffer
+			setBytes(dataIn, buf);
+			
+			Buffer b0 = buf.getBufferWithOneBand(0);
+			Buffer b1 = buf.getBufferWithOneBand(1);
+			Buffer b2 = buf.getBufferWithOneBand(2);
+			
+			//Write output file 
+			GdalWrite out1 = new GdalWrite(rasterOut1, 1, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out1.writeBands(b0.getBands());
+			out1.close();
+			
+			GdalWrite out2 = new GdalWrite(rasterOut2, 1, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out2.writeBands(b1.getBands());
+			out2.close();
+			
+			GdalWrite out3 = new GdalWrite(rasterOut3, 1, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			
+			//TODO: se ha comentarizado pq se para al cerrar las librer�as. Cuando se
+			//retome esta cach� deber�a ponerse en marcha
+			
+			/*out3.writeBands(b2.getBands());
+			out3.close();
+				
+			
+			for (int col = 0; col < buf.getWidth(); col++) {
+				for (int row = 0; row < buf.getHeight(); row++) {
+					byte b_0 = buf.getElemByte(row, col, 0);
+					byte b_1 = buf.getElemByte(row, col, 1);
+					byte b_2 = buf.getElemByte(row, col, 2);
+					assertEquals(b_0, b0.getElemByte(row, col, 0));
+					assertEquals(b_1, b1.getElemByte(row, col, 0));
+					assertEquals(b_2, b2.getElemByte(row, col, 0));
+				}
+			}
+			*/
+			b0.free();
+			b1.free();
+			b2.free();
+			buf.free();
+				
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestGetBufferWithOneBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setBytes(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+    			for (int col = 0; col < d[iBand][0].length; col++) {
+    				for (int row = 0; row < d[iBand].length; row++) {
+						buf.setElem(row, col, iBand, d[iBand][row][col]);
+					}
+				}
+			}
+    	}
+	}
+//	
+//	private void setlines(object datain, buffer buf) throws operationnotsupportedexception {
+//		if(datain instanceof byte[][][]) {
+//    		byte[][][] d = (byte[][][])datain;
+//    		for (int iband = 0; iband < d.length; iband++) {
+//				for (int row = 0; row < d[iband].length; row++) {
+//					buf.setlineinbandbyte(d[iband][row], row, iband);
+//				}
+//			}
+//    	}
+//	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestGetBufferWithOneBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestSwapTwoBands.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestSwapTwoBands.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestSwapTwoBands.java	(revision 3222)
@@ -0,0 +1,126 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.exception.WrongParameterException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test swap two bands of a raster and save the result in other file.
+ * Finally it compares the output bands with the input bands.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestSwapTwoBands extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-swapedTwo.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestSwapTwoBands running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input1 = null;
+		GdalWrite out = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input1 = new GdalRead(rasterIn);
+			Object dataIn1 = input1.readBlock(0, 0, input1.getWidth(), input1.getHeight());
+						
+			//Create Buffer
+			Buffer buf1 = new RasterVertCacheBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount());
+			
+			//Set data to buffer
+			setBytes(dataIn1, buf1);
+						
+			Buffer buf2 = new RasterVertCacheBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount());
+
+			//Set data to buffer
+			setBytes(dataIn1, buf2);
+			try {
+				buf2.swapBands(0, 2);
+			} catch (WrongParameterException e) {
+				e.printStackTrace();
+			}
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, input1.getBandCount(), input1.getDataType(), input1.getWidth(), input1.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf2.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(0);
+			Band band2 = buf2.getBand(2);
+			compareBands(band1, band2);
+			
+			band1 = buf1.getBand(2);
+			band2 = buf2.getBand(0);
+			compareBands(band1, band2);
+			
+			band1 = buf1.getBand(1);
+			band2 = buf2.getBand(1);
+			compareBands(band1, band2);
+			
+			buf1.free();
+			buf2.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestSwapTwoBands: " + (t2 - t1) + " milisegundos");
+	}
+	
+	public void compareBands(Band band1, Band band2) {
+		for (int j = 0; j < band1.getWidth(); j++) {
+			for (int i = 0; i < band1.getHeight(); i++) {
+				byte b1 = band1.getElemByte(i, j);
+				byte b2 = band2.getElemByte(i, j);
+				assertEquals(b1, b2);
+			}
+		}
+	}
+	
+	private void setBytes(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+    			for (int col = 0; col < d[iBand][0].length; col++) {
+    				for (int row = 0; row < d[iBand].length; row++) {
+						buf.setElem(row, col, iBand, d[iBand][row][col]);
+					}
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestSwapTwoBands.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestAddBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestAddBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestAddBand.java	(revision 3222)
@@ -0,0 +1,111 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test add a band in a raster of 3 bands. As a result of this test a raster
+ * of four bands is created and saved in the hard disk. The value of additional band
+ * is zero in all its elements. Finally it gets the band added and compare each values 
+ * with 0. 
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestAddBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-4bands.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestAddBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf = new RasterVertCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount());
+			
+			//Set data to buffer
+			setBytes(dataIn, buf);
+			buf.addBand(1);
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 4, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out.writeBands(buf.getBands());
+			out.close();	
+			
+			Band band = buf.getBand(1);
+			for (int j = 0; j < band.getWidth(); j++) {
+				for (int i = 0; i < band.getHeight(); i++) {
+					byte b = band.getElemByte(i, j);
+					assertEquals(0, b);
+				}
+			}
+			
+			buf.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestAddBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setBytes(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+    			for (int col = 0; col < d[iBand][0].length; col++) {
+    				for (int row = 0; row < d[iBand].length; row++) {
+						buf.setElem(row, col, iBand, d[iBand][row][col]);
+					}
+				}
+			}
+    	}
+	}
+	
+//	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+//		if(dataIn instanceof byte[][][]) {
+//    		byte[][][] d = (byte[][][])dataIn;
+//    		for (int iBand = 0; iBand < d.length; iBand++) {
+//				for (int row = 0; row < d[iBand].length; row++) {
+//					buf.setLineInBandByte(d[iBand][row], row, iBand);
+//				}
+//			}
+//    	}
+//	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestAddBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestReplicateBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestReplicateBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestReplicateBand.java	(revision 3222)
@@ -0,0 +1,116 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/** 
+ * This test insert one band at the end of the layer. The data of this new band is a copy 
+ * of the band in position zero. Finally data of band zero and band three are compared
+ * checking if both have the same values. 
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestReplicateBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-replicateBands.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestReplicateBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input1 = null;
+		GdalWrite out = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input1 = new GdalRead(rasterIn);
+			Object dataIn1 = input1.readBlock(0, 0, input1.getWidth(), input1.getHeight());
+			
+			//Create Buffer
+			Buffer buf1 = new RasterVertCacheBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount());
+			
+			//Set data to buffer
+			setBytes(dataIn1, buf1);
+						
+			buf1.replicateBand(0, 3);
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 4, input1.getDataType(), input1.getWidth(), input1.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			
+			//TODO: se ha comentado pq se para al cerrar las librer�as. Cuando se
+			//retome esta cach� deber�a ponerse en marcha
+			/*out.writeBands(buf1.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(0);
+			Band band2 = buf1.getBand(3);
+			for (int j = 0; j < band1.getWidth(); j++) {
+				for (int i = 0; i < band1.getHeight(); i++) {
+					byte b1 = band1.getElemByte(i, j);
+					byte b2 = band2.getElemByte(i, j);
+					assertEquals(b1, b2);
+				}
+			}
+			
+			buf1.free();*/
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestReplicateBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setBytes(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+    			for (int col = 0; col < d[iBand][0].length; col++) {
+    				for (int row = 0; row < d[iBand].length; row++) {
+						buf.setElem(row, col, iBand, d[iBand][row][col]);
+					}
+				}
+			}
+    	}
+	}
+	
+//	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {  
+//		if(dataIn instanceof byte[][][]) {
+//    		byte[][][] d = (byte[][][])dataIn;
+//    		for (int iBand = 0; iBand < d.length; iBand++) {
+//				for (int row = 0; row < d[iBand].length; row++) {
+//					buf.setLineInBandByte(d[iBand][row], row, iBand);
+//				}
+//			}
+//    	}
+//	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestReplicateBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestCopyBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestCopyBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestCopyBand.java	(revision 3222)
@@ -0,0 +1,120 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.BandNotCompatibleException;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * Copy the band 0 from a buffer over the band 2 in the same buffer using the
+ * method getBandCopy.  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestCopyBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-copyFirstBand.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestCopyBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf1 = new RasterVertCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount());
+			
+			//Set data to buffer
+			setBytes(dataIn, buf1);
+			
+			//TODO: se ha comentado pq se para al cerrar las librer�as. Cuando se
+			//retome esta cach� deber�a ponerse en marcha
+			/*Band rb = buf1.getBandCopy(0);
+			
+			try {
+				buf1.copyBand(2, rb);
+			} catch (BandNotCompatibleException e) {
+				e.printStackTrace();
+			}
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 3, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf1.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(0);
+			Band band2 = buf1.getBand(2);
+			for (int j = 0; j < band1.getWidth(); j++) {
+				for (int i = 0; i < band1.getHeight(); i++) {
+					byte b1 = band1.getElemByte(i, j);
+					byte b2 = band2.getElemByte(i, j);
+					assertEquals(b1, b2);
+				}
+			}
+			
+			buf1.free();*/
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestCopyBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setBytes(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+    			for (int col = 0; col < d[iBand][0].length; col++) {
+    				for (int row = 0; row < d[iBand].length; row++) {
+						buf.setElem(row, col, iBand, d[iBand][row][col]);
+					}
+				}
+			}
+    	}
+	}
+	
+//	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+//		if(dataIn instanceof byte[][][]) {
+//    		byte[][][] d = (byte[][][])dataIn;
+//    		for (int iBand = 0; iBand < d.length; iBand++) {
+//				for (int row = 0; row < d[iBand].length; row++) {
+//					buf.setLineInBandByte(d[iBand][row], row, iBand);
+//				}
+//			}
+//    	}
+//	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestCopyBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestCopyBand2.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestCopyBand2.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestCopyBand2.java	(revision 3222)
@@ -0,0 +1,130 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.BandNotCompatibleException;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * Copy the band 0 from a buffer over the band 2 of other buffer using the
+ * method getBand (reference).
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestCopyBand2 extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-copyFirstBand.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestCopyBand2 running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf1 = new RasterVertCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount());
+			
+			//Set data to buffer
+			setBytes(dataIn, buf1);
+			
+			//Create Buffer
+			Buffer buf2 = new RasterVertCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount());
+			
+			//Set data to buffer
+			setBytes(dataIn, buf2);
+			
+			//TODO: se ha comentado pq se para al cerrar las librer�as. Cuando se
+			//retome esta cach� deber�a ponerse en marcha
+			/*Band rb = buf1.getBand(0);
+			
+			try {
+				buf2.copyBand(2, rb);
+			} catch (BandNotCompatibleException e) {
+				e.printStackTrace();
+			}
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 3, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf2.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(0);
+			Band band2 = buf2.getBand(2);
+			for (int j = 0; j < band1.getWidth(); j++) {
+				for (int i = 0; i < band1.getHeight(); i++) {
+					byte b1 = band1.getElemByte(i, j);
+					byte b2 = band2.getElemByte(i, j);
+					assertEquals(b1, b2);
+				}
+			}
+			
+			buf1.free();
+			buf2.free();*/
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestCopyBand2: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setBytes(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+    			for (int col = 0; col < d[iBand][0].length; col++) {
+    				for (int row = 0; row < d[iBand].length; row++) {
+						buf.setElem(row, col, iBand, d[iBand][row][col]);
+					}
+				}
+			}
+    	}
+	}
+	
+//	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+//		if(dataIn instanceof byte[][][]) {
+//    		byte[][][] d = (byte[][][])dataIn;
+//    		for (int iBand = 0; iBand < d.length; iBand++) {
+//				for (int row = 0; row < d[iBand].length; row++) {
+//					buf.setLineInBandByte(d[iBand][row], row, iBand);
+//				}
+//			}
+//    	}
+//	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestCopyBand2.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestRemoveBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestRemoveBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestRemoveBand.java	(revision 3222)
@@ -0,0 +1,124 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test read a RGB image and remove one band from the read buffer. Then compare 
+ * the bands that have not been removed with the source bands. As a result of this test a raster
+ * of two bands is created and saved in the hard disk
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestRemoveBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-2bands.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestRemoveBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf = new RasterVertCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount());
+			
+			//Set data to buffer
+			setBytes(dataIn, buf);
+			buf.removeBand(1);
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 2, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out.writeBands(buf.getBands());
+			buf.free();
+			out.close();	
+			
+			//Open output file and compare
+			GdalRead newFile = new GdalRead(rasterOut);
+			Object dataOut = newFile.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			byte[][][] d1 = (byte[][][])dataOut;
+			byte[][][] d2 = (byte[][][])dataIn;
+			
+			for (int row = 0; row < buf.getHeight(); row++) {
+				for (int col = 0; col < buf.getWidth(); col++) {
+					if(d1[0][row][col] != d2[0][row][col])
+						System.out.println("BAND:" + 0 +" ROW:" + row + " COL:" + col + " " + d1[0][row][col] + " " + d2[0][row][col]);
+					assertEquals(d1[0][row][col], d2[0][row][col]);
+				}
+			}
+				
+			for (int row = 0; row < buf.getHeight(); row++) {
+				for (int col = 0; col < buf.getWidth(); col++) {
+					if(d1[1][row][col] != d2[2][row][col])
+						System.out.println("BAND:" + 1 +" ROW:" + row + " COL:" + col + " " + d1[1][row][col] + " " + d2[2][row][col]);
+					assertEquals(d1[1][row][col], d2[2][row][col]);
+				}
+			}
+			
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestRemoveBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setBytes(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+    			for (int col = 0; col < d[iBand][0].length; col++) {
+    				for (int row = 0; row < d[iBand].length; row++) {
+						buf.setElem(row, col, iBand, d[iBand][row][col]);
+					}
+				}
+			}
+    	}
+	}
+	
+//	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+//		if(dataIn instanceof byte[][][]) {
+//    		byte[][][] d = (byte[][][])dataIn;
+//    		for (int iBand = 0; iBand < d.length; iBand++) {
+//				for (int row = 0; row < d[iBand].length; row++) {
+//					buf.setLineInBandByte(d[iBand][row], row, iBand);
+//				}
+//			}
+//    	}
+//	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestRemoveBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestSwapBands.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestSwapBands.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestSwapBands.java	(revision 3222)
@@ -0,0 +1,141 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.exception.WrongParameterException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test swap several bands of a raster and save the result in other file.
+ * Finally it compares the output bands with the input bands.
+ * <P>
+ * The array to test is {2, 0, 1}. That means the band 0 goes to the position two, the
+ * band one goes to the position zero and the band two goes to the position one. 
+ * When the swap operation is executed, this test will check comparing the result 
+ * bands with the input bands 
+ * </P>
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestSwapBands extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-swaped.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("StripeCache TestSwapBands running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input1 = null;
+		GdalWrite out = null;
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			//Read input data
+			input1 = new GdalRead(rasterIn);
+			Object dataIn1 = input1.readBlock(0, 0, input1.getWidth(), input1.getHeight());
+						
+			//Create Buffer
+			Buffer buf1 = new RasterVertCacheBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount());
+			
+			//Set data to buffer
+			setBytes(dataIn1, buf1);
+						
+			Buffer buf2 = new RasterVertCacheBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount());
+
+			//Set data to buffer
+			setBytes(dataIn1, buf2);
+			try {
+				buf2.swapBands(new int[]{2, 0, 1});
+			} catch (WrongParameterException e) {
+				e.printStackTrace();
+			}
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, input1.getBandCount(), input1.getDataType(), input1.getWidth(), input1.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf2.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(0);
+			Band band2 = buf2.getBand(1);
+			compareBands(band1, band2);
+			
+			band1 = buf1.getBand(1);
+			band2 = buf2.getBand(2);
+			compareBands(band1, band2);
+			
+			band1 = buf1.getBand(2);
+			band2 = buf2.getBand(0);
+			compareBands(band1, band2);
+			
+			buf1.free();
+			buf2.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo StripeCache TestSwapBands: " + (t2 - t1) + " milisegundos");
+	}
+	
+	public void compareBands(Band band1, Band band2) {
+		for (int j = 0; j < band1.getWidth(); j++) {
+			for (int i = 0; i < band1.getHeight(); i++) {
+				byte b1 = band1.getElemByte(i, j);
+				byte b2 = band2.getElemByte(i, j);
+				assertEquals(b1, b2);
+			}
+		}
+	}
+	
+	private void setBytes(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+    			for (int col = 0; col < d[iBand][0].length; col++) {
+    				for (int row = 0; row < d[iBand].length; row++) {
+						buf.setElem(row, col, iBand, d[iBand][row][col]);
+					}
+				}
+			}
+    	}
+	}
+//	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+//		if(dataIn instanceof byte[][][]) {
+//    		byte[][][] d = (byte[][][])dataIn;
+//    		for (int iBand = 0; iBand < d.length; iBand++) {
+//				for (int row = 0; row < d[iBand].length; row++) {
+//					buf.setLineInBandByte(d[iBand][row], row, iBand);
+//				}
+//			}
+//    	}
+//	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/stripecache/vertical/TestSwapBands.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationBSplineIncrease.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationBSplineIncrease.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationBSplineIncrease.java	(revision 3222)
@@ -0,0 +1,86 @@
+package org.gvsig.raster.cache.buffer.impl;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer;
+
+/**
+ * Copy the band 0 from a buffer over the band 2 in the same buffer using the
+ * method getBandCopy.  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestInterpolationBSplineIncrease extends TestCase {
+	private String         rasterIn  = "./src/test/resources/image/001m09_1_0.tif";
+	private String         rasterOut = "/tmp/out-interpBSpline.tif";
+	private static int     REL       = 2;
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("TestInterpolationBSpline running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			//Read input data
+			input = new GdalRead(rasterIn);
+			int readSize = 10;
+			Object dataIn = input.readBlock(0, 0, readSize, readSize);
+			
+			//Create Buffer
+			Buffer buf1 = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														readSize, 
+														readSize,
+														input.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			setLines(dataIn, buf1);
+			Buffer buf = buf1.getAdjustedWindow(readSize * REL, readSize * REL, BufferInterpolationImpl.INTERPOLATION_BSpline);
+						
+			//Write output file 
+			out = new GdalWrite(rasterOut, 3, input.getDataType(), buf.getWidth(), buf.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf.getBands());
+			out.close();	
+			
+			buf1.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo TestInterpolationBSpline: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}
+

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationBSplineIncrease.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationBSplineReduction.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationBSplineReduction.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationBSplineReduction.java	(revision 3222)
@@ -0,0 +1,85 @@
+package org.gvsig.raster.cache.buffer.impl;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer;
+
+/**
+ * Copy the band 0 from a buffer over the band 2 in the same buffer using the
+ * method getBandCopy.  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestInterpolationBSplineReduction extends TestCase {
+	private String         rasterIn  = "./src/test/resources/image/001m09_1_0.tif";
+	private String         rasterOut = "/tmp/out-interpBSplineReduction.tif";
+	private static int     REL       = 5;
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("TestInterpolationBSplineReduction running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+						
+			//Create Buffer
+			Buffer buf1 = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			setLines(dataIn, buf1);
+			Buffer buf = buf1.getAdjustedWindow(input.getWidth() / REL, input.getHeight() / REL, BufferInterpolationImpl.INTERPOLATION_BSpline);
+						
+			//Write output file 
+			out = new GdalWrite(rasterOut, 3, input.getDataType(), buf.getWidth(), buf.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf.getBands());
+			out.close();	
+			
+			buf1.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo TestInterpolationBSplineReduction: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}
+

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationBSplineReduction.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationBicubicIncrease.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationBicubicIncrease.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationBicubicIncrease.java	(revision 3222)
@@ -0,0 +1,86 @@
+package org.gvsig.raster.cache.buffer.impl;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer;
+
+/**
+ * Copy the band 0 from a buffer over the band 2 in the same buffer using the
+ * method getBandCopy.  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestInterpolationBicubicIncrease extends TestCase {
+	private String         rasterIn  = "./src/test/resources/image/001m09_1_0.tif";
+	private String         rasterOut = "/tmp/out-interpBicubic.tif";
+	private static int     REL       = 2;
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("TestInterpolationBicubic running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			//Read input data
+			input = new GdalRead(rasterIn);
+			int readSize = 10;
+			Object dataIn = input.readBlock(0, 0, readSize, readSize);
+			
+			//Create Buffer
+			Buffer buf1 = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														readSize, 
+														readSize,
+														input.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			setLines(dataIn, buf1);
+			Buffer buf = buf1.getAdjustedWindow(readSize * REL, readSize * REL, BufferInterpolationImpl.INTERPOLATION_Bicubic);
+						
+			//Write output file 
+			out = new GdalWrite(rasterOut, 3, input.getDataType(), buf.getWidth(), buf.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf.getBands());
+			out.close();	
+			
+			buf1.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo TestInterpolationBicubic: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}
+

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationBicubicIncrease.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationNearestIncrease.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationNearestIncrease.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationNearestIncrease.java	(revision 3222)
@@ -0,0 +1,86 @@
+package org.gvsig.raster.cache.buffer.impl;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer;
+
+/**
+ * Copy the band 0 from a buffer over the band 2 in the same buffer using the
+ * method getBandCopy.  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestInterpolationNearestIncrease extends TestCase {
+	private String         rasterIn  = "./src/test/resources/image/001m09_1_0.tif";
+	private String         rasterOut = "/tmp/out-interpNearest.tif";
+	private static int     REL       = 2;
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("MemoryBuffer TestCopyBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			//Read input data
+			input = new GdalRead(rasterIn);
+			int readSize = 10;
+			Object dataIn = input.readBlock(0, 0, readSize, readSize);
+						
+			//Create Buffer
+			Buffer buf1 = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														readSize, 
+														readSize,
+														input.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			setLines(dataIn, buf1);
+			Buffer buf = buf1.getAdjustedWindow(readSize * REL, readSize * REL, BufferInterpolationImpl.INTERPOLATION_NearestNeighbour);
+						
+			//Write output file 
+			out = new GdalWrite(rasterOut, 3, input.getDataType(), buf.getWidth(), buf.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf.getBands());
+			out.close();	
+			
+			buf1.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo MemoryBuffer TestCopyBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}
+

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationNearestIncrease.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/others/ArrayVsArrayList.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/others/ArrayVsArrayList.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/others/ArrayVsArrayList.java	(revision 3222)
@@ -0,0 +1,70 @@
+package org.gvsig.raster.cache.buffer.impl.others;
+
+import java.util.ArrayList;
+
+import org.gvsig.raster.cache.buffer.PxTile;
+import org.gvsig.raster.cache.buffer.impl.PxTileImpl;
+import org.gvsig.raster.cache.buffer.impl.rocache.ByteBand;
+import org.gvsig.raster.cache.buffer.impl.rocache.ReadOnlyCacheBand;
+
+/**
+ * This test compare the access time of an element in two cases. The first
+ * case is the access to an element in a simple array of objects. The second
+ * case is the access to an element in an ArrayList.
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ *
+ */
+public class ArrayVsArrayList {
+	public static int N = 500000;
+	/**
+	 * @param args
+	 */
+	public static void main(String[] args) {
+		ArrayVsArrayList p = new ArrayVsArrayList();
+		p.array();
+		p.arrayList();
+	}
+	
+	private void array() {
+		long t1 = System.currentTimeMillis();
+		ArrayList<PxTile> stripeList = new ArrayList<PxTile>();
+		for (int i = 0; i < 1; i++) 
+			stripeList.add(new PxTileImpl(0, 0, 0, 0));
+		
+		ReadOnlyCacheBand[] l = new ReadOnlyCacheBand[N];
+		for (int i = 0; i < N; i++) {
+			ByteBand b =  new ByteBand(stripeList, null, 15, 15, 15, 2345, 3244);
+			l[i] = b;
+		}
+		int z = 0;
+		for (int i = 0; i < N; i++) {
+			int y = l[i].getBandNumber();
+			z += y;
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Time Array with " + N + " elements: " + (t2 - t1) + " milisegundos" + z);
+		
+	}
+	
+	private void arrayList() {
+		long t1 = System.currentTimeMillis();
+		ArrayList<PxTile> stripeList = new ArrayList<PxTile>();
+		for (int i = 0; i < 1; i++) 
+			stripeList.add(new PxTileImpl(0, 0, 0, 0));
+		
+		ArrayList<ReadOnlyCacheBand> l = new ArrayList<ReadOnlyCacheBand>();
+		for (int i = 0; i < N; i++) {
+			ByteBand b =  new ByteBand(stripeList, null, 15, 15, 15, 2345, 3244);
+			l.add(b);
+		}
+		int z = 0;
+		for (int i = 0; i < N; i++) {
+			int y = l.get(i).getBandNumber();
+			z += y;
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Time ArrayList with " + N + " elements: " + (t2 - t1) + " milisegundos" + z);
+	}
+
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/others/ArrayVsArrayList.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/others/TestCacheVsMemory.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/others/TestCacheVsMemory.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/others/TestCacheVsMemory.java	(revision 3222)
@@ -0,0 +1,151 @@
+package org.gvsig.raster.cache.buffer.impl.others;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer;
+import org.gvsig.raster.cache.buffer.impl.stripecache.horizontal.RasterCacheBuffer;
+
+/**
+ * Performance Test: It loads a complete image of 65MB in a cached buffer and after read the
+ * same image in a memory buffer. For this test we use a small size of cache (2MB) and a size of
+ * one page of 0.2MB
+ *  
+ * REPEAT = 1
+ * Using setValues
+ * Time cached: 1538 ms
+ * Time memory: 1163 ms
+ * 
+ * REPEAT = 1
+ * Using setLines
+ * Time cached: 198 ms
+ * Time memory: 171 ms
+ *
+ * REPEAT = 10
+ * Using setValues
+ * Time cached: 14317 ms
+ * Time memory: 11168 ms
+ * 
+ * REPEAT = 10
+ * Using setLines
+ * Time cached: 1944 ms
+ * Time memory: 1209 ms
+ * 
+ * Intel(R) Core(TM)2 CPU E8400  @ 3.00GHz
+ * 2GB RAM DDR3 1066
+ * HDD ATA 133
+ * Linux Ubuntu 10.04 kernel 2.6.24
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestCacheVsMemory extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private static int REPEAT = 10;
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("CacheVsMemory running...");
+	}
+	
+	public void testStack() {
+		
+		try {
+			GdalRead input = null;
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 25;
+			BufferCacheManagerImpl.pageSize = 2;
+		
+			//****************CACHE**********************
+			long t1 = System.currentTimeMillis();
+			for (int iTimes = 0; iTimes < REPEAT; iTimes++) {
+
+				//Create Buffer
+				Buffer buf1 = new RasterCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+						input.getWidth(), 
+						input.getHeight(),
+						input.getBandCount());
+
+				//Set data to buffer
+				setValues(dataIn, buf1);
+				buf1.free();
+			}
+			
+			long t2 = System.currentTimeMillis();
+			System.out.println("Tiempo StripeCache : " + (t2 - t1) + " milisegundos");
+			//****************FIN CACHE******************
+			
+			//****************MEMO***********************
+			t1 = System.currentTimeMillis();
+			for (int iTimes = 0; iTimes < REPEAT; iTimes++) {
+
+				//Create Buffer
+				Buffer buf2 = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+						input.getWidth(), 
+						input.getHeight(),
+						input.getBandCount(),
+						true);
+
+				//Set data to buffer
+				setValues(dataIn, buf2);
+				buf2.free();
+			}
+			
+			t2 = System.currentTimeMillis();
+			System.out.println("Tiempo Memoria : " + (t2 - t1) + " milisegundos");
+			//****************FIN MEMO******************
+			
+			input.close();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		
+		
+	}
+	
+	public void setValues(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int band = 0; band < d.length; band++) {
+				for (int row = 0; row < d[band].length; row++) {
+					for (int col = 0; col < d[band][row].length; col++) {
+						buf.setElem(row, col, band, (byte)d[band][row][col]);
+					}
+				}
+			}
+    	}
+	}
+	
+	public void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/others/TestCacheVsMemory.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestReadWindowAndCompareData.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestReadWindowAndCompareData.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestReadWindowAndCompareData.java	(revision 3222)
@@ -0,0 +1,112 @@
+package org.gvsig.raster.cache.buffer.impl.rocache;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferParam;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.BufferParamImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer;
+
+/**
+ * Read a number from cache
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestReadWindowAndCompareData extends TestCase {
+	private String in = "./src/test/resources/image/001m09_1_0.tif";
+	private int    initX  = 200;
+	private int    initY  = 200;
+	private int    w      = 400;
+	private int    h      = 400;
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("ROCache TestReadTiffAndCompareData running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		
+		BufferCacheManagerImpl.cacheSize = 1;
+		BufferCacheManagerImpl.pageSize = 0.2;
+		
+		Buffer buf1 = null;
+		try {
+			input = new GdalRead(in);
+
+			Object dataIn = input.readBlock(initX, initY, w, h);
+
+			//Create Buffer
+			buf1 = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+											w, 
+											h,
+											input.getBandCount(),
+											true);
+
+			//Set data to buffer
+			setLines(dataIn, buf1);
+		} catch (GdalException e1) {
+			e1.printStackTrace();
+		} catch (IOException e1) {
+			e1.printStackTrace();
+		} catch (ProcessInterruptedException e1) {
+			e1.printStackTrace();
+		} catch (OperationNotSupportedException e1) {
+			e1.printStackTrace();
+		}
+		
+		RasterReadOnlyBuffer buf = null;
+		try {
+			BufferParam p = new BufferParamImpl(in, initX, initY, w, h, new int[]{0, 1, 2});
+			buf = new RasterReadOnlyBuffer(p);
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		
+				
+		for (int iBand = 0; iBand < buf.getBandCount(); iBand++) {
+			for (int row = 0; row < buf.getHeight(); row++) {
+				for (int col = 0; col < buf.getWidth(); col++) {
+					byte n = buf.getElemByte(row, col, iBand);
+					byte m = buf1.getElemByte(row, col, iBand);
+					if(n != m)
+						System.out.println(row + " " + col);
+					assertEquals(n, m);
+				}
+			}
+		}
+		
+		try {
+			buf.free();
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo ROCache TestRWOneValue: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestReadWindowAndCompareData.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestWindow.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestWindow.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestWindow.java	(revision 3222)
@@ -0,0 +1,107 @@
+package org.gvsig.raster.cache.buffer.impl.rocache;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.PxTileImpl;
+import org.gvsig.raster.cache.buffer.impl.io.BufferDataSourceImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer;
+
+/** 
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestWindow extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/window.tif";
+	private String compare = "./src/test/resources/image/clip_test_robufer.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("ROCache TestWindow running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalWrite output = null;
+		try {
+			
+			BufferDataSource ds = null;
+			try {
+				ds = new BufferDataSourceImpl(rasterIn, new PxTileImpl(100, 100, 500, 400));
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+			Buffer buf = new RasterReadOnlyBuffer(ds);
+			
+			GdalRead input1 = new GdalRead(compare);
+			output = new GdalWrite(rasterOut, 3, input1.getGdalTypeFromRasterBufType(ds.getDataType()), ds.getWidth(), ds.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			output.writeBands(buf.getBands());
+			output.close();
+			
+			//Read input data
+			
+			Object dataIn = input1.readBlock(0, 0, input1.getWidth(), input1.getHeight());
+			
+			//Create Buffer
+			Buffer buf1 = new RasterMemoryBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			setLines(dataIn, buf1);
+			for (int i = 0; i < buf.getBandCount(); i++) 
+				compareBands(buf.getBand(i), buf.getBand(i));
+			
+			buf.free();
+			buf1.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo ROCache TestWindow: " + (t2 - t1) + " milisegundos");
+	}
+	
+	
+	public void compareBands(Band band1, Band band2) {
+		for (int i = 0; i < band1.getHeight(); i++) {
+			for (int j = 0; j < band1.getWidth(); j++) {
+				byte b1 = band1.getElemByte(i, j);
+				byte b2 = band2.getElemByte(i, j);
+				assertEquals(b1, b2);
+			}
+		}
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestWindow.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestReadTiffAndCompareData.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestReadTiffAndCompareData.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestReadTiffAndCompareData.java	(revision 3222)
@@ -0,0 +1,108 @@
+package org.gvsig.raster.cache.buffer.impl.rocache;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.BufferDataSourceImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer;
+
+/**
+ * Read a number from cache
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestReadTiffAndCompareData extends TestCase {
+	private String in = "./src/test/resources/image/001m09_1_0.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("ROCache TestReadTiffAndCompareData running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		
+		BufferCacheManagerImpl.cacheSize = 1;
+		BufferCacheManagerImpl.pageSize = 0.2;
+		
+		Buffer buf1 = null;
+		try {
+			input = new GdalRead(in);
+
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+
+			//Create Buffer
+			buf1 = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+											input.getWidth(), 
+											input.getHeight(),
+											input.getBandCount(),
+											true);
+
+			//Set data to buffer
+			setLines(dataIn, buf1);
+		} catch (GdalException e1) {
+			e1.printStackTrace();
+		} catch (IOException e1) {
+			e1.printStackTrace();
+		} catch (ProcessInterruptedException e1) {
+			e1.printStackTrace();
+		} catch (OperationNotSupportedException e1) {
+			e1.printStackTrace();
+		}
+		
+		
+		BufferDataSource ds = null;
+		try {
+			ds = new BufferDataSourceImpl(in);
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		RasterReadOnlyBuffer buf = new RasterReadOnlyBuffer(ds);
+				
+		for (int iBand = 0; iBand < buf.getBandCount(); iBand++) {
+			for (int row = 0; row < buf.getHeight(); row++) {
+				for (int col = 0; col < buf.getWidth(); col++) {
+					byte n = buf.getElemByte(row, col, iBand);
+					byte m = buf1.getElemByte(row, col, iBand);
+					if(n != m)
+						System.out.println(row + " " + col);
+					assertEquals(n, m);
+				}
+			}
+		}
+		
+		try {
+			buf.free();
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo ROCache TestRWOneValue: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestReadTiffAndCompareData.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestAssignBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestAssignBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestAssignBand.java	(revision 3222)
@@ -0,0 +1,91 @@
+package org.gvsig.raster.cache.buffer.impl.rocache;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.exception.BandNotCompatibleException;
+import org.gvsig.raster.cache.buffer.impl.io.BufferDataSourceImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * Assign by reference a band in a Buffer
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestAssignBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-4bands.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("ROCache TestAssignBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input1 = null;
+
+		GdalWrite out = null;
+		try {
+						
+			//Read input data
+			input1 = new GdalRead(rasterIn);
+						
+			BufferDataSource ds = null;
+			try {
+				ds = new BufferDataSourceImpl(rasterIn);
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+			Buffer buf1 = new RasterReadOnlyBuffer(ds);
+			
+			BufferDataSource ds1 = null;
+			try {
+				ds1 = new BufferDataSourceImpl(rasterIn);
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+			Buffer buf2 = new RasterReadOnlyBuffer(ds1);
+			
+			Band rb = buf2.getBand(2);
+			try {
+				buf1.assignBand(1, rb);
+			} catch (BandNotCompatibleException e) {
+				e.printStackTrace();
+			}
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 4, input1.getDataType(), input1.getWidth(), input1.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out.writeBands(buf1.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(1);
+			Band band2 = buf1.getBand(3);
+			for (int i = 0; i < band1.getHeight(); i++) {
+				for (int j = 0; j < band1.getWidth(); j++) {
+					byte b1 = band1.getElemByte(i, j);
+					byte b2 = band2.getElemByte(i, j);
+					assertEquals(b1, b2);
+				}
+			}
+			
+			buf1.free();
+			buf2.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo ROCache TestAssignBand: " + (t2 - t1) + " milisegundos");
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestAssignBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestMultifile.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestMultifile.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestMultifile.java	(revision 3222)
@@ -0,0 +1,105 @@
+package org.gvsig.raster.cache.buffer.impl.rocache;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.BufferParam;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.impl.BufferParamImpl;
+import org.gvsig.raster.cache.buffer.impl.io.BufferDataSourceImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test gets bands from a raster with the method getBufferWithOneBand() and compare
+ * each band from original source with obtained bands 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestMultifile extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut1 = "/tmp/out-b1.tif";
+	private String rasterOut2 = "/tmp/out-b2.tif";
+	private String rasterOut3 = "/tmp/out-b3.tif";
+	private int    x      = 200;
+	private int    y      = 200;
+	private int    w      = 800;
+	private int    h      = 800;
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("ROCache TestGetBufferWithOneBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		try {
+			//Read input data
+			input = new GdalRead(rasterIn);
+			
+			BufferDataSource ds = null;
+			try {
+				ds = new BufferDataSourceImpl(rasterIn);
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+			Buffer buf = new RasterReadOnlyBuffer(ds);
+						
+			Buffer b0 = buf.getBufferWithOneBand(0);
+			Buffer b1 = buf.getBufferWithOneBand(1);
+			Buffer b2 = buf.getBufferWithOneBand(2);
+			
+			//Write output file 
+			GdalWrite out1 = new GdalWrite(rasterOut1, 1, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out1.writeBands(b0.getBands());
+			out1.close();
+			
+			GdalWrite out2 = new GdalWrite(rasterOut2, 1, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out2.writeBands(b1.getBands());
+			out2.close();
+			
+			GdalWrite out3 = new GdalWrite(rasterOut3, 1, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out3.writeBands(b2.getBands());
+			out3.close();
+			
+			BufferParam params = new BufferParamImpl(
+					new String[]{rasterOut1, rasterOut2, rasterOut3}, 
+					x, y, w, h, null);
+			RasterReadOnlyBuffer multiband = new RasterReadOnlyBuffer(params);
+						
+			for (int row = 0; row < multiband.getHeight(); row++) {
+				for (int col = 0; col < multiband.getWidth(); col++) {
+					byte b_0 = multiband.getElemByte(row, col, 0);
+					byte b_1 = multiband.getElemByte(row, col, 1);
+					byte b_2 = multiband.getElemByte(row, col, 2);
+					assertEquals(b_0, b0.getElemByte(row + y, col + x, 0));
+					assertEquals(b_1, b1.getElemByte(row + y, col + x, 0));
+					assertEquals(b_2, b2.getElemByte(row + y, col + x, 0));
+				}
+			}
+						
+			b0.free();
+			b1.free();
+			b2.free();
+			buf.free();
+				
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo ROCache TestGetBufferWithOneBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestMultifile.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/AllTests.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/AllTests.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/AllTests.java	(revision 3222)
@@ -0,0 +1,26 @@
+package org.gvsig.raster.cache.buffer.impl.rocache;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+	public static Test suite() {
+		TestSuite suite = new TestSuite("Test for org.fv.raster.buffer.rocache");
+		//$JUnit-BEGIN$
+		suite.addTestSuite(TestReplicateBand.class);
+		suite.addTestSuite(TestSwapBands.class);
+		suite.addTestSuite(TestReadTiffAndCompareData.class);
+		suite.addTestSuite(TestSwapTwoBands.class);
+		suite.addTestSuite(TestRemoveBand.class);
+		suite.addTestSuite(TestGetBufferWithOneBand.class);
+		suite.addTestSuite(TestReadWindowAndCompareData.class);
+		suite.addTestSuite(TestAssignBand.class);
+		suite.addTestSuite(TestCopyBand.class);
+		suite.addTestSuite(TestAddBand.class);
+		suite.addTestSuite(TestWindow.class);
+		//$JUnit-END$
+		return suite;
+	}
+
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/AllTests.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestGetBufferWithOneBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestGetBufferWithOneBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestGetBufferWithOneBand.java	(revision 3222)
@@ -0,0 +1,94 @@
+package org.gvsig.raster.cache.buffer.impl.rocache;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.impl.io.BufferDataSourceImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test gets bands from a raster with the method getBufferWithOneBand() and compare
+ * each band from original source with obtained bands 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestGetBufferWithOneBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut1 = "/tmp/out-b1.tif";
+	private String rasterOut2 = "/tmp/out-b2.tif";
+	private String rasterOut3 = "/tmp/out-b3.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("ROCache TestGetBufferWithOneBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		try {
+			//Read input data
+			input = new GdalRead(rasterIn);
+			
+			BufferDataSource ds = null;
+			try {
+				ds = new BufferDataSourceImpl(rasterIn);
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+			Buffer buf = new RasterReadOnlyBuffer(ds);
+						
+			Buffer b0 = buf.getBufferWithOneBand(0);
+			Buffer b1 = buf.getBufferWithOneBand(1);
+			Buffer b2 = buf.getBufferWithOneBand(2);
+			
+			//Write output file 
+			GdalWrite out1 = new GdalWrite(rasterOut1, 1, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out1.writeBands(b0.getBands());
+			out1.close();
+			
+			GdalWrite out2 = new GdalWrite(rasterOut2, 1, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out2.writeBands(b1.getBands());
+			out2.close();
+			
+			GdalWrite out3 = new GdalWrite(rasterOut3, 1, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out3.writeBands(b2.getBands());
+			out3.close();
+			
+			for (int row = 0; row < buf.getHeight(); row++) {
+				for (int col = 0; col < buf.getWidth(); col++) {
+					byte b_0 = buf.getElemByte(row, col, 0);
+					byte b_1 = buf.getElemByte(row, col, 1);
+					byte b_2 = buf.getElemByte(row, col, 2);
+					assertEquals(b_0, b0.getElemByte(row, col, 0));
+					assertEquals(b_1, b1.getElemByte(row, col, 0));
+					assertEquals(b_2, b2.getElemByte(row, col, 0));
+				}
+			}
+			
+			b0.free();
+			b1.free();
+			b2.free();
+			buf.free();
+				
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo ROCache TestGetBufferWithOneBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestGetBufferWithOneBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestSwapTwoBands.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestSwapTwoBands.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestSwapTwoBands.java	(revision 3222)
@@ -0,0 +1,88 @@
+package org.gvsig.raster.cache.buffer.impl.rocache;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.exception.WrongParameterException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.io.BufferDataSourceImpl;
+
+/**
+ * This test swap two bands of a raster and save the result in other file.
+ * Finally it compares the output bands with the input bands.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestSwapTwoBands extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("ROCache TestSwapTwoBands running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		try {
+			//Reducimos el tama�o de la cache para una prueba con menos datos
+			BufferCacheManagerImpl.cacheSize = 2;
+			BufferCacheManagerImpl.pageSize = 0.2;
+			
+			BufferDataSource ds = null;
+			try {
+				ds = new BufferDataSourceImpl(rasterIn);
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+						
+			//Create Buffer
+			Buffer buf1 = new RasterReadOnlyBuffer(ds);
+
+			Buffer buf2 = new RasterReadOnlyBuffer(ds);
+
+			try {
+				buf2.swapBands(0, 2);
+			} catch (WrongParameterException e) {
+				e.printStackTrace();
+			}
+			
+			Band band1 = buf1.getBand(0);
+			Band band2 = buf2.getBand(2);
+			compareBands(band1, band2);
+			
+			band1 = buf1.getBand(2);
+			band2 = buf2.getBand(0);
+			compareBands(band1, band2);
+			
+			band1 = buf1.getBand(1);
+			band2 = buf2.getBand(1);
+			compareBands(band1, band2);
+			
+			buf1.free();
+			buf2.free();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo ROCache TestSwapTwoBands: " + (t2 - t1) + " milisegundos");
+	}
+	
+	public void compareBands(Band band1, Band band2) {
+		for (int i = 0; i < band1.getHeight(); i++) {
+			for (int j = 0; j < band1.getWidth(); j++) {
+				byte b1 = band1.getElemByte(i, j);
+				byte b2 = band2.getElemByte(i, j);
+				assertEquals(b1, b2);
+			}
+		}
+	}
+		
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestSwapTwoBands.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestAddBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestAddBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestAddBand.java	(revision 3222)
@@ -0,0 +1,61 @@
+package org.gvsig.raster.cache.buffer.impl.rocache;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.impl.io.BufferDataSourceImpl;
+
+/**
+ * This test add a band in a raster of 3 bands. As a result of this test a raster
+ * of four bands is created and saved in the hard disk. The value of additional band
+ * is zero in all its elements. Finally it gets the band added and compare each values 
+ * with 0. 
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestAddBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("ROCache TestAddBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		try {
+			//Read input data
+			
+			BufferDataSource ds = null;
+			try {
+				ds = new BufferDataSourceImpl(rasterIn);
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+			Buffer buf = new RasterReadOnlyBuffer(ds);
+			buf.addBand(1);
+						
+			Band band = buf.getBand(1);
+			for (int i = 0; i < band.getHeight(); i++) {
+				for (int j = 0; j < band.getWidth(); j++) {
+					byte b = band.getElemByte(i, j);
+					assertEquals(0, b);
+				}
+			}
+			
+			buf.free();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo ROCache TestAddBand: " + (t2 - t1) + " milisegundos");
+	}	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestAddBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestReplicateBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestReplicateBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestReplicateBand.java	(revision 3222)
@@ -0,0 +1,78 @@
+package org.gvsig.raster.cache.buffer.impl.rocache;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.impl.io.BufferDataSourceImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/** 
+ * This test insert one band at the end of the layer. The data of this new band is a copy 
+ * of the band in position zero. Finally data of band zero and band three are compared
+ * checking if both have the same values. 
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestReplicateBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-replicateBands.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("ROCache TestReplicateBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input1 = null;
+		GdalWrite out = null;
+		try {
+						
+			//Read input data
+			input1 = new GdalRead(rasterIn);
+			BufferDataSource ds = null;
+			try {
+				ds = new BufferDataSourceImpl(rasterIn);
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+			Buffer buf = new RasterReadOnlyBuffer(ds);
+						
+			buf.replicateBand(0, 3);
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 4, input1.getDataType(), input1.getWidth(), input1.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out.writeBands(buf.getBands());
+			out.close();	
+			
+			Band band1 = buf.getBand(0);
+			Band band2 = buf.getBand(3);
+			for (int i = 0; i < band1.getHeight(); i++) {
+				for (int j = 0; j < band1.getWidth(); j++) {
+					byte b1 = band1.getElemByte(i, j);
+					byte b2 = band2.getElemByte(i, j);
+					assertEquals(b1, b2);
+				}
+			}
+			
+			buf.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo ROCache TestReplicateBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestReplicateBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestCopyBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestCopyBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestCopyBand.java	(revision 3222)
@@ -0,0 +1,60 @@
+package org.gvsig.raster.cache.buffer.impl.rocache;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.impl.io.BufferDataSourceImpl;
+
+/**
+ * Copy the band 0 from a buffer over the band 2 in the same buffer using the
+ * method getBandCopy.  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestCopyBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("ROCache TestCopyBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+
+		try {			
+			BufferDataSource ds = null;
+			try {
+				ds = new BufferDataSourceImpl(rasterIn);
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+			Buffer buf = new RasterReadOnlyBuffer(ds);
+			
+			Band rb = buf.getBandCopy(0);
+						
+			Band band1 = buf.getBand(0);
+			for (int i = 0; i < band1.getHeight(); i++) {
+				for (int j = 0; j < band1.getWidth(); j++) {
+					byte b1 = band1.getElemByte(i, j);
+					byte b2 = rb.getElemByte(i, j);
+					assertEquals(b1, b2);
+				}
+			}
+			
+			buf.free();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo ROCache TestCopyBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestCopyBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestRemoveBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestRemoveBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestRemoveBand.java	(revision 3222)
@@ -0,0 +1,105 @@
+package org.gvsig.raster.cache.buffer.impl.rocache;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.io.BufferDataSourceImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer;
+
+/**
+ * This test read a RGB image and remove one band from the read buffer. Then compare 
+ * the bands that have not been removed with the source bands. As a result of this test a raster
+ * of two bands is created and saved in the hard disk
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestRemoveBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("ROCache TestRemoveBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		try {
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+
+			//Create Buffer
+			Buffer buf1 = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+					input.getWidth(), 
+					input.getHeight(),
+					input.getBandCount(),
+					true);
+
+			//Set data to buffer
+			setLines(dataIn, buf1);
+
+			BufferDataSource ds = null;
+			try {
+				ds = new BufferDataSourceImpl(rasterIn);
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+			Buffer buf2 = new RasterReadOnlyBuffer(ds);
+
+			//Remove bands
+			buf2.removeBand(1);
+			buf1.removeBand(1);
+			compareIRasterBuffer(buf1, buf2);
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo ROCache TestRemoveBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+	public void compareIRasterBuffer(Buffer b1, Buffer b2) {
+		for (int iBand = 0; iBand < b1.getBandCount(); iBand++) {
+			
+		for (int i = 0; i < b1.getHeight(); i++) {
+			for (int j = 0; j < b1.getWidth(); j++) {
+				byte b = b1.getElemByte(i, j, iBand);
+				byte c = b2.getElemByte(i, j, iBand);
+				if(b != c)
+					System.out.println("B:" + iBand + "" + i + " " + j);
+				assertEquals(c, b);
+			}
+		}
+		
+		}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestRemoveBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestSwapBands.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestSwapBands.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestSwapBands.java	(revision 3222)
@@ -0,0 +1,125 @@
+package org.gvsig.raster.cache.buffer.impl.rocache;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.exception.WrongParameterException;
+import org.gvsig.raster.cache.buffer.impl.io.BufferDataSourceImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer;
+
+/**
+ * This test swap several bands of a raster compare the result with a memory buffer
+ * swaped.
+ * <P>
+ * The array to test is {2, 0, 1}. That means the band 0 goes to the position two, the
+ * band one goes to the position zero and the band two goes to the position one. 
+ * When the swap operation is executed, this test will check comparing the result 
+ * bands with the input bands 
+ * </P>
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestSwapBands extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("ROCache TestSwapBands running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input1 = null;
+		try {
+			//Read input data
+			input1 = new GdalRead(rasterIn);
+			Object dataIn1 = input1.readBlock(0, 0, input1.getWidth(), input1.getHeight());
+
+			//Create Buffer						
+			Buffer buf2 = new RasterMemoryBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+					input1.getWidth(), 
+					input1.getHeight(),
+					input1.getBandCount(),
+					true);
+
+			//Set data to buffer
+			setLines(dataIn1, buf2);
+
+			BufferDataSource ds = null;
+			try {
+				ds = new BufferDataSourceImpl(rasterIn);
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+			RasterReadOnlyBuffer buf1 = new RasterReadOnlyBuffer(ds);
+			try {
+				buf2.swapBands(new int[]{2, 0, 1});
+				buf1.swapBands(new int[]{2, 0, 1});
+			} catch (WrongParameterException e) {
+				e.printStackTrace();
+			}
+			
+			//Write output file 
+						
+			Band band1 = buf1.getBand(0);
+			Band band2 = buf2.getBand(0);
+			compareBands(band1, band2);
+			
+			band1 = buf1.getBand(1);
+			band2 = buf2.getBand(1);
+			compareBands(band1, band2);
+			
+			band1 = buf1.getBand(2);
+			band2 = buf2.getBand(2);
+			compareBands(band1, band2);
+			
+			buf1.free();
+			buf2.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo ROCache TestSwapBands: " + (t2 - t1) + " milisegundos");
+	}
+	
+	public void compareBands(Band band1, Band band2) {
+		for (int i = 0; i < band1.getHeight(); i++) {
+			for (int j = 0; j < band1.getWidth(); j++) {
+				byte b1 = band1.getElemByte(i, j);
+				byte b2 = band2.getElemByte(i, j);
+				if(b1 != b2)
+					System.out.println(i + " " + j);
+				assertEquals(b1, b2);
+			}
+		}
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/rocache/TestSwapBands.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationBicubicReduction.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationBicubicReduction.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationBicubicReduction.java	(revision 3222)
@@ -0,0 +1,85 @@
+package org.gvsig.raster.cache.buffer.impl;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer;
+
+/**
+ * Copy the band 0 from a buffer over the band 2 in the same buffer using the
+ * method getBandCopy.  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestInterpolationBicubicReduction extends TestCase {
+	private String         rasterIn  = "./src/test/resources/image/001m09_1_0.tif";
+	private String         rasterOut = "/tmp/out-interpBicubicReduction.tif";
+	private static int     REL       = 5;
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("TestInterpolationBicubicReduction running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+						
+			//Create Buffer
+			Buffer buf1 = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			setLines(dataIn, buf1);
+			Buffer buf = buf1.getAdjustedWindow(input.getWidth() / REL, input.getHeight() / REL, BufferInterpolationImpl.INTERPOLATION_Bicubic);
+						
+			//Write output file 
+			out = new GdalWrite(rasterOut, 3, input.getDataType(), buf.getWidth(), buf.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf.getBands());
+			out.close();	
+			
+			buf1.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo TestInterpolationBicubicReduction: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}
+

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationBicubicReduction.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationNearestReduction.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationNearestReduction.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationNearestReduction.java	(revision 3222)
@@ -0,0 +1,85 @@
+package org.gvsig.raster.cache.buffer.impl;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer;
+
+/**
+ * Copy the band 0 from a buffer over the band 2 in the same buffer using the
+ * method getBandCopy.  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestInterpolationNearestReduction extends TestCase {
+	private String         rasterIn  = "./src/test/resources/image/001m09_1_0.tif";
+	private String         rasterOut = "/tmp/out-interpNearestReduction.tif";
+	private static int     REL       = 5;
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("TestInterpolationNearestReduction running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+						
+			//Create Buffer
+			Buffer buf1 = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			setLines(dataIn, buf1);
+			Buffer buf = buf1.getAdjustedWindow(input.getWidth() / REL, input.getHeight() / REL, BufferInterpolationImpl.INTERPOLATION_NearestNeighbour);
+						
+			//Write output file 
+			out = new GdalWrite(rasterOut, 3, input.getDataType(), buf.getWidth(), buf.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf.getBands());
+			out.close();	
+			
+			buf1.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo TestInterpolationNearestReduction: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}
+

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationNearestReduction.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/io/TRWTIFFFullDataBuffer.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/io/TRWTIFFFullDataBuffer.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/io/TRWTIFFFullDataBuffer.java	(revision 3222)
@@ -0,0 +1,50 @@
+package org.gvsig.raster.cache.buffer.impl.io;
+import java.io.IOException;
+
+import org.gvsig.jgdal.GdalException;
+
+/**
+ * Common use of TIFFRead and TIFFWrite class for read and save full data buffers.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TRWTIFFFullDataBuffer {
+	
+	private String rasterOut = "/tmp/out.tif";
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	//private String rasterIn = "/home/nacho/images1/MultiplesFicheros/ComunidadValenciana/p198r033_7t20010601_z31_nn10.tif";
+	public static void main(String[] args) {
+		TRWTIFFFullDataBuffer t = new TRWTIFFFullDataBuffer();
+		t.save();
+	}
+	
+	public void save() {
+		long t1 = System.currentTimeMillis();
+		
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			input = new GdalRead(rasterIn);
+			Object data = input.readData(0, 0, input.getWidth(), input.getHeight());
+			
+			out = new GdalWrite(rasterOut, input.getBandCount(), input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			
+			if(data instanceof byte[][]) {
+				byte[][] d = (byte[][])data;
+				out.writeByteBands(d);
+				out.close();
+			}
+				
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (InterruptedException e) {
+			e.printStackTrace();
+		}
+	
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo: " + (t2 - t1) + " milisegundos");
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/io/TRWTIFFFullDataBuffer.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestCopyBand2.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestCopyBand2.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestCopyBand2.java	(revision 3222)
@@ -0,0 +1,112 @@
+package org.gvsig.raster.cache.buffer.impl.memory;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.BandNotCompatibleException;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+import org.gvsig.raster.cache.buffer.impl.stripecache.horizontal.RasterCacheBuffer;
+
+/**
+ * Copy the band 0 from a buffer over the band 2 of other buffer using the
+ * method getBand (reference).
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestCopyBand2 extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-copyFirstBand.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("MemoryBuffer TestCopyBand2 running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf1 = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			setLines(dataIn, buf1);
+			
+			//Create Buffer
+			Buffer buf2 = new RasterCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount());
+			
+			//Set data to buffer
+			setLines(dataIn, buf2);
+			
+			Band rb = buf1.getBand(0);
+			
+			try {
+				buf2.copyBand(2, rb);
+			} catch (BandNotCompatibleException e) {
+				e.printStackTrace();
+			}
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 3, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf2.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(0);
+			Band band2 = buf2.getBand(2);
+			for (int i = 0; i < band1.getHeight(); i++) {
+				for (int j = 0; j < band1.getWidth(); j++) {
+					byte b1 = band1.getElemByte(i, j);
+					byte b2 = band2.getElemByte(i, j);
+					assertEquals(b1, b2);
+				}
+			}
+			
+			buf1.free();
+			buf2.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo MemoryBuffer TestCopyBand2: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestCopyBand2.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestMemoryBuffer.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestMemoryBuffer.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestMemoryBuffer.java	(revision 3222)
@@ -0,0 +1,70 @@
+package org.gvsig.raster.cache.buffer.impl.memory;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestMemoryBuffer extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("MemoryBuffer TestMemoryBuffer running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			input = new GdalRead(rasterIn);
+			Object data = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			Buffer buf = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount(),
+														true);
+			
+			if(data instanceof byte[][][]) {
+	    		byte[][][] d = (byte[][][])data;
+	    		for (int i = 0; i < d.length; i++) {
+					for (int j = 0; j < d[i].length; j++) {
+						buf.setLineInBandByte(d[i][j], j, i);
+					}
+				}
+	    	}
+			out = new GdalWrite(rasterOut, input.getBandCount(), input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf.getBands());
+			out.close();	
+				
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo MemoryBuffer TestMemoryBuffer: " + (t2 - t1) + " milisegundos");
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestMemoryBuffer.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestRemoveBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestRemoveBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestRemoveBand.java	(revision 3222)
@@ -0,0 +1,107 @@
+package org.gvsig.raster.cache.buffer.impl.memory;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test read a RGB image and remove one band from the read buffer. Then compare 
+ * the bands that have not been removed with the source bands. As a result of this test a raster
+ * of two bands is created and saved in the hard disk
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestRemoveBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-2bands.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("MemoryBuffer TestRemoveBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			setLines(dataIn, buf);
+			buf.removeBand(1);
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 2, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out.writeBands(buf.getBands());
+			buf.free();
+			out.close();	
+			
+			//Open output file and compare
+			GdalRead newFile = new GdalRead(rasterOut);
+			Object dataOut = newFile.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			byte[][][] d1 = (byte[][][])dataOut;
+			byte[][][] d2 = (byte[][][])dataIn;
+			
+			for (int row = 0; row < buf.getHeight(); row++) {
+				for (int col = 0; col < buf.getWidth(); col++) {
+					if(d1[0][row][col] != d2[0][row][col])
+						System.out.println("BAND:" + 0 +" ROW:" + row + " COL:" + col + " " + d1[0][row][col] + " " + d2[0][row][col]);
+					assertEquals(d1[0][row][col], d2[0][row][col]);
+				}
+			}
+				
+			for (int row = 0; row < buf.getHeight(); row++) {
+				for (int col = 0; col < buf.getWidth(); col++) {
+					if(d1[1][row][col] != d2[2][row][col])
+						System.out.println("BAND:" + 1 +" ROW:" + row + " COL:" + col + " " + d1[1][row][col] + " " + d2[2][row][col]);
+					assertEquals(d1[1][row][col], d2[2][row][col]);
+				}
+			}
+			
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo MemoryBuffer TestRemoveBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestRemoveBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestSwapBands.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestSwapBands.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestSwapBands.java	(revision 3222)
@@ -0,0 +1,139 @@
+package org.gvsig.raster.cache.buffer.impl.memory;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.exception.WrongParameterException;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test swap several bands of a raster and save the result in other file.
+ * Finally it compares the output bands with the input bands.
+ * <P>
+ * The array to test is {2, 0, 1}. That means the band 0 goes to the position two, the
+ * band one goes to the position zero and the band two goes to the position one. 
+ * When the swap operation is executed, this test will check comparing the result 
+ * bands with the input bands 
+ * </P>
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestSwapBands extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-swaped.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("MemoryBuffer TestSwapBands running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input1 = null;
+		GdalWrite out = null;
+		try {
+			//Read input data
+			input1 = new GdalRead(rasterIn);
+			Object dataIn1 = input1.readBlock(0, 0, input1.getWidth(), input1.getHeight());
+						
+			//Create Buffer
+			Buffer buf1 = new RasterMemoryBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			setBytes(dataIn1, buf1);
+						
+			Buffer buf2 = new RasterMemoryBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount(),
+														true);
+
+			//Set data to buffer
+			setBytes(dataIn1, buf2);
+			try {
+				buf2.swapBands(new int[]{2, 0, 1});
+			} catch (WrongParameterException e) {
+				e.printStackTrace();
+			}
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, input1.getBandCount(), input1.getDataType(), input1.getWidth(), input1.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf2.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(0);
+			Band band2 = buf2.getBand(1);
+			compareBands(band1, band2);
+			
+			band1 = buf1.getBand(1);
+			band2 = buf2.getBand(2);
+			compareBands(band1, band2);
+			
+			band1 = buf1.getBand(2);
+			band2 = buf2.getBand(0);
+			compareBands(band1, band2);
+			
+			buf1.free();
+			buf2.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo MemoryBuffer TestSwapBands: " + (t2 - t1) + " milisegundos");
+	}
+	
+	public void compareBands(Band band1, Band band2) {
+		for (int i = 0; i < band1.getHeight(); i++) {
+			for (int j = 0; j < band1.getWidth(); j++) {
+				byte b1 = band1.getElemByte(i, j);
+				byte b2 = band2.getElemByte(i, j);
+				assertEquals(b1, b2);
+			}
+		}
+	}
+	
+//	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+//		if(dataIn instanceof byte[][][]) {
+//    		byte[][][] d = (byte[][][])dataIn;
+//    		for (int iBand = 0; iBand < d.length; iBand++) {
+//				for (int row = 0; row < d[iBand].length; row++) {
+//					buf.setLineInBandByte(d[iBand][row], row, iBand);
+//				}
+//			}
+//    	}
+//	}
+	
+	private void setBytes(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+    			for (int row = 0; row < d[iBand].length; row++) {
+    				for (int col = 0; col < d[iBand][0].length; col++) {
+						buf.setElem(row, col, iBand, d[iBand][row][col]);
+					}
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestSwapBands.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestRWTiffAndCompareData.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestRWTiffAndCompareData.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestRWTiffAndCompareData.java	(revision 3222)
@@ -0,0 +1,96 @@
+package org.gvsig.raster.cache.buffer.impl.memory;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test reads a Tiff from disk with the class TIFFRead and load data in
+ * a memory buffer. Then it saves those bytes in a new out file in the same format.
+ * Finally it compares the intput data with the output data to test if there are some
+ * diferences.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestRWTiffAndCompareData extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("MemoryBuffer TestRWTiffAndCompareData running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			if(dataIn instanceof byte[][][]) {
+	    		byte[][][] d = (byte[][][])dataIn;
+	    		for (int i = 0; i < d.length; i++) {
+					for (int j = 0; j < d[i].length; j++) {
+						buf.setLineInBandByte(d[i][j], j, i);
+					}
+				}
+	    	}
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, input.getBandCount(), input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf.getBands());
+			out.close();	
+			
+			//Open output file and compare
+			GdalRead newFile = new GdalRead(rasterOut);
+			Object dataOut = newFile.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			byte[][][] d1 = (byte[][][])dataIn;
+			byte[][][] d2 = (byte[][][])dataOut;
+			for (int iBand = 0; iBand < buf.getBandCount(); iBand++) {
+				for (int row = 0; row < buf.getHeight(); row++) {
+					for (int col = 0; col < buf.getWidth(); col++) {
+						if(d1[iBand][row][col] != d2[iBand][row][col])
+							System.out.println("BAND:" + iBand +" ROW:" + row + " COL:" + col + " " + d1[iBand][row][col] + " " + d2[iBand][row][col]);
+						assertEquals(d1[iBand][row][col], d2[iBand][row][col]);
+					}
+				}
+			}
+				
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo MemoryBuffer TestRWTiffAndCompareData: " + (t2 - t1) + " milisegundos");
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestRWTiffAndCompareData.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestRWOneValue.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestRWOneValue.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestRWOneValue.java	(revision 3222)
@@ -0,0 +1,65 @@
+package org.gvsig.raster.cache.buffer.impl.memory;
+
+import java.awt.image.DataBuffer;
+
+import junit.framework.TestCase;
+
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer;
+
+/**
+ * Escribe y lee un n�mero en la cache
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestRWOneValue extends TestCase {
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("MemoryBuffer TestRWOneValue running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		
+		BufferCacheManagerImpl.cacheSize = 1;
+		BufferCacheManagerImpl.pageSize = 0.2;
+		
+		RasterMemoryBuffer buf = new RasterMemoryBuffer(DataBuffer.TYPE_BYTE, 2571, 1942, 3, true);
+		
+		for (int iBand = 0; iBand < buf.getBandCount(); iBand++) {
+			for (int row = 0; row < buf.getHeight(); row++) {
+				for (int col = 0; col < buf.getWidth(); col++) {
+					byte n = (byte)(8 + iBand);
+					byte m = (byte)(34 + iBand);
+					if(row == 1001 && col == 1032)
+						buf.setElem(row, col, iBand, n);
+					else
+						buf.setElem(row, col, iBand, m);			
+				}
+			}
+		}
+		
+		for (int iBand = 0; iBand < buf.getBandCount(); iBand++) {
+			for (int row = 0; row < buf.getHeight(); row++) {
+				for (int col = 0; col < buf.getWidth(); col++) {
+					byte n = buf.getElemByte(row, col, iBand);
+					byte m = (byte)(34 + iBand); 
+					if(n != m)
+						;//System.out.println(n + " " + row + "," + col);
+					else
+						assertEquals(n, m);
+				}
+			}
+		}
+		
+		buf.free();
+		
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo MemoryBuffer TestRWOneValue: " + (t2 - t1) + " milisegundos");
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestRWOneValue.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestCreateBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestCreateBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestCreateBand.java	(revision 3222)
@@ -0,0 +1,85 @@
+package org.gvsig.raster.cache.buffer.impl.memory;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+
+/**
+ * This test add a band in a raster of 3 bands. As a result of this test a raster
+ * of four bands is created and saved in the hard disk. The value of additional band
+ * is zero in all its elements. Finally it gets the band added and compare each values 
+ * with 0. 
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestCreateBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("MemoryBuffer TestCreateBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		try {
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			setLines(dataIn, buf);
+			Band rb = buf.createBand((byte)100);
+
+			for (int i = 0; i < rb.getHeight(); i++) {
+				for (int j = 0; j < rb.getWidth(); j++) {
+					byte b = rb.getElemByte(i, j);
+					assertEquals((byte)100, b);
+				}
+			}
+			
+			buf.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo MemoryBuffer TestCreateBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestCreateBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestAssignBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestAssignBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestAssignBand.java	(revision 3222)
@@ -0,0 +1,112 @@
+package org.gvsig.raster.cache.buffer.impl.memory;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.BandNotCompatibleException;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestAssignBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-4bands.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("MemoryBuffer TestAssignBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input1 = null;
+		GdalRead input2 = null;
+		GdalWrite out = null;
+		try {
+			//Read input data
+			input1 = new GdalRead(rasterIn);
+			Object dataIn1 = input1.readBlock(0, 0, input1.getWidth(), input1.getHeight());
+			input2 = new GdalRead(rasterIn);
+			Object dataIn2 = input1.readBlock(0, 0, input2.getWidth(), input2.getHeight());
+			
+			//Create Buffer
+			Buffer buf1 = new RasterMemoryBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			setLines(dataIn1, buf1);
+			//Create Buffer
+			Buffer buf2 = new RasterMemoryBuffer(input2.getRasterBufTypeFromGdalType(input2.getDataType()), 
+														input2.getWidth(), 
+														input2.getHeight(),
+														input2.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			setLines(dataIn2, buf2);
+			
+			Band rb = buf2.getBand(2);
+			try {
+				buf1.assignBand(1, rb);
+			} catch (BandNotCompatibleException e) {
+				e.printStackTrace();
+			}
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 4, input1.getDataType(), input1.getWidth(), input1.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out.writeBands(buf1.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(1);
+			Band band2 = buf1.getBand(3);
+			for (int i = 0; i < band1.getHeight(); i++) {
+				for (int j = 0; j < band1.getWidth(); j++) {
+					byte b1 = band1.getElemByte(i, j);
+					byte b2 = band2.getElemByte(i, j);
+					assertEquals(b1, b2);
+				}
+			}
+			
+			buf1.free();
+			buf2.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		}  catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo MemoryBuffer TestAssignBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestAssignBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/AllTests.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/AllTests.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/AllTests.java	(revision 3222)
@@ -0,0 +1,29 @@
+package org.gvsig.raster.cache.buffer.impl.memory;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+	public static Test suite() {
+		TestSuite suite = new TestSuite(
+				"Test for org.gvsig.raster.buffer.memory");
+		//$JUnit-BEGIN$
+		suite.addTestSuite(TestSwapBands.class);
+		suite.addTestSuite(TestMemoryBuffer.class);
+		suite.addTestSuite(TestRemoveBand.class);
+		suite.addTestSuite(TestAddBand.class);
+		suite.addTestSuite(TestSwapTwoBands.class);
+		suite.addTestSuite(TestCopyBand.class);
+		suite.addTestSuite(TestGetBufferWithOneBand.class);
+		suite.addTestSuite(TestReplicateBand.class);
+		suite.addTestSuite(TestRWOneValue.class);
+		suite.addTestSuite(TestCopyBand2.class);
+		suite.addTestSuite(TestCreateBand.class);
+		suite.addTestSuite(TestAssignBand.class);
+		suite.addTestSuite(TestRWTiffAndCompareData.class);
+		//$JUnit-END$
+		return suite;
+	}
+
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/AllTests.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestGetBufferWithOneBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestGetBufferWithOneBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestGetBufferWithOneBand.java	(revision 3222)
@@ -0,0 +1,109 @@
+package org.gvsig.raster.cache.buffer.impl.memory;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test gets bands from a raster with the method getBufferWithOneBand() and compare
+ * each band from original source with obtained bands 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestGetBufferWithOneBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut1 = "/tmp/out-b1.tif";
+	private String rasterOut2 = "/tmp/out-b2.tif";
+	private String rasterOut3 = "/tmp/out-b3.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("MemoryBuffer TestGetBufferWithOneBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		try {
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			setLines(dataIn, buf);
+			
+			Buffer b0 = buf.getBufferWithOneBand(0);
+			Buffer b1 = buf.getBufferWithOneBand(1);
+			Buffer b2 = buf.getBufferWithOneBand(2);
+			
+			//Write output file 
+			GdalWrite out1 = new GdalWrite(rasterOut1, 1, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out1.writeBands(b0.getBands());
+			out1.close();
+			
+			GdalWrite out2 = new GdalWrite(rasterOut2, 1, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out2.writeBands(b1.getBands());
+			out2.close();
+			
+			GdalWrite out3 = new GdalWrite(rasterOut3, 1, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out3.writeBands(b2.getBands());
+			out3.close();
+						
+			for (int row = 0; row < buf.getHeight(); row++) {
+				for (int col = 0; col < buf.getWidth(); col++) {
+					byte b_0 = buf.getElemByte(row, col, 0);
+					byte b_1 = buf.getElemByte(row, col, 1);
+					byte b_2 = buf.getElemByte(row, col, 2);
+					assertEquals(b_0, b0.getElemByte(row, col, 0));
+					assertEquals(b_1, b1.getElemByte(row, col, 0));
+					assertEquals(b_2, b2.getElemByte(row, col, 0));
+				}
+			}
+			
+			b0.free();
+			b1.free();
+			b2.free();
+			buf.free();
+				
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo MemoryBuffer TestGetBufferWithOneBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestGetBufferWithOneBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestSwapTwoBands.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestSwapTwoBands.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestSwapTwoBands.java	(revision 3222)
@@ -0,0 +1,121 @@
+package org.gvsig.raster.cache.buffer.impl.memory;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.exception.WrongParameterException;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test swap two bands of a raster and save the result in other file.
+ * Finally it compares the output bands with the input bands.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestSwapTwoBands extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-swapedTwo.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("MemoryBuffer TestSwapTwoBands running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input1 = null;
+		GdalWrite out = null;
+		try {
+			//Read input data
+			input1 = new GdalRead(rasterIn);
+			Object dataIn1 = input1.readBlock(0, 0, input1.getWidth(), input1.getHeight());
+						
+			//Create Buffer
+			Buffer buf1 = new RasterMemoryBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			setLines(dataIn1, buf1);
+						
+			Buffer buf2 = new RasterMemoryBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount(),
+														true);
+
+			//Set data to buffer
+			setLines(dataIn1, buf2);
+			try {
+				buf2.swapBands(0, 2);
+			} catch (WrongParameterException e) {
+				e.printStackTrace();
+			}
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, input1.getBandCount(), input1.getDataType(), input1.getWidth(), input1.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf2.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(0);
+			Band band2 = buf2.getBand(2);
+			compareBands(band1, band2);
+			
+			band1 = buf1.getBand(2);
+			band2 = buf2.getBand(0);
+			compareBands(band1, band2);
+			
+			band1 = buf1.getBand(1);
+			band2 = buf2.getBand(1);
+			compareBands(band1, band2);
+			
+			buf1.free();
+			buf2.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo MemoryBuffer TestSwapTwoBands: " + (t2 - t1) + " milisegundos");
+	}
+	
+	public void compareBands(Band band1, Band band2) {
+		for (int i = 0; i < band1.getHeight(); i++) {
+			for (int j = 0; j < band1.getWidth(); j++) {
+				byte b1 = band1.getElemByte(i, j);
+				byte b2 = band2.getElemByte(i, j);
+				assertEquals(b1, b2);
+			}
+		}
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestSwapTwoBands.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestAddBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestAddBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestAddBand.java	(revision 3222)
@@ -0,0 +1,95 @@
+package org.gvsig.raster.cache.buffer.impl.memory;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * This test add a band in a raster of 3 bands. As a result of this test a raster
+ * of four bands is created and saved in the hard disk. The value of additional band
+ * is zero in all its elements. Finally it gets the band added and compare each values 
+ * with 0. 
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestAddBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-4bands.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("MemoryBuffer TestAddBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+	
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			setLines(dataIn, buf);
+			buf.addBand(1);
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 4, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out.writeBands(buf.getBands());
+			out.close();	
+			
+			Band band = buf.getBand(1);
+			for (int i = 0; i < band.getHeight(); i++) {
+				for (int j = 0; j < band.getWidth(); j++) {
+					byte b = band.getElemByte(i, j);
+					assertEquals(0, b);
+				}
+			}
+			
+			buf.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		}  catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo MemoryBuffer TestAddBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestAddBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestReplicateBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestReplicateBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestReplicateBand.java	(revision 3222)
@@ -0,0 +1,96 @@
+package org.gvsig.raster.cache.buffer.impl.memory;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/** 
+ * This test insert one band at the end of the layer. The data of this new band is a copy 
+ * of the band in position zero. Finally data of band zero and band three are compared
+ * checking if both have the same values. 
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestReplicateBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-replicateBands.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("MemoryBuffer TestReplicateBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input1 = null;
+		GdalWrite out = null;
+		try {
+			//Read input data
+			input1 = new GdalRead(rasterIn);
+			Object dataIn1 = input1.readBlock(0, 0, input1.getWidth(), input1.getHeight());
+			
+			//Create Buffer
+			Buffer buf1 = new RasterMemoryBuffer(input1.getRasterBufTypeFromGdalType(input1.getDataType()), 
+														input1.getWidth(), 
+														input1.getHeight(),
+														input1.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			setLines(dataIn1, buf1);
+						
+			buf1.replicateBand(0, 3);
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 4, input1.getDataType(), input1.getWidth(), input1.getHeight(), GdalWrite.COLOR_INTERP_GRAY);
+			out.writeBands(buf1.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(0);
+			Band band2 = buf1.getBand(3);
+			for (int i = 0; i < band1.getHeight(); i++) {
+				for (int j = 0; j < band1.getWidth(); j++) {
+					byte b1 = band1.getElemByte(i, j);
+					byte b2 = band2.getElemByte(i, j);
+					assertEquals(b1, b2);
+				}
+			}
+			
+			buf1.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo MemoryBuffer TestReplicateBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {  
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestReplicateBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestCopyBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestCopyBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestCopyBand.java	(revision 3222)
@@ -0,0 +1,102 @@
+package org.gvsig.raster.cache.buffer.impl.memory;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.BandNotCompatibleException;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+
+/**
+ * Copy the band 0 from a buffer over the band 2 in the same buffer using the
+ * method getBandCopy.  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestCopyBand extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	private String rasterOut = "/tmp/out-copyFirstBand.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("MemoryBuffer TestCopyBand running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//Create Buffer
+			Buffer buf1 = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			setLines(dataIn, buf1);
+			
+			
+			Band rb = buf1.getBandCopy(0);
+			
+			try {
+				buf1.copyBand(2, rb);
+			} catch (BandNotCompatibleException e) {
+				e.printStackTrace();
+			}
+			
+			//Write output file 
+			out = new GdalWrite(rasterOut, 3, input.getDataType(), input.getWidth(), input.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf1.getBands());
+			out.close();	
+			
+			Band band1 = buf1.getBand(0);
+			Band band2 = buf1.getBand(2);
+			for (int i = 0; i < band1.getHeight(); i++) {
+				for (int j = 0; j < band1.getWidth(); j++) {
+					byte b1 = band1.getElemByte(i, j);
+					byte b2 = band2.getElemByte(i, j);
+					assertEquals(b1, b2);
+				}
+			}
+			
+			buf1.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo MemoryBuffer TestCopyBand: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/memory/TestCopyBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationInvDistanceIncrease.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationInvDistanceIncrease.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationInvDistanceIncrease.java	(revision 3222)
@@ -0,0 +1,86 @@
+package org.gvsig.raster.cache.buffer.impl;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer;
+
+/**
+ * Copy the band 0 from a buffer over the band 2 in the same buffer using the
+ * method getBandCopy.  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestInterpolationInvDistanceIncrease extends TestCase {
+	private String         rasterIn  = "./src/test/resources/image/001m09_1_0.tif";
+	private String         rasterOut = "/tmp/out-interpInvDistance.tif";
+	private static int     REL       = 2;
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("TestInterpolationInvDistance running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			//Read input data
+			input = new GdalRead(rasterIn);
+			int readSize = 10;
+			Object dataIn = input.readBlock(0, 0, readSize, readSize);
+			
+			//Create Buffer
+			Buffer buf1 = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														readSize, 
+														readSize,
+														input.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			setLines(dataIn, buf1);
+			Buffer buf = buf1.getAdjustedWindow(readSize * REL, readSize * REL, BufferInterpolationImpl.INTERPOLATION_InverseDistance);
+						
+			//Write output file 
+			out = new GdalWrite(rasterOut, 3, input.getDataType(), buf.getWidth(), buf.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf.getBands());
+			out.close();	
+			
+			buf1.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo TestInterpolationInvDistance: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}
+

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationInvDistanceIncrease.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestStatistics.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestStatistics.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestStatistics.java	(revision 3222)
@@ -0,0 +1,156 @@
+package org.gvsig.raster.cache.buffer.impl;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.io.BufferDataSourceImpl;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer;
+import org.gvsig.raster.cache.buffer.impl.rocache.RasterReadOnlyBuffer;
+import org.gvsig.raster.cache.buffer.impl.stripecache.horizontal.RasterCacheBuffer;
+
+/**
+ * This test calculate the statistics of a image and compare the result with 
+ * the correct values. 
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestStatistics extends TestCase {
+	private String rasterIn = "./src/test/resources/image/001m09_1_0.tif";
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("TestStatistics running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		try {
+	
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+			
+			//MEMORY
+			Buffer buf = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			setLines(dataIn, buf);
+			buf.getStatistics().calculate();			
+			test(buf);
+			buf.free();
+			
+			//CACHE
+			buf = new RasterCacheBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+										input.getWidth(), 
+										input.getHeight(),
+										input.getBandCount());
+			
+			//Set data to buffer
+			setLines(dataIn, buf);
+			buf.getStatistics().calculate();			
+			test(buf);
+			buf.free();
+			
+			//READ ONLY
+			BufferDataSource ds = null;
+			try {
+				ds = new BufferDataSourceImpl(rasterIn);
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+			buf = new RasterReadOnlyBuffer(ds);
+			buf.getStatistics().calculate();			
+			test(buf);
+			buf.free();
+			
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		}  catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo TestStatistics: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void test(Buffer buf) {
+		for (int i = 0; i < buf.getBandCount(); i++) {
+			Band b = buf.getBand(i);
+			/*System.out.println("Band " + i);
+			System.out.println("Max: " + b.getMax());
+			System.out.println("Min: " + b.getMin());
+			System.out.println("Max RGB: " + b.getMaxRGB());
+			System.out.println("Min RGB: " + b.getMinRGB());
+			System.out.println("SecondMax: " + b.getSecondMax());
+			System.out.println("SecondMin: " + b.getSecondMin());
+			System.out.println("SecondMax RGB: " + b.getSecondMaxRGB());
+			System.out.println("SecondMin RGB: " + b.getSecondMinRGB());
+			System.out.println("Mean: " + b.getMean());*/
+			if(i == 0) {
+				assertEquals((int)b.getMax(), 124);
+				assertEquals((int)b.getMin(), -125);
+				assertEquals((int)b.getMaxRGB(), 255);
+				assertEquals((int)b.getMinRGB(), 0);
+				assertEquals((int)b.getSecondMax(), 118);
+				assertEquals((int)b.getSecondMin(), -119);
+				assertEquals((int)b.getSecondMaxRGB(), 249);
+				assertEquals((int)b.getSecondMinRGB(), 6);
+				assertEquals((int)b.getMean(), 79);
+			}
+			if(i == 1) {
+				assertEquals((int)b.getMax(), 120);
+				assertEquals((int)b.getMin(), -128);
+				assertEquals((int)b.getMaxRGB(), 255);
+				assertEquals((int)b.getMinRGB(), 0);
+				assertEquals((int)b.getSecondMax(), 113);
+				assertEquals((int)b.getSecondMin(), -121);
+				assertEquals((int)b.getSecondMaxRGB(), 248);
+				assertEquals((int)b.getSecondMinRGB(), 8);
+				assertEquals((int)b.getMean(), 88);
+			}
+			if(i == 2) {
+				assertEquals((int)b.getMax(), 115);
+				assertEquals((int)b.getMin(), -128);
+				assertEquals((int)b.getMaxRGB(), 255);
+				assertEquals((int)b.getMinRGB(), 0);
+				assertEquals((int)b.getSecondMax(), 102);
+				assertEquals((int)b.getSecondMin(), -116);
+				assertEquals((int)b.getSecondMaxRGB(), 242);
+				assertEquals((int)b.getSecondMinRGB(), 13);
+				assertEquals((int)b.getMean(), 91);
+			}
+		}
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestStatistics.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/AllTests.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/AllTests.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/AllTests.java	(revision 3222)
@@ -0,0 +1,65 @@
+package org.gvsig.raster.cache.buffer.impl;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+	public static Test suite() {
+		TestSuite suite = new TestSuite(
+				"Test for org.gvsig.raster.buffer");
+		//$JUnit-BEGIN$
+		suite.addTestSuite(org.gvsig.raster.cache.buffer.impl.memory.TestSwapBands.class);
+		suite.addTestSuite(org.gvsig.raster.cache.buffer.impl.memory.TestMemoryBuffer.class);
+		suite.addTestSuite(org.gvsig.raster.cache.buffer.impl.memory.TestRemoveBand.class);
+		suite.addTestSuite(org.gvsig.raster.cache.buffer.impl.memory.TestAddBand.class);
+		suite.addTestSuite(org.gvsig.raster.cache.buffer.impl.memory.TestSwapTwoBands.class);
+		suite.addTestSuite(org.gvsig.raster.cache.buffer.impl.memory.TestCopyBand.class);
+		suite.addTestSuite(org.gvsig.raster.cache.buffer.impl.memory.TestGetBufferWithOneBand.class);
+		suite.addTestSuite(org.gvsig.raster.cache.buffer.impl.memory.TestReplicateBand.class);
+		suite.addTestSuite(org.gvsig.raster.cache.buffer.impl.memory.TestRWOneValue.class);
+		suite.addTestSuite(org.gvsig.raster.cache.buffer.impl.memory.TestCopyBand2.class);
+		suite.addTestSuite(org.gvsig.raster.cache.buffer.impl.memory.TestCreateBand.class);
+		suite.addTestSuite(org.gvsig.raster.cache.buffer.impl.memory.TestAssignBand.class);
+		suite.addTestSuite(org.gvsig.raster.cache.buffer.impl.memory.TestRWTiffAndCompareData.class);
+		
+		suite.addTestSuite(org.gvsig.raster.cache.buffer.impl.rocache.TestReplicateBand.class);
+		suite.addTestSuite(org.gvsig.raster.cache.buffer.impl.rocache.TestSwapBands.class);
+		suite.addTestSuite(org.gvsig.raster.cache.buffer.impl.rocache.TestReadTiffAndCompareData.class);
+		suite.addTestSuite(org.gvsig.raster.cache.buffer.impl.rocache.TestSwapTwoBands.class);
+		suite.addTestSuite(org.gvsig.raster.cache.buffer.impl.rocache.TestRemoveBand.class);
+		suite.addTestSuite(org.gvsig.raster.cache.buffer.impl.rocache.TestGetBufferWithOneBand.class);
+		suite.addTestSuite(org.gvsig.raster.cache.buffer.impl.rocache.TestAssignBand.class);
+		suite.addTestSuite(org.gvsig.raster.cache.buffer.impl.rocache.TestCopyBand.class);
+		suite.addTestSuite(org.gvsig.raster.cache.buffer.impl.rocache.TestAddBand.class);
+		suite.addTestSuite(org.gvsig.raster.cache.buffer.impl.rocache.TestWindow.class);
+		
+		suite.addTestSuite(org.gvsig.raster.cache.buffer.impl.stripecache.horizontal.TestSwapTwoBands.class);
+		suite.addTestSuite(org.gvsig.raster.cache.buffer.impl.stripecache.horizontal.TestAssignBand.class);
+		suite.addTestSuite(org.gvsig.raster.cache.buffer.impl.stripecache.horizontal.TestCopyBand.class);
+		suite.addTestSuite(org.gvsig.raster.cache.buffer.impl.stripecache.horizontal.TestRemoveBand.class);
+		suite.addTestSuite(org.gvsig.raster.cache.buffer.impl.stripecache.horizontal.TestReplicateBand.class);
+		suite.addTestSuite(org.gvsig.raster.cache.buffer.impl.stripecache.horizontal.TestAddBand.class);
+		suite.addTestSuite(org.gvsig.raster.cache.buffer.impl.stripecache.horizontal.TestRWOneValue.class);
+		suite.addTestSuite(org.gvsig.raster.cache.buffer.impl.stripecache.horizontal.TestCreateBand.class);
+		suite.addTestSuite(org.gvsig.raster.cache.buffer.impl.stripecache.horizontal.TestRWTiffAndCompareData.class);
+		suite.addTestSuite(org.gvsig.raster.cache.buffer.impl.stripecache.horizontal.TestSwapBands.class);
+		suite.addTestSuite(org.gvsig.raster.cache.buffer.impl.stripecache.horizontal.TestCopyBand2.class);
+		suite.addTestSuite(org.gvsig.raster.cache.buffer.impl.stripecache.horizontal.TestGetBufferWithOneBand.class);
+		
+		suite.addTestSuite(TestInterpolationBicubicIncrease.class);
+		suite.addTestSuite(TestInterpolationBicubicReduction.class);
+		suite.addTestSuite(TestInterpolationBilinearIncrease.class);
+		suite.addTestSuite(TestInterpolationBilinearReduction.class);
+		suite.addTestSuite(TestInterpolationBSplineIncrease.class);
+		suite.addTestSuite(TestInterpolationBSplineReduction.class);
+		suite.addTestSuite(TestInterpolationInvDistanceIncrease.class);
+		suite.addTestSuite(TestInterpolationInvDistanceReduction.class);
+		suite.addTestSuite(TestInterpolationNearestIncrease.class);
+		suite.addTestSuite(TestInterpolationNearestReduction.class);
+		suite.addTestSuite(TestStatistics.class);
+		//$JUnit-END$
+		return suite;
+	}
+
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/AllTests.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationInvDistanceReduction.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationInvDistanceReduction.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationInvDistanceReduction.java	(revision 3222)
@@ -0,0 +1,85 @@
+package org.gvsig.raster.cache.buffer.impl;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.io.GdalRead;
+import org.gvsig.raster.cache.buffer.impl.io.GdalWrite;
+import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer;
+
+/**
+ * Copy the band 0 from a buffer over the band 2 in the same buffer using the
+ * method getBandCopy.  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestInterpolationInvDistanceReduction extends TestCase {
+	private String         rasterIn  = "./src/test/resources/image/001m09_1_0.tif";
+	private String         rasterOut = "/tmp/out-interpInvDistanceReduction.tif";
+	private static int     REL       = 5;
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+
+	public void setUp() {
+		System.err.println("TestInterpolationInvDistanceReduction running...");
+	}
+	
+	public void testStack() {
+		long t1 = System.currentTimeMillis();
+		GdalRead input = null;
+		GdalWrite out = null;
+		try {
+			//Read input data
+			input = new GdalRead(rasterIn);
+			Object dataIn = input.readBlock(0, 0, input.getWidth(), input.getHeight());
+						
+			//Create Buffer
+			Buffer buf1 = new RasterMemoryBuffer(input.getRasterBufTypeFromGdalType(input.getDataType()), 
+														input.getWidth(), 
+														input.getHeight(),
+														input.getBandCount(),
+														true);
+			
+			//Set data to buffer
+			setLines(dataIn, buf1);
+			Buffer buf = buf1.getAdjustedWindow(input.getWidth() / REL, input.getHeight() / REL, BufferInterpolationImpl.INTERPOLATION_InverseDistance);
+						
+			//Write output file 
+			out = new GdalWrite(rasterOut, 3, input.getDataType(), buf.getWidth(), buf.getHeight(), GdalWrite.COLOR_INTERP_RGB);
+			out.writeBands(buf.getBands());
+			out.close();	
+			
+			buf1.free();
+		} catch (GdalException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ProcessInterruptedException e) {
+			e.printStackTrace();
+		} catch (OperationNotSupportedException e) {
+			e.printStackTrace();
+		}
+		long t2 = System.currentTimeMillis();
+		System.out.println("Tiempo TestInterpolationInvDistanceReduction: " + (t2 - t1) + " milisegundos");
+	}
+	
+	private void setLines(Object dataIn, Buffer buf) throws OperationNotSupportedException {
+		if(dataIn instanceof byte[][][]) {
+    		byte[][][] d = (byte[][][])dataIn;
+    		for (int iBand = 0; iBand < d.length; iBand++) {
+				for (int row = 0; row < d[iBand].length; row++) {
+					buf.setLineInBandByte(d[iBand][row], row, iBand);
+				}
+			}
+    	}
+	}
+	
+}
+

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/test/impl/TestInterpolationInvDistanceReduction.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/BufferInterpolationImpl.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/BufferInterpolationImpl.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/BufferInterpolationImpl.java	(revision 3222)
@@ -0,0 +1,1300 @@
+package org.gvsig.raster.cache.buffer.impl;
+
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferInterpolation;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.task.DefaultTaskEventManager;
+import org.gvsig.raster.cache.buffer.task.TaskEventManager;
+
+
+
+/**
+ * <p>
+ * This class is a coverage of a RasterBuffer and contains diferents algorithms to interpolate data buffers. The methods
+ * implemented here are nearest neighbour, bilinear, inverse distance, bspline and
+ * bicubic.
+ * </p>
+ * 
+ * @version 07/05/2007
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ *
+ */
+public class BufferInterpolationImpl implements BufferInterpolation {
+	private Buffer                  buffer          = null;
+	private double                  percent         = 0;
+	private BufferCacheManagerImpl  manager         = null;
+	
+	/**
+	 * Set the data to be interpolated
+	 * @param buf
+	 */
+	public BufferInterpolationImpl(Buffer buf) {
+		this.buffer = buf;
+		manager = new BufferCacheManagerImpl();
+	}
+		
+	/**
+	 * Calcula los vectores de desplazamiento en pixels en X e Y cuando se supersamplea.
+	 * @param r Array de desplazamientos para las filas. Debe tener espacio reservado
+	 * @param c Array de desplazamientos para las columnas. Debe tener espacio reservado
+	 * cargados.
+	 */
+	private void calcSupersamplingStepsArrays(int[] r, int[] c, double[] superSampStep) {
+		double pos = superSampStep[1];
+		for(int row = 0; row < r.length; row ++) {
+			r[row] = (int)(pos / superSampStep[3]);
+			pos ++;
+		}
+		pos = superSampStep[0];
+		for(int col = 0; col < c.length; col ++) {
+			c[col] = (int)(pos / superSampStep[2]);
+			pos ++;
+		}
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.cachete.api.buffer.IBufferInterpolation#getSupersampledScrolledNearestNeighbour(double[], int, int)
+	 */
+	public Buffer getSupersampledScrolledNearestNeighbour(double[] superSampStep, int w, int h) throws ProcessInterruptedException {
+		TaskEventManager task = new DefaultTaskEventManager(this);
+		
+		int[] rowStep = new int[h];
+		int[] colStep = new int[w];
+		calcSupersamplingStepsArrays(rowStep, colStep, superSampStep);
+		
+		BufferParamImpl param = new BufferParamImpl(w, h); 
+		param.setDataType(buffer.getDataType()); 
+		param.setBandCount(buffer.getBandCount());
+		Buffer bufOut = manager.createBuffer(param);
+		try {
+			switch(param.getDataType()) {
+			case RasterBuffer.TYPE_BYTE:
+				for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) {
+					for (int row = 0; row < h; row++) {
+						for (int col = 0; col < w; col++) {
+							try {
+								bufOut.setElem(row, col, iBand, buffer.getElemByte(rowStep[row], colStep[col], iBand));
+							} catch (ArrayIndexOutOfBoundsException e) {/*System.out.println("->" + row + " " + col);*/break;}
+						}
+						if(task.getEvent() != null)
+							task.manageEvent(task.getEvent());
+					}
+				}
+				break;
+			case RasterBuffer.TYPE_SHORT:
+				for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) {
+					for (int row = 0; row < h; row++) {
+						for (int col = 0; col < w; col++) {
+							try {
+								bufOut.setElem(row, col, iBand, buffer.getElemShort(rowStep[row], colStep[col], iBand));
+							} catch (ArrayIndexOutOfBoundsException e) {/*System.out.println("->" + row + " " + col);*/break;}
+						}
+						if(task.getEvent() != null)
+							task.manageEvent(task.getEvent());
+					}
+				}
+				break;
+
+			case RasterBuffer.TYPE_INT:
+				for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) {
+					for (int row = 0; row < h; row++) {
+						for (int col = 0; col < w; col++) {
+							try {
+								bufOut.setElem(row, col, iBand, buffer.getElemInt(rowStep[row], colStep[col], iBand));
+							} catch (ArrayIndexOutOfBoundsException e) {/*System.out.println("->" + row + " " + col);*/break;}
+						}
+						if(task.getEvent() != null)
+							task.manageEvent(task.getEvent());
+					}
+				}
+				break;
+			case RasterBuffer.TYPE_FLOAT:
+				for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) {
+					for (int row = 0; row < h; row++) {
+						for (int col = 0; col < w; col++) {
+							try {
+								bufOut.setElem(row, col, iBand, buffer.getElemFloat(rowStep[row], colStep[col], iBand));
+							} catch (ArrayIndexOutOfBoundsException e) {/*System.out.println("->" + row + " " + col);*/break;}
+						}
+						if(task.getEvent() != null)
+							task.manageEvent(task.getEvent());
+					}
+				}
+				break;
+			case RasterBuffer.TYPE_DOUBLE:
+				for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) {
+					for (int row = 0; row < h; row++) {
+						for (int col = 0; col < w; col++) {
+							try {
+								bufOut.setElem(row, col, iBand, buffer.getElemDouble(rowStep[row], colStep[col], iBand));
+							} catch (ArrayIndexOutOfBoundsException e) {/*System.out.println("->" + row + " " + col);*/break;}
+						}
+						if(task.getEvent() != null)
+							task.manageEvent(task.getEvent());
+					}
+				}
+				break;
+			}
+		} catch (OperationNotSupportedException e) {
+			//It is not possible because the RW buffer is created inside of this function 
+		}
+		return bufOut;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.cachete.api.buffer.IBufferInterpolation#getSupersampledScrolledBilinearInterpolation(double[], int, int)
+	 */
+	public Buffer getSupersampledScrolledBilinearInterpolation(double[] superSampStep, int w, int h) throws ProcessInterruptedException {
+		TaskEventManager task = new DefaultTaskEventManager(this);
+
+		int[] rowStep = new int[h];
+		int[] colStep = new int[w];
+		calcSupersamplingStepsArrays(rowStep, colStep, superSampStep);
+		
+		double pxSize = (double) buffer.getWidth() / (double) w;
+		BufferParamImpl params = new BufferParamImpl(w, h);
+		params.setDataType(buffer.getDataType());
+		params.setBandCount(buffer.getBandCount());
+		Buffer rasterBuf = manager.createBuffer(params);
+
+		double posX = pxSize / 2D; // Empieza en el centro del primer pixel
+		double posY = posX;
+		double dx = 0D, dy = 0D;
+
+		try {
+			percent = 0;
+			double multip = 100.0D / (h * buffer.getBandCount());
+
+			for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) {
+				posY = pxSize / 2D;
+				switch (buffer.getDataType()) {
+				case RasterBuffer.TYPE_BYTE:
+					for (int iRow = 0; iRow < h; iRow++) {
+						dy = posY - ((int) posY);
+						posX = pxSize / 2D;
+						for (int iCol = 0; iCol < w; iCol++) {
+							dx = posX - ((int) posX);
+							try {
+								double[] kernel = getKernelByte(((int) posX), ((int) posY), iBand);
+								rasterBuf.setElem(iRow, iCol, iBand, (byte) ((byte) getBilinearValue(dx, dy, kernel) & 0xff));
+							} catch (ArrayIndexOutOfBoundsException e) {
+								// System.out.println(posX + " " + posY);
+							}
+							posX += pxSize;
+						}
+						posY += pxSize;
+						percent = (iBand * h + iRow) * multip;
+						if (task.getEvent() != null)
+							task.manageEvent(task.getEvent());
+					}
+					break;
+				case RasterBuffer.TYPE_SHORT:
+					for (int iRow = 0; iRow < h; iRow++) {
+						dy = posY - ((int) posY);
+						posX = pxSize / 2D;
+						for (int iCol = 0; iCol < w; iCol++) {
+							dx = posX - ((int) posX);
+							try {
+								double[] kernel = getKernelShort(((int) posX), ((int) posY), iBand);
+								rasterBuf.setElem(iRow, iCol, iBand, (short) ((short) getBilinearValue(dx, dy, kernel) & 0xffff));
+							} catch (ArrayIndexOutOfBoundsException e) {
+								// System.out.println(posX + " " + posY);
+							}
+							posX += pxSize;
+						}
+						posY += pxSize;
+						percent = (iBand * h + iRow) * multip;
+						if (task.getEvent() != null)
+							task.manageEvent(task.getEvent());
+					}
+					break;
+				case RasterBuffer.TYPE_INT:
+					for (int iRow = 0; iRow < h; iRow++) {
+						dy = posY - ((int) posY);
+						posX = pxSize / 2D;
+						for (int iCol = 0; iCol < w; iCol++) {
+							dx = posX - ((int) posX);
+							try {
+								double[] kernel = getKernelInt(((int) posX), ((int) posY), iBand);
+								rasterBuf.setElem(iRow, iCol, iBand, (int) ((int) getBilinearValue(dx, dy, kernel) & 0xff));
+							} catch (ArrayIndexOutOfBoundsException e) {
+								// System.out.println(posX + " " + posY);
+							}
+							posX += pxSize;
+						}
+						posY += pxSize;
+						percent = (iBand * h + iRow) * multip;
+						if (task.getEvent() != null)
+							task.manageEvent(task.getEvent());
+					}
+					break;
+				case RasterBuffer.TYPE_FLOAT:
+					for (int iRow = 0; iRow < h; iRow++) {
+						dy = posY - ((int) posY);
+						posX = pxSize / 2D;
+						for (int iCol = 0; iCol < w; iCol++) {
+							dx = posX - ((int) posX);
+							try {
+								double[] kernel = getKernelInt(((int) posX), ((int) posY), iBand);
+								rasterBuf.setElem(iRow, iCol, iBand, (float) getBilinearValue(dx, dy, kernel));
+							} catch (ArrayIndexOutOfBoundsException e) {
+								// System.out.println(posX + " " + posY);
+							}
+							posX += pxSize;
+						}
+						posY += pxSize;
+						percent = (iBand * h + iRow) * multip;
+						if (task.getEvent() != null)
+							task.manageEvent(task.getEvent());
+					}
+					break;
+				case RasterBuffer.TYPE_DOUBLE:
+					for (int iRow = 0; iRow < h; iRow++) {
+						dy = posY - ((int) posY);
+						posX = pxSize / 2D;
+						for (int iCol = 0; iCol < w; iCol++) {
+							dx = posX - ((int) posX);
+							try {
+								double[] kernel = getKernelInt(((int) posX), ((int) posY), iBand);
+								rasterBuf.setElem(iRow, iCol, iBand, (double) getBilinearValue(dx, dy, kernel));
+							} catch (ArrayIndexOutOfBoundsException e) {
+								// System.out.println(posX + " " + posY);
+							}
+							posX += pxSize;
+						}
+						posY += pxSize;
+						percent = (iBand * h + iRow) * multip;
+						if (task.getEvent() != null)
+							task.manageEvent(task.getEvent());
+					}
+					break;
+				}
+			}
+		} catch (OperationNotSupportedException e) {
+			//This exception is only possible with a read only buffer
+		}
+		return rasterBuf;
+	}
+
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.cachete.api.buffer.IBufferInterpolation#adjustRasterNearestNeighbourInterpolation(int, int)
+	 */
+	public Buffer adjustRasterNearestNeighbourInterpolation(int w, int h) throws ProcessInterruptedException {
+		TaskEventManager task = new DefaultTaskEventManager(this);
+
+		double stepX = (double) w / (double) buffer.getWidth();
+		double stepY = (double) h / (double) buffer.getHeight();
+		BufferParamImpl params = new BufferParamImpl(w, h);
+		params.setDataType(buffer.getDataType());
+		params.setBandCount(buffer.getBandCount());
+		Buffer rasterBuf = manager.createBuffer(params);
+
+		try {
+			int[] bands = new int[rasterBuf.getBandCount()];
+			for (int iBand = 0; iBand < rasterBuf.getBandCount(); iBand++)
+				bands[iBand] = iBand;
+
+			percent = 0;
+			double multip = 100.0D / (buffer.getHeight() * bands.length);
+			switch (buffer.getDataType()) {
+			case RasterBuffer.TYPE_BYTE:
+				for (int iBand = 0; iBand < bands.length; iBand++) {
+					if (w <= buffer.getWidth()) { // submuestreo
+						for (int iRow = 0; iRow < buffer.getHeight(); iRow++) {
+							for (int iCol = 0; iCol < buffer.getWidth(); iCol++)
+								rasterBuf.setElem((int) (iRow * stepY), (int) (iCol * stepX), bands[iBand], buffer.getElemByte(iRow, iCol, iBand));
+							percent = (iBand * buffer.getHeight() + iRow) * multip;
+							if (task.getEvent() != null)
+								task.manageEvent(task.getEvent());
+						}
+					} else { // supermuestreo
+						for (int iRow = 0; iRow < h; iRow++) {
+							for (int iCol = 0; iCol < w; iCol++)
+								rasterBuf.setElem(iRow, iCol, bands[iBand], buffer.getElemByte((int) (iRow / stepY), (int) (iCol / stepX), iBand));
+							percent = (iBand * buffer.getHeight() + iRow) * multip;
+							if (task.getEvent() != null)
+								task.manageEvent(task.getEvent());
+						}
+					}
+				}
+				break;
+			case RasterBuffer.TYPE_DOUBLE:
+				for (int iBand = 0; iBand < bands.length; iBand++) {
+					if (w <= buffer.getWidth()) { // submuestreo
+						for (int iRow = 0; iRow < buffer.getHeight(); iRow++) {
+							for (int iCol = 0; iCol < buffer.getWidth(); iCol++)
+								rasterBuf.setElem((int) (iRow * stepY), (int) (iCol * stepX), bands[iBand], buffer.getElemDouble(iRow, iCol, iBand));
+							percent = (iBand * buffer.getHeight() + iRow) * multip;
+							if (task.getEvent() != null)
+								task.manageEvent(task.getEvent());
+						}
+					} else { // supermuestreo
+						for (int iRow = 0; iRow < h; iRow++) {
+							for (int iCol = 0; iCol < w; iCol++)
+								rasterBuf.setElem(iRow, iCol, bands[iBand], buffer.getElemDouble((int) (iRow / stepY), (int) (iCol / stepX), iBand));
+							percent = (iBand * buffer.getHeight() + iRow) * multip;
+							if (task.getEvent() != null)
+								task.manageEvent(task.getEvent());
+						}
+					}
+				}
+				break;
+			case RasterBuffer.TYPE_FLOAT:
+				for (int iBand = 0; iBand < bands.length; iBand++) {
+					if (w <= buffer.getWidth()) { // submuestreo
+						for (int iRow = 0; iRow < buffer.getHeight(); iRow++) {
+							for (int iCol = 0; iCol < buffer.getWidth(); iCol++)
+								rasterBuf.setElem((int) (iRow * stepY), (int) (iCol * stepX), bands[iBand], buffer.getElemFloat(iRow, iCol, iBand));
+							percent = (iBand * buffer.getHeight() + iRow) * multip;
+							if (task.getEvent() != null)
+								task.manageEvent(task.getEvent());
+						}
+					} else { // supermuestreo
+						for (int iRow = 0; iRow < h; iRow++) {
+							for (int iCol = 0; iCol < w; iCol++)
+								rasterBuf.setElem(iRow, iCol, bands[iBand], buffer.getElemFloat((int) (iRow / stepY), (int) (iCol / stepX), iBand));
+							percent = (iBand * buffer.getHeight() + iRow) * multip;
+							if (task.getEvent() != null)
+								task.manageEvent(task.getEvent());
+						}
+					}
+				}
+				break;
+			case RasterBuffer.TYPE_INT:
+				for (int iBand = 0; iBand < bands.length; iBand++) {
+					if (w <= buffer.getWidth()) { // submuestreo
+						for (int iRow = 0; iRow < buffer.getHeight(); iRow++) {
+							for (int iCol = 0; iCol < buffer.getWidth(); iCol++)
+								rasterBuf.setElem((int) (iRow * stepY), (int) (iCol * stepX), bands[iBand], buffer.getElemInt(iRow, iCol, iBand));
+							percent = (iBand * buffer.getHeight() + iRow) * multip;
+							if (task.getEvent() != null)
+								task.manageEvent(task.getEvent());
+						}
+					} else { // supermuestreo
+						for (int iRow = 0; iRow < h; iRow++) {
+							for (int iCol = 0; iCol < w; iCol++)
+								rasterBuf.setElem(iRow, iCol, bands[iBand], buffer.getElemInt((int) (iRow / stepY), (int) (iCol / stepX), iBand));
+							percent = (iBand * buffer.getHeight() + iRow) * multip;
+							if (task.getEvent() != null)
+								task.manageEvent(task.getEvent());
+						}
+					}
+				}
+				break;
+			case RasterBuffer.TYPE_USHORT:
+			case RasterBuffer.TYPE_SHORT:
+				for (int iBand = 0; iBand < bands.length; iBand++) {
+					if (w <= buffer.getWidth()) { // submuestreo
+						for (int iRow = 0; iRow < buffer.getHeight(); iRow++) {
+							for (int iCol = 0; iCol < buffer.getWidth(); iCol++)
+								rasterBuf.setElem((int) (iRow * stepY), (int) (iCol * stepX), bands[iBand], buffer.getElemShort(iRow, iCol, iBand));
+							percent = (iBand * buffer.getHeight() + iRow) * multip;
+							if (task.getEvent() != null)
+								task.manageEvent(task.getEvent());
+						}
+					} else { // supermuestreo
+						for (int iRow = 0; iRow < h; iRow++) {
+							for (int iCol = 0; iCol < w; iCol++)
+								rasterBuf.setElem(iRow, iCol, bands[iBand], buffer.getElemShort((int) (iRow / stepY), (int) (iCol / stepX), iBand));
+							percent = (iBand * buffer.getHeight() + iRow) * multip;
+							if (task.getEvent() != null)
+								task.manageEvent(task.getEvent());
+						}
+					}
+				}
+				break;
+			}
+		} catch (OperationNotSupportedException e) {
+			//This exception is only possible with a read only buffer
+		}
+		return rasterBuf; 
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.cachete.api.buffer.IBufferInterpolation#adjustRasterBilinearInterpolation(int, int)
+	 */
+	public Buffer adjustRasterBilinearInterpolation(int w, int h) throws ProcessInterruptedException {
+		TaskEventManager task = new DefaultTaskEventManager(this);//BufferCacheLocator.getManager().getTask();
+
+		double pxSize = (double) buffer.getWidth() / (double) w;
+		BufferParamImpl params = new BufferParamImpl(w, h);
+		params.setDataType(buffer.getDataType());
+		params.setBandCount(buffer.getBandCount());
+		Buffer rasterBuf = manager.createBuffer(params);
+
+		double posX = pxSize / 2D; // Empieza en el centro del primer pixel
+		double posY = posX;
+		double dx = 0D, dy = 0D;
+
+		try {
+			percent = 0;
+			double multip = 100.0D / (h * buffer.getBandCount());
+
+			for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) {
+				posY = pxSize / 2D;
+				switch (buffer.getDataType()) {
+				case RasterBuffer.TYPE_BYTE:
+					for (int iRow = 0; iRow < h; iRow++) {
+						dy = posY - ((int) posY);
+						posX = pxSize / 2D;
+						for (int iCol = 0; iCol < w; iCol++) {
+							dx = posX - ((int) posX);
+							try {
+								double[] kernel = getKernelByte(((int) posX), ((int) posY), iBand);
+								rasterBuf.setElem(iRow, iCol, iBand, (byte) ((byte) getBilinearValue(dx, dy, kernel) & 0xff));
+							} catch (ArrayIndexOutOfBoundsException e) {
+								// System.out.println(posX + " " + posY);
+							}
+							posX += pxSize;
+						}
+						posY += pxSize;
+						percent = (iBand * h + iRow) * multip;
+						if (task.getEvent() != null)
+							task.manageEvent(task.getEvent());
+					}
+					break;
+				case RasterBuffer.TYPE_SHORT:
+					for (int iRow = 0; iRow < h; iRow++) {
+						dy = posY - ((int) posY);
+						posX = pxSize / 2D;
+						for (int iCol = 0; iCol < w; iCol++) {
+							dx = posX - ((int) posX);
+							try {
+								double[] kernel = getKernelShort(((int) posX), ((int) posY), iBand);
+								rasterBuf.setElem(iRow, iCol, iBand, (short) ((short) getBilinearValue(dx, dy, kernel) & 0xffff));
+							} catch (ArrayIndexOutOfBoundsException e) {
+								// System.out.println(posX + " " + posY);
+							}
+							posX += pxSize;
+						}
+						posY += pxSize;
+						percent = (iBand * h + iRow) * multip;
+						if (task.getEvent() != null)
+							task.manageEvent(task.getEvent());
+					}
+					break;
+				case RasterBuffer.TYPE_INT:
+					for (int iRow = 0; iRow < h; iRow++) {
+						dy = posY - ((int) posY);
+						posX = pxSize / 2D;
+						for (int iCol = 0; iCol < w; iCol++) {
+							dx = posX - ((int) posX);
+							try {
+								double[] kernel = getKernelInt(((int) posX), ((int) posY), iBand);
+								rasterBuf.setElem(iRow, iCol, iBand, (int) ((int) getBilinearValue(dx, dy, kernel) & 0xff));
+							} catch (ArrayIndexOutOfBoundsException e) {
+								// System.out.println(posX + " " + posY);
+							}
+							posX += pxSize;
+						}
+						posY += pxSize;
+						percent = (iBand * h + iRow) * multip;
+						if (task.getEvent() != null)
+							task.manageEvent(task.getEvent());
+					}
+					break;
+				case RasterBuffer.TYPE_FLOAT:
+					for (int iRow = 0; iRow < h; iRow++) {
+						dy = posY - ((int) posY);
+						posX = pxSize / 2D;
+						for (int iCol = 0; iCol < w; iCol++) {
+							dx = posX - ((int) posX);
+							try {
+								double[] kernel = getKernelInt(((int) posX), ((int) posY), iBand);
+								rasterBuf.setElem(iRow, iCol, iBand, (float) getBilinearValue(dx, dy, kernel));
+							} catch (ArrayIndexOutOfBoundsException e) {
+								// System.out.println(posX + " " + posY);
+							}
+							posX += pxSize;
+						}
+						posY += pxSize;
+						percent = (iBand * h + iRow) * multip;
+						if (task.getEvent() != null)
+							task.manageEvent(task.getEvent());
+					}
+					break;
+				case RasterBuffer.TYPE_DOUBLE:
+					for (int iRow = 0; iRow < h; iRow++) {
+						dy = posY - ((int) posY);
+						posX = pxSize / 2D;
+						for (int iCol = 0; iCol < w; iCol++) {
+							dx = posX - ((int) posX);
+							try {
+								double[] kernel = getKernelInt(((int) posX), ((int) posY), iBand);
+								rasterBuf.setElem(iRow, iCol, iBand, (double) getBilinearValue(dx, dy, kernel));
+							} catch (ArrayIndexOutOfBoundsException e) {
+								// System.out.println(posX + " " + posY);
+							}
+							posX += pxSize;
+						}
+						posY += pxSize;
+						percent = (iBand * h + iRow) * multip;
+						if (task.getEvent() != null)
+							task.manageEvent(task.getEvent());
+					}
+					break;
+				}
+			}
+		} catch (OperationNotSupportedException e) {
+			//This exception is only possible with a read only buffer
+		}
+		return rasterBuf;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.cachete.api.buffer.IBufferInterpolation#adjustRasterInverseDistanceInterpolation(int, int)
+	 */
+	public Buffer adjustRasterInverseDistanceInterpolation(int w, int h) throws ProcessInterruptedException {
+		TaskEventManager task = new DefaultTaskEventManager(this);
+
+		double pxSize = (double) buffer.getWidth() / (double) w;
+		BufferParamImpl params = new BufferParamImpl(w, h);
+		params.setDataType(buffer.getDataType());
+		params.setBandCount(buffer.getBandCount());
+		Buffer rasterBuf = manager.createBuffer(params);
+
+		double posX = pxSize / 2D;
+		double posY = posX;
+		double dx = 0D, dy = 0D;
+
+		try {
+			percent = 0;
+			double multip = 100.0D / (h * buffer.getBandCount());
+
+			for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) {
+				posY = pxSize / 2D;
+				switch (buffer.getDataType()) {
+				case RasterBuffer.TYPE_BYTE:
+					for (int iRow = 0; iRow < h; iRow++) {
+						dy = posY - ((int) posY);
+						posX = pxSize / 2D;
+						for (int iCol = 0; iCol < w; iCol++) {
+							dx = posX - ((int) posX);
+							try {
+								double[] kernel = getKernelByte(((int) posX), ((int) posY), iBand);
+								rasterBuf.setElem(iRow, iCol, iBand, (byte) ((byte) getInverseDistanceValue(dx, dy, kernel) & 0xff));
+							} catch (ArrayIndexOutOfBoundsException e) {
+								// System.out.println(posX + " " + posY);
+							}
+							posX += pxSize;
+						}
+						posY += pxSize;
+						percent = (iBand * h + iRow) * multip;
+						if (task.getEvent() != null)
+							task.manageEvent(task.getEvent());
+					}
+					break;
+				case RasterBuffer.TYPE_SHORT:
+					for (int iRow = 0; iRow < h; iRow++) {
+						dy = posY - ((int) posY);
+						posX = pxSize / 2D;
+						for (int iCol = 0; iCol < w; iCol++) {
+							dx = posX - ((int) posX);
+							try {
+								double[] kernel = getKernelShort(((int) posX), ((int) posY), iBand);
+								rasterBuf.setElem(iRow, iCol, iBand, (short) ((short) getInverseDistanceValue(dx, dy, kernel) & 0xffff));
+							} catch (ArrayIndexOutOfBoundsException e) {
+								// System.out.println(posX + " " + posY);
+							}
+							posX += pxSize;
+						}
+						posY += pxSize;
+						percent = (iBand * h + iRow) * multip;
+						if (task.getEvent() != null)
+							task.manageEvent(task.getEvent());
+					}
+					break;
+				case RasterBuffer.TYPE_INT:
+					for (int iRow = 0; iRow < h; iRow++) {
+						dy = posY - ((int) posY);
+						posX = pxSize / 2D;
+						for (int iCol = 0; iCol < w; iCol++) {
+							dx = posX - ((int) posX);
+							try {
+								double[] kernel = getKernelInt(((int) posX), ((int) posY), iBand);
+								rasterBuf.setElem(iRow, iCol, iBand, (int) ((int) getInverseDistanceValue(dx, dy, kernel) & 0xff));
+							} catch (ArrayIndexOutOfBoundsException e) {
+								// System.out.println(posX + " " + posY);
+							}
+							posX += pxSize;
+						}
+						posY += pxSize;
+						percent = (iBand * h + iRow) * multip;
+						if (task.getEvent() != null)
+							task.manageEvent(task.getEvent());
+					}
+					break;
+				case RasterBuffer.TYPE_FLOAT:
+					for (int iRow = 0; iRow < h; iRow++) {
+						dy = posY - ((int) posY);
+						posX = pxSize / 2D;
+						for (int iCol = 0; iCol < w; iCol++) {
+							dx = posX - ((int) posX);
+							try {
+								double[] kernel = getKernelFloat(((int) posX), ((int) posY), iBand);
+								rasterBuf.setElem(iRow, iCol, iBand, (float) getInverseDistanceValue(dx, dy, kernel));
+							} catch (ArrayIndexOutOfBoundsException e) {
+								// System.out.println(posX + " " + posY);
+							}
+							posX += pxSize;
+						}
+						posY += pxSize;
+						percent = (iBand * h + iRow) * multip;
+						if (task.getEvent() != null)
+							task.manageEvent(task.getEvent());
+					}
+					break;
+				case RasterBuffer.TYPE_DOUBLE:
+					for (int iRow = 0; iRow < h; iRow++) {
+						dy = posY - ((int) posY);
+						posX = pxSize / 2D;
+						for (int iCol = 0; iCol < w; iCol++) {
+							dx = posX - ((int) posX);
+							try {
+								double[] kernel = getKernelDouble(((int) posX), ((int) posY), iBand);
+								rasterBuf.setElem(iRow, iCol, iBand, (double) getInverseDistanceValue(dx, dy, kernel));
+							} catch (ArrayIndexOutOfBoundsException e) {
+								// System.out.println(posX + " " + posY);
+							}
+							posX += pxSize;
+						}
+						posY += pxSize;
+						percent = (iBand * h + iRow) * multip;
+						if (task.getEvent() != null)
+							task.manageEvent(task.getEvent());
+					}
+					break;
+				}
+			}
+		} catch (OperationNotSupportedException e) {
+			//This exception is only possible with a read only buffer
+		}
+		return rasterBuf;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.cachete.api.buffer.IBufferInterpolation#adjustRasterBSplineInterpolation(int, int)
+	 */
+	public Buffer adjustRasterBSplineInterpolation(int w, int h) throws ProcessInterruptedException {
+		TaskEventManager task = new DefaultTaskEventManager(this);
+
+		double pxSize = (double) buffer.getWidth() / (double) w;
+		BufferParamImpl params = new BufferParamImpl(w, h);
+		params.setDataType(buffer.getDataType());
+		params.setBandCount(buffer.getBandCount());
+		Buffer rasterBuf = manager.createBuffer(params);
+
+		double posX = pxSize / 2D;
+		double posY = posX;
+		double dx = 0D, dy = 0D;
+
+		try {
+			percent = 0;
+			double multip = 100.0D / (h * buffer.getBandCount());
+
+			for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) {
+				posY = pxSize / 2D;
+				switch (buffer.getDataType()) {
+				case RasterBuffer.TYPE_BYTE:
+					for (int iRow = 0; iRow < h; iRow++) {
+						dy = posY - ((int) posY);
+						posX = pxSize / 2D;
+						for (int iCol = 0; iCol < w; iCol++) {
+							dx = posX - ((int) posX);
+							try {
+								double[][] kernel = get4x4Submatrix(((int) posX), ((int) posY), iBand);
+								if (kernel == null) {
+									double[] k = getKernelByte(((int) posX), ((int) posY), iBand);
+									rasterBuf.setElem(iRow, iCol, iBand, (byte) ((byte) getBilinearValue(dx, dy, k) & 0xff));
+								} else
+									rasterBuf.setElem(iRow, iCol, iBand, (byte) ((byte) getBSplineValue(dx, dy, kernel) & 0xff));
+							} catch (ArrayIndexOutOfBoundsException e) {
+								// System.out.println(posX + " " + posY);
+							}
+							posX += pxSize;
+						}
+						posY += pxSize;
+						percent = (iBand * h + iRow) * multip;
+						if (task.getEvent() != null)
+							task.manageEvent(task.getEvent());
+					}
+					break;
+				case RasterBuffer.TYPE_SHORT:
+					for (int iRow = 0; iRow < h; iRow++) {
+						dy = posY - ((int) posY);
+						posX = pxSize / 2D;
+						for (int iCol = 0; iCol < w; iCol++) {
+							dx = posX - ((int) posX);
+							try {
+								double[][] kernel = get4x4Submatrix(((int) posX), ((int) posY), iBand);
+								if (kernel == null) {
+									double[] k = getKernelShort(((int) posX), ((int) posY), iBand);
+									rasterBuf.setElem(iRow, iCol, iBand, (short) ((short) getBilinearValue(dx, dy, k) & 0xffff));
+								} else
+									rasterBuf.setElem(iRow, iCol, iBand, (short) ((short) getBSplineValue(dx, dy, kernel) & 0xffff));
+							} catch (ArrayIndexOutOfBoundsException e) {
+								// System.out.println(posX + " " + posY);
+							}
+							posX += pxSize;
+						}
+						posY += pxSize;
+						percent = (iBand * h + iRow) * multip;
+						if (task.getEvent() != null)
+							task.manageEvent(task.getEvent());
+					}
+					break;
+				case RasterBuffer.TYPE_INT:
+					for (int iRow = 0; iRow < h; iRow++) {
+						dy = posY - ((int) posY);
+						posX = pxSize / 2D;
+						for (int iCol = 0; iCol < w; iCol++) {
+							dx = posX - ((int) posX);
+							try {
+								double[][] kernel = get4x4Submatrix(((int) posX), ((int) posY), iBand);
+								if (kernel == null) {
+									double[] k = getKernelInt(((int) posX), ((int) posY), iBand);
+									rasterBuf.setElem(iRow, iCol, iBand, (int) ((int) getBilinearValue(dx, dy, k) & 0xffffffff));
+								} else
+									rasterBuf.setElem(iRow, iCol, iBand, (int) ((int) getBSplineValue(dx, dy, kernel) & 0xffffffff));
+							} catch (ArrayIndexOutOfBoundsException e) {
+								// System.out.println(posX + " " + posY);
+							}
+							posX += pxSize;
+						}
+						posY += pxSize;
+						percent = (iBand * h + iRow) * multip;
+						if (task.getEvent() != null)
+							task.manageEvent(task.getEvent());
+					}
+					break;
+				case RasterBuffer.TYPE_FLOAT:
+					for (int iRow = 0; iRow < h; iRow++) {
+						dy = posY - ((int) posY);
+						posX = pxSize / 2D;
+						for (int iCol = 0; iCol < w; iCol++) {
+							dx = posX - ((int) posX);
+							try {
+								double[][] kernel = get4x4Submatrix(((int) posX), ((int) posY), iBand);
+								if (kernel == null) {
+									double[] k = getKernelFloat(((int) posX), ((int) posY), iBand);
+									rasterBuf.setElem(iRow, iCol, iBand, (float) getBilinearValue(dx, dy, k));
+								} else
+									rasterBuf.setElem(iRow, iCol, iBand, (float) getBSplineValue(dx, dy, kernel));
+							} catch (ArrayIndexOutOfBoundsException e) {
+								// System.out.println(posX + " " + posY);
+							}
+							posX += pxSize;
+						}
+						posY += pxSize;
+						percent = (iBand * h + iRow) * multip;
+						if (task.getEvent() != null)
+							task.manageEvent(task.getEvent());
+					}
+					break;
+				case RasterBuffer.TYPE_DOUBLE:
+					for (int iRow = 0; iRow < h; iRow++) {
+						dy = posY - ((int) posY);
+						posX = pxSize / 2D;
+						for (int iCol = 0; iCol < w; iCol++) {
+							dx = posX - ((int) posX);
+							try {
+								double[][] kernel = get4x4Submatrix(((int) posX), ((int) posY), iBand);
+								if (kernel == null) {
+									double[] k = getKernelDouble(((int) posX), ((int) posY), iBand);
+									rasterBuf.setElem(iRow, iCol, iBand, (double) getBilinearValue(dx, dy, k));
+								} else
+									rasterBuf.setElem(iRow, iCol, iBand, (double) getBSplineValue(dx, dy, kernel));
+							} catch (ArrayIndexOutOfBoundsException e) {
+								// System.out.println(posX + " " + posY);
+							}
+							posX += pxSize;
+						}
+						posY += pxSize;
+						percent = (iBand * h + iRow) * multip;
+						if (task.getEvent() != null)
+							task.manageEvent(task.getEvent());
+					}
+					break;
+				}
+			}
+		} catch (OperationNotSupportedException e) {
+			//This exception is only possible with a read only buffer
+		}
+		return rasterBuf;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.cachete.api.buffer.IBufferInterpolation#adjustRasterBicubicSplineInterpolation(int, int)
+	 */
+	public Buffer adjustRasterBicubicSplineInterpolation(int w, int h) throws ProcessInterruptedException {
+		TaskEventManager task = new DefaultTaskEventManager(this);
+
+		double pxSize = (double) buffer.getWidth() / (double) w;
+		BufferParamImpl params = new BufferParamImpl(w, h);
+		params.setDataType(buffer.getDataType());
+		params.setBandCount(buffer.getBandCount());
+		Buffer rasterBuf = manager.createBuffer(params);
+
+		double posX = pxSize / 2D;
+		double posY = posX;
+		double dx = 0D, dy = 0D;
+
+		try {
+			percent = 0;
+			double multip = 100.0D / (h * buffer.getBandCount());
+
+			for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) {
+				posY = pxSize / 2D;
+				switch (buffer.getDataType()) {
+				case RasterBuffer.TYPE_BYTE:
+					for (int iRow = 0; iRow < h; iRow++) {
+						dy = posY - ((int) posY);
+						posX = pxSize / 2D;
+						for (int iCol = 0; iCol < w; iCol++) {
+							dx = posX - ((int) posX);
+							try {
+								double[][] kernel = get4x4Submatrix(((int) posX), ((int) posY), iBand);
+								if (kernel == null) {
+									double[] k = getKernelByte(((int) posX), ((int) posY), iBand);
+									rasterBuf.setElem(iRow, iCol, iBand, (byte) ((byte) getBilinearValue(dx, dy, k) & 0xff));
+								} else
+									rasterBuf.setElem(iRow, iCol, iBand, (byte) ((byte) getBicubicSplineValue(dx, dy, kernel)));
+							} catch (ArrayIndexOutOfBoundsException e) {
+								// System.out.println(posX + " " + posY);
+							}
+							posX += pxSize;
+						}
+						posY += pxSize;
+						percent = (iBand * h + iRow) * multip;
+						if (task.getEvent() != null)
+							task.manageEvent(task.getEvent());
+					}
+					break;
+				case RasterBuffer.TYPE_SHORT:
+					for (int iRow = 0; iRow < h; iRow++) {
+						dy = posY - ((int) posY);
+						posX = pxSize / 2D;
+						for (int iCol = 0; iCol < w; iCol++) {
+							dx = posX - ((int) posX);
+							try {
+								double[][] kernel = get4x4Submatrix(((int) posX), ((int) posY), iBand);
+								if (kernel == null) {
+									double[] k = getKernelShort(((int) posX), ((int) posY), iBand);
+									rasterBuf.setElem(iRow, iCol, iBand, (short) ((short) getBilinearValue(dx, dy, k) & 0xffff));
+								} else
+									rasterBuf.setElem(iRow, iCol, iBand, (short) ((short) getBicubicSplineValue(dx, dy, kernel) & 0xffff));
+							} catch (ArrayIndexOutOfBoundsException e) {
+								// System.out.println(posX + " " + posY);
+							}
+							posX += pxSize;
+						}
+						posY += pxSize;
+						percent = (iBand * h + iRow) * multip;
+						if (task.getEvent() != null)
+							task.manageEvent(task.getEvent());
+					}
+					break;
+				case RasterBuffer.TYPE_INT:
+					for (int iRow = 0; iRow < h; iRow++) {
+						dy = posY - ((int) posY);
+						posX = pxSize / 2D;
+						for (int iCol = 0; iCol < w; iCol++) {
+							dx = posX - ((int) posX);
+							try {
+								double[][] kernel = get4x4Submatrix(((int) posX), ((int) posY), iBand);
+								if (kernel == null) {
+									double[] k = getKernelInt(((int) posX), ((int) posY), iBand);
+									rasterBuf.setElem(iRow, iCol, iBand, (int) ((int) getBilinearValue(dx, dy, k) & 0xffffffff));
+								} else
+									rasterBuf.setElem(iRow, iCol, iBand, (int) ((int) getBicubicSplineValue(dx, dy, kernel) & 0xffffffff));
+							} catch (ArrayIndexOutOfBoundsException e) {
+								// System.out.println(posX + " " + posY);
+							}
+							posX += pxSize;
+						}
+						posY += pxSize;
+						percent = (iBand * h + iRow) * multip;
+						if (task.getEvent() != null)
+							task.manageEvent(task.getEvent());
+					}
+					break;
+				case RasterBuffer.TYPE_FLOAT:
+					for (int iRow = 0; iRow < h; iRow++) {
+						dy = posY - ((int) posY);
+						posX = pxSize / 2D;
+						for (int iCol = 0; iCol < w; iCol++) {
+							dx = posX - ((int) posX);
+							try {
+								double[][] kernel = get4x4Submatrix(((int) posX), ((int) posY), iBand);
+								if (kernel == null) {
+									double[] k = getKernelFloat(((int) posX), ((int) posY), iBand);
+									rasterBuf.setElem(iRow, iCol, iBand, (float) getBilinearValue(dx, dy, k));
+								} else
+									rasterBuf.setElem(iRow, iCol, iBand, (float) getBicubicSplineValue(dx, dy, kernel));
+							} catch (ArrayIndexOutOfBoundsException e) {
+								// System.out.println(posX + " " + posY);
+							}
+							posX += pxSize;
+						}
+						posY += pxSize;
+						percent = (iBand * h + iRow) * multip;
+						if (task.getEvent() != null)
+							task.manageEvent(task.getEvent());
+					}
+					break;
+				case RasterBuffer.TYPE_DOUBLE:
+					for (int iRow = 0; iRow < h; iRow++) {
+						dy = posY - ((int) posY);
+						posX = pxSize / 2D;
+						for (int iCol = 0; iCol < w; iCol++) {
+							dx = posX - ((int) posX);
+							try {
+								double[][] kernel = get4x4Submatrix(((int) posX), ((int) posY), iBand);
+								if (kernel == null) {
+									double[] k = getKernelDouble(((int) posX), ((int) posY), iBand);
+									rasterBuf.setElem(iRow, iCol, iBand, (double) getBilinearValue(dx, dy, k));
+								} else
+									rasterBuf.setElem(iRow, iCol, iBand, (double) getBicubicSplineValue(dx, dy, kernel));
+							} catch (ArrayIndexOutOfBoundsException e) {
+								// System.out.println(posX + " " + posY);
+							}
+							posX += pxSize;
+						}
+						posY += pxSize;
+						percent = (iBand * h + iRow) * multip;
+						if (task.getEvent() != null)
+							task.manageEvent(task.getEvent());
+					}
+					break;
+				}
+			}
+		} catch (OperationNotSupportedException e) {
+			//This exception is only possible with a read only buffer
+		}
+		return rasterBuf;
+	}
+
+	/**
+	 * 
+	 * @param dx
+	 * @param dy
+	 * @param kernel
+	 * @return
+	 */
+	private double getBicubicSplineValue(double dx, double dy, double[][] kernel) {
+		int	i;
+		double a0, a2, a3, b1, b2, b3;
+		double[] c = new double[4];
+
+		for(i = 0; i < 4; i++) {
+			a0 = kernel[0][i] - kernel[1][i];
+			a2 = kernel[2][i] - kernel[1][i];
+			a3 = kernel[3][i] - kernel[1][i];
+
+			b1 = -a0 / 3.0 + a2 - a3 / 6.0;
+			b2 = a0 / 2.0 + a2 / 2.0;
+			b3 = -a0 / 6.0 - a2 / 2.0 + a3 / 6.0;
+
+			c[i] = kernel[1][i] + b1 * dx + b2 * (dx * dx) + b3 * (dx * dx * dx);
+		}
+
+		a0 = c[0] - c[1];
+		a2 = c[2] - c[1];
+		a3 = c[3] - c[1];
+
+		b1 = -a0 / 3.0 + a2 - a3 / 6.0;
+		b2 =  a0 / 2.0 + a2 / 2.0;
+		b3 = -a0 / 6.0 - a2 / 2.0 + a3 / 6.0;
+
+		return( c[1] + b1 * dy + b2 * (dy * dy) + b3 * (dy * dy * dy) );
+	}
+
+	/**
+	 * 
+	 * @param dx
+	 * @param dy
+	 * @param kernel
+	 * @return
+	 */
+	private double getBSplineValue(double dx, double dy, double[][] kernel) {
+		int i = 0, ix = 0, iy = 0;
+		double px = 0, py = 0, z = 0;
+		double[] Rx = new double[4];
+		double[] Ry = new double[4];
+
+		for(i = 0, px = -1.0 - dx, py = -1.0 - dy; i < 4; i++, px++, py++){
+			Rx[i]	= 0.0;
+			Ry[i]	= 0.0;
+
+			if( (z = px + 2.0) > 0.0 )
+				Rx[i] += z * z * z;
+			if( (z = px + 1.0) > 0.0 )
+				Rx[i] += -4.0 * z * z * z;
+			if( (z = px + 0.0) > 0.0 )
+				Rx[i] += 6.0 * z * z * z;
+			if( (z = px - 1.0) > 0.0 )
+				Rx[i] += -4.0 * z * z * z;
+			if( (z = py + 2.0) > 0.0 )
+				Ry[i] += z * z * z;
+			if( (z = py + 1.0) > 0.0 )
+				Ry[i] += -4.0 * z * z * z;
+			if( (z = py + 0.0) > 0.0 )
+				Ry[i] += 6.0 * z * z * z;
+			if( (z = py - 1.0) > 0.0 )
+				Ry[i] += -4.0 * z * z * z;
+
+			Rx[i] /= 6.0;
+			Ry[i] /= 6.0;
+		}
+
+		for(iy = 0, z = 0.0; iy < 4; iy++) {
+			for(ix = 0; ix < 4; ix++) {
+				z	+= kernel[ix][iy] * Rx[ix] * Ry[iy];
+			}
+		}
+		return z;
+	}
+
+	/**
+	 * Calcula los valores N y Z para el m�todo bilinear y obtiene el valor del pixel como
+	 * Z / N
+	 * @param dx distancia en X desde el centro del pixel hasta el punto. Es un valor entre 0 y 1
+	 * @param dy distancia en Y desde el centro del pixel hasta el punto. Es un valor entre 0 y 1
+	 * @param kernel valor del pixel y alrededor 
+	 * @return valor del pixel
+	 */
+	private double getBilinearValue(double dx, double dy, double[] kernel) {
+		double z = 0.0, n = 0.0, d;
+		d = (1.0 - dx) * (1.0 - dy);
+		z += d * kernel[0];
+		n += d;
+
+		d = dx * (1.0 - dy);
+		z += d * kernel[1]; 
+		n += d;
+
+		d = (1.0 - dx) * dy;
+		z += d * kernel[2]; 
+		n += d;
+
+		d = dx * dy;
+		z += d * kernel[3]; 
+		n += d;
+
+		double b = 0;
+		if(n > 0.0)
+			b = (z / n);
+		return b;
+	}
+
+	/**
+	 * Calcula los valores N y Z para el m�todo de distancia inversa y calcula el valor del
+	 * pixel como Z / N.
+	 * @param dx distancia en X desde el centro del pixel hasta el punto. Es un valor entre 0 y 1
+	 * @param dy distancia en Y desde el centro del pixel hasta el punto. Es un valor entre 0 y 1
+	 * @param kernel valor del pixel y alrededor 
+	 * @return valor del pixel
+	 */
+	private double getInverseDistanceValue(double dx, double dy, double[] kernel) {
+		double z = 0.0, n = 0.0, d;
+		d = 1.0 / Math.sqrt(dx * dx + dy * dy);
+		z += d * kernel[0];
+		n += d;
+
+		d = 1.0 / Math.sqrt((1.0 - dx) * ( 1.0 - dx) + dy * dy);
+		z += d * kernel[1]; 
+		n += d;
+
+		d = 1.0 / Math.sqrt(dx*dx + (1.0-dy)*(1.0-dy));
+		z += d * kernel[2]; 
+		n += d;
+
+		d = 1.0 / Math.sqrt((1.0 - dx) *( 1.0 - dx) + (1.0 - dy) * (1.0 - dy));
+		z += d * kernel[3]; 
+		n += d;
+
+		double b = 0;
+		if(n > 0.0)
+			b = (z / n);
+		return b;
+	}
+
+	/**
+	 * Obtiene un kernel de 4x4 elementos. Si alguno de los elementos se sale de la imagen
+	 * , por ejemplo en los bordes devuelve null.  
+	 * @param x
+	 * @param y
+	 * @param band
+	 * @return
+	 */
+	private double[][] get4x4Submatrix(int x, int y, int band) {
+		int	ix, iy, px, py;
+		double[][] z_xy = new double[4][4];
+
+		for(iy = 0, py = y - 1; iy < 4; iy++, py++) {
+			for(ix = 0, px = x - 1; ix < 4; ix++, px++) {
+				if (!buffer.isInside(px, py))
+					return null;
+				else {
+					switch(buffer.getDataType()) {
+					case Buffer.TYPE_BYTE: z_xy[ix][iy] = (buffer.getElemByte(py, px, band) & 0xff); break;
+					case Buffer.TYPE_SHORT: z_xy[ix][iy] = (buffer.getElemShort(py, px, band) & 0xffff); break;
+					case Buffer.TYPE_INT: z_xy[ix][iy] = (buffer.getElemInt(py, px, band) & 0xffffffff); break;
+					case Buffer.TYPE_FLOAT: z_xy[ix][iy] = buffer.getElemFloat(py, px, band); break;
+					case Buffer.TYPE_DOUBLE: z_xy[ix][iy] = buffer.getElemDouble(py, px, band); break;
+					}
+				}
+			}
+		}
+		return z_xy;
+	}
+	  
+	/**
+	 * Obtiene un kernel de cuatro elemento que corresponden a los pixeles (x, y), (x + 1, y),
+	 * (x, y + 1), (x + 1, y + 1). Si los pixeles x + 1 o y + 1 se salen del raster de origen
+	 * se tomar� x e y. 
+	 * @param x Coordenada X del pixel inicial
+	 * @param y Coordenada Y del pixel inicial
+	 * @param band N�mero de banda.
+	 * @return Kernel solicitado en forma de array.
+	 */
+	private double[] getKernelByte(int x, int y, int band) {
+		double[] d = new double[4];
+		d[0] = (buffer.getElemByte(y, x, band) & 0xff);
+		int nextX = ((x + 1) >= buffer.getWidth()) ? x : (x + 1);
+		int nextY = ((y + 1) >= buffer.getHeight()) ? y : (y + 1);
+		d[1] = (buffer.getElemByte(y, nextX, band) & 0xff);
+		d[2] = (buffer.getElemByte(nextY, x, band) & 0xff);
+		d[3] = (buffer.getElemByte(nextY, nextX, band) & 0xff);
+		return d;
+	}
+
+	/**
+	 * Obtiene un kernel de cuatro elemento que corresponden a los pixeles (x, y), (x + 1, y),
+	 * (x, y + 1), (x + 1, y + 1). Si los pixeles x + 1 o y + 1 se salen del raster de origen
+	 * se tomar� x e y. 
+	 * @param x Coordenada X del pixel inicial
+	 * @param y Coordenada Y del pixel inicial
+	 * @param band N�mero de banda.
+	 * @return Kernel solicitado en forma de array.
+	 */
+	private double[] getKernelShort(int x, int y, int band) {
+		double[] d = new double[4];
+		d[0] = (buffer.getElemShort(y, x, band) & 0xffff);
+		int nextX = ((x + 1) >= buffer.getWidth()) ? x : (x + 1);
+		int nextY = ((y + 1) >= buffer.getHeight()) ? y : (y + 1);
+		d[1] = (buffer.getElemShort(y, nextX, band) & 0xffff);
+		d[2] = (buffer.getElemShort(nextY, x, band) & 0xffff);
+		d[3] = (buffer.getElemShort(nextY, nextX, band) & 0xffff);
+		return d;
+	}
+
+	/**
+	 * Obtiene un kernel de cuatro elemento que corresponden a los pixeles (x, y), (x + 1, y),
+	 * (x, y + 1), (x + 1, y + 1). Si los pixeles x + 1 o y + 1 se salen del raster de origen
+	 * se tomar� x e y. 
+	 * @param x Coordenada X del pixel inicial
+	 * @param y Coordenada Y del pixel inicial
+	 * @param band N�mero de banda.
+	 * @return Kernel solicitado en forma de array.
+	 */
+	private double[] getKernelInt(int x, int y, int band) {
+		double[] d = new double[4];
+		d[0] = (buffer.getElemInt(y, x, band) & 0xffffffff);
+		int nextX = ((x + 1) >= buffer.getWidth()) ? x : (x + 1);
+		int nextY = ((y + 1) >= buffer.getHeight()) ? y : (y + 1);
+		d[1] = (buffer.getElemInt(y, nextX, band) & 0xffffffff);
+		d[2] = (buffer.getElemInt(nextY, x, band) & 0xffffffff);
+		d[3] = (buffer.getElemInt(nextY, nextX, band) & 0xffffffff);
+		return d;
+	}
+
+	/**
+	 * Obtiene un kernel de cuatro elemento que corresponden a los pixeles (x, y), (x + 1, y),
+	 * (x, y + 1), (x + 1, y + 1). Si los pixeles x + 1 o y + 1 se salen del raster de origen
+	 * se tomar� x e y. 
+	 * @param x Coordenada X del pixel inicial
+	 * @param y Coordenada Y del pixel inicial
+	 * @param band N�mero de banda.
+	 * @return Kernel solicitado en forma de array.
+	 */
+	private double[] getKernelFloat(int x, int y, int band) {
+		double[] d = new double[4];
+		d[0] = buffer.getElemFloat(y, x, band);
+		int nextX = ((x + 1) >= buffer.getWidth()) ? x : (x + 1);
+		int nextY = ((y + 1) >= buffer.getHeight()) ? y : (y + 1);
+		d[1] = buffer.getElemFloat(y, nextX, band);
+		d[2] = buffer.getElemFloat(nextY, x, band);
+		d[3] = buffer.getElemFloat(nextY, nextX, band);
+		return d;
+	}
+
+	/**
+	 * Obtiene un kernel de cuatro elemento que corresponden a los pixeles (x, y), (x + 1, y),
+	 * (x, y + 1), (x + 1, y + 1). Si los pixeles x + 1 o y + 1 se salen del raster de origen
+	 * se tomar� x e y. 
+	 * @param x Coordenada X del pixel inicial
+	 * @param y Coordenada Y del pixel inicial
+	 * @param band N�mero de banda.
+	 * @return Kernel solicitado en forma de array.
+	 */
+	private double[] getKernelDouble(int x, int y, int band) {
+		double[] d = new double[4];
+		d[0] = buffer.getElemDouble(y, x, band);
+		int nextX = ((x + 1) >= buffer.getWidth()) ? x : (x + 1);
+		int nextY = ((y + 1) >= buffer.getHeight()) ? y : (y + 1);
+		d[1] = buffer.getElemDouble(y, nextX, band);
+		d[2] = buffer.getElemDouble(nextY, x, band);
+		d[3] = buffer.getElemDouble(nextY, nextX, band);
+		return d;
+	}
+	
+	/**
+	 * Obtiene el porcentaje del proceso de interpolacion
+	 * @return
+	 */
+	public int getPercent() {
+		return Math.min((int) percent, 100);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.task.IncrementableTask#isCancelable()
+	 */
+	public boolean isCancelable() {
+		return true;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.task.IncrementableTask#isPausable()
+	 */
+	public boolean isPausable() {
+		return false;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.task.BaseIncrementableTask#setPercent(int)
+	 */
+	public void setPercent(int value) {
+		this.percent = value;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.task.IncrementableTask#getLog()
+	 */
+	public String getLog() {
+		return null;
+	}
+}
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/BufferInterpolationImpl.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/BufferCacheDefaultImplLibrary.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/BufferCacheDefaultImplLibrary.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/BufferCacheDefaultImplLibrary.java	(revision 3222)
@@ -0,0 +1,50 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.buffer.impl;
+
+import org.gvsig.raster.cache.buffer.BufferCacheLibrary;
+import org.gvsig.raster.cache.buffer.BufferCacheLocator;
+import org.gvsig.tools.library.AbstractLibrary;
+import org.gvsig.tools.library.LibraryException;
+
+/**
+ * Library for default implementation initialization and configuration.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ * @version $Id$
+ */
+public class BufferCacheDefaultImplLibrary extends AbstractLibrary {
+	
+	public BufferCacheDefaultImplLibrary() {
+		registerAsImplementationOf(BufferCacheLibrary.class);
+	}
+
+	protected void doInitialize() throws LibraryException {
+        BufferCacheLocator.registerManager(BufferCacheManagerImpl.class);
+	}
+
+    @Override
+    protected void doPostInitialize() throws LibraryException {
+
+    }
+
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/BufferCacheDefaultImplLibrary.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/PageBuffer.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/PageBuffer.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/PageBuffer.java	(revision 3222)
@@ -0,0 +1,90 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+import org.gvsig.raster.cache.buffer.exception.BandNotCompatibleException;
+import org.gvsig.raster.cache.buffer.impl.memory.MemoryBand;
+import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer;
+
+/**
+ * This class represent a cache page.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class PageBuffer extends RasterMemoryBuffer {
+	private ArrayList<HDDPage>	           hddPages = null;
+	
+	/**
+	 * Constructor
+	 * @param dataType
+	 * @param width
+	 * @param height
+	 * @param bandNr
+	 * @param malloc
+	 */
+	public PageBuffer(int dataType, int width, int height, int bandNr, boolean malloc) {
+		super(dataType, width, height, bandNr, malloc);
+	}
+		
+	/**
+	 * Asigna la lista de paginas de disco
+	 * @param hddList Lista de p�ginas de disco
+	 */
+	public void setHddPages(ArrayList<HDDPage> hddList) {
+		this.hddPages = hddList;
+	}
+	
+	/**
+	 * Carga una p�gina especificada en el par�metro nPag con los datos necesarios.
+	 * Para esto recorre todas las bandas de la p�gina llamando al load de cada una.
+	 *   
+	 * @param nPag N�mero de p�gina a cargar
+	 */
+	public void loadPage(int nPag) throws InterruptedException {
+		hddPages.get(nPag).loadPage(this);	
+	}
+	
+	/**
+	 * Salva una p�gina especificada en el par�metro nPag a disco. 
+	 * Para esto recorre todas las bandas de la p�gina llamando al save de cada una.
+	 *   
+	 * @param nPag N�mero de p�gina a salvar
+	 * @throws IOException
+	 */
+	public void savePage(int nPag) throws IOException {
+		hddPages.get(nPag).savePage(this);
+	}
+
+	/**
+	 * Set a band buffer by reference
+	 * @param b
+	 */
+	public void setBuffer(MemoryBand b) {
+		setWidth(b.getWidth());
+		setHeight(b.getHeight());
+		setDataType(b.getDataType());
+		setBandCount(b.getBandNumber());
+		bands.clear();
+		bands.add(b);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see java.lang.Object#clone()
+	 */
+	public Object clone() {
+		PageBuffer rmb = new PageBuffer(getDataType(), getWidth(), getHeight(), getBandCount(), false);
+		for(int iBand = 0; iBand < getBandCount(); iBand ++) {
+    		MemoryBand band = bands.get(iBand).clone();
+    		try {
+    			rmb.removeBand(iBand);
+				rmb.assignBand(iBand, band);
+			} catch (BandNotCompatibleException e) {
+			}
+    	}
+    	return rmb;
+	}
+
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/PageBuffer.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/CacheBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/CacheBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/CacheBand.java	(revision 3222)
@@ -0,0 +1,348 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache;
+
+import org.gvsig.raster.cache.buffer.exception.InvalidPageNumberException;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.impl.BandImpl;
+
+
+/**
+ * Clase base para las bandas de un RasterMemoryBuffer.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public abstract class CacheBand extends BandImpl {	
+	protected Cache            cache          = null;
+	protected LRUAlgorithm     lru            = null;
+	/**
+	 * Band number in the list of the raster
+	 */
+	protected int              nBand          = -1;
+	private int                lastLine       = -1;
+	
+    /**
+     * Constructor a llamar desde las clases hijas
+     */
+    public CacheBand(Cache cache, LRUAlgorithm lru, int nBand) {
+    	super(	cache.getDataSourceWidth(), 
+    			cache.getDataSourceHeight());
+    	this.cache = cache;
+    	this.lru = lru;
+    	this.nBand = nBand;
+    }
+   	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getBlockHeight()
+	 */
+	public int getBlockSize() {
+		return cache.getHPag();
+	}
+	
+	/**
+	 * Get associated cache
+	 * @return Cache
+	 */
+	public Cache getCache() {
+		return cache;
+	}
+	
+	/**
+	 * Set associated cache
+	 * @param Cache
+	 */
+	public void setCache(Cache cache) {
+		this.cache = cache;
+	}
+	
+	/**
+	 * Get LruAlgorithm class associated
+	 * @return LRUAlgorithm
+	 */
+	public LRUAlgorithm getLruAlgorithm() {
+		return lru;
+	}
+
+	/**
+	 * Set LruAlgorithm class associated
+	 * @param LRUAlgorithmVertImpl
+	 */
+	public void setLruAlgorithm(LRUAlgorithm lru) {
+		this.lru = lru;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setBandNumber(int)
+	 */
+	public void setBandNumber(int band) {
+		this.nBand = band;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getBandNumber()
+	 */
+	public int getBandNumber() {
+		return this.nBand;
+	}
+	
+	protected boolean exists(int line) {
+        // Store the last line checked so we don't check it again for each
+        // pixel of the same line
+        if (line != lastLine) {
+            try {
+                lru.cacheAccess(line, false);
+                this.lastLine = line;
+            } catch (InvalidPageNumberException e) {
+                return false;
+            } catch (InterruptedException e) {
+				return false;
+			}
+        }
+        return true;
+    }
+		
+	//***********************************************
+    //Getting a block of data
+	
+    /*
+     * (non-Javadoc)
+     * @see org.gvsig.raster.buffer.IRasterBand#getByteBlock(int)
+     */
+	public byte[][] getByteBlock(int block){
+		return null;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getShortBlock(int)
+	 */
+	public short[][] getShortBlock(int block){
+		return null;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getIntBlock(int)
+	 */
+	public int[][] getIntBlock(int block){
+		return null;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getFloatBlock(int)
+	 */
+	public float[][] getFloatBlock(int block){
+		return null;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getDoubleBlock(int)
+	 */
+	public double[][] getDoubleBlock(int block){
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#assign(byte)
+	 */
+	public void assign(byte value) {}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#assign(short)
+	 */
+	public void assign(short value) {}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#assign(int)
+	 */
+	public void assign(int value) {}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#assign(float)
+	 */
+	public void assign(float value) {}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#assign(double)
+	 */
+	public void assign(double value) {}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getElemByte(int, int)
+	 */
+	public byte getElemByte(int line, int col) {
+		return 0;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getElemDouble(int, int)
+	 */
+	public double getElemDouble(int line, int col) {
+		return 0;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getElemFloat(int, int)
+	 */
+	public float getElemFloat(int line, int col) {
+		return 0;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getElemInt(int, int)
+	 */
+	public int getElemInt(int line, int col) {
+		return 0;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getElemShort(int, int)
+	 */
+	public short getElemShort(int line, int col) {
+		return 0;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getByteLine(int)
+	 */
+	public byte[] getByteLine(int line) throws OperationNotSupportedException {
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getDoubleLine(int)
+	 */
+	public double[] getDoubleLine(int line) throws OperationNotSupportedException {
+		return null;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getFloatLine(int)
+	 */
+	public float[] getFloatLine(int line) throws OperationNotSupportedException {
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getIntLine(int)
+	 */
+	public int[] getIntLine(int line) throws OperationNotSupportedException {
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getShortLine(int)
+	 */
+	public short[] getShortLine(int line) throws OperationNotSupportedException {
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setElem(int, int, byte)
+	 */
+	public void setElem(int line, int col, byte data) {}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setElem(int, int, short)
+	 */
+	public void setElem(int line, int col, short data) {}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setElem(int, int, int)
+	 */
+	public void setElem(int line, int col, int data) {}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setElem(int, int, float)
+	 */
+	public void setElem(int line, int col, float data) {}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setElem(int, int, double)
+	 */
+	public void setElem(int line, int col, double data) {}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setByteLine(byte[], int)
+	 */
+	public void setByteLine(byte[] data, int line) throws OperationNotSupportedException {}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setDoubleLine(double[], int)
+	 */
+	public void setDoubleLine(double[] data, int line) throws OperationNotSupportedException {}
+		
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setFloatLine(float[], int)
+	 */
+	public void setFloatLine(float[] data, int line) {}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setIntLine(int[], int)
+	 */
+	public void setIntLine(int[] data, int line) throws OperationNotSupportedException {}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setShortLine(short[], int)
+	 */
+	public void setShortLine(short[] data, int line) throws OperationNotSupportedException {}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setByteBlock(byte[][], int)
+	 */
+	public void setByteBlock(byte[][] data, int block) {}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setShortBlock(short[][], int)
+	 */
+	public void setShortBlock(short[][] data, int block) {}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setIntBlock(int[][], int)
+	 */
+	public void setIntBlock(int[][] data, int block) {}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setFloatBlock(float[][], int)
+	 */
+	public void setFloatBlock(float[][] data, int block) {}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setDoubleBlock(double[][], int)
+	 */
+	public void setDoubleBlock(double[][] data, int block) {}
+
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/CacheBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/CacheStruct.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/CacheStruct.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/CacheStruct.java	(revision 3222)
@@ -0,0 +1,401 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache;
+
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+
+/**
+ * Esta clase representa la estructura en memoria de la cache. Contiene el n�mero de p�ginas 
+ * as� como los subconjuntos en las que se divide. Tendr� tambi�n datos como en ancho y alto de
+ * cada p�gina y tama�o en memoria de esta. 
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ *
+ */
+public class CacheStruct {
+	//******************* PARAMETERS ***************************
+	/**
+	 * Tama�o aproximado de cach� en Megas. Si este valor es alto cabr�n muchas p�ginas en memoria 
+	 * a la vez y si es bajo cabr�n pocas. Hay que tener en cuenta que al instanciar se convertira en bytes
+	 * para su mejor tratamiento. Al llamar al constructor esta variable contendr� el tama�o exacto
+	 * de la cache en bytes. El tama�o aqu� especificado es aproximado. Este variar� dependiendo de los
+	 * par�metros del raster a cachear ya que las p�ginas deben tener una altura potencia de 2.
+	 */
+	protected long     cacheSize           = BufferCacheManagerImpl.cacheSize;
+	/**
+	 * Tama�o m�ximo de la p�gina en Megas. Hay que tener en cuenta que al instanciar se convertira en bytes
+	 * para su mejor tratamiento. Al llamar al constructor esta variable contendr� el tama�o exacto
+	 * de la p�gina en bytes
+	 */
+	protected double   pageSize            = BufferCacheManagerImpl.pageSize;
+	/**
+	 * N�mero de p�ginas que tiene cada conjunto
+	 */
+	protected int      pagsPerGroup        = BufferCacheManagerImpl.pagsPerGroup;
+	//****************** END PARAMETERS ************************
+		
+	protected int[]    possiblePageHeights = {2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536};
+		
+	/**
+	 * Altura de la p�gina de cada banda en l�neas.
+	 */
+	protected int      hPag                = 1;
+	/**
+	 * Para extraer el desplazamiento de una direcci�n (l�nea de raster) hay que hacer una operaci�n And con 
+	 * con la altura de la p�gina -1. Por ejemplo, una p�gina de 16 l�neas de altura el desplazamiento ser�
+	 * 16 - 1 = 15 porque 15 en binario es 1111.
+	 * 
+	 * Si queremos acceder a la linea del raster n�mero 83 (1010011) realizando la operaci�n And con el valor del
+	 * desplazamiento obtenemos (0001111 & 1010011 = 0000011), es decir el valor 3 en decimal. Esto quiere decir
+	 * que la l�nea 83 del raster es la 3 de su p�gina. 
+	 */
+	protected int      offset              = 1;
+	/**
+	 * N�mero de p�ginas en cach�
+	 */
+	protected int      nPags               = 0;
+	/**
+	 * N�mero de estructuras PageBandBuffer que tendr� el objeto PageBuffer. Cada una de estas
+	 * corresponde a una banda del buffer cacheada.
+	 */
+	protected int      nPageBandBuffers    = 0;
+	/**
+	 * N�mero de grupos
+	 */
+	protected int      nGroups             = 0;
+	/**
+	 * N�mero de bits para el desplazamiento de una p�gina. Por ejemplo, una p�gina de 64 l�neas
+	 * tendr� un bitsPag = 6
+	 */
+	protected int      bitsPag             = 0;
+	/**
+	 * N�mero total de p�ginas en las que se divide el raster
+	 */
+	protected int      nTotalPags          = 0;
+	/**
+	 * Tama�o de cache por banda del raster (cacheSize / NBandas)
+	 */
+	protected long     cacheSizePerBand    = 0;
+	/**
+	 * Tama�o de p�gina por banda del raster (pagSize / NBandas)
+	 */
+	protected long     pageSizePerBand     = 0;
+	/**
+	 * Tipo de dato de la cach�
+	 */
+	protected int	   dataType            = 0;
+	
+	protected int      width               = 0;
+	protected int      height              = 0;
+	
+	/**
+	 * Calcula los par�metros del tama�o de cach� y de p�gina, asi como la altura de las mismas y el n�mero
+	 * de grupos que salen en cach�.
+	 * @param nBands N�mero de bandas del raster
+	 * @param dataType Tipo de dato de la imagen
+	 * @param dataSourceWidth ancho de cada l�nea completa del raster.
+	 */
+	public CacheStruct(int nBands, int dataType, int dataSourceWidth, int dataSourceHeight){
+		this.width = dataSourceWidth;
+		this.height = dataSourceHeight;
+		init(nBands, dataType, dataSourceWidth, dataSourceHeight);
+	}
+	
+	/**
+	 * Constructor de una sola banda y sin el calculo de par�metros. Estos deben ser asignados
+	 * posteriorimente. Esta llamada es usada en casos especiales de creaci�n de buffers cacheados.
+	 */
+	public CacheStruct() {
+	}
+	
+	/**
+	 * Constructor solo para test. No utilizar con un uso normal de la librer�a
+	 * Calcula los par�metros del tama�o de cach� y de p�gina, asi como la altura de las mismas y el n�mero
+	 * de grupos que salen en cach�.
+	 * @param nBands N�mero de bandas del raster
+	 * @param dataType Tipo de dato de la imagen
+	 * @param dataSourceWidth ancho de cada l�nea completa del raster.
+	 */
+	public CacheStruct(int nBands, int dataType, int dataSourceWidth, int dataSourceHeight, long cacheSize, long pageSize) {
+		this.cacheSize = cacheSize;
+		this.pageSize = pageSize;
+		init(nBands, dataType, dataSourceWidth, dataSourceHeight);
+	}
+	
+	private void init(int nBands, int dataType, int dataSourceWidth, int dataSourceHeight) {
+		this.nPageBandBuffers = nBands;
+		this.dataType = dataType;
+		
+		//Pasamos los megas a bytes
+		cacheSize = cacheSize * 1048576;
+		pageSize = pageSize * 1048576;
+		
+		cacheSizePerBand = (long)(cacheSize / nBands);
+		pageSizePerBand = (long)(pageSize / nBands);
+				
+		//int dataSize = 0;
+		int dataSizePerBand = 0;
+		if (dataType == Buffer.TYPE_BYTE) {
+			dataSizePerBand = 1;
+		} else if ((dataType == Buffer.TYPE_SHORT) | (dataType == Buffer.TYPE_USHORT)) {
+			dataSizePerBand = 2;
+        } else if (dataType == Buffer.TYPE_INT) {
+        	dataSizePerBand = 4;
+        } else if (dataType == Buffer.TYPE_FLOAT) {
+        	dataSizePerBand = 4;
+        } else if (dataType == Buffer.TYPE_DOUBLE) {
+        	dataSizePerBand = 8;
+        }
+		//dataSize = dataSizePerBand * nBands;
+				
+		//La altura de la p�gina depende del ancho de esta y del tipo de dato
+		for(int i = (possiblePageHeights.length - 1); i >= 0; i --) {
+			long size = (long)dataSourceWidth * (long)possiblePageHeights[i] * (long)dataSizePerBand; 
+			if(size <= pageSizePerBand){
+				hPag = possiblePageHeights[i];
+				break;
+			}
+		}
+		//Calculamos el tama�o de p�gina en bytes 
+		pageSizePerBand = dataSourceWidth * hPag * dataSizePerBand;
+		
+		//Calculamos el n�mero de p�ginas que tendr� el buffer completo
+		nPags = (int)(cacheSizePerBand / pageSizePerBand);
+				
+		while((nPags % pagsPerGroup) != 0)
+			nPags ++;	
+		
+		//Recalculamos el tama�o de la cach�
+		cacheSizePerBand = (long)(pageSizePerBand * nPags);
+		
+		//Calculamos el n�mero de grupos de cach�
+		nGroups = (int)(nPags / pagsPerGroup);
+		
+		int h = hPag; 
+		while(h > 1){
+			h >>= 1;
+			bitsPag ++;
+		}
+		
+		//Calculamos el n�mero total de p�ginas en cach�
+		nTotalPags = (int)(dataSourceHeight / hPag);
+		if((dataSourceHeight % hPag) != 0)
+			nTotalPags ++;
+		
+		offset = hPag - 1;
+		
+		cacheSize = cacheSizePerBand * nBands;
+		pageSize = pageSizePerBand * nBands;
+	}
+
+	/**
+	 * Obtiene el tama�o de cach� en Bytes
+	 * @return Tama�o de cach� en Bytes
+	 */
+	public long getCacheSize() {
+		return cacheSize;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.cachete.buffer.stripecache.ICacheStruct#getHPag()
+	 */
+	public int getHPag() {
+		return hPag;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.cachete.buffer.stripecache.ICacheStruct#setHPag(int)
+	 */
+	public void setHPag(int hPag){
+		this.hPag = hPag;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.cachete.buffer.stripecache.ICacheStruct#getNBands()
+	 */
+	public int getNBands() {
+		return nPageBandBuffers;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.cachete.buffer.stripecache.ICacheStruct#setNBands(int)
+	 */
+	public void setNBands(int nBands){
+		this.nPageBandBuffers = nBands;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.cachete.buffer.stripecache.ICacheStruct#getNPags()
+	 */
+	public int getNPags() {
+		return nPags;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.cachete.buffer.stripecache.ICacheStruct#setNPags(int)
+	 */
+	public void setNPags(int nPags) {
+		this.nPags = nPags;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.cachete.buffer.stripecache.ICacheStruct#getPagSize()
+	 */
+	public long getPagSize() {
+		return (long)pageSize;
+	}
+		
+	/*
+	 * (non-Javadoc)
+	 * @see org.cachete.buffer.stripecache.ICacheStruct#getPagsPerGroup()
+	 */
+	public int getPagsPerGroup() {
+		return pagsPerGroup;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.cachete.buffer.stripecache.ICacheStruct#getNGroups()
+	 */
+	public int getNGroups() {
+		return nGroups;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.cachete.buffer.stripecache.ICacheStruct#setNGroups(int)
+	 */
+	public void setNGroups(int nGroups){
+		this.nGroups = nGroups;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.cachete.buffer.stripecache.ICacheStruct#getNTotalPags()
+	 */
+	public int getNTotalPags() {
+		return nTotalPags;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.cachete.buffer.stripecache.ICacheStruct#setNTotalPags(int)
+	 */
+	public void setNTotalPags(int nPags){
+		this.nTotalPags = nPags;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.cachete.buffer.stripecache.ICacheStruct#getBitsPag()
+	 */
+	public int getBitsPag() {
+		return bitsPag;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.cachete.buffer.stripecache.ICacheStruct#setBitsPag(int)
+	 */
+	public void setBitsPag(int bitsPag){
+		this.bitsPag = bitsPag;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.cachete.buffer.stripecache.ICacheStruct#getOffset()
+	 */
+	public int getOffset() {
+		return offset;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.cachete.buffer.stripecache.ICacheStruct#setOffset(int)
+	 */
+	public void setOffset(int offset){
+		this.offset = offset;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.cachete.buffer.stripecache.ICacheStruct#getCacheSizePerBand()
+	 */
+	public long getCacheSizePerBand() {
+		return cacheSizePerBand;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.cachete.buffer.stripecache.ICacheStruct#setCacheSizePerBand(long)
+	 */
+	public void setCacheSizePerBand(long cacheSizePerBand) {
+		this.cacheSizePerBand = cacheSizePerBand;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.cachete.buffer.stripecache.ICacheStruct#getPagSizePerBand()
+	 */
+	public long getPagSizePerBand() {
+		return pageSizePerBand;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.cachete.buffer.stripecache.ICacheStruct#setPagSizePerBand(long)
+	 */
+	public void setPagSizePerBand(long pagSizePerBand) {
+		this.pageSizePerBand = pagSizePerBand;
+	}
+	
+	/**
+	 * Imprime la informaci�n de estructura de cach�
+	 */
+	public void show() {
+		System.out.println("Cache (total size):" + cacheSize);
+		System.out.println("Page (total size):" + pageSize);
+		System.out.println("Cache (size per band):" + cacheSizePerBand);
+		System.out.println("Page (size per band):" + pageSizePerBand);
+		
+		System.out.println("Number of Pags del raster:" + nTotalPags);
+		System.out.println("Number of Pags de cache:" + nPags);
+		System.out.println("Number of Bands:" + nPageBandBuffers);
+		System.out.println("Number of Groups:" + nGroups);
+		System.out.println("Pages per group:" + pagsPerGroup);
+		System.out.println("bits per pag:" + bitsPag);
+		System.out.println("Page Height (in lines):" + hPag);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.cachete.buffer.stripecache.ICacheStruct#getDataType()
+	 */
+	public int getDataType() {
+		return dataType;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.cachete.buffer.stripecache.ICacheStruct#setDataType(int)
+	 */
+	public void setDataType(int dataType) {
+		this.dataType = dataType;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see java.lang.Object#clone()
+	 */
+	public Object clone() {
+		CacheStruct struct = new CacheStruct(nPageBandBuffers, dataType, width, height);
+		return struct;
+	}
+
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/CacheStruct.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/HDDPageList.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/HDDPageList.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/HDDPageList.java	(revision 3222)
@@ -0,0 +1,158 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.exception.WrongParameterException;
+import org.gvsig.raster.cache.buffer.impl.RasterBuffer;
+import org.gvsig.raster.cache.buffer.impl.io.BufferDataSourceImpl;
+
+/**
+ * List of pages in cache structure
+ * 
+ * 21/10/2008
+ * @author Nacho Brodin nachobrodin@gmail.com
+ */
+public class HDDPageList extends ArrayList<HDDPage> {
+	private static final long   serialVersionUID = 1L;
+	private BufferDataSource    dataSource       = null;
+
+	/**
+	 * Make the list of pages and the structure of pages in memory  
+	 * @param nTotalPags
+	 * @param nPagsCache
+	 * @param nBands
+	 */
+	public HDDPageList(int nTotalPags, int nBands) {
+		dataSource = new BufferDataSourceImpl();
+		for (int iPag = 0; iPag < nTotalPags; iPag++) 
+			add(new HDDPage(iPag, nBands, dataSource));
+	}
+		
+	/**
+	 * Remove a band from disk
+	 * @param nBand Band number to remove
+	 * @throws IOException 
+	 */
+	public void removeBand(int pos) throws IOException {
+		for (int iPage = 0; iPage < size(); iPage++)
+			get(iPage).removeBand(pos);
+	}
+	
+	/**
+	 * Add a band in the selected position
+	 * @param pos Position to add a band
+	 * @throws IOException 
+	 */
+	public void addBand(int pos, PageBuffer pb) throws IOException {
+		for (int iPage = 0; iPage < size(); iPage++)
+			get(iPage).addBand(pos, pb);
+	}
+	
+	/**
+	 * Add a band in the selected position
+	 * @param  pos 
+	 *         Position to add a band
+	 * @throws IOException 
+	 */
+	public void addBand(int pos, Band bandToAdd, PageBuffer buf) throws IOException {
+		switch (bandToAdd.getDataType()) {
+		case RasterBuffer.TYPE_BYTE:
+			for (int iPage = 0; iPage < size(); iPage++) {
+				//Assign the buffer to save by reference
+				byte[][] block = bandToAdd.getByteBlock(iPage);
+				org.gvsig.raster.cache.buffer.impl.memory.ByteBand bb = 
+						new org.gvsig.raster.cache.buffer.impl.memory.ByteBand(buf.getWidth(), buf.getHeight(), pos, false);
+				bb.setByteBlock(block, iPage);
+				buf.setBuffer(bb);
+				get(iPage).addBand(pos, buf);
+			}	
+			break;
+		case RasterBuffer.TYPE_SHORT:
+			for (int iPage = 0; iPage < size(); iPage++) {
+				//Assign the buffer to save by reference
+				short[][] block = bandToAdd.getShortBlock(iPage);
+				org.gvsig.raster.cache.buffer.impl.memory.ShortBand sb = 
+						new org.gvsig.raster.cache.buffer.impl.memory.ShortBand(buf.getWidth(), buf.getHeight(), pos, false);
+				sb.setShortBlock(block, iPage);
+				buf.setBuffer(sb);
+				get(iPage).addBand(pos, buf);
+			}	
+			break;
+		case RasterBuffer.TYPE_INT:
+			for (int iPage = 0; iPage < size(); iPage++) {
+				//Assign the buffer to save by reference
+				int[][] block = bandToAdd.getIntBlock(iPage);
+				org.gvsig.raster.cache.buffer.impl.memory.IntBand ib = 
+						new org.gvsig.raster.cache.buffer.impl.memory.IntBand(buf.getWidth(), buf.getHeight(), pos, false);
+				ib.setIntBlock(block, iPage);
+				buf.setBuffer(ib);
+				get(iPage).addBand(pos, buf);
+			}	
+			break;
+		case RasterBuffer.TYPE_FLOAT:
+			for (int iPage = 0; iPage < size(); iPage++) {
+				//Assign the buffer to save by reference
+				float[][] block = bandToAdd.getFloatBlock(iPage);
+				org.gvsig.raster.cache.buffer.impl.memory.FloatBand fb = 
+						new org.gvsig.raster.cache.buffer.impl.memory.FloatBand(buf.getWidth(), buf.getHeight(), pos, false);
+				fb.setFloatBlock(block, iPage);
+				buf.setBuffer(fb);
+				get(iPage).addBand(pos, buf);
+			}	
+			break;
+		case RasterBuffer.TYPE_DOUBLE:
+			for (int iPage = 0; iPage < size(); iPage++) {
+				//Assign the buffer to save by reference
+				double[][] block = bandToAdd.getDoubleBlock(iPage);
+				org.gvsig.raster.cache.buffer.impl.memory.DoubleBand db = 
+						new org.gvsig.raster.cache.buffer.impl.memory.DoubleBand(buf.getWidth(), buf.getHeight(), pos, false);
+				db.setDoubleBlock(block, iPage);
+				buf.setBuffer(db);
+				get(iPage).addBand(pos, buf);
+			}	
+			break;
+		}
+		
+	}
+	
+	/**
+	 * Swap bands accordint to positions selected in bandPosition parameter.
+	 * 
+	 * @param  bandPosition
+	 *         New order for the bands in the array. Each position in the array represent the old band
+	 *         .The number that it contains represent the new position of that band. For instance, an
+	 *         array with values {1, 0, 2, 3} means that it has four bands and the band number one is swaped
+	 *         with the band number zero. The bands two and three don't change its position in this example.   			
+	 * @throws WrongParameterException
+	 */
+	 public void swapBands(int[] bandPosition) throws WrongParameterException {
+		 for (int iPage = 0; iPage < size(); iPage++)
+				get(iPage).swapBands(bandPosition);
+	 }
+	
+	
+	/**
+	 * Limpia los trozos de cach� en disco y memoria. Despu�s del llamar a este 
+	 * m�todo no puede volver a usarse esta cach�.
+	 * @throws IOException 
+	 */
+	public void clearPageList() throws IOException {
+		for (int i = 0; i < size(); i++)
+			((HDDPage)get(i)).deletePage();
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see java.util.ArrayList#clone()
+	 */
+	public Object clone() {
+		HDDPageList clon = new HDDPageList(0, 0);
+		for (int i = 0; i < size(); i++) 
+			clon.add((HDDPage)get(i).clone());
+		return clon;
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/HDDPageList.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/LRUAlgorithm.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/LRUAlgorithm.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/LRUAlgorithm.java	(revision 3222)
@@ -0,0 +1,204 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache;
+
+import java.io.IOException;
+
+import org.gvsig.raster.cache.buffer.exception.InvalidPageNumberException;
+import org.gvsig.raster.cache.buffer.impl.stripecache.horizontal.CacheHorzImpl;
+
+/**
+ * Esta clase contiene el algoritmo de reemplazo de trozos de cach� LRU
+ *   
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ *
+ */
+public class LRUAlgorithm {
+
+	private Cache cache = null;
+	
+	/**
+	 * Constructor. Asigna la cach� para poder aplicar el algoritmo.
+	 * @param cache
+	 */
+	public LRUAlgorithm(Cache cache){
+		this.cache = cache;
+	}
+	
+	/**
+	 * Asigna el objeto cach�.
+	 * @param cache 
+	 */
+	public void setCache(Cache cache) {
+		this.cache = (CacheHorzImpl)cache;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.LRUAlgorithm#cacheAccess(int, boolean)
+	 */
+	public void cacheAccess(int line, boolean readOnly)throws InvalidPageNumberException, InterruptedException {
+		int pag = line >> cache.getBitsPag();			
+		if(cache.isInCache(pag)) {
+			if(cache.getNumberInAccessPage() != pag) {
+				loadPage(pag, readOnly);
+				//cache.log("loadPage");
+			}
+		} else {
+			replacePage(pag + 1, readOnly, false);
+			replacePage(pag, readOnly, true);
+			//cache.log("replacePage");
+		}
+	}
+	
+	/**
+	 * Carga la p�gina desde cach� al buffer actualmente en uso. Esta operaci�n no lleva
+	 * cambio de datos sino que solo es un cambio de punteros. La secuencia de operaciones es:
+	 * <UL>
+	 * <LI>Cargar la p�gina como accedida</LI>
+	 * <LI>Asignar n�mero a la p�gina accedida</LI>
+	 * <LI>Actualizar la antig�edad de accesos.Se incrementar� uno en todas las p�ginas del 
+	 * conjunto y se pondr� a 0 la p�gina accedida.</LI>
+	 * <LI>Poner a 0 el valor de lastAccess de la p�gina cargada. Esto hace que tenga m�nima 
+	 * prioridad en la politica de reemplazamiento.</LI>
+	 * <LI>Poner a false el flag de p�gina modificada si el par�metro readOnly es false.</LI>
+	 * </UL>
+	 * @param nPag N�mero de p�gina del raster a la que se intenta acceder.
+	 * @param readOnly ser� true si el acceso que se est� realizando es de lectura y false si se
+	 * est� escribiendo alg�n dato. 
+	 */
+	private void loadPage(int nPag, boolean readOnly)throws InvalidPageNumberException{
+		PageBuffer buf = cache.getPageBufferFromNumberRasterPage(nPag);
+		int[] cacheGroupPage = cache.getNumberGroupFromNumberRasterPage(nPag);
+		if(buf != null && cacheGroupPage != null){ //Comprueba que el n�mero de p�gina sea correcto para la cach�.
+			cache.setAccessPage(buf, nPag);
+			cache.updateLastAccess(cacheGroupPage[0]);
+			cache.setZeroInLastAccess(cacheGroupPage[0], cacheGroupPage[1]);
+			if(!readOnly)
+				cache.setModify(cacheGroupPage[0], cacheGroupPage[1]);
+		}else
+			throw new InvalidPageNumberException("");
+		//System.out.println("LOAD: "+nPag);
+	}
+	
+	/**
+	 * <P>
+	 * Cuando se accede a una p�gina que no est� cacheada necesitamos cargarla en cach� antes de 
+	 * acceder a ella. Si hay un hueco libre en su conjunto se meter� en este pero sino habr� 
+	 * que reemplazar una ocupada. Para esto habr� que localizar el conjunto donde va 
+	 * destinada y luego la posici�n del conjunto donde se cargar� localizando cual es el 
+	 * elemento del conjunto que hace m�s tiempo que se accedi�.
+	 * </P>
+	 * <P>
+	 * Si el elemento es insertado en un hueco la secuencia es la siguiente:
+	 * </P>
+	 * <UL>
+	 * <LI>Obtenemos la siguiente p�gina vacia.</LI>
+	 * <LI>La cargamos de datos.</LI>
+	 * <LI>Se asigna como p�gina accedida</LI>
+	 * <LI>Ponemos true en su posici�n en el vector cacheada</LI>
+	 * <LI>Asignamos el n�mero de p�gina de raster que hemos cargado en esa posici�n de la cach�.</LI>
+	 * <LI>Incrementamos en 1 todos los valores de �ltimo acceso de las p�ginas del grupo.</LI>
+	 * <LI>Ponemos a 0 su �ltimo acceso</LI>
+	 * <LI>Si el acceso es para escritura ponemos el flag de p�gina modificada a true.</LI>
+	 * </UL>
+	 * <P>
+	 * Si se reemplaza una p�gina la secuencia es la siguiente:
+	 * </P>
+	 * <UL>
+	 *  <LI>Incrementamos en 1 todos los valores de �ltimo acceso de las p�ginas del grupo y 
+	 *  obtenemos la posici�n de la p�gina de reemplazo.</LI>
+	 * <LI>Ponemos a false la p�gina que va a sacarse de cach�</LI>
+	 * <LI>Si ha sido modificada la p�gina que va a sacarse de cach� se vuelca a disco</LI>
+	 * <LI>Ponemos el flag de modificada para la p�gina sacada a disco a false.</LI>
+	 * <LI>Cargamos la p�gina de cach� de datos.</LI>
+	 * <LI>Asignamos el n�mero de p�gina de raster que hemos cargado en esa posici�n de la cach�.</LI>
+	 * <LI>Se asigna como p�gina accedida</LI>
+	 * <LI>Ponemos true en su posici�n en el vector cacheada</LI>
+	 * <LI>Ponemos a 0 su �ltimo acceso</LI>
+	 * <LI>Si el acceso es para escritura ponemos el flag de p�gina modificada a true.</LI>
+	 * </UL>
+	 * @param nPag N�mero de p�gina que est� siendo accedida
+	 * @param readOnly ser� true si el acceso que se est� realizando es de lectura y false si se
+	 * est� escribiendo alg�n dato. 
+	 * @param n ser� true si el acceso se est� haciendo a la p�gina n y false si se est� haciendo a
+	 * la n+1. 
+	 * @throws InterruptedException 
+	 */
+	private void replacePage(int nPag, boolean readOnly, boolean n) throws InterruptedException {
+		int group = nPag % cache.getNGroups();
+		
+		if(nPag >= cache.getNTotalPags())
+			return;
+		
+		//Insertamos en un hueco
+		
+		if(insertInAGap(group, readOnly, nPag, n))
+			return;
+				
+		//Reemplazamos una existente
+		
+		int posInGroupPageToReplace = cache.updateLastAccess(group); //Se actualizan los indices y se obtiene la p�gina a reemplazar
+		
+		cache.setZeroInLastAccess(group, posInGroupPageToReplace);
+		int rasterPageToReplace = cache.getRasterPageNumberInPosition(group, posInGroupPageToReplace);
+				
+		//Sacamos la antigua
+		cache.setPageAsNotLoadInCache(rasterPageToReplace);
+		if(cache.isModified(group, posInGroupPageToReplace)){
+			try {
+				cache.savePage(group, posInGroupPageToReplace, rasterPageToReplace); 	//Volcamos disco 
+				cache.unsetModify(group, posInGroupPageToReplace);
+			} catch (IOException e) {
+				System.err.println("No se ha podido salvar la p�gina de cach�.");
+				e.printStackTrace();
+			}
+		}
+		
+		//Insertamos la nueva
+		cache.loadPage(group, posInGroupPageToReplace, nPag);	//Cargamos de nuevo el buffer
+		cache.setRasterPageNumberInPosition(group, posInGroupPageToReplace, nPag);
+		cache.setPageAsLoadInCache(nPag);		//Pone true en su posici�n en el vector cacheada
+		PageBuffer pb = cache.getPageBuffer(group, posInGroupPageToReplace);
+		
+		if(n) {
+			if(!readOnly)
+				cache.setModify(group, posInGroupPageToReplace);
+			cache.setAccessPage(pb, nPag);  	//Asigna como accedida
+		}
+		//System.out.println("REPLACE: "+nPag);
+	}
+	
+	/**
+	 * Comprueba si hay alg�n hueco en el que insertar y si es as� se inserta en el y devuelve
+	 * true. 
+	 * @param group conjunto donde hay que buscar para la inserci�n
+	 * @param readOnly si es true la operaci�n es de solo consulta y si es false la operaci�n 
+	 * est� modificando alg�n valor de la p�gina a insertar
+	 * @param nPag N�mero de p�gina a cargar
+	 * @return true si se ha insertado en un hueco y false si no se ha insertado
+	 * @throws InterruptedException 
+	 */
+	private boolean insertInAGap(int group, boolean readOnly, int nPag, boolean n) throws InterruptedException {
+		PageBuffer pb = null;
+		for(int i = 0; i < cache.getPagsPerGroup(); i++) {
+			if(cache.getLastAccess()[group][i] == -1) {
+
+				//Pone true en su posici�n en el vector cacheada
+				pb = cache.getPageBuffer(group, i);
+				cache.loadPage(group, i, nPag);					//Sube la p�gina a cach�
+				cache.setRasterPageNumberInPosition(group, i, nPag);//Asigna el n�mero de p�g a una posici�n de cach�
+				cache.setPageAsLoadInCache(nPag);
+				cache.updateLastAccess(group);
+				cache.setZeroInLastAccess(group, i);
+				if(n){ //La n+1 no se carga como accedida ni se pone a 0 su contador de �ltima accedida	
+					if(!readOnly)
+						cache.setModify(group, i);
+					cache.setAccessPage(pb, nPag);  //Asigna como accedida
+				}				
+				//System.out.println("INSERT: "+nPag);
+				return true;
+			}
+		}
+		return false;
+	}
+
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/LRUAlgorithm.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/LRUAlgorithm_deprecated.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/LRUAlgorithm_deprecated.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/LRUAlgorithm_deprecated.java	(revision 3222)
@@ -0,0 +1,29 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache;
+
+import org.gvsig.raster.cache.buffer.exception.InvalidPageNumberException;
+
+/**
+ * Interfaz for LRU algorithms
+ *   
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ *
+ */
+public interface LRUAlgorithm_deprecated {
+
+	/**
+	 * Asigna el objeto cach�.
+	 * @param cache 
+	 */
+	public void setCache(Cache cache);
+	
+	/**
+	 * Funci�n que controla para cada l�nea si la p�gina a la que accede est� cacheada o no
+	 * . Es la encargada de realizar los reemplazos o cargar la p�gina en el buffer de "p�gina
+	 * actualmente accedida" (accessPage de la clase Cache)
+	 * @param line L�nea del raster a la que se est� accediendo
+	 * @param readOnly ser� true si el acceso que se est� realizando es de lectura y false si se
+	 * est� escribiendo alg�n dato
+	 */
+	public void cacheAccess(int line, boolean readOnly)throws InvalidPageNumberException, InterruptedException;
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/LRUAlgorithm_deprecated.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/horizontal/RasterCacheBuffer.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/horizontal/RasterCacheBuffer.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/horizontal/RasterCacheBuffer.java	(revision 3222)
@@ -0,0 +1,962 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.horizontal;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferNoData;
+import org.gvsig.raster.cache.buffer.exception.BandNotCompatibleException;
+import org.gvsig.raster.cache.buffer.exception.InvalidPageNumberException;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.WrongParameterException;
+import org.gvsig.raster.cache.buffer.impl.RasterBuffer;
+import org.gvsig.raster.cache.buffer.impl.stripecache.CacheBand;
+import org.gvsig.raster.cache.buffer.impl.stripecache.LRUAlgorithm;
+
+/**
+ * Esta clase representa un buffer de datos cacheado. El estar en cache significa que
+ * solo una parte de los datos estar�n en memoria y que gestiona, dependiendo de las
+ * peticiones, que partes hay que cargar a memoria y en que momento. Para esto el buffer
+ * no se llena de golpe sino que utiliza una clase que sirve los datos desde la fuente. 
+ * Esta clase servidora de datos debe implementar el interfaz ICacheDatasetSourcepara 
+ * servir datos de la forma requerida.
+ *   
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ *
+ */
+public class RasterCacheBuffer extends RasterBuffer {
+
+	private CacheHorzImpl 			  cache     = null;
+	private LRUAlgorithm              lru       = null;
+	private CacheBandListHorz         bands     = null;
+	private int                       lastLine  = -1;
+	 
+    /**
+     * Constructor. Asigna las variables de inicializaci�n y crea la estructura de 
+     * la cach� con los datos pasados.
+     * @param dataType Tipo de dato del buffer
+     * @param width Ancho del buffer
+     * @param height Alto del buffer
+     * @param nBands N�mero de bandas del buffer
+     */
+	public RasterCacheBuffer(int dataType, int width, int height, int nBands) {
+		super(0, 0, width, height, dataType, nBands);
+		cache = new CacheHorzImpl(nBands, dataType, width, height);
+		lru = new LRUAlgorithm(cache);
+        
+        bands = new CacheBandListHorz();
+        for (int i = 0; i < nBands; i++) {
+        	switch(dataType) {
+        	case RasterBuffer.TYPE_BYTE: bands.add(new ByteBand(cache, lru, i)); break;
+        	case RasterBuffer.TYPE_SHORT: bands.add(new ShortBand(cache, lru, i)); break;
+        	case RasterBuffer.TYPE_INT: bands.add(new IntBand(cache, lru, i)); break;
+        	case RasterBuffer.TYPE_FLOAT: bands.add(new FloatBand(cache, lru, i)); break;
+        	case RasterBuffer.TYPE_DOUBLE: bands.add(new DoubleBand(cache, lru, i)); break;
+        	}
+		}
+	}
+		
+	/**
+	 * Borra la cach� cuando se elimina el objeto RasterCache ya que
+	 * los trozos ya no pueden ser referenciados.
+	 */
+	protected void finalize() throws Throwable {
+		free();
+	}
+	
+	/*
+     * (non-Javadoc)
+     * @see org.gvsig.raster.driver.IRasterBuffer#isBandSwitchable()
+     */
+    public boolean isBandSwitchable(){
+    	return true;
+    }
+    
+	/**
+	 * Obtiene la cach�
+	 * @return
+	 */
+	public CacheHorzImpl getCache() {
+		return cache;
+	}
+	
+	/**
+	 * Asigna la cache
+	 * @param cache
+	 */
+	public void setCache(CacheHorzImpl cache) {
+		this.cache = cache;
+		this.lru.setCache(cache);
+	}
+	
+	/*
+     * (non-Javadoc)
+     * @see org.fv.raster.buffer.IRasterBuffer#isWritable()
+     */
+    public boolean isWritable() {
+    	return true;
+    }
+    
+    private boolean exists(int line) {
+        // Store the last line checked so we don't check it again for each
+        // pixel of the same line
+        if (line != lastLine) {
+            try {
+                lru.cacheAccess(line, false);
+                this.lastLine = line;
+            } catch (InvalidPageNumberException e) {
+                return false;
+            } catch (InterruptedException e) {
+				return false;
+			}
+        }
+        return true;
+    }
+	
+	/***********************************************/
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#getLineByte(int)
+	 */
+    public byte[][] getLineByte(int line) {
+    	if (exists(line)) {
+    		return cache.getAccessPage().getLineByte(
+    			(line & cache.getOffset()));
+    	}
+    	return null;
+    }
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#getLineShort(int)
+	 */
+	public short[][] getLineShort(int line) {
+		if (exists(line)) {
+            return cache.getAccessPage().getLineShort(
+                (line & cache.getOffset()));
+        }
+        return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#getLineInt(int)
+	 */
+	public int[][] getLineInt(int line) {
+		if (exists(line)) {
+            return cache.getAccessPage().getLineInt(
+            		(line & cache.getOffset()));
+        }
+        return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#getLineFloat(int)
+	 */
+	public float[][] getLineFloat(int line) {
+		if (exists(line)) {
+            return cache.getAccessPage().getLineFloat(
+                (line & cache.getOffset()));
+        }
+        return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#getLineDouble(int)
+	 */
+	public double[][] getLineDouble(int line) {
+		if (exists(line)) {
+            return cache.getAccessPage().getLineDouble(
+                (line & cache.getOffset()));
+        }
+        return null;
+	}
+
+	//***********************************************
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#setLineByte(byte[][], int)
+	 */
+	public void setLineByte(byte[][] data, int line) {
+		if (exists(line)) {
+            cache.getAccessPage().setLineByte(
+            		data, (line & cache.getOffset()));
+        }
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#setLineShort(short[][], int)
+	 */
+	public void setLineShort(short[][] data, int line) {
+		if (exists(line)) {
+            cache.getAccessPage().setLineShort(
+            		data, (line & cache.getOffset()));
+        }
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#setLineInt(int[][], int)
+	 */
+	public void setLineInt(int[][] data, int line) {
+		if (exists(line)) {
+            cache.getAccessPage().setLineInt(
+            		data, (line & cache.getOffset()));
+        }
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#setLineFloat(float[][], int)
+	 */
+	public void setLineFloat(float[][] data, int line) {
+		if (exists(line)) {
+            cache.getAccessPage().setLineFloat(
+            		data, (line & cache.getOffset()));
+        }
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#setLineDouble(double[][], int)
+	 */
+	public void setLineDouble(double[][] data, int line) {
+		if (exists(line)) {
+            cache.getAccessPage().setLineDouble(
+            		data, (line & cache.getOffset()));
+        }
+	}
+
+	//*********************************************************
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#getLineFromBandByte(int, int)
+	 */
+	public byte[] getLineFromBandByte(int line, int band) {
+		if (exists(line)) {
+            return cache.getAccessPage().getLineFromBandByte(
+                (line & cache.getOffset()), band);
+        }
+        return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#getLineFromBandShort(int, int)
+	 */
+	public short[] getLineFromBandShort(int line, int band) {
+		if (exists(line)) {
+            return cache.getAccessPage().getLineFromBandShort(
+                (line & cache.getOffset()), band);
+        }
+        return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#getLineFromBandInt(int, int)
+	 */
+	public int[] getLineFromBandInt(int line, int band) {
+		if (exists(line)) {
+            return cache.getAccessPage().getLineFromBandInt(
+                (line & cache.getOffset()), band);
+        }
+        return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.IRasterBuffer#getLineFromBandFloat(int, int)
+	 */
+	public float[] getLineFromBandFloat(int line, int band) {
+        if (exists(line)) {
+            return cache.getAccessPage().getLineFromBandFloat(
+                (line & cache.getOffset()), band);
+        }
+        return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.IRasterBuffer#getLineFromBandDouble(int, int)
+	 */
+	public double[] getLineFromBandDouble(int line, int band) {
+        if (exists(line)) {
+            return cache.getAccessPage().getLineFromBandDouble(
+                (line & cache.getOffset()), band);
+        }
+        return null;
+	}
+
+	//*********************************************************
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#setLineInBandByte(byte[], int, int)
+	 */
+	public void setLineInBandByte(byte[] data, int line, int band) {
+        if (exists(line)) {
+            cache.getAccessPage().setLineInBandByte(data,
+                (line & cache.getOffset()), band);
+        }
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.IRasterBuffer#setLineInBandShort(short[], int, int)
+	 */
+	public void setLineInBandShort(short[] data, int line, int band) {
+        if (exists(line)) {
+            cache.getAccessPage().setLineInBandShort(data,
+                (line & cache.getOffset()), band);
+        }
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.IRasterBuffer#setLineInBandInt(int[], int, int)
+	 */
+	public void setLineInBandInt(int[] data, int line, int band) {
+        if (exists(line)) {
+            cache.getAccessPage().setLineInBandInt(data,
+                (line & cache.getOffset()), band);
+        }
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.IRasterBuffer#setLineInBandFloat(float[], int, int)
+	 */
+	public void setLineInBandFloat(float[] data, int line, int band) {
+        if (exists(line)) {
+            cache.getAccessPage().setLineInBandFloat(data,
+                (line & cache.getOffset()), band);
+        }
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.IRasterBuffer#setLineInBandDouble(double[], int, int)
+	 */
+	public void setLineInBandDouble(double[] data, int line, int band) {
+        if (exists(line)) {
+            cache.getAccessPage().setLineInBandDouble(data,
+                (line & cache.getOffset()), band);
+        }
+	}
+
+	//*********************************************************
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#getElemByte(int, int, int)
+	 */
+	public byte getElemByte(int line, int col, int band) {
+        if (exists(line)) {
+            return cache.getAccessPage().getElemByte(
+                (line & cache.getOffset()), col, band);
+		}
+        return getNoDataValue().isDefined() ? getNoDataValue().getValue().byteValue() : BufferNoData.defaultByteNoDataValue; // No leemos el dato
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.IRasterBuffer#getElemShort(int, int, int)
+	 */
+	public short getElemShort(int line, int col, int band) {
+        if (exists(line)) {
+            return cache.getAccessPage().getElemShort(
+                (line & cache.getOffset()), col, band);
+		}
+        return getNoDataValue().isDefined() ? getNoDataValue().getValue().shortValue() : BufferNoData.defaultShortNoDataValue; // No leemos el dato
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.IRasterBuffer#getElemInt(int, int, int)
+	 */
+	public int getElemInt(int line, int col, int band) {
+        if (exists(line)) {
+            return cache.getAccessPage().getElemInt((line & cache.getOffset()),
+                col, band);
+		}
+        return getNoDataValue().isDefined() ? getNoDataValue().getValue().intValue() : BufferNoData.defaultIntegerNoDataValue; // No leemos el dato
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.IRasterBuffer#getElemFloat(int, int, int)
+	 */
+	public float getElemFloat(int line, int col, int band) {
+        if (exists(line)) {
+            return cache.getAccessPage().getElemFloat(
+                (line & cache.getOffset()), col, band);
+		}
+        return getNoDataValue().isDefined() ? getNoDataValue().getValue().floatValue() : BufferNoData.defaultFloatNoDataValue; // No leemos el dato
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.IRasterBuffer#getElemDouble(int, int, int)
+	 */
+	public double getElemDouble(int line, int col, int band) {
+        if (exists(line)) {
+            return cache.getAccessPage().getElemDouble(
+                (line & cache.getOffset()), col, band);
+		}
+        return getNoDataValue().isDefined() ? getNoDataValue().getValue().doubleValue() : BufferNoData.defaultDoubleNoDataValue; // No leemos el dato
+	}
+
+	//*********************************************************
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#setElem(int, int, int, byte)
+	 */
+	public void setElem(int line, int col, int band, byte data) {
+		if (exists(line)) {
+			cache.getAccessPage().setElem(
+					(line & cache.getOffset()), col, band, data);
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#setElem(int, int, int, short)
+	 */
+	public void setElem(int line, int col, int band, short data) {
+		if (exists(line)) {
+			cache.getAccessPage().setElem(
+					(line & cache.getOffset()), col, band, data);
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#setElem(int, int, int, int)
+	 */
+	public void setElem(int line, int col, int band, int data) {
+		if (exists(line)) {
+			cache.getAccessPage().setElem(
+					(line & cache.getOffset()), col, band, data);
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#setElem(int, int, int, float)
+	 */
+	public void setElem(int line, int col, int band, float data) {
+		if (exists(line)) {
+			cache.getAccessPage().setElem(
+					(line & cache.getOffset()), col, band, data);
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#setElem(int, int, int, double)
+	 */
+	public void setElem(int line, int col, int band, double data) {
+		if (exists(line)) {
+			cache.getAccessPage().setElem(
+					(line & cache.getOffset()), col, band, data);
+		}
+	}
+	
+	//*********************************************************
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#getElemByte(int, int, byte[])
+	 */
+	public void getElemByte(int line, int col, byte[] data) {
+		if(exists(line)) {
+			cache.getAccessPage().getElemByte(
+					(line & cache.getOffset()), col, data);
+			return;
+		}
+		if(getNoDataValue().isDefined()) {
+			for (int iBand = 0; iBand < data.length; iBand++)
+	            data[iBand] = getNoDataValue().getValue().byteValue();
+		} else {
+			for (int iBand = 0; iBand < data.length; iBand++)
+	            data[iBand] = BufferNoData.defaultByteNoDataValue;
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.IRasterBuffer#getElemShort(int, int, short[])
+	 */
+	public void getElemShort(int line, int col, short[] data) {
+		if(exists(line)) {
+			cache.getAccessPage().getElemShort(
+					(line & cache.getOffset()), col, data);
+			return;
+		}
+		if(getNoDataValue().isDefined()) {
+			for (int iBand = 0; iBand < data.length; iBand++)
+	            data[iBand] = getNoDataValue().getValue().shortValue();
+		} else {
+			for (int iBand = 0; iBand < data.length; iBand++)
+	            data[iBand] = BufferNoData.defaultShortNoDataValue;
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.IRasterBuffer#getElemInt(int, int, int[])
+	 */
+	public void getElemInt(int line, int col, int[] data) {
+		if(exists(line)) {
+			cache.getAccessPage().getElemInt(
+					(line & cache.getOffset()), col, data);
+			return;
+		}
+		if(getNoDataValue().isDefined()) {
+			for (int iBand = 0; iBand < data.length; iBand++)
+	            data[iBand] = getNoDataValue().getValue().intValue();
+		} else {
+			for (int iBand = 0; iBand < data.length; iBand++)
+	            data[iBand] = BufferNoData.defaultIntegerNoDataValue;
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.IRasterBuffer#getElemFloat(int, int, float[])
+	 */
+	public void getElemFloat(int line, int col, float[] data) {
+		if(exists(line)) {
+			cache.getAccessPage().getElemFloat(
+					(line & cache.getOffset()), col, data);
+			return;
+		}
+		if(getNoDataValue().isDefined()) {
+			for (int iBand = 0; iBand < data.length; iBand++)
+	            data[iBand] = getNoDataValue().getValue().floatValue();
+		} else {
+			for (int iBand = 0; iBand < data.length; iBand++)
+	            data[iBand] = BufferNoData.defaultFloatNoDataValue;
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.IRasterBuffer#getElemDouble(int, int, double[])
+	 */
+	public void getElemDouble(int line, int col, double[] data) {
+		if(exists(line)) {
+			cache.getAccessPage().getElemDouble(
+					(line & cache.getOffset()), col, data);
+			return;
+		}
+		if(getNoDataValue().isDefined()) {
+			for (int iBand = 0; iBand < data.length; iBand++)
+	            data[iBand] = getNoDataValue().getValue().doubleValue();
+		} else {
+			for (int iBand = 0; iBand < data.length; iBand++)
+	            data[iBand] = BufferNoData.defaultDoubleNoDataValue;
+		}
+	}
+	
+	//*********************************************************
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.IRasterBuffer#setElemByte(int, int, byte[])
+	 */
+	public void setElemByte(int line, int col, byte[] data) {
+        if (exists(line)) {
+            cache.getAccessPage().setElemByte(
+            		(line & cache.getOffset()), col, data);
+        }
+    }
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.IRasterBuffer#setElemShort(int, int, short[])
+	 */
+    public void setElemShort(int line, int col, short[] data) {
+        if (exists(line)) {
+            cache.getAccessPage().setElemShort(
+            		(line & cache.getOffset()), col, data);
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.gvsig.raster.cache.buffer.IRasterBuffer#setElemInt(int, int, int[])
+     */
+    public void setElemInt(int line, int col, int[] data) {
+        if (exists(line)) {
+            cache.getAccessPage().setElemInt(
+            		(line & cache.getOffset()), col, data);
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.gvsig.raster.cache.buffer.IRasterBuffer#setElemFloat(int, int, float[])
+     */
+    public void setElemFloat(int line, int col, float[] data) {
+        if (exists(line)) {
+            cache.getAccessPage().setElemFloat(
+            		(line & cache.getOffset()), col, data);
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.gvsig.raster.cache.buffer.IRasterBuffer#setElemDouble(int, int, double[])
+     */
+    public void setElemDouble(int line, int col, double[] data) {
+        if (exists(line)) {
+            cache.getAccessPage().setElemDouble(
+            		(line & cache.getOffset()), col, data);
+        }
+    }
+
+	//*********************************************************
+	
+	public void assign(int band, byte value) {
+		for(int line = 0; line < getHeight(); line ++){
+			boolean beginLine = true;  //Para acelerar solo comprobar� si la p�gina est� en cach� cada vez que empieza una l�nea
+    		for(int col = 0; col < getWidth(); col ++){
+    			try {
+    				if(beginLine){
+    					lru.cacheAccess(line, false);
+    					beginLine = false;
+    				}
+    			} catch (InvalidPageNumberException e) {return;
+    			} catch (InterruptedException e) {return;}
+    			cache.getAccessPage().setElem((line & cache.getOffset()), col, band, value);		
+    		}
+		}
+	}
+
+	public void assign(int band, short value) {
+		for(int line = 0; line < getHeight(); line ++){
+			boolean beginLine = true;  //Para acelerar solo comprobar� si la p�gina est� en cach� cada vez que empieza una l�nea
+    		for(int col = 0; col < getWidth(); col ++){
+    			try {
+    				if(beginLine){
+    					lru.cacheAccess(line, false);
+    					beginLine = false;
+    				}
+    			} catch (InvalidPageNumberException e) {return;
+    			} catch (InterruptedException e) {return;}
+    			cache.getAccessPage().setElem((line & cache.getOffset()), col, band, value);		
+    		}
+		}		
+	}
+
+	public void assign(int band, int value) {
+		for(int line = 0; line < getHeight(); line ++){
+			boolean beginLine = true;  //Para acelerar solo comprobar� si la p�gina est� en cach� cada vez que empieza una l�nea
+    		for(int col = 0; col < getWidth(); col ++){
+    			try {
+    				if(beginLine){
+    					lru.cacheAccess(line, false);
+    					beginLine = false;
+    				}
+    			} catch (InvalidPageNumberException e) {return;
+    			} catch (InterruptedException e) {return;}
+    			cache.getAccessPage().setElem((line & cache.getOffset()), col, band, value);		
+    		}
+		}	
+	}
+
+	public void assign(int band, float value) {
+		for(int line = 0; line < getHeight(); line ++){
+			boolean beginLine = true;  //Para acelerar solo comprobar� si la p�gina est� en cach� cada vez que empieza una l�nea
+    		for(int col = 0; col < getWidth(); col ++){
+    			try {
+    				if(beginLine){
+    					lru.cacheAccess(line, false);
+    					beginLine = false;
+    				}
+    			} catch (InvalidPageNumberException e) {return;
+    			} catch (InterruptedException e) {return;}
+    			cache.getAccessPage().setElem((line & cache.getOffset()), col, band, value);		
+    		}
+		}	
+	}
+
+	public void assign(int band, double value) {
+		for(int line = 0; line < getHeight(); line ++){
+			boolean beginLine = true;  //Para acelerar solo comprobar� si la p�gina est� en cach� cada vez que empieza una l�nea
+    		for(int col = 0; col < getWidth(); col ++){
+    			try {
+    				if(beginLine){
+    					lru.cacheAccess(line, false);
+    					beginLine = false;
+    				}
+    			} catch (InvalidPageNumberException e) {return;
+    			} catch (InterruptedException e) {return;}
+    			cache.getAccessPage().setElem((line & cache.getOffset()), col, band, value);		
+    		}
+		}
+	}
+	
+	//**************************************
+    //**********BANDS OPERATIONS************
+    //**************************************
+    
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#removeBand(int)
+	 */
+	public void removeBand(int iBand) throws IOException {
+    	if(iBand < 0 || iBand >= getBandCount())
+    		return;
+		cache.removeBand(iBand);
+		bands.remove(iBand);
+		bandLessLess();
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#addBand(int)
+	 */
+	public Band addBand(int pos) throws IOException {
+		cache.addBand(pos);
+		CacheBand cb = bands.add(pos, cache, lru, getDataType());
+		bandPlusPlus();
+		return cb;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#getBands()
+	 */
+	public Band[] getBands() {
+		Band[] b = new Band[bands.size()];
+		for (int i = 0; i < bands.size(); i++) 
+			b[i] = bands.get(i);
+		return b;
+	}
+	
+    /*
+     * (non-Javadoc)
+     * @see org.fv.raster.buffer.IRasterBuffer#getBandList()
+     */
+    public ArrayList<Band> getBandList() {
+    	ArrayList<Band> result = new ArrayList<Band>();
+    	for (int i = 0; i < bands.size(); i++) 
+			result.add(bands.get(i));
+    	return result;
+    }
+	
+	/**
+	 * Set the band to the selected position. To assign a cache band firstly it will 
+	 * check if the band to assign is compatible, then it will
+	 * load in each page in disk the page indicated by the target object. Finally it will 
+	 * assign the Cache object to the new band.
+	 * @throws IOException 
+	 */
+	public void assignBand(int pos, Band band) throws IOException, BandNotCompatibleException {
+		if(	band.getDataType() != getDataType())
+			throw new BandNotCompatibleException("Data type not compatible");
+		if(getBand(0) != null && band.getClass() != getBand(0).getClass())
+			throw new BandNotCompatibleException("buffer type not compatible");
+		if(	band.getHeight() != cache.getDataSourceHeight() || band.getWidth() != cache.getDataSourceWidth())
+				throw new BandNotCompatibleException("Bands with diferents sizes");
+		
+		cache.addBand(pos, band);
+		bands.add(pos, cache, lru, getDataType());
+		bandPlusPlus();
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.driver.IRasterBuffer#getBandByRef(int)
+	 */
+	public Band getBand(int band) {
+		if(bands.size() == 0 || band < 0 || band > (bands.size() - 1))
+			return null;
+		return bands.get(band);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.driver.IRasterBuffer#getBand(int)
+	 */
+	public Band getBandCopy(int band) {
+		switch (getDataType()) {
+		case RasterBuffer.TYPE_BYTE:
+			return (ByteBand)((ByteBand)bands.get(band)).clone();
+		case RasterBuffer.TYPE_SHORT:
+			return (ShortBand)((ShortBand)bands.get(band)).clone();
+		case RasterBuffer.TYPE_INT:
+			return (IntBand)((IntBand)bands.get(band)).clone();
+		case RasterBuffer.TYPE_FLOAT:
+			return (FloatBand)((FloatBand)bands.get(band)).clone();
+		case RasterBuffer.TYPE_DOUBLE:
+			return (DoubleBand)((DoubleBand)bands.get(band)).clone();
+		}
+		return null;
+	}
+	
+	/*
+     * (non-Javadoc)
+     * @see org.gvsig.fmap.driver.IRasterBuffer#getBandBuffer(int)
+     */
+    public Buffer getBufferWithOneBand(int iBand) throws IOException {
+    	//Creamos un buffer del mismo tama�o que el original para que la estructura de cache
+    	//sea la misma. Luego eliminaremos las bandas para a�adirle solo una.
+    	RasterCacheBuffer rcb = new RasterCacheBuffer(getDataType(), getWidth(), getHeight(), getBandCount());
+    	for (int i = getBandCount() - 1; i >= 0; i--) 
+    		rcb.removeBand(i);	
+    	try {
+			rcb.assignBand(0, getBand(iBand));
+		} catch (BandNotCompatibleException e) {
+			//It can't be throwed
+		}
+    	return rcb;
+    }
+    
+    /*
+     *  (non-Javadoc)
+     * @see org.gvsig.fmap.dataaccess.buffer.RasterBuffer#switchBands(int[])
+     */
+    public void swapBands(int[] bandPosition) throws WrongParameterException, IOException {
+    	super.swapBands(bandPosition);
+    	cache.swapBands(bandPosition);
+    	bands.swapBands(bandPosition);
+    }
+    
+    /*
+     * (non-Javadoc)
+     * @see org.gvsig.fmap.driver.IRasterBuffer#swapBands(int, int)
+     */
+	public void swapBands(int band1, int band2) throws WrongParameterException, IOException {
+		if(band1 < 0 || band1 > getBandCount() - 1 || band2 < 0 || band2 > getBandCount() - 1)
+			return;
+		
+		int[] bandPosition = new int[getBandCount()];
+		for (int i = 0; i < bandPosition.length; i++) {
+			if(i == band1) 
+				bandPosition[i] = band2;
+			else if(i == band2) 
+				bandPosition[i] = band1;
+			else
+				bandPosition[i] = i;
+		}
+		swapBands(bandPosition);
+	}
+	
+	/*
+     *  (non-Javadoc)
+     * @see org.gvsig.fmap.driver.IRasterBuffer#copyBand(int, org.gvsig.fmap.dataaccess.buffer.IBand)
+     */
+	public void copyBand(int iBand, Band band) throws BandNotCompatibleException, OperationNotSupportedException {
+		super.copyBand(iBand, band);
+	}
+	
+    /*
+     *  (non-Javadoc)
+     * @see org.gvsig.fmap.driver.IRasterBuffer#replicateBand(int, int)
+     */
+	public void replicateBand(int orig, int dest) throws IOException {
+		Band origBand = getBandCopy(orig);
+		try {
+			assignBand(dest, origBand);
+		} catch (BandNotCompatibleException e) {
+			//It can't be throwed
+		}
+	}  
+	
+	/**
+	 * Create a band with the current cache information.
+	 */
+	public Band createBand(double defaultValue) {
+		CacheHorzImpl clonCache = cache.cloneStructure();
+		LRUAlgorithm lru = new LRUAlgorithm(clonCache);
+		for (int i = getBandCount() - 1; i >= 0 ; i--) {
+			try {
+				clonCache.removeBand(i);
+			} catch (IOException e) {
+				return null;
+			}
+		}
+		clonCache.createPages(1);
+		
+		switch (getDataType()) {
+		case RasterBuffer.TYPE_BYTE:	
+			ByteBand bb = new ByteBand(clonCache, lru, 0);
+			bb.assign((byte)defaultValue);
+			return bb;
+		case RasterBuffer.TYPE_SHORT:
+			ShortBand sb = new ShortBand(clonCache, lru, 0);
+			sb.assign((short)defaultValue);
+			return sb;
+		case RasterBuffer.TYPE_INT:
+			IntBand ib = new IntBand(clonCache, lru, 0);
+			ib.assign((int)defaultValue);
+			return ib;
+		case RasterBuffer.TYPE_FLOAT:
+			FloatBand fb = new FloatBand(clonCache, lru, 0);
+			fb.assign((float)defaultValue);
+			return fb;
+		case RasterBuffer.TYPE_DOUBLE:
+			DoubleBand db = new DoubleBand(clonCache, lru, 0);
+			db.assign(defaultValue);
+			return db;
+		}
+		return null;
+	}
+		
+	/*
+	 *  (non-Javadoc)
+	 * @see org.gvsig.fmap.driver.IRasterBuffer#assignBandToNotValid(int)
+	 */
+	public void assignBandToNotValid(int iBand) {
+		switch (getDataType()) {
+		case RasterBuffer.TYPE_BYTE:	
+			for (int row = 0; row < getHeight(); row++) 
+				for (int col = 0; col < getWidth(); col++) 
+					setElem(row, col, iBand, (byte)notValidValue);
+		case RasterBuffer.TYPE_SHORT:
+			for (int row = 0; row < getHeight(); row++) 
+				for (int col = 0; col < getWidth(); col++) 
+					setElem(row, col, iBand, (short)notValidValue);
+		case RasterBuffer.TYPE_INT:
+			for (int row = 0; row < getHeight(); row++) 
+				for (int col = 0; col < getWidth(); col++) 
+					setElem(row, col, iBand, (int)notValidValue);
+		case RasterBuffer.TYPE_FLOAT:
+			for (int row = 0; row < getHeight(); row++) 
+				for (int col = 0; col < getWidth(); col++) 
+					setElem(row, col, iBand, (float)notValidValue);
+		case RasterBuffer.TYPE_DOUBLE:
+			for (int row = 0; row < getHeight(); row++) 
+				for (int col = 0; col < getWidth(); col++) 
+					setElem(row, col, iBand, (double)notValidValue);
+		}
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.dataset.IRasterBuffer#free()
+	 */
+	public void free() throws IOException {
+		cache.clearCache();
+	}
+	
+	/*
+     *  (non-Javadoc)
+     * @see org.gvsig.fmap.driver.IRasterBuffer#cloneBuffer()
+     */
+    public Buffer cloneBuffer(){
+    	return null;
+    }
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/horizontal/RasterCacheBuffer.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/horizontal/DoubleBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/horizontal/DoubleBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/horizontal/DoubleBand.java	(revision 3222)
@@ -0,0 +1,135 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.horizontal;
+
+import org.gvsig.raster.cache.buffer.exception.InvalidPageNumberException;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.impl.RasterBuffer;
+import org.gvsig.raster.cache.buffer.impl.stripecache.CacheBand;
+import org.gvsig.raster.cache.buffer.impl.stripecache.LRUAlgorithm;
+
+
+/**
+ * This class represent a byte band loaded in cache.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class DoubleBand extends CacheBand {
+		
+	public DoubleBand(CacheHorzImpl cache, LRUAlgorithm lru, int band){
+		super(cache, lru, band);
+		this.setDataType(RasterBuffer.TYPE_DOUBLE);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.BandImpl#getNumberOfBlocks()
+	 */
+	public int getNumberOfBlocks() {
+		return (int)Math.ceil((double)getHeight() / (double)getBlockSize());
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#assign(double)
+	 */
+	public void assign(double value) {
+		for(int line = 0; line < getHeight(); line ++){
+			boolean beginLine = true;  //Para acelerar solo comprobar� si la p�gina est� en cach� cada vez que empieza una l�nea
+    		for(int col = 0; col < getWidth(); col ++){
+    			try {
+    				if(beginLine){
+    					lru.cacheAccess(line, false);
+    					beginLine = false;
+    				}
+    			} catch (InvalidPageNumberException e) {return;
+    			} catch (InterruptedException e) {return;}
+    			cache.getAccessPage().setElem((line & cache.getOffset()), col, nBand, value);		
+    		}
+		}
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getDoubleBlock(int)
+	 */
+	public double[][] getDoubleBlock(int block) {
+		int line = block * getBlockSize();
+		try {
+			lru.cacheAccess(line, true);
+		} catch (InvalidPageNumberException e) {return null;}
+		catch (InterruptedException e) {return null;}
+		return cache.getAccessPage().getBand(nBand).getDoubleBlock(block);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setDoubleBlock(double[][], int)
+	 */
+	public void setDoubleBlock(double[][] data, int block) {
+		int line = block * getBlockSize();
+		try {
+			lru.cacheAccess(line, true);
+		} catch (InvalidPageNumberException e) {return;}
+		catch (InterruptedException e) {return;}
+		try {
+			cache.getAccessPage().getBand(nBand).setDoubleBlock(data, block);
+		} catch (OperationNotSupportedException e) {
+			//Solo buffers de solo lectura
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getDoubleLine(int)
+	 */
+	public double[] getDoubleLine(int line) {
+		if(exists(line)) {
+			return cache.getAccessPage().getLineFromBandDouble(
+					(line & cache.getOffset()), nBand);
+		}
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getElemByte(int, int)
+	 */
+	public double getElemDouble(int line, int col) {
+		if(exists(line)) {
+			return cache.getAccessPage().getElemDouble(
+					(line & cache.getOffset()), col, nBand);
+		}
+		return getNoDataValue().getValue().doubleValue();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#setDoubleLine(double[], int)
+	 */
+	public void setDoubleLine(double[] data, int line) {
+		if(exists(line)) {
+			cache.getAccessPage().setLineInBandDouble(
+					data, (line & cache.getOffset()), nBand);
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#setElem(int, int, double)
+	 */
+	public void setElem(int line, int col, double data) {
+		if(exists(line)) {
+			cache.getAccessPage().setElem(
+					(line & cache.getOffset()), col, nBand, data);
+		}
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see java.lang.Object#clone()
+	 */
+	public Object clone() {
+		CacheHorzImpl cloneCache = (CacheHorzImpl)cache.clone();
+		LRUAlgorithm cloneLRU = new LRUAlgorithm(cloneCache);
+		return new DoubleBand(cloneCache, cloneLRU, nBand);
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/horizontal/DoubleBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/horizontal/IntBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/horizontal/IntBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/horizontal/IntBand.java	(revision 3222)
@@ -0,0 +1,135 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.horizontal;
+
+import org.gvsig.raster.cache.buffer.exception.InvalidPageNumberException;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.impl.RasterBuffer;
+import org.gvsig.raster.cache.buffer.impl.stripecache.CacheBand;
+import org.gvsig.raster.cache.buffer.impl.stripecache.LRUAlgorithm;
+
+
+/**
+ * This class represent a byte band loaded in cache.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class IntBand extends CacheBand {
+		
+	public IntBand(CacheHorzImpl cache, LRUAlgorithm lru, int band){
+		super(cache, lru, band);
+		this.setDataType(RasterBuffer.TYPE_INT);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.BandImpl#getNumberOfBlocks()
+	 */
+	public int getNumberOfBlocks() {
+		return (int)Math.ceil((double)getHeight() / (double)getBlockSize());
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#assign(int)
+	 */
+	public void assign(int value) {
+		for(int line = 0; line < getHeight(); line ++) {
+			boolean beginLine = true;  //Para acelerar solo comprobar� si la p�gina est� en cach� cada vez que empieza una l�nea
+    		for(int col = 0; col < getWidth(); col ++) {
+    			try {
+    				if(beginLine){
+    					lru.cacheAccess(line, false);
+    					beginLine = false;
+    				}
+    			} catch (InvalidPageNumberException e) {return;
+    			} catch (InterruptedException e) {return;}
+    			cache.getAccessPage().setElem((line & cache.getOffset()), col, nBand, value);		
+    		}
+		}
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getIntBlock(int)
+	 */
+	public int[][] getIntBlock(int block) {
+		int line = block * getBlockSize();
+		try {
+			lru.cacheAccess(line, true);
+		} catch (InvalidPageNumberException e) {return null;}
+		catch (InterruptedException e) {return null;}
+		return cache.getAccessPage().getBand(nBand).getIntBlock(block);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setIntBlock(int[][], int)
+	 */
+	public void setIntBlock(int[][] data, int block) {
+		int line = block * getBlockSize();
+		try {
+			lru.cacheAccess(line, true);
+		} catch (InvalidPageNumberException e) {return;}
+		catch (InterruptedException e) {return;}
+		try {
+			cache.getAccessPage().getBand(nBand).setIntBlock(data, block);
+		} catch (OperationNotSupportedException e) {
+			//Solo buffers de solo lectura
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getIntLine(int)
+	 */
+	public int[] getIntLine(int line) {
+		if(exists(line)) {
+			return cache.getAccessPage().getLineFromBandInt(
+					(line & cache.getOffset()), nBand);
+		}
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getElemInt(int, int)
+	 */
+	public int getElemInt(int line, int col) {
+		if(exists(line)) {
+			return cache.getAccessPage().getElemInt(
+					(line & cache.getOffset()), col, nBand);
+		}
+		return getNoDataValue().getValue().intValue();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#setIntLine(int[], int)
+	 */
+	public void setIntLine(int[] data, int line) {
+		if(exists(line)) {
+			cache.getAccessPage().setLineInBandInt(
+					data, (line & cache.getOffset()), nBand);
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#setElem(int, int, int)
+	 */
+	public void setElem(int line, int col, int data) {
+		if(exists(line)) {
+			cache.getAccessPage().setElem(
+					(line & cache.getOffset()), col, nBand, data);
+		}
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see java.lang.Object#clone()
+	 */
+	public Object clone() {
+		CacheHorzImpl cloneCache = (CacheHorzImpl)cache.clone();
+		LRUAlgorithm cloneLRU = new LRUAlgorithm(cloneCache);
+		return new IntBand(cloneCache, cloneLRU, nBand);
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/horizontal/IntBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/horizontal/ShortBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/horizontal/ShortBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/horizontal/ShortBand.java	(revision 3222)
@@ -0,0 +1,135 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.horizontal;
+
+import org.gvsig.raster.cache.buffer.exception.InvalidPageNumberException;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.impl.RasterBuffer;
+import org.gvsig.raster.cache.buffer.impl.stripecache.CacheBand;
+import org.gvsig.raster.cache.buffer.impl.stripecache.LRUAlgorithm;
+
+
+/**
+ * This class represent a byte band loaded in cache.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class ShortBand extends CacheBand {
+		
+	public ShortBand(CacheHorzImpl cache, LRUAlgorithm lru, int band){
+		super(cache, lru, band);
+		this.setDataType(RasterBuffer.TYPE_SHORT);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.BandImpl#getNumberOfBlocks()
+	 */
+	public int getNumberOfBlocks() {
+		return (int)Math.ceil((double)getHeight() / (double)getBlockSize());
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#assign(short)
+	 */
+	public void assign(short value) {
+		for(int line = 0; line < getHeight(); line ++){
+			boolean beginLine = true;  //Para acelerar solo comprobar� si la p�gina est� en cach� cada vez que empieza una l�nea
+    		for(int col = 0; col < getWidth(); col ++){
+    			try {
+    				if(beginLine){
+    					lru.cacheAccess(line, false);
+    					beginLine = false;
+    				}
+    			} catch (InvalidPageNumberException e) {return;
+    			} catch (InterruptedException e) {return;}
+    			cache.getAccessPage().setElem((line & cache.getOffset()), col, nBand, value);		
+    		}
+		}
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getShortBlock(int)
+	 */
+	public short[][] getShortBlock(int block) {
+		int line = block * getBlockSize();
+		try {
+			lru.cacheAccess(line, true);
+		} catch (InvalidPageNumberException e) {return null;}
+		catch (InterruptedException e) {return null;}
+		return cache.getAccessPage().getBand(nBand).getShortBlock(block);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setShortBlock(short[][], int)
+	 */
+	public void setShortBlock(short[][] data, int block) {
+		int line = block * getBlockSize();
+		try {
+			lru.cacheAccess(line, true);
+		} catch (InvalidPageNumberException e) {return;}
+		catch (InterruptedException e) {return;}
+		try {
+			cache.getAccessPage().getBand(nBand).setShortBlock(data, block);
+		} catch (OperationNotSupportedException e) {
+			//Solo buffers de solo lectura
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getShortLine(int)
+	 */
+	public short[] getShortLine(int line) {
+		if(exists(line)) {
+			return cache.getAccessPage().getLineFromBandShort(
+					(line & cache.getOffset()), nBand);
+		}
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getElemShort(int, int)
+	 */
+	public short getElemShort(int line, int col) {
+		if(exists(line)) {
+			return cache.getAccessPage().getElemShort(
+					(line & cache.getOffset()), col, nBand);
+		}
+		return getNoDataValue().getValue().shortValue();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#setShortLine(short[], int)
+	 */
+	public void setShortLine(short[] data, int line) {
+		if(exists(line)) {
+			cache.getAccessPage().setLineInBandShort(
+					data, (line & cache.getOffset()), nBand);
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#setElem(int, int, short)
+	 */
+	public void setElem(int line, int col, short data) {
+		if(exists(line)) {
+			cache.getAccessPage().setElem(
+					(line & cache.getOffset()), col, nBand, data);
+		}
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see java.lang.Object#clone()
+	 */
+	public Object clone() {
+		CacheHorzImpl cloneCache = (CacheHorzImpl)cache.clone();
+		LRUAlgorithm cloneLRU = new LRUAlgorithm(cloneCache);
+		return new ShortBand(cloneCache, cloneLRU, nBand);
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/horizontal/ShortBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/horizontal/CacheBandListHorz.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/horizontal/CacheBandListHorz.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/horizontal/CacheBandListHorz.java	(revision 3222)
@@ -0,0 +1,82 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.horizontal;
+
+import java.util.ArrayList;
+
+import org.gvsig.raster.cache.buffer.exception.WrongParameterException;
+import org.gvsig.raster.cache.buffer.impl.RasterBuffer;
+import org.gvsig.raster.cache.buffer.impl.stripecache.CacheBand;
+import org.gvsig.raster.cache.buffer.impl.stripecache.LRUAlgorithm;
+
+/**
+ * List of bands 
+ * 
+ * 21/10/2008
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class CacheBandListHorz extends ArrayList<CacheBand> {
+	private static final long serialVersionUID = 1L;
+
+	/*
+	 * (non-Javadoc)
+	 * @see java.util.ArrayList#remove(int)
+	 */
+	public CacheBand remove(int pos) {
+		CacheBand removedElement = super.remove(pos);
+		for (int i = pos; i < size(); i++) {
+			CacheBand b = get(i);
+			b.setBandNumber(b.getBandNumber() - 1);
+		}
+		return removedElement;
+	}
+	
+	/**
+	 * Add a new band in the selected position 
+	 * @param pos Position to add a band
+	 * @param cache Cache
+	 * @param lru  LRUAlgorithm
+	 * @param dataType 
+	 * @return Band added
+	 */
+	public CacheBand add(int pos, CacheHorzImpl cache, LRUAlgorithm lru, int dataType) {
+		for (int i = pos; i < size(); i++) 
+			get(i).setBandNumber(get(i).getBandNumber() + 1);
+		switch(dataType) {
+    	case RasterBuffer.TYPE_BYTE: ByteBand bb = new ByteBand(cache, lru, pos);
+    								add(pos, bb);
+    								return bb;
+    	case RasterBuffer.TYPE_SHORT: ByteBand sb = new ByteBand(cache, lru, pos);
+    								add(pos, sb);
+    								return sb;
+    	case RasterBuffer.TYPE_INT: ByteBand ib = new ByteBand(cache, lru, pos);
+    								add(pos, ib);
+    								return ib;
+    	case RasterBuffer.TYPE_FLOAT: ByteBand fb = new ByteBand(cache, lru, pos); 
+									add(pos, fb);
+    								return fb;
+    	case RasterBuffer.TYPE_DOUBLE: ByteBand db = new ByteBand(cache, lru, pos);
+									add(pos, db);
+    								return db;
+    	}
+		return null;
+	}
+	
+	/**
+	 * Swap bands according to positions selected in bandPosition parameter. 
+	 * 
+	 * @param  bandPosition
+	 *         New order for the bands in the array. Each position in the array represent the old band
+	 *         .The number that it contains represent the new position of that band. For instance, an
+	 *         array with values {1, 0, 2, 3} means that it has four bands and the band number one is swaped
+	 *         with the band number zero. The bands two and three don't change its position in this example.   			
+	 * @throws WrongParameterException
+	 */
+	public void swapBands(int[] bandPosition) throws WrongParameterException {
+		CacheBandListHorz cbl = (CacheBandListHorz)this.clone();
+		for (int i = 0; i < bandPosition.length; i++) {
+			CacheBand cb = cbl.get(bandPosition[i]);
+			cb.setBandNumber(i);
+			add(i, cb);
+			remove(size() - 1);
+		}
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/horizontal/CacheBandListHorz.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/horizontal/ByteBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/horizontal/ByteBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/horizontal/ByteBand.java	(revision 3222)
@@ -0,0 +1,142 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.horizontal;
+
+import org.gvsig.raster.cache.buffer.exception.InvalidPageNumberException;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.impl.RasterBuffer;
+import org.gvsig.raster.cache.buffer.impl.stripecache.Cache;
+import org.gvsig.raster.cache.buffer.impl.stripecache.CacheBand;
+import org.gvsig.raster.cache.buffer.impl.stripecache.LRUAlgorithm;
+
+
+/**
+ * This class represent a byte band loaded in cache.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class ByteBand extends CacheBand {
+		
+	/**
+	 * Create a empty band asociated to existing cache
+	 * @param cache 
+	 * @param lru
+	 * @param band
+	 */
+	public ByteBand(Cache cache, LRUAlgorithm lru, int band) {
+		super(cache, lru, band);
+		this.setDataType(RasterBuffer.TYPE_BYTE);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getNumberOfBlocks()
+	 */
+	public int getNumberOfBlocks() {
+		return (int)Math.ceil((double)getHeight() / (double)getBlockSize());
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#assign(byte)
+	 */
+	public void assign(byte value) {
+		for(int line = 0; line < getHeight(); line ++) {
+			boolean beginLine = true;  //Para acelerar solo comprobar� si la p�gina est� en cach� cada vez que empieza una l�nea
+    		for(int col = 0; col < getWidth(); col ++) {
+    			try {
+    				if(beginLine) {
+    					lru.cacheAccess(line, false);
+    					beginLine = false;
+    				}
+    			} catch (InvalidPageNumberException e) {return;
+    			} catch (InterruptedException e) {return;}
+    			cache.getAccessPage().setElem((line & cache.getOffset()), col, nBand, value);		
+    		}
+		}
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getByteBlock(int)
+	 */
+	public byte[][] getByteBlock(int block) {
+		int line = block * getBlockSize();
+		try {
+			lru.cacheAccess(line, true);
+		} catch (InvalidPageNumberException e) {return null;}
+		catch (InterruptedException e) {return null;}
+		return cache.getAccessPage().getBand(nBand).getByteBlock(block);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setByteBlock(byte[][], int)
+	 */
+	public void setByteBlock(byte[][] data, int block) {
+		int line = block * getBlockSize();
+		try {
+			lru.cacheAccess(line, true);
+		} catch (InvalidPageNumberException e) {return;}
+		catch (InterruptedException e) {return;}
+		try {
+			cache.getAccessPage().getBand(nBand).setByteBlock(data, block);
+		} catch (OperationNotSupportedException e) {
+			//Solo buffers de solo lectura
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getByteLine(int)
+	 */
+	public byte[] getByteLine(int line) {
+		if(exists(line)) {
+			return cache.getAccessPage().getLineFromBandByte(
+					(line & cache.getOffset()), nBand);
+		}
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getElemByte(int, int)
+	 */
+	public byte getElemByte(int line, int col) {
+		if(exists(line)) {
+			return cache.getAccessPage().getElemByte(
+					(line & cache.getOffset()), col, nBand);
+		}
+		return getNoDataValue().getValue().byteValue();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#setByteLine(byte[], int)
+	 */
+	public void setByteLine(byte[] data, int line) {
+		if(exists(line)) {
+			cache.getAccessPage().setLineInBandByte(
+					data, (line & cache.getOffset()), nBand);
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#setElem(int, int, byte)
+	 */
+	public void setElem(int line, int col, byte data) {
+		if(exists(line)) {
+			cache.getAccessPage().setElem(
+					(line & cache.getOffset()), col, nBand, data);
+		}
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see java.lang.Object#clone()
+	 */
+	public Object clone() {
+		CacheHorzImpl cloneCache = (CacheHorzImpl)cache.clone();
+		LRUAlgorithm cloneLRU = new LRUAlgorithm(cloneCache);
+		return new ByteBand(cloneCache, cloneLRU, nBand);
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/horizontal/ByteBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/horizontal/CacheHorzImpl.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/horizontal/CacheHorzImpl.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/horizontal/CacheHorzImpl.java	(revision 3222)
@@ -0,0 +1,780 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.horizontal;
+
+import java.io.IOException;
+
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.exception.WrongParameterException;
+import org.gvsig.raster.cache.buffer.impl.stripecache.Cache;
+import org.gvsig.raster.cache.buffer.impl.stripecache.CacheStruct;
+import org.gvsig.raster.cache.buffer.impl.stripecache.HDDPageList;
+import org.gvsig.raster.cache.buffer.impl.stripecache.PageBuffer;
+import org.gvsig.raster.cache.buffer.impl.stripecache.PageCacheList;
+
+/**
+ * <P>
+ * Esta clase representa a la cache raster. Consta de una ser�e de p�ginas (CachePages)
+ * que son buffers con los bloques de datos cacheados en un instante dado. Esta cache tiene 
+ * una estructura en forma de array donde cada elemento es una p�gina de cach�. Las p�ginas 
+ * se agrupan en bloques de N p�ginas denominados grupos. La variable nelemsGroup contiene 
+ * el n�mero de p�ginas de cada grupo.
+ * </P>
+ * <P>
+ * La politica de reemplazo es que una p�gina siempre va a un conjunto determinado por el calculo
+ * cto = pag % nelemsGroup. Si hay hueco vac�o en el grupo se a�adir� en el siguiente hueco pero
+ * si hay que reeplazar se reeplazar� la p�gina que m�s tiempo haga su �ltimo acceso. 
+ * </P>
+ * <P>
+ * Esta cach� lleva el control de que p�ginas est�n cargadas a trav�s de un array de de booleanos
+ * donde cada elemento representa a una p�gina de datos del raster. Si el elemento en la posici�n
+ * N de dicho array es true significa que la p�gina est� cacheada. Si es false no lo estar�. 
+ * </P>
+ * <P>
+ * La p�gina de datos actualmente accedida debe estar cacheada por lo que est� clase debe llevar
+ * el control de que p�gina se est� accediendo o a sido accedida por �ltima vez. La variable que
+ * nos dice que p�gina est� siendo accedida es loadPage y pageBuffer ser� la variable que apunta
+ * al buffer de esta p�gina. Cuando se cambia de p�gina en un acceso estas dos variables deben
+ * cambiar a sus nuevos valores.
+ * </P>
+ * <P>
+ * Otro par�metro que controla esta clase es que p�gina de cada grupo ha sido accedido con mayor 
+ * frecuencia. Esto es �til porque siempre se reemplaza la p�gina de un grupo que haga m�s tiempo
+ * que haya sido accedida bajo la premisa de que "las p�ginas con accesos recientes tienen mayor 
+ * probabilidad de volver a ser usadas". Esto es controlado por la variable lastAccess que es
+ * usada para implementar el algoritmo LRU. Cada vez que una p�gina de un grupo es accedida su 
+ * contador de lastAccess se pone a 0. El resto de contadores de las p�ginas del grupo se incrementa
+ * en uno. Siempre se sustituye la p�gina del grupo con valor m�s grande en el contador.
+ * </P>
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ *
+ */
+public class CacheHorzImpl implements Cache {
+	/**
+	 * List of pages in disk. This array represents all pages
+	 */
+	protected HDDPageList     hddPageList            = null;
+	/**
+	 * List of pages in memory. This array represents cached pages
+	 */
+	protected PageCacheList   pageCacheList          = null;
+	/**
+	 * Cada elemento es una p�gina del raster y dice si est� cacheada o no.
+	 */
+	protected boolean[]       cacheada               = null;
+	/**
+	 * N�mero de p�gina cargada en accessPage.
+	 */
+	protected int             numberInAccessPage     = -1;
+	/**
+	 * Buffer de datos de la p�gina actualmente accedida.
+	 */
+	protected PageBuffer      accessPage             = null;
+	/**
+	 * Cada elemento del array es una p�gina de cach� y contiene el n�mero de p�gina cargada en 
+	 * esa posici�n.
+	 */
+	protected int[]	          pageNumberInCache      = null;
+	/**  
+	 * P�ginas de la cach�.
+	 */
+	protected CacheStruct     cacheStruct            = null;
+	/**
+	 * �ltimo acceso a las p�ginas de cada grupo. Valores de la antig�edad del acceso dentro del
+	 * grupo. La primera dimensi�n del array corresponde al n�mero de grupo y la segunda
+	 * a los elementos del grupo. El elemento del grupo con un acceso m�s reciente tendr� 
+	 * un n�mero menor y el de mayor valor ser� el candidato para la sustituci�n en el pr�ximo
+	 * remplazamiento
+	 */
+	protected int[][]         lastAccess             = null;
+	/**
+	 * Cada elemento representa una p�gina de cach� y dice si esta ha sido modificada desde que
+	 * fu� cargada en cach� o no.
+	 */
+	protected boolean[]        modified              = null;
+	
+	protected int              dataSourceWidth       = 0;
+	protected int              dataSourceHeight      = 0;
+		
+	/**
+	 * Inicializamos la variables. Para ello creamos el objeto Cache que contendr� todos los 
+	 * par�metros necesarios para crear el array que controla los accesos m�s recientes y el
+	 * array que dice si una p�gina est� en memoria o no.
+	 * @param nBands N�mero de bandas
+	 * @param dataType Tipo de dato de la p�gina
+	 * @param dataSourceWidth ancho de la fuente de datos
+	 */
+	public CacheHorzImpl(int nBands, int dataType, int dataSourceWidth, int dataSourceHeight) {
+		this.dataSourceHeight = dataSourceHeight;
+		this.dataSourceWidth = dataSourceWidth;
+		init(nBands, dataType, dataSourceWidth, dataSourceHeight);
+	}
+	
+	/**
+	 * Contructor
+	 * @param cacheStruct
+	 */
+	public CacheHorzImpl(CacheStruct cacheStruct) {
+		this.cacheStruct = cacheStruct;
+		
+		//Inicializamos la antig�edad de acceso  
+		lastAccess = new int[cacheStruct.getNGroups()][cacheStruct.getPagsPerGroup()];
+		
+		//Creamos el buffer de la cach�
+		//page = new PageBuffer[cacheStruct.getNPags()];
+		pageNumberInCache = new int[cacheStruct.getNPags()];
+		modified = new boolean[cacheStruct.getNPags()];
+		cacheada = new boolean[cacheStruct.getNTotalPags()];
+		
+		initStructs();
+		initPointers();
+		
+		createPages(getNBands());
+	}
+	
+	/**
+	 * Initialize arrays and data structures
+	 * @param nBands
+	 * @param dataType
+	 * @param dataSourceWidth
+	 * @param dataSourceHeight
+	 */
+	protected void init(int nBands, int dataType, int dataSourceWidth, int dataSourceHeight) {
+		//Creamos la estructura de la cach�
+		cacheStruct = new CacheStruct(nBands, dataType, dataSourceWidth, dataSourceHeight);
+		
+		//Inicializamos la antig�edad de acceso  
+		lastAccess = new int[cacheStruct.getNGroups()][cacheStruct.getPagsPerGroup()];
+		
+		//Creamos el buffer de la cach�
+		pageNumberInCache = new int[cacheStruct.getNPags()];
+		modified = new boolean[cacheStruct.getNPags()];
+		cacheada = new boolean[cacheStruct.getNTotalPags()];
+				
+		initStructs();
+		initPointers();
+		
+		createPages(getNBands());
+	}
+		
+	/**
+	 * Inicializa las estructuras de mantenimiento de cach�. Estas son array de paginas
+	 * accedidas por �ltima vez, numeros de p�gina cargadas en cada posici�n de cach�, 
+	 * array con la informaci�n de p�gina modificada y array que dice si una p�gina de disco
+	 * est� cacheada o no.
+	 */
+	protected void initStructs() {
+		for(int i = 0; i < cacheStruct.getNGroups(); i ++)
+			for(int j = 0; j < cacheStruct.getPagsPerGroup(); j ++)
+				lastAccess[i][j] = -1;
+		
+		for(int i = 0; i < cacheada.length; i++)
+			cacheada[i] = false;
+		
+		
+		for(int i = 0; i < cacheStruct.getNPags(); i++) {
+			//pageNumberInCache[i] = -1;
+			modified[i] = false;
+		}		
+	}
+	
+	protected void initPointers() {
+		int cont = 0;
+		for(int iGroup = 0; iGroup < cacheStruct.getNGroups(); iGroup ++) {
+			for(int iPagPerGroup = 0; iPagPerGroup < cacheStruct.getPagsPerGroup(); iPagPerGroup ++) {
+				int pag = iGroup + (cacheStruct.getNGroups() * iPagPerGroup);
+				pageNumberInCache[cont] = pag;
+				if(pag < cacheada.length - 1)
+					cacheada[pag] = true;
+				cont ++;
+			}
+		}	
+	}
+	
+	/**
+	 * Create new and empty pages with the structure information of
+	 * this cache
+	 */
+	public void createPages(int bands) {
+		hddPageList = new HDDPageList(cacheStruct.getNTotalPags(), bands);
+		pageCacheList = new PageCacheList(cacheStruct.getNPags(),
+										bands,
+										cacheStruct.getHPag(),
+										cacheStruct.getDataType(),
+										dataSourceWidth);
+		pageCacheList.setHddPages(hddPageList);
+	}
+	
+	/**
+	 * Load the cache status selected in the parameter. The array has one position for each
+	 * page of cache. In each position has the page number loaded in that memory place.
+	 *  
+	 * @param pageNumberInCache Array of positions
+	 * @throws InterruptedException 
+	 */
+	public void loadCacheStatus(int[] pageNumberInCache) throws InterruptedException {
+		if(pageNumberInCache.length != pageCacheList.size())
+			return;
+		for (int iPage = 0; iPage < pageNumberInCache.length; iPage++) 
+			pageCacheList.get(iPage).loadPage(pageNumberInCache[iPage]);
+	}
+	
+	/**
+	 * Limpia los trozos de cach� en disco. Despu�s del llamar a este 
+	 * m�todo no puede volver a usarse esta cach�.
+	 * @throws IOException 
+	 */
+	public void clearCache() throws IOException {
+		pageCacheList.clearPageList();
+		hddPageList.clearPageList();
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#getBitsPag()
+	 */
+	public int getBitsPag() {
+		return cacheStruct.getBitsPag();
+	}
+
+	/**
+	 * Obtiene la altura de la p�gina de cache en l�neas. 
+	 * @return N�mero de l�neas de altura de p�gina.
+	 */
+	public int getHPag() {
+		return cacheStruct.getHPag();
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#isInCache(int)
+	 */
+	public boolean isInCache(int nPag) {
+		/*if(nPag < 0 || nPag >= cacheada.length)
+			return false;*/
+		return cacheada[nPag];
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#setPageAsLoadInCache(int)
+	 */
+	public void setPageAsLoadInCache(int nPag) {
+		if(nPag < 0 || nPag >= cacheada.length)
+			return;
+		cacheada[nPag] = true;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#setPageAsNotLoadInCache(int)
+	 */
+	public void setPageAsNotLoadInCache(int nPag) {
+		if(nPag < 0 || nPag >= cacheada.length)
+			return;
+		cacheada[nPag] = false;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#getRasterPageNumberInPosition(int)
+	 */
+	public int getRasterPageNumberInPosition(int nCachePage) {
+		return pageNumberInCache[nCachePage];
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#getRasterPageNumberInPosition(int, int)
+	 */
+	public int getRasterPageNumberInPosition(int group, int posInGroup) {
+		return pageNumberInCache[group * getPagsPerGroup() + posInGroup];
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#setRasterPageNumberInPosition(int, int)
+	 */
+	public void setRasterPageNumberInPosition(int nCachePage, int nRasterPage) {
+		pageNumberInCache[nCachePage] = nRasterPage;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#setRasterPageNumberInPosition(int, int, int)
+	 */
+	public void setRasterPageNumberInPosition(int group, int posInGroup, int nRasterPage) {
+		pageNumberInCache[group * getPagsPerGroup() + posInGroup] = nRasterPage;
+	}
+	
+	/**
+	 * Obtiene el n�mero de p�gina de cach� donde est� cargada la p�gina del raster
+	 * que se ha pasado por par�metro.
+	 * @param pag P�gina del raster
+	 * @return N�mero de p�gina del raster
+	 */
+	public int getNumberCachePageFromNumberRasterPage(int pag) {
+		int group = pag % getNGroups(); 
+		for(int i = 0; i < getPagsPerGroup(); i++)
+			if(pageNumberInCache[group + i] == pag)
+				return (group * getPagsPerGroup() + i);
+		return -1;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#getNumberGroupFromNumberRasterPage(int)
+	 */
+	public int[] getNumberGroupFromNumberRasterPage(int pag) {
+		int group = pag % getNGroups();
+		for(int i = 0; i < getPagsPerGroup(); i++)
+			if(pageNumberInCache[(group * getPagsPerGroup()) + i] == pag)
+				return new int[]{group, i};
+		return null;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#getLastAccess()
+	 */
+	public int[][] getLastAccess() {
+		return lastAccess;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#setZeroInLastAccess(int, int)
+	 */
+	public void setZeroInLastAccess(int group, int posInGroup) {
+		lastAccess[group][posInGroup] = 0;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#getNumberInAccessPage()
+	 */
+	public int getNumberInAccessPage() {
+		return numberInAccessPage;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#getPagsPerGroup()
+	 */
+	public int getPagsPerGroup() {
+		return cacheStruct.getPagsPerGroup();
+	}
+
+	/**
+	 * Obtiene la p�gina de datos de la posici�n pag
+	 * @param pag N�mero de p�gina de cach� a recuperar
+	 * @return PageBuffer correspondiente a la p�gina recuperada
+	 */
+	public PageBuffer getPageBufferFromNumberCachePage(int pag) {
+		return pageCacheList.get(pag);
+	}
+	
+	/**
+	 * Obtiene la p�gina de datos a partir del n�mero de p�gina de raster
+	 * @param pag N�mero de p�gina raster a recuperar
+	 * @return PageBuffer correspondiente a la p�gina recuperada o null si no est� en cach�
+	 */
+	public PageBuffer getPageBufferFromNumberRasterPage(int pag) {
+		int group = pag % getNGroups();
+		for(int i = 0; i < getPagsPerGroup(); i++)
+			if(pageNumberInCache[group * getPagsPerGroup() + i] == pag)
+				return pageCacheList.get(group * getPagsPerGroup() + i);
+		return null;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#getPageBuffer(int, int)
+	 */
+	public PageBuffer getPageBuffer(int group, int posInGroup) {
+		return pageCacheList.get(group * getPagsPerGroup() + posInGroup);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.cachete.buffer.stripecache.ICache#getAccessPage()
+	 */
+	public PageBuffer getAccessPage() {
+		return accessPage;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#setAccessPage(org.gvsig.raster.cache.buffer.impl.stripecache.horizontal.PageBuffer, int)
+	 */
+	public void setAccessPage(PageBuffer pb, int pagNumber) {
+		accessPage = pb;
+		numberInAccessPage = pagNumber;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#isModified(int)
+	 */
+	public boolean isModified(int nCachePag) {
+		return modified[nCachePag];
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#isModified(int, int)
+	 */
+	public boolean isModified(int group, int posInGroup) {
+		return modified[group * getPagsPerGroup() + posInGroup];
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#setModify(int)
+	 */
+	public void setModify(int nCachePag) {
+		modified[nCachePag] = true;	
+	}
+	
+	/**
+	 * Pone como modificada una p�gina de cach�
+	 * @param group Grupo en el que se encuentra la p�gina
+	 * @param posInGroup Posici�n dentro del grupo en el que est� la p�gina
+	 */
+	public void setModify(int group, int posInGroup) {
+		modified[group * getPagsPerGroup() + posInGroup] = true;	
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#unsetModify(int)
+	 */
+	public void unsetModify(int nCachePag) {
+		modified[nCachePag] = false;	
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#unsetModify(int, int)
+	 */
+	public void unsetModify(int group, int posInGroup) {
+		modified[group * getPagsPerGroup() + posInGroup] = false;	
+	}
+	
+	/**
+	 * Obtiene el n�mero de p�ginas de la cach�
+	 * @return N�mero total de p�ginas de la cach�
+	 */
+	public int getNPags() {
+		return cacheStruct.getNPags();
+	}
+	
+	/**
+	 * Obtiene el n�mero de bandas
+	 * @return N�mero de bandas
+	 */
+	public int getNBands() {
+		return cacheStruct.getNBands();
+	}
+	
+	/**
+	 * Obtiene la estructura de ca cach�
+	 * @return CacheStruct
+	 */
+	public CacheStruct getCacheStruct() {
+		return cacheStruct;
+	}
+	
+	/**
+	 * Asigna la estructura de ca cach�
+	 * @param CacheStruct
+	 */
+	public void setCacheStruct(CacheStruct cacheStruct) {
+		this.cacheStruct = cacheStruct;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#getNGroups()
+	 */
+	public int getNGroups() {
+		return cacheStruct.getNGroups();
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#getNTotalPags()
+	 */
+	public int getNTotalPags() {
+		return cacheStruct.getNTotalPags();
+	}
+	
+	/**
+	 * Obtiene el array con los n�meros de p�gina que hay cargados
+	 * en cada bloque de cache
+	 * @return array con los n�mero de p�gina
+	 */
+	public int[] getPageNumberInCache() {
+		return this.pageNumberInCache;
+	}
+	
+	/**
+	 * Para extraer el desplazamiento de una direcci�n (l�nea de raster) hay que hacer una operaci�n And con 
+	 * con la altura de la p�gina -1. Por ejemplo, una p�gina de 16 l�neas de altura el desplazamiento ser�
+	 * 16 - 1 = 15 porque 15 en binario es 1111.
+	 * 
+	 * Si queremos acceder a la linea del raster n�mero 83 (1010011) realizando la operaci�n And con el valor del
+	 * desplazamiento obtenemos (0001111 & 1010011 = 0000011), es decir el valor 3 en decimal. Esto quiere decir
+	 * que la l�nea 83 del raster es la 3 de su p�gina. 
+	 * @return valor del desplazamiento
+	 */
+	public int getOffset() {
+		return cacheStruct.getOffset();
+	}
+	
+	/**
+	 * Convierte una p�gina dentro de un grupo de la cach� en un n�mero de 
+	 * p�gina de cach�. Por ejemplo, en una cach� de 10 grupos y 5 p�ginas por grupo
+	 * la p�gina 2 del grupo 4 devolver� el 23 (5 * 4 + 3 = 23) teniendo en cuenta que
+	 * la p�gina y el grupo cero tambi�n cuentan.  
+	 * @param group
+	 * @param pageInGroup
+	 * @return
+	 */
+	public int convertPageInGroupToPageInCache(int group, int pageInGroup) {
+		return (group * cacheStruct.getPagsPerGroup() + pageInGroup);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#updateLastAccess(int)
+	 */
+	public int updateLastAccess(int group) {
+		int max = Integer.MIN_VALUE;
+		int posMax = 0;
+		for(int i = 0; i < getPagsPerGroup(); i++) {
+			if(getLastAccess()[group][i] >= 0)
+				getLastAccess()[group][i] ++;
+			
+			if(getLastAccess()[group][i] > max) {
+				max = getLastAccess()[group][i];
+				posMax = i;
+			}
+		}
+		return posMax;
+	}
+	
+	/**
+	 * Obtiene la posici�n del grupo de la p�gina a reemplazar, es decir la de m�ximo valor
+	 * en el vector lastAccess.
+	 * @param group N�mero de grupo a obtener la p�gina de reemplazo
+	 * @return La posici�n del elemento del grupo con valor m�ximo. Este elemento 
+	 * es el candidato para el reemplazo.
+	 */
+	public int posInGroupPagToReplace(int group) {
+		int max = Integer.MIN_VALUE;
+		int posMax = 0;
+		for(int i = 0; i < getPagsPerGroup(); i++) {
+			if(getLastAccess()[group][i] > max) {
+				max = getLastAccess()[group][i];
+				posMax = i;
+			}
+		}
+		return posMax;
+	} 
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#loadPage(int, int, int)
+	 */
+	public void loadPage(int group, int posInGroupPageToReplace, int nPag) throws InterruptedException {
+		pageCacheList.get(group * getPagsPerGroup() + posInGroupPageToReplace).loadPage(nPag);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#savePage(int, int, int)
+	 */
+	public void savePage(int group, int posInGroupPageToReplace, int nPag) throws IOException {
+		pageCacheList.get(group * getPagsPerGroup() + posInGroupPageToReplace).savePage(nPag);
+	}
+
+	/**
+	 * Salva a disco todas las p�ginas en memoria cach� e inicializa estructuras de datos.
+	 * 
+	 * @throws IOException
+	 */
+	public void resetCache() throws IOException {
+		for (int iCachePage = 0; iCachePage < pageCacheList.size(); iCachePage++) { 
+			if(modified[iCachePage])
+				pageCacheList.get(iCachePage).savePage(this.getRasterPageNumberInPosition(iCachePage));
+		}
+		initStructs();
+	}
+	
+	/**
+	 * Remove the selected cache band from disk and memory
+	 * @param iBand Band number to remove
+	 * @throws IOException 
+	 */
+	public void removeBand(int pos) throws IOException {
+		pageCacheList.removeBand(pos);
+		hddPageList.removeBand(pos);
+	}
+	
+	/**
+	 * Add an empty band in the cache
+	 * @param iBand Band number to add
+	 * @throws IOException 
+	 */
+	public void addBand(int pos) throws IOException {
+		resetCache();
+		pageCacheList.addBand(pos);
+		PageBuffer buf = new PageBuffer(cacheStruct.getDataType(), dataSourceWidth, cacheStruct.getHPag(), 1, true);
+		hddPageList.addBand(pos, buf);
+	}
+	
+	/**
+	 * Add a band in the cache
+	 * @param iBand Band number to add
+	 * @param Band Band to add
+	 * @throws IOException 
+	 */
+	public void addBand(int pos, Band band) throws IOException {
+		resetCache();
+		pageCacheList.addBand(pos);
+		PageBuffer buf = new PageBuffer(cacheStruct.getDataType(), dataSourceWidth, band.getBlockSize(), 1, true);
+		hddPageList.addBand(pos, band, buf);
+	}
+	
+	/**
+	 * Swap bands accordint to positions selected in bandPosition parameter.
+	 * 
+	 * @param  bandPosition
+	 *         New order for the bands in the array. Each position in the array represent the old band
+	 *         .The number that it contains represent the new position of that band. For instance, an
+	 *         array with values {1, 0, 2, 3} means that it has four bands and the band number one is swaped
+	 *         with the band number zero. The bands two and three don't change its position in this example.   			
+	 * @throws WrongParameterException
+	 * @throws IOException 
+	 */
+	 public void swapBands(int[] bandPosition) throws WrongParameterException, IOException {
+		resetCache();
+		pageCacheList.swapBands(bandPosition);
+		hddPageList.swapBands(bandPosition);
+	 }
+			
+	/**
+	 * Consulta si alguna p�gina de memoria tiene modificaciones para volcar a disco
+	 * @return true si hay alguna p�gina con modificaciones y false si no la hay
+	 */
+	public boolean anyPageModified() {
+		for (int iPage = 0; iPage < modified.length; iPage++) {
+			if(modified[iPage])
+				return true;
+		}
+		return false;
+	}
+	
+	/**
+	 * Get the width of the data source
+	 * @return int
+	 */
+	public int getDataSourceWidth() {
+		return dataSourceWidth;
+	}
+
+	/**
+	 * Get the height of the data source
+	 * @return int
+	 */
+	public int getDataSourceHeight() {
+		return dataSourceHeight;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see java.lang.Object#clone()
+	 */
+	public Object clone() {
+		CacheHorzImpl clon = cloneStructure();
+		clon.hddPageList = (HDDPageList)hddPageList.clone();
+		clon.pageCacheList = (PageCacheList)pageCacheList.clone();
+		clon.pageCacheList.setHddPages(clon.hddPageList);
+		return clon;
+	}
+	
+	/**
+	 * Clone the cache structure without clone data pages neither disk pages 
+	 * @return Cache
+	 */
+	public CacheHorzImpl cloneStructure() {
+		CacheHorzImpl clon = new CacheHorzImpl(cacheStruct.getNBands(), cacheStruct.getDataType(), dataSourceWidth, dataSourceHeight);
+		for (int i = 0; i < cacheada.length; i++) 
+			clon.cacheada[i] = cacheada[i];
+		clon.numberInAccessPage = numberInAccessPage;
+		for (int i = 0; i < pageNumberInCache.length; i++) 
+			clon.pageNumberInCache[i] = pageNumberInCache[i];
+		for (int i = 0; i < lastAccess.length; i++) {
+			for (int j = 0; j < lastAccess[i].length; j++) {
+				clon.lastAccess[i][j] = lastAccess[i][j];
+			}
+		}
+		for (int i = 0; i < modified.length; i++)
+			clon.modified[i] = modified[i];
+		clon.cacheStruct = (CacheStruct)cacheStruct.clone();
+		return clon;
+	}
+
+	/**
+	 * Imprime la informaci�n de estructura de cach�
+	 */
+	public void show() {
+		((org.gvsig.raster.cache.buffer.impl.stripecache.CacheStruct)cacheStruct).show();
+		System.out.println("Cacheada:");
+		for(int i = 0; i < cacheada.length; i++)
+			System.out.print(i + "=" + cacheada[i]+" ");
+		System.out.println();
+		System.out.println("LastAccess:");
+		for(int i = 0; i < cacheStruct.getNGroups(); i++) {
+			System.out.println("Grupo " + i +":");
+			for(int j = 0; j < cacheStruct.getPagsPerGroup(); j++)
+				System.out.println("elem " + j + " : " + "Page " + pageNumberInCache[i * cacheStruct.getPagsPerGroup() + j] + " : " + lastAccess[i][j]);
+		
+		}
+	}
+	
+	/**
+	 * Imprime la informaci�n de estructura de cach�
+	 * @throws IOException 
+	 */
+//	public void log(String txt) {
+//		try {
+//			FileServices.getDesc().write(txt);
+//			FileServices.getDesc().newLine();
+//			FileServices.getDesc().write("**** Pag(i) = �Cacheada?: ****");
+//			FileServices.getDesc().newLine();
+//			/*for(int i = 0; i < cacheada.length; i++) {
+//				TxtIO.getDesc().write(i + "=" + cacheada[i] + " ");
+//				TxtIO.getDesc().newLine();
+//			}*/
+//
+//			FileServices.getDesc().write("Numero pag en accessPage: " + numberInAccessPage);
+//			FileServices.getDesc().newLine();
+//			FileServices.getDesc().write("Accesos:");
+//			FileServices.getDesc().newLine();
+//			int count = 0;
+//			for(int i = 0; i < cacheStruct.getNGroups(); i++) {
+//				FileServices.getDesc().write("--->Grupo " + i +":");
+//				FileServices.getDesc().newLine();
+//				for(int j = 0; j < cacheStruct.getPagsPerGroup(); j++) {
+//					FileServices.getDesc().write("Pos:" + count + ", Pos grupo:" + j + " : " + ", Pag en esta pos: " + pageNumberInCache[i * cacheStruct.getPagsPerGroup() + j] + " Access:" + lastAccess[i][j]);
+//					FileServices.getDesc().newLine();
+//					count ++;
+//				}		
+//			}
+//		} catch (IOException e) {
+//			e.printStackTrace();
+//		}
+//	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/horizontal/CacheHorzImpl.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/horizontal/FloatBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/horizontal/FloatBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/horizontal/FloatBand.java	(revision 3222)
@@ -0,0 +1,135 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.horizontal;
+
+import org.gvsig.raster.cache.buffer.exception.InvalidPageNumberException;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.impl.RasterBuffer;
+import org.gvsig.raster.cache.buffer.impl.stripecache.CacheBand;
+import org.gvsig.raster.cache.buffer.impl.stripecache.LRUAlgorithm;
+
+
+/**
+ * This class represent a byte band loaded in cache.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class FloatBand extends CacheBand {
+		
+	public FloatBand(CacheHorzImpl cache, LRUAlgorithm lru, int band){
+		super(cache, lru, band);
+		this.setDataType(RasterBuffer.TYPE_FLOAT);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.BandImpl#getNumberOfBlocks()
+	 */
+	public int getNumberOfBlocks() {
+		return (int)Math.ceil((double)getHeight() / (double)getBlockSize());
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#assign(float)
+	 */
+	public void assign(float value) {
+		for(int line = 0; line < getHeight(); line ++){
+			boolean beginLine = true;  //Para acelerar solo comprobar� si la p�gina est� en cach� cada vez que empieza una l�nea
+    		for(int col = 0; col < getWidth(); col ++){
+    			try {
+    				if(beginLine){
+    					lru.cacheAccess(line, false);
+    					beginLine = false;
+    				}
+    			} catch (InvalidPageNumberException e) {return;
+    			} catch (InterruptedException e) {return;}
+    			cache.getAccessPage().setElem((line & cache.getOffset()), col, nBand, value);		
+    		}
+		}
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getFloatBlock(int)
+	 */
+	public float[][] getFloatBlock(int block) {
+		int line = block * getBlockSize();
+		try {
+			lru.cacheAccess(line, true);
+		} catch (InvalidPageNumberException e) {return null;}
+		catch (InterruptedException e) {return null;}
+		return cache.getAccessPage().getBand(nBand).getFloatBlock(block);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setFloatBlock(float[][], int)
+	 */
+	public void setFloatBlock(float[][] data, int block) {
+		int line = block * getBlockSize();
+		try {
+			lru.cacheAccess(line, true);
+		} catch (InvalidPageNumberException e) {return;}
+		catch (InterruptedException e) {return;}
+		try {
+			cache.getAccessPage().getBand(nBand).setFloatBlock(data, block);
+		} catch (OperationNotSupportedException e) {
+			//Solo buffers de solo lectura
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getFloatLine(int)
+	 */
+	public float[] getFloatLine(int line) {
+		if(exists(line)) {
+			return cache.getAccessPage().getLineFromBandFloat(
+					(line & cache.getOffset()), nBand);
+		}
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getElemByte(int, int)
+	 */
+	public float getElemFloat(int line, int col) {
+		if(exists(line)) {
+			return cache.getAccessPage().getElemFloat(
+					(line & cache.getOffset()), col, nBand);
+		}
+		return getNoDataValue().getValue().floatValue();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#setByteLine(float[], int)
+	 */
+	public void setByteLine(float[] data, int line) {
+		if(exists(line)) {
+			cache.getAccessPage().setLineInBandFloat(
+					data, (line & cache.getOffset()), nBand);
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#setElem(int, int, float)
+	 */
+	public void setElem(int line, int col, float data) {
+		if(exists(line)) {
+			cache.getAccessPage().setElem(
+					(line & cache.getOffset()), col, nBand, data);
+		}
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see java.lang.Object#clone()
+	 */
+	public Object clone() {
+		CacheHorzImpl cloneCache = (CacheHorzImpl)cache.clone();
+		LRUAlgorithm cloneLRU = new LRUAlgorithm(cloneCache);
+		return new FloatBand(cloneCache, cloneLRU, nBand);
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/horizontal/FloatBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/vertical/ShortBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/vertical/ShortBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/vertical/ShortBand.java	(revision 3222)
@@ -0,0 +1,154 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import org.gvsig.raster.cache.buffer.exception.InvalidPageNumberException;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.impl.RasterBuffer;
+import org.gvsig.raster.cache.buffer.impl.stripecache.Cache;
+import org.gvsig.raster.cache.buffer.impl.stripecache.CacheBand;
+import org.gvsig.raster.cache.buffer.impl.stripecache.LRUAlgorithm;
+
+
+/**
+ * This class represent a byte band loaded in cache.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class ShortBand extends CacheBand {
+		
+	public ShortBand(Cache cache, LRUAlgorithm lru, int band){
+		super(cache, lru, band);
+		this.setDataType(RasterBuffer.TYPE_SHORT);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getNumberOfBlocks()
+	 */
+	@Override
+	public int getNumberOfBlocks() {
+		return (int)Math.ceil((double)getWidth() / (double)getBlockSize());
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Band#isHorizontalBlock()
+	 */
+	public boolean isHorizontalBlock() {
+		return false;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#assign(short)
+	 */
+	public void assign(short value) {
+		for(int col = 0; col < getWidth(); col ++){
+			boolean beginCol = true;  //Para acelerar solo comprobar� si la p�gina est� en cach� cada vez que empieza una columna
+    		for(int line = 0; line < getHeight(); line ++){
+    			try {
+    				if(beginCol){
+    					lru.cacheAccess(col, false);
+    					beginCol = false;
+    				}
+    			} catch (InvalidPageNumberException e) {
+    				return;
+    			} catch (InterruptedException e) {
+    				return;
+    			}
+    			cache.getAccessPage().setElem(line, (col & cache.getOffset()), nBand, value);		
+    		}
+		}
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getShortBlock(int)
+	 */
+	public short[][] getShortBlock(int block) {
+		int col = block * getBlockSize();
+		try {
+			lru.cacheAccess(col, true);
+		} catch (InvalidPageNumberException e) {
+			return null;
+		} catch (InterruptedException e) {
+			return null;
+		}
+		return cache.getAccessPage().getBand(nBand).getShortBlock(block);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setShortBlock(short[][], int)
+	 */
+	public void setShortBlock(short[][] data, int block) {
+		int col = block * getBlockSize();
+		try {
+			lru.cacheAccess(col, true);
+		} catch (InvalidPageNumberException e) {
+			return;
+		} catch (InterruptedException e) {
+			return;
+		}
+		try {
+			cache.getAccessPage().getBand(nBand).setShortBlock(data, block);
+		} catch (OperationNotSupportedException e) {
+			//Solo buffers de solo lectura
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getShortLine(int)
+	 */
+	public short[] getShortLine(int line) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("Operation getShortLine not supported for a vertical band of cache");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getElemShort(int, int)
+	 */
+	public short getElemShort(int line, int col) {
+		try {
+			lru.cacheAccess(col, true);
+		} catch (InvalidPageNumberException e) {
+			return (short)getNoDataValue().getValue().shortValue();
+		} catch (InterruptedException e) {
+			return (short)getNoDataValue().getValue().shortValue();
+		}
+		return cache.getAccessPage().getElemShort(line, (col & cache.getOffset()), nBand);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#setShortLine(short[], int)
+	 */
+	public void setShortLine(short[] data, int line) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("Operation getShortLine not supported for a vertical band of cache");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#setElem(int, int, short)
+	 */
+	public void setElem(int line, int col, short data) {
+		try {
+			lru.cacheAccess(col, false);
+		} catch (InvalidPageNumberException e) { 
+			return;
+		} catch (InterruptedException e) {
+			 return;
+		}
+		cache.getAccessPage().setElem(line, (col & cache.getOffset()), nBand, data);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see java.lang.Object#clone()
+	 */
+	public Object clone() {
+		Cache cloneCache = (Cache)cache.clone();
+		LRUAlgorithm cloneLRU = new LRUAlgorithm(cloneCache);
+		return new ShortBand(cloneCache, cloneLRU, nBand);
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/vertical/ShortBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/vertical/CacheBandListVert.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/vertical/CacheBandListVert.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/vertical/CacheBandListVert.java	(revision 3222)
@@ -0,0 +1,82 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import java.util.ArrayList;
+
+import org.gvsig.raster.cache.buffer.exception.WrongParameterException;
+import org.gvsig.raster.cache.buffer.impl.RasterBuffer;
+import org.gvsig.raster.cache.buffer.impl.stripecache.CacheBand;
+import org.gvsig.raster.cache.buffer.impl.stripecache.LRUAlgorithm;
+
+/**
+ * List of bands 
+ * 
+ * 21/10/2008
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class CacheBandListVert extends ArrayList<CacheBand> {
+	private static final long serialVersionUID = 1L;
+
+	/*
+	 * (non-Javadoc)
+	 * @see java.util.ArrayList#remove(int)
+	 */
+	public CacheBand remove(int pos) {
+		CacheBand removedElement = super.remove(pos);
+		for (int i = pos; i < size(); i++) {
+			CacheBand b = get(i);
+			b.setBandNumber(b.getBandNumber() - 1);
+		}
+		return removedElement;
+	}
+	
+	/**
+	 * Add a new band in the selected position 
+	 * @param pos Position to add a band
+	 * @param cache Cache
+	 * @param lru  LRUAlgorithm
+	 * @param dataType 
+	 * @return Band added
+	 */
+	public CacheBand add(int pos, CacheVertImpl cache, LRUAlgorithm lru, int dataType) {
+		for (int i = pos; i < size(); i++) 
+			get(i).setBandNumber(get(i).getBandNumber() + 1);
+		switch(dataType) {
+    	case RasterBuffer.TYPE_BYTE: ByteBand bb = new ByteBand(cache, lru, pos);
+    								add(pos, bb);
+    								return bb;
+    	case RasterBuffer.TYPE_SHORT: ByteBand sb = new ByteBand(cache, lru, pos);
+    								add(pos, sb);
+    								return sb;
+    	case RasterBuffer.TYPE_INT: ByteBand ib = new ByteBand(cache, lru, pos);
+    								add(pos, ib);
+    								return ib;
+    	case RasterBuffer.TYPE_FLOAT: ByteBand fb = new ByteBand(cache, lru, pos); 
+									add(pos, fb);
+    								return fb;
+    	case RasterBuffer.TYPE_DOUBLE: ByteBand db = new ByteBand(cache, lru, pos);
+									add(pos, db);
+    								return db;
+    	}
+		return null;
+	}
+	
+	/**
+	 * Swap bands according to positions selected in bandPosition parameter. 
+	 * 
+	 * @param  bandPosition
+	 *         New order for the bands in the array. Each position in the array represent the old band
+	 *         .The number that it contains represent the new position of that band. For instance, an
+	 *         array with values {1, 0, 2, 3} means that it has four bands and the band number one is swaped
+	 *         with the band number zero. The bands two and three don't change its position in this example.   			
+	 * @throws WrongParameterException
+	 */
+	public void swapBands(int[] bandPosition) throws WrongParameterException {
+		CacheBandListVert cbl = (CacheBandListVert)this.clone();
+		for (int i = 0; i < bandPosition.length; i++) {
+			CacheBand cb = cbl.get(bandPosition[i]);
+			cb.setBandNumber(i);
+			add(i, cb);
+			remove(size() - 1);
+		}
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/vertical/CacheBandListVert.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/vertical/CacheVertImpl.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/vertical/CacheVertImpl.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/vertical/CacheVertImpl.java	(revision 3222)
@@ -0,0 +1,654 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import java.io.IOException;
+
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.exception.WrongParameterException;
+import org.gvsig.raster.cache.buffer.impl.stripecache.CacheStruct;
+import org.gvsig.raster.cache.buffer.impl.stripecache.HDDPageList;
+import org.gvsig.raster.cache.buffer.impl.stripecache.PageBuffer;
+import org.gvsig.raster.cache.buffer.impl.stripecache.PageCacheList;
+import org.gvsig.raster.cache.buffer.impl.stripecache.horizontal.CacheHorzImpl;
+
+/**
+ * <P>
+ * Esta clase representa a la cache raster. Consta de una ser�e de p�ginas (CachePages)
+ * que son buffers con los bloques de datos cacheados en un instante dado. Esta cache tiene 
+ * una estructura en forma de array donde cada elemento es una p�gina de cach�. Las p�ginas 
+ * se agrupan en bloques de N p�ginas denominados grupos. La variable nelemsGroup contiene 
+ * el n�mero de p�ginas de cada grupo.
+ * </P>
+ * <P>
+ * La politica de reemplazo es que una p�gina siempre va a un conjunto determinado por el calculo
+ * cto = pag % nelemsGroup. Si hay hueco vac�o en el grupo se a�adir� en el siguiente hueco pero
+ * si hay que reeplazar se reeplazar� la p�gina que m�s tiempo haga su �ltimo acceso. 
+ * </P>
+ * <P>
+ * Esta cach� lleva el control de que p�ginas est�n cargadas a trav�s de un array de de booleanos
+ * donde cada elemento representa a una p�gina de datos del raster. Si el elemento en la posici�n
+ * N de dicho array es true significa que la p�gina est� cacheada. Si es false no lo estar�. 
+ * </P>
+ * <P>
+ * La p�gina de datos actualmente accedida debe estar cacheada por lo que est� clase debe llevar
+ * el control de que p�gina se est� accediendo o a sido accedida por �ltima vez. La variable que
+ * nos dice que p�gina est� siendo accedida es loadPage y pageBuffer ser� la variable que apunta
+ * al buffer de esta p�gina. Cuando se cambia de p�gina en un acceso estas dos variables deben
+ * cambiar a sus nuevos valores.
+ * </P>
+ * <P>
+ * Otro par�metro que controla esta clase es que p�gina de cada grupo ha sido accedido con mayor 
+ * frecuencia. Esto es �til porque siempre se reemplaza la p�gina de un grupo que haga m�s tiempo
+ * que haya sido accedida bajo la premisa de que "las p�ginas con accesos recientes tienen mayor 
+ * probabilidad de volver a ser usadas". Esto es controlado por la variable lastAccess que es
+ * usada para implementar el algoritmo LRU. Cada vez que una p�gina de un grupo es accedida su 
+ * contador de lastAccess se pone a 0. El resto de contadores de las p�ginas del grupo se incrementa
+ * en uno. Siempre se sustituye la p�gina del grupo con valor m�s grande en el contador.
+ * </P>
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ *
+ */
+public class CacheVertImpl extends CacheHorzImpl {
+	
+		
+	/**
+	 * Inicializamos la variables. Para ello creamos el objeto Cache que contendr� todos los 
+	 * par�metros necesarios para crear el array que controla los accesos m�s recientes y el
+	 * array que dice si una p�gina est� en memoria o no.
+	 * @param nBands N�mero de bandas
+	 * @param dataType Tipo de dato de la p�gina
+	 * @param dataSourceWidth ancho de la fuente de datos
+	 */
+	public CacheVertImpl(int nBands, int dataType, int dataSourceWidth, int dataSourceHeight) {
+		super(nBands, dataType, dataSourceWidth, dataSourceHeight);
+	}
+	
+	/**
+	 * Contructor
+	 * @param cacheStruct
+	 */
+	public CacheVertImpl(CacheStruct cacheStruct) {
+		super(cacheStruct);
+	}
+	
+	/**
+	 * Initialize arrays and data structures
+	 * @param nBands
+	 * @param dataType
+	 * @param dataSourceWidth
+	 * @param dataSourceHeight
+	 */
+	protected void init(int nBands, int dataType, int dataSourceWidth, int dataSourceHeight) {
+		//Creamos la estructura de la cach�
+		//Se cambian el ancho y el alto en la cach� vertical
+		cacheStruct = new CacheStructVertImpl(nBands, dataType, dataSourceWidth, dataSourceHeight);
+		
+		//Inicializamos la antig�edad de acceso  
+		lastAccess = new int[cacheStruct.getNGroups()][cacheStruct.getPagsPerGroup()];
+		
+		//Creamos el buffer de la cach�
+		pageNumberInCache = new int[cacheStruct.getNPags()];
+		modified = new boolean[cacheStruct.getNPags()];
+		cacheada = new boolean[cacheStruct.getNTotalPags()];
+				
+		initStructs();
+		initPointers();
+		
+		createPages(getNBands());
+	}
+		
+	
+	/**
+	 * Create new and empty pages with the structure information of
+	 * this cache
+	 */
+	public void createPages(int bands) {
+		hddPageList = new HDDPageList(cacheStruct.getNTotalPags(), bands);
+		pageCacheList = new PageCacheList(cacheStruct.getNPags(),
+										bands,
+										dataSourceHeight,
+										cacheStruct.getDataType(),
+										cacheStruct.getHPag());
+		pageCacheList.setHddPages(hddPageList);
+	}
+	
+	/**
+	 * Load the cache status selected in the parameter. The array has one position for each
+	 * page of cache. In each position has the page number loaded in that memory place.
+	 *  
+	 * @param pageNumberInCache Array of positions
+	 * @throws InterruptedException 
+	 */
+	public void loadCacheStatus(int[] pageNumberInCache) throws InterruptedException {
+		if(pageNumberInCache.length != pageCacheList.size())
+			return;
+		for (int iPage = 0; iPage < pageNumberInCache.length; iPage++) 
+			pageCacheList.get(iPage).loadPage(pageNumberInCache[iPage]);
+	}
+	
+	/**
+	 * Limpia los trozos de cach� en disco. Despu�s del llamar a este 
+	 * m�todo no puede volver a usarse esta cach�.
+	 * @throws IOException 
+	 */
+	public void clearCache() throws IOException {
+		pageCacheList.clearPageList();
+		hddPageList.clearPageList();
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#getBitsPag()
+	 */
+	public int getBitsPag() {
+		return cacheStruct.getBitsPag();
+	}
+
+	/**
+	 * Obtiene la altura de la p�gina de cache en l�neas. 
+	 * @return N�mero de l�neas de altura de p�gina.
+	 */
+	public int getHPag() {
+		return cacheStruct.getHPag();
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#isInCache(int)
+	 */
+	public boolean isInCache(int nPag) {
+		/*if(nPag < 0 || nPag >= cacheada.length)
+			return false;*/
+		return cacheada[nPag];
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#setPageAsLoadInCache(int)
+	 */
+	public void setPageAsLoadInCache(int nPag) {
+		if(nPag < 0 || nPag >= cacheada.length)
+			return;
+		cacheada[nPag] = true;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#setPageAsNotLoadInCache(int)
+	 */
+	public void setPageAsNotLoadInCache(int nPag) {
+		if(nPag < 0 || nPag >= cacheada.length)
+			return;
+		cacheada[nPag] = false;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#getRasterPageNumberInPosition(int)
+	 */
+	public int getRasterPageNumberInPosition(int nCachePage) {
+		return pageNumberInCache[nCachePage];
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#getRasterPageNumberInPosition(int, int)
+	 */
+	public int getRasterPageNumberInPosition(int group, int posInGroup) {
+		return pageNumberInCache[group * getPagsPerGroup() + posInGroup];
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#setRasterPageNumberInPosition(int, int)
+	 */
+	public void setRasterPageNumberInPosition(int nCachePage, int nRasterPage) {
+		pageNumberInCache[nCachePage] = nRasterPage;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#setRasterPageNumberInPosition(int, int, int)
+	 */
+	public void setRasterPageNumberInPosition(int group, int posInGroup, int nRasterPage) {
+		pageNumberInCache[group * getPagsPerGroup() + posInGroup] = nRasterPage;
+	}
+	
+	/**
+	 * Obtiene el n�mero de p�gina de cach� donde est� cargada la p�gina del raster
+	 * que se ha pasado por par�metro.
+	 * @param pag P�gina del raster
+	 * @return N�mero de p�gina del raster
+	 */
+	public int getNumberCachePageFromNumberRasterPage(int pag) {
+		int group = pag % getNGroups(); 
+		for(int i = 0; i < getPagsPerGroup(); i++)
+			if(pageNumberInCache[group + i] == pag)
+				return (group * getPagsPerGroup() + i);
+		return -1;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#getNumberGroupFromNumberRasterPage(int)
+	 */
+	public int[] getNumberGroupFromNumberRasterPage(int pag) {
+		int group = pag % getNGroups();
+		for(int i = 0; i < getPagsPerGroup(); i++)
+			if(pageNumberInCache[(group * getPagsPerGroup()) + i] == pag)
+				return new int[]{group, i};
+		return null;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#getLastAccess()
+	 */
+	public int[][] getLastAccess() {
+		return lastAccess;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#setZeroInLastAccess(int, int)
+	 */
+	public void setZeroInLastAccess(int group, int posInGroup) {
+		lastAccess[group][posInGroup] = 0;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#getNumberInAccessPage()
+	 */
+	public int getNumberInAccessPage() {
+		return numberInAccessPage;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#getPagsPerGroup()
+	 */
+	public int getPagsPerGroup() {
+		return cacheStruct.getPagsPerGroup();
+	}
+
+	/**
+	 * Obtiene la p�gina de datos de la posici�n pag
+	 * @param pag N�mero de p�gina de cach� a recuperar
+	 * @return PageBuffer correspondiente a la p�gina recuperada
+	 */
+	public PageBuffer getPageBufferFromNumberCachePage(int pag) {
+		return pageCacheList.get(pag);
+	}
+	
+	/**
+	 * Obtiene la p�gina de datos a partir del n�mero de p�gina de raster
+	 * @param pag N�mero de p�gina raster a recuperar
+	 * @return PageBuffer correspondiente a la p�gina recuperada o null si no est� en cach�
+	 */
+	public PageBuffer getPageBufferFromNumberRasterPage(int pag) {
+		int group = pag % getNGroups();
+		for(int i = 0; i < getPagsPerGroup(); i++)
+			if(pageNumberInCache[group * getPagsPerGroup() + i] == pag)
+				return pageCacheList.get(group * getPagsPerGroup() + i);
+		return null;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#getPageBuffer(int, int)
+	 */
+	public PageBuffer getPageBuffer(int group, int posInGroup) {
+		return pageCacheList.get(group * getPagsPerGroup() + posInGroup);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.cachete.buffer.stripecache.ICache#getAccessPage()
+	 */
+	public PageBuffer getAccessPage() {
+		return accessPage;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#setAccessPage(org.gvsig.raster.cache.buffer.impl.stripecache.horizontal.PageBuffer, int)
+	 */
+	public void setAccessPage(PageBuffer pb, int pagNumber) {
+		accessPage = pb;
+		numberInAccessPage = pagNumber;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#isModified(int)
+	 */
+	public boolean isModified(int nCachePag) {
+		return modified[nCachePag];
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#isModified(int, int)
+	 */
+	public boolean isModified(int group, int posInGroup) {
+		return modified[group * getPagsPerGroup() + posInGroup];
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#setModify(int)
+	 */
+	public void setModify(int nCachePag) {
+		modified[nCachePag] = true;	
+	}
+	
+	/**
+	 * Pone como modificada una p�gina de cach�
+	 * @param group Grupo en el que se encuentra la p�gina
+	 * @param posInGroup Posici�n dentro del grupo en el que est� la p�gina
+	 */
+	public void setModify(int group, int posInGroup) {
+		modified[group * getPagsPerGroup() + posInGroup] = true;	
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#unsetModify(int)
+	 */
+	public void unsetModify(int nCachePag) {
+		modified[nCachePag] = false;	
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#unsetModify(int, int)
+	 */
+	public void unsetModify(int group, int posInGroup) {
+		modified[group * getPagsPerGroup() + posInGroup] = false;	
+	}
+	
+	/**
+	 * Obtiene el n�mero de p�ginas de la cach�
+	 * @return N�mero total de p�ginas de la cach�
+	 */
+	public int getNPags() {
+		return cacheStruct.getNPags();
+	}
+	
+	/**
+	 * Obtiene el n�mero de bandas
+	 * @return N�mero de bandas
+	 */
+	public int getNBands() {
+		return cacheStruct.getNBands();
+	}
+	
+	/**
+	 * Obtiene la estructura de ca cach�
+	 * @return CacheStruct
+	 */
+	public CacheStruct getCacheStruct() {
+		return cacheStruct;
+	}
+	
+	/**
+	 * Asigna la estructura de ca cach�
+	 * @param CacheStruct
+	 */
+	public void setCacheStruct(CacheStruct cacheStruct) {
+		this.cacheStruct = cacheStruct;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#getNGroups()
+	 */
+	public int getNGroups() {
+		return cacheStruct.getNGroups();
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#getNTotalPags()
+	 */
+	public int getNTotalPags() {
+		return cacheStruct.getNTotalPags();
+	}
+	
+	/**
+	 * Obtiene el array con los n�meros de p�gina que hay cargados
+	 * en cada bloque de cache
+	 * @return array con los n�mero de p�gina
+	 */
+	public int[] getPageNumberInCache() {
+		return this.pageNumberInCache;
+	}
+	
+	/**
+	 * Para extraer el desplazamiento de una direcci�n (l�nea de raster) hay que hacer una operaci�n And con 
+	 * con la altura de la p�gina -1. Por ejemplo, una p�gina de 16 l�neas de altura el desplazamiento ser�
+	 * 16 - 1 = 15 porque 15 en binario es 1111.
+	 * 
+	 * Si queremos acceder a la linea del raster n�mero 83 (1010011) realizando la operaci�n And con el valor del
+	 * desplazamiento obtenemos (0001111 & 1010011 = 0000011), es decir el valor 3 en decimal. Esto quiere decir
+	 * que la l�nea 83 del raster es la 3 de su p�gina. 
+	 * @return valor del desplazamiento
+	 */
+	public int getOffset() {
+		return cacheStruct.getOffset();
+	}
+	
+	/**
+	 * Convierte una p�gina dentro de un grupo de la cach� en un n�mero de 
+	 * p�gina de cach�. Por ejemplo, en una cach� de 10 grupos y 5 p�ginas por grupo
+	 * la p�gina 2 del grupo 4 devolver� el 23 (5 * 4 + 3 = 23) teniendo en cuenta que
+	 * la p�gina y el grupo cero tambi�n cuentan.  
+	 * @param group
+	 * @param pageInGroup
+	 * @return
+	 */
+	public int convertPageInGroupToPageInCache(int group, int pageInGroup) {
+		return (group * cacheStruct.getPagsPerGroup() + pageInGroup);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#updateLastAccess(int)
+	 */
+	public int updateLastAccess(int group) {
+		int max = Integer.MIN_VALUE;
+		int posMax = 0;
+		for(int i = 0; i < getPagsPerGroup(); i++) {
+			if(getLastAccess()[group][i] >= 0)
+				getLastAccess()[group][i] ++;
+			
+			if(getLastAccess()[group][i] > max) {
+				max = getLastAccess()[group][i];
+				posMax = i;
+			}
+		}
+		return posMax;
+	}
+	
+	/**
+	 * Obtiene la posici�n del grupo de la p�gina a reemplazar, es decir la de m�ximo valor
+	 * en el vector lastAccess.
+	 * @param group N�mero de grupo a obtener la p�gina de reemplazo
+	 * @return La posici�n del elemento del grupo con valor m�ximo. Este elemento 
+	 * es el candidato para el reemplazo.
+	 */
+	public int posInGroupPagToReplace(int group) {
+		int max = Integer.MIN_VALUE;
+		int posMax = 0;
+		for(int i = 0; i < getPagsPerGroup(); i++) {
+			if(getLastAccess()[group][i] > max) {
+				max = getLastAccess()[group][i];
+				posMax = i;
+			}
+		}
+		return posMax;
+	} 
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#loadPage(int, int, int)
+	 */
+	public void loadPage(int group, int posInGroupPageToReplace, int nPag) throws InterruptedException {
+		pageCacheList.get(group * getPagsPerGroup() + posInGroupPageToReplace).loadPage(nPag);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.ICache#savePage(int, int, int)
+	 */
+	public void savePage(int group, int posInGroupPageToReplace, int nPag) throws IOException {
+		pageCacheList.get(group * getPagsPerGroup() + posInGroupPageToReplace).savePage(nPag);
+	}
+
+	/**
+	 * Salva a disco todas las p�ginas en memoria cach� e inicializa estructuras de datos.
+	 * 
+	 * @throws IOException
+	 */
+	public void resetCache() throws IOException {
+		for (int iCachePage = 0; iCachePage < pageCacheList.size(); iCachePage++) { 
+			if(modified[iCachePage])
+				pageCacheList.get(iCachePage).savePage(this.getRasterPageNumberInPosition(iCachePage));
+		}
+		initStructs();
+	}
+	
+	/**
+	 * Remove the selected cache band from disk and memory
+	 * @param iBand Band number to remove
+	 * @throws IOException 
+	 */
+	public void removeBand(int pos) throws IOException {
+		pageCacheList.removeBand(pos);
+		hddPageList.removeBand(pos);
+	}
+	
+	/**
+	 * Add an empty band in the cache
+	 * @param iBand Band number to add
+	 * @throws IOException 
+	 */
+	public void addBand(int pos) throws IOException {
+		resetCache();
+		pageCacheList.addBand(pos);
+		PageBuffer buf = new PageBuffer(cacheStruct.getDataType(), dataSourceWidth, cacheStruct.getHPag(), 1, true);
+		hddPageList.addBand(pos, buf);
+	}
+	
+	/**
+	 * Add a band in the cache
+	 * @param iBand Band number to add
+	 * @param Band Band to add
+	 * @throws IOException 
+	 */
+	public void addBand(int pos, Band band) throws IOException {
+		resetCache();
+		pageCacheList.addBand(pos);
+		PageBuffer buf = new PageBuffer(cacheStruct.getDataType(), dataSourceWidth, band.getBlockSize(), 1, true);
+		hddPageList.addBand(pos, band, buf);
+	}
+	
+	/**
+	 * Swap bands accordint to positions selected in bandPosition parameter.
+	 * 
+	 * @param  bandPosition
+	 *         New order for the bands in the array. Each position in the array represent the old band
+	 *         .The number that it contains represent the new position of that band. For instance, an
+	 *         array with values {1, 0, 2, 3} means that it has four bands and the band number one is swaped
+	 *         with the band number zero. The bands two and three don't change its position in this example.   			
+	 * @throws WrongParameterException
+	 * @throws IOException 
+	 */
+	 public void swapBands(int[] bandPosition) throws WrongParameterException, IOException {
+		resetCache();
+		pageCacheList.swapBands(bandPosition);
+		hddPageList.swapBands(bandPosition);
+	 }
+			
+	/**
+	 * Consulta si alguna p�gina de memoria tiene modificaciones para volcar a disco
+	 * @return true si hay alguna p�gina con modificaciones y false si no la hay
+	 */
+	public boolean anyPageModified() {
+		for (int iPage = 0; iPage < modified.length; iPage++) {
+			if(modified[iPage])
+				return true;
+		}
+		return false;
+	}
+	
+	/**
+	 * Get the width of the data source
+	 * @return int
+	 */
+	public int getDataSourceWidth() {
+		return dataSourceWidth;
+	}
+
+	/**
+	 * Get the height of the data source
+	 * @return int
+	 */
+	public int getDataSourceHeight() {
+		return dataSourceHeight;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see java.lang.Object#clone()
+	 */
+	public Object clone() {
+		CacheVertImpl clon = cloneStructure();
+		clon.hddPageList = (HDDPageList)hddPageList.clone();
+		clon.pageCacheList = (PageCacheList)pageCacheList.clone();
+		clon.pageCacheList.setHddPages(clon.hddPageList);
+		return clon;
+	}
+	
+	/**
+	 * Clone the cache structure without clone data pages neither disk pages 
+	 * @return Cache
+	 */
+	public CacheVertImpl cloneStructure() {
+		CacheVertImpl clon = new CacheVertImpl(cacheStruct.getNBands(), cacheStruct.getDataType(), dataSourceWidth, dataSourceHeight);
+		for (int i = 0; i < cacheada.length; i++) 
+			clon.cacheada[i] = cacheada[i];
+		clon.numberInAccessPage = numberInAccessPage;
+		for (int i = 0; i < pageNumberInCache.length; i++) 
+			clon.pageNumberInCache[i] = pageNumberInCache[i];
+		for (int i = 0; i < lastAccess.length; i++) {
+			for (int j = 0; j < lastAccess[i].length; j++) {
+				clon.lastAccess[i][j] = lastAccess[i][j];
+			}
+		}
+		for (int i = 0; i < modified.length; i++)
+			clon.modified[i] = modified[i];
+		clon.cacheStruct = (CacheStruct)cacheStruct.clone();
+		return clon;
+	}
+
+	/**
+	 * Imprime la informaci�n de estructura de cach�
+	 */
+	public void show() {
+		((org.gvsig.raster.cache.buffer.impl.stripecache.CacheStruct)cacheStruct).show();
+		System.out.println("Cacheada:");
+		for(int i = 0; i < cacheada.length; i++)
+			System.out.print(i + "=" + cacheada[i]+" ");
+		System.out.println();
+		System.out.println("LastAccess:");
+		for(int i = 0; i < cacheStruct.getNGroups(); i++) {
+			System.out.println("Grupo " + i +":");
+			for(int j = 0; j < cacheStruct.getPagsPerGroup(); j++)
+				System.out.println("elem " + j + " : " + "Page " + pageNumberInCache[i * cacheStruct.getPagsPerGroup() + j] + " : " + lastAccess[i][j]);
+		
+		}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/vertical/CacheVertImpl.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/vertical/ByteBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/vertical/ByteBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/vertical/ByteBand.java	(revision 3222)
@@ -0,0 +1,152 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import org.gvsig.raster.cache.buffer.BufferNoData;
+import org.gvsig.raster.cache.buffer.exception.InvalidPageNumberException;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.impl.RasterBuffer;
+import org.gvsig.raster.cache.buffer.impl.stripecache.Cache;
+import org.gvsig.raster.cache.buffer.impl.stripecache.CacheBand;
+import org.gvsig.raster.cache.buffer.impl.stripecache.LRUAlgorithm;
+
+
+/**
+ * This class represent a byte band loaded in cache.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class ByteBand extends CacheBand {
+		
+	/**
+	 * Create a empty band asociated to existing cache
+	 * @param cache 
+	 * @param lru
+	 * @param band
+	 */
+	public ByteBand(Cache cache, LRUAlgorithm lru, int band) {
+		super(cache, lru, band);
+		this.setDataType(RasterBuffer.TYPE_BYTE);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.stripecache.CacheBand#getNumberOfBlocks()
+	 */
+	@Override
+	public int getNumberOfBlocks() {
+		return (int)Math.ceil((double)getWidth() / (double)getBlockSize());
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Band#isHorizontalBlock()
+	 */
+	public boolean isHorizontalBlock() {
+		return false;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#assign(byte)
+	 */
+	public void assign(byte value) {
+		for(int col = 0; col < getWidth(); col ++) {
+			boolean beginCol = true;  //Para acelerar solo comprobar� si la p�gina est� en cach� cada vez que empieza una columna
+    		for(int line = 0; line < getHeight(); line ++) {
+    			try {
+    				if(beginCol) {
+    					lru.cacheAccess(col, false);
+    					beginCol = false;
+    				}
+    			} catch (InvalidPageNumberException e) {
+    				return;
+    			} catch (InterruptedException e) {
+    				return;
+    			}
+    			cache.getAccessPage().setElem(line, (col& cache.getOffset()), nBand, value);		
+    		}
+		}
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getByteBlock(int)
+	 */
+	public byte[][] getByteBlock(int block) {
+		int col = block * getBlockSize();
+		try {
+			lru.cacheAccess(col, true);
+		} catch (InvalidPageNumberException e) {
+			return null;
+		} catch (InterruptedException e) {
+			return null;
+		}
+		return cache.getAccessPage().getBand(nBand).getByteBlock(block);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setByteBlock(byte[][], int)
+	 */
+	public void setByteBlock(byte[][] data, int block) {
+		int col = block * getBlockSize();
+		try {
+			lru.cacheAccess(col, true);
+		} catch (InvalidPageNumberException e) {
+			return;
+		} catch (InterruptedException e) {
+			return;
+		}
+		try {
+			cache.getAccessPage().getBand(nBand).setByteBlock(data, block);
+		} catch (OperationNotSupportedException e) {
+			//Solo buffers de solo lectura
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getByteLine(int)
+	 */
+	public byte[] getByteLine(int line) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("Operation getByteLine not supported for a vertical band of cache");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getElemByte(int, int)
+	 */
+	public byte getElemByte(int line, int col) {
+		if(exists(col)) {
+			return cache.getAccessPage().getElemByte(line, (col & cache.getOffset()), nBand);
+		}
+		return getNoDataValue().isDefined() ? getNoDataValue().getValue().byteValue() : BufferNoData.defaultByteNoDataValue;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#setByteLine(byte[], int)
+	 */
+	public void setByteLine(byte[] data, int line) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("Operation getByteLine not supported for a vertical band of cache");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#setElem(int, int, byte)
+	 */
+	public void setElem(int line, int col, byte data) {
+		if(exists(col)) {
+			cache.getAccessPage().setElem(line, (col & cache.getOffset()), nBand, data);
+		}
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see java.lang.Object#clone()
+	 */
+	public Object clone() {
+		Cache cloneCache = (Cache)cache.clone();
+		LRUAlgorithm cloneLRU = new LRUAlgorithm(cloneCache);
+		return new ByteBand(cloneCache, cloneLRU, nBand);
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/vertical/ByteBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/vertical/FloatBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/vertical/FloatBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/vertical/FloatBand.java	(revision 3222)
@@ -0,0 +1,154 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import org.gvsig.raster.cache.buffer.exception.InvalidPageNumberException;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.impl.RasterBuffer;
+import org.gvsig.raster.cache.buffer.impl.stripecache.Cache;
+import org.gvsig.raster.cache.buffer.impl.stripecache.CacheBand;
+import org.gvsig.raster.cache.buffer.impl.stripecache.LRUAlgorithm;
+
+
+/**
+ * This class represent a byte band loaded in cache.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class FloatBand extends CacheBand {
+		
+	public FloatBand(Cache cache, LRUAlgorithm lru, int band){
+		super(cache, lru, band);
+		this.setDataType(RasterBuffer.TYPE_FLOAT);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getNumberOfBlocks()
+	 */
+	@Override
+	public int getNumberOfBlocks() {
+		return (int)Math.ceil((double)getWidth() / (double)getBlockSize());
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Band#isHorizontalBlock()
+	 */
+	public boolean isHorizontalBlock() {
+		return false;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#assign(float)
+	 */
+	public void assign(float value) {
+		for(int col = 0; col < getWidth(); col ++) {
+			boolean beginCol = true;  //Para acelerar solo comprobar� si la p�gina est� en cach� cada vez que empieza una columna
+    		for(int line = 0; line < getHeight(); line ++) {
+    			try {
+    				if(beginCol) {
+    					lru.cacheAccess(col, false);
+    					beginCol = false;
+    				}
+    			} catch (InvalidPageNumberException e) {
+    				return;
+    			} catch (InterruptedException e) {
+    				return;
+    			}
+    			cache.getAccessPage().setElem(line, (col& cache.getOffset()), nBand, value);		
+    		}
+		}
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getFloatBlock(int)
+	 */
+	public float[][] getFloatBlock(int block) {
+		int col = block * getBlockSize();
+		try {
+			lru.cacheAccess(col, true);
+		} catch (InvalidPageNumberException e) {
+			return null;
+		} catch (InterruptedException e) {
+			return null;
+		}
+		return cache.getAccessPage().getBand(nBand).getFloatBlock(block);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setFloatBlock(float[][], int)
+	 */
+	public void setFloatBlock(float[][] data, int block) {
+		int col = block * getBlockSize();
+		try {
+			lru.cacheAccess(col, true);
+		} catch (InvalidPageNumberException e) {
+			return;
+		} catch (InterruptedException e) {
+			return;
+		}
+		try {
+			cache.getAccessPage().getBand(nBand).setFloatBlock(data, block);
+		} catch (OperationNotSupportedException e) {
+			//Solo buffers de solo lectura
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getFloatLine(int)
+	 */
+	public float[] getFloatLine(int line) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("Operation getByteLine not supported for a vertical band of cache");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getElemByte(int, int)
+	 */
+	public float getElemFloat(int line, int col) {
+		try {
+			lru.cacheAccess(col, true);
+		} catch (InvalidPageNumberException e) {
+			return (float)getNoDataValue().getValue().floatValue();
+		} catch (InterruptedException e) {
+			return (float)getNoDataValue().getValue().floatValue();
+		}
+		return cache.getAccessPage().getElemFloat(line, (col& cache.getOffset()), nBand);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#setByteLine(float[], int)
+	 */
+	public void setByteLine(float[] data, int line) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("Operation getByteLine not supported for a vertical band of cache");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#setElem(int, int, float)
+	 */
+	public void setElem(int line, int col, float data) {
+		try {
+			lru.cacheAccess(col, false);
+		} catch (InvalidPageNumberException e) {
+			return;
+		} catch (InterruptedException e) {
+			return;
+		}
+		cache.getAccessPage().setElem(line, (col& cache.getOffset()), nBand, data);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see java.lang.Object#clone()
+	 */
+	public Object clone() {
+		Cache cloneCache = (Cache)cache.clone();
+		LRUAlgorithm cloneLRU = new LRUAlgorithm(cloneCache);
+		return new FloatBand(cloneCache, cloneLRU, nBand);
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/vertical/FloatBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/vertical/CacheStructVertImpl.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/vertical/CacheStructVertImpl.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/vertical/CacheStructVertImpl.java	(revision 3222)
@@ -0,0 +1,125 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.impl.stripecache.CacheStruct;
+
+/**
+ * Esta clase representa la estructura en memoria de la cache. Contiene el n�mero de p�ginas 
+ * as� como los subconjuntos en las que se divide. Tendr� tambi�n datos como en ancho y alto de
+ * cada p�gina y tama�o en memoria de esta. 
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ *
+ */
+public class CacheStructVertImpl extends CacheStruct {
+	
+	/**
+	 * Calcula los par�metros del tama�o de cach� y de p�gina, asi como la altura de las mismas y el n�mero
+	 * de grupos que salen en cach�.
+	 * @param nBands N�mero de bandas del raster
+	 * @param dataType Tipo de dato de la imagen
+	 * @param dataSourceWidth ancho de cada l�nea completa del raster.
+	 */
+	public CacheStructVertImpl(int nBands, int dataType, int dataSourceWidth, int dataSourceHeight){
+		this.width = dataSourceWidth;
+		this.height = dataSourceHeight;
+		init(nBands, dataType, dataSourceWidth, dataSourceHeight);
+	}
+	
+	/**
+	 * Constructor de una sola banda y sin el calculo de par�metros. Estos deben ser asignados
+	 * posteriorimente. Esta llamada es usada en casos especiales de creaci�n de buffers cacheados.
+	 */
+	public CacheStructVertImpl() {
+	}
+	
+	/**
+	 * Constructor solo para test. No utilizar con un uso normal de la librer�a
+	 * Calcula los par�metros del tama�o de cach� y de p�gina, asi como la altura de las mismas y el n�mero
+	 * de grupos que salen en cach�.
+	 * @param nBands N�mero de bandas del raster
+	 * @param dataType Tipo de dato de la imagen
+	 * @param dataSourceWidth ancho de cada l�nea completa del raster.
+	 */
+	public CacheStructVertImpl(int nBands, int dataType, int dataSourceWidth, int dataSourceHeight, long cacheSize, long pageSize) {
+		this.cacheSize = cacheSize;
+		this.pageSize = pageSize;
+		init(nBands, dataType, dataSourceWidth, dataSourceHeight);
+	}
+	
+	private void init(int nBands, int dataType, int dataSourceWidth, int dataSourceHeight) {
+		this.nPageBandBuffers = nBands;
+		this.dataType = dataType;
+		
+		//Pasamos los megas a bytes
+		cacheSize = cacheSize * 1048576;
+		pageSize = pageSize * 1048576;
+		
+		cacheSizePerBand = (long)(cacheSize / nBands);
+		pageSizePerBand = (long)(pageSize / nBands);
+				
+		//int dataSize = 0;
+		int dataSizePerBand = 0;
+		if (dataType == Buffer.TYPE_BYTE) {
+			dataSizePerBand = 1;
+		} else if ((dataType == Buffer.TYPE_SHORT) | (dataType == Buffer.TYPE_USHORT)) {
+			dataSizePerBand = 2;
+        } else if (dataType == Buffer.TYPE_INT) {
+        	dataSizePerBand = 4;
+        } else if (dataType == Buffer.TYPE_FLOAT) {
+        	dataSizePerBand = 4;
+        } else if (dataType == Buffer.TYPE_DOUBLE) {
+        	dataSizePerBand = 8;
+        }
+		//dataSize = dataSizePerBand * nBands;
+				
+		//La anchura de la p�gina depende del alto de esta y del tipo de dato
+		for(int i = (possiblePageHeights.length - 1); i >= 0; i --) {
+			long size = (long)dataSourceHeight * (long)possiblePageHeights[i] * (long)dataSizePerBand; 
+			if(size <= pageSizePerBand){
+				hPag = possiblePageHeights[i];
+				break;
+			}
+		}
+		//Calculamos el tama�o de p�gina en bytes 
+		pageSizePerBand = dataSourceHeight * hPag * dataSizePerBand;
+		
+		//Calculamos el n�mero de p�ginas que tendr� el buffer completo
+		nPags = (int)(cacheSizePerBand / pageSizePerBand);
+				
+		while((nPags % pagsPerGroup) != 0)
+			nPags ++;	
+		
+		//Recalculamos el tama�o de la cach�
+		cacheSizePerBand = (long)(pageSizePerBand * nPags);
+		
+		//Calculamos el n�mero de grupos de cach�
+		nGroups = (int)(nPags / pagsPerGroup);
+		
+		int h = hPag; 
+		while(h > 1){
+			h >>= 1;
+			bitsPag ++;
+		}
+		
+		//Calculamos el n�mero total de p�ginas en cach�
+		nTotalPags = (int)(dataSourceWidth / hPag);
+		if((dataSourceWidth % hPag) != 0)
+			nTotalPags ++;
+		
+		offset = hPag - 1;
+		
+		cacheSize = cacheSizePerBand * nBands;
+		pageSize = pageSizePerBand * nBands;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see java.lang.Object#clone()
+	 */
+	public Object clone() {
+		CacheStructVertImpl struct = new CacheStructVertImpl(nPageBandBuffers, dataType, width, height);
+		return struct;
+	}
+
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/vertical/CacheStructVertImpl.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/vertical/DoubleBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/vertical/DoubleBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/vertical/DoubleBand.java	(revision 3222)
@@ -0,0 +1,142 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import org.gvsig.raster.cache.buffer.exception.InvalidPageNumberException;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.impl.RasterBuffer;
+import org.gvsig.raster.cache.buffer.impl.stripecache.Cache;
+import org.gvsig.raster.cache.buffer.impl.stripecache.CacheBand;
+import org.gvsig.raster.cache.buffer.impl.stripecache.LRUAlgorithm;
+
+
+/**
+ * This class represent a byte band loaded in cache.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class DoubleBand extends CacheBand {
+		
+	public DoubleBand(Cache cache, LRUAlgorithm lru, int band){
+		super(cache, lru, band);
+		this.setDataType(RasterBuffer.TYPE_DOUBLE);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getNumberOfBlocks()
+	 */
+	@Override
+	public int getNumberOfBlocks() {
+		return (int)Math.ceil((double)getWidth() / (double)getBlockSize());
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Band#isHorizontalBlock()
+	 */
+	public boolean isHorizontalBlock() {
+		return false;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#assign(double)
+	 */
+	public void assign(double value) {
+		for(int col = 0; col < getWidth(); col ++) {
+			boolean beginCol = true;  //Para acelerar solo comprobar� si la p�gina est� en cach� cada vez que empieza una columna
+    		for(int line = 0; line < getHeight(); line ++) {
+    			try {
+    				if(beginCol) {
+    					lru.cacheAccess(col, false);
+    					beginCol = false;
+    				}
+    			} catch (InvalidPageNumberException e) {
+    				return;
+    			} catch (InterruptedException e) {
+    				return;
+    			}
+    			cache.getAccessPage().setElem(line, (col& cache.getOffset()), nBand, value);		
+    		}
+		}
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getDoubleBlock(int)
+	 */
+	public double[][] getDoubleBlock(int block) {
+		int line = block * getBlockSize();
+		try {
+			lru.cacheAccess(line, true);
+		} catch (InvalidPageNumberException e) {return null;}
+		catch (InterruptedException e) {return null;}
+		return cache.getAccessPage().getBand(nBand).getDoubleBlock(block);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setDoubleBlock(double[][], int)
+	 */
+	public void setDoubleBlock(double[][] data, int block) {
+		int col = block * getBlockSize();
+		try {
+			lru.cacheAccess(col, true);
+		} catch (InvalidPageNumberException e) {return;}
+		catch (InterruptedException e) {return;}
+		try {
+			cache.getAccessPage().getBand(nBand).setDoubleBlock(data, block);
+		} catch (OperationNotSupportedException e) {
+			//Solo buffers de solo lectura
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getDoubleLine(int)
+	 */
+	public double[] getDoubleLine(int line) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("Operation getByteLine not supported for a vertical band of cache");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getElemByte(int, int)
+	 */
+	public double getElemDouble(int line, int col) {
+		try {
+			lru.cacheAccess(col, true);
+		} catch (InvalidPageNumberException e) {return (double)getNoDataValue().getValue().doubleValue();
+		} catch (InterruptedException e) {return (double)getNoDataValue().getValue().doubleValue();}
+		return cache.getAccessPage().getElemDouble(line, (col& cache.getOffset()), nBand);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#setDoubleLine(double[], int)
+	 */
+	public void setDoubleLine(double[] data, int line) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("Operation getByteLine not supported for a vertical band of cache");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#setElem(int, int, double)
+	 */
+	public void setElem(int line, int col, double data) {
+		try {
+			lru.cacheAccess(col, false);
+		} catch (InvalidPageNumberException e) { return;}
+		 catch (InterruptedException e) {return;}
+		cache.getAccessPage().setElem(line, (col& cache.getOffset()), nBand, data);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see java.lang.Object#clone()
+	 */
+	public Object clone() {
+		Cache cloneCache = (Cache)cache.clone();
+		LRUAlgorithm cloneLRU = new LRUAlgorithm(cloneCache);
+		return new DoubleBand(cloneCache, cloneLRU, nBand);
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/vertical/DoubleBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/vertical/IntBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/vertical/IntBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/vertical/IntBand.java	(revision 3222)
@@ -0,0 +1,154 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import org.gvsig.raster.cache.buffer.exception.InvalidPageNumberException;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.impl.RasterBuffer;
+import org.gvsig.raster.cache.buffer.impl.stripecache.Cache;
+import org.gvsig.raster.cache.buffer.impl.stripecache.CacheBand;
+import org.gvsig.raster.cache.buffer.impl.stripecache.LRUAlgorithm;
+
+
+/**
+ * This class represent a byte band loaded in cache.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class IntBand extends CacheBand {
+		
+	public IntBand(Cache cache, LRUAlgorithm lru, int band){
+		super(cache, lru, band);
+		this.setDataType(RasterBuffer.TYPE_INT);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getNumberOfBlocks()
+	 */
+	@Override
+	public int getNumberOfBlocks() {
+		return (int)Math.ceil((double)getWidth() / (double)getBlockSize());
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Band#isHorizontalBlock()
+	 */
+	public boolean isHorizontalBlock() {
+		return false;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#assign(int)
+	 */
+	public void assign(int value) {
+		for(int col = 0; col < getWidth(); col ++) {
+			boolean beginCol = true;  //Para acelerar solo comprobar� si la p�gina est� en cach� cada vez que empieza una columna
+    		for(int line = 0; line < getHeight(); line ++) {
+    			try {
+    				if(beginCol) {
+    					lru.cacheAccess(col, false);
+    					beginCol = false;
+    				}
+    			} catch (InvalidPageNumberException e) {
+    				return;
+    			} catch (InterruptedException e) {
+    				return;
+    			}
+    			cache.getAccessPage().setElem(line, (col& cache.getOffset()), nBand, value);		
+    		}
+		}
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getIntBlock(int)
+	 */
+	public int[][] getIntBlock(int block) {
+		int col = block * getBlockSize();
+		try {
+			lru.cacheAccess(col, true);
+		} catch (InvalidPageNumberException e) {
+			return null;
+		} catch (InterruptedException e) {
+			return null;
+		}
+		return cache.getAccessPage().getBand(nBand).getIntBlock(block);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setIntBlock(int[][], int)
+	 */
+	public void setIntBlock(int[][] data, int block) {
+		int col = block * getBlockSize();
+		try {
+			lru.cacheAccess(col, true);
+		} catch (InvalidPageNumberException e) {
+			return;
+		} catch (InterruptedException e) {
+			return;
+		}
+		try {
+			cache.getAccessPage().getBand(nBand).setIntBlock(data, block);
+		} catch (OperationNotSupportedException e) {
+			//Solo buffers de solo lectura
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getIntLine(int)
+	 */
+	public int[] getIntLine(int line) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("Operation getByteLine not supported for a vertical band of cache");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getElemInt(int, int)
+	 */
+	public int getElemInt(int line, int col) {
+		try {
+			lru.cacheAccess(line, true);
+		} catch (InvalidPageNumberException e) {
+			return (int)getNoDataValue().getValue().intValue();
+		} catch (InterruptedException e) {
+			return (int)getNoDataValue().getValue().intValue();
+		}
+		return cache.getAccessPage().getElemInt(line, (col& cache.getOffset()), nBand);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#setIntLine(int[], int)
+	 */
+	public void setIntLine(int[] data, int line) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("Operation getByteLine not supported for a vertical band of cache");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#setElem(int, int, int)
+	 */
+	public void setElem(int line, int col, int data) {
+		try {
+			lru.cacheAccess(col, false);
+		} catch (InvalidPageNumberException e) { 
+			return;
+		} catch (InterruptedException e) {
+			return;
+		}
+		cache.getAccessPage().setElem(line, (col& cache.getOffset()), nBand, data);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see java.lang.Object#clone()
+	 */
+	public Object clone() {
+		Cache cloneCache = (Cache)cache.clone();
+		LRUAlgorithm cloneLRU = new LRUAlgorithm(cloneCache);
+		return new IntBand(cloneCache, cloneLRU, nBand);
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/vertical/IntBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/vertical/RasterVertCacheBuffer.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/vertical/RasterVertCacheBuffer.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/vertical/RasterVertCacheBuffer.java	(revision 3222)
@@ -0,0 +1,861 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache.vertical;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferNoData;
+import org.gvsig.raster.cache.buffer.exception.BandNotCompatibleException;
+import org.gvsig.raster.cache.buffer.exception.InvalidPageNumberException;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.WrongParameterException;
+import org.gvsig.raster.cache.buffer.impl.RasterBuffer;
+import org.gvsig.raster.cache.buffer.impl.stripecache.Cache;
+import org.gvsig.raster.cache.buffer.impl.stripecache.CacheBand;
+import org.gvsig.raster.cache.buffer.impl.stripecache.LRUAlgorithm;
+
+/**
+ * Esta clase representa un buffer de datos cacheado. El estar en cache significa que
+ * solo una parte de los datos estar�n en memoria y que gestiona, dependiendo de las
+ * peticiones, que partes hay que cargar a memoria y en que momento. Para esto el buffer
+ * no se llena de golpe sino que utiliza una clase que sirve los datos desde la fuente. 
+ * Esta clase servidora de datos debe implementar el interfaz ICacheDatasetSourcepara 
+ * servir datos de la forma requerida.
+ *   
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ *
+ */
+public class RasterVertCacheBuffer extends RasterBuffer {
+	private CacheVertImpl              cache      = null;
+	private LRUAlgorithm           	   lru        = null;
+	private CacheBandListVert          bands      = null;
+	private int                        lastColumn = -1;
+	
+    /**
+     * Constructor. Asigna las variables de inicializaci�n y crea la estructura de 
+     * la cach� con los datos pasados.
+     * @param dataType Tipo de dato del buffer
+     * @param width Ancho del buffer
+     * @param height Alto del buffer
+     * @param nBands N�mero de bandas del buffer
+     */
+	public RasterVertCacheBuffer(int dataType, int width, int height, int nBands) {
+		super(0, 0, width, height, dataType, nBands);
+		cache = new CacheVertImpl(nBands, dataType, width, height);
+		lru = new LRUAlgorithm(cache);
+        
+        bands = new CacheBandListVert();
+        for (int i = 0; i < nBands; i++) {
+        	switch(dataType) {
+        	case RasterBuffer.TYPE_BYTE: bands.add(new ByteBand(cache, lru, i)); break;
+        	case RasterBuffer.TYPE_SHORT: bands.add(new ShortBand(cache, lru, i)); break;
+        	case RasterBuffer.TYPE_INT: bands.add(new IntBand(cache, lru, i)); break;
+        	case RasterBuffer.TYPE_FLOAT: bands.add(new FloatBand(cache, lru, i)); break;
+        	case RasterBuffer.TYPE_DOUBLE: bands.add(new DoubleBand(cache, lru, i)); break;
+        	}
+		}
+	}
+		
+	/**
+	 * Borra la cach� cuando se elimina el objeto RasterCache ya que
+	 * los trozos ya no pueden ser referenciados.
+	 */
+	protected void finalize() throws Throwable {
+		free();
+	}
+	
+	/*
+     * (non-Javadoc)
+     * @see org.gvsig.raster.driver.IRasterBuffer#isBandSwitchable()
+     */
+    public boolean isBandSwitchable(){
+    	return true;
+    }
+    
+	/**
+	 * Obtiene la cach�
+	 * @return
+	 */
+	public Cache getCache() {
+		return cache;
+	}
+	
+	/**
+	 * Asigna la cache
+	 * @param cache
+	 */
+	public void setCache(CacheVertImpl cache) {
+		this.cache = cache;
+		this.lru.setCache(cache);
+	}
+	
+	/*
+     * (non-Javadoc)
+     * @see org.fv.raster.buffer.IRasterBuffer#isWritable()
+     */
+    public boolean isWritable() {
+    	return true;
+    }
+    
+    private boolean exists(int column) {
+        // Store the last line checked so we don't check it again for each
+        // pixel of the same line
+        if (column != lastColumn) {
+            try {
+                lru.cacheAccess(column, false);
+                this.lastColumn = column;
+            } catch (InvalidPageNumberException e) {
+                return false;
+            } catch (InterruptedException e) {
+				return false;
+			}
+        }
+        return true;
+    }
+	
+	/***********************************************/
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#getLineByte(int)
+	 */
+	public byte[][] getLineByte(int line) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("Operation getLineByte not supported by cache with vertical stripes");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#getLineShort(int)
+	 */
+	public short[][] getLineShort(int line) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("Operation getLineShort not supported by cache with vertical stripes");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#getLineInt(int)
+	 */
+	public int[][] getLineInt(int line) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("Operation getLineInt not supported by cache with vertical stripes");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#getLineFloat(int)
+	 */
+	public float[][] getLineFloat(int line) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("Operation getLineFloat not supported by cache with vertical stripes");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#getLineDouble(int)
+	 */
+	public double[][] getLineDouble(int line) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("Operation getLineDouble not supported by cache with vertical stripes");
+	}
+
+	//***********************************************
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#setLineByte(byte[][], int)
+	 */
+	public void setLineByte(byte[][] data, int line) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("Operation getLineDouble not supported by cache with vertical stripes");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#setLineShort(short[][], int)
+	 */
+	public void setLineShort(short[][] data, int line) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("Operation getLineDouble not supported by cache with vertical stripes");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#setLineInt(int[][], int)
+	 */
+	public void setLineInt(int[][] data, int line) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("Operation getLineDouble not supported by cache with vertical stripes");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#setLineFloat(float[][], int)
+	 */
+	public void setLineFloat(float[][] data, int line) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("Operation getLineDouble not supported by cache with vertical stripes");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#setLineDouble(double[][], int)
+	 */
+	public void setLineDouble(double[][] data, int line) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("Operation getLineDouble not supported by cache with vertical stripes");
+	}
+
+	//*********************************************************
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#getLineFromBandByte(int, int)
+	 */
+	public byte[] getLineFromBandByte(int line, int band) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("Operation getLineDouble not supported by cache with vertical stripes");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#getLineFromBandShort(int, int)
+	 */
+	public short[] getLineFromBandShort(int line, int band) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("Operation getLineDouble not supported by cache with vertical stripes");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#getLineFromBandInt(int, int)
+	 */
+	public int[] getLineFromBandInt(int line, int band) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("Operation getLineDouble not supported by cache with vertical stripes");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#getLineFromBandFloat(int, int)
+	 */
+	public float[] getLineFromBandFloat(int line, int band) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("Operation getLineDouble not supported by cache with vertical stripes");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#getLineFromBandDouble(int, int)
+	 */
+	public double[] getLineFromBandDouble(int line, int band) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("Operation getLineDouble not supported by cache with vertical stripes");
+	}
+
+	//*********************************************************
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#setLineInBandByte(byte[], int, int)
+	 */
+	public void setLineInBandByte(byte[] data, int line, int band) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("Operation getLineDouble not supported by cache with vertical stripes");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#setLineInBandShort(short[], int, int)
+	 */
+	public void setLineInBandShort(short[] data, int line, int band) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("Operation getLineDouble not supported by cache with vertical stripes");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#setLineInBandInt(int[], int, int)
+	 */
+	public void setLineInBandInt(int[] data, int line, int band) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("Operation getLineDouble not supported by cache with vertical stripes");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#setLineInBandFloat(float[], int, int)
+	 */
+	public void setLineInBandFloat(float[] data, int line, int band) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("Operation getLineDouble not supported by cache with vertical stripes");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#setLineInBandDouble(double[], int, int)
+	 */
+	public void setLineInBandDouble(double[] data, int line, int band) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("Operation getLineDouble not supported by cache with vertical stripes");
+	}
+
+	//*********************************************************
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#getElemByte(int, int, int)
+	 */
+	public byte getElemByte(int line, int col, int band) {
+		if(exists(col)) {
+			return cache.getAccessPage().getElemByte(line, (col & cache.getOffset()), band);
+		}
+		return getNoDataValue().isDefined() ? getNoDataValue().getValue().byteValue() : BufferNoData.defaultByteNoDataValue;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#getElemShort(int, int, int)
+	 */
+	public short getElemShort(int line, int col, int band) {
+		if(exists(col)) {
+			return cache.getAccessPage().getElemShort(line, (col & cache.getOffset()), band);
+		}
+		return getNoDataValue().isDefined() ? getNoDataValue().getValue().shortValue() : BufferNoData.defaultShortNoDataValue;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#getElemInt(int, int, int)
+	 */
+	public int getElemInt(int line, int col, int band) {
+		if(exists(col)) {
+			return cache.getAccessPage().getElemInt(line, (col & cache.getOffset()), band);
+		}
+		return getNoDataValue().isDefined() ? getNoDataValue().getValue().intValue() : BufferNoData.defaultIntegerNoDataValue;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#getElemFloat(int, int, int)
+	 */
+	public float getElemFloat(int line, int col, int band) {
+		if(exists(col)) {
+			return cache.getAccessPage().getElemFloat(line, (col & cache.getOffset()), band);
+		}
+		return getNoDataValue().isDefined() ? getNoDataValue().getValue().floatValue() : BufferNoData.defaultFloatNoDataValue;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#getElemDouble(int, int, int)
+	 */
+	public double getElemDouble(int line, int col, int band) {
+		if(exists(col)) {
+			return cache.getAccessPage().getElemDouble(line, (col & cache.getOffset()), band);
+		}
+		return getNoDataValue().isDefined() ? getNoDataValue().getValue().doubleValue() : BufferNoData.defaultDoubleNoDataValue;
+	}
+
+	//*********************************************************
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#setElem(int, int, int, byte)
+	 */
+	public void setElem(int line, int col, int band, byte data) {
+		if(exists(col)) {
+			cache.getAccessPage().setElem(line, (col & cache.getOffset()), band, data);
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#setElem(int, int, int, short)
+	 */
+	public void setElem(int line, int col, int band, short data) {
+		if(exists(col)) {
+			cache.getAccessPage().setElem(line, (col & cache.getOffset()), band, data);
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#setElem(int, int, int, int)
+	 */
+	public void setElem(int line, int col, int band, int data) {
+		if(exists(col)) {
+			cache.getAccessPage().setElem(line, (col & cache.getOffset()), band, data);
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#setElem(int, int, int, float)
+	 */
+	public void setElem(int line, int col, int band, float data) {
+		if(exists(col)) {
+			cache.getAccessPage().setElem(line, (col & cache.getOffset()), band, data);
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#setElem(int, int, int, double)
+	 */
+	public void setElem(int line, int col, int band, double data) {
+		if(exists(col)) {
+			cache.getAccessPage().setElem(line, (col & cache.getOffset()), band, data);
+		}
+	}
+	
+	//*********************************************************
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#getElemByte(int, int, byte[])
+	 */
+	public void getElemByte(int line, int col, byte[] data) {
+		if(exists(line)) {
+			cache.getAccessPage().getElemByte(
+					line, (col & cache.getOffset()), data);
+			return;
+		}
+		if(getNoDataValue().isDefined()) {
+			for (int iBand = 0; iBand < data.length; iBand++)
+	            data[iBand] = getNoDataValue().getValue().byteValue();
+		} else {
+			for (int iBand = 0; iBand < data.length; iBand++)
+	            data[iBand] = BufferNoData.defaultByteNoDataValue;
+		}
+	}
+
+	public void getElemShort(int line, int col, short[] data) {
+		if(exists(line)) {
+			cache.getAccessPage().getElemShort(
+					line, (col & cache.getOffset()), data);
+			return;
+		}
+		if(getNoDataValue().isDefined()) {
+			for (int iBand = 0; iBand < data.length; iBand++)
+	            data[iBand] = getNoDataValue().getValue().shortValue();
+		} else {
+			for (int iBand = 0; iBand < data.length; iBand++)
+	            data[iBand] = BufferNoData.defaultShortNoDataValue;
+		}
+	}
+
+	public void getElemInt(int line, int col, int[] data) {
+		if(exists(line)) {
+			cache.getAccessPage().getElemInt(
+					line, (col & cache.getOffset()), data);
+			return;
+		}
+		if(getNoDataValue().isDefined()) {
+			for (int iBand = 0; iBand < data.length; iBand++)
+	            data[iBand] = getNoDataValue().getValue().intValue();
+		} else {
+			for (int iBand = 0; iBand < data.length; iBand++)
+	            data[iBand] = BufferNoData.defaultIntegerNoDataValue;
+		}
+	}
+
+	public void getElemFloat(int line, int col, float[] data) {
+		if(exists(line)) {
+			cache.getAccessPage().getElemFloat(
+					line, (col & cache.getOffset()), data);
+			return;
+		}
+		if(getNoDataValue().isDefined()) {
+			for (int iBand = 0; iBand < data.length; iBand++)
+	            data[iBand] = getNoDataValue().getValue().floatValue();
+		} else {
+			for (int iBand = 0; iBand < data.length; iBand++)
+	            data[iBand] = BufferNoData.defaultFloatNoDataValue;
+		}
+	}
+
+	public void getElemDouble(int line, int col, double[] data) {
+		if(exists(line)) {
+			cache.getAccessPage().getElemDouble(
+					line, (col & cache.getOffset()), data);
+			return;
+		}
+		if(getNoDataValue().isDefined()) {
+			for (int iBand = 0; iBand < data.length; iBand++)
+	            data[iBand] = getNoDataValue().getValue().doubleValue();
+		} else {
+			for (int iBand = 0; iBand < data.length; iBand++)
+	            data[iBand] = BufferNoData.defaultDoubleNoDataValue;
+		}
+	}
+	
+	//*********************************************************
+	
+	public void setElemByte(int line, int col, byte[] data) {
+		if(exists(col)) {
+			cache.getAccessPage().setElemByte(
+					line, (col & cache.getOffset()), data);
+		}
+	}
+
+	public void setElemShort(int line, int col, short[] data) {
+		if(exists(col)) {
+			cache.getAccessPage().setElemShort(
+					line, (col & cache.getOffset()), data);
+		}
+	}
+
+	public void setElemInt(int line, int col, int[] data) {
+		if(exists(col)) {
+			cache.getAccessPage().setElemInt(
+					line, (col & cache.getOffset()), data);
+		}
+	}
+
+	public void setElemFloat(int line, int col, float[] data) {
+		if(exists(col)) {
+			cache.getAccessPage().setElemFloat(
+					line, (col & cache.getOffset()), data);
+		}
+	}
+
+	public void setElemDouble(int line, int col, double[] data) {
+		if(exists(col)) {
+			cache.getAccessPage().setElemDouble(
+					line, (col & cache.getOffset()), data);
+		}
+	}
+
+	//*********************************************************
+	
+	public void assign(int band, byte value) {
+		for(int line = 0; line < getHeight(); line ++) {
+			boolean beginLine = true;  //Para acelerar solo comprobar� si la p�gina est� en cach� cada vez que empieza una l�nea
+    		for(int col = 0; col < getWidth(); col ++) {
+    			try {
+    				if(beginLine) {
+    					lru.cacheAccess(line, false);
+    					beginLine = false;
+    				}
+    			} catch (InvalidPageNumberException e) {
+    				return;
+    			} catch (InterruptedException e) {
+    				return;
+    			}
+    			cache.getAccessPage().setElem(line, (col & cache.getOffset()), band, value);		
+    		}
+		}
+	}
+
+	public void assign(int band, short value) {
+		for(int line = 0; line < getHeight(); line ++) {
+			boolean beginLine = true;  //Para acelerar solo comprobar� si la p�gina est� en cach� cada vez que empieza una l�nea
+    		for(int col = 0; col < getWidth(); col ++) {
+    			try {
+    				if(beginLine) {
+    					lru.cacheAccess(line, false);
+    					beginLine = false;
+    				}
+    			} catch (InvalidPageNumberException e) {
+    				return;
+    			} catch (InterruptedException e) {
+    				return;
+    			}
+    			cache.getAccessPage().setElem(line, (col & cache.getOffset()), band, value);		
+    		}
+		}		
+	}
+
+	public void assign(int band, int value) {
+		for(int line = 0; line < getHeight(); line ++) {
+			boolean beginLine = true;  //Para acelerar solo comprobar� si la p�gina est� en cach� cada vez que empieza una l�nea
+    		for(int col = 0; col < getWidth(); col ++) {
+    			try {
+    				if(beginLine) {
+    					lru.cacheAccess(line, false);
+    					beginLine = false;
+    				}
+    			} catch (InvalidPageNumberException e) {
+    				return;
+    			} catch (InterruptedException e) {
+    				return;
+    			}
+    			cache.getAccessPage().setElem(line, (col & cache.getOffset()), band, value);		
+    		}
+		}	
+	}
+
+	public void assign(int band, float value) {
+		for(int line = 0; line < getHeight(); line ++) {
+			boolean beginLine = true;  //Para acelerar solo comprobar� si la p�gina est� en cach� cada vez que empieza una l�nea
+    		for(int col = 0; col < getWidth(); col ++) {
+    			try {
+    				if(beginLine) {
+    					lru.cacheAccess(line, false);
+    					beginLine = false;
+    				}
+    			} catch (InvalidPageNumberException e) {
+    				return;
+    			} catch (InterruptedException e) {
+    				return;
+    			}
+    			cache.getAccessPage().setElem(line, (col & cache.getOffset()), band, value);		
+    		}
+		}	
+	}
+
+	public void assign(int band, double value) {
+		for(int line = 0; line < getHeight(); line ++){
+			boolean beginLine = true;  //Para acelerar solo comprobar� si la p�gina est� en cach� cada vez que empieza una l�nea
+    		for(int col = 0; col < getWidth(); col ++){
+    			try {
+    				if(beginLine) {
+    					lru.cacheAccess(line, false);
+    					beginLine = false;
+    				}
+    			} catch (InvalidPageNumberException e) {
+    				return;
+    			} catch (InterruptedException e) {
+    				return;
+    			}
+    			cache.getAccessPage().setElem(line, (col & cache.getOffset()), band, value);		
+    		}
+		}
+	}
+	
+	//**************************************
+    //**********BANDS OPERATIONS************
+    //**************************************
+    
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#removeBand(int)
+	 */
+	public void removeBand(int iBand) throws IOException {
+    	if(iBand < 0 || iBand >= getBandCount())
+    		return;
+		cache.removeBand(iBand);
+		bands.remove(iBand);
+		bandLessLess();
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#addBand(int)
+	 */
+	public Band addBand(int pos) throws IOException {
+		cache.addBand(pos);
+		CacheBand cb = bands.add(pos, cache, lru, getDataType());
+		bandPlusPlus();
+		return cb;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBuffer#getBands()
+	 */
+	public Band[] getBands() {
+		Band[] b = new Band[bands.size()];
+		for (int i = 0; i < bands.size(); i++) 
+			b[i] = bands.get(i);
+		return b;
+	}
+	
+    /*
+     * (non-Javadoc)
+     * @see org.fv.raster.buffer.IRasterBuffer#getBandList()
+     */
+    public ArrayList<Band> getBandList() {
+    	ArrayList<Band> result = new ArrayList<Band>();
+    	for (int i = 0; i < bands.size(); i++) 
+			result.add(bands.get(i));
+    	return result;
+    }
+	
+	/**
+	 * Set the band to the selected position. To assign a cache band firstly it will 
+	 * check if the band to assign is compatible, then it will
+	 * load in each page in disk the page indicated by the target object. Finally it will 
+	 * assign the Cache object to the new band.
+	 * @throws IOException 
+	 */
+	public void assignBand(int pos, Band band) throws IOException, BandNotCompatibleException {
+		if(	band.getDataType() != getDataType())
+			throw new BandNotCompatibleException("Data type not compatible");
+		if(getBand(0) != null && band.getClass() != getBand(0).getClass())
+			throw new BandNotCompatibleException("buffer type not compatible");
+		if(	band.getHeight() != cache.getDataSourceHeight() || band.getWidth() != cache.getDataSourceWidth())
+				throw new BandNotCompatibleException("Bands with diferents sizes");
+		
+		cache.addBand(pos, band);
+		bands.add(pos, cache, lru, getDataType());
+		bandPlusPlus();
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.driver.IRasterBuffer#getBandByRef(int)
+	 */
+	public Band getBand(int band) {
+		if(bands.size() == 0 || band < 0 || band > (bands.size() - 1))
+			return null;
+		return bands.get(band);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.driver.IRasterBuffer#getBand(int)
+	 */
+	public Band getBandCopy(int band) {
+		switch (getDataType()) {
+		case RasterBuffer.TYPE_BYTE:
+			return (ByteBand)((ByteBand)bands.get(band)).clone();
+		case RasterBuffer.TYPE_SHORT:
+			return (ShortBand)((ShortBand)bands.get(band)).clone();
+		case RasterBuffer.TYPE_INT:
+			return (IntBand)((IntBand)bands.get(band)).clone();
+		case RasterBuffer.TYPE_FLOAT:
+			return (FloatBand)((FloatBand)bands.get(band)).clone();
+		case RasterBuffer.TYPE_DOUBLE:
+			return (DoubleBand)((DoubleBand)bands.get(band)).clone();
+		}
+		return null;
+	}
+	
+	/*
+     * (non-Javadoc)
+     * @see org.gvsig.fmap.driver.IRasterBuffer#getBandBuffer(int)
+     */
+    public Buffer getBufferWithOneBand(int iBand) throws IOException {
+    	//Creamos un buffer del mismo tama�o que el original para que la estructura de cache
+    	//sea la misma. Luego eliminaremos las bandas para a�adirle solo una.
+    	RasterVertCacheBuffer rcb = new RasterVertCacheBuffer(getDataType(), getWidth(), getHeight(), getBandCount());
+    	for (int i = getBandCount() - 1; i >= 0; i--) 
+    		rcb.removeBand(i);	
+    	try {
+			rcb.assignBand(0, getBand(iBand));
+		} catch (BandNotCompatibleException e) {
+			//It can't be throwed
+		}
+    	return rcb;
+    }
+    
+    /*
+     *  (non-Javadoc)
+     * @see org.gvsig.fmap.dataaccess.buffer.RasterBuffer#switchBands(int[])
+     */
+    public void swapBands(int[] bandPosition) throws WrongParameterException, IOException {
+    	super.swapBands(bandPosition);
+    	cache.swapBands(bandPosition);
+    	bands.swapBands(bandPosition);
+    }
+    
+    /*
+     * (non-Javadoc)
+     * @see org.gvsig.fmap.driver.IRasterBuffer#swapBands(int, int)
+     */
+	public void swapBands(int band1, int band2) throws WrongParameterException, IOException {
+		if(band1 < 0 || band1 > getBandCount() - 1 || band2 < 0 || band2 > getBandCount() - 1)
+			return;
+		
+		int[] bandPosition = new int[getBandCount()];
+		for (int i = 0; i < bandPosition.length; i++) {
+			if(i == band1) 
+				bandPosition[i] = band2;
+			else if(i == band2) 
+				bandPosition[i] = band1;
+			else
+				bandPosition[i] = i;
+		}
+		swapBands(bandPosition);
+	}
+	
+	/*
+     *  (non-Javadoc)
+     * @see org.gvsig.fmap.driver.IRasterBuffer#copyBand(int, org.gvsig.fmap.dataaccess.buffer.IBand)
+     */
+	public void copyBand(int iBand, Band band) throws BandNotCompatibleException, OperationNotSupportedException {
+		super.copyBand(iBand, band);
+	}
+	
+    /*
+     *  (non-Javadoc)
+     * @see org.gvsig.fmap.driver.IRasterBuffer#replicateBand(int, int)
+     */
+	public void replicateBand(int orig, int dest) throws IOException {
+		Band origBand = getBandCopy(orig);
+		try {
+			assignBand(dest, origBand);
+		} catch (BandNotCompatibleException e) {
+			//It can't be throwed
+		}
+	}  
+	
+	/**
+	 * Create a band with the current cache information.
+	 */
+	public Band createBand(double defaultValue) {
+		CacheVertImpl clonCache = cache.cloneStructure();
+		LRUAlgorithm lru = new LRUAlgorithm(clonCache);
+		for (int i = getBandCount() - 1; i >= 0 ; i--) {
+			try {
+				clonCache.removeBand(i);
+			} catch (IOException e) {
+				return null;
+			}
+		}
+		clonCache.createPages(1);
+		
+		switch (getDataType()) {
+		case RasterBuffer.TYPE_BYTE:	
+			ByteBand bb = new ByteBand(clonCache, lru, 0);
+			bb.assign((byte)defaultValue);
+			return bb;
+		case RasterBuffer.TYPE_SHORT:
+			ShortBand sb = new ShortBand(clonCache, lru, 0);
+			sb.assign((short)defaultValue);
+			return sb;
+		case RasterBuffer.TYPE_INT:
+			IntBand ib = new IntBand(clonCache, lru, 0);
+			ib.assign((int)defaultValue);
+			return ib;
+		case RasterBuffer.TYPE_FLOAT:
+			FloatBand fb = new FloatBand(clonCache, lru, 0);
+			fb.assign((float)defaultValue);
+			return fb;
+		case RasterBuffer.TYPE_DOUBLE:
+			DoubleBand db = new DoubleBand(clonCache, lru, 0);
+			db.assign(defaultValue);
+			return db;
+		}
+		return null;
+	}
+		
+	/*
+	 *  (non-Javadoc)
+	 * @see org.gvsig.fmap.driver.IRasterBuffer#assignBandToNotValid(int)
+	 */
+	public void assignBandToNotValid(int iBand) {
+		switch (getDataType()) {
+		case RasterBuffer.TYPE_BYTE:	
+			for (int row = 0; row < getHeight(); row++) 
+				for (int col = 0; col < getWidth(); col++) 
+					setElem(row, col, iBand, (byte)notValidValue);
+		case RasterBuffer.TYPE_SHORT:
+			for (int row = 0; row < getHeight(); row++) 
+				for (int col = 0; col < getWidth(); col++) 
+					setElem(row, col, iBand, (short)notValidValue);
+		case RasterBuffer.TYPE_INT:
+			for (int row = 0; row < getHeight(); row++) 
+				for (int col = 0; col < getWidth(); col++) 
+					setElem(row, col, iBand, (int)notValidValue);
+		case RasterBuffer.TYPE_FLOAT:
+			for (int row = 0; row < getHeight(); row++) 
+				for (int col = 0; col < getWidth(); col++) 
+					setElem(row, col, iBand, (float)notValidValue);
+		case RasterBuffer.TYPE_DOUBLE:
+			for (int row = 0; row < getHeight(); row++) 
+				for (int col = 0; col < getWidth(); col++) 
+					setElem(row, col, iBand, (double)notValidValue);
+		}
+	}
+		
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.dataset.IRasterBuffer#free()
+	 */
+	public void free() throws IOException {
+		cache.clearCache();
+	}
+	
+	/*
+     *  (non-Javadoc)
+     * @see org.gvsig.fmap.driver.IRasterBuffer#cloneBuffer()
+     */
+    public Buffer cloneBuffer(){
+    	return null;
+    }
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/vertical/RasterVertCacheBuffer.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/HDDPage.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/HDDPage.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/HDDPage.java	(revision 3222)
@@ -0,0 +1,144 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.exception.WrongParameterException;
+import org.gvsig.raster.cache.buffer.impl.BufferServices;
+
+
+/**
+ * Esta clase representa una p�gina de disco. Una p�gina de disco tendr� un n�mero de
+ * p�gina asociado y un servidor de datos de disco por cada banda. 
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class HDDPage {
+	private String              timePag    = null;    
+	private int                 iPag       = -1;
+	private int                 nBands     = -1;
+	private BufferDataSource    dataSource = null;
+		
+	/**
+	 * Constructor: crea un objeto dataSource para cada banda. Para todos los datasource de un 
+	 * mismo HddPage se usa el mismo identificador.
+	 * @param nPag N�mero de p�gina
+	 * @param nBands N�mero de bandas del dataset
+	 */
+	public HDDPage(int iPag, int nBands, BufferDataSource dataSource) {
+		this.dataSource = dataSource;
+		this.iPag = iPag;
+		this.nBands = nBands;
+		this.timePag = BufferServices.getTemporalPath() + File.separator + Long.toString(System.currentTimeMillis()) + "-" + iPag + "-";
+	}
+		
+	/**
+	 * Limpia los trozos de cach� en disco. Despu�s del llamar a este 
+	 * m�todo no puede volver a usarse esta cach�.
+	 * @throws IOException 
+	 */
+	public void deletePage() throws IOException {
+		for (int i = 0; i < nBands; i++) 
+			dataSource.delete(timePag + i);
+	}
+	
+	/**
+	 * Limpia los trozos de cach� en disco de una banda. Despu�s del llamar a este 
+	 * m�todo no puede volver a usarse esta banda.
+	 * @throws IOException 
+	 */
+	public void removeBand(int pos) throws IOException {
+		dataSource.delete(timePag + pos);
+		for (int i = (pos + 1); i < nBands; i++) 
+			dataSource.changeFileName(timePag + i, timePag + (i - 1));
+		nBands --;
+	}
+	
+	/**
+	 * Adds a new band in the selected position. 
+	 * @param pos
+	 * @throws IOException 
+	 */
+	public void addBand(int pos, PageBuffer pb) throws IOException {
+		for (int i = (nBands - 1); i >= pos ; i--)
+			dataSource.changeFileName(timePag + i, timePag + (i + 1));
+		dataSource.saveBand(pb.getBand(0), timePag + pos);
+		nBands ++;
+	}
+	
+	/**
+	 * Swaps bands according to positions selected in bandPosition parameter.
+	 * 
+	 * @param  bandPosition
+	 *         New order for the bands in the array. Each position in the array represent the old band
+	 *         .The number that it contains represent the new position of that band. For instance, an
+	 *         array with values {1, 0, 2, 3} means that it has four bands and the band number one is swaped
+	 *         with the band number zero. The bands two and three don't change its position in this example.   			
+	 * @throws WrongParameterException
+	 */
+	 public void swapBands(int[] bandPosition) throws WrongParameterException {
+		 for (int i = 0; i < bandPosition.length; i++) 
+			 dataSource.changeFileName(timePag + i, timePag + i + "old");
+		 for (int i = 0; i < bandPosition.length; i++) 
+			 dataSource.changeFileName(timePag + bandPosition[i] + "old", timePag + i);
+	 }
+	
+	/**
+	 * Loads a page of data from the hard disk. 
+	 * @param buf Buffer where is loaded
+	 * @throws InterruptedException
+	 */
+	public void loadPage(PageBuffer buf) throws InterruptedException {
+		dataSource.loadPage(buf, timePag);
+	}
+	
+	/**
+	 * Salva una p�gina especificada en el par�metro nPag a disco. 
+	 * Para esto recorre todas las bandas de la p�gina llamando al save de cada una.
+	 *   
+	 * @param nPag N�mero de p�gina a salvar
+	 * @throws IOException
+	 */
+	public void savePage(PageBuffer buf) throws IOException {
+		dataSource.savePage(buf, timePag);
+	}
+
+	/**
+	 * Gets the string with the file id
+	 * @return
+	 */
+	public String getFileID() {
+		return timePag;
+	}
+	
+	/**
+	 * Sets the string with the file id
+	 * @return
+	 */
+	public void setFileID(String id) {
+		this.timePag = id;
+	}
+	
+	/**
+	 * This method creates a new file with a new identifier and copy data. 
+	 */
+	public Object clone() {
+		HDDPage clon = new HDDPage(iPag, nBands, dataSource);
+		String newID = BufferServices.getTemporalPath() + File.separator + Long.toString(System.currentTimeMillis()) + "-" + iPag + "-";
+		clon.setFileID(newID);
+		for (int i = 0; i < nBands; i++) {
+			try {
+				File f = new File(timePag + i);
+				if(f.exists() && f.canRead() && f.canWrite())
+					BufferServices.copyFile(timePag + i, newID + i);
+			} catch (FileNotFoundException e) {
+				e.printStackTrace();
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+		return clon;
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/HDDPage.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/PageCacheList.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/PageCacheList.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/PageCacheList.java	(revision 3222)
@@ -0,0 +1,105 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+import org.gvsig.raster.cache.buffer.exception.WrongParameterException;
+
+/**
+ * List of pages in cache structure
+ * 
+ * 21/10/2008
+ * @author Nacho Brodin nachobrodin@gmail.com
+ */
+public class PageCacheList extends ArrayList<PageBuffer> {
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * Make the list of pages and the structure of pages in memory
+	 * @param  nPagsCache
+	 *         Number of pages in cache
+	 * @param  nBands
+	 *         Number of bands 
+	 * @param  hPag
+	 *         Page height in pixels
+	 * @param  dataType
+	 * @param  dataSourceWidth
+	 */
+	public PageCacheList(int nPagsCache, int nBands, int hPag, int dataType, int wPag) {
+		for (int iPag = 0; iPag < nPagsCache; iPag++) 
+			add(new PageBuffer(dataType, wPag, hPag, nBands, true));
+	}
+	
+	/**
+	 * Empty constructor for clonations
+	 */
+	public PageCacheList(){}
+		
+	/**
+	 * Elimina una banda de la cach�. Antes salva a disco todos los trozos cacheados e inicializa
+	 * las estructuras de control de cach�. 
+	 * @param  nBand 
+	 *         N�mero de banda a eliminar
+	 * @throws IOException 
+	 */
+	public void removeBand(int iBand) throws IOException {
+		for (int iPage = 0; iPage < size(); iPage++)
+			get(iPage).removeBand(iBand);
+	}
+	
+	/**
+	 * Add a band to PageCacheList
+	 * @param iBand
+	 */
+	public void addBand(int pos) {
+		for (int iPage = 0; iPage < size(); iPage++)
+			get(iPage).addBand(pos);
+	}
+	
+	/**
+	 * Swap bands accordint to positions selected in bandPosition parameter.
+	 * 
+	 * @param  bandPosition
+	 *         New order for the bands in the array. Each position in the array represent the old band
+	 *         .The number that it contains represent the new position of that band. For instance, an
+	 *         array with values {1, 0, 2, 3} means that it has four bands and the band number one is swaped
+	 *         with the band number zero. The bands two and three don't change its position in this example.   			
+	 * @throws WrongParameterException
+	 * @throws IOException 
+	 */
+	 public void swapBands(int[] bandPosition) throws WrongParameterException, IOException {
+		 for (int iPage = 0; iPage < size(); iPage++)
+				get(iPage).swapBands(bandPosition);
+	 }
+	
+	/**
+	 * Limpia los trozos de cach� de memoria. Despu�s del llamar a este 
+	 * m�todo no puede volver a usarse esta cach�.
+	 * @throws IOException 
+	 */
+	public void clearPageList() throws IOException {
+		for (int i = 0; i < size(); i++)
+			get(i).free();
+	}
+	
+	/**
+	 * Asigna la lista de paginas de disco
+	 * @param  hddList 
+	 *         Lista de p�ginas de disco
+	 */
+	public void setHddPages(ArrayList<HDDPage> hddList) {
+		for (int i = 0; i < size(); i++) 
+			get(i).setHddPages(hddList);
+	}
+		
+	/*
+	 * (non-Javadoc)
+	 * @see java.util.ArrayList#clone()
+	 */
+	public Object clone() {
+		PageCacheList clon = new PageCacheList();
+		for (int i = 0; i < size(); i++) 
+			clon.add( (PageBuffer)get(i).clone());
+		return clon;
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/PageCacheList.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/ICacheStruct.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/ICacheStruct.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/ICacheStruct.java	(revision 3222)
@@ -0,0 +1,175 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache;
+
+
+
+/**
+ * Esta clase representa la estructura en memoria de la cache. Contiene el n�mero de p�ginas 
+ * as� como los subconjuntos en las que se divide. Tendr� tambi�n datos como en ancho y alto de
+ * cada p�gina y tama�o en memoria de esta. 
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ *
+ */
+public interface ICacheStruct {
+	/**
+	 * Obtiene la altura de la p�gina de cache en l�neas. 
+	 * @return N�mero de l�neas de altura de p�gina.
+	 */
+	public int getHPag();
+	
+	/**
+	 * Asigna la altura de la p�gina de cache en l�neas. 
+	 * @param N�mero de l�neas de altura de p�gina.
+	 */
+	public void setHPag(int hPag);
+
+	/**
+	 * Obtiene el n�mero de bandas
+	 * @return N�mero de bandas
+	 */
+	public int getNBands();
+	
+	/**
+	 * Asigna el n�mero de bandas
+	 * @param N�mero de bandas
+	 */
+	public void setNBands(int nBands);
+
+	/**
+	 * Obtiene el n�mero de p�ginas de la cach�
+	 * @return N�mero total de p�ginas de la cach�
+	 */
+	public int getNPags();
+	
+	/**
+	 * Asigna el n�mero de p�ginas de la cach�
+	 * @param N�mero total de p�ginas de la cach�
+	 */
+	public void setNPags(int nPags);
+
+	/**
+	 * Obtiene el tama�o de p�gina en bytes
+	 * @return Tama�o de p�gina en bytes
+	 */
+	public long getPagSize();
+		
+	/**
+	 * Obtiene el n�mero de p�ginas que contiene cada grupo.
+	 * @return N�mero de p�ginas de un grupo.
+	 */
+	public int getPagsPerGroup();
+
+	/**
+	 * Obtiene el n�mero de grupos de cach�
+	 * @return N�mero de grupos
+	 */
+	public int getNGroups();
+	
+	/**
+	 * Asigna el n�mero de grupos de cach�
+	 * @param nGroups N�mero de grupos
+	 */
+	public void setNGroups(int nGroups);
+	
+	/**
+	 * Obtiene el n�mero total de p�ginas del raster
+	 * @return N�mero total de p�ginas
+	 */
+	public int getNTotalPags();
+	
+	/**
+	 * Asigna el n�mero total de p�ginas del raster
+	 * @param N�mero total de p�ginas
+	 */
+	public void setNTotalPags(int nPags);
+	
+	/**
+	 * Obtiene el n�mero de bits por p�gina para poder calcular el desplazamiento binario
+	 * de la direcci�n de acceso de la petici�n. Es decir si se solicita un dato en la l�nea
+	 * 36 (en decimal) del raster 100100(en binario) y el desplazamiento es 4 bits el n�mero de 
+	 * p�gina resultante ser� 10(en binario) 2 (en decimal)
+	 * @return N�mero de bits por p�gina.
+	 */
+	public int getBitsPag();
+	
+	/**
+	 * Asigna el n�mero de bits por p�gina para poder calcular el desplazamiento binario
+	 * de la direcci�n de acceso de la petici�n. Es decir si se solicita un dato en la l�nea
+	 * 36 (en decimal) del raster 100100(en binario) y el desplazamiento es 4 bits el n�mero de 
+	 * p�gina resultante ser� 10(en binario) 2 (en decimal)
+	 * @param bitsPag
+	 */
+	public void setBitsPag(int bitsPag);
+
+	/**
+	 * Obtiene el valor del desplazamiento
+	 * Para extraer el desplazamiento de una direcci�n (l�nea de raster) hay que hacer una operaci�n And con 
+	 * con la altura de la p�gina -1. Por ejemplo, una p�gina de 16 l�neas de altura el desplazamiento ser�
+	 * 16 - 1 = 15 porque 15 en binario es 1111.
+	 * 
+	 * Si queremos acceder a la linea del raster n�mero 83 (1010011) realizando la operaci�n And con el valor del
+	 * desplazamiento obtenemos (0001111 & 1010011 = 0000011), es decir el valor 3 en decimal. Esto quiere decir
+	 * que la l�nea 83 del raster es la 3 de su p�gina. 
+	 * @return valor del desplazamiento
+	 */
+	public int getOffset();
+
+	/**
+	 * Asigna el valor del desplazamiento.
+	 * Para extraer el desplazamiento de una direcci�n (l�nea de raster) hay que hacer una operaci�n And con 
+	 * con la altura de la p�gina -1. Por ejemplo, una p�gina de 16 l�neas de altura el desplazamiento ser�
+	 * 16 - 1 = 15 porque 15 en binario es 1111.
+	 * 
+	 * Si queremos acceder a la linea del raster n�mero 83 (1010011) realizando la operaci�n And con el valor del
+	 * desplazamiento obtenemos (0001111 & 1010011 = 0000011), es decir el valor 3 en decimal. Esto quiere decir
+	 * que la l�nea 83 del raster es la 3 de su p�gina. 
+	 * @param offset valor del desplazamiento
+	 */
+	public void setOffset(int offset);
+
+	/**
+	 * Obtiene el tama�o de la cach� por cada banda del raster. Hay que tener en
+	 * cuenta que cada banda se trata como una estructura de datos en memoria distinta
+	 * para poder hacer switch con las bandas de una forma sencilla
+	 * @return long con el tama�o de cache por banda
+	 */
+	public long getCacheSizePerBand();
+
+	/**
+	 * Asigna el tama�o de la cach� por cada banda del raster. Hay que tener en
+	 * cuenta que cada banda se trata como una estructura de datos en memoria distinta
+	 * para poder hacer switch con las bandas de una forma sencilla
+	 * @param long con el tama�o de cache por banda
+	 */
+	public void setCacheSizePerBand(long cacheSizePerBand);
+
+	/**
+	 * Obtiene el tama�o de una p�gina de cach� correspondiente a una banda
+	 * @return tama�o de una p�gina de cach� correspondiente a una banda
+	 */
+	public long getPagSizePerBand();
+
+	/**
+	 * Asigna el tama�o de una p�gina de cach� correspondiente a una banda
+	 * @param tama�o de una p�gina de cach� correspondiente a una banda
+	 */
+	public void setPagSizePerBand(long pagSizePerBand);
+	
+	/**
+	 * Obtiene el tipo de dato
+	 * @return Tipo de dato
+	 */
+	public int getDataType();
+
+	/**
+	 * Asigna el tipo de dato
+	 * @param dataType
+	 */
+	public void setDataType(int dataType);
+	
+	/**
+	 * Clones this object
+	 * @return
+	 */
+	public Object clone();
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/ICacheStruct.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/Cache.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/Cache.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/Cache.java	(revision 3222)
@@ -0,0 +1,262 @@
+package org.gvsig.raster.cache.buffer.impl.stripecache;
+
+import java.io.IOException;
+
+import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer;
+
+
+/**
+ * This interface should be implemented by any class that represents a Cache
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public interface Cache {
+	/**
+	 * Get the width of the data source
+	 * @return int
+	 */
+	public int getDataSourceWidth();
+
+	/**
+	 * Get the height of the data source
+	 * @return int
+	 */
+	public int getDataSourceHeight();
+	
+	/**
+	 * Gets the height of a cache page in lines
+	 * @return Number of lines
+	 */
+	public int getHPag();
+	
+	/**
+	 * Gets the page of data which is being accessed 
+	 * @return accessed PageBuffer 
+	 */
+	public RasterMemoryBuffer getAccessPage();
+	
+	/**
+	 * Gets the offset
+	 * @return
+	 */
+	public int getOffset();
+	
+	/**
+	 * Clones this object
+	 * @return
+	 */
+	public Object clone();
+	
+	/**
+	 * Obtiene la p�gina de datos de la posici�n pag
+	 * @param pag N�mero de p�gina de cach� a recuperar
+	 * @return PageBuffer correspondiente a la p�gina recuperada
+	 */
+	public PageBuffer getPageBufferFromNumberCachePage(int pag);
+	
+	/**
+	 * Obtiene la p�gina de datos a partir del n�mero de p�gina de raster
+	 * @param pag N�mero de p�gina raster a recuperar
+	 * @return PageBuffer correspondiente a la p�gina recuperada o null si no est� en cach�
+	 */
+	public PageBuffer getPageBufferFromNumberRasterPage(int pag);
+	
+	/**
+	 * Obtiene el n�mero de p�gina de cach� (en formato grupo/p�gina dentro del grupo) 
+	 * donde est� cargada la p�gina del raster que se ha pasado por par�metro.
+	 * @param pag P�gina del raster
+	 * @return N�mero de p�gina del raster
+	 */
+	public int[] getNumberGroupFromNumberRasterPage(int pag);
+	
+	/**
+	 * Asigna el buffer de la p�gina accedida por referencia
+	 * @param pb
+	 */
+	public void setAccessPage(PageBuffer pb, int pagNumber);
+	
+	/**
+	 * Actualiza los �ltimos accesos del grupo pasado por par�metro. Se incrementar� 
+	 * uno en todas las p�ginas del conjunto a excepci�n de las que valen -1 ya que 
+	 * esto significa que no hay p�gina cargada en dicha posici�n.
+	 * @param group N�mero de grupo a actualizar sus accesos
+	 * @return La posici�n del elemento del grupo con valor m�ximo. Este elemento 
+	 * es el candidato para el reemplazo.
+	 */
+	public int updateLastAccess(int group);
+	
+	/**
+	 * Asigna un cero en la posici�n del array que contiene la antig�edad de acceso dentro 
+	 * del grupo. Esta operaci�n se realiza cada vez que se accede a un dato del la p�gina 
+	 * cacheada y significa que es la p�gina m�s recientemente accedida.
+	 * @param group N�mero de grupo
+	 * @param posInGroup Posici�n de la p�gina dentro del grupo.
+	 */
+	public void setZeroInLastAccess(int group, int posInGroup);
+	
+	/**
+	 * Pone como modificada una p�gina de cach�
+	 * @param nCachePag N�mero de p�gina de cach� (posici�n de esta)
+	 */
+	public void setModify(int nCachePag);
+	
+	/**
+	 * Pone como modificada una p�gina de cach�
+	 * @param group Grupo en el que se encuentra la p�gina
+	 * @param posInGroup Posici�n dentro del grupo en el que est� la p�gina
+	 */
+	public void setModify(int group, int posInGroup);
+	
+	/**
+	 * Obtiene el n�mero de grupos de cach�
+	 * @return N�mero de grupos
+	 */
+	public int getNGroups();
+	
+	/**
+	 * Obtiene el n�mero total de p�ginas del raster
+	 * @return N�mero total de p�ginas
+	 */
+	public int getNTotalPags();
+	
+	/**
+	 * Obtiene el n�mero de p�gina del raster cargada en una p�gina de cach� especificada
+	 * en el par�metro. 
+	 * @param nCachePage N�mero de p�gina de cach� de la que se quiere saber que p�gina del 
+	 * raster hay cargada.
+	 * @return N�mero de p�gina del raster
+	 */
+	public int getRasterPageNumberInPosition(int nCachePage);
+	
+	/**
+	 * Obtiene el n�mero de p�gina del raster cargada en una p�gina de cach� especificada
+	 * en el par�metro. 
+	 * @param group Grupo en el que se encuentra la p�gina
+	 * @param posInGroup Posici�n dentro del grupo en el que est� la p�gina
+	 * @return N�mero de p�gina del raster
+	 */
+	public int getRasterPageNumberInPosition(int group, int posInGroup);
+	
+	/**
+	 * Asigna el n�mero de p�gina del raster cargada en una p�gina de cach� especificada.
+	 * @param nCachePage N�mero de p�gina de cach� 
+	 * @param nRasterPage N�mero de p�gina de raster a asignar
+	 */
+	public void setRasterPageNumberInPosition(int nCachePage, int nRasterPage);
+	
+	/**
+	 * Asigna el n�mero de p�gina del raster cargada en una p�gina de cach� especificada.
+	 * @param nCachePage N�mero de p�gina de cach� 
+	 * @param nRasterPage N�mero de p�gina de raster a asignar
+	 */
+	public void setRasterPageNumberInPosition(int group, int posInGroup, int nRasterPage);
+	
+	/**
+	 * Marca una p�gina como cargada en cach�.
+	 * @param nPag N�mero de p�gina a marcar.
+	 */
+	public void setPageAsLoadInCache(int nPag);
+	
+	/**
+	 * Desmarca una p�gina como cargada en cach�.
+	 * @param nPag N�mero de p�gina a desmarcar.
+	 */
+	public void setPageAsNotLoadInCache(int nPag);
+	
+	/**
+	 * Consulta si una p�gina de cach� ha sido modificada desde que se carg� en cach� o no.
+	 * @param nCachePag N�mero de p�gina de cach� (posici�n de esta)
+	 * @return true si ha sido modificada y false si no lo ha sido.
+	 */
+	public boolean isModified(int nCachePag);
+
+	/**
+	 * Consulta si una p�gina de cach� ha sido modificada desde que se carg� en cach� o no.
+	 * @param group Grupo en el que se encuentra la p�gina
+	 * @param posInGroup Posici�n dentro del grupo en el que est� la p�gina
+	 * @return true si ha sido modificada y false si no lo ha sido.
+	 */
+	public boolean isModified(int group, int posInGroup);
+	
+	/**
+	 * Pone como no modificada una p�gina de cach�
+	 * @param nCachePag N�mero de p�gina de cach� (posici�n de esta)
+	 */
+	public void unsetModify(int nCachePag);
+	
+	/**
+	 * Pone como no modificada una p�gina de cach�
+	 * @param group Grupo en el que se encuentra la p�gina
+	 * @param posInGroup Posici�n dentro del grupo en el que est� la p�gina
+	 */
+	public void unsetModify(int group, int posInGroup);
+	
+	/**
+	 * Salva una p�gina especificada en el par�metro nPag a disco. La
+	 * petici�n que ha de hacerse se calcula previamente con la estructura de la cach�.
+	 *   
+	 * @param group Grupo del que se salva la p�gina nPag
+	 * @param posInGroupPageToReplace Posici�n dentro del grupo del que se salva la p�gina
+	 * @param nPag P�gina a salvar
+	 * @throws IOException
+	 */
+	public void savePage(int group, int posInGroupPageToReplace, int nPag) throws IOException;
+	
+	/**
+	 * Carga una p�gina especificada en el par�metro nPag con los datos necesarios. La
+	 * petici�n que ha de hacerse se calcula previamente con la estructura de la cach�.
+	 *   
+	 * @param group Grupo sobre el que se carga la p�gina nPag
+	 * @param posInGroupPageToReplace Posici�n dentro del grupo sobre el que se carga la p�gina
+	 * @param nPag P�gina a cargar
+	 * @throws InterruptedException 
+	 */
+	public void loadPage(int group, int posInGroupPageToReplace, int nPag) throws InterruptedException;
+	
+	/**
+	 * Obtiene la p�gina de datos del grupo definido en el par�metro group y de la 
+	 * posici�n pag dentro de ese grupo.
+	 * @param group Grupo de la p�gina requerida
+	 * @param pag N�mero de p�gina dentro del grupo
+	 * @return PageBuffer correspondiente a la p�gina recuperada
+	 */
+	public PageBuffer getPageBuffer(int group, int posInGroup);
+	
+	/**
+	 * Obtiene el array que contiene los valores de la antig�edad del acceso dentro del
+	 * grupo. La primera dimensi�n del array corresponde al n�mero de grupo y la segunda
+	 * a los elementos del grupo. El elemento del grupo con un acceso m�s reciente tendr� 
+	 * un n�mero menor y el de mayor valor ser� el candidato para la sustituci�n en el pr�ximo
+	 * remplazamiento.
+	 * @return Array bidimensional con los valores de antig�edad.
+	 */
+	public int[][] getLastAccess();
+	
+	/**
+	 * Obtiene el n�mero de p�ginas que tiene cada grupo
+	 * @return Entero con el n�mero de p�ginas por grupo 
+	 */
+	public int getPagsPerGroup();
+	
+	/**
+	 * Obtiene el n�mero de bits por p�gina para poder calcular el desplazamiento binario
+	 * de la direcci�n de acceso de la petici�n. Es decir si se solicita un dato en la l�nea
+	 * 36 (en decimal) del raster 100100(en binario) y el desplazamiento es 4 bits el n�mero de 
+	 * p�gina resultante ser� 10(en binario) 2 (en decimal)
+	 * @return
+	 */
+	public int getBitsPag();
+	
+	/**
+	 * Array de booleanos donde cada elemento es una p�gina del raster y dice si la p�gina 
+	 * est� cacheada o no.
+	 * @return true si la p�gina est� en cach� y false si no lo est�
+	 */
+	public boolean isInCache(int nPag);
+	
+	/**
+	 * Obtiene el n�mero de p�gina cargada en el buffer
+	 * @return Entero con el n�mero de p�gina
+	 */
+	public int getNumberInAccessPage();
+
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/stripecache/Cache.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/BufferCacheManagerImpl.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/BufferCacheManagerImpl.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/BufferCacheManagerImpl.java	(revision 3222)
@@ -0,0 +1,306 @@
+package org.gvsig.raster.cache.buffer.impl;
+
+import java.io.IOException;
+
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferCacheManager;
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.BufferInterpolation;
+import org.gvsig.raster.cache.buffer.BufferNoData;
+import org.gvsig.raster.cache.buffer.BufferParam;
+import org.gvsig.raster.cache.buffer.histogram.BufferHistogram;
+import org.gvsig.raster.cache.buffer.impl.datastruct.DefaultNoData;
+import org.gvsig.raster.cache.buffer.impl.histogram.BufferHistogramImpl;
+import org.gvsig.raster.cache.buffer.impl.io.BufferDataSourceImpl;
+import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer;
+import org.gvsig.raster.cache.buffer.impl.rocache.RasterReadOnlyBuffer;
+import org.gvsig.raster.cache.buffer.impl.stripecache.horizontal.RasterCacheBuffer;
+import org.gvsig.raster.cache.buffer.impl.stripecache.vertical.RasterVertCacheBuffer;
+import org.gvsig.raster.cache.buffer.impl.task.DefaultTaskEventManager;
+import org.gvsig.raster.cache.buffer.task.TaskEventManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class BufferCacheManagerImpl implements BufferCacheManager {
+	private static final Logger    logger = LoggerFactory.getLogger(BufferCacheManagerImpl.class);
+	
+	/**
+	 * This variable represents which buffer is going to be used. By default has a
+	 * DONT_FORCE value. That means that the algorithm to select the type of buffer 
+	 * is applied. The other types of constants force the use of a kind of buffer.  
+	 */
+	public static int	           forceBuffer                = DONT_FORCE;
+	
+	/**
+	 * Tama�o aproximado de cach� en Megas. Si este valor es alto cabr�n muchas p�ginas en memoria
+	 * a la vez y si es bajo cabr�n pocas. Hay que tener en cuenta que al instanciar se convertira en bytes
+	 * para su mejor tratamiento. Al llamar al constructor esta variable contendr� el tama�o exacto
+	 * de la cache en bytes. El tama�o aqu� especificado es aproximado. Este variar� dependiendo de los
+	 * par�metros del raster a cachear ya que las p�ginas deben tener una altura potencia de 2.
+	 */
+	public static long              cacheSize                 = 25;
+	/**
+	 * Tama�o m�ximo de la p�gina en Megas. Hay que tener en cuenta que al instanciar se convertira en bytes
+	 * para su mejor tratamiento. Al llamar al constructor esta variable contendr� el tama�o exacto
+	 * de la p�gina en bytes
+	 */
+	public static double            pageSize                  = 4;
+	/**
+	 * N�mero de p�ginas que tiene cada conjunto de cach�
+	 */
+	public static int               pagsPerGroup              = 5;
+	/**
+	 * En la generaci�n autom�tica de clases esta variable representa el n�mero de
+	 * clases en las que se hace la divisi�n.
+	 */
+	public static int               defaultNumberOfClasses    = 64;
+	
+	/**
+	 * Genera instancias del buffer de datos adecuado al tama�o del raster. Si no hay muchos datos
+	 * (menos de cacheMemorySize) crear� un buffer en memoria. Si hay m�s de esta cantidad
+	 * entonces crearemos un buffer cacheado (RasterCache). A partir de la cantidad se�alada
+	 * por multicacheMemorySize haremos un buffer cacheado donde cada p�gina no ocupa todo
+	 * el ancho del raster ya que este ser� muy grande. La gesti�n de una cache donde cada
+	 * pagina ha de partir una l�nea lleva una complejidad a�adida.
+	 *  
+	 * @param params Par�metros de la carga
+	 * @return Objeto RasterBuffer
+	 */
+	public Buffer createBuffer(BufferParam params) {
+		//Opci�n de cachear siempre activada (Solo DEBUG)
+		if(forceBuffer == BufferCacheManager.BAND_CACHE)
+			return new RasterCacheBuffer(params.getDataType(), 
+					(int)params.getWidth(), 
+					(int)params.getHeight(), 
+					params.getBandCount());
+		
+		if(forceBuffer == BufferCacheManager.BAND_VERT_CACHE)
+			return new RasterVertCacheBuffer(params.getDataType(), 
+					(int)params.getWidth(), 
+					(int)params.getHeight(), 
+					params.getBandCount());
+		
+		if (forceBuffer == BufferCacheManager.READ_ONLY_CACHE)
+			return new RasterReadOnlyBuffer(params.getDataSource(), 
+					params.getX(), 
+					params.getY(), 
+					params.getWidth(), 
+					params.getHeight(),
+					params.getBandList());
+		
+		if (forceBuffer == BufferCacheManager.MEMORY_BUFFER) {
+			RasterMemoryBuffer b = new RasterMemoryBuffer(params.getDataType(), 
+					(int)params.getWidth(), 
+					(int)params.getHeight(), 
+					params.getBandCount(), 
+					true);
+			try {
+				//Para el buffer en memoria ya no necesitamos el proveedor de datos
+				if(params.getDataSource() != null)
+					params.getDataSource().close();
+			} catch (IOException e) {
+				logger.debug("I can't close the dataset", b, e);
+			}
+			return b;
+		}
+			
+		if(forceBuffer == BufferCacheManager.DONT_FORCE) {
+			if(params.getAccessType() == RasterBuffer.READ_ONLY) 
+				return new RasterReadOnlyBuffer(params.getDataSource(), 
+						params.getX(), 
+						params.getY(), 
+						params.getWidth(), 
+						params.getHeight(),
+						params.getBandList());
+			
+			
+			if(params.getAccessType() == RasterBuffer.READ_WRITE || params.getAccessType() == RasterBuffer.READ_WRITE_CVERT) {
+				long size = (RasterBuffer.getBytesFromRasterBufType((int)params.getDataType()) * (int)params.getWidth() * (int)params.getHeight() * (int)params.getBandCount()) / 1024;
+				long ms1 = BufferCacheManagerImpl.cacheSize * 1024;
+				if(size <= ms1) {
+					RasterMemoryBuffer b =  new RasterMemoryBuffer(params.getDataType(), 
+							(int)params.getWidth(), 
+							(int)params.getHeight(), 
+							params.getBandCount(), 
+							true);
+					try {
+						//Para el buffer en memoria ya no necesitamos el proveedor de datos
+						if(params.getDataSource() != null)
+							params.getDataSource().close();
+					} catch (IOException e) {
+						logger.debug("I can't close the dataset", b, e);
+					}
+					return b;
+				} else {
+					if(params.getAccessType() == RasterBuffer.READ_WRITE) {
+						return new RasterCacheBuffer(params.getDataType(), 
+								(int)params.getWidth(), 
+								(int)params.getHeight(), 
+								params.getBandCount());
+					}
+					if(params.getAccessType() == RasterBuffer.READ_WRITE_CVERT) {
+						return new RasterVertCacheBuffer(params.getDataType(), 
+								(int)params.getWidth(), 
+								(int)params.getHeight(), 
+								params.getBandCount());
+					}
+				}
+			}
+		}
+		return null;
+	}
+	
+	/**
+	 * Genera una instancia del buffer de solo lectura. Este buffer consta de una cache y unos apuntadores
+	 * a las p�ginas en disco. Cuando se accede a los datos se carga en memoria la p�gina pedida.
+	 *  
+	 * @param  file 
+	 *         File to read data
+	 */
+	public Buffer createReadOnlyBuffer(String file) {
+		BufferDataSource ds = null;
+		try {
+			ds = new BufferDataSourceImpl(file);
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		return new RasterReadOnlyBuffer(ds);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.BufferCacheManager#createMemoryBuffer(org.gvsig.raster.cache.buffer.BufferParam)
+	 */
+	public Buffer createMemoryBuffer(BufferParam params) {
+		return new RasterMemoryBuffer(params.getDataType(), 
+									(int)params.getWidth(), 
+									(int)params.getHeight(), 
+									params.getBandCount(), 
+									true);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.BufferCacheManager#createMemoryBuffer(int, int, int, int, boolean)
+	 */
+	public Buffer createMemoryBuffer(int dataType, int width, int height, int bandNr, boolean malloc) {
+		return new RasterMemoryBuffer(dataType, width, height, bandNr, malloc);
+	}
+	
+	/**
+	 * Creates a new instance of an interpolation object.
+	 * @param buf IRasterBuffer
+	 * @return IBufferInterpolation
+	 */
+	public BufferInterpolation createInterpolation(Buffer buf) {
+		return new BufferInterpolationImpl(buf);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.BufferCacheManager#createBufferParams(int, int, int, int)
+	 */
+	public BufferParam createBufferParams(int w, int h, int bandCount, int dataType) {
+		return new BufferParamImpl(w, h, bandCount, dataType);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.BufferCacheManager#createBufferParams(int, int)
+	 */
+	public BufferParam createBufferParams(int w, int h) {
+		return new BufferParamImpl(w, h);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.BufferCacheManager#createBufferParams(java.lang.String, int, int, int, int)
+	 */
+	public BufferParam createBufferParams(String file, int x, int y, int w, int h, int[] bands) throws IOException {
+		return new BufferParamImpl(file, x, y, w, h, bands);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.BufferCacheManager#createBufferParams(java.lang.String, int, int, int, int)
+	 */
+	public BufferParam createBufferParams(String file, int x, int y, int w, int h) throws IOException {
+		return new BufferParamImpl(file, x, y, w, h, null);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.BufferCacheManager#createBufferParams(java.lang.String[], int, int, int, int, int[])
+	 */
+	public BufferParam createBufferParams(String[] files, int x, int y, int w, int h, int[] bands) throws IOException {
+		return new BufferParamImpl(files, x, y, w, h, bands);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.BufferCacheManager#createNoData(java.lang.Number, java.lang.Number, java.lang.String, int)
+	 */
+	public BufferNoData createNoData(Number noData, Number nativeNoData, String fileName, int bandCount) {
+		return new DefaultNoData(noData, nativeNoData, fileName, bandCount);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.BufferCacheManager#createNoData(java.lang.Number, java.lang.Number, java.lang.String)
+	 */
+	public BufferNoData createNoData(Number noData, Number nativeNoData, String fileName) {
+		return new DefaultNoData(noData, nativeNoData, fileName);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.BufferCacheManager#createDefaultNoData(int, int)
+	 */
+	public BufferNoData createDefaultNoData(int bandCount, int dataType) {
+		switch (dataType) {
+		case Buffer.TYPE_BYTE:
+			return new DefaultNoData(new Byte(BufferNoData.defaultByteNoDataValue), new Byte(BufferNoData.defaultByteNoDataValue), null);
+		case Buffer.TYPE_SHORT:
+			return new DefaultNoData(new Short(BufferNoData.defaultShortNoDataValue), new Short(BufferNoData.defaultShortNoDataValue), null);
+		case Buffer.TYPE_INT:
+			return new DefaultNoData(new Integer(BufferNoData.defaultIntegerNoDataValue), new Integer(BufferNoData.defaultIntegerNoDataValue), null);
+		case Buffer.TYPE_FLOAT:
+			return new DefaultNoData(new Float(BufferNoData.defaultFloatNoDataValue), new Float(BufferNoData.defaultFloatNoDataValue), null);
+		case Buffer.TYPE_DOUBLE:
+			return new DefaultNoData(new Double(BufferNoData.defaultDoubleNoDataValue), new Double(BufferNoData.defaultDoubleNoDataValue), null);
+		}
+		return null;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.BufferCacheManager#createHistogram(int, double[], double[], int, int)
+	 */
+	public BufferHistogram createHistogram(int nBands, double[] min, double[] max, int dataType, int numberOfClasses) {
+		return new BufferHistogramImpl(nBands, min, max, dataType, numberOfClasses);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.BufferCacheManager#createHistogram(int, int, double[], double[])
+	 */
+	public BufferHistogram createHistogram(int nBands, int nClasses, double[] min, double[] max) {
+		return new BufferHistogramImpl(nBands, nClasses, min, max);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.BufferCacheManager#createTask(java.lang.Object)
+	 */
+	public TaskEventManager createTask(Object process) {
+		return new DefaultTaskEventManager(process);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.BufferCacheManager#getTask()
+	 */
+	public TaskEventManager getTask() {
+		return DefaultTaskEventManager.get();
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/BufferCacheManagerImpl.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/BufferStatsImpl.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/BufferStatsImpl.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/BufferStatsImpl.java	(revision 3222)
@@ -0,0 +1,352 @@
+package org.gvsig.raster.cache.buffer.impl;
+
+import java.util.ArrayList;
+
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferStats;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+
+/**
+ * This class is used to calculate basic statistics in a band.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class BufferStatsImpl implements BufferStats {
+	private ArrayList<Band>    bands              = null;
+	private Buffer             buffer             = null;
+	private int                percent            = 0;
+	private boolean            calculated         = false;
+	private boolean            noDataValueEnable  = false;
+	
+	/*
+	 * Working variables
+	 */
+	private boolean[]          initializedBand    = null;
+	private long[]             iValues            = null;
+	private long[]             accumMean          = null;
+	
+	/**
+	 * Set the buffer
+	 * @param buffer
+	 */
+	public BufferStatsImpl(Buffer buffer) {
+		bands = buffer.getBandList();
+		this.buffer = buffer;
+		noDataValueEnable = Buffer.noDataValueEnable;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.BufferStats#calculate()
+	 */
+	public void calculate() {		
+		iValues = new long[buffer.getBandCount()];
+		accumMean = new long[buffer.getBandCount()];
+		initializedBand = new boolean[buffer.getBandCount()];
+
+		for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) {
+			bands.get(iBand).setMax(Double.NEGATIVE_INFINITY);
+			bands.get(iBand).setMin(Double.POSITIVE_INFINITY);
+			bands.get(iBand).setSecondMax(Double.NEGATIVE_INFINITY);
+			bands.get(iBand).setSecondMin(Double.POSITIVE_INFINITY);
+			bands.get(iBand).setMaxRGB(0);
+			bands.get(iBand).setMinRGB(255);
+			bands.get(iBand).setSecondMaxRGB(0);
+			bands.get(iBand).setSecondMinRGB(255);
+			initializedBand[iBand] = false;
+		}
+
+		switch (buffer.getDataType()) {
+		case Buffer.TYPE_BYTE:
+			for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) {
+				Band band = bands.get(iBand);
+				for (int row = 0; row < buffer.getHeight(); row++) {
+					for (int col = 0; col < buffer.getWidth(); col++) {
+						double z = buffer.getElemByte(row, col, iBand);
+						if(!evaluateByteElement(band, iBand, z, ((byte) z) & 0xff))
+							continue;
+					}
+				}
+			}
+			break;
+		case Buffer.TYPE_SHORT:
+			for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) {
+				Band band = bands.get(iBand);
+				for (int row = 0; row < buffer.getHeight(); row++) {
+					for (int col = 0; col < buffer.getWidth(); col++) {
+						if(!evaluateElement(band, iBand, 
+								buffer.getElemShort(row, col, iBand)))
+							continue;
+					}
+				}
+			}
+			break;
+
+		case Buffer.TYPE_INT:
+			for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) {
+				Band band = bands.get(iBand);
+				for (int row = 0; row < buffer.getHeight(); row++) {
+					for (int col = 0; col < buffer.getWidth(); col++) {
+						if(!evaluateElement(band, iBand, 
+								buffer.getElemInt(row, col, iBand)))
+							continue;
+					}
+				}
+			}
+			break;
+		case Buffer.TYPE_FLOAT:
+			for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) {
+				Band band = bands.get(iBand);
+				for (int row = 0; row < buffer.getHeight(); row++) {
+					for (int col = 0; col < buffer.getWidth(); col++) {
+						if(!evaluateElement(band, iBand, 
+								buffer.getElemFloat(row, col, iBand)))
+							continue;
+					}
+				}
+			}
+			break;
+		case Buffer.TYPE_DOUBLE:
+			for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) {
+				Band band = bands.get(iBand);
+				for (int row = 0; row < buffer.getHeight(); row++) {
+					for (int col = 0; col < buffer.getWidth(); col++) {
+						if(!evaluateElement(band, iBand, 
+								buffer.getElemDouble(row, col, iBand)))
+							continue;
+					}
+				}
+			}
+			break;
+		}
+		
+		for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) {
+			if (iValues[iBand] > 0) {
+				bands.get(iBand).setMean(accumMean[iBand] / (double) iValues[iBand]);
+			}
+		}
+		
+		percent = 100;
+		calculated = true;
+	}
+	
+	/**
+	 * Reset the percentage progress
+	 */
+	public void resetPercent() {
+		percent = 0;
+	}
+
+	/**
+	 * Get the percentage progress
+	 * @return porcentaje de progreso
+	 */
+	public int getPercent() {
+		return percent;
+	}
+	
+	/**
+	 * Get the flag calculated. 
+	 * If calculated is true means the statistics have been calculated
+	 * @return
+	 */
+	public boolean isCalculated() {
+		return calculated;
+	}
+	
+	/**
+	 * Analyze one eight bits element to recalculate statistic values.
+	 * @param  band 
+	 *         Band
+	 * @param  iBand
+	 *         position of this band
+	 * @param  z
+	 *         Value to analyze
+	 * @param  rgb
+	 *         RGB value to analyze
+	 * @return
+	 */
+	private boolean evaluateByteElement(Band band, int iBand, double z, double rgb) {
+		if (noDataValueEnable && (z == buffer.getNoDataValue().getValue().doubleValue()))
+			return false;
+
+		if (Double.isNaN(z))
+			return false;
+		
+		accumMean[iBand] += rgb;
+		iValues[iBand] ++;
+
+		if (!initializedBand[iBand]) {
+			band.setSecondMin(band.getMin());
+			band.setSecondMax(band.getMax());
+			band.setMin(z);
+			band.setMax(z);
+			band.setSecondMinRGB(band.getMinRGB());
+			band.setSecondMaxRGB(band.getMaxRGB());
+			band.setMinRGB(rgb);
+			band.setMaxRGB(rgb);
+			initializedBand[iBand] = true;
+			return false;
+		}
+
+		if (z < band.getSecondMin()) {
+			if (z < band.getMin()) {
+				band.setSecondMin(band.getMin());
+				band.setMin(z);
+			} else {
+				if (z > band.getMin())
+					band.setSecondMin(z);
+			}
+		}
+
+		if (z > band.getSecondMax()) {
+			if (z > band.getMax()) {
+				band.setSecondMax(band.getMax());
+				band.setMax(z);
+			} else {
+				if (z < band.getMax())
+					band.setSecondMax(z);
+			}
+		}
+
+		if (rgb < band.getSecondMinRGB()) {
+			if (rgb < band.getMinRGB()) {
+				band.setSecondMinRGB(band.getMinRGB());
+				band.setMinRGB(rgb);
+			} else {
+				if (rgb > band.getMinRGB())
+					band.setSecondMinRGB(rgb);
+			}
+		}
+
+		if (rgb > band.getSecondMaxRGB()) {
+			if (rgb > band.getMaxRGB()) {
+				band.setSecondMaxRGB(band.getMaxRGB());
+				band.setMaxRGB(rgb);
+			} else {
+				if (rgb < band.getMaxRGB())
+					band.setSecondMaxRGB(rgb);
+			}
+		}
+		
+		return true;
+	}
+	
+	/**
+	 * Analyze one element to recalculate statistic values.
+	 * @param  band 
+	 *         Band
+	 * @param  iBand
+	 *         position of this band
+	 * @param  z
+	 *         Value to analyze
+	 * @return
+	 */
+	private boolean evaluateElement(Band band, int iBand, double z) {
+		if (noDataValueEnable && (z == buffer.getNoDataValue().getValue().doubleValue()))
+			return false;
+
+		if (Double.isNaN(z))
+			return false;
+
+		accumMean[iBand] += z;
+		iValues[iBand] ++;
+
+		if (!initializedBand[iBand]) {
+			band.setSecondMin(band.getMin());
+			band.setSecondMax(band.getMax());
+			band.setMin(z);
+			band.setMax(z);
+			initializedBand[iBand] = true;
+			return false;
+		}
+
+		if (z < band.getSecondMin()) {
+			if (z < band.getMin()) {
+				band.setSecondMin(band.getMin());
+				band.setMin(z);
+			} else {
+				if (z > band.getMin())
+					band.setSecondMin(z);
+			}
+		}
+
+		if (z > band.getSecondMax()) {
+			if (z > band.getMax()) {
+				band.setSecondMax(band.getMax());
+				band.setMax(z);
+			} else {
+				if (z < band.getMax())
+					band.setSecondMax(z);
+			}
+		}
+		
+		return true;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.dataset.Buffer#getLimits()
+	 */
+	public double[] getLimits() throws ProcessInterruptedException {
+		if(!isCalculated())
+			calculate();
+		
+		double max = Double.NEGATIVE_INFINITY;
+		double secondMax = max;
+		double min = Double.MAX_VALUE;
+		double secondMin = min;
+		
+		for (int i = 0; i < bands.size(); i++) {
+			if(bands.get(i).getMax() > max)
+				max = bands.get(i).getMax();
+			if(bands.get(i).getSecondMax() > secondMax)
+				secondMax = bands.get(i).getSecondMax();
+			if(bands.get(i).getMin() < min)
+				min = bands.get(i).getMin();
+			if(bands.get(i).getSecondMin() > secondMin)
+				secondMin = bands.get(i).getSecondMin();
+		}
+		
+		double[] values = new double[4];
+		values[0] = min;
+		values[1] = max;
+		values[2] = secondMin;
+		values[3] = secondMax;
+		return values;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.BufferStats#getAllBandsLimits()
+	 */
+	public double[][] getAllBandsLimits() throws ProcessInterruptedException {
+		if(!isCalculated())
+			calculate();
+		
+		double max[] = new double[bands.size()];
+		double min[] = new double[bands.size()];
+
+		for (int i = 0; i < bands.size(); i++) {
+			max[i] = Double.NEGATIVE_INFINITY;
+			min[i] = Double.MAX_VALUE;
+		}
+		
+		double[][] values = new double[2][bands.size()];
+
+		for (int i = 0; i < bands.size(); i++) {
+			values[0][i] = bands.get(i).getMin();
+			values[1][i] = bands.get(i).getMax();
+		}
+		return values;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.BufferStats#getBandList()
+	 */
+	public ArrayList<Band> getBandList() {
+		return bands;
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/BufferStatsImpl.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/datasource/FileNotOpenException.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/datasource/FileNotOpenException.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/datasource/FileNotOpenException.java	(revision 3222)
@@ -0,0 +1,14 @@
+package org.gvsig.raster.cache.buffer.impl.datasource;
+
+/**
+ * Excepci�n cuando se intenta acceder a un fichero que no ha sido abierto
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ *
+ */
+public class FileNotOpenException extends Exception{
+	private static final long serialVersionUID = -6732162228052967671L;
+
+	public FileNotOpenException(String msg){
+		super(msg);
+	}
+}
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/datasource/FileNotOpenException.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/datasource/IRasterDataSource.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/datasource/IRasterDataSource.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/datasource/IRasterDataSource.java	(revision 3222)
@@ -0,0 +1,117 @@
+package org.gvsig.raster.cache.buffer.impl.datasource;
+
+import java.awt.geom.Point2D;
+
+import org.gvsig.raster.cache.buffer.Buffer;
+
+/**
+ * Interfaz que deben implementar cualquier fuente de datos raster. Cualquier fuente
+ * de datos que alimente una cache de informaci�n debe implementar este interfaz para
+ * que pueda ser aprovechada por esta.
+ * 
+ * @version 27/08/2007
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ *
+ */
+public interface IRasterDataSource {
+			
+	/**
+	 * Obtiene el tipo de dato por banda
+	 * @return tipo de dato por banda
+	 */
+	public int[] getDataType();
+
+	/**
+	 * Obtiene el valor NoData asociado al raster.
+	 * @return
+	 */
+	public double getNoDataValue();
+		
+	/**
+	 * Obtiene el n�mero de bandas del raster
+	 * @return N�mero de bandas
+	 */
+	public int getBandCount();
+			
+	/**
+	 * Obtiene el n�mero de datasets con el extent completo del IRasterDataSource. El valor 
+	 * devuelto por esta llamada coincidir�a con el valor devuelto por getDatasetCount() de un
+	 * RasterDataset que lo compone.
+	 * @return integer.
+	 */
+	public int getDatasetCount();
+	
+	/**
+	 * Obtiene la altura del raster en p�xeles.
+	 * @return altura
+	 */
+	public double getHeight();
+
+	/**
+	 * Obtiene la anchura del raster en p�xeles.
+	 * @return anchura
+	 */
+	public double getWidth();
+			
+	/**
+	 * Obtiene una ventana de datos de la imagen a partir de coordenadas reales. 
+	 * No aplica supersampleo ni subsampleo sino que devuelve una matriz de igual tama�o a los
+	 * pixeles de disco. 
+	 * @param x Posici�n X superior izquierda
+	 * @param y Posici�n Y superior izquierda
+	 * @param w Ancho en coordenadas pixel
+	 * @param h Alto en coordenadas pixel
+	 * @param bandList
+	 * @return Buffer de datos
+	 */
+	public Buffer getWindowRaster(int x, int y, int w, int h) 
+		throws InvalidSetViewException, InterruptedException, DriverException;
+		
+	/**
+	 * Obtiene una ventana de datos de la imagen a partir de coordenadas reales. 
+	 * Aplica supersampleo o subsampleo en funci�n del tama�o del buffer
+	 * @param x Posici�n X superior izquierda en pixels
+	 * @param y Posici�n Y superior izquierda en pixels
+	 * @param w Ancho en pixels
+	 * @param h Alto en pixels
+	 * @param bufWidth ancho del buffer de datos
+	 * @param bufHeight alto del buffer de datos
+	 * @param bandList
+	 * @return Buffer de datos
+	 */
+	public Buffer getWindowRaster(int x, int y, int w, int h, int bufWidth, int bufHeight) 
+		throws InvalidSetViewException, InterruptedException, DriverException;
+		
+	/**
+	 * Obtiene el valor del raster en la coordenada que se le pasa.
+	 * El valor ser� Double, Int, Byte, etc. dependiendo del tipo de
+	 * raster.
+	 * @param x	coordenada X
+	 * @param y coordenada Y
+	 * @return
+	 */
+	public Object getData(int x, int y, int band)throws InvalidSetViewException, FileNotOpenException, DriverException;
+		
+	/**
+	 * Metodo que obtiene si un punto cae dentro de los l�mites de la extensi�n de la fuente de 
+	 * datos raster o fuera de ellos.
+	 * @param p Punto a calcular
+	 * @return true si est� dentro de los l�mites y false si est� fuera
+	 */
+	public boolean isInside(Point2D p); 
+	
+	/**
+	 * Obtiene en un array de String la lista de nombres de ficheros. 
+	 * @param i Columna para un CompositeDataset 
+	 * @param j Fila para un CompositeDataset
+	 * @return lista de nombres de los ficheros del GeoRasterMultiFile
+	 */
+	public String[] getNameDatasetStringList(int i, int j);
+		
+	/**
+	 * Calcula el tama�o en byte de los raster.
+	 * @return tama�o en bytes de todos los ficheros de la lista
+	 */
+	public long getFileSize();
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/datasource/IRasterDataSource.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/datasource/DriverException.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/datasource/DriverException.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/datasource/DriverException.java	(revision 3222)
@@ -0,0 +1,30 @@
+package org.gvsig.raster.cache.buffer.impl.datasource;
+
+/**
+ * Excepci�n lanzada por un driver de raster. Cada driver concreto tiene su propio
+ * tipo de excepciones GdalException, MrsSIDException, JNCSFileException ... 
+ * Estas son lanzadas hacia el nivel superior como una sola si no pueden ser gestionadas 
+ * en el nivel dataset.io.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ *
+ */
+public class DriverException extends Exception{
+	private static final long serialVersionUID = 7412405741078802490L;
+
+	/**
+	 * Constructor. Asigna el texto de la excepci�n
+	 * @param msg
+	 */
+	public DriverException(String msg){
+		super(msg);
+	}
+	
+	/**
+	 * Constructor. Asigna el texto de la excepci�n y la excepci�n generica.
+	 * @param msg
+	 */
+	public DriverException(String msg, Exception e){
+		super(msg, e);
+	}
+}
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/datasource/DriverException.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/datasource/InvalidSetViewException.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/datasource/InvalidSetViewException.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/datasource/InvalidSetViewException.java	(revision 3222)
@@ -0,0 +1,15 @@
+package org.gvsig.raster.cache.buffer.impl.datasource;
+
+/**
+ * Excepci�n se asigna una extensi�n a un fichero que no es correcta. Normalmente
+ * es porque nos hemos salido de la extensi�n.
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ *
+ */
+public class InvalidSetViewException extends Exception{
+	private static final long serialVersionUID = 337663732071639106L;
+
+	public InvalidSetViewException(String msg){
+		super(msg);
+	}
+}
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/datasource/InvalidSetViewException.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/datasource/IDataWriter.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/datasource/IDataWriter.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/datasource/IDataWriter.java	(revision 3222)
@@ -0,0 +1,77 @@
+package org.gvsig.raster.cache.buffer.impl.datasource;
+
+
+/**
+ * Este interfaz debe ser implementado por las clases que vayan a
+ * servir datos a los drivers de escritura.
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public interface IDataWriter {
+	/**
+	 * Para el tipo de datos ARGB (32 bits en un solo entero) obtiene un array que representa 
+	 * los datos le�dos. Este array se obtendr� de la fuente de datos
+	 * asociada al renderizador y sera de ancho sizeX y alto sizeY. Es el propio renderizador
+	 * el encargado de llevar la posici�n de la �ltima l�nea le�da para la siguiente petici�n
+	 * ofrecer datos a partir de donde se quedo.
+	 * @param sizeX Ancho del bloque de datos
+	 * @param sizeY Alto del bloque de datos
+	 * @return Array con los datos leidos
+	 */
+	public int[] readARGBData(int sizeX, int sizeY, int nBand);
+	
+	/**
+	 * Para el tipo de datos byte obtiene un array bidimensional donde la primera dimensi�n
+	 * son las bandas y la segunda los datos. Este array se obtendra de la fuente de datos
+	 * asociada al renderizador y sera de ancho sizeX y alto sizeY. Es el propio renderizador
+	 * el encargado de llevar la posici�n de la �ltima l�nea le�da para la siguiente petici�n
+	 * ofrecer datos a partir de donde se quedo.
+	 * @param sizeX Ancho del bloque de datos
+	 * @param sizeY Alto del bloque de datos
+	 * @return Array bidimensionar de numero de bandas por datos leidos
+	 */
+    public byte[][] readByteData(int sizeX, int sizeY);
+	/**
+	 * Para el tipo de datos short obtiene un array bidimensional donde la primera dimensi�n
+	 * son las bandas y la segunda los datos. Este array se obtendra de la fuente de datos
+	 * asociada al renderizador y sera de ancho sizeX y alto sizeY. Es el propio renderizador
+	 * el encargado de llevar la posici�n de la �ltima l�nea le�da para la siguiente petici�n
+	 * ofrecer datos a partir de donde se quedo.
+	 * @param sizeX Ancho del bloque de datos
+	 * @param sizeY Alto del bloque de datos
+	 * @return Array bidimensionar de numero de bandas por datos leidos
+	 */
+    public short[][] readShortData(int sizeX, int sizeY);
+	/**
+	 * Para el tipo de datos int obtiene un array bidimensional donde la primera dimensi�n
+	 * son las bandas y la segunda los datos. Este array se obtendra de la fuente de datos
+	 * asociada al renderizador y sera de ancho sizeX y alto sizeY. Es el propio renderizador
+	 * el encargado de llevar la posici�n de la �ltima l�nea le�da para la siguiente petici�n
+	 * ofrecer datos a partir de donde se quedo.
+	 * @param sizeX Ancho del bloque de datos
+	 * @param sizeY Alto del bloque de datos
+	 * @return Array bidimensionar de numero de bandas por datos leidos
+	 */
+    public int[][] readIntData(int sizeX, int sizeY);
+	/**
+	 * Para el tipo de datos float obtiene un array bidimensional donde la primera dimensi�n
+	 * son las bandas y la segunda los datos. Este array se obtendra de la fuente de datos
+	 * asociada al renderizador y sera de ancho sizeX y alto sizeY. Es el propio renderizador
+	 * el encargado de llevar la posici�n de la �ltima l�nea le�da para la siguiente petici�n
+	 * ofrecer datos a partir de donde se quedo.
+	 * @param sizeX Ancho del bloque de datos
+	 * @param sizeY Alto del bloque de datos
+	 * @return Array bidimensionar de numero de bandas por datos leidos
+	 */
+    public float[][] readFloatData(int sizeX, int sizeY);
+	/**
+	 * Para el tipo de datos double obtiene un array bidimensional donde la primera dimensi�n
+	 * son las bandas y la segunda los datos. Este array se obtendra de la fuente de datos
+	 * asociada al renderizador y sera de ancho sizeX y alto sizeY. Es el propio renderizador
+	 * el encargado de llevar la posici�n de la �ltima l�nea le�da para la siguiente petici�n
+	 * ofrecer datos a partir de donde se quedo.
+	 * @param sizeX Ancho del bloque de datos
+	 * @param sizeY Alto del bloque de datos
+	 * @return Array bidimensionar de numero de bandas por datos leidos
+	 */
+    public double[][] readDoubleData(int sizeX, int sizeY);
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/datasource/IDataWriter.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:executable
   + *

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/BufferParamImpl.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/BufferParamImpl.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/BufferParamImpl.java	(revision 3222)
@@ -0,0 +1,152 @@
+package org.gvsig.raster.cache.buffer.impl;
+
+import java.io.IOException;
+
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.BufferParam;
+import org.gvsig.raster.cache.buffer.impl.io.BufferDataSourceImpl;
+import org.gvsig.raster.cache.buffer.impl.io.BufferMultiDataSourceImpl;
+
+/**
+ * Buffer parameters. This class contains generic parameters. 
+ * Basic information to fill: x, y, w, h, datatype and bandcount. If
+ * the buffer is RasterReadOnlyBuffer is necessary a IBufferDataSource too.
+ * 02/11/2008
+ * @author Nacho Brodin nachobrodin@gmail.com
+ */
+public class BufferParamImpl extends PxTileImpl implements BufferParam {
+	private static final long serialVersionUID = 1L;
+	private int               accessType       = Buffer.READ_WRITE;
+	private int[]             bands            = null;
+
+	/**
+	 * Constructor
+	 * @param  w
+	 *         Width
+	 * @param  h
+	 *         Height
+	 */
+	public BufferParamImpl(int w, int h) {
+		super(0, 0, w, h);
+	}
+	
+	/**
+	 * Constructor
+	 * @param  file
+	 *         file name
+	 * @param  x
+	 *         X position
+	 * @param  y
+	 *         Y position
+	 * @param  w
+	 *         Width
+	 * @param  h
+	 *         Height
+	 * @param  bands
+	 *         bands to load in the buffer
+	 * @throws IOException 
+	 */
+	public BufferParamImpl(String file, int x, int y, int w, int h, int[] bands) throws IOException {
+		super(x, y, w, h);
+		PxTileImpl pxTile = new PxTileImpl(x, y, w, h);
+		BufferDataSourceImpl datasource = new BufferDataSourceImpl(file, pxTile);
+		setDataSource(datasource);
+		if(bands == null) {
+			int bandCount = getDataSource().getBandCount();
+			this.bands = new int[bandCount];
+			for (int i = 0; i < bandCount; i++) {
+				this.bands[i] = i;
+			}
+		} else
+			this.bands = bands;
+		setBandCount(this.bands.length);
+		accessType = Buffer.READ_ONLY;
+	}
+	
+	/**
+	 * Constructor for multifiles
+	 * @param  file
+	 *         file name
+	 * @param  x
+	 *         X position
+	 * @param  y
+	 *         Y position
+	 * @param  w
+	 *         Width in pixels
+	 * @param  h
+	 *         Height in pixels
+	 * @param  bands
+	 *         bands to load in the buffer. It can be null. In this case all bands will be used
+	 * @throws IOException 
+	 */
+	public BufferParamImpl(String[] file, int x, int y, int w, int h, int[] bands) throws IOException {
+		super(x, y, w, h);
+		PxTileImpl pxTile = new PxTileImpl(x, y, w, h);
+		BufferDataSource datasource = new BufferMultiDataSourceImpl(file, pxTile);
+		setDataSource(datasource);
+		
+		if(bands == null) {
+			int bandCount = getDataSource().getBandCount();
+			this.bands = new int[bandCount];
+			for (int i = 0; i < bandCount; i++) {
+				this.bands[i] = i;
+			}
+		} else
+			this.bands = bands;
+		setBandCount(this.bands.length);
+		accessType = Buffer.READ_ONLY;
+	}
+	
+	/**
+	 * Creates a parameter object for building a buffer. The buffer type is read-write.
+	 * This type could be changed after the creation of a {@link BufferParam} object.
+	 * @param  w
+	 *         Width
+	 * @param  h
+	 *         Height
+	 * @param  bandCount
+	 * 		   Number of bands
+	 * @param  dataType
+	 *         Type of data        
+	 */
+	public BufferParamImpl(int w, int h, int bandCount, int dataType) {
+		super(0, 0, w, h);
+		this.setBandCount(bandCount);
+		this.setDataType(dataType);
+		this.setAccessType(Buffer.READ_WRITE);
+	}
+	
+	/*
+	 * 
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.BufferParam#setAccessType(int)
+	 */
+	public void setAccessType(int accessType) {
+		this.accessType = accessType;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.BufferParam#getAccessType()
+	 */
+	public int getAccessType() {
+		return accessType;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.BufferParam#setFile(java.lang.String)
+	 */
+	public void setBandList(int[] bands) {
+		this.bands = bands;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.BufferParam#getFile()
+	 */
+	public int[] getBandList() {
+		return bands;
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/BufferParamImpl.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/histogram/HistogramClassImpl.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/histogram/HistogramClassImpl.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/histogram/HistogramClassImpl.java	(revision 3222)
@@ -0,0 +1,123 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.buffer.impl.histogram;
+
+import org.gvsig.raster.cache.buffer.histogram.HistogramClass;
+
+
+/**
+ * Clase que define un intervalo de datos. Es util para cosas como el calculo de histogramas
+ * con tipo de datos en coma flotante en el cual hay que dividir los intervalos en
+ * clases. Las clases se tendr�n en cuenta como un intervalo el cual el menor es cerrado y el 
+ * mayor abierto, es decir
+ * <PRE>
+ * En las clases:
+ * 0-1000
+ * 1000-2000
+ * los intervalos son 
+ * [0, 1000 [  de 0-999.9p
+ * [1000, 2000[ de 1000-1999.9p
+ * </PRE>
+ *  
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ *
+ */
+public class HistogramClassImpl implements HistogramClass {	
+	private double 	value = 0D;
+	private double 	min = 0D;
+	private double 	max = 0D;
+
+	/**
+	 * Constructor.
+	 * @param a Entero que representa al un valor de la clase
+	 * @param b Entero que representa al un valor de la clase
+	 */
+	public HistogramClassImpl(double a, double b){
+		this.max = (a >= b) ? a : b;
+		this.min = (a <= b) ? a : b;
+	}
+	
+	/**
+	 * Comprueba si el valor pasado por par�metro est� dentro del intervalo
+	 * @param value Valor a comprobar
+	 * @return true si est� dentro del intervalo y false si no lo est�
+	 */
+	public boolean isIn(double value){
+		return (value >= min && value < max);
+	}
+	
+	/**
+	 * Obtiene el valor m�ximo de la clase
+	 * @return Entero que representa al valor m�ximo de la clase
+	 */
+	public double getMax() {
+		return max;
+	}
+	
+	/**
+	 * Asigna el valor m�ximo de la clase
+	 * @param max Entero que representa al valor m�ximo de la clase
+	 */
+	public void setMax(double max) {
+		this.max = max;
+	}
+	
+	/**
+	 * Obtiene el valor m�nimo de la clase
+	 * @return Entero que representa al valor m�nimo de la clase
+	 */
+	public double getMin() {
+		return min;
+	}
+	
+	/**
+	 * ASigna el valor m�nimo de la clase
+	 * @param min Entero que representa al valor m�nimo de la clase
+	 */
+	public void setMin(double min) {
+		this.min = min;
+	}
+
+	/**
+	 * Obtiene el valor de la clase
+	 * @return double con el valor
+	 */
+	public double getValue() {
+		return value;
+	}
+
+	/**
+	 * Asigna el valor de la clase
+	 * @param double con el valor
+	 */
+	public void setValue(double value) {
+		this.value = value;
+	}	
+	
+	/**
+	 * Incrementa en n el valor especificado
+	 * @param double n
+	 */
+	public void increment(double n) {
+		this.value += n;
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/histogram/HistogramClassImpl.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/histogram/BufferHistogramComputer.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/histogram/BufferHistogramComputer.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/histogram/BufferHistogramComputer.java	(revision 3222)
@@ -0,0 +1,151 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.buffer.impl.histogram;
+
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.HistogramException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.histogram.BufferHistogram;
+import org.gvsig.raster.cache.buffer.histogram.HistogramComputer;
+
+
+/**
+ * This class computes the histogram for a <code>Buffer</code>
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class BufferHistogramComputer implements HistogramComputer {
+	private BufferHistogram             histogram            = null;
+	private Buffer                      buffer               = null;
+	protected int			            progressHistogram    = 0;
+	private double[]                    limits               = null;
+	private boolean                     refresh              = false;
+	
+	/**
+	 * Constructor
+	 * @param dataset
+	 */
+	public BufferHistogramComputer(Buffer buffer) {
+		this.buffer = buffer;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.fmap.dal.coverage.store.props.HistogramComputer#getBufferHistogram()
+	 */
+	public BufferHistogram getBufferHistogram(int numberOfClasses) throws ProcessInterruptedException, HistogramException {
+		if(histogram == null || refresh) {
+			//RasterTask task = RasterTaskQueue.get(Thread.currentThread().getId() + "");
+			progressHistogram = 0;
+			double[][] limits = buffer.getStatistics().getAllBandsLimits();
+
+			BufferHistogramImpl hist = new BufferHistogramImpl(buffer.getBandCount(), limits[0], limits[1], buffer.getDataType(), numberOfClasses);
+
+			for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) {
+				for (int row = 0; row < buffer.getHeight(); row++) {
+					switch(buffer.getDataType()) {
+					case Buffer.TYPE_BYTE:
+						for (int col = 0; col < buffer.getWidth(); col++) 
+							hist.incrementPxValue(iBand, (double)(buffer.getElemByte(row, col, iBand)));
+						break;
+					case Buffer.TYPE_SHORT:
+						for (int col = 0; col < buffer.getWidth(); col++) 
+							hist.incrementPxValue(iBand, (double)(buffer.getElemShort(row, col, iBand)));
+						break;
+					case Buffer.TYPE_INT:
+						for (int col = 0; col < buffer.getWidth(); col++) 
+							hist.incrementPxValue(iBand, (double)(buffer.getElemInt(row, col, iBand)));
+						break;
+					case Buffer.TYPE_FLOAT:
+						for (int col = 0; col < buffer.getWidth(); col++) 
+							hist.incrementPxValue(iBand, (double)buffer.getElemFloat(row, col, iBand));
+						break;
+					case Buffer.TYPE_DOUBLE:
+						for (int col = 0; col < buffer.getWidth(); col++) 
+							hist.incrementPxValue(iBand, buffer.getElemDouble(row, col, iBand));
+						break;
+					}
+
+					/*if (task.getEvent() != null)
+						task.manageEvent(task.getEvent());*/
+
+					progressHistogram = ((iBand * buffer.getHeight() + row) * 100) /(buffer.getHeight() * buffer.getBandCount());
+				}
+			}
+			progressHistogram = 100;
+			histogram = hist;
+		}
+		return histogram;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.fmap.dal.coverage.store.props.HistogramComputer#resetPercent()
+	 */
+	public void resetPercent() {
+		progressHistogram = 0;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.fmap.dal.coverage.store.props.HistogramComputer#getPercent()
+	 */
+	public int getPercent() {
+		return progressHistogram;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.fmap.dal.coverage.store.props.HistogramComputer#getMinimum()
+	 */
+	public double getMinimum() {
+		if(limits == null)
+			try {
+				limits = buffer.getStatistics().getLimits();
+			} catch (ProcessInterruptedException e) {
+				return 0;
+			}
+		return limits[0];
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.fmap.dal.coverage.store.props.HistogramComputer#getMaximum()
+	 */
+	public double getMaximum() {
+		if(limits == null)
+			try {
+				limits = buffer.getStatistics().getLimits();
+			} catch (ProcessInterruptedException e) {
+				return 0;
+			}
+		return limits[1];
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.fmap.dal.coverage.store.props.HistogramComputer#refreshHistogram()
+	 */
+	public void refreshHistogram() {
+		refresh = true;
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/histogram/BufferHistogramComputer.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/histogram/BufferHistogramImpl.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/histogram/BufferHistogramImpl.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/histogram/BufferHistogramImpl.java	(revision 3222)
@@ -0,0 +1,622 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.buffer.impl.histogram;
+
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferNoData;
+import org.gvsig.raster.cache.buffer.histogram.BufferHistogram;
+import org.gvsig.raster.cache.buffer.histogram.HistogramClass;
+import org.slf4j.LoggerFactory;
+/**
+ * Representa un histograma.
+ * 
+ * @version 27/03/2007
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class BufferHistogramImpl implements BufferHistogram {
+	/**
+	 * Variable que representa el histograma. La primera dimensi�n es el n�mero de 
+	 * bandas y la segunda un array de clases. En el caso b�sico de un RGB una clase tendr� el
+	 * valor m�nimo igual al m�ximo.
+	 */
+	private HistogramClass[][] histogram   = null;
+
+	private long[][]           table       = null;
+	private double[]           min         = null;
+	private double[]           max         = null;
+	private BufferNoData       noDataValue = null;
+	private int                dataType    = Buffer.TYPE_UNDEFINED;
+	
+	private int                nClasses    = 0;
+
+	/**
+	 * Constructor
+	 * @param nBands N�mero de bandas
+	 * @param nClasses N�mero de clases en que hacemos la divisi�n
+	 * @param min Valor m�nimo del histograma
+	 * @param max Valor m�ximo del histograma
+	 */
+	public BufferHistogramImpl(int nBands, int nClasses, double[] min, double[] max) {
+		if ((nBands != min.length) || (nBands != max.length)) {
+			System.out.println("No tiene las mismas bandas");
+		}
+		constructorHistogramImpl(min, max, nClasses);
+	}
+	
+	private void constructorHistogramImpl(double[] min, double[] max, int nClasses) {
+		table = new long[min.length][nClasses];
+		for (int i = 0; i < table.length; i++)
+			for (int j = 0; j < table[0].length; j++)
+				table[i][j] = 0;
+		this.min = (double[]) min.clone();
+		this.max = (double[]) max.clone();
+
+		this.nClasses = getNumValues();
+	}
+
+	/**
+	 * Constructor
+	 * @param nBands N�mero de bandas
+	 * @param nClasses N�mero de clases en que hacemos la divisi�n
+	 * @param min Valor m�nimo del histograma
+	 * @param max Valor m�ximo del histograma
+	 */
+	public BufferHistogramImpl(int nBands, double[] min, double[] max, int dataType, int numberOfClasses) {
+		//int numberClasses;
+		this.dataType = dataType;
+		this.min = (double[]) min.clone();
+		this.max = (double[]) max.clone();
+		if (dataType == Buffer.TYPE_BYTE) {
+			//numberClasses = RasterLibrary.defaultNumberOfColors;
+			boolean unsigned = false;
+			for (int i = 0; i < this.min.length; i++)
+				if (this.min[i] < 0)
+					unsigned = true;
+			for (int i = 0; i < this.min.length; i++) {
+				if (unsigned) {
+					this.min[i] = -128;
+					this.max[i] = 127;
+				} else {
+					this.min[i] = 0;
+					this.max[i] = 255;
+				}
+			}
+		}/* else {
+			numberClasses = RasterLibrary.defaultNumberOfClasses;
+		}*/
+		
+		constructorHistogramImpl(this.min, this.max, numberOfClasses);
+	}
+	
+	/**
+	 * Realiza la uni�n entre el histograma actual y el pasado 
+	 * por par�metro.
+	 * @param hist
+	 */
+	public boolean union(BufferHistogram hist) {
+		long[][] auxTable = hist.getTable();
+
+		if (auxTable.length != table.length)
+			return false;
+
+		if (auxTable.length == 0)
+			return true;
+
+		if (auxTable[0].length != table[0].length)
+			return false;
+
+		for (int i = 0; i < table.length; i++)
+			for (int j = 0; j < table[i].length; j++)
+				table[i][j] += auxTable[i][j];
+
+		return true;
+	}
+
+	/**
+	 * Asigna la tabla
+	 * @param t
+	 */
+	public void setTable(long[][] t) {
+		table = new long[t.length][t[0].length];
+		for (int i = 0; i < table.length; i++)
+			for (int j = 0; j < table[0].length; j++)
+				table[i][j] = t[i][j];
+		
+		this.nClasses = getNumValues();
+	}
+	
+	/**
+	 * Devuelve el minimo valor del histograma
+	 * @return
+	 */
+	public double getMin(int band) {
+		return min[band];
+	}
+
+	/**
+	 * Devuelve el maximo valor del histograma
+	 * @return
+	 */
+	public double getMax(int band) {
+		return max[band];
+	}
+
+	/**
+	 * Devuelve los minimos valores del histograma
+	 * @return
+	 */
+	public double[] getMinims() {
+		return min;
+	}
+
+	/**
+	 * Devuelve los maximos valores del histograma
+	 * @return
+	 */
+	public double[] getMaxims() {
+		return max;
+	}
+
+	/**
+	 * Devuelve si un histograma esta en un rango RGB aceptable
+	 * @return
+	 */
+	public boolean isInRangeRGB() {
+		if (dataType == Buffer.TYPE_BYTE)
+			return true;
+		return true;
+	}
+
+	/**
+	 * Obtiene el histograma sin modificar
+	 * @return array bidimensional donde el primer elemento es el valor del pixel
+	 * o rango y el segundo el n�mero de elementos que aparecen.
+	 */
+	public HistogramClass[][] getHistogram() {
+		if (nClasses == 0)
+			return null;
+		
+		histogram = new HistogramClass[table.length][nClasses];
+				
+		for (int i = 0; i < table.length; i++) {
+			for (int j = 0; j < table[i].length; j++) {
+				HistogramClass hc = new HistogramClassImpl(	min[i] + ((j * (max[i] - min[i])) / (nClasses - 1)), 
+														min[i] + (((j + 1) * (max[i] - min[i])) / (nClasses - 1)));
+				hc.setValue(table[i][j]);
+				histogram[i][j] = hc;
+			}
+		}
+		return histogram;
+	}
+	
+	/**
+	 * Obtiene el n�mero de bandas del histograma 
+	 * @return entero que representa el n�mero de bandas 
+	 */
+	public int getNumBands() {
+		if (table != null)
+			return table.length;
+		return 0;
+	}
+	
+	/**
+	 * Obtiene el tipo de datos del histograma original
+	 * @return
+	 */
+	public int getDataType() {
+		return dataType;
+	}
+	
+	/**
+	 * Obtiene la longitud (n�mero de valores) de una banda determinada
+	 * @param band Banda o obtener la longitud
+	 * @return entero con la longitud de la banda
+	 * rangos de valores y DataclassList.
+	 */
+	public int getBandLenght(int band) {
+		if (table != null)
+			return table[band].length;
+		return 0;
+	}
+	
+	/**
+	 * Obtiene el n�mero de valores o clases del histograma
+	 * @return entero que representa el n�mero de valores o clases del histograma
+	 */
+	public int getNumValues() {
+		if (table == null)
+			return 0;
+
+		if (table.length == 0)
+			return 0;
+		
+		return table[0].length;
+	}
+	
+	/**
+	 * Asigna un histograma
+	 * @param hist histograma asignado
+	 */
+	public void setHistogram(HistogramClass[][] hist){
+		histogram = hist;
+	}
+		
+	/**
+	 * Asigna un valor para una posici�n del histograma
+	 * @param band Valor del pixel o clase a asignar
+	 * @param px Valor del pixel
+	 * @param value Valor a asignar
+	 */
+	public void setHistogramValue(int band, double px, long value) {
+		int pos = (int) (((nClasses - 1) * (px - min[band])) / (max[band] - min[band]));
+		if (pos < 0)
+			pos = 0;
+		if (pos >= nClasses)
+			pos = nClasses - 1;
+		table[band][pos] = value;
+	}
+	
+	/**
+	 * Asigna un valor para una posici�n del histograma segun la posicion en las
+	 * clases
+	 * @param band Valor del pixel o clase a asignar
+	 * @param pos Posicion dentro de la clase. Ejemplo 0..63
+	 * @param value Valor a asignar
+	 */
+	public void setHistogramValueByPos(int band, int pos, long value) {
+		if (pos < 0)
+			pos = 0;
+		if (pos >= nClasses)
+			pos = nClasses - 1;
+		table[band][pos] = value;
+	}
+
+	/**
+	 * Obtiene un valor del histograma
+	 * @param band N�mero de banda del valor a recuperar
+	 * @param px Pixel o valor de la clase del valor a recuperar
+	 * @return valor
+	 */
+	public double getHistogramValue(int band, double px) {
+		if (histogram == null)
+			getHistogram();
+
+		for (int i = 0; i < histogram[band].length; i++)
+			if (((HistogramClass) histogram[band][i]).isIn(px))
+				return ((HistogramClass) histogram[band][i]).getValue();
+
+		return 0;
+	}
+	
+	/**
+	 * Obtiene un valor del histograma segun la posicion dentro de las clases
+	 * @param band N�mero de banda del valor a recuperar
+	 * @param px Pixel o valor de la clase del valor a recuperar
+	 * @return valor
+	 */
+	public double getHistogramValueByPos(int band, int pos) {
+		if (pos < 0)
+			pos = 0;
+
+		if (pos >= nClasses)
+			pos = nClasses - 1;
+
+		return table[band][pos];
+	}
+	
+	/**
+	 * Incrementa un valor de una posici�n del histograma
+	 * @param band N�mero de banda
+	 * @param px Pixel o valor de la clase
+	 */
+	public void incrementPxValue(int band, double px) {
+		if (Double.isNaN(px))
+			return;
+
+		if (noDataValue != null && noDataValue.isDefined()) {
+			switch (dataType) {
+			case Buffer.TYPE_BYTE:
+				if(((byte)px) == noDataValue.getValue().byteValue())
+						return;
+				break;
+			case Buffer.TYPE_SHORT:
+				if(((short)px) == noDataValue.getValue().shortValue())
+					return;
+				break;
+			case Buffer.TYPE_INT:
+				if(((int)px) == noDataValue.getValue().intValue())
+					return;
+				break;
+			case Buffer.TYPE_FLOAT:
+				if(((float)px) == noDataValue.getValue().floatValue())
+					return;
+				break;
+			case Buffer.TYPE_DOUBLE:
+				if(((double)px) == noDataValue.getValue().doubleValue())
+					return;
+				break;
+			}
+		}
+			
+
+		int pos = (int) (((nClasses - 1) * (px - min[band])) / (max[band] - min[band]));
+
+		if (pos < 0)
+			pos = 0;
+
+		if (pos >= nClasses)
+			pos = nClasses - 1;
+
+		table[band][pos]++;
+	}
+
+	/**
+	 * Calculo de estad�sticas a partir de un histograma. El resultado de la funci�n es un array
+	 * bidimensional donde el primer �ndice inndica la estadistica y el segundo el n�mero de banda.
+	 * 
+	 * <UL>
+	 * <LI>m�nimo</LI>
+	 * <LI>m�ximo</LI>
+	 * <LI>media</LI>
+	 * <LI>mediana</LI>
+	 * <LI>N�mero de pixels</LI>
+	 * </UL>
+	 * @param histogram
+	 * @param bandas solicitadas. Cada elemento del vector representa una banda. Si est� a true se calcula la 
+	 * estadistica para esa banda y si est� a false no se calcular�.
+	 * @return
+	 */
+	public double[][] getBasicStats(boolean[] bands) {
+		if (histogram == null)
+			return null;
+		return getBasicStats(0, histogram[0].length - 1, bands);
+	}
+
+	/**
+	 * Calculo de estad�sticas a partir de un histograma. El resultado de la funci�n es un array
+	 * bidimensional donde el primer �ndice inndica la estadistica y el segundo el n�mero de banda.
+	 * 
+	 * <UL>
+	 * <LI>m�nimo</LI>
+	 * <LI>m�ximo</LI>
+	 * <LI>media</LI>
+	 * <LI>mediana</LI>
+	 * <LI>N�mero de pixels</LI>
+	 * </UL>
+	 * @param histogram
+	 * @param beginPos Posici�n de inicio del histograma para contabilizar estadisticas
+	 * @param endPos Posici�n de fin del histograma para contabilizar estadisticas
+	 * @param bandas solicitadas. Cada elemento del vector representa una banda. Si est� a true se calcula la 
+	 * estadistica para esa banda y si est� a false no se calcular�.
+	 * @return
+	 */
+	public double[][] getBasicStats(double beginPos2, double endPos2, boolean[] bands) {
+		if (histogram == null)
+			getHistogram();
+		
+		int beginPos = (int) ((beginPos2 * (nClasses - 1)) / 100.0);
+		int endPos = (int) ((endPos2 * (nClasses - 1)) / 100.0);
+
+		// Contamos el n�mero de bandas para las cuales se calcula la estad�stica
+		int bandCount = 0;
+		for (int iBand = 0; iBand < bands.length; iBand++)
+			if (bands[iBand])
+				bandCount++;
+
+		double[][] res = new double[5][];
+
+		double[] min = new double[bandCount];// M�nimo
+		double[] max = new double[bandCount];// M�ximo
+		for (int iBand = 0; iBand < bandCount; iBand++) {
+			max[iBand] = Double.NEGATIVE_INFINITY;
+			min[iBand] = Double.POSITIVE_INFINITY;
+		}
+		double[] average = new double[bandCount]; // Valor de pixel medio (Media)
+		double[] middle = new double[bandCount]; // Mediana
+		double[] nPixelsBand = new double[bandCount];// N�mero de pixels por banda
+
+		int showBandCounter = 0; // Contador de bandas de las que hay calcular la
+															// estadistica
+		for (int iBand = 0; iBand < histogram.length; iBand++) {
+			if (bands[iBand]) {
+				for (int i = beginPos; i <= endPos; i++) {
+					// Calculo del m�nimo
+					if (histogram[iBand][i].getValue() != 0 && histogram[iBand][i].getMin() < min[showBandCounter])
+						min[showBandCounter] = histogram[iBand][i].getMin();
+
+					// Calculo del m�ximo
+					if (histogram[iBand][i].getValue() != 0 && histogram[iBand][i].getMax() > max[showBandCounter])
+						max[showBandCounter] = histogram[iBand][i].getMin();
+
+					// Calculo del n�mero de pixeles
+					nPixelsBand[showBandCounter] += histogram[iBand][i].getValue();
+
+					average[showBandCounter] += histogram[iBand][i].getValue() * ((histogram[iBand][i].getMax() + histogram[iBand][i].getMin())/2);
+				}
+				// Calculo de la media
+				try {
+					average[showBandCounter] /= nPixelsBand[showBandCounter];
+				} catch (ArithmeticException exc) {
+					average[showBandCounter] = 0;
+				}
+
+				// Calculo de mediana
+				double stopPos = nPixelsBand[showBandCounter] / 2;
+				int aux = 0;
+				int i = beginPos;
+				for (i = beginPos; aux <= stopPos; i++) {
+					if (i >= histogram[iBand].length)
+						break;
+					try {
+						aux += histogram[iBand][i].getValue();
+					} catch (ArrayIndexOutOfBoundsException e) {
+						LoggerFactory.getLogger(getClass().getName()).debug("Acceso a un valor de histogram (Banda: " + iBand + " Posici�n: " + i + ") fuera de l�mites. (NBandas: " + histogram.length + " Valores:" + histogram[iBand].length + ")", e);
+					}
+				}
+				middle[showBandCounter] = (histogram[iBand][i - 1].getMax() + histogram[iBand][i - 1].getMin()) / 2;
+
+				showBandCounter++;
+			}
+		}
+	 
+		res[0] = min;
+		res[1] = max;
+		res[2] = average;
+		res[3] = middle;
+		res[4] = nPixelsBand;
+		return res;
+	}
+	
+	/**
+	 * Obtiene la tabla de valores
+	 * @return
+	 */
+	public long[][] getTable() {
+		return table;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.fmap.dal.coverage.datastruct.BufferHistogram#addTable(long[][])
+	 */
+	public void addTable(long[][] table) {
+		if(this.table == null) {
+			this.table = table;
+			return;
+		}
+		long[][] newTable = new long[this.table.length + table.length][];
+		for (int i = 0; i < this.table.length; i++) {
+			newTable[i] = this.table[i];
+		}
+		for (int i = this.table.length; i < (this.table.length + table.length); i++) {
+			newTable[i] = table[i];
+		}
+		table = newTable;
+	}
+	
+	/**
+	 * Obtiene la tabla de valores normalizada. Divide todos los elementos por el n�mero de
+	 * pixeles total.
+	 * @return tabla de valores normalizada
+	 */
+	public static double[][] convertToNormalizeHistogram(long[][] tableToConvert) {
+		long[] nValues = new long[tableToConvert.length];
+		for (int i = 0; i < tableToConvert.length; i++)
+			for (int j = 0; j < tableToConvert[i].length; j++)
+				nValues[i] += tableToConvert[i][j];
+		
+		double[][] res = new double[tableToConvert.length][tableToConvert[0].length];
+		for (int i = 0; i < tableToConvert.length; i++)
+			for (int j = 0; j < tableToConvert[i].length; j++) 
+				res[i][j] = (double)((double)tableToConvert[i][j] / (double)nValues[i]);
+
+		return res;
+	}
+	
+	/**
+	 * Obtiene la tabla de valores normalizada y acumulada. Divide todos los elementos por el n�mero de
+	 * pixeles total.
+	 * @return tabla de valores normalizada
+	 */
+	public static double[][] convertTableToNormalizeAccumulate(long[][] tableToConvert) {
+		double[][] res = convertToNormalizeHistogram(tableToConvert);
+		for (int i = 0; i < tableToConvert.length; i++)
+			for (int j = 0; j < tableToConvert[i].length; j++)
+				if(j > 0)
+					res[i][j] += res[i][j - 1];
+
+		return res;
+	}
+	
+	/**
+	 * Obtiene el histograma de la imagen negativa.
+	 * @return long[][]
+	 */
+	public long[][] getNegativeTable() {
+		long[][] tableNeg = new long[table.length][table[0].length];
+		for (int i = 0; i < tableNeg.length; i++) 
+			for (int j = 0; j < tableNeg[i].length; j++) 
+				tableNeg[i][table[i].length - j - 1] = table[i][j];
+		return tableNeg;
+	}
+
+	/**
+	 * Convierte un histograma al rango de valores de RGB, en pocas palabras
+	 * aplica una operacion 0xff a cada pixel para quitar los numeros negativos
+	 * y desplazarlos a su rango visual.
+	 * @param histogram
+	 */
+	public static BufferHistogram convertHistogramToRGB(BufferHistogram histogram) {
+		if (histogram == null)
+			return null;
+
+		if (histogram.getDataType() != Buffer.TYPE_BYTE)
+			return histogram;
+
+		double min = histogram.getMin(0);
+		double max = histogram.getMax(0);
+
+		long table2[][] = histogram.getTable();
+
+		long newTable[][] = new long[table2.length][table2[0].length];
+
+		// Ponemos a cero todos los valores
+		for (int i = 0; i < table2.length; i++)
+			for (int j = 0; j < table2[i].length; j++)
+				newTable[i][j] = 0;
+
+		// Sumamos en la posicion calculada nueva el valor correspondiente
+		for (int i = 0; i < table2.length; i++) {
+			for (int j = 0; j < table2[i].length; j++) {
+				double val = ((j * (max - min)) / 255) + min;
+				int pos = ((int) val) & 0xff;
+				if (pos < 0)
+					pos = 0;
+				if (pos >= newTable[i].length)
+					pos = newTable[i].length - 1;
+
+				newTable[i][pos] += table2[i][j];
+			}
+		}
+
+		double mins[] = new double[histogram.getNumBands()];
+		double maxs[] = new double[histogram.getNumBands()];
+		
+		for (int i = 0; i < mins.length; i++) {
+			mins[i] = 0;
+			maxs[i] = 255;
+		}
+
+		BufferHistogramImpl histogramNew = new BufferHistogramImpl(histogram.getNumBands(), mins, maxs, Buffer.TYPE_BYTE, 256);
+
+		histogramNew.setTable(newTable);
+
+		return histogramNew;
+	}
+
+	/**
+	 * @param noDataValue the noDataValue to set
+	 */
+	public void setNoDataValue(BufferNoData noDataValue) {
+		this.noDataValue = noDataValue;
+	}
+}
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/histogram/BufferHistogramImpl.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/BufferServices.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/BufferServices.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/BufferServices.java	(revision 3222)
@@ -0,0 +1,105 @@
+package org.gvsig.raster.cache.buffer.impl;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.gvsig.raster.cache.buffer.impl.datasource.IRasterDataSource;
+
+
+/**
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class BufferServices {
+	
+	/**
+	 * Dadas unas coordenadas pixel y un n�mero de bandas, esta funci�n comprueba si 
+	 * el tama�o de ventana que va a generarse supera el tama�o de la cach� 
+	 * @param coords Coordenadas pixel del raster
+	 * @param bands N�mero de bandas
+	 * @param ds
+	 * @return true si la ventana supera el tama�o de la cach� o false si no lo supera.
+	 */
+	public static boolean isBufferTooBig(double[] coords, double resolution, int bands) {
+		double wPx = (coords[0] - coords[2]) / resolution;
+		double hPx = (coords[1] - coords[3]) / resolution;
+		return isBufferTooBig(new double[]{0, 0, wPx, hPx}, bands);
+	} 
+	
+	/**
+	 * Dadas unas coordenadas pixel y un n�mero de bandas, esta funci�n comprueba si 
+	 * el tama�o de ventana que va a generarse supera el tama�o de la cach� 
+	 * @param coords Coordenadas pixel del raster
+	 * @param bands N�mero de bandas
+	 * @param ds
+	 * @return true si la ventana supera el tama�o de la cach� o false si no lo supera.
+	 */
+	public static boolean isBufferTooBig(double[] coords, int bands) {		
+		int w = (int)Math.abs(coords[2] - coords[0]);
+		int h = (int)Math.abs(coords[3] - coords[1]);
+
+		long windowSize = w * h * bands; 
+		return (windowSize > (BufferCacheManagerImpl.cacheSize * 1048576));
+	} 
+	
+	/**
+	 * Devuelve true si el tama�o del dataset es menor que el de la cach� y false 
+	 * si no lo es.
+	 * @param datasource Fuente de datos
+	 * @return true si podemos cargar en memoria el raster
+	 */
+	public static boolean loadInMemory(IRasterDataSource datasource) {
+		return (datasource.getFileSize() < (BufferCacheManagerImpl.cacheSize * 1048576));
+	}
+	
+	/**
+	 * Copia de ficheros
+	 * @param pathOrig Ruta de origen
+	 * @param pathDst Ruta de destino.
+	 */
+	public static void copyFile(String pathOrig, String pathDst) throws FileNotFoundException, IOException {
+		InputStream in;
+		OutputStream out;
+
+		if (pathOrig == null || pathDst == null) {
+			System.err.println("Error en path");
+			return;
+		}
+
+		File orig = new File(pathOrig);
+		if (!orig.exists() || !orig.isFile() || !orig.canRead()) {
+			System.err.println("Error copying the file:" + pathOrig + " <Source Exists:" + orig.exists() + ", Source is file:" + orig.isFile() + ", Source can be read:" + orig.canRead() + ">");
+			return;
+		}
+
+		File dest = new File(pathDst);
+		String file = new File(pathOrig).getName();
+		if (dest.isDirectory())
+			pathDst += file;
+		
+		dest = new File(pathDst);
+		if(!dest.exists())
+			dest.createNewFile();
+
+		in = new FileInputStream(pathOrig);
+		out = new FileOutputStream(pathDst);
+
+		byte[] buf = new byte[1024];
+		int len;
+
+		while ((len = in.read(buf)) > 0)
+			out.write(buf, 0, len);
+
+		in.close();
+		out.close();
+	}
+
+	public static String getTemporalPath() {
+		return System.getProperty("java.io.tmpdir");
+	}
+
+}
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/BufferServices.java
___________________________________________________________________
Added: svn:executable
   + *
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/task/DefaultTask.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/task/DefaultTask.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/task/DefaultTask.java	(revision 3222)
@@ -0,0 +1,62 @@
+package org.gvsig.raster.cache.buffer.impl.task;
+
+import java.util.EventObject;
+
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.task.CancelEvent;
+/**
+ * Clase que deben contener los procesos de raster. Un proceso debe registrarse
+ * al arrancar y eliminarse al terminar o ser cancelado. El proceso debe ser
+ * el encargado de realizar estas acciones.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class DefaultTask {
+	public EventObject activeEvent = null;
+	public Object      process     = null;
+	private String     idThread    = "";
+
+	/**
+	 * Asigna la clase que contiene el proceso.
+	 * @param process
+	 */
+	public DefaultTask(Object process) {
+		idThread = Thread.currentThread().getId() + "";
+		this.process = process;
+	}
+	/**
+	 * Asigna el evento
+	 * @param ev EventObject
+	 */
+	public void setEvent(EventObject ev) {
+		activeEvent = ev;
+	}
+	
+	/**
+	 * Obtiene el evento
+	 * @return EventObject
+	 */
+	public EventObject getEvent() {
+		return activeEvent;
+	}
+	
+	/**
+	 * Obtiene el identificador �nico del proceso. 
+	 * @return Identificador del proceso
+	 */
+	public String getID() {
+		return idThread;
+	}
+	
+	/**
+	 * Gesti�n de las se�ales. Este m�todo define las acciones por defecto para
+	 * cada se�al. No es necesario utilizar estas. Se puede en cada caso, hacer un m�todo
+	 * manageEvent en el que se gestione las acciones concretas de una se�al.
+	 * 
+	 * @param ev Evento a gestionar
+	 */
+	public void manageEvent(EventObject ev) throws ProcessInterruptedException {
+		if (ev instanceof CancelEvent)
+			throw new ProcessInterruptedException("Proceso cancelado por se�al del usuario.");
+	}
+}
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/task/DefaultTask.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/task/DefaultRasterTaskQueue.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/task/DefaultRasterTaskQueue.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/task/DefaultRasterTaskQueue.java	(revision 3222)
@@ -0,0 +1,96 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.buffer.impl.task;
+
+import java.util.ArrayList;
+import java.util.EventObject;
+import java.util.TreeMap;
+
+/**
+ * Clase donde se registran todos los procesos raster para poder ser accedidos por distintos
+ * objetos y puedan mandarles se�ales.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ *
+ */
+public class DefaultRasterTaskQueue {
+	
+	private static TreeMap<String, DefaultTask> processPool = new TreeMap<String, DefaultTask>();
+	private static ArrayList<String>           processID   = new ArrayList<String>();
+	
+	/**
+	 * Registra procesos para que puedan ser accedidos
+	 * @param id Identificador del proceso
+	 * @param process Proceso
+	 */
+	public static void register(DefaultTask process) {
+		processPool.put(process.getID(), process);
+		processID.add(process.getID());
+	}	
+	
+	/**
+	 * Saca un proceso del repositorio
+	 * @param id Identificador del proceso.
+	 */
+	public static void remove(DefaultTask process) {
+		processPool.remove(process.getID());
+		for (int i = 0; i < processID.size(); i++) {
+			if(((String)processID.get(i)).compareTo(process.getID()) == 0) {
+				processID.remove(i);
+				break;
+			}
+		}
+	}
+	
+	/**
+	 * Gets a task using its identifier
+	 * @param id Identifier of this task
+	 * @return Task
+	 */
+	public static DefaultTask get(String id) {
+		return ((DefaultTask)processPool.get(id) == null) ? new DefaultTask(null) : (DefaultTask)processPool.get(id);
+	}
+	
+	/**
+	 * Envia un evento al proceso cuyo id coincide con el par�metro
+	 * @param id Identificador del proceso
+	 * @param ev Evento
+	 */
+	public static void sendSignal(String id, EventObject ev) {
+		Object obj = processPool.get(id);
+		if(obj != null && obj instanceof DefaultTask) 
+			((DefaultTask)obj).setEvent(ev);
+	}
+	
+	/**
+	 * Envia un evento a todos los procesos
+	 * @param id Identificador del proceso
+	 * @param ev Evento
+	 */
+	public static void sendSignal(EventObject ev) {
+		for (int i = 0; i < processID.size(); i++) {
+			String id = (String)processID.get(i);
+			sendSignal(id, ev);
+		}
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/task/DefaultRasterTaskQueue.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/task/DefaultTaskEventManager.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/task/DefaultTaskEventManager.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/task/DefaultTaskEventManager.java	(revision 3222)
@@ -0,0 +1,86 @@
+package org.gvsig.raster.cache.buffer.impl.task;
+
+import java.util.EventObject;
+
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.task.TaskEventManager;
+/**
+ * This class manages a raster task. 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class DefaultTaskEventManager implements TaskEventManager {
+	private DefaultTask task = null;
+	
+	/**
+	 * This constructor creates this object but it doesn't register
+	 * the task
+	 * @param process
+	 */
+	public DefaultTaskEventManager() {
+	}
+	
+	/**
+	 * This constructor creates the task and register this
+	 * in the repository
+	 * @param process
+	 */
+	public DefaultTaskEventManager(Object process) {
+		task = new DefaultTask(process);
+		DefaultRasterTaskQueue.register(task);
+	}
+	
+	/*
+	 * O(non-Javadoc)
+	 * @see org.gvsig.fmap.dal.coverage.process.TaskEventManager#removeTask()
+	 */
+	public void removeTask() {
+		DefaultRasterTaskQueue.remove(task);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.fmap.dal.coverage.process.TaskEventManager#setEvent(java.util.EventObject)
+	 */
+	public void setEvent(EventObject ev) {
+		task.setEvent(ev);
+	}
+	
+	/**
+	 * Assigns a task without register.
+	 * @param task
+	 */
+	public void setTask(DefaultTask task) {
+		this.task = task;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.fmap.dal.coverage.process.TaskEventManager#getEvent()
+	 */
+	public EventObject getEvent() {
+		return task.getEvent();
+	}
+	
+	/**
+	 * Gesti�n de las se�ales. Este m�todo define las acciones por defecto para
+	 * cada se�al. No es necesario utilizar estas. Se puede en cada caso, hacer un m�todo
+	 * manageEvent en el que se gestione las acciones concretas de una se�al.
+	 * 
+	 * @param ev Evento a gestionar
+	 */
+	public  void manageEvent(EventObject ev) throws ProcessInterruptedException {
+		task.manageEvent(ev);
+	}
+	
+	/**
+	 * Obtiene un proceso a partir de su identificador
+	 * @param id Identificador del proceso
+	 * @return Proceso
+	 */
+	public static TaskEventManager get() {
+		DefaultTask task = DefaultRasterTaskQueue.get(Thread.currentThread().getId() + "");
+		DefaultTaskEventManager taskEventManager = new DefaultTaskEventManager();
+		taskEventManager.setTask(task);
+		return taskEventManager;
+	}
+}
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/task/DefaultTaskEventManager.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/rocache/ReadOnlyCacheBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/rocache/ReadOnlyCacheBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/rocache/ReadOnlyCacheBand.java	(revision 3222)
@@ -0,0 +1,444 @@
+package org.gvsig.raster.cache.buffer.impl.rocache;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.PxTile;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.BandImpl;
+import org.gvsig.raster.cache.buffer.impl.memory.RasterMemoryBuffer;
+
+/**
+ * Base class for a ReadOnlyCacheBand
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public abstract class ReadOnlyCacheBand extends BandImpl {
+	/**
+	 * Loaded page
+	 */
+	protected Buffer                     page              = null;
+	protected Buffer                     secondPage        = null;
+	protected BufferDataSource           dataSource        = null;
+	protected ArrayList<PxTile>          stripeList        = null;
+	
+	/**
+	 * Band number in the list of the raster
+	 */
+	protected int                        nBand             = -1;
+	/**
+	 * Number of page loaded in IBuffer
+	 */
+	protected int                        loadedPage        = -1;
+	protected int                        loadedSecondPage  = -1;
+	
+	protected int                        bitsPag           = 0;
+	/**
+	 * Para extraer el desplazamiento de una direcci�n (l�nea de raster) hay que hacer una operaci�n And con 
+	 * con la altura de la p�gina -1. Por ejemplo, una p�gina de 16 l�neas de altura el desplazamiento ser�
+	 * 16 - 1 = 15 porque 15 en binario es 1111.
+	 * 
+	 * Si queremos acceder a la linea del raster n�mero 83 (1010011) realizando la operaci�n And con el valor del
+	 * desplazamiento obtenemos (0001111 & 1010011 = 0000011), es decir el valor 3 en decimal. Esto quiere decir
+	 * que la l�nea 83 del raster es la 3 de su p�gina. 
+	 */
+	protected int                         offset           = 1;
+	
+    /**
+     * Constructor a llamar desde las clases hijas
+     */
+    public ReadOnlyCacheBand(ArrayList<PxTile> stripeList,
+    						BufferDataSource dataSource,
+    						int offset,
+    						int bitsPag,
+    						int nBand, 
+    						int width, 
+    						int height, 
+    						int dataType) {
+    	super(width, height);
+    	super.setDataType(dataType);
+    	this.nBand = nBand;
+    	this.dataSource = dataSource;
+    	this.stripeList = stripeList;
+    	this.offset = offset;
+    	this.bitsPag = bitsPag;
+    	
+    	//Creamos las p�ginas en memoria
+		this.page = new RasterMemoryBuffer(getDataType(), 
+											width,
+											getBlockSize(),
+											1,
+											true);
+		this.secondPage = new RasterMemoryBuffer(getDataType(), 
+												width, 
+												getBlockSize(),
+												1,
+												true);
+    }
+    
+	/**
+	 * Load a page with data from disk
+	 * @param nPage
+	 */
+	protected void loadOrSwapPage(int nPage) {
+		if(loadedSecondPage == nPage) {
+			swapPages();
+			return;
+		}
+		loadPage(nPage);
+	}
+	
+	/**
+	 * Swap the two pages
+	 */
+	protected void loadPage(int nPage) {
+		try {
+			if(dataSource != null) {
+				dataSource.loadPage(page, stripeList.get(nPage), nBand);
+				dataSource.loadPage(secondPage, stripeList.get((nPage + 1) % stripeList.size()), nBand);
+			}
+			loadedPage = nPage;
+			loadedSecondPage = (nPage + 1) % stripeList.size();
+			//System.out.println("Load:" + loadedPage + " " + loadedSecondPage);
+		} catch (OperationNotSupportedException e) {
+		} catch (IOException e) {
+		} catch (ProcessInterruptedException e) {
+		}
+	}
+
+	/**
+	 * Swap the two pages
+	 */
+	protected void swapPages() {
+		int aux = loadedPage;
+		loadedPage = loadedSecondPage;
+		loadedSecondPage = aux;
+		Buffer pAux = page;
+		page = secondPage;
+		secondPage = pAux;
+		//System.out.println("Swap:" + loadedPage + " " + loadedSecondPage);
+	}
+    	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getBlockHeight()
+	 */
+	public int getBlockSize() {
+		return (int)stripeList.get(0).getHeight();
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getNumberOfBlocks()
+	 */
+	public int getNumberOfBlocks() {
+		return stripeList.size();
+	}
+		
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setBandNumber(int)
+	 */
+	public void setBandNumber(int band) {
+		this.nBand = band;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getBandNumber()
+	 */
+	public int getBandNumber() {
+		return this.nBand;
+	}
+		
+	//***********************************************
+    //Getting a block of data
+	
+    /*
+     * (non-Javadoc)
+     * @see org.gvsig.raster.buffer.IRasterBand#getByteBlock(int)
+     */
+	public byte[][] getByteBlock(int block){
+		return null;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getShortBlock(int)
+	 */
+	public short[][] getShortBlock(int block) {
+		return null;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getIntBlock(int)
+	 */
+	public int[][] getIntBlock(int block) {
+		return null;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getFloatBlock(int)
+	 */
+	public float[][] getFloatBlock(int block) {
+		return null;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getDoubleBlock(int)
+	 */
+	public double[][] getDoubleBlock(int block) {
+		return null;
+	}
+	
+	//*****************************************************
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getElemByte(int, int)
+	 */
+	public byte getElemByte(int line, int col) {
+		return 0;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getElemDouble(int, int)
+	 */
+	public double getElemDouble(int line, int col) {
+		return 0;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getElemFloat(int, int)
+	 */
+	public float getElemFloat(int line, int col) {
+		return 0;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getElemInt(int, int)
+	 */
+	public int getElemInt(int line, int col) {
+		return 0;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getElemShort(int, int)
+	 */
+	public short getElemShort(int line, int col) {
+		return 0;
+	}
+	
+	//*****************************************************
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getByteLine(int)
+	 */
+	public byte[] getByteLine(int line) throws OperationNotSupportedException {
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getDoubleLine(int)
+	 */
+	public double[] getDoubleLine(int line) throws OperationNotSupportedException {
+		return null;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getFloatLine(int)
+	 */
+	public float[] getFloatLine(int line) throws OperationNotSupportedException {
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getIntLine(int)
+	 */
+	public int[] getIntLine(int line) throws OperationNotSupportedException {
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getShortLine(int)
+	 */
+	public short[] getShortLine(int line) throws OperationNotSupportedException {
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setElem(int, int, byte)
+	 */
+	public void setElem(int line, int col, byte data) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("ReadOnlyCacheBand doesn't support this operation");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setElem(int, int, short)
+	 */
+	public void setElem(int line, int col, short data) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("ReadOnlyCacheBand doesn't support this operation");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setElem(int, int, int)
+	 */
+	public void setElem(int line, int col, int data) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("ReadOnlyCacheBand doesn't support this operation");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setElem(int, int, float)
+	 */
+	public void setElem(int line, int col, float data) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("ReadOnlyCacheBand doesn't support this operation");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setElem(int, int, double)
+	 */
+	public void setElem(int line, int col, double data) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("ReadOnlyCacheBand doesn't support this operation");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setByteLine(byte[], int)
+	 */
+	public void setByteLine(byte[] data, int line) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("ReadOnlyCacheBand doesn't support this operation");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setDoubleLine(double[], int)
+	 */
+	public void setDoubleLine(double[] data, int line) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("ReadOnlyCacheBand doesn't support this operation");
+	}
+		
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setFloatLine(float[], int)
+	 */
+	public void setFloatLine(float[] data, int line) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("ReadOnlyCacheBand doesn't support this operation");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setIntLine(int[], int)
+	 */
+	public void setIntLine(int[] data, int line) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("ReadOnlyCacheBand doesn't support this operation");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setShortLine(short[], int)
+	 */
+	public void setShortLine(short[] data, int line) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("ReadOnlyCacheBand doesn't support this operation");
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setByteBlock(byte[][], int)
+	 */
+	public void setByteBlock(byte[][] data, int block) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("ReadOnlyCacheBand doesn't support this operation");
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setShortBlock(short[][], int)
+	 */
+	public void setShortBlock(short[][] data, int block) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("ReadOnlyCacheBand doesn't support this operation");
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setIntBlock(int[][], int)
+	 */
+	public void setIntBlock(int[][] data, int block) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("ReadOnlyCacheBand doesn't support this operation");
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setFloatBlock(float[][], int)
+	 */
+	public void setFloatBlock(float[][] data, int block) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("ReadOnlyCacheBand doesn't support this operation");
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setDoubleBlock(double[][], int)
+	 */
+	public void setDoubleBlock(double[][] data, int block) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("ReadOnlyCacheBand doesn't support this operation");
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.IBand#assign(byte)
+	 */
+	public void assign(byte value) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("ReadOnlyCacheBand doesn't support this operation");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.IBand#assign(short)
+	 */
+	public void assign(short value) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("ReadOnlyCacheBand doesn't support this operation");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.IBand#assign(int)
+	 */
+	public void assign(int value) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("ReadOnlyCacheBand doesn't support this operation");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.IBand#assign(float)
+	 */
+	public void assign(float value) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("ReadOnlyCacheBand doesn't support this operation");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.IBand#assign(double)
+	 */
+	public void assign(double value) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("ReadOnlyCacheBand doesn't support this operation");
+	}
+
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/rocache/ReadOnlyCacheBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/rocache/ByteBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/rocache/ByteBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/rocache/ByteBand.java	(revision 3222)
@@ -0,0 +1,70 @@
+package org.gvsig.raster.cache.buffer.impl.rocache;
+
+import java.util.ArrayList;
+
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.PxTile;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+
+/**
+ * This class represent a byte band loaded in memory.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class ByteBand extends ReadOnlyCacheBand {
+
+	public ByteBand(ArrayList<PxTile> stripeList,
+			BufferDataSource dataSource, int offset, int bitsPag, int band,
+			int width, int height) {
+		super(stripeList, dataSource, offset, bitsPag, band, width, height, Buffer.TYPE_BYTE);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getByteBlock(int)
+	 */
+	public byte[][] getByteBlock(int block){
+		if(block != loadedPage)
+			loadOrSwapPage(block);
+		return page.getBand(0).getByteBlock(block);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getElemByte(int, int)
+	 */
+	public byte getElemByte(int line, int col) {
+		int pag = line >> bitsPag;
+		if(pag != loadedPage)
+			loadOrSwapPage(pag);
+		return page.getElemByte(line & offset, col, 0);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getByteLine(int)
+	 */
+	public byte[] getByteLine(int line) throws OperationNotSupportedException {
+		int pag = line >> bitsPag;
+		if(pag != loadedPage)
+			loadOrSwapPage(pag);
+		return page.getLineByte(line & offset)[0];
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see java.lang.Object#clone()
+	 */
+	public Object clone() {
+		BufferDataSource ds = dataSource.clone();	
+		ByteBand result = new ByteBand(stripeList, 
+				ds,
+				offset,
+				bitsPag,
+				nBand,
+				getWidth(),
+				getHeight());
+		return result;
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/rocache/ByteBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/rocache/RasterReadOnlyBuffer.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/rocache/RasterReadOnlyBuffer.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/rocache/RasterReadOnlyBuffer.java	(revision 3222)
@@ -0,0 +1,939 @@
+package org.gvsig.raster.cache.buffer.impl.rocache;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferParam;
+import org.gvsig.raster.cache.buffer.PxTile;
+import org.gvsig.raster.cache.buffer.exception.BandNotCompatibleException;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.WrongParameterException;
+import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl;
+import org.gvsig.raster.cache.buffer.impl.PxTileImpl;
+import org.gvsig.raster.cache.buffer.impl.RasterBuffer;
+import org.gvsig.raster.cache.buffer.impl.datasource.DriverException;
+
+/**
+ * Read Only buffer.
+ * This buffer has a reference to original raster. Firstly its load only two pages in memory. When more
+ * data out of those pages are required other stripes will be loaded.
+ * 
+ * At the beginning the cache's structure is calculated creating an array of pieces. Each one of this pieces
+ * is represented by the object ReadOnlyStripe.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ *
+ */
+public class RasterReadOnlyBuffer extends RasterBuffer {
+	/**
+	 * Pagina cargada
+	 */
+	private ArrayList<ReadOnlyCacheBand>    bandList          = null;
+	/**
+	 * N�mero de p�gina cargada en IBuffer
+	 */
+	private int                             loadedPage        = -1;
+	private int                             loadedSecondPage  = -1;
+	
+	private int                             bitsPag           = 0;
+
+	/**
+	 * N�mero total de p�ginas en las que se divide el raster
+	 */
+	private int                             nTotalPags        = 0;
+
+	private int[]                           possibleHeights   = {2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536};
+	
+	/**
+	 * Para extraer el desplazamiento de una direcci�n (l�nea de raster) hay que hacer una operaci�n And con 
+	 * con la altura de la p�gina -1. Por ejemplo, una p�gina de 16 l�neas de altura el desplazamiento ser�
+	 * 16 - 1 = 15 porque 15 en binario es 1111.
+	 * 
+	 * Si queremos acceder a la linea del raster n�mero 83 (1010011) realizando la operaci�n And con el valor del
+	 * desplazamiento obtenemos (0001111 & 1010011 = 0000011), es decir el valor 3 en decimal. Esto quiere decir
+	 * que la l�nea 83 del raster es la 3 de su p�gina. 
+	 */
+	private int                              offset           = 1;
+	/**
+	 * Altura de la p�gina de cada banda en l�neas.
+	 */
+	private int                              hPag             = 1;
+	private BufferDataSource                 dataSource       = null;
+	private ArrayList<PxTile>                stripeList       = null;
+	
+	/**
+	 * Constructor. Asigna las variables de inicializaci�n y crea la estructura de 
+	 * la cach� con los datos pasados.
+	 * @param dataType Tipo de dato
+	 * @param width Ancho
+	 * @param getDataType() Alto
+	 * @param bandNr Banda
+	 * @param orig
+	 * @throws DriverException 
+	 * @throws NotSupportedExtensionException 
+	 * @throws FileNotFoundException 
+	 */
+	public RasterReadOnlyBuffer(BufferDataSource dataSource, int x, int y, int w, int h, int[] bands) {
+		super(x, y, w, h, dataSource.getDataType(), bands.length);
+		this.dataSource = dataSource;
+		stripeList = new ArrayList<PxTile>();
+		createStructure(bands);
+	}
+	
+	/**
+	 * Constructor. Asigna las variables de inicializaci�n y crea la estructura de 
+	 * la cach� con los datos pasados.
+	 * @param dataSource 
+	 *        Datasource
+	 * @param bands 
+	 */
+	public RasterReadOnlyBuffer(BufferDataSource dataSource, int[] bands) {
+		super(  0, 
+				0, 
+				dataSource.getWidth(), 
+				dataSource.getHeight(), 
+				dataSource.getDataType(), 
+				bands.length);
+		this.dataSource = dataSource;
+		stripeList = new ArrayList<PxTile>();
+		createStructure(bands);
+	}
+	
+	/**
+	 * Constructor. Asigna las variables de inicializaci�n y crea la estructura de 
+	 * la cach� con los datos pasados.
+	 * @param dataSource 
+	 *        Datasource
+	 */
+	public RasterReadOnlyBuffer(BufferDataSource dataSource) {
+		super(  0, 
+				0, 
+				dataSource.getWidth(), 
+				dataSource.getHeight(), 
+				dataSource.getDataType(), 
+				dataSource.getBandCount());
+		this.dataSource = dataSource;
+		stripeList = new ArrayList<PxTile>();
+		int[] bands = new int[dataSource.getBandCount()];
+		for (int i = 0; i < bands.length; i++) {
+			bands[i] = i;
+		}
+		createStructure(bands);
+	}
+	
+	/**
+	 * Constructor. Asigna las variables de inicializaci�n y crea la estructura de 
+	 * la cach� con los datos pasados.
+	 * @param dataSource 
+	 *        Datasource
+	 */
+	public RasterReadOnlyBuffer(BufferParam param) {
+		super(  param.getX(), 
+				param.getY(), 
+				param.getWidth(), 
+				param.getHeight(), 
+				param.getDataSource().getDataType(), 
+				param.getBandCount());
+		this.dataSource = param.getDataSource();
+		stripeList = new ArrayList<PxTile>();
+		createStructure(param.getBandList());
+	}
+	
+	/**
+	 * 
+	 */
+	private void createStructure(int[] bands) {
+		//Pasamos los megas a bytes
+		double pageSize = BufferCacheManagerImpl.pageSize * 1048576;
+		
+		long pageSizePerBand = (long)(pageSize / getBandCount());
+		
+		int dataSizePerBand = 0;
+		if (getDataType() == Buffer.TYPE_BYTE) {
+			dataSizePerBand = 1;
+		} else if ((getDataType() == Buffer.TYPE_SHORT) | (getDataType() == Buffer.TYPE_USHORT)) {
+			dataSizePerBand = 2;
+        } else if (getDataType() == Buffer.TYPE_INT) {
+        	dataSizePerBand = 4;
+        } else if (getDataType() == Buffer.TYPE_FLOAT) {
+        	dataSizePerBand = 4;
+        } else if (getDataType() == Buffer.TYPE_DOUBLE) {
+        	dataSizePerBand = 8;
+        }
+		
+		//La altura de la p�gina depende del ancho de esta y del tipo de dato
+		for(int i = (possibleHeights.length - 1); i >= 0; i --) {
+			long size = (long)getWidth() * (long)possibleHeights[i] * (long)dataSizePerBand; 
+			if(size <= pageSizePerBand) {
+				hPag = possibleHeights[i];
+				break;
+			}
+		}
+		
+		//Calculamos el tama�o de p�gina en bytes 
+		pageSizePerBand = getWidth() * hPag * dataSizePerBand;
+		
+		int h = hPag; 
+		while(h > 1){
+			h >>= 1;
+			bitsPag ++;
+		}
+		
+		//Calculamos el n�mero total de p�ginas en cach�
+		nTotalPags = (int)Math.ceil((double)getHeight() / (double)hPag);
+		int fullPages = (int)Math.floor((double)getHeight() / (double)hPag);
+		
+		//Calculamos la lista de franjas con sus coordenadas
+		int y = 0;
+		int x = 0;
+		for (int i = 0; i < fullPages; i++) {
+			stripeList.add(new PxTileImpl(x, y, getWidth(), hPag));
+			y += hPag;
+		}
+		offset = hPag - 1;
+		
+		int hLastPage = getHeight() - (fullPages * hPag);
+		for (int i = fullPages; i < nTotalPags; i++)
+			stripeList.add(new PxTileImpl(x, y, getWidth(), hLastPage));
+		
+		//Creamos las p�ginas en memoria
+		//createMemoryPages();
+		createBands(bands);
+	}
+		
+	private void createBands(int[] bands) {
+		bandList = new ArrayList<ReadOnlyCacheBand>();
+		for (int i = 0; i < bands.length; i++) {
+			BufferDataSource ds = dataSource.clone();
+			ds.setSelectedBand(bands[i]);
+			switch (getDataType()) {
+			case RasterBuffer.TYPE_BYTE:
+				bandList.add(new ByteBand(stripeList, ds, offset, bitsPag, bands[i], getWidth(), getHeight()));
+				break;
+			case RasterBuffer.TYPE_SHORT:
+				bandList.add(new ShortBand(stripeList, ds, offset, bitsPag, bands[i], getWidth(), getHeight()));
+				break;
+			case RasterBuffer.TYPE_INT:
+				bandList.add(new IntBand(stripeList, ds, offset, bitsPag, bands[i], getWidth(), getHeight()));
+				break;
+			case RasterBuffer.TYPE_FLOAT:
+				bandList.add(new FloatBand(stripeList, ds, offset, bitsPag, bands[i], getWidth(), getHeight()));
+				break;
+			case RasterBuffer.TYPE_DOUBLE:
+				bandList.add(new DoubleBand(stripeList, ds, offset, bitsPag, bands[i], getWidth(), getHeight()));
+				break;
+			}
+		}
+	}
+		
+	/**
+	 * Load a page with data from disk
+	 * @param nPage
+	 */
+	private void loadPage(int nPage) {
+		if(loadedSecondPage == nPage) {
+			for (int i = 0; i < bandList.size(); i++) 
+				bandList.get(i).swapPages();
+			this.loadedPage = bandList.get(0).loadedPage;
+			this.loadedSecondPage = bandList.get(0).loadedSecondPage;
+			return;
+		}
+
+		for (int i = 0; i < getBandCount(); i++) 
+			bandList.get(i).loadPage(nPage);
+		this.loadedPage = bandList.get(0).loadedPage;
+		this.loadedSecondPage = bandList.get(0).loadedSecondPage;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#isWritable()
+	 */
+    public boolean isWritable() {
+    	return false;
+    }
+    
+    public void addDrawableBands(int[] bands) {
+    	stripeList = new ArrayList<PxTile>();
+		createStructure(bands);
+    }
+
+    //*********************************************************
+    
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#getLineByte(int)
+	 */
+	public byte[][] getLineByte(int line) throws OperationNotSupportedException {
+		int pag = line >> bitsPag;
+		if(pag != loadedPage)
+			loadPage(pag);
+		byte[][] result = new byte[getBandCount()][];
+		for (int i = 0; i < getBandCount(); i++) 
+			result[i] = bandList.get(i).page.getLineByte(line & offset)[0];
+		return result;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#getLineShort(int)
+	 */
+	public short[][] getLineShort(int line) throws OperationNotSupportedException {
+		int pag = line >> bitsPag;
+		if(pag != loadedPage)
+			loadPage(pag);
+		short[][] result = new short[getBandCount()][];
+		for (int i = 0; i < getBandCount(); i++) 
+			result[i] = bandList.get(i).page.getLineShort(line & offset)[0];
+		return result;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#getLineInt(int)
+	 */
+	public int[][] getLineInt(int line) throws OperationNotSupportedException {
+		int pag = line >> bitsPag;
+		if(pag != loadedPage)
+			loadPage(pag);
+		int[][] result = new int[getBandCount()][];
+		for (int i = 0; i < getBandCount(); i++)  
+			result[i] = bandList.get(i).page.getLineInt(line & offset)[0];
+		return result;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#getLineFloat(int)
+	 */
+	public float[][] getLineFloat(int line) throws OperationNotSupportedException {
+		int pag = line >> bitsPag;
+		if(pag != loadedPage)
+			loadPage(pag);
+		float[][] result = new float[getBandCount()][];
+		for (int i = 0; i < getBandCount(); i++)
+			result[i] = bandList.get(i).page.getLineFloat(line & offset)[0];
+		return result;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#getLineDouble(int)
+	 */
+	public double[][] getLineDouble(int line) throws OperationNotSupportedException {
+		int pag = line >> bitsPag;
+		if(pag != loadedPage)
+			loadPage(pag);
+		double[][] result = new double[getBandCount()][];
+		for (int i = 0; i < getBandCount(); i++) 
+			result[i] = bandList.get(i).page.getLineDouble(line & offset)[0];
+		return result;
+	}
+
+	//*********************************************************
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#getLineFromBandByte(int, int)
+	 */
+	public byte[] getLineFromBandByte(int line, int band) throws OperationNotSupportedException {
+		int pag = line >> bitsPag;
+		if(pag != loadedPage)
+			loadPage(pag);
+		return this.bandList.get(band).page.getLineFromBandByte(line & offset, 0);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#getLineFromBandShort(int, int)
+	 */
+	public short[] getLineFromBandShort(int line, int band) throws OperationNotSupportedException {
+		int pag = line >> bitsPag;
+		if(pag != loadedPage)
+			loadPage(pag);
+		return this.bandList.get(band).page.getLineFromBandShort(line & offset, 0);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#getLineFromBandInt(int, int)
+	 */
+	public int[] getLineFromBandInt(int line, int band) throws OperationNotSupportedException {
+		int pag = line >> bitsPag;
+		if(pag != loadedPage)
+			loadPage(pag);
+		return this.bandList.get(band).page.getLineFromBandInt(line & offset, 0);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#getLineFromBandFloat(int, int)
+	 */
+	public float[] getLineFromBandFloat(int line, int band) throws OperationNotSupportedException {
+		int pag = line >> bitsPag;
+		if(pag != loadedPage)
+			loadPage(pag);
+		return this.bandList.get(band).page.getLineFromBandFloat(line & offset, 0);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#getLineFromBandDouble(int, int)
+	 */
+	public double[] getLineFromBandDouble(int line, int band) throws OperationNotSupportedException {
+		int pag = line >> bitsPag;
+		if(pag != loadedPage)
+			loadPage(pag);
+		return this.bandList.get(band).page.getLineFromBandDouble(line & offset, 0);
+	}
+
+	//*********************************************************
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#getElemByte(int, int, int)
+	 */
+	public byte getElemByte(int line, int col, int band) {
+		int pag = line >> bitsPag;
+		if(pag != loadedPage)
+			loadPage(pag);
+		return this.bandList.get(band).page.getElemByte(line & offset, col, 0);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#getElemShort(int, int, int)
+	 */
+	public short getElemShort(int line, int col, int band) {
+		int pag = line >> bitsPag;
+		if(pag != loadedPage)
+			loadPage(pag);
+		return this.bandList.get(band).page.getElemShort(line & offset, col, 0);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#getElemInt(int, int, int)
+	 */
+	public int getElemInt(int line, int col, int band) {
+		int pag = line >> bitsPag;
+		if(pag != loadedPage)
+			loadPage(pag);
+		return this.bandList.get(band).page.getElemInt(line & offset, col, 0);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#getElemFloat(int, int, int)
+	 */
+	public float getElemFloat(int line, int col, int band) {
+		int pag = line >> bitsPag;
+		if(pag != loadedPage)
+			loadPage(pag);
+		return this.bandList.get(band).page.getElemFloat(line & offset, col, 0);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#getElemDouble(int, int, int)
+	 */
+	public double getElemDouble(int line, int col, int band) {
+		int pag = line >> bitsPag;
+		if(pag != loadedPage)
+			loadPage(pag);
+		return this.bandList.get(band).page.getElemDouble(line & offset, col, 0);
+	}
+	
+	//*********************************************************
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#getElemByte(int, int, byte[])
+	 */
+	public void getElemByte(int line, int col, byte[] data) {
+		int pag = line >> bitsPag;
+		if(pag != loadedPage)
+			loadPage(pag);
+		for (int i = 0; i < getBandCount(); i++)  
+			data[i] = bandList.get(i).page.getElemByte(line & offset, col, 0);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#getElemShort(int, int, short[])
+	 */
+	public void getElemShort(int line, int col, short[] data) {
+		int pag = line >> bitsPag;
+		if(pag != loadedPage)
+			loadPage(pag);
+		for (int i = 0; i < getBandCount(); i++)  
+			data[i] = bandList.get(i).page.getElemShort(line & offset, col, 0);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#getElemInt(int, int, int[])
+	 */
+	public void getElemInt(int line, int col, int[] data) {
+		int pag = line >> bitsPag;
+		if(pag != loadedPage)
+			loadPage(pag);
+		for (int i = 0; i < getBandCount(); i++)  
+			data[i] = bandList.get(i).page.getElemInt(line & offset, col, 0);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#getElemFloat(int, int, float[])
+	 */
+	public void getElemFloat(int line, int col, float[] data) {
+		int pag = line >> bitsPag;
+		if(pag != loadedPage)
+			loadPage(pag);
+		for (int i = 0; i < getBandCount(); i++)  
+			data[i] = bandList.get(i).page.getElemFloat(line & offset, col, 0);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#getElemDouble(int, int, double[])
+	 */
+	public void getElemDouble(int line, int col, double[] data) {
+		int pag = line >> bitsPag;
+		if(pag != loadedPage)
+			loadPage(pag);
+		for (int i = 0; i < getBandCount(); i++)  
+			data[i] = bandList.get(i).page.getElemDouble(line & offset, col, 0);
+	}
+	
+	//*********************************************************
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#assignBandToNotValid(int)
+	 */
+	public void assignBandToNotValid(int iBand) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("RasterReadOnlyBuffer doesn't support this operation");
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#assign(int, byte)
+	 */
+	public void assign(int band, byte value) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("RasterReadOnlyBuffer doesn't support this operation");
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#assign(int, short)
+	 */
+	public void assign(int band, short value) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("RasterReadOnlyBuffer doesn't support this operation");
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#assign(int, int)
+	 */
+	public void assign(int band, int value) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("RasterReadOnlyBuffer doesn't support this operation");
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#assign(int, float)
+	 */
+	public void assign(int band, float value) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("RasterReadOnlyBuffer doesn't support this operation");
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#assign(int, double)
+	 */
+	public void assign(int band, double value) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("RasterReadOnlyBuffer doesn't support this operation");
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#setElem(int, int, int, byte)
+	 */
+	public void setElem(int line, int col, int band, byte data) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("RasterReadOnlyBuffer doesn't support this operation");
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#setElem(int, int, int, short)
+	 */
+	public void setElem(int line, int col, int band, short data) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("RasterReadOnlyBuffer doesn't support this operation");
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#setElem(int, int, int, int)
+	 */
+	public void setElem(int line, int col, int band, int data) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("RasterReadOnlyBuffer doesn't support this operation");
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#setElem(int, int, int, float)
+	 */
+	public void setElem(int line, int col, int band, float data) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("RasterReadOnlyBuffer doesn't support this operation");
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#setElem(int, int, int, double)
+	 */
+	public void setElem(int line, int col, int band, double data) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("RasterReadOnlyBuffer doesn't support this operation");
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#setElemByte(int, int, byte[])
+	 */
+	public void setElemByte(int line, int col, byte[] data) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("RasterReadOnlyBuffer doesn't support this operation");
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#setElemDouble(int, int, double[])
+	 */
+	public void setElemDouble(int line, int col, double[] data) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("RasterReadOnlyBuffer doesn't support this operation");
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#setElemFloat(int, int, float[])
+	 */
+	public void setElemFloat(int line, int col, float[] data) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("RasterReadOnlyBuffer doesn't support this operation");
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#setElemInt(int, int, int[])
+	 */
+	public void setElemInt(int line, int col, int[] data) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("RasterReadOnlyBuffer doesn't support this operation");
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#setElemShort(int, int, short[])
+	 */
+	public void setElemShort(int line, int col, short[] data) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("RasterReadOnlyBuffer doesn't support this operation");
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#setLineByte(byte[][], int)
+	 */
+	public void setLineByte(byte[][] data, int line) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("RasterReadOnlyBuffer doesn't support this operation");
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#setLineDouble(double[][], int)
+	 */
+	public void setLineDouble(double[][] data, int line) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("RasterReadOnlyBuffer doesn't support this operation");
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#setLineFloat(float[][], int)
+	 */
+	public void setLineFloat(float[][] data, int line) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("RasterReadOnlyBuffer doesn't support this operation");
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#setLineInBandByte(byte[], int, int)
+	 */
+	public void setLineInBandByte(byte[] data, int line, int band) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("RasterReadOnlyBuffer doesn't support this operation");
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#setLineInBandDouble(double[], int, int)
+	 */
+	public void setLineInBandDouble(double[] data, int line, int band) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("RasterReadOnlyBuffer doesn't support this operation");
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#setLineInBandFloat(float[], int, int)
+	 */
+	public void setLineInBandFloat(float[] data, int line, int band) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("RasterReadOnlyBuffer doesn't support this operation");
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#setLineInBandInt(int[], int, int)
+	 */
+	public void setLineInBandInt(int[] data, int line, int band) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("RasterReadOnlyBuffer doesn't support this operation");
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#setLineInBandShort(short[], int, int)
+	 */
+	public void setLineInBandShort(short[] data, int line, int band) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("RasterReadOnlyBuffer doesn't support this operation");
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#setLineInt(int[][], int)
+	 */
+	public void setLineInt(int[][] data, int line) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("RasterReadOnlyBuffer doesn't support this operation");
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#setLineShort(short[][], int)
+	 */
+	public void setLineShort(short[][] data, int line) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("RasterReadOnlyBuffer doesn't support this operation");
+	}
+	
+	//**************************************
+    //**********BANDS OPERATIONS************
+    //**************************************
+    
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.RasterBuffer#swapBands(int[])
+	 */
+	public void swapBands(int[] bandPosition) throws WrongParameterException, IOException{
+		super.swapBands(bandPosition);
+		ArrayList<ReadOnlyCacheBand> result = new ArrayList<ReadOnlyCacheBand>();
+		for (int i = 0; i < bandList.size(); i++) 
+			result.add(bandList.get(bandPosition[i]));
+		bandList = result;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#getBands()
+	 */
+	public Band[] getBands() {
+		Band[] result = new Band[bandList.size()];
+		for (int i = 0; i < result.length; i++) 
+			result[i] = bandList.get(i);
+		return result;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#getBandList()
+	 */
+    public ArrayList<Band> getBandList() {
+    	ArrayList<Band> result = new ArrayList<Band>();
+    	for (int i = 0; i < bandList.size(); i++) 
+			result.add(bandList.get(i));
+    	return result;
+    }
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#getBand(int)
+	 */
+	public Band getBand(int band){
+		return this.bandList.get(band);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.RasterBuffer#swapBands(int, int)
+	 */
+	public void swapBands(int band1, int band2) throws WrongParameterException, IOException {
+		ReadOnlyCacheBand aux1 = bandList.get(band1);
+		ReadOnlyCacheBand aux2 = bandList.get(band2);
+		
+		bandList.remove(band1);
+		bandList.add(band1, aux2);
+		bandList.remove(band2);
+		bandList.add(band2, aux1);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#removeBand(int)
+	 */
+	public void removeBand(int pos) throws IOException {
+		bandList.remove(pos);
+		bandLessLess();
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#addBand(int)
+	 */
+	public Band addBand(int pos) throws IOException {
+		bandPlusPlus();
+		switch (getDataType()) {
+		case RasterBuffer.TYPE_BYTE:
+			ByteBand bb = new ByteBand(stripeList, null, offset, bitsPag, 0, getWidth(), getHeight());
+			bandList.add(pos, bb);
+			return bb;
+		case RasterBuffer.TYPE_SHORT:
+			ShortBand sb = new ShortBand(stripeList, null, offset, bitsPag, 0, getWidth(), getHeight());
+			bandList.add(pos, sb);
+			return sb;
+		case RasterBuffer.TYPE_INT:
+			IntBand ib = new IntBand(stripeList, null, offset, bitsPag, 0, getWidth(), getHeight());
+			bandList.add(pos, ib);
+			return ib;
+		case RasterBuffer.TYPE_FLOAT:
+			FloatBand fb = new FloatBand(stripeList, null, offset, bitsPag, 0, getWidth(), getHeight());
+			bandList.add(pos, fb);
+			return fb;
+		case RasterBuffer.TYPE_DOUBLE:
+			DoubleBand db = new DoubleBand(stripeList, null, offset, bitsPag, 0, getWidth(), getHeight());
+			bandList.add(pos, db);
+			return db;
+		}
+		return null;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#getBufferWithOneBand(int)
+	 */
+	public Buffer getBufferWithOneBand(int nBand) throws IOException {
+		int[] bands = new int[]{nBand};
+		return new RasterReadOnlyBuffer(this.dataSource.clone(), bands);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.RasterBuffer#copyBand(int, org.gvsig.raster.cache.buffer.Band)
+	 */
+	public void copyBand(int iBand, Band band) throws BandNotCompatibleException, OperationNotSupportedException {
+		throw new OperationNotSupportedException("RasterReadOnlyBuffer doesn't support this operation");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#assignBand(int, org.gvsig.raster.cache.buffer.Band)
+	 */
+	public void assignBand(int nBand, Band band) throws BandNotCompatibleException {
+		if(	band.getDataType() != getDataType())
+			throw new BandNotCompatibleException("Data type not compatible");
+		if(	band.getHeight() != getHeight() || band.getWidth() != getWidth())
+			throw new BandNotCompatibleException("Bands with diferents sizes");
+		if(band.getClass() != getBand(0).getClass() || !(band instanceof ReadOnlyCacheBand))
+			throw new BandNotCompatibleException("buffer type not compatible");
+		
+		bandPlusPlus();
+		switch (getDataType()) {
+		case RasterBuffer.TYPE_BYTE:
+			ByteBand bb = new ByteBand(stripeList, ((ReadOnlyCacheBand)band).dataSource, offset, bitsPag, ((ReadOnlyCacheBand)band).nBand, getWidth(), getHeight());
+			this.bandList.add(nBand, bb);
+			break;
+		case RasterBuffer.TYPE_SHORT:
+			ShortBand sb = new ShortBand(stripeList, ((ReadOnlyCacheBand)band).dataSource, offset, bitsPag, ((ReadOnlyCacheBand)band).nBand, getWidth(), getHeight());
+			this.bandList.add(nBand, sb);
+			break;
+		case RasterBuffer.TYPE_INT:
+			IntBand ib = new IntBand(stripeList, ((ReadOnlyCacheBand)band).dataSource, offset, bitsPag, ((ReadOnlyCacheBand)band).nBand, getWidth(), getHeight());
+			this.bandList.add(nBand, ib);
+			break;
+		case RasterBuffer.TYPE_FLOAT:
+			FloatBand fb = new FloatBand(stripeList, ((ReadOnlyCacheBand)band).dataSource, offset, bitsPag, ((ReadOnlyCacheBand)band).nBand, getWidth(), getHeight());
+			this.bandList.add(nBand, fb);
+			break;
+		case RasterBuffer.TYPE_DOUBLE:
+			DoubleBand db = new DoubleBand(stripeList, ((ReadOnlyCacheBand)band).dataSource, offset, bitsPag, ((ReadOnlyCacheBand)band).nBand, getWidth(), getHeight());
+			this.bandList.add(nBand, db);
+			break;
+		}
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#getBandCopy(int)
+	 */
+	public Band getBandCopy(int band) {
+		switch (getDataType()) {
+		case RasterBuffer.TYPE_BYTE:
+			return (ByteBand)((ByteBand)bandList.get(band)).clone();
+		case RasterBuffer.TYPE_SHORT:
+			return (ShortBand)((ShortBand)bandList.get(band)).clone();
+		case RasterBuffer.TYPE_INT:
+			return (IntBand)((IntBand)bandList.get(band)).clone();
+		case RasterBuffer.TYPE_FLOAT:
+			return (FloatBand)((FloatBand)bandList.get(band)).clone();
+		case RasterBuffer.TYPE_DOUBLE:
+			return (DoubleBand)((DoubleBand)bandList.get(band)).clone();
+		}
+		return null;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#replicateBand(int, int)
+	 */
+	public void replicateBand(int orig, int dest) throws IOException {
+		Band origBand = getBandCopy(orig);
+		try {
+			assignBand(dest, origBand);
+		} catch (BandNotCompatibleException e) {
+			//It can't be throwed
+		}
+	}  
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#createBand(double)
+	 */
+	public Band createBand(double defaultValue) throws OperationNotSupportedException {
+		throw new OperationNotSupportedException("RasterReadOnlyBuffer doesn't support this operation");
+	}
+		
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#free()
+	 */
+	public void free() throws IOException {
+		for (int i = 0; i < bandList.size() ; i++) {
+			bandList.get(i).page.free();
+			bandList.get(i).secondPage.free();
+		}
+		if(dataSource != null)
+			dataSource.close();
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.impl.RasterBuffer#cloneBuffer()
+	 */
+	public Buffer cloneBuffer(){
+		return null;
+	}
+
+}
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/rocache/RasterReadOnlyBuffer.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/rocache/FloatBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/rocache/FloatBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/rocache/FloatBand.java	(revision 3222)
@@ -0,0 +1,70 @@
+package org.gvsig.raster.cache.buffer.impl.rocache;
+
+import java.util.ArrayList;
+
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.PxTile;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.impl.RasterBuffer;
+
+/**
+ * This class represent a float band loaded in memory.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class FloatBand extends ReadOnlyCacheBand {
+
+	public FloatBand(ArrayList<PxTile> stripeList,
+			BufferDataSource dataSource, int offset, int bitsPag, int band,
+			int width, int height) {
+		super(stripeList, dataSource, offset, bitsPag, band, width, height, RasterBuffer.TYPE_FLOAT);
+	}
+
+	 /*
+     * (non-Javadoc)
+     * @see org.gvsig.raster.buffer.IRasterBand#getFloatBlock(int)
+     */
+	public float[][] getFloatBlock(int block){
+		if(block != loadedPage)
+			loadOrSwapPage(block);
+		return page.getBand(0).getFloatBlock(block);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getElemFloat(int, int)
+	 */
+	public float getElemFloat(int line, int col) {
+		int pag = line >> bitsPag;
+		if(pag != loadedPage)
+			loadOrSwapPage(pag);
+		return page.getElemFloat(line & offset, col, 0);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getFloatLine(int)
+	 */
+	public float[] getFloatLine(int line) throws OperationNotSupportedException {
+		int pag = line >> bitsPag;
+		if(pag != loadedPage)
+			loadOrSwapPage(pag);
+		return page.getLineFloat(line & offset)[0];
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see java.lang.Object#clone()
+	 */
+	public Object clone() {
+		BufferDataSource ds = dataSource.clone();	
+		FloatBand result = new FloatBand(stripeList, 
+				ds,
+				offset,
+				bitsPag,
+				nBand,
+				getWidth(),
+				getHeight());
+		return result;
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/rocache/FloatBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/rocache/DoubleBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/rocache/DoubleBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/rocache/DoubleBand.java	(revision 3222)
@@ -0,0 +1,70 @@
+package org.gvsig.raster.cache.buffer.impl.rocache;
+
+import java.util.ArrayList;
+
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.PxTile;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.impl.RasterBuffer;
+
+/**
+ * This class represent a double band loaded in memory.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class DoubleBand extends ReadOnlyCacheBand {
+
+	public DoubleBand(ArrayList<PxTile> stripeList,
+			BufferDataSource dataSource, int offset, int bitsPag, int band,
+			int width, int height) {
+		super(stripeList, dataSource, offset, bitsPag, band, width, height, RasterBuffer.TYPE_DOUBLE);
+	}
+
+	 /*
+     * (non-Javadoc)
+     * @see org.gvsig.raster.buffer.IRasterBand#getDoubleBlock(int)
+     */
+	public double[][] getDoubleBlock(int block){
+		if(block != loadedPage)
+			loadOrSwapPage(block);
+		return page.getBand(0).getDoubleBlock(block);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getElemDouble(int, int)
+	 */
+	public double getElemDouble(int line, int col) {
+		int pag = line >> bitsPag;
+		if(pag != loadedPage)
+			loadOrSwapPage(pag);
+		return page.getElemDouble(line & offset, col, 0);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getDoubleLine(int)
+	 */
+	public double[] getDoubleLine(int line) throws OperationNotSupportedException {
+		int pag = line >> bitsPag;
+		if(pag != loadedPage)
+			loadOrSwapPage(pag);
+		return page.getLineDouble(line & offset)[0];
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see java.lang.Object#clone()
+	 */
+	public Object clone() {
+		BufferDataSource ds = dataSource.clone();	
+		DoubleBand result = new DoubleBand(stripeList, 
+				ds,
+				offset,
+				bitsPag,
+				nBand,
+				getWidth(),
+				getHeight());
+		return result;
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/rocache/DoubleBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/rocache/IntBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/rocache/IntBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/rocache/IntBand.java	(revision 3222)
@@ -0,0 +1,70 @@
+package org.gvsig.raster.cache.buffer.impl.rocache;
+
+import java.util.ArrayList;
+
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.PxTile;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.impl.RasterBuffer;
+
+/**
+ * This class represent a int band loaded in memory.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class IntBand extends ReadOnlyCacheBand {
+
+	public IntBand(ArrayList<PxTile> stripeList,
+			BufferDataSource dataSource, int offset, int bitsPag, int band,
+			int width, int height) {
+		super(stripeList, dataSource, offset, bitsPag, band, width, height, RasterBuffer.TYPE_INT);
+	}
+
+	 /*
+     * (non-Javadoc)
+     * @see org.gvsig.raster.buffer.IRasterBand#getIntBlock(int)
+     */
+	public int[][] getIntBlock(int block){
+		if(block != loadedPage)
+			loadOrSwapPage(block);
+		return page.getBand(0).getIntBlock(block);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getElemInt(int, int)
+	 */
+	public int getElemInt(int line, int col) {
+		int pag = line >> bitsPag;
+		if(pag != loadedPage)
+			loadOrSwapPage(pag);
+		return page.getElemInt(line & offset, col, 0);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getIntLine(int)
+	 */
+	public int[] getIntLine(int line) throws OperationNotSupportedException {
+		int pag = line >> bitsPag;
+		if(pag != loadedPage)
+			loadOrSwapPage(pag);
+		return page.getLineInt(line & offset)[0];
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see java.lang.Object#clone()
+	 */
+	public Object clone() {
+		BufferDataSource ds = dataSource.clone();	
+		IntBand result = new IntBand(stripeList, 
+				ds,
+				offset,
+				bitsPag,
+				nBand,
+				getWidth(),
+				getHeight());
+		return result;
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/rocache/IntBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/rocache/ShortBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/rocache/ShortBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/rocache/ShortBand.java	(revision 3222)
@@ -0,0 +1,70 @@
+package org.gvsig.raster.cache.buffer.impl.rocache;
+
+import java.util.ArrayList;
+
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.PxTile;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+
+/**
+ * This class represent a short band loaded in memory.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class ShortBand extends ReadOnlyCacheBand {
+
+	public ShortBand(ArrayList<PxTile> stripeList,
+			BufferDataSource dataSource, int offset, int bitsPag, int band,
+			int width, int height) {
+		super(stripeList, dataSource, offset, bitsPag, band, width, height, Buffer.TYPE_SHORT);
+	}
+
+	 /*
+     * (non-Javadoc)
+     * @see org.gvsig.raster.buffer.IRasterBand#getShortBlock(int)
+     */
+	public short[][] getShortBlock(int block){
+		if(block != loadedPage)
+			loadOrSwapPage(block);
+		return page.getBand(0).getShortBlock(block);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getElemShort(int, int)
+	 */
+	public short getElemShort(int line, int col) {
+		int pag = line >> bitsPag;
+		if(pag != loadedPage)
+			loadOrSwapPage(pag);
+		return page.getElemShort(line & offset, col, 0);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getShortLine(int)
+	 */
+	public short[] getShortLine(int line) throws OperationNotSupportedException {
+		int pag = line >> bitsPag;
+		if(pag != loadedPage)
+			loadOrSwapPage(pag);
+		return page.getLineShort(line & offset)[0];
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see java.lang.Object#clone()
+	 */
+	public Object clone() {
+		BufferDataSource ds = dataSource.clone();	
+		ShortBand result = new ShortBand(stripeList, 
+				ds,
+				offset,
+				bitsPag,
+				nBand,
+				getWidth(),
+				getHeight());
+		return result;
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/rocache/ShortBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/BandImpl.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/BandImpl.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/BandImpl.java	(revision 3222)
@@ -0,0 +1,203 @@
+package org.gvsig.raster.cache.buffer.impl;
+
+import org.gvsig.raster.cache.buffer.Band;
+
+
+/**
+ * Clase base para las bandas de un RasterBuffer ya est� cacheado o no.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public abstract class BandImpl extends RasterBase implements Band {	
+    /*
+     * Basic statistics for a band
+     */
+	protected double      max            = 0;
+	protected double      min            = 0;
+	protected double      secondMax      = 0;
+	protected double      secondMin      = 0;
+	protected double      maxRGB         = 0;
+	protected double      minRGB         = 0;
+	protected double      secondMaxRGB   = 0;
+	protected double      secondMinRGB   = 0;
+	protected double      mean           = 0;
+	
+    /**
+     * Constructor a llamar desde las clases hijas
+     * @param width
+     * @param height
+     */
+    public BandImpl(int width, int height){
+    	super(0, 0, width, height);
+    	super.setBandCount(1);
+    }
+        
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getBlockHeight()
+	 */
+	public int getBlockSize() {
+		return getHeight();
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getNumberOfBlocks()
+	 */
+	public int getNumberOfBlocks() {
+		return (int)Math.ceil(getHeight() / getBlockSize());
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Band#isHorizontalBlock()
+	 */
+	public boolean isHorizontalBlock() {
+		return true;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.IBandStatsValues#getMax()
+	 */
+	public double getMax() {
+		return max;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.IBandStatsValues#setMax(double)
+	 */
+	public void setMax(double max) {
+		this.max = max;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.IBandStatsValues#getMin()
+	 */
+	public double getMin() {
+		return min;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.IBandStatsValues#setMin(double)
+	 */
+	public void setMin(double min) {
+		this.min = min;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.IBandStatsValues#getSecondMax()
+	 */
+	public double getSecondMax() {
+		return secondMax;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.IBandStatsValues#setSecondMax(double)
+	 */
+	public void setSecondMax(double secondMax) {
+		this.secondMax = secondMax;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.IBandStatsValues#getSecondMin()
+	 */
+	public double getSecondMin() {
+		return secondMin;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.IBandStatsValues#setSecondMin(double)
+	 */
+	public void setSecondMin(double secondMin) {
+		this.secondMin = secondMin;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.IBandStatsValues#getMaxRGB()
+	 */
+	public double getMaxRGB() {
+		return maxRGB;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.IBandStatsValues#setMaxRGB(double)
+	 */
+	public void setMaxRGB(double maxRGB) {
+		this.maxRGB = maxRGB;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.IBandStatsValues#getMinRGB()
+	 */
+	public double getMinRGB() {
+		return minRGB;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.IBandStatsValues#setMinRGB(double)
+	 */
+	public void setMinRGB(double minRGB) {
+		this.minRGB = minRGB;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.IBandStatsValues#getSecondMaxRGB()
+	 */
+	public double getSecondMaxRGB() {
+		return secondMaxRGB;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.IBandStatsValues#setSecondMaxRGB(double)
+	 */
+	public void setSecondMaxRGB(double secondMaxRGB) {
+		this.secondMaxRGB = secondMaxRGB;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.IBandStatsValues#getSecondMinRGB()
+	 */
+	public double getSecondMinRGB() {
+		return secondMinRGB;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.IBandStatsValues#setSecondMinRGB(double)
+	 */
+	public void setSecondMinRGB(double secondMinRGB) {
+		this.secondMinRGB = secondMinRGB;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.IBandStatsValues#getMean()
+	 */
+	public double getMean() {
+		return mean;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.IBandStatsValues#setMean(double)
+	 */
+	public void setMean(double mean) {
+		this.mean = mean;
+	}
+
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/BandImpl.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/PxTileImpl.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/PxTileImpl.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/PxTileImpl.java	(revision 3222)
@@ -0,0 +1,124 @@
+package org.gvsig.raster.cache.buffer.impl;
+
+import java.awt.geom.Rectangle2D;
+
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.PxTile;
+
+/**
+ * Class with the information about a tile of data.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class PxTileImpl extends PxTile {
+	private static final long    serialVersionUID = 1L;
+	private String               reference        = null;
+	private Rectangle2D          selection        = null;
+	private BufferDataSource[]   dataSource       = null;
+	
+	/**
+	 * Set size and position values
+	 * @param  x
+	 *         Upper left X position 
+	 * @param  y
+	 *         Upper left X position
+	 * @param  w
+	 *         Width
+	 * @param  h
+	 *         Height
+	 */
+	public PxTileImpl(int x, int y, int w, int h) {
+		super(x, y, w, h);
+	}
+	
+	/**
+	 * Set size, position values and a file reference
+	 * @param  x
+	 *         Upper left X position 
+	 * @param  y
+	 *         Upper left X position
+	 * @param  w
+	 *         Width
+	 * @param  h
+	 *         Height
+	 * @param  ref
+	 *         file reference
+	 */
+	public PxTileImpl(int x, int y, int w, int h, String ref) {
+		super(x, y, w, h);
+		this.reference = ref;
+	}
+	
+	/**
+	 * Get a interest area
+	 * @return Rectangle2D
+	 */
+	public Rectangle2D getAreaOfInterest() {
+		return selection;
+	}
+	
+	/**
+	 * Set a interest area
+	 * @param selection
+	 */
+	public void setAreaOfInterest(Rectangle2D selection) {
+		this.selection = selection;
+	}
+	
+	/**
+	 * Get the file reference
+	 * @return
+	 */
+	public String getReference() {
+		return reference;
+	}
+	
+	/**
+	 * Set the file reference
+	 * @param ref
+	 */
+	public void setReference(String ref) {
+		this.reference = ref;
+	}
+	
+	/**
+	 * Set the data source
+	 * @param dataSource
+	 */
+	public void setDataSource(BufferDataSource dataSource) {
+		this.dataSource = new BufferDataSource[]{dataSource};
+	}
+	
+	/**
+	 * Set the data source
+	 * @param dataSource
+	 */
+	public void setDataSource(BufferDataSource[] dataSource) {
+		this.dataSource = dataSource;
+	}
+
+	/**
+	 * Get the data source
+	 * @return
+	 */
+	public BufferDataSource getDataSource() {
+		if(dataSource != null && dataSource.length >= 1)
+			return dataSource[0];
+		return null;
+	}
+	
+	/**
+	 * Get the data source
+	 * @return
+	 */
+	public BufferDataSource[] getDataSourceList() {
+		return dataSource;
+	}
+	
+	/**
+	 * Show information for debug
+	 */
+	public void show() {
+		System.out.println("X:" + getX() + " Y:" + getY() + " W:" + getWidth() + " H:" + getHeight());
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/PxTileImpl.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/io/GdalWrite.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/io/GdalWrite.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/io/GdalWrite.java	(revision 3222)
@@ -0,0 +1,378 @@
+package org.gvsig.raster.cache.buffer.impl.io;
+
+import org.gvsig.jgdal.Gdal;
+import org.gvsig.jgdal.GdalBuffer;
+import org.gvsig.jgdal.GdalDriver;
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.jgdal.GdalRasterBand;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.impl.RasterBuffer;
+
+/**
+ * Escritor de datos tif. Esta clase escribe los datos de golpe con los m�todos write.
+ * Al terminar ha de hacerse un close al dataset.
+ * 
+ * 17/10/2008
+ * @author Nacho Brodin nachobrodin@gmail.com
+ */
+public class GdalWrite {
+	public static String                    COLOR_INTERP_GRAY       = "GRAY";
+	public static String                    COLOR_INTERP_RGB        = "RGB";
+	
+	private Gdal 							dataset                 = null;
+	private GdalBuffer[]					bufBands                = null;
+    private int                             w                       = 0;
+    private int                             h                       = 0;
+    private int                             nBands                  = 0;
+	private GdalRasterBand 					rband                   = null;
+	
+	/**
+	 * Constructor del escritor de TIFF
+	 * @param file Nombre del fichero de destino
+	 * @param nbands N�mero de bandas
+	 * @param dataType Tipo de datos
+	 * @param w Ancho
+	 * @param h Alto
+	 * @param colorInterp Interpretaci�n de color representada por las constantes de esta clase
+	 * @throws GdalException
+	 */
+	public GdalWrite(String file, int nbands, int dataType, int w, int h, String colorInterp) throws GdalException {
+    	this.w = w;
+    	this.h = h;
+    	this.nBands = nbands;
+    	
+		GdalDriver drv;
+		drv = Gdal.getDriverByName("GTiff");
+		
+		String[] paramList = new String[]{	"PHOTOMETRIC=" + colorInterp, 
+											"INTERLEAVE=BAND", 
+											"COMPRESS=NONE"};
+
+		dataset = drv.create(file, w, h, nbands, dataType, paramList);
+		
+		bufBands = new GdalBuffer[nBands];
+		for(int iBand = 0; iBand < nBands; iBand ++)
+			bufBands[iBand] = new GdalBuffer();
+	}
+	
+	/**
+	 * Writer for IRasterBand data.
+	 * @param IRasterBand.
+	 */
+	public void writeBands(Band[] band) {
+		for (int iBlock = 0; iBlock < band[0].getNumberOfBlocks(); iBlock++) {
+			int initX = band[0].isHorizontalBlock() ? 0 : (iBlock * band[0].getBlockSize());
+			int initY = band[0].isHorizontalBlock() ? (iBlock * band[0].getBlockSize()) : 0;
+			int wBlock = band[0].isHorizontalBlock() ? w : Math.min(band[0].getBlockSize(), w - (iBlock * band[0].getBlockSize()));
+			int hBlock = band[0].isHorizontalBlock() ? Math.min(band[0].getBlockSize(), h - (iBlock * band[0].getBlockSize())) : h;
+			
+			switch (band[0].getDataType()) {
+			case RasterBuffer.TYPE_BYTE:
+				for (int iBand = 0; iBand < band.length; iBand++) {
+					byte[][] b = band[iBand].getByteBlock(iBlock);
+					bufBands[iBand].buffByte = converByteMatrixBandToArray(b, wBlock, hBlock);	
+				}
+				for (int iBand = 0; iBand < band.length; iBand++) {
+					try {
+						rband = dataset.getRasterBand(iBand + 1);
+						rband.writeRaster(initX, 
+										initY, 
+										wBlock, 
+										hBlock, 
+										bufBands[iBand], 
+										Gdal.GDT_Byte);
+					} catch (GdalException e) {
+						//No se est� escribiendo ...
+						System.err.println("Error escribiendo");
+					}
+				}
+				break;
+			case RasterBuffer.TYPE_SHORT:
+				for (int iBand = 0; iBand < band.length; iBand++) {
+					short[][] b = band[iBand].getShortBlock(iBlock);
+					bufBands[iBand].buffShort = converShortMatrixBandToArray(b, wBlock, hBlock);	
+				}
+				for (int iBand = 0; iBand < band.length; iBand++){
+					try {
+						rband = dataset.getRasterBand(iBand + 1);
+						rband.writeRaster(initX, 
+										initY, 
+										wBlock, 
+										hBlock, 
+										bufBands[iBand], 
+										Gdal.GDT_Int16);
+					} catch (GdalException e) {
+						//No se est� escribiendo ...
+					}
+				}	
+				break;
+			case RasterBuffer.TYPE_INT:
+				for (int iBand = 0; iBand < band.length; iBand++) {
+					int[][] b = band[iBand].getIntBlock(iBlock);
+					bufBands[iBand].buffInt = converIntMatrixBandToArray(b, wBlock, hBlock);	
+				}
+				for (int iBand = 0; iBand < band.length; iBand++){
+					try {
+						rband = dataset.getRasterBand(iBand + 1);
+						rband.writeRaster(initX, 
+										initY, 
+										wBlock, 
+										hBlock, 
+										bufBands[iBand], 
+										Gdal.GDT_Int32);
+					} catch (GdalException e) {
+						//No se est� escribiendo ...
+					}
+				}	
+				break;
+			case RasterBuffer.TYPE_FLOAT:
+				for (int iBand = 0; iBand < band.length; iBand++) {
+					float[][] b = band[iBand].getFloatBlock(iBlock);
+					bufBands[iBand].buffFloat = converFloatMatrixBandToArray(b, wBlock, hBlock);	
+				}
+				for (int iBand = 0; iBand < band.length; iBand++){
+					try {
+						rband = dataset.getRasterBand(iBand + 1);
+						rband.writeRaster(initX, 
+										initY, 
+										wBlock, 
+										hBlock, 
+										bufBands[iBand], 
+										Gdal.GDT_Float32);
+					} catch (GdalException e) {
+						//No se est� escribiendo ...
+					}
+				}
+				break;
+			case RasterBuffer.TYPE_DOUBLE:
+				for (int iBand = 0; iBand < band.length; iBand++) {
+					double[][] b = band[iBand].getDoubleBlock(iBlock);
+					bufBands[iBand].buffDouble = converDoubleMatrixBandToArray(b, wBlock, hBlock);	
+				}
+				for (int iBand = 0; iBand < band.length; iBand++){
+					try {
+						rband = dataset.getRasterBand(iBand + 1);
+						rband.writeRaster(initX, 
+										initY, 
+										wBlock, 
+										hBlock, 
+										bufBands[iBand], 
+										Gdal.GDT_Float64);
+					} catch (GdalException e) {
+						//No se est� escribiendo ...
+					}
+				}
+				break;
+			}
+		}
+	}
+			
+	/**
+	 * Escritura de datos tipo Byte.
+	 * @param buf Buffer de datos.
+	 */
+	public void writeByteBands(byte[][] buf) {
+		for(int iBand = 0; iBand < nBands; iBand ++)
+			bufBands[iBand].buffByte = new byte[buf[iBand].length];
+
+		//Escribimos el bloque destino
+		for (int iBand = 0; iBand < buf.length; iBand++)
+			bufBands[iBand].buffByte = buf[iBand];
+
+		for (int iBand = 0; iBand < buf.length; iBand++){
+			try {
+				rband = dataset.getRasterBand(iBand + 1);
+				rband.writeRaster(0, 0, w, h, bufBands[iBand], Gdal.GDT_Byte);
+			} catch (GdalException e) {
+				//No se est� escribiendo ...
+			}
+		}
+	}
+
+	/**
+	 * Escritura de datos tipo Short.
+	 * @param buf Buffer de datos.
+	 */
+	public void writeShortBands(short[][] buf) {
+		for(int iBand = 0; iBand < nBands; iBand ++)
+			bufBands[iBand].buffShort = new short[buf[iBand].length];
+
+		//Escribimos el bloque destino
+		for (int iBand = 0; iBand < nBands; iBand++)
+			bufBands[iBand].buffShort = buf[iBand];
+
+		for (int iBand = 0; iBand < nBands; iBand++){
+			try {
+				rband = dataset.getRasterBand(iBand + 1);
+				rband.writeRaster(0, 0, w, h, bufBands[iBand], Gdal.GDT_Int16);
+			} catch (GdalException e) {
+				//No se est� escribiendo ...
+			}
+		}
+	}
+
+	/**
+	 * Escritura de datos tipo Int.
+	 * @param buf Buffer de datos.
+	 */
+	public void writeIntBands(int[][] buf) {
+		for(int iBand = 0; iBand < nBands; iBand ++)
+			bufBands[iBand].buffInt = new int[buf[iBand].length];
+
+		//Escribimos el bloque destino
+		for (int iBand = 0; iBand < buf.length; iBand++)
+			bufBands[iBand].buffInt = buf[iBand];
+
+		for (int iBand = 0; iBand < buf.length; iBand++){
+			try {
+				rband = dataset.getRasterBand(iBand + 1);
+				rband.writeRaster(0, 0, w, h, bufBands[iBand], Gdal.GDT_Int32);
+			} catch (GdalException e) {
+				//No se est� escribiendo ...
+			}
+		}
+	}
+
+	/**
+	 * Escritura de datos tipo Float.
+	 * @param buf Buffer de datos.
+	 */
+	public void writeFloatBands(float[][] buf) {
+		for(int iBand = 0; iBand < nBands; iBand ++)
+			bufBands[iBand].buffFloat = new float[buf[iBand].length];
+
+		//Escribimos el bloque destino
+		for (int iBand = 0; iBand < buf.length; iBand++)
+			bufBands[iBand].buffFloat = buf[iBand];
+
+		for (int iBand = 0; iBand < buf.length; iBand++){
+			try {
+				rband = dataset.getRasterBand(iBand + 1);
+				rband.writeRaster(0, 0, w, h, bufBands[iBand], Gdal.GDT_Float32);
+			} catch (GdalException e) {
+				//No se est� escribiendo ...
+			}
+		}
+	}
+
+	/**
+	 * Escritura de datos tipo Double.
+	 * @param buf Buffer de datos.
+	 */
+	public void writeDoubleBands(double[][] buf) {
+		for(int iBand = 0; iBand < nBands; iBand ++)
+			bufBands[iBand].buffDouble = new double[buf[iBand].length];
+
+		//Escribimos el bloque destino
+		for (int iBand = 0; iBand < buf.length; iBand++)
+			bufBands[iBand].buffDouble = buf[iBand];
+
+		for (int iBand = 0; iBand < buf.length; iBand++) {
+			try {
+				rband = dataset.getRasterBand(iBand + 1);
+				rband.writeRaster(0, 0, w, h, bufBands[iBand], Gdal.GDT_Float64);
+			} catch (GdalException e) {
+				//No se est� escribiendo ...
+			}
+		}
+	}
+	
+	/**
+	 * Closes the dataset. It's mandatory to do this operation when the writer finish.
+	 * @throws GdalException
+	 */
+	public void close() throws GdalException {
+		if(dataset != null)
+			dataset.close();
+	}
+	
+	/**
+	 * Convert a matrix band of byte data type in an array of data. 
+	 * The matrix band has nlines X mcolumns 
+	 * @param band Matrix band
+	 * @return Array band
+	 */
+	public byte[] converByteMatrixBandToArray(byte[][] band, int w, int h) {
+		byte[] b = new byte[w * h];
+		int cont = 0;
+		for (int i = 0; i < h; i++) {
+			for (int j = 0; j < w; j++) {
+				b[cont] = band[i][j];
+				cont ++;
+			}
+		}
+		return b;
+	}
+	
+	/**
+	 * Convert a matrix band of byte data type in an array of data. 
+	 * The matrix band has nlines X mcolumns 
+	 * @param band Matrix band
+	 * @return Array band
+	 */
+	public short[] converShortMatrixBandToArray(short[][] band, int w, int h) {
+		short[] b = new short[band.length * band[0].length];
+		int cont = 0;
+		for (int i = 0; i < h; i++) {
+			for (int j = 0; j < w; j++) {
+				b[cont] = band[i][j];
+				cont ++;
+			}
+		}
+		return b;
+	}
+	
+	/**
+	 * Convert a matrix band of byte data type in an array of data. 
+	 * The matrix band has nlines X mcolumns 
+	 * @param band Matrix band
+	 * @return Array band
+	 */
+	public int[] converIntMatrixBandToArray(int[][] band, int w, int h) {
+		int[] b = new int[band.length * band[0].length];
+		int cont = 0;
+		for (int i = 0; i < h; i++) {
+			for (int j = 0; j < w; j++) {
+				b[cont] = band[i][j];
+				cont ++;
+			}
+		}
+		return b;
+	}
+		
+	/**
+	 * Convert a matrix band of byte data type in an array of data. 
+	 * The matrix band has nlines X mcolumns 
+	 * @param band Matrix band
+	 * @return Array band
+	 */
+	public float[] converFloatMatrixBandToArray(float[][] band, int w, int h) {
+		float[] b = new float[band.length * band[0].length];
+		int cont = 0;
+		for (int i = 0; i < h; i++) {
+			for (int j = 0; j < w; j++) {
+				b[cont] = band[i][j];
+				cont ++;
+			}
+		}
+		return b;
+	}
+	
+	/**
+	 * Convert a matrix band of byte data type in an array of data. 
+	 * The matrix band has nlines X mcolumns 
+	 * @param band Matrix band
+	 * @return Array band
+	 */
+	public double[] converDoubleMatrixBandToArray(double[][] band, int w, int h) {
+		double[] b = new double[band.length * band[0].length];
+		int cont = 0;
+		for (int i = 0; i < h; i++) {
+			for (int j = 0; j < w; j++) {
+				b[cont] = band[i][j];
+				cont ++;
+			}
+		}
+		return b;
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/io/GdalWrite.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/io/GdalRead.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/io/GdalRead.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/io/GdalRead.java	(revision 3222)
@@ -0,0 +1,387 @@
+package org.gvsig.raster.cache.buffer.impl.io;
+
+
+import java.awt.geom.AffineTransform;
+import java.io.IOException;
+
+import org.gvsig.jgdal.Gdal;
+import org.gvsig.jgdal.GdalBuffer;
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.jgdal.GdalRasterBand;
+import org.gvsig.jgdal.GeoTransform;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+/**
+ * Lectura de datos de un TIFF de disco
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class GdalRead extends Gdal {
+	public 	GeoTransform                 trans = null;
+	public int                           width = 0, height = 0;
+	public double                        originX = 0D, originY = 0D;
+	protected int                        rBandNr = 1, gBandNr = 2, bBandNr = 3, aBandNr = 4;
+	private int                          dataType = 0;
+	protected GdalRasterBand[]           gdalBands = null;
+
+	/**
+	 * Estado de transparencia del raster.
+	 */
+	protected AffineTransform            ownTransformation = null;
+	private int                          nBands            = 0;
+	
+	
+	public GdalRead(String fName) throws GdalException, IOException {
+		super();
+		init(fName);
+	}
+	
+	/**
+	 * Acciones de inicializaci�n
+	 * @param fName
+	 * @throws GdalException
+	 * @throws IOException
+	 */
+	private void init(String fName) throws GdalException, IOException {
+		open(fName, GA_ReadOnly);
+		if (getPtro() == -1)
+			throw new GdalException("Error en la apertura del fichero. El fichero no tiene un formato v�lido.");
+
+		width = getRasterXSize();
+		height = getRasterYSize();
+		int[] dt = new int[getRasterCount()];
+		for (int i = 0; i < getRasterCount(); i++)
+			dt[i] = this.getRasterBand(i + 1).getRasterDataType();
+		nBands = getRasterCount();
+		dataType = dt[0];
+		
+
+		try {
+			trans = getGeoTransform();
+
+			boolean isCorrect = false;
+			for (int i = 0; i < trans.adfgeotransform.length; i++)
+				if (trans.adfgeotransform[i] != 0)
+					isCorrect = true;
+			if (!isCorrect)
+				throw new GdalException("");
+
+			ownTransformation = new AffineTransform(trans.adfgeotransform[1], trans.adfgeotransform[4], trans.adfgeotransform[2], trans.adfgeotransform[5], trans.adfgeotransform[0], trans.adfgeotransform[3]);
+		} catch (GdalException exc) {
+			// Transformaci�n para ficheros sin georreferenciaci�n. Se invierte la Y
+			// ya que las WC decrecen de
+			// arriba a abajo y los pixeles crecen de arriba a abajo
+			ownTransformation = new AffineTransform(1, 0, 0, -1, 0, height);
+		}
+	}
+	
+	/**
+	 * Conversi�n de los tipos de datos de gdal a los tipos de datos de RasterBuf
+	 * @param gdalType Tipo de dato de gdal
+	 * @return Tipo de dato de RasterBuf
+	 */
+	public int getRasterBufTypeFromGdalType(int gdalType) {
+		switch (gdalType) {
+			case 1:// Eight bit unsigned integer GDT_Byte = 1
+				return Buffer.TYPE_BYTE;
+
+			case 3:// Sixteen bit signed integer GDT_Int16 = 3,
+				return Buffer.TYPE_SHORT;
+
+			case 2:// Sixteen bit unsigned integer GDT_UInt16 = 2
+				//return RasterBuffer.TYPE_USHORT;
+				return Buffer.TYPE_SHORT; //Apa�o para usar los tipos de datos que soportamos
+
+			case 5:// Thirty two bit signed integer GDT_Int32 = 5
+				return Buffer.TYPE_INT;
+
+			case 6:// Thirty two bit floating point GDT_Float32 = 6
+				return Buffer.TYPE_FLOAT;
+
+			case 7:// Sixty four bit floating point GDT_Float64 = 7
+				return Buffer.TYPE_DOUBLE;
+
+				// TODO:Estos tipos de datos no podemos gestionarlos. Habria que definir
+				// el tipo complejo y usar el tipo long que de momento no se gasta.
+			case 4:// Thirty two bit unsigned integer GDT_UInt32 = 4,
+				return Buffer.TYPE_INT;
+				//return RasterBuffer.TYPE_UNDEFINED; // Deberia devolver un Long
+
+			case 8:// Complex Int16 GDT_CInt16 = 8
+			case 9:// Complex Int32 GDT_CInt32 = 9
+			case 10:// Complex Float32 GDT_CFloat32 = 10
+			case 11:// Complex Float64 GDT_CFloat64 = 11
+				return Buffer.TYPE_UNDEFINED;
+		}
+		return Buffer.TYPE_UNDEFINED;
+	}
+	
+	/**
+	 * Conversi�n de los tipos de datos de gdal a los tipos de datos de RasterBuf
+	 * @param gdalType Tipo de dato de gdal
+	 * @return Tipo de dato de RasterBuf
+	 */
+	public int getGdalTypeFromRasterBufType(int rasterBufType) {
+		switch (rasterBufType) {
+			case Buffer.TYPE_BYTE: return Gdal.GDT_Byte;
+			case Buffer.TYPE_USHORT: return Gdal.GDT_UInt16;
+			case Buffer.TYPE_SHORT: return Gdal.GDT_Int16;
+			case Buffer.TYPE_INT: return Gdal.GDT_Int32;
+			case Buffer.TYPE_FLOAT: return Gdal.GDT_Float32;
+			case Buffer.TYPE_DOUBLE: return Gdal.GDT_Float64;
+			case Buffer.TYPE_UNDEFINED: return Gdal.GDT_Unknown;
+		}
+		return Gdal.GDT_Unknown;
+	}
+	
+	/**
+	 * Obtiene el anchura del raster
+	 * @return
+	 */
+	public int getWidth() { 
+		return this.width;
+	}
+	
+	/**
+	 * Obtiene la altura del raster
+	 * @return 
+	 */
+	public int getHeight() { 
+		return this.height;
+	}
+	
+	/**
+	 * Obtiene el flag que informa de si el raster tiene valor no data o no.
+	 * Consultar� todas las bandas del mismo y si alguna tiene valor no data
+	 * devuelve true sino devolver� false.
+	 * @return true si tiene valor no data y false si no lo tiene
+	 * @throws GdalException
+	 */
+	public boolean existsNoDataValue() throws GdalException {
+		for (int i = 0; i < getRasterCount(); i++) {
+			GdalRasterBand rb = getRasterBand(i + 1);
+			if (rb.existsNoDataValue())
+				return true;
+		}
+		return false;
+	}
+	
+	/**
+	 * Obtiene el flag que informa de si el raster tiene valor no data o no
+	 * en una banda concreta.
+	 * @return true si tiene valor no data en esa banda y false si no lo tiene
+	 * @param band Posici�n de la banda a consultar (0..n)
+	 * @throws GdalException
+	 */
+	public boolean existsNoDataValue(int band) throws GdalException {
+		GdalRasterBand rb = getRasterBand(band + 1);
+		return rb.existsNoDataValue();
+	}
+	
+	/**
+	 * Obtiene el tipo de dato
+	 * @return entero que representa el tipo de dato
+	 */
+	public int getDataType() { 
+		return dataType; 
+	}
+	
+	/**
+	 * Obtiene el n�mero de bandas
+	 * @return
+	 */
+	public int getBandCount() {
+		return nBands;
+	}
+	
+	/**
+	 * Lee una bloque completo del raster y devuelve un array tridimensional del tipo correcto. Esta funci�n es util
+	 * para una lectura rapida de todo el fichero sin necesidad de asignar vista. 
+	 * @param nLine N�mero de l�nea a leer
+	 * @param band Banda requerida
+	 * @return Object que es un array unidimendional del tipo de datos del raster
+	 * @throws GdalException
+	 */
+	public Object readBlock(int posX, int posY, int blockWidth, int blockHeight) throws GdalException, ProcessInterruptedException {
+		bBandNr = super.getRasterCount();
+				
+		GdalRasterBand[] gdalBand = new GdalRasterBand[bBandNr];
+		for (int iBand = 0; iBand < gdalBand.length; iBand++) 
+			gdalBand[iBand] = super.getRasterBand(iBand + 1);
+				
+		GdalBuffer[] gdalBuf = new GdalBuffer[bBandNr];
+				
+		if (dataType == GDT_Byte) {
+			byte[][][] buf = new byte[bBandNr][blockHeight][getRasterXSize()];
+			for (int iBand = 0; iBand < gdalBuf.length; iBand++) {
+				gdalBuf[iBand] = gdalBand[iBand].readRaster(posX, posY, blockWidth, blockHeight, blockWidth, blockHeight, dataType);
+				for (int iRow = 0; iRow < blockHeight; iRow++) {
+					for (int iCol = 0; iCol < blockWidth; iCol++) 
+						buf[iBand][iRow][iCol] = gdalBuf[iBand].buffByte[iRow * blockWidth + iCol];
+				}
+			}	
+			return buf;
+		} else if (dataType == GDT_CInt16 || dataType == GDT_Int16  || dataType == GDT_UInt16) {
+			short[][][] buf = new short[bBandNr][blockHeight][getRasterXSize()];
+			for (int iBand = 0; iBand < gdalBuf.length; iBand++) {
+				gdalBuf[iBand] = gdalBand[iBand].readRaster(posX, posY, blockWidth, blockHeight, blockWidth, blockHeight, dataType);
+				for (int iRow = 0; iRow < blockHeight; iRow++) {
+					for (int iCol = 0; iCol < blockWidth; iCol++) 
+						buf[iBand][iRow][iCol] = gdalBuf[iBand].buffShort[iRow * blockWidth + iCol];
+				}
+			}	
+			return buf;
+		} else if (dataType == GDT_CInt32 || dataType == GDT_Int32  || dataType == GDT_UInt32) {
+			int[][][] buf = new int[bBandNr][blockHeight][getRasterXSize()];
+			for (int iBand = 0; iBand < gdalBuf.length; iBand++) {
+				gdalBuf[iBand] = gdalBand[iBand].readRaster(posX, posY, blockWidth, blockHeight, blockWidth, blockHeight, dataType);
+				for (int iRow = 0; iRow < blockHeight; iRow++) { 
+					for (int iCol = 0; iCol < blockWidth; iCol++)
+						buf[iBand][iRow][iCol] = gdalBuf[iBand].buffInt[iRow * blockWidth + iCol];
+				}
+			}	
+			return buf;
+		} else if(dataType == GDT_Float32 || dataType == GDT_CFloat32) {
+			float[][][] buf = new float[bBandNr][blockHeight][getRasterXSize()];
+			for (int iBand = 0; iBand < gdalBuf.length; iBand++) {
+				gdalBuf[iBand] = gdalBand[iBand].readRaster(posX, posY, blockWidth, blockHeight, blockWidth, blockHeight, dataType);
+				for (int iRow = 0; iRow < blockHeight; iRow++) {
+					for (int iCol = 0; iCol < blockWidth; iCol++)
+						buf[iBand][iRow][iCol] = gdalBuf[iBand].buffFloat[iRow * blockWidth + iCol];
+				}
+			}	
+			return buf;
+		} else if(dataType == GDT_Float64 || dataType == GDT_CFloat64) {
+			double[][][] buf = new double[bBandNr][blockHeight][getRasterXSize()];
+			for (int iBand = 0; iBand < gdalBuf.length; iBand++) {
+				gdalBuf[iBand] = gdalBand[iBand].readRaster(posX, posY, blockWidth, blockHeight, blockWidth, blockHeight, dataType);
+				for (int iRow = 0; iRow < blockHeight; iRow++) {
+					for (int iCol = 0; iCol < blockWidth; iCol++) 
+						buf[iBand][iRow][iCol] = gdalBuf[iBand].buffDouble[iRow * blockWidth + iCol];
+				}
+			}		
+			return buf;
+		}
+		return null;
+	}
+	
+	/**
+	 * Lee una bloque completo del raster y devuelve un array tridimensional del tipo correcto. Esta funci�n es util
+	 * para una lectura rapida de todo el fichero sin necesidad de asignar vista. 
+	 * @param nLine N�mero de l�nea a leer
+	 * @param band Banda requerida
+	 * @return Object que es un array unidimendional del tipo de datos del raster
+	 * @throws GdalException
+	 */
+	public Object readBlock(int posX, int posY, int blockWidth, int blockHeight, int iBand) throws GdalException, ProcessInterruptedException {
+				
+		GdalRasterBand gdalBand = null;
+		gdalBand = super.getRasterBand(iBand + 1);
+				
+		GdalBuffer gdalBuf = null;
+				
+		if (dataType == GDT_Byte) {
+			byte[][] buf = new byte[blockHeight][blockWidth];
+				gdalBuf = gdalBand.readRaster(posX, posY, blockWidth, blockHeight, blockWidth, blockHeight, dataType);
+				for (int iRow = 0; iRow < blockHeight; iRow++) {
+					for (int iCol = 0; iCol < blockWidth; iCol++) 
+						buf[iRow][iCol] = gdalBuf.buffByte[iRow * blockWidth + iCol];
+				}
+			return buf;
+		} else if (dataType == GDT_CInt16 || dataType == GDT_Int16  || dataType == GDT_UInt16) {
+			short[][] buf = new short[blockHeight][blockWidth];
+				gdalBuf = gdalBand.readRaster(posX, posY, blockWidth, blockHeight, blockWidth, blockHeight, dataType);
+				for (int iRow = 0; iRow < blockHeight; iRow++) {
+					for (int iCol = 0; iCol < blockWidth; iCol++) 
+						buf[iRow][iCol] = gdalBuf.buffShort[iRow * blockWidth + iCol];
+				}
+			return buf;
+		} else if (dataType == GDT_CInt32 || dataType == GDT_Int32  || dataType == GDT_UInt32) {
+			int[][] buf = new int[blockHeight][blockWidth];
+				gdalBuf = gdalBand.readRaster(posX, posY, blockWidth, blockHeight, blockWidth, blockHeight, dataType);
+				for (int iRow = 0; iRow < blockHeight; iRow++) { 
+					for (int iCol = 0; iCol < blockWidth; iCol++)
+						buf[iRow][iCol] = gdalBuf.buffInt[iRow * blockWidth + iCol];
+				}
+			return buf;
+		} else if(dataType == GDT_Float32 || dataType == GDT_CFloat32) {
+			float[][] buf = new float[blockHeight][blockWidth];
+				gdalBuf = gdalBand.readRaster(posX, posY, blockWidth, blockHeight, blockWidth, blockHeight, dataType);
+				for (int iRow = 0; iRow < blockHeight; iRow++) {
+					for (int iCol = 0; iCol < blockWidth; iCol++)
+						buf[iRow][iCol] = gdalBuf.buffFloat[iRow * blockWidth + iCol];
+				}
+			return buf;
+		} else if(dataType == GDT_Float64 || dataType == GDT_CFloat64) {
+			double[][] buf = new double[blockHeight][blockWidth];
+				gdalBuf = gdalBand.readRaster(posX, posY, blockWidth, blockHeight, blockWidth, blockHeight, dataType);
+				for (int iRow = 0; iRow < blockHeight; iRow++) {
+					for (int iCol = 0; iCol < blockWidth; iCol++) 
+						buf[iRow][iCol] = gdalBuf.buffDouble[iRow * blockWidth + iCol];
+				}
+			return buf;
+		}
+		return null;
+	}
+	
+	/**
+	 * Lee una bloque completo del raster y devuelve un array tridimensional del tipo correcto. Esta funci�n es util
+	 * para una lectura rapida de todo el fichero sin necesidad de asignar vista. 
+	 * @param nLine N�mero de l�nea a leer
+	 * @param band Banda requerida
+	 * @return Object que es un array unidimendional del tipo de datos del raster
+	 * @throws GdalException
+	 */
+	public Object readData(int posX, int posY, int blockWidth, int blockHeight) throws GdalException, InterruptedException {
+		bBandNr = super.getRasterCount();
+				
+		GdalRasterBand[] gdalBand = new GdalRasterBand[bBandNr];
+		for (int iBand = 0; iBand < gdalBand.length; iBand++) 
+			gdalBand[iBand] = super.getRasterBand(iBand + 1);
+				
+		GdalBuffer[] gdalBuf = new GdalBuffer[bBandNr];
+				
+		if (dataType == GDT_Byte) {
+			byte[][] buf = new byte[bBandNr][];
+			for (int iBand = 0; iBand < gdalBuf.length; iBand++) {
+				gdalBuf[iBand] = gdalBand[iBand].readRaster(posX, posY, blockWidth, blockHeight, blockWidth, blockHeight, dataType);
+				buf[iBand] = gdalBuf[iBand].buffByte;	
+			}	
+			return buf;
+		} else if (dataType == GDT_CInt16 || dataType == GDT_Int16  || dataType == GDT_UInt16) {
+			short[][] buf = new short[bBandNr][];
+			for (int iBand = 0; iBand < gdalBuf.length; iBand++) {
+				gdalBuf[iBand] = gdalBand[iBand].readRaster(posX, posY, blockWidth, blockHeight, blockWidth, blockHeight, dataType);
+				buf[iBand] = gdalBuf[iBand].buffShort;
+			}	
+			return buf;
+		} else if (dataType == GDT_CInt32 || dataType == GDT_Int32  || dataType == GDT_UInt32) {
+			int[][] buf = new int[bBandNr][];
+			for (int iBand = 0; iBand < gdalBuf.length; iBand++) {
+				gdalBuf[iBand] = gdalBand[iBand].readRaster(posX, posY, blockWidth, blockHeight, blockWidth, blockHeight, dataType);
+				buf[iBand] = gdalBuf[iBand].buffInt;
+			}	
+			return buf;
+		} else if(dataType == GDT_Float32 || dataType == GDT_CFloat32) {
+			float[][] buf = new float[bBandNr][];
+			for (int iBand = 0; iBand < gdalBuf.length; iBand++) {
+				gdalBuf[iBand] = gdalBand[iBand].readRaster(posX, posY, blockWidth, blockHeight, blockWidth, blockHeight, dataType);
+				buf[iBand] = gdalBuf[iBand].buffFloat;
+			}	
+			return buf;
+		} else if(dataType == GDT_Float64 || dataType == GDT_CFloat64) {
+			double[][] buf = new double[bBandNr][];
+			for (int iBand = 0; iBand < gdalBuf.length; iBand++) {
+				gdalBuf[iBand] = gdalBand[iBand].readRaster(posX, posY, blockWidth, blockHeight, blockWidth, blockHeight, dataType);
+				buf[iBand] = gdalBuf[iBand].buffDouble;
+			}		
+			return buf;
+		}
+				
+			return null;
+	}
+		
+}
+
+
+
+

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/io/GdalRead.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/io/BufferDataSourceImpl.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/io/BufferDataSourceImpl.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/io/BufferDataSourceImpl.java	(revision 3222)
@@ -0,0 +1,462 @@
+package org.gvsig.raster.cache.buffer.impl.io;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.PxTile;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.PxTileImpl;
+import org.gvsig.raster.cache.buffer.impl.RasterBase;
+
+/**
+ * Data Server for read only buffers.
+ * 
+ * @author Nacho Brodin nachobrodin@gmail.com
+ */
+public class BufferDataSourceImpl extends RasterBase implements BufferDataSource {
+	private GdalRead        reader        = null;
+	private String          path          = null;
+	private PxTile          window        = null;  
+	private int             selectedBand  = -1;
+		
+	/**
+	 * This constructor is useful to use this class with a image reference.
+	 * Typically ReadOnlyCache   
+	 * @param  path
+	 *         Path to the file
+	 * @throws IOException
+	 */
+	public BufferDataSourceImpl(String path) throws IOException {
+		super(0, 0, 0, 0); //Se asignan los par�metros despues de construir el tiff
+		this.path = path;
+		
+		try {
+			reader = new GdalRead(path);
+		} catch (GdalException e) {
+			throw new IOException();
+		}
+		super.setWidth(reader.getWidth());
+		super.setHeight(reader.getHeight());
+		super.setDataType(reader.getRasterBufTypeFromGdalType(reader.getDataType()));
+		super.setBandCount(reader.getBandCount());
+		window = new PxTileImpl(0, 0, reader.getWidth(), reader.getHeight());
+	}
+	
+	/**
+	 * This constructor is useful to use this class with a image reference
+	 * .Typically ReadOnlyCache. 
+	 * @param  path
+	 *         Path to the file
+	 * @throws IOException
+	 */
+	public BufferDataSourceImpl(String path, PxTileImpl window) throws IOException {
+		super(window.getX(), window.getY(), 0, 0); //Se asignan los par�metros despues de construir el tiff
+		this.path = path;
+		this.window = window;
+		
+		try {
+			reader = new GdalRead(path);
+		} catch (GdalException e) {
+			throw new IOException();
+		}
+		super.setWidth(window.getWidth());
+		super.setHeight(window.getHeight());
+		super.setDataType(reader.getRasterBufTypeFromGdalType(reader.getDataType()));
+		super.setBandCount(reader.getBandCount());
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.cachete.buffer.IBufferDataSource#close()
+	 */
+	public void close() throws IOException {
+		if(reader != null)
+			try {
+				reader.close();
+				reader = null;
+			} catch (GdalException e) {
+				throw new IOException();
+			}
+	}
+	
+	/**
+	 * This constructor is useful to use this class without a image reference. 
+	 * Typically StripeCache    
+	 * @throws IOException
+	 */
+	public BufferDataSourceImpl() {
+		super(0, 0, 0, 0);
+	}
+		
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.BufferDataSource#getPath()
+	 */
+	public String[] getPath() {
+		return new String[]{path};
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.BufferDataSource#setPath(java.lang.String[])
+	 */
+	public void setPath(String[] path) {
+		if(path != null && path.length >= 1)
+			this.path = path[0];
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.BufferDataSource#setPath(java.lang.String)
+	 */
+	public void setPath(String path) {
+		this.path = path;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.rocache.ICacheDataSource#getBand()
+	 */
+	public int getSelectedBand() {
+		return this.selectedBand;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.rocache.ICacheDataSource#setBand(java.lang.String)
+	 */
+	public void setSelectedBand(int selectedBand) {
+		this.selectedBand = selectedBand;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.rocache.ICacheDataSource#loadSelectedBand(org.gvsig.raster.buffer.IRasterBuffer, org.gvsig.raster.buffer.rocache.ReadOnlyStripe)
+	 */
+	public void loadSelectedBand(Buffer rb, PxTile stripe) 
+		throws IOException, ProcessInterruptedException, OperationNotSupportedException {
+		loadPage(rb, stripe, selectedBand);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.rocache.ICacheDataSource#loadPage(org.gvsig.raster.buffer.IRasterBuffer, org.gvsig.raster.buffer.rocache.ReadOnlyStripe)
+	 */
+	public void loadPage(Buffer rb, PxTile stripe) throws IOException, OperationNotSupportedException, ProcessInterruptedException {
+		try {
+			Object dataObj = reader.readBlock((int)stripe.getX() + window.getX(), (int)stripe.getY() + window.getY(), (int)stripe.getWidth(), (int)stripe.getHeight());
+			if (reader.getDataType() == GdalRead.GDT_Byte) {
+				byte[][][] buf = (byte[][][])dataObj;
+				for (int iBand = 0; iBand < buf.length; iBand++) 
+					for (int iLine = 0; iLine < buf[iBand].length; iLine++) 
+						for (int iColumn = 0; iColumn < buf[iBand][iLine].length; iColumn++) 
+							rb.setElem(iLine, iColumn, iBand, buf[iBand][iLine][iColumn]);
+										
+			} else if (reader.getDataType() == GdalRead.GDT_CInt16 || reader.getDataType() == GdalRead.GDT_Int16  || reader.getDataType() == GdalRead.GDT_UInt16) {
+				short[][][] buf = (short[][][])dataObj;
+				for (int iBand = 0; iBand < buf.length; iBand++) 
+					for (int iLine = 0; iLine < buf[iBand].length; iLine++) 
+						for (int iColumn = 0; iColumn < buf[iBand][iLine].length; iColumn++) 
+							rb.setElem(iLine, iColumn, iBand, buf[iBand][iLine][iColumn]);
+							
+			} else if (reader.getDataType() == GdalRead.GDT_CInt32 || reader.getDataType() == GdalRead.GDT_Int32  || reader.getDataType() == GdalRead.GDT_UInt32) {
+				int[][][] buf = (int[][][])dataObj;
+				for (int iBand = 0; iBand < buf.length; iBand++) 
+					for (int iLine = 0; iLine < buf[iBand].length; iLine++) 
+						for (int iColumn = 0; iColumn < buf[iBand][iLine].length; iColumn++) 
+							rb.setElem(iLine, iColumn, iBand, buf[iBand][iLine][iColumn]);
+							
+			} else if(reader.getDataType() == GdalRead.GDT_Float32 || reader.getDataType() == GdalRead.GDT_CFloat32) {
+				float[][][] buf = (float[][][])dataObj;
+				for (int iBand = 0; iBand < buf.length; iBand++) 
+					for (int iLine = 0; iLine < buf[iBand].length; iLine++) 
+						for (int iColumn = 0; iColumn < buf[iBand][iLine].length; iColumn++) 
+							rb.setElem(iLine, iColumn, iBand, buf[iBand][iLine][iColumn]);
+							
+			} else if(reader.getDataType() == GdalRead.GDT_Float64 || reader.getDataType() == GdalRead.GDT_CFloat64) {
+				double[][][] buf = (double[][][])dataObj;
+				for (int iBand = 0; iBand < buf.length; iBand++) 
+					for (int iLine = 0; iLine < buf[iBand].length; iLine++) 
+						for (int iColumn = 0; iColumn < buf[iBand][iLine].length; iColumn++) 
+							rb.setElem(iLine, iColumn, iBand, buf[iBand][iLine][iColumn]);
+							
+			}
+		} catch (GdalException e) {
+			throw new IOException("Error reading block.");
+		}
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.rocache.ICacheDataSource#loadPage(org.fv.raster.buffer.IRasterBuffer, org.fv.raster.buffer.rocache.ReadOnlyStripe, int)
+	 */
+	public void loadPage(Buffer rb, PxTile stripe, int iBand) throws IOException, ProcessInterruptedException, OperationNotSupportedException {
+		if(rb.getBandCount() != 1)
+			throw new IOException("Wrong buffer");
+		
+		try {
+			Object dataObj = reader.readBlock((int)stripe.getX() + window.getX(), (int)stripe.getY() + window.getY(), (int)stripe.getWidth(), (int)stripe.getHeight(), iBand);
+			if (reader.getDataType() == GdalRead.GDT_Byte) {
+				byte[][] buf = (byte[][])dataObj;
+				for (int iLine = 0; iLine < buf.length; iLine++) 
+					for (int iColumn = 0; iColumn < buf[iLine].length; iColumn++) 
+						rb.setElem(iLine, iColumn, 0, buf[iLine][iColumn]);
+
+			} else if (reader.getDataType() == GdalRead.GDT_CInt16 || reader.getDataType() == GdalRead.GDT_Int16  || reader.getDataType() == GdalRead.GDT_UInt16) {
+				short[][] buf = (short[][])dataObj;
+				for (int iLine = 0; iLine < buf.length; iLine++) 
+					for (int iColumn = 0; iColumn < buf[iLine].length; iColumn++) 
+						rb.setElem(iLine, iColumn, 0, buf[iLine][iColumn]);
+
+			} else if (reader.getDataType() == GdalRead.GDT_CInt32 || reader.getDataType() == GdalRead.GDT_Int32  || reader.getDataType() == GdalRead.GDT_UInt32) {
+				int[][] buf = (int[][])dataObj;
+				for (int iLine = 0; iLine < buf.length; iLine++) 
+					for (int iColumn = 0; iColumn < buf[iLine].length; iColumn++) 
+						rb.setElem(iLine, iColumn, 0, buf[iLine][iColumn]);
+
+			} else if(reader.getDataType() == GdalRead.GDT_Float32 || reader.getDataType() == GdalRead.GDT_CFloat32) {
+				float[][] buf = (float[][])dataObj;
+				for (int iLine = 0; iLine < buf.length; iLine++) 
+					for (int iColumn = 0; iColumn < buf[iLine].length; iColumn++) 
+						rb.setElem(iLine, iColumn, iBand, buf[iLine][iColumn]);
+
+			} else if(reader.getDataType() == GdalRead.GDT_Float64 || reader.getDataType() == GdalRead.GDT_CFloat64) {
+				double[][] buf = (double[][])dataObj;
+				for (int iLine = 0; iLine < buf.length; iLine++) 
+					for (int iColumn = 0; iColumn < buf[iLine].length; iColumn++) 
+						rb.setElem(iLine, iColumn, 0, buf[iLine][iColumn]);
+
+			}
+		} catch (GdalException e) {
+			throw new IOException("Error reading block.");
+		}
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.gvsig.fmap.dataaccess.cache.ICacheDataSource#loadPage(int, org.gvsig.fmap.dataaccess.cache.PageBuffer)
+	 */
+	public void loadPage(Buffer buf, String inFileName) {
+		for (int i = 0; i < buf.getBandCount(); i++) 
+			loadBand(buf.getBand(i), inFileName + i);
+	}
+	
+	/**
+	 * Load a band from hard disk
+	 * @param pageBuffer
+	 * @param inFileName
+	 */
+	public void loadBand(Band pageBuffer, String inFileName) {
+		File file = new File(inFileName);
+		if (!file.exists())
+			return;
+
+		try {
+			FileInputStream fis = new FileInputStream(file);
+			BufferedInputStream bis = new BufferedInputStream(fis);
+			DataInputStream dis = new DataInputStream(bis);
+			read(dis, pageBuffer);
+			fis.close();
+			bis.close();
+			dis.close();
+		} catch (FileNotFoundException e) {
+			return;
+		} catch (IOException ex) {
+			// TODO: EXCEPTION: Lanzar IO y FileNotFound
+			ex.printStackTrace();
+			return;
+		}  catch (OperationNotSupportedException ex) {
+			ex.printStackTrace();
+			return;
+		}
+	}
+
+	/* (non-Javadoc)
+	 * @see org.gvsig.fmap.dataaccess.cache.ICacheDataSource#savePage(int, org.gvsig.fmap.dataaccess.cache.PageBuffer)
+	 */
+	public void savePage(Buffer buf, String fileName) throws IOException {
+		for (int i = 0; i < buf.getBandCount(); i++)
+			saveBand(buf.getBand(i), fileName + i);
+	}
+
+	/**
+	 * Save a band to hard disk
+	 * @param pageBuffer
+	 * @param fileName
+	 * @throws IOException
+	 */
+	public void saveBand(Band pageBuffer, String fileName) throws IOException {
+		File f = new File(fileName);
+		FileOutputStream fos = new FileOutputStream(f);
+		BufferedOutputStream bos = new BufferedOutputStream(fos);
+		DataOutputStream dos = new DataOutputStream(bos);
+		save(dos, pageBuffer);
+		dos.close();
+		bos.close();
+		fos.close();
+	}
+		
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.dataaccess.cache.ICacheDataSource#delete()
+	 */
+	public void delete(String fileName) {
+		File f = new File(fileName);
+		if (f.exists()) {
+			f.delete();
+		}
+	}
+		
+	/**
+	 * Salva un PageBuffer sobre un stream DataOutpuStream dependiendo del tipo de dato del 
+	 * buffer.
+	 * @param dos DataOutputStream 
+	 * @param pageBuffer PageBuffer
+	 * @throws IOException
+	 */
+	private void save(DataOutputStream dos, Band pageBuffer) throws IOException {
+		switch (pageBuffer.getDataType()) {
+			case Buffer.TYPE_BYTE:
+				try {
+					for (int line = 0; line < pageBuffer.getHeight(); line++)
+						dos.write(pageBuffer.getByteLine(line));
+				} catch (OperationNotSupportedException e) {
+					for (int line = 0; line < pageBuffer.getHeight(); line++)
+						for (int col = 0; col < pageBuffer.getWidth(); col++)
+							dos.writeByte(pageBuffer.getElemByte(line, col));
+				}
+				break;
+			case Buffer.TYPE_SHORT:
+				for (int line = 0; line < pageBuffer.getHeight(); line++)
+					for (int col = 0; col < pageBuffer.getWidth(); col++)
+						dos.writeShort(pageBuffer.getElemShort(line, col));
+				break;
+			case Buffer.TYPE_INT:
+				for (int line = 0; line < pageBuffer.getHeight(); line++)
+					for (int col = 0; col < pageBuffer.getWidth(); col++)
+						dos.writeInt(pageBuffer.getElemInt(line, col));
+				break;
+			case Buffer.TYPE_FLOAT:
+				for (int line = 0; line < pageBuffer.getHeight(); line++)
+					for (int col = 0; col < pageBuffer.getWidth(); col++)
+						dos.writeFloat(pageBuffer.getElemFloat(line, col));
+				break;
+			case Buffer.TYPE_DOUBLE:
+				for (int line = 0; line < pageBuffer.getHeight(); line++)
+					for (int col = 0; col < pageBuffer.getWidth(); col++)
+						dos.writeDouble(pageBuffer.getElemDouble(line, col));
+				break;
+		}
+	}
+	
+	/**
+	 * Carga un PageBuffer desde un stream DataInputStream dependiendo del tipo de dato del 
+	 * buffer.
+	 * @param dis DataInputStream
+	 * @param pageBuffer PageBuffer
+	 * @throws IOException
+	 * @throws OperationNotSupportedException 
+	 */
+	private void read(DataInputStream dis, Band pageBuffer) throws IOException, OperationNotSupportedException {
+		int w = pageBuffer.getWidth();
+		int j = 0;
+		switch (pageBuffer.getDataType()) {
+		case Buffer.TYPE_BYTE:
+			byte[] b = new byte[pageBuffer.getWidth() * pageBuffer.getHeight()];
+			dis.readFully(b);
+			for (int line = 0; line < pageBuffer.getHeight(); line++) {
+				byte[] linea = new byte[w];
+				for (int d = 0; d < linea.length; d++)
+					linea[d] = b[(line * w) + d];
+				pageBuffer.setByteLine(linea, line);
+			}
+			break;
+		case Buffer.TYPE_SHORT:
+			short[] s = new short[pageBuffer.getWidth() * pageBuffer.getHeight()];
+			while (j < s.length) {
+				s[j] = dis.readShort();
+				j++;
+			}
+			for (int line = 0; line < pageBuffer.getHeight(); line++) {
+				short[] linea = new short[w];
+				for (int x = 0; x < linea.length; x++)
+					linea[x] = s[(line * w) + x];
+				pageBuffer.setShortLine(linea, line);
+			}
+			break;
+		case Buffer.TYPE_INT:
+			int[] i = new int[pageBuffer.getWidth() * pageBuffer.getHeight()];
+			while (j < i.length) {
+				i[j] = dis.readInt();
+				j++;
+			}
+			for (int line = 0; line < pageBuffer.getHeight(); line++) {
+				int[] linea = new int[w];
+				for (int x = 0; x < linea.length; x++)
+					linea[x] = i[(line * w) + x];
+				pageBuffer.setIntLine(linea, line);
+			}
+			break;
+		case Buffer.TYPE_FLOAT:
+			float[] f = new float[pageBuffer.getWidth() * pageBuffer.getHeight()];
+			while (j < f.length) {
+				f[j] = dis.readFloat();
+				j++;
+			}
+			for (int line = 0; line < pageBuffer.getHeight(); line++) {
+				float[] linea = new float[w];
+				for (int x = 0; x < linea.length; x++)
+					linea[x] = f[(line * w) + x];
+				pageBuffer.setFloatLine(linea, line);
+			}
+			break;
+		case Buffer.TYPE_DOUBLE:
+			double[] d = new double[pageBuffer.getWidth() * pageBuffer.getHeight()];
+			while (j < d.length) {
+				d[j] = dis.readDouble();
+				j++;
+			}
+			for (int line = 0; line < pageBuffer.getHeight(); line++) {
+				double[] linea = new double[w];
+				for (int x = 0; x < linea.length; x++)
+					linea[x] = d[(line * w) + x];
+				pageBuffer.setDoubleLine(linea, line);
+			}
+			break;
+		}
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.stripecache.ICacheDataSource#changeFileName(java.lang.String, java.lang.String)
+	 */
+	public void changeFileName(String oldName, String newName) {
+		File f1 = new File(oldName);
+		f1.renameTo(new File(newName));
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see java.lang.Object#clone()
+	 */
+	public BufferDataSource clone() {
+		try {
+			BufferDataSourceImpl result = new BufferDataSourceImpl(path, (PxTileImpl)window);
+			result.selectedBand = selectedBand;
+			return result;
+		} catch (IOException e) {
+			return null;
+		}
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/io/BufferDataSourceImpl.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/io/BufferMultiDataSourceImpl.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/io/BufferMultiDataSourceImpl.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/io/BufferMultiDataSourceImpl.java	(revision 3222)
@@ -0,0 +1,320 @@
+package org.gvsig.raster.cache.buffer.impl.io;
+
+import java.io.IOException;
+
+import org.gvsig.jgdal.GdalException;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferDataSource;
+import org.gvsig.raster.cache.buffer.PxTile;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.impl.PxTileImpl;
+
+/**
+ * Data Server for read only buffers. 
+ * 
+ * @author Nacho Brodin nachobrodin@gmail.com
+ */
+public class BufferMultiDataSourceImpl extends BufferDataSourceImpl implements BufferDataSource {
+	private GdalRead[]      reader        = null;
+	private String[]        path          = null;
+	private PxTile          window        = null;  
+	private int             selectedBand  = -1;
+		
+	/**
+	 * This constructor is useful to use this class with a image reference.
+	 * Typically ReadOnlyCache   
+	 * @param  path
+	 *         Path to the file
+	 * @throws IOException
+	 */
+	public BufferMultiDataSourceImpl(String[] path) throws IOException {
+		this.path = path;
+		reader = new GdalRead[path.length];
+		int bandCount = 0;
+		
+		try {
+			for (int i = 0; i < path.length; i++) {
+				reader[i] = new GdalRead(path[i]);
+				bandCount += reader[i].getBandCount();
+			}
+		} catch (GdalException e) {
+			throw new IOException();
+		}
+		super.setWidth(reader[0].getWidth());
+		super.setHeight(reader[0].getHeight());
+		super.setDataType(reader[0].getRasterBufTypeFromGdalType(reader[0].getDataType()));
+		super.setBandCount(bandCount);
+		window = new PxTileImpl(0, 0, reader[0].getWidth(), reader[0].getHeight());
+	}
+	
+	/**
+	 * This constructor is useful to use this class with a image reference
+	 * .Typically ReadOnlyCache. 
+	 * @param  path
+	 *         Path to the file
+	 * @throws IOException
+	 */
+	public BufferMultiDataSourceImpl(String[] path, PxTileImpl window) throws IOException {
+		this.path = path;
+		this.window = window;
+		reader = new GdalRead[path.length];
+		int bandCount = 0;
+		
+		try {
+			for (int i = 0; i < path.length; i++) {
+				reader[i] = new GdalRead(path[i]);
+				bandCount += reader[i].getBandCount();
+			}
+		} catch (GdalException e) {
+			throw new IOException();
+		}
+		super.setWidth(window.getWidth());
+		super.setHeight(window.getHeight());
+		super.setDataType(reader[0].getRasterBufTypeFromGdalType(reader[0].getDataType()));
+		super.setBandCount(bandCount);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.cachete.buffer.IBufferDataSource#close()
+	 */
+	public void close() throws IOException {
+		for (int i = 0; i < reader.length; i++) {
+			if(reader[i] != null)
+				try {
+					reader[i].close();
+					reader[i] = null;
+				} catch (GdalException e) {
+					throw new IOException();
+				}			
+		}
+	}
+		
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.BufferDataSource#getPath()
+	 */
+	public String[] getPath() {
+		return path;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.BufferDataSource#setPath(java.lang.String[])
+	 */
+	public void setPath(String[] path) {
+		this.path = path;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.BufferDataSource#setPath(java.lang.String)
+	 */
+	public void setPath(String path) {
+		this.path = new String[]{path};
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.rocache.ICacheDataSource#loadSelectedBand(org.gvsig.raster.buffer.IRasterBuffer, org.gvsig.raster.buffer.rocache.ReadOnlyStripe)
+	 */
+	public void loadSelectedBand(Buffer rb, PxTile stripe) throws IOException, ProcessInterruptedException, OperationNotSupportedException {
+		loadPage(rb, stripe, selectedBand);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.rocache.ICacheDataSource#loadPage(org.gvsig.raster.buffer.IRasterBuffer, org.gvsig.raster.buffer.rocache.ReadOnlyStripe)
+	 */
+	public void loadPage(Buffer rb, PxTile stripe) throws IOException, ProcessInterruptedException, OperationNotSupportedException {
+		try {
+			int dataType = reader[0].getDataType();
+			
+			if (dataType == GdalRead.GDT_Byte) {
+				
+				int last = 0;				
+				byte[][][] buf = new byte[rb.getBandCount()][][];
+				for (int i = 0; i < reader.length; i++) {
+					Object dataObj = reader[0].readBlock((int)stripe.getX() + window.getX(), (int)stripe.getY() + window.getY(), (int)stripe.getWidth(), (int)stripe.getHeight());
+					byte[][][] b = (byte[][][])dataObj;
+					int k = 0;
+					for (int j = last; j < b.length; j++) {
+						buf[j] = b[k];
+						k ++;
+					}
+					last += b.length; 
+				}
+				
+				for (int iBand = 0; iBand < buf.length; iBand++) 
+					for (int iLine = 0; iLine < buf[iBand].length; iLine++) 
+						for (int iColumn = 0; iColumn < buf[iBand][iLine].length; iColumn++) 
+							rb.setElem(iLine, iColumn, iBand, buf[iBand][iLine][iColumn]);
+										
+			} else if (dataType == GdalRead.GDT_CInt16 || dataType == GdalRead.GDT_Int16  || dataType == GdalRead.GDT_UInt16) {
+
+				int last = 0;				
+				short[][][] buf = new short[rb.getBandCount()][][];
+				for (int i = 0; i < reader.length; i++) {
+					Object dataObj = reader[0].readBlock((int)stripe.getX() + window.getX(), (int)stripe.getY() + window.getY(), (int)stripe.getWidth(), (int)stripe.getHeight());
+					short[][][] b = (short[][][])dataObj;
+					int k = 0;
+					for (int j = last; j < b.length; j++) {
+						buf[j] = b[k];
+						k ++;
+					}
+					last += b.length; 
+				}
+				
+				for (int iBand = 0; iBand < buf.length; iBand++) 
+					for (int iLine = 0; iLine < buf[iBand].length; iLine++) 
+						for (int iColumn = 0; iColumn < buf[iBand][iLine].length; iColumn++) 
+							rb.setElem(iLine, iColumn, iBand, buf[iBand][iLine][iColumn]);
+							
+			} else if (dataType == GdalRead.GDT_CInt32 || dataType == GdalRead.GDT_Int32  || dataType == GdalRead.GDT_UInt32) {
+
+				int last = 0;				
+				int[][][] buf = new int[rb.getBandCount()][][];
+				for (int i = 0; i < reader.length; i++) {
+					Object dataObj = reader[0].readBlock((int)stripe.getX() + window.getX(), (int)stripe.getY() + window.getY(), (int)stripe.getWidth(), (int)stripe.getHeight());
+					int[][][] b = (int[][][])dataObj;
+					int k = 0;
+					for (int j = last; j < b.length; j++) {
+						buf[j] = b[k];
+						k ++;
+					}
+					last += b.length; 
+				}
+				
+				for (int iBand = 0; iBand < buf.length; iBand++) 
+					for (int iLine = 0; iLine < buf[iBand].length; iLine++) 
+						for (int iColumn = 0; iColumn < buf[iBand][iLine].length; iColumn++) 
+							rb.setElem(iLine, iColumn, iBand, buf[iBand][iLine][iColumn]);
+							
+			} else if(dataType == GdalRead.GDT_Float32 || dataType == GdalRead.GDT_CFloat32) {
+
+				int last = 0;				
+				float[][][] buf = new float[rb.getBandCount()][][];
+				for (int i = 0; i < reader.length; i++) {
+					Object dataObj = reader[0].readBlock((int)stripe.getX() + window.getX(), (int)stripe.getY() + window.getY(), (int)stripe.getWidth(), (int)stripe.getHeight());
+					float[][][] b = (float[][][])dataObj;
+					int k = 0;
+					for (int j = last; j < b.length; j++) {
+						buf[j] = b[k];
+						k ++;
+					}
+					last += b.length; 
+				}
+				
+				for (int iBand = 0; iBand < buf.length; iBand++) 
+					for (int iLine = 0; iLine < buf[iBand].length; iLine++) 
+						for (int iColumn = 0; iColumn < buf[iBand][iLine].length; iColumn++) 
+							rb.setElem(iLine, iColumn, iBand, buf[iBand][iLine][iColumn]);
+							
+			} else if(dataType == GdalRead.GDT_Float64 || dataType == GdalRead.GDT_CFloat64) {
+
+				int last = 0;				
+				double[][][] buf = new double[rb.getBandCount()][][];
+				for (int i = 0; i < reader.length; i++) {
+					Object dataObj = reader[0].readBlock((int)stripe.getX() + window.getX(), (int)stripe.getY() + window.getY(), (int)stripe.getWidth(), (int)stripe.getHeight());
+					double[][][] b = (double[][][])dataObj;
+					int k = 0;
+					for (int j = last; j < b.length; j++) {
+						buf[j] = b[k];
+						k ++;
+					}
+					last += b.length; 
+				}
+				
+				for (int iBand = 0; iBand < buf.length; iBand++) 
+					for (int iLine = 0; iLine < buf[iBand].length; iLine++) 
+						for (int iColumn = 0; iColumn < buf[iBand][iLine].length; iColumn++) 
+							rb.setElem(iLine, iColumn, iBand, buf[iBand][iLine][iColumn]);
+							
+			}
+		} catch (GdalException e) {
+			throw new IOException("Error reading block.");
+		}
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.rocache.ICacheDataSource#loadPage(org.fv.raster.buffer.IRasterBuffer, org.fv.raster.buffer.rocache.ReadOnlyStripe, int)
+	 */
+	public void loadPage(Buffer rb, PxTile stripe, int iBand) throws IOException, ProcessInterruptedException, OperationNotSupportedException {
+		if(rb.getBandCount() != 1)
+			throw new IOException("Wrong buffer");
+		
+		int dataType = reader[0].getDataType();
+		int readerNum = 0;
+		int bandInsideReader = 0;
+		int accum = 0;
+		for (int i = 0; i < reader.length; i++) {
+			bandInsideReader = iBand - accum;
+			accum += reader[i].getBandCount();
+			if(accum > iBand) {
+				readerNum = i;
+				break;
+			}
+		}
+		
+		try {
+			Object dataObj = reader[readerNum].readBlock((int)stripe.getX() + window.getX(), (int)stripe.getY() + window.getY(), (int)stripe.getWidth(), (int)stripe.getHeight(), bandInsideReader);
+			if (dataType == GdalRead.GDT_Byte) {
+				byte[][] buf = (byte[][])dataObj;
+				for (int iLine = 0; iLine < buf.length; iLine++) 
+					for (int iColumn = 0; iColumn < buf[iLine].length; iColumn++) 
+						rb.setElem(iLine, iColumn, 0, buf[iLine][iColumn]);
+
+			} else if (dataType == GdalRead.GDT_CInt16 || dataType == GdalRead.GDT_Int16  || dataType == GdalRead.GDT_UInt16) {
+				short[][] buf = (short[][])dataObj;
+				for (int iLine = 0; iLine < buf.length; iLine++) 
+					for (int iColumn = 0; iColumn < buf[iLine].length; iColumn++) 
+						rb.setElem(iLine, iColumn, 0, buf[iLine][iColumn]);
+
+			} else if (dataType == GdalRead.GDT_CInt32 || dataType == GdalRead.GDT_Int32  || dataType == GdalRead.GDT_UInt32) {
+				int[][] buf = (int[][])dataObj;
+				for (int iLine = 0; iLine < buf.length; iLine++) 
+					for (int iColumn = 0; iColumn < buf[iLine].length; iColumn++) 
+						rb.setElem(iLine, iColumn, 0, buf[iLine][iColumn]);
+
+			} else if(dataType == GdalRead.GDT_Float32 || dataType == GdalRead.GDT_CFloat32) {
+				float[][] buf = (float[][])dataObj;
+				for (int iLine = 0; iLine < buf.length; iLine++) 
+					for (int iColumn = 0; iColumn < buf[iLine].length; iColumn++) 
+						rb.setElem(iLine, iColumn, iBand, buf[iLine][iColumn]);
+
+			} else if(dataType == GdalRead.GDT_Float64 || dataType == GdalRead.GDT_CFloat64) {
+				double[][] buf = (double[][])dataObj;
+				for (int iLine = 0; iLine < buf.length; iLine++) 
+					for (int iColumn = 0; iColumn < buf[iLine].length; iColumn++) 
+						rb.setElem(iLine, iColumn, 0, buf[iLine][iColumn]);
+
+			}
+		} catch (GdalException e) {
+			throw new IOException("Error reading block.");
+		}
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.gvsig.fmap.dataaccess.cache.ICacheDataSource#loadPage(int, org.gvsig.fmap.dataaccess.cache.PageBuffer)
+	 */
+	public void loadPage(Buffer buf, String inFileName) {
+		for (int i = 0; i < buf.getBandCount(); i++) 
+			loadBand(buf.getBand(i), inFileName + i);
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see java.lang.Object#clone()
+	 */
+	public BufferDataSource clone() {
+		try {
+			BufferMultiDataSourceImpl result = new BufferMultiDataSourceImpl(path, (PxTileImpl)window);
+			result.selectedBand = selectedBand;
+			return result;
+		} catch (IOException e) {
+			return null;
+		}
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/io/BufferMultiDataSourceImpl.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/memory/ByteBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/memory/ByteBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/memory/ByteBand.java	(revision 3222)
@@ -0,0 +1,106 @@
+package org.gvsig.raster.cache.buffer.impl.memory;
+
+import org.gvsig.raster.cache.buffer.Buffer;
+
+
+/**
+ * This class represent a byte band loaded in memory.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class ByteBand extends MemoryBand {
+	public byte[][] 	buf = null;
+	
+	public ByteBand(int width, int height, int nBand, boolean malloc) {
+		super(width, height, nBand);
+		this.setDataType(Buffer.TYPE_BYTE);
+		if(malloc)
+			buf = new byte[height][width];
+	}
+
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#assign(byte)
+	 */
+	public void assign(byte value) {
+		for (int i = 0; i < buf.length; i++) {
+			for (int j = 0; j < buf[i].length; j++) {
+				buf[i][j] = value;
+			}
+		}		
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getByteBlock(int)
+	 */
+	public byte[][] getByteBlock(int block) {
+		return buf;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.memory.RasterMemoryBand#setByteBlock(byte[][], int)
+	 */
+	public void setByteBlock(byte[][] data, int block) {
+		this.buf = data;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getByteLine(int)
+	 */
+	public byte[] getByteLine(int line) {
+		return buf[line];
+	}
+
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getElemByte(int, int)
+	 */
+	public byte getElemByte(int line, int col) {
+		return buf[line][col];
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#setByteLine(byte[], int)
+	 */
+	public void setByteLine(byte[] data, int line) {
+		buf[line] = data;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#setElem(int, int, byte)
+	 */
+	public void setElem(int line, int col, byte data) {
+		buf[line][col] = data;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.memory.MemoryBand#free()
+	 */
+	public void free() {
+		buf = null;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.memory.MemoryBand#clone()
+	 */
+	public MemoryBand clone() {
+		if(buf == null)
+			return new ByteBand(getWidth(), getHeight(), getBandNumber(), false);
+		ByteBand bb = new ByteBand(getWidth(), getHeight(), getBandNumber(), true);
+		for(int row = 0; row < buf.length; row ++) {
+			for(int col = 0; col < buf[0].length; col ++) {
+				bb.setElem(row, col, buf[row][col]);
+			}
+		}		
+		return bb;
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/memory/ByteBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/memory/FloatBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/memory/FloatBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/memory/FloatBand.java	(revision 3222)
@@ -0,0 +1,104 @@
+package org.gvsig.raster.cache.buffer.impl.memory;
+
+import org.gvsig.raster.cache.buffer.Buffer;
+
+
+/**
+ * Clase que representa una banda float de un buffer de memoria
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class FloatBand extends MemoryBand {
+	public float[][] 	buf = null;
+	
+	public FloatBand(int width, int height, int nBand, boolean malloc){
+		super(width, height, nBand);
+		this.setDataType(Buffer.TYPE_FLOAT);
+		if(malloc)
+			buf = new float[height][width];
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#assign(float)
+	 */
+	public void assign(float value) {
+		for (int i = 0; i < buf.length; i++) {
+			for (int j = 0; j < buf[i].length; j++) {
+				buf[i][j] = value;
+			}
+		}		
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getFloatBlock(int)
+	 */
+	public float[][] getFloatBlock(int block) {
+		return buf;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setFloatBlock(float[][], int)
+	 */
+	public void setFloatBlock(float[][] data, int block) {
+		this.buf = data;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getFloatLine(int)
+	 */
+	public float[] getFloatLine(int line) {
+		return buf[line];
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getElemFloat(int, int)
+	 */
+	public float getElemFloat(int line, int col) {
+		return buf[line][col];
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#setFloatLine(float[], int)
+	 */
+	public void setFloatLine(float[] data, int line) {
+		buf[line] = data;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#setElem(int, int, float)
+	 */
+	public void setElem(int line, int col, float data) {
+		buf[line][col] = data;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.memory.MemoryBand#free()
+	 */
+	public void free() {
+		buf = null;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.memory.MemoryBand#clone()
+	 */
+	public MemoryBand clone() {
+		if(buf == null)
+			return new FloatBand(getWidth(), getHeight(), getBandNumber(), false);
+		FloatBand fb = new FloatBand(getWidth(), getHeight(), getBandNumber(), true);
+		for(int row = 0; row < buf.length; row ++) {
+			for(int col = 0; col < buf[0].length; col ++) {
+				fb.setElem(row, col, buf[row][col]);
+			}
+		}		
+		return fb;
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/memory/FloatBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/memory/MemoryBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/memory/MemoryBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/memory/MemoryBand.java	(revision 3222)
@@ -0,0 +1,268 @@
+package org.gvsig.raster.cache.buffer.impl.memory;
+
+import org.gvsig.raster.cache.buffer.impl.BandImpl;
+
+
+/**
+ * Clase base para las bandas de un RasterMemoryBuffer.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public abstract class MemoryBand extends BandImpl {	
+	private int nBand = -1;
+    /**
+     * Constructor a llamar desde las clases hijas
+     * @param  width
+     * @param  height
+     * @param  nBand
+     *         Position of this band
+     */
+    public MemoryBand(int width, int height, int nBand){
+    	super(width, height);
+    	this.nBand = nBand;
+    }
+    
+    /*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setBandNumber(int)
+	 */
+	public void setBandNumber(int band) {
+		this.nBand = band;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getBandNumber()
+	 */
+	public int getBandNumber() {
+		return this.nBand;
+	}
+       
+	//***********************************************
+    //Getting a block of data
+	
+    /*
+     * (non-Javadoc)
+     * @see org.gvsig.raster.buffer.IRasterBand#getByteBlock(int)
+     */
+	public byte[][] getByteBlock(int block){return null;}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getShortBlock(int)
+	 */
+	public short[][] getShortBlock(int block){return null;}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getIntBlock(int)
+	 */
+	public int[][] getIntBlock(int block){return null;}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getFloatBlock(int)
+	 */
+	public float[][] getFloatBlock(int block){return null;}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getDoubleBlock(int)
+	 */
+	public double[][] getDoubleBlock(int block){return null;}
+
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#assign(byte)
+	 */
+	public void assign(byte value) {}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#assign(short)
+	 */
+	public void assign(short value) {}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#assign(int)
+	 */
+	public void assign(int value) {}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#assign(float)
+	 */
+	public void assign(float value) {}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#assign(double)
+	 */
+	public void assign(double value) {}
+
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getElemByte(int, int)
+	 */
+	public byte getElemByte(int line, int col) {return 0;}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getElemDouble(int, int)
+	 */
+	public double getElemDouble(int line, int col) {return 0;}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getElemFloat(int, int)
+	 */
+	public float getElemFloat(int line, int col) {return 0;}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getElemInt(int, int)
+	 */
+	public int getElemInt(int line, int col) {return 0;}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getElemShort(int, int)
+	 */
+	public short getElemShort(int line, int col) {return 0;}
+	
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getByteLine(int)
+	 */
+	public byte[] getByteLine(int line) {return null;}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getDoubleLine(int)
+	 */
+	public double[] getDoubleLine(int line) {return null;}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getFloatLine(int)
+	 */
+	public float[] getFloatLine(int line) {return null;}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getIntLine(int)
+	 */
+	public int[] getIntLine(int line) {return null;}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#getShortLine(int)
+	 */
+	public short[] getShortLine(int line) {return null;}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setElem(int, int, byte)
+	 */
+	public void setElem(int line, int col, byte data) {}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setElem(int, int, short)
+	 */
+	public void setElem(int line, int col, short data) {}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setElem(int, int, int)
+	 */
+	public void setElem(int line, int col, int data) {}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setElem(int, int, float)
+	 */
+	public void setElem(int line, int col, float data) {}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setElem(int, int, double)
+	 */
+	public void setElem(int line, int col, double data) {}
+
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setByteLine(byte[], int)
+	 */
+	public void setByteLine(byte[] data, int line) {}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setDoubleLine(double[], int)
+	 */
+	public void setDoubleLine(double[] data, int line) {}
+		
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setFloatLine(float[], int)
+	 */
+	public void setFloatLine(float[] data, int line) {}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setIntLine(int[], int)
+	 */
+	public void setIntLine(int[] data, int line) {}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setShortLine(short[], int)
+	 */
+	public void setShortLine(short[] data, int line) {}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setByteBlock(byte[][], int)
+	 */
+	public void setByteBlock(byte[][] data, int block) {}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setShortBlock(short[][], int)
+	 */
+	public void setShortBlock(short[][] data, int block) {}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setIntBlock(int[][], int)
+	 */
+	public void setIntBlock(int[][] data, int block) {}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setFloatBlock(float[][], int)
+	 */
+	public void setFloatBlock(float[][] data, int block) {}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setDoubleBlock(double[][], int)
+	 */
+	public void setDoubleBlock(double[][] data, int block) {}
+	
+	/**
+	 * Remove band resources
+	 */
+	public abstract void free();
+	
+	/**
+	 * Clone a MemoryBand object
+	 */
+	public abstract MemoryBand clone();
+
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/memory/MemoryBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/memory/DoubleBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/memory/DoubleBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/memory/DoubleBand.java	(revision 3222)
@@ -0,0 +1,104 @@
+package org.gvsig.raster.cache.buffer.impl.memory;
+
+import org.gvsig.raster.cache.buffer.Buffer;
+
+
+/**
+ * Clase que representa una banda double de un buffer de memoria
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class DoubleBand extends MemoryBand{
+	public double[][] 	buf = null;
+	
+	public DoubleBand(int width, int height, int nBand, boolean malloc){
+		super(width, height, nBand);
+		this.setDataType(Buffer.TYPE_DOUBLE);
+		if(malloc)
+			buf = new double[height][width];
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#assign(double)
+	 */
+	public void assign(double value) {
+		for (int i = 0; i < buf.length; i++) {
+			for (int j = 0; j < buf[i].length; j++) {
+				buf[i][j] = value;
+			}
+		}		
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getDoubleBlock(int)
+	 */
+	public double[][] getDoubleBlock(int block) {
+		return buf;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setDoubleBlock(double[][], int)
+	 */
+	public void setDoubleBlock(double[][] data, int block) {
+		this.buf = data;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getDoubleLine(int)
+	 */
+	public double[] getDoubleLine(int line) {
+		return buf[line];
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getElemDouble(int, int)
+	 */
+	public double getElemDouble(int line, int col) {
+		return buf[line][col];
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#setDoubleLine(double[], int)
+	 */
+	public void setDoubleLine(double[] data, int line) {
+		buf[line] = data;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#setElem(int, int, double)
+	 */
+	public void setElem(int line, int col, double data) {
+		buf[line][col] = data;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.memory.MemoryBand#free()
+	 */
+	public void free() {
+		buf = null;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.memory.MemoryBand#clone()
+	 */
+	public MemoryBand clone() {
+		if(buf == null)
+			return new DoubleBand(getWidth(), getHeight(), getBandNumber(), false);
+		DoubleBand db = new DoubleBand(getWidth(), getHeight(), getBandNumber(), true);
+		for(int row = 0; row < buf.length; row ++) {
+			for(int col = 0; col < buf[0].length; col ++) {
+				db.setElem(row, col, buf[row][col]);
+			}
+		}		
+		return db;
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/memory/DoubleBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/memory/IntBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/memory/IntBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/memory/IntBand.java	(revision 3222)
@@ -0,0 +1,104 @@
+package org.gvsig.raster.cache.buffer.impl.memory;
+
+import org.gvsig.raster.cache.buffer.Buffer;
+
+
+/**
+ * Clase que representa una banda byte de un buffer de memoria
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class IntBand extends MemoryBand {
+	public int[][] 	buf = null;
+	
+	public IntBand(int width, int height, int nBand, boolean malloc){
+		super(width, height, nBand);
+		this.setDataType(Buffer.TYPE_INT);
+		if(malloc)
+			buf = new int[height][width];
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#assign(int)
+	 */
+	public void assign(int value) {
+		for (int i = 0; i < buf.length; i++) {
+			for (int j = 0; j < buf[i].length; j++) {
+				buf[i][j] = value;
+			}
+		}		
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getIntBlock(int)
+	 */
+	public int[][] getIntBlock(int block) {
+		return buf;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setIntBlock(int[][], int)
+	 */
+	public void setIntBlock(int[][] data, int block) {
+		this.buf = data;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getIntLine(int)
+	 */
+	public int[] getIntLine(int line) {
+		return buf[line];
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getElemInt(int, int)
+	 */
+	public int getElemInt(int line, int col) {
+		return buf[line][col];
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#setIntLine(int[], int)
+	 */
+	public void setIntLine(int[] data, int line) {
+		buf[line] = data;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#setElem(int, int, int)
+	 */
+	public void setElem(int line, int col, int data) {
+		buf[line][col] = data;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.memory.MemoryBand#free()
+	 */
+	public void free() {
+		buf = null;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.memory.MemoryBand#clone()
+	 */
+	public MemoryBand clone() {
+		if(buf == null)
+			return new IntBand(getWidth(), getHeight(), getBandNumber(), false);
+		IntBand ib = new IntBand(getWidth(), getHeight(), getBandNumber(), true);
+		for(int row = 0; row < buf.length; row ++) {
+			for(int col = 0; col < buf[0].length; col ++) {
+				ib.setElem(row, col, buf[row][col]);
+			}
+		}		
+		return ib;
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/memory/IntBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/memory/RasterMemoryBuffer.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/memory/RasterMemoryBuffer.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/memory/RasterMemoryBuffer.java	(revision 3222)
@@ -0,0 +1,694 @@
+package org.gvsig.raster.cache.buffer.impl.memory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.exception.BandNotCompatibleException;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.WrongParameterException;
+import org.gvsig.raster.cache.buffer.impl.RasterBuffer;
+
+
+/**
+ * Implementaci�n del buffer de datos en memoria. Contiene las operaciones necesarias
+ * para acceso a datos raster implementando IRasterBuffer y su almacenamiento de datos est� basado
+ * en arrays tridimensionales. Existe un array para cada tipo de dato pero al instanciarse
+ * solo se usar� uno de ellos, el que corresponda al tipo de dato del raster manejado. 
+ * Esto quiere decir que cada RasterMemoryBuffer solo puede contener bandas de un solo tipo de
+ * dato donde la variable dataType especificar� de que tipo de dato se trata.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ *
+ */
+public class RasterMemoryBuffer extends RasterBuffer {
+	protected ArrayList<MemoryBand> bands = new ArrayList<MemoryBand>();
+       
+    /**
+     * Constructor
+     * @param dataType Tipo de dato
+     * @param width Ancho
+     * @param height Alto
+     * @param bandNr Banda
+     * @param orig
+     */
+    public RasterMemoryBuffer(int dataType, int width, int height, int bandNr, boolean malloc) {
+    	super(0, 0, width, height, dataType, bandNr);
+   		load(dataType, width, height, bandNr, malloc);
+    }
+    
+    /*
+     *  (non-Javadoc)
+     * @see org.gvsig.fmap.dataaccess.buffer.RasterBuffer#malloc(int, int, int, int)
+     */
+    private void load(int dataType, int width, int height, int bandNr, boolean malloc) {
+        if (dataType == TYPE_BYTE) {
+            for(int i = 0; i < bandNr; i++)
+            	bands.add(new ByteBand(width, height, i, malloc));
+        } else if ((dataType == TYPE_SHORT) | (dataType == TYPE_USHORT)) {
+            for(int i = 0; i < bandNr; i++)
+            	bands.add(new ShortBand(width, height, i, malloc));
+        } else if (dataType == TYPE_INT) {
+            for(int i = 0; i < bandNr; i++)
+            	bands.add(new IntBand(width, height, i, malloc));
+        } else if (dataType == TYPE_FLOAT) {
+            for(int i = 0; i < bandNr; i++)
+            	bands.add(new FloatBand(width, height, i, malloc));
+        } else if (dataType == TYPE_DOUBLE) {
+            for(int i = 0; i < bandNr; i++)
+            	bands.add(new DoubleBand(width, height, i, malloc));
+        }
+
+    }
+	
+    /**
+     * Obtiene el tama�o del tipo de dato en bytes
+     * @return Tipo de dato
+     */
+    public int getDataSize() {
+        if (getDataType() == TYPE_BYTE) {
+            return 1;
+        } else if ((getDataType() == TYPE_SHORT) | (getDataType() == TYPE_USHORT)) {
+            return 2;
+        } else if (getDataType() == TYPE_INT) {
+            return 4;
+        }else if (getDataType() == TYPE_FLOAT) {
+            return 8;
+        }else if (getDataType() == TYPE_DOUBLE) {
+            return 16;
+        }
+
+        return 0;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.fv.raster.buffer.IRasterBuffer#isWritable()
+     */
+    public boolean isWritable() {
+    	return true;
+    }
+    
+    //***********************************************
+    //Obtiene una linea de datos con todas las bandas
+    
+    public byte[][] getLineByte(int line) {
+    	byte[][] r = new byte[getBandCount()][];
+    	for(int iBand = 0; iBand < getBandCount(); iBand ++)
+    		r[iBand] = bands.get(iBand).getByteLine(line);
+    	return r;
+    }
+
+    public short[][] getLineShort(int line) {
+    	short[][] r = new short[getBandCount()][];
+    	for(int iBand = 0; iBand < getBandCount(); iBand ++)
+    		r[iBand] = bands.get(iBand).getShortLine(line);
+    	return r;
+    }
+
+    public int[][] getLineInt(int line) {
+    	int[][] r = new int[getBandCount()][];
+    	for(int iBand = 0; iBand < getBandCount(); iBand ++)
+    		r[iBand] = bands.get(iBand).getIntLine(line);
+    	return r;
+    }
+        
+    public float[][] getLineFloat(int line) {
+    	float[][] r = new float[getBandCount()][];
+    	for(int iBand = 0; iBand < getBandCount(); iBand ++)
+    		r[iBand] = bands.get(iBand).getFloatLine(line);
+    	return r;
+    }
+    
+    public double[][] getLineDouble(int line) {
+    	double[][] r = new double[getBandCount()][];
+    	for(int iBand = 0; iBand < getBandCount(); iBand ++)
+    		r[iBand] = bands.get(iBand).getDoubleLine(line);
+    	return r;
+    }
+
+    //***********************************************
+    //Asigna una linea de datos a todas las bandas
+    
+    public void setLineByte(byte[][] data, int line) {
+    	for(int iBand = 0; iBand < getBandCount(); iBand ++)
+    		bands.get(iBand).setByteLine(data[iBand], line);
+    }
+
+    public void setLineShort(short[][] data, int line) {
+    	for(int iBand = 0; iBand < getBandCount(); iBand ++)
+    		bands.get(iBand).setShortLine(data[iBand], line);
+    }
+
+    public void setLineInt(int[][] data, int line) {
+    	for(int iBand = 0; iBand < getBandCount(); iBand ++)
+    		bands.get(iBand).setIntLine(data[iBand], line);
+    }
+        
+    public void setLineFloat(float[][] data, int line) {
+    	for(int iBand = 0; iBand < getBandCount(); iBand ++)
+    		bands.get(iBand).setFloatLine(data[iBand], line);
+    }
+    
+    public void setLineDouble(double[][] data, int line) {
+    	for(int iBand = 0; iBand < getBandCount(); iBand ++)
+    		bands.get(iBand).setDoubleLine(data[iBand], line);
+    }
+    
+    //***********************************************
+    //Obtiene una linea de datos de una banda
+    
+    public byte[] getLineFromBandByte(int line, int iBand) {
+        return bands.get(iBand).getByteLine(line);
+    }
+
+    public short[] getLineFromBandShort(int line, int iBand) {
+        return bands.get(iBand).getShortLine(line);
+    }
+
+    public int[] getLineFromBandInt(int line, int iBand) {
+        return bands.get(iBand).getIntLine(line);
+    }
+        
+    public float[] getLineFromBandFloat(int line, int iBand) {
+        return bands.get(iBand).getFloatLine(line);
+    }
+    
+    public double[] getLineFromBandDouble(int line, int iBand) {
+        return bands.get(iBand).getDoubleLine(line);
+    }
+        
+    //***********************************************
+    //Asigna una linea de datos a una banda
+    
+    public void setLineInBandByte(byte[] data, int line, int iBand) {
+    	bands.get(iBand).setByteLine(data, line);
+    }
+
+    public void setLineInBandShort(short[] data, int line, int iBand) {
+    	bands.get(iBand).setShortLine(data, line);
+    }
+
+    public void setLineInBandInt(int[] data, int line, int iBand) {
+    	bands.get(iBand).setIntLine(data, line);
+    }
+        
+    public void setLineInBandFloat(float[] data, int line, int iBand) {
+    	bands.get(iBand).setFloatLine(data, line);
+    }
+    
+    public void setLineInBandDouble(double[] data, int line, int iBand) {
+    	bands.get(iBand).setDoubleLine(data, line);
+    }
+    
+    //***********************************************    
+    //Obtiene un elemento de la matriz
+    
+    public byte getElemByte(int line, int col, int iBand) {
+    	return bands.get(iBand).getElemByte(line, col);
+    }
+    
+    public short getElemShort(int line, int col, int iBand) {
+    	return bands.get(iBand).getElemShort(line, col);
+    }
+    
+    public int getElemInt(int line, int col, int iBand) {
+    	return bands.get(iBand).getElemInt(line, col);
+    }
+    
+    public float getElemFloat(int line, int col, int iBand) {
+    	return bands.get(iBand).getElemFloat(line, col);
+    }
+    
+    public double getElemDouble(int line, int col, int iBand) {
+    	return bands.get(iBand).getElemDouble(line, col);
+    }
+    
+    //**********************************************    
+    //Asigna un elemento de la matriz
+    
+    public void setElem(int line, int col, int iBand, byte data) {
+    	bands.get(iBand).setElem(line, col, data);
+    }
+    
+    public void setElem(int line, int col, int iBand, short data) {
+    	bands.get(iBand).setElem(line, col, data);
+    }
+    
+    public void setElem(int line, int col, int iBand, int data) {
+    	bands.get(iBand).setElem(line, col, data);
+    }
+    
+    public void setElem(int line, int col, int iBand, float data) {
+    	bands.get(iBand).setElem(line, col, data);
+    }
+    
+    public void setElem(int line, int col, int iBand, double data) {
+    	bands.get(iBand).setElem(line, col, data);
+    }
+    
+    //***********************************************
+    //Copia un elemento de todas la bandas en el buffer pasado por par�metro
+    
+    public void getElemByte(int line, int col, byte[] data) {
+    	for (int iBand = 0; (iBand < getBandCount() && iBand < data.length); iBand++)
+            data[iBand] = bands.get(iBand).getElemByte(line, col);
+    }
+    
+    public void getElemShort(int line, int col, short[] data) {
+    	for (int iBand = 0; (iBand < getBandCount() && iBand < data.length); iBand++)
+            data[iBand] = bands.get(iBand).getElemShort(line, col);
+    }
+    
+    public void getElemInt(int line, int col, int[] data) {
+    	for (int iBand = 0; (iBand < getBandCount() && iBand < data.length); iBand++)
+            data[iBand] = bands.get(iBand).getElemInt(line, col);
+    }  
+    
+    public void getElemFloat(int line, int col, float[] data) {
+    	for (int iBand = 0; (iBand < getBandCount() && iBand < data.length); iBand++)
+            data[iBand] = bands.get(iBand).getElemFloat(line, col);
+    }
+    
+    public void getElemDouble(int line, int col, double[] data) {
+    	for (int iBand = 0; (iBand < getBandCount() && iBand < data.length); iBand++)
+            data[iBand] = bands.get(iBand).getElemDouble(line, col);
+    }
+
+    //***********************************************
+    //Asigna un elemento a todas la bandas en el buffer pasado por par�metro
+    
+    public void setElemByte(int line, int col, byte[] data) {
+    	for (int iBand = 0; (iBand < getBandCount() && iBand < data.length); iBand++)
+    		bands.get(iBand).setElem(line, col, data[iBand]);
+    }
+    
+    public void setElemShort(int line, int col, short[] data) {
+    	for (int iBand = 0; (iBand < getBandCount() && iBand < data.length); iBand++)
+    		bands.get(iBand).setElem(line, col, data[iBand]);
+    }
+    
+    public void setElemInt(int line, int col, int[] data) {
+    	for (int iBand = 0; (iBand < getBandCount() && iBand < data.length); iBand++)
+    		bands.get(iBand).setElem(line, col, data[iBand]);
+    }
+
+    public void setElemFloat(int line, int col, float[] data) {
+    	for (int iBand = 0; (iBand < getBandCount() && iBand < data.length); iBand++)
+    		bands.get(iBand).setElem(line, col, data[iBand]);
+    }
+    
+    public void setElemDouble(int line, int col, double[] data) {
+    	for (int iBand = 0; (iBand < getBandCount() && iBand < data.length); iBand++)
+    		bands.get(iBand).setElem(line, col, data[iBand]);
+    }
+    
+    //***********************************************
+    //Obtiene una banda entera
+    
+    /*
+     * (non-Javadoc)
+     * @see org.gvsig.raster.buffer.IRasterBuffer#getBandByRef(int)
+     */
+    public Band getBand(int iBand){
+    	return bands.get(iBand);
+    }
+    
+    /*
+     * (non-Javadoc)
+     * @see org.gvsig.raster.buffer.IRasterBuffer#getBand(int)
+     */
+    public Band getBandCopy(int iBand) {
+    	if (getDataType() == TYPE_BYTE) {
+    		ByteBand bb = new ByteBand(getWidth(), getHeight(), 0, true);
+    		for (int row = 0; row < bb.getHeight(); row++) 
+    			for (int col = 0; col < bb.getWidth(); col++) 
+    				bb.setElem(row, col, bands.get(iBand).getElemByte(row, col));
+    		return bb;
+        } else if ((getDataType() == TYPE_SHORT) | (getDataType() == TYPE_USHORT)) {
+    		ShortBand sb = new ShortBand(getWidth(), getHeight(), 0, true);
+    		for (int row = 0; row < sb.getHeight(); row++) 
+    			for (int col = 0; col < sb.getWidth(); col++) 
+    				sb.setElem(row, col, bands.get(iBand).getElemShort(row, col));
+    		return sb;
+        } else if (getDataType() == TYPE_INT) {
+    		IntBand ib = new IntBand(getWidth(), getHeight(), 0, true);
+    		for (int row = 0; row < ib.getHeight(); row++) 
+    			for (int col = 0; col < ib.getWidth(); col++) 
+    				ib.setElem(row, col, bands.get(iBand).getElemInt(row, col));
+    		return ib;
+        }else if (getDataType() == TYPE_FLOAT) {
+    		FloatBand fb = new FloatBand(getWidth(), getHeight(), 0, true);
+    		for (int row = 0; row < fb.getHeight(); row++) 
+    			for (int col = 0; col < fb.getWidth(); col++) 
+    				fb.setElem(row, col, bands.get(iBand).getElemFloat(row, col));
+    		return fb;
+        }else if (getDataType() == TYPE_DOUBLE) {
+    		DoubleBand db = new DoubleBand(getWidth(), getHeight(), 0, true);
+    		for (int row = 0; row < db.getHeight(); row++) 
+    			for (int col = 0; col < db.getWidth(); col++) 
+    				db.setElem(row, col, bands.get(iBand).getElemDouble(row, col));
+    		return db;
+        }
+    	return null;
+    }
+    
+    /*
+     * (non-Javadoc)
+     * @see org.gvsig.raster.buffer.IRasterBuffer#getBands()
+     */
+    public Band[] getBands() {
+    	Band[] b = new Band[bands.size()];
+		for (int i = 0; i < bands.size(); i++) 
+			b[i] = bands.get(i);
+		return b;
+    }
+    
+	/*
+     * (non-Javadoc)
+     * @see org.fv.raster.buffer.IRasterBuffer#getBandList()
+     */
+    public ArrayList<Band> getBandList() {
+    	ArrayList<Band> result = new ArrayList<Band>();
+    	for (int i = 0; i < bands.size(); i++) 
+			result.add(bands.get(i));
+    	return result;
+    }
+    
+    /*
+     *  (non-Javadoc)
+     * @see org.gvsig.fmap.driver.IRasterBuffer#getBandBuffer(int)
+     */
+    public Buffer getBufferWithOneBand(int iBand) throws OperationNotSupportedException {
+    	RasterMemoryBuffer rmb = new RasterMemoryBuffer(getDataType(), getWidth(), getHeight(), 1, false);
+    	if (getDataType() == TYPE_BYTE) 
+    		rmb.getBand(0).setByteBlock(bands.get(iBand).getByteBlock(-1), -1);
+        else if ((getDataType() == TYPE_SHORT) | (getDataType() == TYPE_USHORT))
+        	rmb.getBand(0).setShortBlock(bands.get(iBand).getShortBlock(-1), -1);
+        else if (getDataType() == TYPE_INT)
+        	rmb.getBand(0).setIntBlock(bands.get(iBand).getIntBlock(-1), -1);
+        else if (getDataType() == TYPE_FLOAT)
+        	rmb.getBand(0).setFloatBlock(bands.get(iBand).getFloatBlock(-1), -1);
+        else if (getDataType() == TYPE_DOUBLE)
+        	rmb.getBand(0).setDoubleBlock(bands.get(iBand).getDoubleBlock(-1), -1);
+    	return rmb;
+    }
+    //***********************************************
+    //Inicializa una banda a un valor pasado por par�metro
+    
+    public void assign(int iBand, byte value) {
+    	for(int line = 0; line < getHeight(); line ++)
+    		for(int col = 0; col < getWidth(); col ++)
+    			bands.get(iBand).setElem(line, col, value);
+    }
+    
+    public void assign(int iBand, short value) {
+    	for(int line = 0; line < getHeight(); line ++)
+    		for(int col = 0; col < getWidth(); col ++)
+    			bands.get(iBand).setElem(line, col, value);
+    }
+    
+    public void assign(int iBand, int value) {
+    	for(int line = 0; line < getHeight(); line ++)
+    		for(int col = 0; col < getWidth(); col ++)
+    			bands.get(iBand).setElem(line, col, value);
+    }
+
+    public void assign(int iBand, float value) {
+    	for(int line = 0; line < getHeight(); line ++)
+    		for(int col = 0; col < getWidth(); col ++)
+    			bands.get(iBand).setElem(line, col, value);
+    }
+    
+    public void assign(int iBand, double value) {
+    	for(int line = 0; line < getHeight(); line ++)
+    		for(int col = 0; col < getWidth(); col ++)
+    			bands.get(iBand).setElem(line, col, value);
+    }
+    
+    
+    //***********************************************
+    //Crea un buffer banda inicializado con el valor pasado por par�metro
+    
+
+    public Band createBand(double defaultValue){
+    	switch(getDataType()){
+    	case RasterBuffer.TYPE_BYTE:ByteBand bb = new ByteBand(getWidth(), getHeight(), -1, false);
+    								bb.buf = createByteBand(getWidth(), getHeight(), (byte)defaultValue);
+    								return bb;
+    	case RasterBuffer.TYPE_SHORT:	ShortBand sb = new ShortBand(getWidth(), getHeight(), -1, false);
+										sb.buf = createShortBand(getWidth(), getHeight(), (short)defaultValue);
+										return sb;
+    	case RasterBuffer.TYPE_INT:	IntBand ib = new IntBand(getWidth(), getHeight(), -1, false);
+									ib.buf = createIntBand(getWidth(), getHeight(), (int)defaultValue);
+									return ib;
+    	case RasterBuffer.TYPE_FLOAT:	FloatBand fb = new FloatBand(getWidth(), getHeight(), -1, false);
+										fb.buf = createFloatBand(getWidth(), getHeight(), (float)defaultValue);
+										return fb;
+    	case RasterBuffer.TYPE_DOUBLE:	DoubleBand db = new DoubleBand(getWidth(), getHeight(), -1, false);
+										db.buf = createDoubleBand(getWidth(), getHeight(), (double)defaultValue);
+										return db;
+    	}
+    	return null;
+    }
+
+    public byte[][] createByteBand(int width, int height, byte defaultValue){
+    	byte[][] band = new byte[height][width];
+    	if(defaultValue != 0){
+	    	for(int line = 0; line < height; line ++)
+	    		for(int col = 0; col < width; col ++)
+	    			band[line][col] = defaultValue;
+    	}
+    	return band;
+    }
+    
+    public short[][] createShortBand(int width, int height, short defaultValue){
+    	short[][] band = new short[height][width];
+    	if(defaultValue != 0){
+	    	for(int line = 0; line < height; line ++)
+	    		for(int col = 0; col < width; col ++)
+	    			band[line][col] = defaultValue;
+    	}
+    	return band;
+    }
+    
+    public int[][] createIntBand(int width, int height, int defaultValue){
+    	int[][] band = new int[height][width];
+    	if(defaultValue != 0){
+	    	for(int line = 0; line < height; line ++)
+	    		for(int col = 0; col < width; col ++)
+	    			band[line][col] = defaultValue;
+    	}
+    	return band;
+    }
+    
+    public float[][] createFloatBand(int width, int height, float defaultValue){
+    	float[][] band = new float[height][width];
+    	if(defaultValue != 0){
+	    	for(int line = 0; line < height; line ++)
+	    		for(int col = 0; col < width; col ++)
+	    			band[line][col] = defaultValue;
+    	}
+    	return band;
+    }
+    
+    public double[][] createDoubleBand(int width, int height, double defaultValue){
+    	double[][] band = new double[height][width];
+    	if(defaultValue != 0){
+	    	for(int line = 0; line < height; line ++)
+	    		for(int col = 0; col < width; col ++)
+	    			band[line][col] = defaultValue;
+    	}
+    	return band;
+    }
+    
+    //***********************************************
+    //A�ade una banda entera. Los datos son asignados por referencia
+
+    private void addBandByReference(int iBand, Band data) {
+    	if(iBand < 0 || !(data instanceof MemoryBand))
+    		return;
+    	if(iBand > getBandCount())
+    		bands.add((MemoryBand)data);
+    	bands.add(iBand, (MemoryBand)data);
+    	
+    	setBandCount(bands.size());
+    }
+            
+    /**
+     * Replica la banda de una posici�n sobre otra. Si la banda de destino no existe
+     * se crea nueva. Si la posici�n de la banda de destino est� intercalada entre bandas 
+     * que ya existen las otras se desplazan hacia abajo, NO se machacan los datos de ninguna.
+     * Los datos se replican por referencia por lo que al modificar la banda original las
+     * del resto quedar�n afectadas.   
+     * @param orig. Posici�n de la banda de origen. 
+     * @param dest. Posici�n de la banda destino
+     */   
+    public void replicateBand(int orig, int dest){
+    	if(orig >= bands.size())
+			return;
+		addBandByReference(dest, getBand(orig));
+    }
+    
+    /*
+     *  (non-Javadoc)
+     * @see org.gvsig.fmap.dataaccess.buffer.RasterBuffer#switchBands(int[])
+     */
+    public void swapBands(int[] bandPosition) throws WrongParameterException, IOException {
+    	super.swapBands(bandPosition);
+    	ArrayList<MemoryBand> result = new ArrayList<MemoryBand>();
+		for (int i = 0; i < bands.size(); i++) 
+			result.add(bands.get(bandPosition[i]));
+		bands = result;
+    }
+    
+    /*
+     *  (non-Javadoc)
+     * @see org.gvsig.fmap.driver.IRasterBuffer#copyBand(int, org.gvsig.fmap.dataaccess.buffer.IBand)
+     */
+    public void copyBand(int nBand, Band band) throws BandNotCompatibleException, OperationNotSupportedException {
+    	super.copyBand(nBand, band);
+	}
+
+    /*
+     *  (non-Javadoc)
+     * @see org.gvsig.fmap.driver.IRasterBuffer#assignBand(int, org.gvsig.fmap.dataaccess.buffer.IBand)
+     */
+	public void assignBand(int iBand, Band data) throws BandNotCompatibleException {
+		if(	data.getDataType() != getDataType())
+			throw new BandNotCompatibleException("Data type not compatible");
+		if(!(data instanceof MemoryBand))
+			throw new BandNotCompatibleException("buffer type not compatible");
+		if(	data.getHeight() != getHeight() || data.getWidth() != getWidth())
+			throw new BandNotCompatibleException("Bands with diferents sizes");
+		
+		if(iBand < 0 || !(data instanceof MemoryBand))
+    		return;
+    	if(iBand > getBandCount())
+    		bands.add((MemoryBand)data);
+    	bands.add(iBand, (MemoryBand)data);
+    	
+    	setBandCount(bands.size());
+	}
+    
+    /*
+     *  (non-Javadoc)
+     * @see org.gvsig.fmap.driver.IRasterBuffer#cloneBuffer()
+     */
+    public Buffer cloneBuffer(){
+    	RasterMemoryBuffer rmb = new RasterMemoryBuffer(getDataType(), getWidth(), getHeight(), getBandCount(), false);
+    	for(int iBand = 0; iBand < getBandCount(); iBand ++) {
+    		MemoryBand band = bands.get(iBand).clone();
+    		try {
+    			rmb.removeBand(iBand);
+				rmb.assignBand(iBand, band);
+			} catch (BandNotCompatibleException e) {
+			}
+    	}
+    	return rmb;
+    }
+    
+    /*
+     * (non-Javadoc)
+     * @see org.gvsig.fmap.driver.IRasterBuffer#swapBands(int, int)
+     */
+    public void swapBands(int band1, int band2) throws WrongParameterException, IOException {
+    	super.swapBands(band1, band2);
+    	
+    	int[] bandPosition = new int[getBandCount()];
+		for (int i = 0; i < bandPosition.length; i++) {
+			if(i == band1) 
+				bandPosition[i] = band2;
+			else if(i == band2) 
+				bandPosition[i] = band1;
+			else
+				bandPosition[i] = i;
+		}
+		swapBands(bandPosition);
+    }
+        
+    /**
+     * Convierte un tipo de dato a cadena
+     * @param type Tipo de dato
+     * @return cadena  que representa el tipo de dato
+     */
+    public static String typesToString(int type) {
+        switch (type) {
+        case RasterBuffer.TYPE_BYTE:
+            return new String("Byte");
+
+        case RasterBuffer.TYPE_DOUBLE:
+            return new String("Double");
+
+        case RasterBuffer.TYPE_FLOAT:
+            return new String("Float");
+
+        case RasterBuffer.TYPE_INT:
+        	return new String("Integer");
+        	
+        case RasterBuffer.TYPE_USHORT:
+        case RasterBuffer.TYPE_SHORT:
+            return new String("Short");
+        }
+
+        return null;
+    }
+    
+	/*
+	 *  (non-Javadoc)
+	 * @see org.gvsig.fmap.driver.IRasterBuffer#assignBandToNotValid(int)
+	 */
+    public void assignBandToNotValid(int iBand) {
+    	if(iBand < 0)
+    		return;
+    	if(getBandCount() > iBand) 
+    		bands.add((MemoryBand)createBand(getNotValidValue()));
+    	bands.add(iBand, (MemoryBand)createBand(getNotValidValue()));
+    }
+    
+    /*
+     * (non-Javadoc)
+     * @see org.gvsig.raster.buffer.IRasterBuffer#removeBand(int)
+     */
+    public void removeBand(int iBand) {
+    	if(iBand < 0 || iBand >= getBandCount())
+    		return;
+    	bands.remove(iBand);
+    	bandLessLess();
+    }
+    
+    /*
+     * (non-Javadoc)
+     * @see org.gvsig.raster.buffer.IRasterBuffer#addBand()
+     */
+    public Band addBand(int pos) {
+    	bandPlusPlus();
+    	switch(getDataType()){
+    	case RasterBuffer.TYPE_BYTE:ByteBand bb = new ByteBand(getWidth(), getHeight(), pos, true);
+    								bands.add(pos, bb);
+    								return bb;
+    	case RasterBuffer.TYPE_SHORT:ShortBand sb = new ShortBand(getWidth(), getHeight(), pos, true);
+									bands.add(pos, sb);
+									return sb;
+    	case RasterBuffer.TYPE_INT:	IntBand ib = new IntBand(getWidth(), getHeight(), pos, true);
+    								bands.add(pos, ib);
+									return ib;
+    	case RasterBuffer.TYPE_FLOAT:	FloatBand fb = new FloatBand(getWidth(), getHeight(), pos, true);
+    									bands.add(pos, fb);
+										return fb;
+    	case RasterBuffer.TYPE_DOUBLE:	DoubleBand db = new DoubleBand(getWidth(), getHeight(), pos, true);
+    									bands.add(pos, db);
+										return db;
+    	}
+    	return null;
+    }
+
+	/**
+	 * Libera el buffer de memoria
+	 */
+	public void free() {
+		for (int i = 0; i < bands.size(); i++) 
+			bands.get(i).free();
+	}
+}
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/memory/RasterMemoryBuffer.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/memory/ShortBand.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/memory/ShortBand.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/memory/ShortBand.java	(revision 3222)
@@ -0,0 +1,105 @@
+package org.gvsig.raster.cache.buffer.impl.memory;
+
+import org.gvsig.raster.cache.buffer.impl.RasterBuffer;
+
+
+/**
+ * Clase que representa una banda short de un buffer de memoria
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class ShortBand extends MemoryBand {
+	public short[][] 	buf = null;
+	
+	public ShortBand(int width, int height, int nBand, boolean malloc){
+		super(width, height, nBand);
+		this.setDataType(RasterBuffer.TYPE_SHORT);
+		if(malloc)
+			buf = new short[height][width];
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#assign(short)
+	 */
+	public void assign(short value) {
+		for (int i = 0; i < buf.length; i++) {
+			for (int j = 0; j < buf[i].length; j++) {
+				buf[i][j] = value;
+			}
+		}		
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getShortBlock(int)
+	 */
+	public short[][] getShortBlock(int block) {
+		return buf;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.IRasterBand#setShortBlock(short[][], int)
+	 */
+	public void setShortBlock(short[][] data, int block) {
+		this.buf = data;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getShortLine(int)
+	 */
+	public short[] getShortLine(int line) {
+		return buf[line];
+	}
+
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#getElemShort(int, int)
+	 */
+	public short getElemShort(int line, int col) {
+		return buf[line][col];
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#setShortLine(short[], int)
+	 */
+	public void setShortLine(short[] data, int line) {
+		buf[line] = data;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.buffer.RasterBand#setElem(int, int, short)
+	 */
+	public void setElem(int line, int col, short data) {
+		buf[line][col] = data;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.memory.MemoryBand#free()
+	 */
+	public void free() {
+		buf = null;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.fv.raster.buffer.memory.MemoryBand#clone()
+	 */
+	public MemoryBand clone() {
+		if(buf == null)
+			return new ShortBand(getWidth(), getHeight(), getBandNumber(), false);
+		ShortBand sb = new ShortBand(getWidth(), getHeight(), getBandNumber(), true);
+		for(int row = 0; row < buf.length; row ++) {
+			for(int col = 0; col < buf[0].length; col ++) {
+				sb.setElem(row, col, buf[row][col]);
+			}
+		}		
+		return sb;
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/memory/ShortBand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/RasterBuffer.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/RasterBuffer.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/RasterBuffer.java	(revision 3222)
@@ -0,0 +1,308 @@
+package org.gvsig.raster.cache.buffer.impl;
+
+import java.awt.geom.Rectangle2D;
+import java.io.IOException;
+
+import org.gvsig.raster.cache.buffer.Band;
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferInterpolation;
+import org.gvsig.raster.cache.buffer.BufferStats;
+import org.gvsig.raster.cache.buffer.exception.BandNotCompatibleException;
+import org.gvsig.raster.cache.buffer.exception.HistogramException;
+import org.gvsig.raster.cache.buffer.exception.OperationNotSupportedException;
+import org.gvsig.raster.cache.buffer.exception.ProcessInterruptedException;
+import org.gvsig.raster.cache.buffer.exception.WrongParameterException;
+import org.gvsig.raster.cache.buffer.histogram.HistogramComputer;
+import org.gvsig.raster.cache.buffer.impl.histogram.BufferHistogramComputer;
+
+/**
+ * Base class for a raster buffer.
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ *
+ */
+public abstract class RasterBuffer extends RasterBase implements Buffer {	
+	private BufferStats          statistics            = null;
+	private Rectangle2D          dataExtent            = null;
+	private HistogramComputer    histogramComputer     = null;
+	private Object               store                 = null;
+	private BufferInterpolation  interp                = null;
+	
+	/**
+	 * Valor con el que se rellena una banda no valida del buffer. Una banda no valida es la que 
+	 * no tiene datos asignados y tampoco puede ser null. Todas las bandas no validas de un buffer
+	 * apuntan por referencia a la misma banda.
+	 */
+	protected double             notValidValue         = 0D;
+	
+	/**
+	 * Sets size and position values
+	 * @param  x
+	 *         Upper left X position 
+	 * @param  y
+	 *         Upper left X position
+	 * @param  w
+	 *         Width
+	 * @param  h
+	 *         Height
+	 */
+	public RasterBuffer(int x, int y, int w, int h) {
+		super(x, y, w, h);
+	}
+	
+	/**
+	 * Sets size and position values
+	 * @param  x
+	 *         Upper left X position 
+	 * @param  y
+	 *         Upper left X position
+	 * @param  w
+	 *         Width
+	 * @param  h
+	 *         Height
+	 */
+	public RasterBuffer(int x, int y, int w, int h, int dataType, int nBands) {
+		super(x, y, w, h, dataType, nBands);
+	}
+	
+	public static int getBytesFromRasterBufType(int rasterBufType) {
+		switch (rasterBufType) {
+			case TYPE_BYTE: return 1;
+			case TYPE_USHORT:
+			case TYPE_SHORT: return 2;
+			case TYPE_INT:
+			case TYPE_FLOAT:
+			case TYPE_DOUBLE: return 8;
+		}
+		return 0; // TYPE_UNDEFINED
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#setStore(java.lang.Object)
+	 */
+	public void setStore(Object store) {
+		this.store = store;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#getStore()
+	 */
+	public Object getStore() {
+		return store;
+	}
+	
+	/**
+	 * Gets a bouding box of this buffer
+	 * @return
+	 */
+	public Rectangle2D getDataExtent() {
+		return dataExtent;
+	}
+	
+	/**
+	 * Sets a bounding box of this buffer
+	 * @param r
+	 */
+	public void setDataExtent(Rectangle2D r) {
+		this.dataExtent = r;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#addDrawableBands(int[])
+	 */
+	public void addDrawableBands(int[] bands) {
+		
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#copyBand(int, org.gvsig.raster.cache.buffer.Band)
+	 */
+	public void copyBand(int iBand, Band band) throws BandNotCompatibleException, OperationNotSupportedException {
+		if(band.getDataType() != this.getDataType())
+			throw new BandNotCompatibleException("Diferent data types");
+		if(band.getWidth() != this.getWidth())
+			throw new BandNotCompatibleException("Diferent sizes");
+		if(band.getHeight() != this.getHeight())
+			throw new BandNotCompatibleException("Diferent sizes");
+		if(iBand < 0 || iBand > getBandCount() - 1)
+			throw new BandNotCompatibleException("Wrong position");
+		
+		switch (getDataType()) {
+		case RasterBuffer.TYPE_BYTE:	
+			for (int row = 0; row < getHeight(); row++) 
+				for (int col = 0; col < getWidth(); col++) 
+					setElem(row, col, iBand, band.getElemByte(row, col));
+			break;
+		case RasterBuffer.TYPE_SHORT:
+			for (int row = 0; row < getHeight(); row++) 
+				for (int col = 0; col < getWidth(); col++) 
+					setElem(row, col, iBand, band.getElemShort(row, col));
+			break;
+		case RasterBuffer.TYPE_INT:
+			for (int row = 0; row < getHeight(); row++) 
+				for (int col = 0; col < getWidth(); col++) 
+					setElem(row, col, iBand, band.getElemInt(row, col));
+			break;
+		case RasterBuffer.TYPE_FLOAT:
+			for (int row = 0; row < getHeight(); row++) 
+				for (int col = 0; col < getWidth(); col++) 
+					setElem(row, col, iBand, band.getElemFloat(row, col));
+			break;
+		case RasterBuffer.TYPE_DOUBLE:
+			for (int row = 0; row < getHeight(); row++) 
+				for (int col = 0; col < getWidth(); col++) 
+					setElem(row, col, iBand, band.getElemDouble(row, col));
+			break;
+		}
+	}
+		
+	/**
+	 * Cambia bandas de posici�n. Las posiciones deben existir como bandas del raster. 
+	 * Cada elemento del array representa una banda existente en el buffer (de longitud
+	 * rasterBuf.length) y el valor contenido dentro la banda que le corresponde. Por ejemplo
+	 * si pasamos un array {1, 0, 3, 2} significa que el buffer tiene cuatro bandas y que 
+	 * cambiamos la 0 por la 1 y la 2 por la 3. Un array {0, 1, 2, 3} en el mismo 
+	 * caso no producir�a nig�n cambio.
+	 * 
+	 * Si quisieramos asignar en un buffer monobanda su banda a la segunda posici�n habria
+	 * que insertar una vacia, por ejemplo con addBandFloat(0, null) se insertaria una 
+	 * banda nula en la posici�n 0 y la banda que estaba en la 0 pasar�a a la segunda.
+	 * @throws WrongParameterException 
+	 * @throws IOException 
+	 * 
+	 */
+	public void swapBands(int[] bandPosition) throws WrongParameterException, IOException {
+		if(bandPosition.length != getBandCount())
+    		throw new WrongParameterException("Number of elements not valid");
+    	for (int i = 0; i < bandPosition.length; i++) {
+			if(bandPosition[i] < 0 || bandPosition[i] > getBandCount())
+				throw new WrongParameterException("Array not valid");
+		}
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#swapBands(int, int)
+	 */
+	public void swapBands(int band1, int band2) throws WrongParameterException, IOException {
+		if(band1 < 0 || band1 > getBandCount() - 1 || band2 < 0 || band2 > getBandCount() - 1)
+			throw new WrongParameterException("Wrong band number");
+	}
+		
+	/**
+	 * Convierte un tipo de dato a cadena
+	 * @param type Tipo de dato
+	 * @return cadena  que representa el tipo de dato
+	 */
+	public static String typesToString(int type) {
+		switch (type) {
+		case RasterBuffer.TYPE_BYTE:
+			return new String("Byte");
+
+		case RasterBuffer.TYPE_DOUBLE:
+			return new String("Double");
+
+		case RasterBuffer.TYPE_FLOAT:
+			return new String("Float");
+
+		case RasterBuffer.TYPE_INT:
+			return new String("Integer");
+
+		case RasterBuffer.TYPE_USHORT:
+		case RasterBuffer.TYPE_SHORT:
+			return new String("Short");
+		}
+
+		return null;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#isInside(int, int)
+	 */
+	public boolean isInside(int x, int y) {
+		if (x < 0 || y < 0 || x >= getWidth() || y >= getHeight())
+			return false;
+		return true;
+	}
+		
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#getNotValidValue()
+	 */
+	public double getNotValidValue(){
+		return notValidValue;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#setNotValidValue(double)
+	 */
+	public void setNotValidValue(double value){
+		this.notValidValue = value;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#cloneBuffer()
+	 */
+	public abstract Buffer cloneBuffer();
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#getAdjustedWindow(int, int, int)
+	 */
+	public Buffer getAdjustedWindow(int w, int h, int interpolationMethod) throws ProcessInterruptedException {
+		if (interp == null)
+			interp = new BufferInterpolationImpl(this);
+
+		if (w == getWidth() && h == getHeight())
+			return this;
+		Buffer rasterBuf = null;
+		switch (interpolationMethod) {
+			case BufferInterpolationImpl.INTERPOLATION_NearestNeighbour:
+				rasterBuf = interp.adjustRasterNearestNeighbourInterpolation(w, h);
+				break;
+			case BufferInterpolationImpl.INTERPOLATION_Bilinear:
+				rasterBuf = interp.adjustRasterBilinearInterpolation(w, h);
+				break;
+			case BufferInterpolationImpl.INTERPOLATION_InverseDistance:
+				rasterBuf = interp.adjustRasterInverseDistanceInterpolation(w, h);
+				break;
+			case BufferInterpolationImpl.INTERPOLATION_Bicubic:
+				rasterBuf = interp.adjustRasterBicubicSplineInterpolation(w, h);
+				break;
+			case BufferInterpolationImpl.INTERPOLATION_BSpline:
+				rasterBuf = interp.adjustRasterBSplineInterpolation(w, h);
+				break;
+		}
+		if (rasterBuf != null)
+			return rasterBuf;
+		else
+			return this;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.Buffer#getStatistics()
+	 */
+	public BufferStats getStatistics() {
+		if(statistics == null)
+			statistics = new BufferStatsImpl(this);
+		return statistics;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.histogram.Histogramable#getHistogramComputer()
+	 */
+	public HistogramComputer getHistogramComputer() throws HistogramException, ProcessInterruptedException {
+		if(histogramComputer == null)
+			histogramComputer = new BufferHistogramComputer(this);
+		return histogramComputer;
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/RasterBuffer.java
___________________________________________________________________
Added: svn:executable
   + *
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/RasterBase.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/RasterBase.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/RasterBase.java	(revision 3222)
@@ -0,0 +1,223 @@
+package org.gvsig.raster.cache.buffer.impl;
+
+import org.gvsig.raster.cache.buffer.BufferNoData;
+
+
+
+/**
+ * Base class for raster elements. This class contains methos for
+ * reading width, height, number of bands and other raster parameters 
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public abstract class RasterBase {
+	private static final long    serialVersionUID = 1L;
+	private int                  dataType         = RasterBuffer.TYPE_UNDEFINED;
+	private int                  bandCount        = 0;
+	private int                  width            = 0;
+	private int                  height           = 0;
+	private int                  x                = 0;
+	private int                  y                = 0;
+	public BufferNoData			     noDataValue      = null;
+	
+	/**
+	 * Sets size and position values
+	 * @param  x
+	 *         Upper left X position 
+	 * @param  y
+	 *         Upper left X position
+	 * @param  w
+	 *         Width
+	 * @param  h
+	 *         Height
+	 */
+	public RasterBase(int x, int y, int w, int h) {
+		this.x = x;
+		this.y = y;
+		this.width = w;
+		this.height = h;
+	}
+	
+	/**
+	 * Sets size and position values
+	 * @param  x
+	 *         Upper left X position 
+	 * @param  y
+	 *         Upper left X position
+	 * @param  w
+	 *         Width
+	 * @param  h
+	 *         Height
+	 * @param  datatype
+	 * 	       Data type of this raster
+	 * @param  nBands
+	 * 	       Number of bands of this raster
+	 */
+	public RasterBase(int x, int y, int w, int h, int dataType, int nBands) {
+		this.x = x;
+		this.y = y;
+		this.width = w;
+		this.height = h;
+		this.dataType = dataType;
+		this.bandCount = nBands;
+	}
+	
+	/**
+	 * Returns the width in pixels
+	 * @return Width in pixels of this raster
+	 */
+	public int getWidth() {
+		return width;
+	}
+
+	/**
+	 * Sets the width in pixels
+	 * @param  width
+	 *         Width in pixels of this raster
+	 */
+	public void setWidth(int width) {
+		this.width = width;
+	}
+
+	/**
+	 * Returns the height in pixels
+	 * @return Height in pixels of this raster
+	 */
+	public int getHeight() {
+		return height;
+	}
+
+	/**
+	 * Sets the height in pixels
+	 * @param  height
+	 *         Height in pixels of this raster 
+	 */
+	public void setHeight(int height) {
+		this.height = height;
+	}
+
+	/**
+	 * Returns the X upper left coordinate
+	 * @return X upper left coordinate in pixels
+	 */
+	public int getX() {
+		return x;
+	}
+
+	/**
+	 * Sets the X upper left coordinate
+	 * @params  x
+	 *          X upper left coordinate in pixels
+	 */
+	public void setX(int x) {
+		this.x = x;
+	}
+
+	/**
+	 * Returns the Y upper left coordinate
+	 * @return Y upper left coordinate in pixels
+	 */
+	public int getY() {
+		return y;
+	}
+
+	/**
+	 * Sets the Y upper left coordinate
+	 * @params  y
+	 *          Y upper left coordinate in pixels
+	 */
+	public void setY(int y) {
+		this.y = y;
+	}
+
+	/**
+	 * Gets the data type
+	 * @return
+	 */
+	public int getDataType() {
+		return dataType;
+	}
+
+	/**
+	 * Sets the data type
+	 * @param dataType
+	 */
+	public void setDataType(int dataType) {
+		this.dataType = dataType;
+	}
+
+	/**
+	 * Gets number of bands
+	 * @return
+	 */
+	public int getBandCount() {
+		return bandCount;
+	}
+
+	/**
+	 * Sets number of bands
+	 * @param bandCount
+	 */
+	public void setBandCount(int bandCount) {
+		this.bandCount = bandCount;
+	}
+	
+	/**
+	 * Adds one to the band counter
+	 */
+	public void bandPlusPlus() {
+		this.bandCount ++;
+	}
+	
+	/**
+	 * Substracts one to the band counter
+	 */
+	public void bandLessLess() {
+		this.bandCount --;
+	}
+ 	
+ 	/**
+     * Gets no data value
+     * @return double
+     */
+	public BufferNoData getNoDataValue() {
+		return noDataValue;
+	}
+	
+	/**
+ 	 * Sets no data value
+ 	 * @return double
+ 	 */
+	public void setNoDataValue(BufferNoData nd){
+		noDataValue = nd;
+	}
+	
+	/**
+	 * Gets the size of the data type in bytes
+	 * @return Size of the data type that is used
+	 */
+	public int getDataSize() {
+		if (getDataType() == RasterBuffer.TYPE_BYTE) {
+			return 1;
+		} else if ((getDataType() == RasterBuffer.TYPE_SHORT) | (getDataType() == RasterBuffer.TYPE_USHORT)) {
+			return 2;
+		} else if (getDataType() == RasterBuffer.TYPE_INT) {
+			return 4;
+		}else if (getDataType() == RasterBuffer.TYPE_FLOAT) {
+			return 8;
+		}else if (getDataType() == RasterBuffer.TYPE_DOUBLE) {
+			return 16;
+		}
+
+		return 0;
+	}
+    
+    /**
+	 * Gets the buffer size
+	 * @return buffer size
+	 */
+	public long sizeof() {
+		return (long)(getDataSize() * getWidth() * getHeight() * getBandCount());
+	}
+
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/RasterBase.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/datastruct/DefaultNoData.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/datastruct/DefaultNoData.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/datastruct/DefaultNoData.java	(revision 3222)
@@ -0,0 +1,316 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.buffer.impl.datastruct;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.gvsig.raster.cache.buffer.Buffer;
+import org.gvsig.raster.cache.buffer.BufferNoData;
+
+/**
+ * This class represents the implementation of a nodata value.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class DefaultNoData implements BufferNoData {
+	private List<Number>             noDataByBand        = new ArrayList<Number>();
+	private List<Number>             nativeNoDataByBand  = new ArrayList<Number>();
+	private int                      bandCount           = 1;
+	private String                   fileName            = null;
+	private boolean                  noDataAsTransparent = true;
+	private int                      dataType            = Buffer.TYPE_UNDEFINED;
+	
+	/**
+	 * Constructor
+	 */
+	public DefaultNoData() {
+	}
+	
+	/**
+	 * Constructor.
+	 * @param fileName
+	 * 	      Name of file owner of this nodata value. This string is useful to 
+	 *        save and load throw the rmf.
+	 */
+	public DefaultNoData(String fileName) {
+		this.fileName = fileName;
+	}
+	
+	/**
+	 * Constructor. Only for rasters with one band
+	 * 
+	 * @param noData
+	 *        value to assign to all bands
+	 * @param nativeNoData
+	 *        The native is the original value
+	 *        saved in the head of the file or its metadata.
+	 * @param fileName
+	 *        Name of file owner of this nodata value. This string is useful to 
+	 *        save and load throw the rmf.
+	 */
+	public DefaultNoData(Number noData, Number nativeNoData, String fileName) {
+		setValue(noData);
+		setNativeValue(nativeNoData);
+		this.fileName = fileName;
+		setDataType(noData);
+	}
+	
+	private void setDataType(Number number) {
+		if(number instanceof Byte)
+			dataType = Buffer.TYPE_BYTE;
+		if(number instanceof Short)
+			dataType = Buffer.TYPE_SHORT;
+		if(number instanceof Integer)
+			dataType = Buffer.TYPE_INT;
+		if(number instanceof Float)
+			dataType = Buffer.TYPE_FLOAT;
+		if(number instanceof Double)
+			dataType = Buffer.TYPE_DOUBLE;
+	}
+	
+	/**
+	 * Constructor
+	 * 
+	 * @param noData
+	 *        value to assign to all bands
+	 * @param nativeNoData
+	 *        The native is the original value
+	 *        saved in the head of the file or its metadata.
+	 * @param fileName
+	 *        Name of file owner of this nodata value. This string is useful to
+	 *        save the rmf file
+	 * @param bandCount
+	 *        Number of bands of the file
+	 */
+	public DefaultNoData(Number noData, Number nativeNoData, String fileName, int bandCount) {
+		setValue(noData);
+		setNativeValue(nativeNoData);
+		this.fileName = fileName;
+		setDataType(noData);
+		if(bandCount > 1)
+			this.bandCount = bandCount;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.fmap.dal.coverage.datastruct.NoData#getValue()
+	 */
+	public Number getValue() {
+		try {
+			return noDataByBand.get(0);
+		} catch (ArrayIndexOutOfBoundsException e) {
+			return null;
+		}
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.fmap.dal.coverage.datastruct.NoData#isDefined()
+	 */
+	public boolean isDefined() {
+		return (getValue() != null);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.fmap.dal.coverage.datastruct.NoData#setValue(java.lang.Number)
+	 */
+	public void setValue(Number noData) {
+		noDataByBand.clear();
+		for (int i = 0; i < bandCount; i++) {
+			noDataByBand.add(noData);	
+		}
+		setDataType(noData);
+	}
+	
+	public Number getNativeValue() {
+		try {
+			return nativeNoDataByBand.get(0);
+		} catch (ArrayIndexOutOfBoundsException e) {
+			return null;
+		}
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.fmap.dal.coverage.datastruct.NoData#setNativeValue(double)
+	 */
+	public void setNativeValue(Number nativeNoDataValue) {
+		nativeNoDataByBand.clear();
+		for (int i = 0; i < bandCount; i++) {
+			nativeNoDataByBand.add(nativeNoDataValue);	
+		}
+		setDataType(nativeNoDataValue);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.fmap.dal.coverage.datastruct.NoData#delete()
+	 */
+	public void delete() {
+		noDataByBand.clear();
+		for (int i = 0; i < bandCount; i++) {
+			noDataByBand.add(null);	
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.fmap.dal.coverage.datastruct.NoData#restore()
+	 */
+	public void restore() {
+		noDataByBand.clear();
+		for (int i = 0; i < bandCount; i++) {
+			noDataByBand.add(nativeNoDataByBand.get(i));	
+		}
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.fmap.dal.coverage.datastruct.NoData#setFileName(java.lang.String)
+	 */
+	public void setFileName(String fileName) {
+		this.fileName = fileName;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.buffer.BufferNoData#getFileName()
+	 */
+	public String getFileName() {
+		return fileName;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.fmap.dal.coverage.datastruct.NoData#isNoDataTransparent()
+	 */
+	public boolean isNoDataTransparent() {
+		return noDataAsTransparent;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.fmap.dal.coverage.datastruct.NoData#setNoDataTransparent(boolean)
+	 */
+	public void setNoDataTransparent(boolean noDataAsTransparent) {
+		this.noDataAsTransparent = noDataAsTransparent;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.fmap.dal.coverage.datastruct.NoData#getDataType()
+	 */
+	public int getDataType() {
+		return dataType;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.fmap.dal.coverage.datastruct.NoData#setDataType(int)
+	 */
+	public void setDataType(int datatype) {
+		this.dataType = datatype;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.fmap.dal.coverage.datastruct.NoData#compare(org.gvsig.fmap.dal.coverage.datastruct.NoData)
+	 */
+	@SuppressWarnings("unchecked")
+	public boolean compare(BufferNoData noData) {	
+		String f = ((DefaultNoData)noData).fileName;
+		
+		if((f == null || fileName == null) && f != fileName)
+			return false;
+		
+		if( fileName != null &&  f != null &&
+			fileName.compareTo(f) != 0)
+			return false;
+		
+		if(bandCount != ((DefaultNoData)noData).bandCount)
+			return false;
+		
+		if(dataType != ((DefaultNoData)noData).dataType)
+			return false;
+		
+		for (int i = 0; i < noDataByBand.size(); i++) {
+			if(((Comparable)noDataByBand.get(i)).compareTo(noData.getValue()) != 0)
+				return false;
+		}
+		for (int i = 0; i < nativeNoDataByBand.size(); i++) {
+			if(((Comparable)nativeNoDataByBand.get(i)).compareTo(noData.getValue()) != 0)
+				return false;
+		}
+		return true;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see java.lang.Object#clone()
+	 */
+	public Object clone() {
+		return new DefaultNoData(getValue(), getNativeValue(), fileName, bandCount);
+	}
+	
+	//***********************************************
+	//Only for file with more than one band
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.fmap.dal.coverage.datastruct.NoData#getValueByBand(int)
+	 */
+	public Number getValueByBand(int nBand) {
+		try {
+			return noDataByBand.get(nBand);
+		} catch (ArrayIndexOutOfBoundsException e) {
+			return null;
+		}
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.fmap.dal.coverage.datastruct.NoData#setValueByBand(java.lang.Number, int)
+	 */
+	public void setValueByBand(Number noDataValue, int nBand) {
+		noDataByBand.add(nBand, noDataValue);
+		setDataType(noDataValue);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.fmap.dal.coverage.datastruct.NoData#getBandCount()
+	 */
+	public int getBandCount() {
+		return bandCount;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.fmap.dal.coverage.datastruct.NoData#setBandCount(int)
+	 */
+	public void setBandCount(int bandCount) {
+		this.bandCount = bandCount;
+	}
+	
+}
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/deprecated/buffer/impl/datastruct/DefaultNoData.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/java/org/gvsig/raster/cache/tile/TestThreadPool.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/java/org/gvsig/raster/cache/tile/TestThreadPool.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/java/org/gvsig/raster/cache/tile/TestThreadPool.java	(revision 3222)
@@ -0,0 +1,119 @@
+package org.gvsig.raster.cache.tile;
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+import org.gvsig.raster.cache.tile.exception.TileGettingException;
+import org.gvsig.raster.cache.tile.impl.pool.ThreadPoolImpl;
+import org.gvsig.raster.cache.tile.pool.ThreadPool;
+import org.gvsig.raster.cache.tile.provider.Downloader;
+import org.gvsig.tools.library.impl.DefaultLibrariesInitializer;
+
+/**
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestThreadPool extends TestCase {
+	private static final int  WIDTH           = 3;
+	private static final int  HEIGHT          = 3;
+	private static final int  DOWNLOAD_TIME   = 500;
+	
+	public class MyDownloader implements Downloader {
+
+		public Tile downloadTile(Tile tile) {
+			//tile.getFile() -> Aqui se guarda el fichero descargado
+			try {
+				Thread.sleep(DOWNLOAD_TIME);
+			} catch (InterruptedException e) {
+				e.printStackTrace();
+			}
+			return tile;
+		}
+
+		public Tile readTileFromDisk(Tile tile) throws TileGettingException {
+			// TODO Auto-generated method stub
+			return null;
+		}
+		
+		/*
+		 * (non-Javadoc)
+		 * @see org.gvsig.raster.cache.tile.provider.Downloader#cancelDownloading(boolean)
+		 */
+		public void cancelDownloading(boolean cancel) {
+			
+		}
+
+		public Object[] getCrashImage(int w, int h) {
+			// TODO Auto-generated method stub
+			return null;
+		}
+
+		public Object[] getDownloadingImage(int w, int h) {
+			// TODO Auto-generated method stub
+			return null;
+		}
+		
+	}
+	
+	public void start() {
+		try {
+			this.doSetUp();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		this.testStack();
+	}
+	
+	protected void doSetUp() throws Exception {
+		System.err.println("TestThreadPool running...");
+	}
+	
+	public void testStack() {
+		new DefaultLibrariesInitializer().fullInitialize(true);
+		ThreadPool pool = new ThreadPoolImpl(false);
+		MyDownloader d = new MyDownloader();
+		
+		for (int x = 0; x < HEIGHT; x++) {
+			for (int y = 0; y < WIDTH; y++) {
+				Tile t = TileCacheLocator.getManager().createTile(0, x, y);
+				t.setSharedPipe(pool.getTilePipe());
+				t.setDownloader(d);
+				t.setFile(new File(""));
+				pool.addTask(t);
+			}
+		}
+		
+		int nCollected = 0;
+		while (nCollected < (WIDTH * HEIGHT)) {
+			Tile tile = (Tile)pool.getTilePipe().getAtomicTask();
+			System.out.println("Getting " + tile.getRow() + " " + tile.getCol() + " P:" + tile.getPriority());
+			nCollected ++;
+		}
+		if(pool != null)
+			pool.destroyPool();
+	}
+
+}
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/java/org/gvsig/raster/cache/tile/TestThreadPool.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/java/org/gvsig/raster/cache/tile/impl/pool/TestThreadPool.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/java/org/gvsig/raster/cache/tile/impl/pool/TestThreadPool.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/java/org/gvsig/raster/cache/tile/impl/pool/TestThreadPool.java	(revision 3222)
@@ -0,0 +1,114 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.tile.impl.pool;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+import org.gvsig.raster.cache.tile.Tile;
+import org.gvsig.raster.cache.tile.exception.TileGettingException;
+import org.gvsig.raster.cache.tile.impl.TileImpl;
+import org.gvsig.raster.cache.tile.impl.pool.ThreadPoolImpl;
+import org.gvsig.raster.cache.tile.provider.Downloader;
+
+/**
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestThreadPool extends TestCase {
+	private static final int  WIDTH           = 3;
+	private static final int  HEIGHT          = 3;
+	private static final int  DOWNLOAD_TIME   = 500;
+	
+	public class MyDownloader implements Downloader {
+
+		public Tile downloadTile(Tile tile) {
+			//tile.getFile() -> Aqui se guarda el fichero descargado
+			try {
+				Thread.sleep(DOWNLOAD_TIME);
+			} catch (InterruptedException e) {
+				e.printStackTrace();
+			}
+			return tile;
+		}
+
+		public Tile readTileFromDisk(Tile tile) throws TileGettingException {
+			// TODO Auto-generated method stub
+			return null;
+		}
+		
+		/*
+		 * (non-Javadoc)
+		 * @see org.gvsig.raster.cache.tile.provider.Downloader#cancelDownloading(boolean)
+		 */
+		public void cancelDownloading(boolean cancel) {
+			
+		}
+
+		public Object[] getCrashImage(int w, int h) {
+			// TODO Auto-generated method stub
+			return null;
+		}
+
+		public Object[] getDownloadingImage(int w, int h) {
+			// TODO Auto-generated method stub
+			return null;
+		}
+		
+	}
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+	
+	public void setUp() {
+		System.err.println("TestThreadPool running...");
+
+	}
+	
+	public void testStack() {
+		ThreadPoolImpl pool = new ThreadPoolImpl(false);
+		MyDownloader d = new MyDownloader();
+		org.gvsig.raster.cache.tile.impl.pool.TilePipeImpl pipe = new org.gvsig.raster.cache.tile.impl.pool.TilePipeImpl();
+		
+		for (int x = 0; x < HEIGHT; x++) {
+			for (int y = 0; y < WIDTH; y++) {
+				TileImpl t = new TileImpl(0, x, y);
+				t.setSharedPipe(pipe);
+				t.setDownloader(d);
+				t.setFile(new File(""));
+				pool.addTask(t);
+			}
+		}
+		
+		int nCollected = 0;
+		while (nCollected < (WIDTH * HEIGHT)) {
+			Tile tile = (Tile)pipe.getAtomicTask();
+			System.out.println("Getting " + tile.getRow() + " " + tile.getCol() + " P:" + tile.getPriority());
+			nCollected ++;
+		}
+		if(pool != null)
+			pool.destroyPool();
+	}
+}
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/java/org/gvsig/raster/cache/tile/impl/pool/TestThreadPool.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/java/org/gvsig/raster/cache/tile/impl/pool/TestThreadPoolWithPriorities.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/java/org/gvsig/raster/cache/tile/impl/pool/TestThreadPoolWithPriorities.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/java/org/gvsig/raster/cache/tile/impl/pool/TestThreadPoolWithPriorities.java	(revision 3222)
@@ -0,0 +1,119 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.tile.impl.pool;
+
+import java.io.File;
+import java.util.Random;
+
+import junit.framework.TestCase;
+
+import org.gvsig.raster.cache.tile.Tile;
+import org.gvsig.raster.cache.tile.exception.TileGettingException;
+import org.gvsig.raster.cache.tile.impl.TileImpl;
+import org.gvsig.raster.cache.tile.impl.pool.ThreadPoolImpl;
+import org.gvsig.raster.cache.tile.provider.Downloader;
+
+/**
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestThreadPoolWithPriorities extends TestCase {
+	private static final int  WIDTH           = 3;
+	private static final int  HEIGHT          = 3;
+	private static final int  DOWNLOAD_TIME   = 500;
+	
+	public class MyDownloader implements Downloader {
+
+		public Tile downloadTile(Tile tile) {
+			//tile.getFile() -> Aqui se guarda el fichero descargado
+			try {
+				Thread.sleep(DOWNLOAD_TIME);
+			} catch (InterruptedException e) {
+				e.printStackTrace();
+			}
+			return tile;
+		}
+
+		public Tile readTileFromDisk(Tile tile) throws TileGettingException {
+			// TODO Auto-generated method stub
+			return null;
+		}
+		
+		/*
+		 * (non-Javadoc)
+		 * @see org.gvsig.raster.cache.tile.provider.Downloader#cancelDownloading(boolean)
+		 */
+		public void cancelDownloading(boolean cancel) {
+			
+		}
+
+		public Object[] getCrashImage(int w, int h) {
+			// TODO Auto-generated method stub
+			return null;
+		}
+
+		public Object[] getDownloadingImage(int w, int h) {
+			// TODO Auto-generated method stub
+			return null;
+		}
+		
+	}
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+	
+	public void setUp() {
+		System.err.println("TestThreadPool running...");
+
+	}
+	
+	public void testStack() {
+		ThreadPoolImpl pool = new ThreadPoolImpl();
+		MyDownloader d = new MyDownloader();
+		org.gvsig.raster.cache.tile.impl.pool.TilePipeImpl pipe = new org.gvsig.raster.cache.tile.impl.pool.TilePipeImpl();
+		Random r = new Random();
+		
+		for (int x = 0; x < HEIGHT; x++) {
+			for (int y = 0; y < WIDTH; y++) {
+				TileImpl t = new TileImpl(0, x, y);
+				t.setSharedPipe(pipe);
+				t.setDownloader(d);
+				t.setFile(new File(""));
+				t.setPriority(r.nextInt());
+				pool.addTask(t);
+			}
+		}
+		
+		pool.init();
+		
+		int nCollected = 0;
+		while (nCollected < (WIDTH * HEIGHT)) {
+			Tile tile = (Tile)pipe.getAtomicTask();
+			System.out.println("Getting " + tile.getRow() + " " + tile.getCol() + " P:" + tile.getPriority());
+			nCollected ++;
+		}
+		if(pool != null)
+			pool.destroyPool();
+	}
+}
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/java/org/gvsig/raster/cache/tile/impl/pool/TestThreadPoolWithPriorities.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/java/org/gvsig/raster/cache/tile/impl/provider/TestCacheStruct.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/java/org/gvsig/raster/cache/tile/impl/provider/TestCacheStruct.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/java/org/gvsig/raster/cache/tile/impl/provider/TestCacheStruct.java	(revision 3222)
@@ -0,0 +1,75 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.tile.impl.provider;
+
+import junit.framework.TestCase;
+
+/**
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestCacheStruct extends TestCase {
+
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+	
+	public void setUp() {
+		System.err.println("TestCacheStruct running...");
+
+	}
+	
+	public void testStack() {
+        System.err.println("TODO: SOLVE THIS TEST");
+
+        // int levels = 25;
+        // FlatXFileSystemStrategy strat = new FlatXFileSystemStrategy();
+        // DefaultCacheStruct struct = new DefaultCacheStruct(
+        // CacheStruct.FLAT,
+        // levels,
+        // new Rectangle2D.Double(142671.0, 4194630.0, 228883.5, 255217.5),
+        // 28.5,
+        // 256,
+        // 256,
+        // "myLayer",
+        // strat,
+        // "baseDir",
+        // "tif");
+        // System.out.println("***World***");
+        // for (int i = 0; i < levels; i++) {
+        // System.out.println("-Level:" + i + " " +
+        // struct.getWorldWidthOfTileMatrixByLevel(i) + " X " +
+        // struct.getWorldHeightOfTileMatrixByLevel(i) + " : " +
+        // struct.getPixelSizeByLevel(i));
+        // }
+        //
+        // System.out.println("***Layer***");
+        // for (int i = 0; i < levels; i++) {
+        // System.out.println("Level:" + i +
+        // " X:" + struct.getLayerInitXTilePositionByLevel(i) +
+        // " Y:" + struct.getLayerInitYTilePositionByLevel(i) + ", " +
+        // struct.getLayerWidthOfTileMatrixByLevel(i) + " X " +
+        // struct.getLayerHeightOfTileMatrixByLevel(i));
+        // }
+	}
+}
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/java/org/gvsig/raster/cache/tile/impl/provider/TestCacheStruct.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/java/org/gvsig/raster/cache/tile/impl/download/TestThreadPool.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/java/org/gvsig/raster/cache/tile/impl/download/TestThreadPool.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/java/org/gvsig/raster/cache/tile/impl/download/TestThreadPool.java	(revision 3222)
@@ -0,0 +1,110 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.tile.impl.download;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+import org.gvsig.raster.cache.tile.Tile;
+import org.gvsig.raster.cache.tile.exception.TileGettingException;
+import org.gvsig.raster.cache.tile.impl.TileImpl;
+import org.gvsig.raster.cache.tile.impl.pool.ThreadPoolImpl;
+import org.gvsig.raster.cache.tile.pool.ThreadPool;
+import org.gvsig.raster.cache.tile.provider.Downloader;
+
+/**
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestThreadPool extends TestCase {
+	private static final int  WIDTH           = 3;
+	private static final int  HEIGHT          = 3;
+	private static final int  DOWNLOAD_TIME   = 500;
+	
+	public class MyDownloader implements Downloader {
+
+		public Tile downloadTile(Tile tile) {
+			//tile.getFile() -> Aqui se guarda el fichero descargado
+			try {
+				Thread.sleep(DOWNLOAD_TIME);
+			} catch (InterruptedException e) {
+				e.printStackTrace();
+			}
+			return tile;
+		}
+
+		public Tile readTileFromDisk(Tile tile) throws TileGettingException {
+			// TODO Auto-generated method stub
+			return null;
+		}
+
+		public void cancelDownloading(boolean cancel) {
+			// TODO Auto-generated method stub
+			
+		}
+
+		public Object[] getCrashImage(int w, int h) {
+			// TODO Auto-generated method stub
+			return null;
+		}
+
+		public Object[] getDownloadingImage(int w, int h) {
+			// TODO Auto-generated method stub
+			return null;
+		}
+	}
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+	
+	public void setUp() {
+		System.err.println("TestThreadPool running...");
+
+	}
+	
+	public void testStack() {
+		ThreadPool pool = new ThreadPoolImpl(false);
+		MyDownloader d = new MyDownloader();
+		
+		for (int x = 0; x < HEIGHT; x++) {
+			for (int y = 0; y < WIDTH; y++) {
+				TileImpl t = new TileImpl(0, x, y);
+				t.setSharedPipe(pool.getTilePipe());
+				t.setDownloader(d);
+				t.setFile(new File(""));
+				pool.addTask(t);
+			}
+		}
+		
+		int nCollected = 0;
+		while (nCollected < (WIDTH * HEIGHT)) {
+			Tile tile = (Tile)pool.getTilePipe().getAtomicTask();
+			System.out.println("Getting " + tile.getRow() + " " + tile.getCol() + " P:" + tile.getPriority());
+			nCollected ++;
+		}
+		if(pool != null)
+			pool.destroyPool();
+	}
+}
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/java/org/gvsig/raster/cache/tile/impl/download/TestThreadPool.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/java/org/gvsig/raster/cache/tile/impl/download/TestThreadPoolWithPriorities.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/java/org/gvsig/raster/cache/tile/impl/download/TestThreadPoolWithPriorities.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/java/org/gvsig/raster/cache/tile/impl/download/TestThreadPoolWithPriorities.java	(revision 3222)
@@ -0,0 +1,119 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.tile.impl.download;
+
+import java.io.File;
+import java.util.Random;
+
+import junit.framework.TestCase;
+
+import org.gvsig.raster.cache.tile.Tile;
+import org.gvsig.raster.cache.tile.exception.TileGettingException;
+import org.gvsig.raster.cache.tile.impl.TileImpl;
+import org.gvsig.raster.cache.tile.impl.pool.ThreadPoolImpl;
+import org.gvsig.raster.cache.tile.pool.ThreadPool;
+import org.gvsig.raster.cache.tile.provider.Downloader;
+
+/**
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TestThreadPoolWithPriorities extends TestCase {
+	private static final int  WIDTH           = 3;
+	private static final int  HEIGHT          = 3;
+	private static final int  DOWNLOAD_TIME   = 500;
+	
+	public class MyDownloader implements Downloader {
+
+		public Tile downloadTile(Tile tile) {
+			//tile.getFile() -> Aqui se guarda el fichero descargado
+			try {
+				Thread.sleep(DOWNLOAD_TIME);
+			} catch (InterruptedException e) {
+				e.printStackTrace();
+			}
+			return tile;
+		}
+
+		public Tile readTileFromDisk(Tile tile) throws TileGettingException {
+			// TODO Auto-generated method stub
+			return null;
+		}
+		
+		/*
+		 * (non-Javadoc)
+		 * @see org.gvsig.raster.cache.tile.provider.Downloader#cancelDownloading(boolean)
+		 */
+		public void cancelDownloading(boolean cancel) {
+			
+		}
+
+		public Object[] getCrashImage(int w, int h) {
+			// TODO Auto-generated method stub
+			return null;
+		}
+
+		public Object[] getDownloadingImage(int w, int h) {
+			// TODO Auto-generated method stub
+			return null;
+		}
+		
+	}
+	
+	public void start() {
+		this.setUp();
+		this.testStack();
+	}
+	
+	public void setUp() {
+		System.err.println("TestThreadPool running...");
+
+	}
+	
+	public void testStack() {
+		ThreadPool pool = new ThreadPoolImpl();
+		MyDownloader d = new MyDownloader();
+		Random r = new Random();
+		
+		for (int x = 0; x < HEIGHT; x++) {
+			for (int y = 0; y < WIDTH; y++) {
+				TileImpl t = new TileImpl(0, x, y);
+				t.setSharedPipe(pool.getTilePipe());
+				t.setDownloader(d);
+				t.setFile(new File(""));
+				t.setPriority(r.nextInt());
+				pool.addTask(t);
+			}
+		}
+		
+		((ThreadPoolImpl)pool).init();
+		
+		int nCollected = 0;
+		while (nCollected < (WIDTH * HEIGHT)) {
+			Tile tile = (Tile)pool.getTilePipe().getAtomicTask();
+			System.out.println("Getting " + tile.getRow() + " " + tile.getCol() + " P:" + tile.getPriority());
+			nCollected ++;
+		}
+		if(pool != null)
+			pool.destroyPool();
+	}
+}
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/java/org/gvsig/raster/cache/tile/impl/download/TestThreadPoolWithPriorities.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/resources/image/out-interpInvDistance.tif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/resources/image/out-interpInvDistance.tif
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/resources/image/prueba.tif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/resources/image/prueba.tif
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/resources/image/prueba.rmf
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/resources/image/prueba.rmf	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/resources/image/prueba.rmf	(revision 3222)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="ISO-8859-15"?>
+<RasterMetaFile>
+<FLyrGeoRaster>
+	<Extent>
+			<X>0.0</X>
+			<Y>3.0</Y>
+			<RotationX>0.0</RotationX>
+			<RotationY>0.0</RotationY>
+			<PixelSizeX>1.0</PixelSizeX>
+			<PixelSizeY>-1.0</PixelSizeY>
+			<Width>3.0</Width>
+			<Height>3.0</Height>
+	</Extent>
+	<Dimension>
+			<ImagePxWidth>3.0</ImagePxWidth>
+			<ImagePxHeight>3.0</ImagePxHeight>
+	</Dimension>
+</FLyrGeoRaster>
+</RasterMetaFile>
Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/resources/image/out-interpBSpline.tif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/resources/image/out-interpBSpline.tif
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/resources/image/001m09_1_0.tif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/resources/image/001m09_1_0.tif
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/resources/image/001m09_1_0.rmf
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/resources/image/001m09_1_0.rmf	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/resources/image/001m09_1_0.rmf	(revision 3222)
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="ISO-8859-15"?>
+<RasterMetaFile>
+<Statistics>
+	<BandCount>3</BandCount>
+	<Band>
+		<Max>124.0</Max>
+		<Min>-125.0</Min>
+		<SecondMax>118.0</SecondMax>
+		<SecondMin>-119.0</SecondMin>
+		<MaxRGB>255.0</MaxRGB>
+		<MinRGB>0.0</MinRGB>
+		<SecondMaxRGB>249.0</SecondMaxRGB>
+		<SecondMinRGB>6.0</SecondMinRGB>
+		<Mean>10.724756162873467</Mean>
+		<Variance>3732.9921559140375</Variance>
+	</Band>
+	<Band>
+		<Max>120.0</Max>
+		<Min>-128.0</Min>
+		<SecondMax>113.0</SecondMax>
+		<SecondMin>-121.0</SecondMin>
+		<MaxRGB>255.0</MaxRGB>
+		<MinRGB>0.0</MinRGB>
+		<SecondMaxRGB>248.0</SecondMaxRGB>
+		<SecondMinRGB>8.0</SecondMinRGB>
+		<Mean>-5.959546810839912</Mean>
+		<Variance>3170.059813419536</Variance>
+	</Band>
+	<Band>
+		<Max>115.0</Max>
+		<Min>-128.0</Min>
+		<SecondMax>102.0</SecondMax>
+		<SecondMin>-116.0</SecondMin>
+		<MaxRGB>255.0</MaxRGB>
+		<MinRGB>0.0</MinRGB>
+		<SecondMaxRGB>242.0</SecondMaxRGB>
+		<SecondMinRGB>13.0</SecondMinRGB>
+		<Mean>29.884241606350802</Mean>
+		<Variance>5352.010158331949</Variance>
+	</Band>
+</Statistics>
+<FLyrGeoRaster>
+	<Extent>
+			<X>687369.0</X>
+			<Y>5292882.0</Y>
+			<RotationX>0.0</RotationX>
+			<RotationY>0.0</RotationY>
+			<PixelSizeX>15.0</PixelSizeX>
+			<PixelSizeY>-15.0</PixelSizeY>
+			<Width>38565.0</Width>
+			<Height>29130.0</Height>
+	</Extent>
+	<Dimension>
+			<ImagePxWidth>2571.0</ImagePxWidth>
+			<ImagePxHeight>1942.0</ImagePxHeight>
+	</Dimension>
+</FLyrGeoRaster>
+<Histogram>
+	<BandCount>3</BandCount>
+	<DataType>0</DataType>
+	<Band>
+		<Min>-128.0</Min>
+		<Max>127.0</Max>
+		<Values>0 0 0 91443 0 0 0 0 0 87582 0 0 0 0 0 83416 0 0 0 0 0 80242 0 0 0 0 0 77785 0 0 0 0 0 0 76043 0 0 0 0 0 75204 0 0 0 0 0 73991 0 0 0 0 0 72935 0 0 0 0 0 0 71374 0 0 0 0 0 68978 0 0 0 0 0 65623 0 0 0 0 0 62017 0 0 0 0 0 57527 0 0 0 0 0 0 52522 0 0 0 0 0 46880 0 0 0 0 0 40535 0 0 0 0 0 34249 0 0 0 0 0 0 28144 0 0 0 0 0 21973 0 0 0 0 0 66785 154890 0 0 0 0 0 213232 0 0 0 0 0 332313 0 0 0 0 0 0 439405 0 0 0 0 0 495390 0 0 0 0 0 447438 0 0 0 0 0 330266 0 0 0 0 0 0 218374 0 0 0 0 0 143093 0 0 0 0 0 94619 0 0 0 0 0 63522 0 0 0 0 0 48709 0 0 0 0 0 0 46991 0 0 0 0 0 52318 0 0 0 0 0 60650 0 0 0 0 0 69485 0 0 0 0 0 0 77576 0 0 0 0 0 86087 0 0 0 0 0 92322 0 0 0 0 0 96139 0 0 0 0 0 94815 0 0 0</Values>
+	</Band>
+	<Band>
+		<Min>-128.0</Min>
+		<Max>127.0</Max>
+		<Values>60432 0 0 0 0 0 0 75527 0 0 0 0 0 0 0 92307 0 0 0 0 0 0 110369 0 0 0 0 0 0 0 126309 0 0 0 0 0 0 139939 0 0 0 0 0 0 0 149451 0 0 0 0 0 0 154194 0 0 0 0 0 0 0 154621 0 0 0 0 0 0 148426 0 0 0 0 0 0 0 136584 0 0 0 0 0 0 120553 0 0 0 0 0 0 0 102244 0 0 0 0 0 0 82065 0 0 0 0 0 0 0 62891 0 0 0 0 0 0 45204 0 0 0 0 0 0 0 30684 0 0 0 0 0 0 58527 198081 0 0 0 0 0 0 0 294634 0 0 0 0 0 0 463009 0 0 0 0 0 0 0 573354 0 0 0 0 0 0 531548 0 0 0 0 0 0 0 374029 0 0 0 0 0 0 232874 0 0 0 0 0 0 0 139815 0 0 0 0 0 0 78379 0 0 0 0 0 0 0 42064 0 0 0 0 0 0 28627 0 0 0 0 0 0 0 24092 0 0 0 0 0 0 23115 0 0 0 0 0 0 0 25295 0 0 0 0 0 0 29655 0 0 0 0 0 0 0 37025 0 0 0 0 0 0 46959 0 0 0 0 0 0 0</Values>
+	</Band>
+	<Band>
+		<Min>-128.0</Min>
+		<Max>127.0</Max>
+		<Values>243210 0 0 0 0 0 0 0 0 0 0 0 189162 0 0 0 0 0 0 0 0 0 0 0 0 158442 0 0 0 0 0 0 0 0 0 0 0 0 136969 0 0 0 0 0 0 0 0 0 0 0 0 117646 0 0 0 0 0 0 0 0 0 0 0 97359 0 0 0 0 0 0 0 0 0 0 0 0 77068 0 0 0 0 0 0 0 0 0 0 0 0 57309 0 0 0 0 0 0 0 0 0 0 0 0 39587 0 0 0 0 0 0 0 0 0 0 0 26383 0 0 0 0 0 0 0 0 0 0 0 0 51062 133876 0 0 0 0 0 0 0 0 0 0 0 0 135257 0 0 0 0 0 0 0 0 0 0 0 0 251799 0 0 0 0 0 0 0 0 0 0 0 385960 0 0 0 0 0 0 0 0 0 0 0 0 499935 0 0 0 0 0 0 0 0 0 0 0 0 575464 0 0 0 0 0 0 0 0 0 0 0 0 571982 0 0 0 0 0 0 0 0 0 0 0 500034 0 0 0 0 0 0 0 0 0 0 0 0 418372 0 0 0 0 0 0 0 0 0 0 0 0 326006 0 0 0 0 0 0 0 0 0 0 0 0</Values>
+	</Band>
+</Histogram>
+</RasterMetaFile>
Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/resources/image/out-interpBicubic.tif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/resources/image/out-interpBicubic.tif
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/resources/image/out-interpNearest.tif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/resources/image/out-interpNearest.tif
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/resources/image/clip_test_robufer.tif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/resources/image/clip_test_robufer.tif
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/resources/image/spain.tif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/resources/image/spain.tif
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/resources/image/out-interpBilinear.tif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/test/resources/image/out-interpBilinear.tif
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/disk/DefaultFileSystemStrategy.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/disk/DefaultFileSystemStrategy.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/disk/DefaultFileSystemStrategy.java	(revision 3222)
@@ -0,0 +1,28 @@
+package org.gvsig.raster.cache.tile.impl.disk;
+
+import org.gvsig.raster.cache.tile.disk.ITileFileSystemStrategy;
+
+
+public abstract class DefaultFileSystemStrategy implements ITileFileSystemStrategy {
+		
+	private String              tileNameSuffix;
+	private final static String DEFAULT_TILE_SUFFIX = ".tile.gvsig";
+	
+	public DefaultFileSystemStrategy() {
+		
+	}
+	
+	public DefaultFileSystemStrategy(String tileNameSuffix) {	
+		this.tileNameSuffix = tileNameSuffix;	
+	}
+	
+	public String getTileNameSuffix() {
+		if (tileNameSuffix == null)
+			return DEFAULT_TILE_SUFFIX;
+		return this.tileNameSuffix;
+	}
+	
+	public void setTileNameSuffix(String suffix) {
+		this.tileNameSuffix = suffix;
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/disk/DefaultFileSystemStrategy.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/disk/FlatXFileSystemStrategy.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/disk/FlatXFileSystemStrategy.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/disk/FlatXFileSystemStrategy.java	(revision 3222)
@@ -0,0 +1,101 @@
+/* TileRasterCache, a library to download tiles from several sources.
+ *
+ * Copyright (C) 2010 Prodevelop SL.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *  
+ *   Prodevelop Integraci�n de Tecnolog�as SL
+ *   Plaza don Juan de Vilarrasa , 14-5
+ *   46000 Valencia
+ *   Spain
+ *
+ *   +34 963 510 612
+ *   +34 963 510 968
+ *   gis@prodevelop.es
+ *   http://www.prodevelop.es
+ *   
+ *   author: Alberto Romeu Carrasco (aromeu@prodevelop.es)
+ */
+
+package org.gvsig.raster.cache.tile.impl.disk;
+
+import java.io.File;
+
+
+/**
+ * This IFileSystemStrategy creates a directory for each zoom level of a layer.
+ * Inside the directory of a zoom level, creates a directory for each X row and
+ * inside the directory of an X row stores a file with the Y row, so
+ * OSM/0/0/0.tile represents the tile http://osm/0/0/0.png
+ * 
+ * This strategy is the most spread for mobile map viewers (although is not the most efficient)
+ * @author aromeu
+ *
+ */
+public class FlatXFileSystemStrategy extends DefaultFileSystemStrategy {
+	
+	public FlatXFileSystemStrategy() {
+		super();
+	}
+
+	public FlatXFileSystemStrategy(String tileNameSuffix) {
+		super(tileNameSuffix);		
+	}
+
+	public String getRelativeToLayerDirTilePath(int row, 
+			int col, 
+			int zoomLevel, 
+			String var, 
+			String z, 
+			String time) {
+		if(zoomLevel < 0) {  //Real zoom level
+			return new StringBuffer()
+			.append(var)
+			.append(File.separator)
+			.append(z)
+			.append(File.separator)
+			.append(time)
+			.append(File.separator)
+			.append("real")
+			.append(File.separator)
+			.append(col)
+			.append(File.separator)
+			.append(row).toString();
+		} else {
+			return new StringBuffer()
+			.append(var)
+			.append(File.separator)
+			.append(z)
+			.append(File.separator)
+			.append(time)
+			.append(File.separator)
+			.append(zoomLevel)
+			.append(File.separator)
+			.append(col)
+			.append(File.separator)
+			.append(row).toString();
+		}
+	}
+	
+	public String getLayerNameSuffix() {
+		return "_flatx";
+	}	
+
+	public String getName() {
+		return FLATX;
+	}	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/disk/FlatXFileSystemStrategy.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/provider/TileMatrix.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/provider/TileMatrix.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/provider/TileMatrix.java	(revision 3222)
@@ -0,0 +1,122 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.tile.impl.provider;
+
+
+/**
+ * Description of a tile matrix
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TileMatrix {
+    private double                      scaleDenominator    = 0;
+    private double[]                    topLeftCorner       = null;
+    private int                         tileWidth           = 0;
+    private int                         tileHeight          = 0;
+    private long                        matrixWidth         = 0;
+    private long                        matrixHeight        = 0;
+    private static final double         MTS_X_GRADO         = 111319.490793274;
+    
+	public double getScaleDenominator() {
+		return scaleDenominator;
+	}
+
+	public void setScaleDenominator(double scaleDenominator) {
+		this.scaleDenominator = scaleDenominator;
+	}
+
+	public int getTileWidth() {
+		return tileWidth;
+	}
+
+	public void setTileWidth(int tileWidth) {
+		this.tileWidth = tileWidth;
+	}
+
+	public int getTileHeight() {
+		return tileHeight;
+	}
+
+	public void setTileHeight(int tileHeight) {
+		this.tileHeight = tileHeight;
+	}
+
+	public long getMatrixWidth() {
+		return matrixWidth;
+	}
+
+	public void setMatrixWidth(long matrixWidth) {
+		this.matrixWidth = matrixWidth;
+	}
+
+	public long getMatrixHeight() {
+		return matrixHeight;
+	}
+
+	public void setMatrixHeight(long matrixHeight) {
+		this.matrixHeight = matrixHeight;
+	}
+
+	public double[] getTopLeftCorner() {
+		return topLeftCorner;
+	}
+	
+	public void setTopLeftCorner(double[] topLeftCorner) {
+		this.topLeftCorner = topLeftCorner;
+	}
+    
+    /**
+     * Gets the width in meters of a tile
+     * @param projected
+     * @return
+     */
+    public double getWidthMtsTile(boolean projected) {
+    	if(!projected) {
+    		return (scaleDenominator * tileWidth * 0.00028) / MTS_X_GRADO;
+    	} else {
+    		return (scaleDenominator * tileWidth * 0.00028);
+    	}
+    }
+    
+    /**
+     * Gets the height in meters of a tile
+     * @param projected
+     * @return
+     */
+    public double getHeightMtsTile(boolean projected) {
+    	if(!projected) {
+    		return (scaleDenominator * tileHeight * 0.00028) / MTS_X_GRADO;
+    	} else {
+    		return (scaleDenominator * tileHeight * 0.00028);
+    	}
+    }
+    
+	public void print() {
+		System.out.println("   *****TileMatrix******");
+		System.out.println("   scaleDenominator:" + getScaleDenominator());
+		if(topLeftCorner != null)
+			System.out.println("   topLeftCorner:" + topLeftCorner[0] + ", " + topLeftCorner[1]);
+		System.out.println("   tileWidth:" + getTileWidth());
+		System.out.println("   tileHeight:" + getTileHeight());
+		System.out.println("   matrixWidth:" + getMatrixWidth());
+		System.out.println("   matrixHeight:" + getMatrixHeight());
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/provider/TileMatrix.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/provider/TileMatrixLimits.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/provider/TileMatrixLimits.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/provider/TileMatrixLimits.java	(revision 3222)
@@ -0,0 +1,101 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.tile.impl.provider;
+
+import java.awt.geom.Point2D;
+
+/**
+ * Limits of a tile matrix
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TileMatrixLimits {
+	private TileMatrix             tileMatrix           = null;
+	private int                    minTileRow           = 0;
+	private int                    maxTileRow           = 0;
+	private int                    minTileCol           = 0;
+	private int                    maxTileCol           = 0;
+	
+	public TileMatrix getTileMatrix() {
+		if(tileMatrix == null)
+			tileMatrix = new TileMatrix();
+		return tileMatrix;
+	}
+
+	/**
+	 * Gets the upper left corner and the lower right corner of the 
+	 * selected tile
+	 * @param x X tile position
+	 * @param y Y tile position
+	 * @return
+	 */
+	public Point2D[] getTileExtent(int x, int y) {
+		double sizeTile = getTileMatrix().getTileWidth() * getTileMatrix().getScaleDenominator();
+		double initX = getTileMatrix().getTopLeftCorner()[0] + (sizeTile * x);
+		double initY = getTileMatrix().getTopLeftCorner()[1] - (sizeTile * y);
+		Point2D[] p = new Point2D[2];
+		p[0] = new Point2D.Double(initX, initY);
+		p[1] = new Point2D.Double(initX + sizeTile, initY - sizeTile);
+		return p;
+	}
+	
+	public int getMinTileRow() {
+		return minTileRow;
+	}
+	
+	public void setMinTileRow(int minTileRow) {
+		this.minTileRow = minTileRow;
+	}
+	
+	public int getMaxTileRow() {
+		return maxTileRow;
+	}
+	
+	public void setMaxTileRow(int maxTileRow) {
+		this.maxTileRow = maxTileRow;
+	}
+	
+	public int getMinTileCol() {
+		return minTileCol;
+	}
+	
+	public void setMinTileCol(int minTileCol) {
+		this.minTileCol = minTileCol;
+	}
+	
+	public int getMaxTileCol() {
+		return maxTileCol;
+	}
+	
+	public void setMaxTileCol(int maxTileCol) {
+		this.maxTileCol = maxTileCol;
+	}
+	
+	public void print() {
+		System.out.println("  *****TileMatrixLimits******");
+		System.out.println("  MaxTileCol:" + getMaxTileCol());
+		System.out.println("  MaxTileRow:" + getMaxTileRow());
+		System.out.println("  MinTileCol:" + getMinTileCol());
+		System.out.println("  MinTileRow:" + getMinTileRow());
+		if(tileMatrix != null)
+			tileMatrix.print();
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/provider/TileMatrixLimits.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/provider/DefaultCacheStruct.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/provider/DefaultCacheStruct.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/provider/DefaultCacheStruct.java	(revision 3222)
@@ -0,0 +1,389 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.tile.impl.provider;
+
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.gvsig.raster.cache.tile.Tile;
+import org.gvsig.raster.cache.tile.TileCacheLocator;
+import org.gvsig.raster.cache.tile.disk.ITileFileSystemStrategy;
+import org.gvsig.raster.cache.tile.exception.TileBuildException;
+import org.gvsig.raster.cache.tile.impl.TileImpl;
+import org.gvsig.raster.cache.tile.provider.CacheStruct;
+
+/**
+ * Implementation for a structure of a cache
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class DefaultCacheStruct implements CacheStruct {
+    private TileMatrixSet                 tileMatrixSet  = null;
+    private ArrayList<TileMatrixLimits>   limits         = null;
+    private String                        layerName      = null;
+    private String                        uri            = null;
+	private Rectangle2D                   worldExtent    = null;
+	private String                        fileSuffix     = null;
+	private String                        epsg           = null;
+	private long                          fileSize       = 0;
+	private double                        realPixelSize  = 0;
+	private Rectangle2D                   layerExtent    = null;
+    
+    public DefaultCacheStruct(int typeOfCoords, 
+    		int levels, 
+    		Rectangle2D layerExtent, 
+    		double pixelSize,
+    		int tilePxWidth,
+    		int tilePxHeight,
+    		String uri,
+    		String layerName,
+    		ITileFileSystemStrategy strategy,
+    		String baseDir,
+    		String fileSuffix,
+    		String epsg,
+    		long size) {
+    	this.uri = uri;
+    	this.layerName = layerName;
+    	this.fileSuffix = fileSuffix;
+    	this.fileSize = size;
+    	this.realPixelSize = pixelSize;
+    	this.layerExtent = layerExtent;
+    	if(epsg != null && epsg.startsWith("EPSG:"))
+    		this.epsg = epsg;
+    	
+    	//Coordenadas del mundo en geogr�ficas y planas
+    	
+    	if(typeOfCoords == CacheStruct.GEOGRAFIC) {
+    		worldExtent = new Rectangle2D.Double(-180, -90, 360, 180);
+    	} 
+    	if(typeOfCoords == CacheStruct.FLAT) {
+    		worldExtent = new Rectangle2D.Double(-20037508, -20037508, 40075016, 40075016);
+    	}
+    	
+    	double[] pixelSizeList = buildWorldMatrix(typeOfCoords, levels, tilePxWidth, tilePxHeight, worldExtent);
+        buildLayerMatrix(levels, tilePxWidth, tilePxHeight, worldExtent, layerExtent, pixelSizeList, pixelSize);
+    }
+    
+    private void buildLayerMatrix(int levels, 
+    		int tilePxWidth, 
+    		int tilePxHeight,
+    		Rectangle2D worldExtent,
+    		Rectangle2D layerExtent,
+    		double[] pixelSizeList,
+    		double maxPixelSize) {
+    	limits = new ArrayList<TileMatrixLimits>();
+
+    	for (int i = 0; i < levels; i++) {
+    		//Calculo de tiles para ese nivel en la capa actual
+    		int minTileCol = (int)(Math.abs(layerExtent.getMinX() - worldExtent.getMinX()) / pixelSizeList[i]) / tilePxWidth;
+    		int minTileRow = (int)(Math.abs(layerExtent.getMaxY() - worldExtent.getMaxY()) / pixelSizeList[i]) / tilePxHeight;
+    		int maxTileCol = (int)(Math.abs(layerExtent.getMaxX() - worldExtent.getMinX()) / pixelSizeList[i]) / tilePxWidth;
+    		int maxTileRow = (int)(Math.abs(layerExtent.getMinY() - worldExtent.getMaxY()) / pixelSizeList[i]) / tilePxHeight;
+    		
+    		//int imageTileWidth = (int)Math.ceil((layerExtent.getWidth() / pixelSizeList[i]) / tilePxWidth);
+    		//int imageTileHeight = (int)Math.ceil((layerExtent.getHeight() / pixelSizeList[i]) / tilePxHeight);
+    		TileMatrixLimits limit = new TileMatrixLimits();
+    		limit.setMinTileRow(minTileRow);
+    		limit.setMinTileCol(minTileCol);
+    		limit.setMaxTileRow(maxTileRow);
+    		limit.setMaxTileCol(maxTileCol);
+    		
+    		//Calcula las coordenadas de la esquina superior izquierda del TileMatrixLimits
+    		double ulx = worldExtent.getMinX() + (minTileCol * tilePxWidth * pixelSizeList[i]);
+    		double uly = worldExtent.getMaxY() - (minTileRow * tilePxHeight * pixelSizeList[i]);
+    		limit.getTileMatrix().setTopLeftCorner(new double[]{ulx, uly});
+    		limit.getTileMatrix().setScaleDenominator(pixelSizeList[i]);
+    		limit.getTileMatrix().setTileWidth(tilePxWidth);
+    		limit.getTileMatrix().setTileHeight(tilePxHeight);
+    		
+    		limits.add(limit);
+    		if(i == (levels - 1) || (maxPixelSize != Double.POSITIVE_INFINITY && maxPixelSize != Double.NEGATIVE_INFINITY && pixelSizeList[i] < maxPixelSize)) {
+    			//System.out.println("Image res:" + maxPixelSize + " Real res:" + pixelSizeList[i]);
+    			break;
+    		}
+    	}
+    }
+    
+    private double[] buildWorldMatrix(int typeOfCoords,
+    		int levels, 
+    		int tilePxWidth, 
+    		int tilePxHeight,
+    		Rectangle2D worldExtent) {
+    	double[] pixelSizeList = new double[levels];
+    	
+    	limits = new ArrayList<TileMatrixLimits>();
+    	tileMatrixSet = new TileMatrixSet();
+    	tileMatrixSet.setBbox(worldExtent);
+    	
+    	int nTilesWidth = 0;
+    	int nTilesHeight = 0;
+    		
+    	for (int i = 0; i < levels; i++) {
+    		TileMatrix tm = new TileMatrix();
+    		tm.setTileWidth(tilePxWidth);
+    		tm.setTileHeight(tilePxHeight);
+    		if(i == 0) {
+    			nTilesWidth = (typeOfCoords == CacheStruct.FLAT) ? 1 : 2;
+    			nTilesHeight = 1;
+    		} else {
+    			nTilesWidth *= 2;
+    			nTilesHeight *= 2;
+    		}
+    		
+    		tm.setMatrixWidth(nTilesWidth);
+    		tm.setMatrixHeight(nTilesHeight);
+    		if(tilePxWidth > 0 && nTilesWidth > 0)
+    			pixelSizeList[i] = worldExtent.getWidth() / ((long)tilePxWidth * (long)nTilesWidth);
+    		else
+    			pixelSizeList[i] = 0;
+    		//System.out.println("-Level:" + i + " " + nTilesWidth + " " + nTilesHeight + " " + pixelSizeList[i]);
+    		tm.setScaleDenominator(pixelSizeList[i]);
+    		tileMatrixSet.getTileMatrix().add(tm);
+    	}
+    	return pixelSizeList;
+    }
+    
+    public Rectangle2D getWorldExtent() {
+    	return worldExtent;
+    }
+
+	public int getNumberOfLevels() {
+		return tileMatrixSet.getTileMatrix().size();
+	}
+
+	public String getLayerName() {
+		return layerName;
+	}
+
+	public String getServerURL() {
+		return uri;
+	}
+
+	public String getFileSuffix() {
+		return fileSuffix;
+	}
+
+	public int[] getTileSizeByLevel(int level) {
+		return new int[] {
+			tileMatrixSet.getTileMatrix().get(level).getTileWidth(),
+			tileMatrixSet.getTileMatrix().get(level).getTileHeight()
+		};
+	}
+
+	public double[] getTileSizeInRealCoordsByLevel(int level) {
+		return new double[] {
+				getPixelSizeByLevel(level) * tileMatrixSet.getTileMatrix().get(level).getTileWidth(),
+				getPixelSizeByLevel(level) *  tileMatrixSet.getTileMatrix().get(level).getTileHeight()
+			};
+	}
+
+	public int getLayerWidthOfTileMatrixByLevel(int level) {
+		if(level < limits.size()) {
+			TileMatrixLimits l = limits.get(level);
+			return (l.getMaxTileRow() - l.getMinTileRow()) + 1;
+		}
+		return 0;
+	}
+
+	public int getLayerHeightOfTileMatrixByLevel(int level) {
+		if(level < limits.size()) {
+			TileMatrixLimits l = limits.get(level);
+			return (l.getMaxTileCol() - l.getMinTileCol()) + 1;
+		}
+		return 0;
+	}
+
+	public int getLayerInitXTilePositionByLevel(int level) {
+		TileMatrixLimits l = limits.get(level);
+		return l.getMinTileCol();
+	}
+
+	public int getLayerInitYTilePositionByLevel(int level) {
+		TileMatrixLimits l = limits.get(level);
+		return l.getMinTileRow();
+	}
+
+	public long getWorldHeightOfTileMatrixByLevel(int level) {
+		return tileMatrixSet.getTileMatrix().get(level).getMatrixWidth();
+	}
+
+	public long getWorldWidthOfTileMatrixByLevel(int level) {
+		return tileMatrixSet.getTileMatrix().get(level).getMatrixHeight();
+	}
+	
+	public double getPixelSizeByLevel(int level) {
+		if(level < 0)
+			return realPixelSize;
+		return tileMatrixSet.getTileMatrix().get(level).getScaleDenominator();
+	}
+	
+	public Point2D[] getTileExtent(Tile tile) {
+		return limits.get(tile.getLevel()).getTileExtent(tile.getRow(), tile.getCol());
+	}
+	
+	public Point2D[] getTileExtent(int level, int col, int row) {
+		return limits.get(level).getTileExtent(row, col);
+	}
+	
+	public Tile getTileStructure(int level, int tileCol, int tileRow, Point2D ul, Point2D lr) throws TileBuildException  {
+		int[] size = getTileSizeByLevel(level);
+		Tile tile = TileCacheLocator.getManager().createTile(level, tileRow, tileCol);
+		tile.setUl(ul);
+		tile.setLr(lr);
+		tile.setWidthPx(size[0]);
+		tile.setHeightPx(size[1]);
+		
+		return tile;
+	}
+	
+	public List<Tile> getTileList(Rectangle2D r) {
+		int tilePxWidth = tileMatrixSet.getTileMatrix().get(0).getTileWidth();
+		int tilePxHeight = tileMatrixSet.getTileMatrix().get(0).getTileHeight();
+		int minTileCol = (int)(r.getX() / tilePxWidth);
+		int minTileRow = (int)(r.getY() / tilePxHeight);
+		int maxTileCol = (int)((r.getX() + r.getWidth()) / tilePxWidth);
+		int maxTileRow = (int)((r.getY() + r.getHeight()) / tilePxHeight);
+		double tileWCWidth = tilePxWidth * realPixelSize;
+		double tileWCHeight = tilePxHeight * realPixelSize;
+		
+		//Calculo de tiles con sus coordenadas
+		List<Tile> tileList = new ArrayList<Tile>();
+		for (int i = minTileRow; i <= maxTileRow; i++) {
+			for (int j = minTileCol; j <= maxTileCol; j++) {
+				Point2D ulTile = new Point2D.Double(
+						layerExtent.getMinX() + (tileWCWidth * j),
+						layerExtent.getMaxY() - (tileWCHeight * i));
+				Point2D lrTile = new Point2D.Double(ulTile.getX() + tileWCWidth, ulTile.getY() - tileWCHeight);
+				Tile t = new TileImpl(tilePxWidth, tilePxHeight, i, j, ulTile, lrTile);
+				t.setLevel(-1);
+				int initTileX = tilePxWidth * j;
+				int initTileY = tilePxHeight * i;
+				Rectangle2D rTile = new Rectangle2D.Double(initTileX, initTileY, tilePxWidth, tilePxHeight);
+				t.setCoordsPx(rTile);
+				tileList.add(t);
+			}
+		}
+		return tileList;
+	}
+	
+	public List<Tile> getTileList(Point2D ul, Point2D lr, double mtsPixelRequest) {
+		return getTileList(ul, lr, mtsPixelRequest, false);
+	}
+	
+	public List<Tile> getTileList(Point2D ul, Point2D lr, double mtsPixelRequest, boolean increaseResolution) {
+		//Selecci�n de nivel de resoluci�n
+		int tilePxWidth = 0;
+		int tilePxHeight = 0;
+		double tileWCWidth = 0;
+		double tileWCHeight = 0;
+		int level = 0;
+		double mtsPixelLevel = 0;
+		boolean levelAssigned = false;
+		for (int i = 0; i < tileMatrixSet.getTileMatrix().size(); i++) {
+			mtsPixelLevel = tileMatrixSet.getTileMatrix().get(i).getScaleDenominator();
+			if(clipDecimals(mtsPixelRequest, 6) >= clipDecimals(mtsPixelLevel, 6) || 
+			   (!levelAssigned && i == (tileMatrixSet.getTileMatrix().size() - 1))) {
+				level = Math.max(i, 0);
+				if(increaseResolution)
+					level ++;
+				
+				//Se ajusta al m�ximo nivel disponible para esa capa
+				if(level > (limits.size() - 1)) {
+					level = limits.size() - 1;
+				}
+				
+				mtsPixelLevel = tileMatrixSet.getTileMatrix().get(level).getScaleDenominator();
+				
+				tilePxWidth = tileMatrixSet.getTileMatrix().get(level).getTileWidth();
+				tilePxHeight = tileMatrixSet.getTileMatrix().get(level).getTileHeight();
+				
+				tileWCWidth = tilePxWidth * mtsPixelLevel;
+				tileWCHeight = tilePxHeight * mtsPixelLevel;
+				levelAssigned = true;
+				break;
+			}
+		}
+		
+		//Calculo del rectangulo de tiles
+		int minTileCol = (int)((Math.abs(ul.getX() - worldExtent.getMinX()) / mtsPixelLevel) / tilePxWidth);
+		int minTileRow = (int)((Math.abs(ul.getY() - worldExtent.getMaxY()) / mtsPixelLevel) / tilePxHeight);
+		double maxTC = ((Math.abs(lr.getX() - worldExtent.getMinX()) / mtsPixelLevel) / tilePxWidth);
+		double maxTR = ((Math.abs(lr.getY() - worldExtent.getMaxY()) / mtsPixelLevel) / tilePxHeight);
+		int maxTileCol = ((maxTC - ((int)maxTC)) == 0) ? (int)(maxTC - 1) : (int)maxTC;
+		int maxTileRow = ((maxTR - ((int)maxTR)) == 0) ? (int)(maxTR - 1) : (int)maxTR;
+		
+		//Calculo de tiles con sus coordenadas
+		List<Tile> tileList = new ArrayList<Tile>();
+		for (int i = minTileRow; i <= maxTileRow; i++) {
+			for (int j = minTileCol; j <= maxTileCol; j++) {
+				Point2D ulTile = new Point2D.Double(
+						worldExtent.getMinX() + (tileWCWidth * j),
+						worldExtent.getMaxY() - (tileWCHeight * i));
+				Point2D lrTile = new Point2D.Double(ulTile.getX() + tileWCWidth, ulTile.getY() - tileWCHeight);
+				Tile t = new TileImpl(tilePxWidth, tilePxHeight, i, j, ulTile, lrTile);
+				t.setLevel(level);
+				tileList.add(t);
+			}
+		}
+		return tileList;
+	}
+	
+	public boolean compare(CacheStruct struct) {
+		//Compara: n�mero de niveles, tama�o de tile, 
+		//anchoXalto de la matriz, tama�o de pixel por nivel, 
+		//coordenadas de al menos un tile de la matriz
+		if(struct.getNumberOfLevels() == getNumberOfLevels()) {
+			for (int i = 0; i < getNumberOfLevels(); i++) {
+				if(	struct.getTileSizeByLevel(i)[0] == getTileSizeByLevel(i)[0] && 
+					struct.getTileSizeByLevel(i)[1] == getTileSizeByLevel(i)[1] &&
+					struct.getWorldHeightOfTileMatrixByLevel(i) == getWorldHeightOfTileMatrixByLevel(i) &&
+					struct.getWorldWidthOfTileMatrixByLevel(i) == getWorldWidthOfTileMatrixByLevel(i) &&
+					clipDecimals(struct.getPixelSizeByLevel(i), 2) == clipDecimals(getPixelSizeByLevel(i), 2) &&
+					compareExtents(struct.getTileExtent(i, 0, 0), getTileExtent(i, 0, 0))) {
+					return true;
+				}
+			}
+		}
+		return false;
+	}
+	
+	public String getEPSG() {
+		return epsg;
+	}
+
+	public String getFileSize() {
+		return fileSize + "";
+	}
+	
+	private boolean compareExtents(Point2D[] p, Point2D[] p1) {
+		return (p[0].getX() == p1[0].getX() && p[0].getY() == p1[0].getY() &&
+				p[1].getX() == p1[1].getX() && p[1].getY() == p1[1].getY());
+	}
+	
+	public double clipDecimals(double num, int n) {
+		long m = (long) Math.pow(10, n);
+		long aux = Math.round(num * m);
+		return (double) aux / (double) m;
+	}
+
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/provider/DefaultCacheStruct.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/provider/TileMatrixSet.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/provider/TileMatrixSet.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/provider/TileMatrixSet.java	(revision 3222)
@@ -0,0 +1,77 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.tile.impl.provider;
+
+import java.awt.geom.Rectangle2D;
+import java.io.IOException;
+import java.util.ArrayList;
+
+import org.kxml2.io.KXmlParser;
+import org.xmlpull.v1.XmlPullParserException;
+
+
+/**
+ * <p>Defines a set of tiles</p>
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TileMatrixSet {
+    protected Rectangle2D                 bbox                = null;
+    private String                        supportedCRS        = null;
+    protected ArrayList<TileMatrix>       tileMatrix          = null;
+    
+	public void setBbox(Rectangle2D bbox) {
+		this.bbox = bbox;
+	}
+	
+    public Rectangle2D getBoundingBox() {
+    	return bbox;
+    }
+	
+	public ArrayList<TileMatrix> getTileMatrix() {
+		if(tileMatrix == null)
+			tileMatrix = new ArrayList<TileMatrix>();
+		return tileMatrix;
+	}
+
+	public String getSupportedCRS() {
+		return supportedCRS;
+	}
+
+	public void setSupportedCRS(String supportedCRS) {
+		this.supportedCRS = supportedCRS;
+	}
+	
+	public void parse(KXmlParser parser) throws IOException,
+			XmlPullParserException {
+	}
+	
+	public void print() {
+		System.out.println("*****TileMatrixSet******");
+		if(bbox != null)
+			System.out.println(bbox.toString());
+		System.out.println("supportedCRS:" + getSupportedCRS());
+		for (int i = 0; i < tileMatrix.size(); i++) {
+			((TileMatrix)tileMatrix.get(i)).print();	
+		}
+		
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/provider/TileMatrixSet.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/layer/TimerTilePool.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/layer/TimerTilePool.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/layer/TimerTilePool.java	(revision 3222)
@@ -0,0 +1,94 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.tile.impl.layer;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.Timer;
+
+import org.gvsig.raster.cache.tile.impl.DefaultTileCacheManager;
+import org.gvsig.raster.cache.tile.impl.pool.ThreadPoolImpl;
+import org.gvsig.raster.cache.tile.provider.TileListener;
+
+/**
+ * Timer for one tile
+ *
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TimerTilePool implements ActionListener {
+	private Timer                timer          = null;
+	private ThreadPoolImpl       tilePool       = null;
+	private TileListener         listener       = null;
+	
+	public TimerTilePool(ThreadPoolImpl tilePool) {
+		this.tilePool = tilePool;
+	}
+	
+	/**
+	 * Sets the tile listener to send the tile ready signal 
+	 * @param tile
+	 */
+	public void setListener(TileListener listener) {
+		this.listener = listener;
+	}
+	
+	/**
+	 * Starts the timer
+	 */
+	public void start() {
+		getTimer().start();
+	}
+	
+	/**
+	 * Stops the timer
+	 */
+	public void stop() {
+		getTimer().stop();
+	}
+	
+	/**
+	 * Restarts the timer
+	 */
+	public void restart() {
+		getTimer().restart();
+	}
+	
+	/**
+	 * Gets the timer
+	 * @return
+	 */
+	private Timer getTimer() {
+		if(timer == null)
+			timer = new Timer(DefaultTileCacheManager.TILE_TIME_OUT, this);
+		return timer;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+	 */
+	public void actionPerformed(ActionEvent e) {
+		tilePool.cancelPool(listener);
+		tilePool.getTilePipe().setAtomicTask(null);
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/layer/TimerTilePool.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/layer/TiledLayerImpl.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/layer/TiledLayerImpl.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/layer/TiledLayerImpl.java	(revision 3222)
@@ -0,0 +1,323 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.tile.impl.layer;
+
+import java.io.File;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.List;
+
+import org.gvsig.raster.cache.tile.Tile;
+import org.gvsig.raster.cache.tile.disk.ITileFileSystemStrategy;
+import org.gvsig.raster.cache.tile.exception.TileGettingException;
+import org.gvsig.raster.cache.tile.impl.TileCacheImpl;
+import org.gvsig.raster.cache.tile.impl.TileImpl;
+import org.gvsig.raster.cache.tile.impl.pool.ThreadPoolImpl;
+import org.gvsig.raster.cache.tile.layer.TiledLayer;
+import org.gvsig.raster.cache.tile.provider.CacheStruct;
+import org.gvsig.raster.cache.tile.provider.TileListener;
+import org.gvsig.raster.cache.tile.provider.TileServer;
+import org.gvsig.tools.task.TaskStatus;
+
+/**
+ * Main implementation for the tile cache
+ *
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TiledLayerImpl implements TiledLayer {
+	private TileServer                  provider          = null;
+	private TileCacheImpl               tileCache         = null;
+	private String                      basePath          = null;
+	private String                      pathToDirLayer    = null;
+	private String                      idLayer           = null;
+	//private LRUTileCache                memoryCache = null;
+	private ThreadPoolImpl              pool              = null;
+	private ITileFileSystemStrategy     strategy          = null;
+	private TimerOneTile                timerOneTile      = null;
+	private TimerTilePool               timerTilePool     = null;
+	
+	public TiledLayerImpl(TileCacheImpl tileCache, 
+			TileServer provider, 
+			ITileFileSystemStrategy strategy
+			/*LRUTileCache memCache*/) {
+		this.tileCache = tileCache;
+		this.provider = provider;
+		this.basePath = tileCache.getBaseDirectory();
+		//this.memoryCache = memCache;
+		this.strategy = strategy;
+	}
+	
+	/**
+	 * Gets the timer of one tile
+	 * @return
+	 */
+	private TimerOneTile getTimerOneTile() {
+		if(timerOneTile == null)
+			timerOneTile = new TimerOneTile();
+		return timerOneTile;
+	}
+	
+	/**
+	 * Gets the timer of a list of tiles
+	 * @return
+	 */
+	@SuppressWarnings("unused")
+	private TimerTilePool getTimerTilePool() {
+		if(timerTilePool == null)
+			timerTilePool = new TimerTilePool(getThreadPool());
+		return timerTilePool;
+	}
+	/**
+	 * Gets the pool of threads
+	 * @return
+	 */
+	public ThreadPoolImpl getThreadPool() {
+		if(pool == null)
+			pool = new ThreadPoolImpl(false);
+		return pool;
+	}
+	
+	/**
+	 * Updates the string with the base directory
+	 * @param dir
+	 */
+	public void updateBaseDirectory(String dir) {
+		this.basePath = dir;
+		this.pathToDirLayer = null;
+	}
+	
+	public Tile getTile(Tile tile) throws TileGettingException {
+		assignPathTile(tile);
+		
+		//Busca en memoria
+		/*if(memoryCache != null) {
+			buf = memoryCache.get(tile.getId());
+			if(buf != null)
+				return buf;
+		}*/
+		
+		//Busca en disco
+		provider.getDownloader().readTileFromDisk(tile);
+		if(tile.dataIsLoaded()) {
+			if(!tile.isCorrupt())
+				return tile;
+			return 
+				null;
+		}
+		
+		
+		getTimerOneTile().setTile(tile);
+		getTimerOneTile().start();
+		//Lo descarga de la fuente y lo carga desde disco
+		provider.getDownloader().downloadTile(tile);
+		getTimerOneTile().stop();
+		
+		tileCache.updateSize(tile.getFile().length());
+		tileCache.saveSize();
+		if(!tile.isCorrupt())
+			return tile;
+		return 
+			null;
+	}
+	
+	public void getTiles(List<Tile> tiles, TileListener listener, TaskStatus status) throws TileGettingException {
+		//If a tile is in memory or in disk then this will be returned 
+		//else this will be gotten from the provider
+
+		int nTilesToDownload = 0;
+		getThreadPool().getInputTaskList().clear();
+		getThreadPool().getTilePipe().clear();
+		
+		for (int i = 0; i < tiles.size(); i++) {
+			Tile tile = tiles.get(i);
+			assignPathTile(tile);
+			
+			/*if(memoryCache != null) { //Busca en memoria
+				buf = memoryCache.get(tile.getId());
+				if(buf != null) {
+					tile.setData(new Object[]{buf});
+					listener.tileReady(tile);
+					continue;
+				}
+			}*/
+			
+			try {
+				((TileImpl)tile).setDownloader(provider.getDownloader());
+				provider.getDownloader().readTileFromDisk(tile);
+			} catch (TileGettingException e) {
+				//No ha podido leer el tile. Nos tragamos la excepci�n para que pueda encolarse 
+				//para volver a descargar
+			}
+			
+			if(tile.dataIsLoaded()) {
+				listener.tileReady(tile);
+				continue;
+			}
+			
+			//Lo obtiene desde el proveedor
+			((TileImpl)tile).setSharedPipe(getThreadPool().getTilePipe());
+			getThreadPool().addTask(tile);
+			nTilesToDownload ++;
+		}
+
+		//getTimerTilePool().setListener(listener);
+		//getTimerTilePool().start();
+		for (int i = 0; i < nTilesToDownload; i++) {
+			//getTimerTilePool().restart();
+			Tile tile = (Tile)getThreadPool().getTilePipe().getAtomicTask();
+			
+			if(tile == null) {
+				if(!getThreadPool().isPoolValid())
+					pool = null;
+				break;
+			}
+			
+			tileCache.updateSize(tile.getFile().length());
+			
+			if(status != null && status.isCancellationRequested()) {
+				getThreadPool().emptyPool();
+			 	break;
+			}
+			
+			if(status == null || !status.isCancellationRequested())
+				listener.tileReady(tile);
+		}
+		//getTimerTilePool().stop();
+		tileCache.saveSize();
+	}
+
+	public String getBaseLayerDirectory() {
+		CacheStruct struct = provider.getStruct();
+		int maxLevel = struct.getNumberOfLevels() - 1;
+		if(pathToDirLayer == null) {
+			try {
+				MessageDigest md = java.security.MessageDigest.getInstance("MD5");
+				md.update(new String(struct.getServerURL() + 
+						struct.getLayerName() + 
+						struct.getFileSuffix() +
+						struct.getWorldWidthOfTileMatrixByLevel(maxLevel) + 
+						struct.getWorldHeightOfTileMatrixByLevel(maxLevel) + 
+						struct.getTileSizeByLevel(maxLevel)[0] +
+						struct.getTileSizeByLevel(maxLevel)[1] +
+						struct.getNumberOfLevels() + 
+						struct.getEPSG() + 
+						struct.getFileSize()).getBytes());
+				idLayer = convertToHex(md.digest());
+			} catch (NoSuchAlgorithmException e) {
+				idLayer = new String(struct.getServerURL() + 
+						struct.getLayerName() +
+						struct.getFileSuffix() +
+						struct.getWorldWidthOfTileMatrixByLevel(maxLevel) + 
+						struct.getWorldHeightOfTileMatrixByLevel(maxLevel) + 
+						struct.getTileSizeByLevel(maxLevel)[0] +
+						struct.getTileSizeByLevel(maxLevel)[1] +
+						struct.getNumberOfLevels() + 
+						struct.getEPSG() +
+						struct.getFileSize());
+			}
+			int begin = struct.getLayerName().lastIndexOf(File.separator) + 1;
+			int end = struct.getLayerName().lastIndexOf(".");
+			end = end < 0 ? struct.getLayerName().length() : end;
+			String name = struct.getLayerName().substring(begin, end);
+			idLayer = idLayer + "-" + name;
+			pathToDirLayer = basePath + File.separator + idLayer;
+		}
+		return pathToDirLayer;
+	}
+	
+	public String getID() {
+		if(idLayer == null)
+			getBaseLayerDirectory();
+		return idLayer;
+	}
+	
+	public long delete() {
+		File f = new File(getBaseLayerDirectory());
+		if(f.exists() && f.isDirectory()) {
+			return deleteDirectory(f);
+		}
+		return 0;
+	}
+	
+	/**
+	 * Deletes a directory removing first files inside.
+	 * @param f
+	 */
+	private long deleteDirectory(File f) {
+		long size = 0;
+		File[] files = f.listFiles();
+		for (int i = 0; i < files.length; i++) {
+			if (files[i].isDirectory()) {
+				size += deleteDirectory(files[i]);
+			} else {
+				size += files[i].length();
+			}
+			files[i].delete();
+		}
+		return size;
+	}
+	
+	/**
+	 * Assigns the path to a tile
+	 * @param tile
+	 * @return
+	 */
+	public String assignPathTile(Tile tile) {
+		String file = getBaseLayerDirectory() + 
+					  File.separator + 
+					  strategy.getRelativeToLayerDirTilePath(tile.getRow(), 
+							  tile.getCol(), 
+							  tile.getLevel(),
+							  tile.getVariable(),
+							  tile.getZ(),
+							  tile.getTimeInstant()
+							  ) +
+                      "." + provider.getFileSuffix();
+		String path = file.substring(0, file.lastIndexOf(File.separator));
+		File f = new File(path);
+		if(!f.exists())
+			f.mkdirs();
+		tile.setFile(new File(file));
+		return file;
+	}
+	
+	/**
+	 * Converts an array of bytes to hexadecimal string
+	 * @param data
+	 * @return
+	 */
+	private String convertToHex(byte[] data) { 
+        StringBuffer buf = new StringBuffer();
+        for (int i = 0; i < data.length; i++) { 
+            int halfbyte = (data[i] >>> 4) & 0x0F;
+            int two_halfs = 0;
+            do { 
+                if ((0 <= halfbyte) && (halfbyte <= 9)) 
+                    buf.append((char) ('0' + halfbyte));
+                else 
+                    buf.append((char) ('a' + (halfbyte - 10)));
+                halfbyte = data[i] & 0x0F;
+            } while(two_halfs++ < 1);
+        } 
+        return buf.toString();
+    }
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/layer/TiledLayerImpl.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/layer/TimerOneTile.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/layer/TimerOneTile.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/layer/TimerOneTile.java	(revision 3222)
@@ -0,0 +1,93 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.tile.impl.layer;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.IOException;
+
+import javax.swing.Timer;
+
+import org.gvsig.raster.cache.tile.Tile;
+import org.gvsig.raster.cache.tile.impl.DefaultTileCacheManager;
+import org.gvsig.raster.cache.tile.impl.TileImpl.CancelTaskImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Timer for one tile
+ *
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TimerOneTile implements ActionListener {
+	private Timer                timer          = null;
+	private Tile                 tileToCancel   = null;
+	private static final Logger  logger         = LoggerFactory.getLogger(TimerOneTile.class);
+	
+	public TimerOneTile() {
+		
+	}
+	
+	/**
+	 * Sets the tile to be canceled 
+	 * @param tile
+	 */
+	public void setTile(Tile tile) {
+		this.tileToCancel = tile;
+	}
+	
+	/**
+	 * Starts the timer
+	 */
+	public void start() {
+		getTimer().start();
+	}
+	
+	/**
+	 * Stops the timer
+	 */
+	public void stop() {
+		getTimer().stop();
+	}
+	
+	/**
+	 * Gets the timer
+	 * @return
+	 */
+	private Timer getTimer() {
+		if(timer == null)
+			timer = new Timer(DefaultTileCacheManager.TILE_TIME_OUT, this);
+		return timer;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+	 */
+	public void actionPerformed(ActionEvent e) {
+		//try {
+			((CancelTaskImpl)tileToCancel.getCancelled()).setCanceled(true);
+		/*} catch (IOException e1) {
+			logger.debug("Tile can not be cancelled", e1);
+		}*/
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/layer/TimerOneTile.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/TileCacheDefaultImplLibrary.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/TileCacheDefaultImplLibrary.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/TileCacheDefaultImplLibrary.java	(revision 3222)
@@ -0,0 +1,50 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.tile.impl;
+
+import org.gvsig.raster.cache.tile.TileCacheLibrary;
+import org.gvsig.raster.cache.tile.TileCacheLocator;
+import org.gvsig.tools.library.AbstractLibrary;
+import org.gvsig.tools.library.LibraryException;
+
+/**
+ * Library for default implementation initialization and configuration.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ * @version $Id$
+ */
+public class TileCacheDefaultImplLibrary extends AbstractLibrary {
+	
+	public TileCacheDefaultImplLibrary() {
+		registerAsImplementationOf(TileCacheLibrary.class);
+	}
+
+	protected void doInitialize() throws LibraryException {
+        TileCacheLocator.registerManager(DefaultTileCacheManager.class);
+	}
+
+    @Override
+    protected void doPostInitialize() throws LibraryException {
+
+    }
+
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/TileCacheDefaultImplLibrary.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/TileImpl.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/TileImpl.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/TileImpl.java	(revision 3222)
@@ -0,0 +1,360 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.tile.impl;
+
+import java.awt.geom.AffineTransform;
+import java.awt.geom.NoninvertibleTransformException;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+
+import org.gvsig.compat.net.ICancellable;
+import org.gvsig.raster.cache.tile.Tile;
+import org.gvsig.raster.cache.tile.pool.AtomicTask;
+import org.gvsig.raster.cache.tile.pool.TilePipe;
+import org.gvsig.raster.cache.tile.provider.Downloader;
+
+/**
+ * Main implementation for the tile cache
+ *
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TileImpl implements Tile {
+	private boolean             corrupt           = false;
+	private int                 level             = 0;
+	private int                 col               = 0;
+	private int                 row               = 0;
+	private String              var               = "V";
+	private String              z                 = "Z";
+	private String              time              = "T";
+	private int                 widthPx           = 0;
+	private int                 heightPx          = 0;
+	private Point2D             ul                = null;
+	private Point2D             lr                = null;
+	private Rectangle2D         coordPx           = null;
+	
+	private File                file              = null;
+	private Downloader          downloader        = null;
+	private HashMap<String, Object>    
+                                downloaderParams  = new HashMap<String, Object>();
+	private TilePipe            sharedPipe        = null;
+	private int                 priority          = 0;
+	private Object[]            data              = null;
+	protected CancelTaskImpl    cancelDownloading = null;
+	
+	/**
+	 * All tasks which use libRemoteServices need an object that implements ICancellable
+	 * to cancel processes.
+	 * @author Nacho Brodin (nachobrodin@gmail.com)
+	 */
+	public class CancelTaskImpl implements ICancellable {
+		private boolean       cancel = false;
+		
+		public CancelTaskImpl() {
+		}
+		
+		public Object getID() {
+			return this;
+		}
+
+		public boolean isCanceled() {
+			return cancel;
+		}
+		
+		/**
+		 * Cancel the task
+		 * @param cancel
+		 * @throws IOException 
+		 */
+		public void setCanceled(boolean cancel) {
+			this.cancel = cancel;
+		}
+
+	}
+	
+	public TileImpl(int level, int col, int row) {
+		this.level = level;
+		this.col = col;
+		this.row = row;
+		cancelDownloading = new CancelTaskImpl();
+	}
+	
+	public TileImpl(int wPx, int hPx, int row, int col, Point2D ul, Point2D lr) {
+		this.row = row;
+		this.col = col;
+		this.ul = ul;
+		this.lr = lr;
+		this.widthPx = wPx;
+		this.heightPx = hPx;
+		cancelDownloading = new CancelTaskImpl();
+	}
+	
+	public Object[] getDownloadingImage() {
+		return downloader.getDownloadingImage(getWidthPx(), getHeightPx());
+	}
+	
+	public Object[] getCrashImage() {
+		return downloader.getCrashImage(getWidthPx(), getHeightPx());
+	}
+	
+	public Object getDownloadingARGB() {
+		Object[] result = downloader.getDownloadingImage(getWidthPx(), getHeightPx());
+		if(result != null && result.length >= 1)
+			return result[0];
+		return null;
+	}
+	
+	public Object getCrashARGB() {
+		Object[] result = downloader.getCrashImage(getWidthPx(), getHeightPx());
+		if(result != null && result.length >= 1)
+			return result[0];
+		return null;
+	}
+	
+	/**
+	 * Convierte un punto desde del mundo a coordenadas pixel.
+	 * @param pt Punto a transformar
+	 * @return punto transformado en coordenadas pixel
+	 */
+	public Point2D worldToRaster(Point2D pt) {
+		Point2D p = new Point2D.Double();
+		double psX = (lr.getX() - ul.getX()) / widthPx;
+		double psY = (lr.getY() - ul.getY()) / heightPx;
+		AffineTransform t = new AffineTransform(psX, 0, 0, psY, ul.getX() - (psX / 2), ul.getY() + (psY / 2));
+		try {
+			t.inverseTransform(pt, p);
+		} catch (NoninvertibleTransformException e) {
+			return pt;
+		}
+		return p;
+	}
+	
+	public Tile cloneTile() {
+		TileImpl newTile = new TileImpl(widthPx, heightPx, row, col, (Point2D)ul.clone(), (Point2D)lr.clone());
+		newTile.file = file;
+		return newTile;
+	}
+	
+	public String getVariable() {
+		return var;
+	}
+	
+	public String getZ() {
+		return z;
+	}
+	
+	public String getTimeInstant() {
+		return time;
+	}
+	
+	public void setVariable(String var) {
+		this.var = var;
+	}
+	
+	public void setZ(String z) {
+		this.z = z;
+	}
+	
+	public int getLevel() {
+		return level;
+	}
+	
+	public void setTimeInstant(String t) {
+		this.time = t;
+	}
+
+	public int getCol() {
+		return col;
+	}
+
+	public int getRow() {
+		return row;
+	}
+	
+	public void setCol(int col) {
+		this.col = col;
+	}
+	
+	public void setRow(int row) {
+		this.row = row;
+	}
+	
+	public void setLevel(int level) {
+		this.level = level;
+	}
+	
+	public Rectangle2D getCoordsPx() {
+		return coordPx;
+	}
+	
+	public void setCoordsPx(Rectangle2D r) {
+		this.coordPx = r;
+	}
+
+	public int getWidthPx() {
+		return widthPx;
+	}
+
+	public void setWidthPx(int widthPx) {
+		this.widthPx = widthPx;
+	}
+
+	public int getHeightPx() {
+		return heightPx;
+	}
+
+	public void setHeightPx(int heightPx) {
+		this.heightPx = heightPx;
+	}
+	
+	public Rectangle2D getExtent() {
+		return new Rectangle2D.Double(ul.getX(), ul.getY(), 
+				Math.abs(ul.getX() - lr.getX()), Math.abs(ul.getY() - lr.getY()));
+	}
+
+	public Point2D getUl() {
+		return ul;
+	}
+
+	public void setUl(Point2D ul) {
+		this.ul = ul;
+	}
+
+	public Point2D getLr() {
+		return lr;
+	}
+
+	public void setLr(Point2D lr) {
+		this.lr = lr;
+	}
+
+	public File getFile() {
+		return file;
+	}
+
+	public void setFile(File file) {
+		this.file = file;
+	}
+
+	/**
+	 * Gets the downloader for this tile
+	 * @return
+	 */
+	public Downloader getDownloader() {
+		return downloader;
+	}
+
+	public void setDownloader(Downloader downloader) {
+		this.downloader = downloader;
+	}
+
+	public Object getDownloaderParams(String key) {
+		return downloaderParams.get(key.toUpperCase());
+	}
+
+	public void setDownloaderParams(String key, Object value) {
+		this.downloaderParams.put(key.toUpperCase(), value);
+	}
+	
+	public void setCorrupt(boolean corrupt) {
+		this.corrupt = corrupt;
+	}
+	
+	public boolean isCorrupt() {
+		boolean c = corrupt;
+		corrupt = false;
+		return c;
+	}
+	
+	/**
+	 * Actions for download a tile
+	 */
+	public void run() {
+		try {
+			downloader.downloadTile(this);
+			corrupt = false;
+		} catch (Exception e) {
+			if(getFile().exists())
+				getFile().delete();
+			corrupt = true;
+			System.out.println("Exception Cancelando tile....." + getId());
+		} finally {
+			if(sharedPipe != null)
+				sharedPipe.setAtomicTask(this);
+		}
+	}
+	
+	public void cancelTask() {
+		((CancelTaskImpl)getCancelled()).setCanceled(true);
+		sharedPipe = null;
+	}
+	
+	public ICancellable getCancelled() {
+		return cancelDownloading;
+	}
+
+	/**
+	 * Gets the pipe of tiles
+	 * @return
+	 */
+	public TilePipe getSharedPipe() {
+		return sharedPipe;
+	}
+
+	public void setSharedPipe(TilePipe sharedPipe) {
+		this.sharedPipe = sharedPipe;
+	}
+	
+	public String getId() {
+		return getLevel() + "_" + getRow() + "_" + getCol();
+	}
+
+	public int getPriority() {
+		return priority;
+	}
+	
+	public void setPriority(int priority) {
+		this.priority = priority;
+	}
+	
+	public void setData(Object[] data) {
+		this.data = data;
+	}
+	
+	public Object[] getData() {
+		return data;
+	}
+
+	public int compareTo(AtomicTask o) {
+		if(getPriority() > o.getPriority())
+			return 1;
+		if(getPriority() < o.getPriority())
+			return -1;
+		return 0;
+	}
+	
+	public boolean dataIsLoaded() {
+		return (getData() != null && getData().length > 0);
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/TileImpl.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/DefaultTileCacheManager.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/DefaultTileCacheManager.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/DefaultTileCacheManager.java	(revision 3222)
@@ -0,0 +1,154 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.tile.impl;
+
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+
+import org.gvsig.raster.cache.tile.Tile;
+import org.gvsig.raster.cache.tile.TileCache;
+import org.gvsig.raster.cache.tile.TileCacheLibrary;
+import org.gvsig.raster.cache.tile.TileCacheManager;
+import org.gvsig.raster.cache.tile.disk.ITileFileSystemStrategy;
+import org.gvsig.raster.cache.tile.impl.disk.FlatXFileSystemStrategy;
+import org.gvsig.raster.cache.tile.impl.pool.ThreadPoolImpl;
+import org.gvsig.raster.cache.tile.impl.provider.DefaultCacheStruct;
+import org.gvsig.raster.cache.tile.pool.ThreadPool;
+import org.gvsig.raster.cache.tile.provider.CacheStruct;
+
+/**
+ * Default {@link RasterManager} implementation.
+ * 
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ * @version $Id$
+ */
+public class DefaultTileCacheManager implements TileCacheManager {
+	private static DefaultTileCacheManager internalInstance  = new DefaultTileCacheManager();
+	private TileCache                      tileCacheInstance = null;
+	public static int                      TILE_TIME_OUT     = 20000;
+	   
+	/**
+	 * Gets an instance of this object for internal use.
+	 * @return DefaultRasterManager
+	 */
+	public static DefaultTileCacheManager getInstance() {
+		return internalInstance;
+	}
+
+	public TileCache getTileCache(String baseDir) {
+		if(tileCacheInstance == null)
+			tileCacheInstance = new TileCacheImpl(baseDir);
+		return tileCacheInstance;
+	}
+
+	public Tile createTile(int level, int col, int row) {
+		return new TileImpl(level, col, row);
+	}
+	
+	public Tile createTile(int wPx, int hPx, int row, int col, Point2D ul, Point2D lr) {
+		return new TileImpl(wPx, hPx, row, col, ul, lr);
+	}
+	
+	public CacheStruct createCacheStructure(int typeOfCoords, 
+    		int levels, 
+    		Rectangle2D layerExtent, 
+    		double pixelSize,
+    		int tilePxWidth,
+    		int tilePxHeight,
+    		String uri,
+    		String layerName,
+    		String strategy,
+    		String baseDir,
+    		String fileSuffix,
+    		String epsg,
+    		long size) {
+		return new DefaultCacheStruct(typeOfCoords, 
+				levels, 
+				layerExtent, 
+				pixelSize, 
+				tilePxWidth, 
+				tilePxHeight,
+				uri,
+				layerName, 
+				createStrategy(strategy),
+				baseDir,
+				fileSuffix,
+				epsg,
+				size );
+	}
+	
+	public CacheStruct createCacheStructure(int typeOfCoords, 
+    		int levels, 
+    		Rectangle2D layerExtent, 
+    		double pixelSize,
+    		int tilePxWidth,
+    		int tilePxHeight,
+    		String layerName,
+    		String strategy,
+    		String baseDir,
+    		String fileSuffix,
+    		String epsg,
+    		long size) {
+		return new DefaultCacheStruct(typeOfCoords, 
+				levels, 
+				layerExtent, 
+				pixelSize, 
+				tilePxWidth, 
+				tilePxHeight,
+				layerName,
+				layerName, 
+				createStrategy(strategy),
+				baseDir,
+				fileSuffix,
+				epsg,
+				size );
+	}
+	
+	/**
+	 * Creates a strategy object
+	 * @param strategy
+	 * @return
+	 */
+	public ITileFileSystemStrategy createStrategy(String strategy) {
+		ITileFileSystemStrategy strat = null;
+		if(strategy == null || strategy.compareTo(TileCacheLibrary.FLATX_STRUCT) == 0)
+			strat = new FlatXFileSystemStrategy();
+		return strat;
+	}
+
+	public ThreadPool createThreadPool(boolean priorityActive) {
+		return new ThreadPoolImpl(priorityActive);
+	}
+
+	public ThreadPool createThreadPool(boolean priorityActive, int nThreads) {
+		return new ThreadPoolImpl(priorityActive, nThreads);
+	}
+	
+	public void setTileTimeOut(int ms) {
+		TILE_TIME_OUT = ms;
+	}
+	
+	public int getTileTimeOut() {
+		return TILE_TIME_OUT;
+	}
+	
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/DefaultTileCacheManager.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/TileCacheImpl.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/TileCacheImpl.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/TileCacheImpl.java	(revision 3222)
@@ -0,0 +1,144 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.tile.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+
+import org.gvsig.raster.cache.tile.TileCache;
+import org.gvsig.raster.cache.tile.TileCacheLibrary;
+import org.gvsig.raster.cache.tile.TileCacheLocator;
+import org.gvsig.raster.cache.tile.disk.ITileFileSystemStrategy;
+import org.gvsig.raster.cache.tile.impl.layer.TiledLayerImpl;
+import org.gvsig.raster.cache.tile.layer.TiledLayer;
+import org.gvsig.raster.cache.tile.provider.TileServer;
+
+/**
+ * Main implementation for the tile cache
+ *
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TileCacheImpl implements TileCache {
+	private ArrayList<TiledLayerImpl>   layerList            = null;
+	//private MemoryManager               memoryManager        = null;
+	private String                      baseDir              = null;
+	private double                      currentSize          = 0;
+	protected String                    preffixSizeFileName  = "c_len";
+	protected String                    configDir            = ".metadata";
+	
+	public TileCacheImpl(String baseDir) {
+		this.layerList = new ArrayList<TiledLayerImpl>();
+		//memoryManager = new MemoryManager();
+		this.baseDir = baseDir;
+		loadSize();
+	}
+	
+	public void updateBaseDirectory(String dir) {
+		this.baseDir = dir;
+		for (int i = 0; i < layerList.size(); i++) {
+			layerList.get(i).updateBaseDirectory(dir);
+		}
+	}
+	
+	/**
+	 * Updates the size of the tiles downloaded
+	 * @param sizeBytes
+	 */
+	public synchronized void updateSize(long sizeBytes) {
+		currentSize +=  ((double)sizeBytes);
+	}
+	
+	/**
+	 * Loads the size of the directory
+	 */
+	private void loadSize() {
+		File f = new File(baseDir + File.separator + configDir);
+		if(!f.exists()) {
+			f.mkdirs();
+			saveSize();
+		}
+		String[] list = f.list();
+		for (int i = 0; i < list.length; i++) {
+			if(list[i].startsWith(preffixSizeFileName)) {
+				String s = list[i].substring(5, list[i].length());
+				try {
+					currentSize = Double.valueOf(s);
+				} catch (NumberFormatException e) {
+				}
+			}
+		}
+	}
+	
+	/**
+	 * Saves a size file
+	 * @throws IOException
+	 */
+	public synchronized void saveSize() {
+		String dir = baseDir + File.separator + configDir;
+		File f = new File(dir);
+		if(!f.exists()) {
+			f.mkdirs();
+		}
+		String[] list = f.list();
+		if(list != null) {
+			for (int i = 0; i < list.length; i++) {
+				if(list[i].startsWith(preffixSizeFileName)) {
+					new File(dir + File.separator + list[i]).delete();
+				}
+			}
+		}
+		try {
+			new File(dir + File.separator + preffixSizeFileName + (int)currentSize).createNewFile();
+		} catch (IOException e) {
+		}
+	}
+	
+	public boolean isFullDiskCache() {
+		return currentSize >= (TileCacheLibrary.MAX_CACHE_SIZE *  1048576);
+	}
+	
+	public TiledLayer createLayer(TileServer provider, String strategyType) {
+		ITileFileSystemStrategy strat = ((DefaultTileCacheManager)TileCacheLocator.getManager()).createStrategy(strategyType);
+		TiledLayerImpl l = new TiledLayerImpl(this, provider, strat/*, memoryManager.createLRUTileCache()*/);
+		layerList.add(l);
+		return l;
+	}
+	
+	/**
+	 * Gets the base directory
+	 * @return
+	 */
+	public String getBaseDirectory() {
+		return baseDir;
+	}
+	
+	public String getConfigurationDirectory() {
+		return configDir;
+	}
+	
+	public void removeLayer(TiledLayer layer) {
+		layerList.remove(layer);
+		updateSize(-layer.delete());
+		saveSize();
+	}
+}
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/TileCacheImpl.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/memory/MemoryManager.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/memory/MemoryManager.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/memory/MemoryManager.java	(revision 3222)
@@ -0,0 +1,41 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.tile.impl.memory;
+
+
+/**
+ * Manager for the memory distribution among different layers when the LRUTileCache
+ * is used
+ *
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class MemoryManager {
+
+	/**
+	 * Gets a new LRUTileCache object
+	 * @return
+	 */
+	public LRUTileCache createLRUTileCache() {
+		return null;
+	}
+
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/memory/MemoryManager.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/memory/LRUTileCache.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/memory/LRUTileCache.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/memory/LRUTileCache.java	(revision 3222)
@@ -0,0 +1,167 @@
+/* gvSIG Mini. A free mobile phone viewer of free maps.
+ *
+ * Copyright (C) 2009 Prodevelop.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
+ *
+ * For more information, contact:
+ *
+ *   Prodevelop, S.L.
+ *   Pza. Don Juan de Villarrasa, 14 - 5
+ *   46001 Valencia
+ *   Spain
+ *
+ *   +34 963 510 612
+ *   +34 963 510 968
+ *   prode@prodevelop.es
+ *   http://www.prodevelop.es
+ *
+ *   gvSIG Mini has been partially funded by IMPIVA (Instituto de la Peque�a y
+ *   Mediana Empresa de la Comunidad Valenciana) &
+ *   European Union FEDER funds.
+ *   
+ *   2009.
+ *   author Rub�n Blanco rblanco@prodevelop.es
+ *
+ *
+ * Original version of the code made by Nicolas Gramlich.
+ * No header license code found on the original source file.
+ * 
+ * Original source code downloaded from http://code.google.com/p/osmdroid/
+ * package org.andnav.osm.views.util;
+ * 
+ * License stated in that website is 
+ * http://www.gnu.org/licenses/lgpl.html
+ * As no specific LGPL version was specified, LGPL license version is LGPL v2.1
+ * is assumed.
+ *  
+ * 
+ */
+package org.gvsig.raster.cache.tile.impl.memory;
+
+
+//import org.gvsig.raster.cache.buffer.Buffer;
+
+/**
+ * A Last Recent Used cache of Bitmaps
+ * @author aromeu 
+ * @author rblanco
+ *
+ */
+public class LRUTileCache {
+//	extends HashMap<String, Buffer> {
+//	private static final long        serialVersionUID = 6215141;
+//	private final int                maxCacheSize;
+//	private LinkedList<String>       list             = null;
+//	private final static Logger      log              = Logger.getLogger("LRUTileCache");
+//
+//	/**
+//	 * The Constructor
+//	 * @param maxCacheSize The cache size in number of Bitmaps
+//	 */
+//	public LRUTileCache(final int maxCacheSize) {
+//		super(maxCacheSize);
+//		this.maxCacheSize = Math.max(0, maxCacheSize);
+//		this.list = new LinkedList<String>();
+//	}
+//
+//	/**
+//	 * Clears the cache
+//	 */
+//	public synchronized void clear() {		
+//		try {
+//			/*for (final Buffer b : this.values()) {
+//				if (b != null) {
+//					b.recycle();
+//				}
+//			}*/
+//			super.clear();
+//			list.clear();
+//		} catch (Exception e) {
+//			log.log(Level.SEVERE, "clear cache: ", e);
+//		}
+//	}
+//
+//	/**
+//	 * Adds a Bitmap to the cache. If the cache is full, removes the last
+//	 */
+//	public synchronized Buffer put(final String key, final Buffer value) {
+//		try {
+//			if (maxCacheSize == 0) {
+//				return null;
+//			}
+//
+//			// if the key isn't in the cache and the cache is full...
+//			if (!super.containsKey(key) && !list.isEmpty()
+//					&& list.size() + 1 > maxCacheSize) {
+//				final Object deadKey = list.removeLast();
+//				super.remove(deadKey);
+//				//if (bitmap != null)
+//					//bitmap.recycle();
+//			}
+//
+//			updateKey(key);			
+//		} catch (Exception e) {
+//			log.log(Level.SEVERE, "put", e);
+//		}
+//		return super.put(key, value);		
+//	}
+//
+//	/**
+//	 * Returns a cached Bitmap given a key
+//	 * @param key The key of the Bitmap stored on the HashMap
+//	 * @return The Bitmap or null if it is not stored in the cache
+//	 */
+//	public synchronized Buffer get(final String key) {
+//		try {
+//			final Buffer value = super.get(key);
+//			if (value != null) {
+//				updateKey(key);
+//			}
+//			return value;
+//		} catch (Exception e) {
+//			log.log(Level.SEVERE, "get",  e);
+//			return null;
+//		}		
+//	} 
+//
+//	/**
+//	 * Removes a Bitmap from the cache
+//	 * @param key The key of the Bitmap to remove
+//	 */
+//	public synchronized void remove(final String key) {
+//		try {
+//			list.remove(key);			
+//		} catch (Exception e) {
+//			log.log(Level.SEVERE, "remove", e);			
+//		}
+//		super.remove(key);
+//		//if (bitmap != null)
+//			//bitmap.recycle();		
+//	}
+//
+//	/**
+//	 * The key is touched (recent used) and added to the top of the list
+//	 * @param key The key to be updated
+//	 */
+//	private void updateKey(final String key) {
+//		try {
+//			list.remove(key);
+//			list.addFirst(key);
+//		} catch (Exception e) {
+//			log.log(Level.SEVERE, "updatekey", e);
+//		}		
+//	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/memory/LRUTileCache.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/pool/ThreadPoolImpl.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/pool/ThreadPoolImpl.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/pool/ThreadPoolImpl.java	(revision 3222)
@@ -0,0 +1,214 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.tile.impl.pool;
+
+import java.util.Collections;
+import java.util.LinkedList;
+
+import org.gvsig.raster.cache.tile.Tile;
+import org.gvsig.raster.cache.tile.exception.TileGettingException;
+import org.gvsig.raster.cache.tile.pool.AtomicTask;
+import org.gvsig.raster.cache.tile.pool.ThreadPool;
+import org.gvsig.raster.cache.tile.pool.TilePipe;
+import org.gvsig.raster.cache.tile.provider.TileListener;
+
+/**
+ * Pool of threads. This class contains a list of tasks and a limited number
+ * of threads to execute them. When a thread is free will execute the next task 
+ * in the list. 
+ *
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class ThreadPoolImpl implements ThreadPool {
+	private int                        NTHREADS_POOL   = 5;
+	private ThreadTask[]               threadList      = null;
+	private LinkedList<AtomicTask>     tasks           = new LinkedList<AtomicTask>();
+	private boolean                    priorityActive  = false;
+	private TilePipe                   tilePipe        = null;
+
+	/**
+	 * Constructor. Only for testing purposes. After this constructor the method init
+	 * has to be called
+	 */
+	public ThreadPoolImpl() {
+		this.priorityActive = true;
+		threadList = new ThreadTask[NTHREADS_POOL];
+	}
+	
+	/**
+	 * Constructor
+	 * @param priorityActive true if the pool runs using priorities and false if doesn't
+	 * @param nThreads Number of threads of this pool
+	 */
+	public ThreadPoolImpl(boolean priorityActive, int nThreads) {
+		this.priorityActive = true;
+		NTHREADS_POOL = nThreads;
+		init();
+	}
+	
+	/**
+	 * Constructor
+	 * @param priorityActive true if the pool runs using priorities and false if doesn't
+	 */
+	public ThreadPoolImpl(boolean priorityActive) {
+		this.priorityActive = priorityActive;
+		init();
+	}
+	
+	public void init() {
+		if(threadList == null)
+			threadList = new ThreadTask[NTHREADS_POOL];
+		for (int i = 0; i < NTHREADS_POOL; i++) {
+			threadList[i] = new ThreadTask(this);
+			threadList[i].start();
+		}
+	}
+	
+	/**
+	 * Cancel the pool of threads and destroy the pool
+	 * @param listener
+	 */
+	public void cancelPool(TileListener listener) {
+		if(threadList != null) {
+			for (int i = 0; i < NTHREADS_POOL; i++) {
+				if(threadList[i] != null) {
+					Runnable r = threadList[i].stopThread();
+					try {
+						if(listener != null)
+							listener.tileReady((Tile)r);
+					} catch (TileGettingException e) {
+					}
+				}
+			}
+		}
+		for (int i = 0; i < tasks.size(); i++) {
+			try {
+				if(listener != null)
+					listener.tileReady((Tile)tasks.get(i));
+			} catch (TileGettingException e) {
+			}
+		}
+		synchronized (tasks) {
+			tasks.notifyAll();
+		}
+		destroyPool();
+	}
+	
+	/**
+	 * Cleans the input and output pool
+	 * @param listener
+	 */
+	public void emptyPool() {
+		//Don't get and set more tiles
+		for (int i = 0; i < threadList.length; i++) {
+			threadList[i].cancelTaskInProgress();
+		}
+		
+		//Cleans queues
+		synchronized (tasks) {
+			tasks.clear();
+			getTilePipe().clear();
+			tasks.notifyAll();
+		}
+		
+		//Gets tiles again
+		for (int i = 0; i < threadList.length; i++) {
+			threadList[i].resumeTasks();
+		}
+	}
+	
+	public LinkedList<AtomicTask> getInputTaskList() {
+		return tasks;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.tile.pool.ThreadPool#getTilePipe()
+	 */
+	public TilePipe getTilePipe() {
+		if(tilePipe == null)
+			tilePipe = new TilePipeImpl();
+		return tilePipe;
+	}
+	
+	/**
+	 * Stops all threads in the list and sets the list to null
+	 * @deprecated
+	 */
+	public void destroyPool() {
+		for (int i = 0; i < NTHREADS_POOL; i++) {
+			threadList[i].stopThread();
+			threadList[i] = null;
+		}
+		threadList = null;
+	}
+	
+	/**
+	 * Returns true if the pool is valid
+	 * @return
+	 */
+	public boolean isPoolValid() {
+		return !(threadList == null);
+	}
+
+	/**
+	 * Adds a new task to the list
+	 * @param task
+	 */
+	public void addTask(AtomicTask task) {
+		synchronized (tasks) {
+			tasks.addLast(task);
+			tasks.notify();
+		}
+	}
+
+	/**
+	 * Gets the next task in the list
+	 * @return
+	 */
+	public AtomicTask getNext() {
+		AtomicTask returnVal = null;
+		synchronized (tasks) {
+			while (tasks.isEmpty()) {
+				try {
+					tasks.wait();
+				} catch (InterruptedException ex) {
+					System.err.println("Interrupted");
+				}
+			}
+			if(priorityActive)
+				sort(tasks);
+			returnVal = tasks.removeFirst();
+		}
+		return returnVal;
+	}
+	
+	/**
+	 * Sorts the array of tasks. Each atomic task have to implement AtomicTask interface
+	 * which is Runnable and Comparable. The last one allow to sort the array 
+	 * by priorities.
+	 * @param tasks
+	 */
+	private void sort(LinkedList<AtomicTask> tasks) {
+		Collections.sort(tasks);
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/pool/ThreadPoolImpl.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/pool/ThreadTask.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/pool/ThreadTask.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/pool/ThreadTask.java	(revision 3222)
@@ -0,0 +1,58 @@
+package org.gvsig.raster.cache.tile.impl.pool;
+
+import org.gvsig.raster.cache.tile.pool.AtomicTask;
+
+/**
+ * This represents one thread in the pool. This thread gets a new task in
+ * the pool and executes it.
+ *
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+class ThreadTask extends Thread {
+	private ThreadPoolImpl pool         = null;
+	private boolean        stop         = false;
+	private AtomicTask     currentJob   = null; 
+	private boolean        getMoreTiles = true;
+
+	public ThreadTask(ThreadPoolImpl thePool) {
+		pool = thePool;
+	}
+
+	public void run() {
+		while (!stop) {
+			if(getMoreTiles) {
+				currentJob = pool.getNext();
+				currentJob.run();
+			} else {
+				try {
+					Thread.sleep(500);
+				} catch (InterruptedException e) {
+				}
+			}
+		}
+	}
+	
+	/**
+	 * Stops this thread
+	 */
+	public Runnable stopThread() {
+		stop = true;
+		return currentJob;
+	}
+	
+	/**
+	 * Cancels the task in progress and avoids that next tiles are gotten
+	 */
+	public void cancelTaskInProgress() {
+		if(currentJob != null)
+			currentJob.cancelTask();
+		getMoreTiles = false;
+	}
+	
+	/**
+	 * Gets new tiles to processed of the input queue
+	 */
+	public void resumeTasks() {
+		getMoreTiles = true;
+	}
+}
\ No newline at end of file

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/pool/ThreadTask.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/pool/TilePipeImpl.java
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/pool/TilePipeImpl.java	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/pool/TilePipeImpl.java	(revision 3222)
@@ -0,0 +1,108 @@
+/* gvSIG. Geographic Information System of the Valencian Government
+ *
+ * Copyright (C) 2007-2008 Infrastructures and Transports Department
+ * of the Valencian Government (CIT)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ */
+package org.gvsig.raster.cache.tile.impl.pool;
+
+import java.util.LinkedList;
+import java.util.Queue;
+
+import org.gvsig.raster.cache.tile.Tile;
+import org.gvsig.raster.cache.tile.pool.AtomicTask;
+import org.gvsig.raster.cache.tile.pool.TilePipe;
+
+/**
+ * This class manages transactions between the producer and the consumer. The
+ * producer download tiles from a server and the consumer is a tile provider
+ * which will return downloaded tiles.
+ *
+ * @author Nacho Brodin (nachobrodin@gmail.com)
+ */
+public class TilePipeImpl implements TilePipe {
+	private boolean              isEmpty        = true;
+	private Queue<AtomicTask>    buffer         = new LinkedList<AtomicTask>();
+	private boolean              debug          = false;
+	
+	public TilePipeImpl() {
+		this.debug = false;
+	}
+	
+	public TilePipeImpl(boolean debug) {
+		this.debug = debug;
+	}
+	
+	/**
+	 * Sets a tile in the pipe
+	 * @param tile
+	 */
+	public synchronized void setAtomicTask(AtomicTask task) {
+		if(task != null)
+			buffer.add(task);
+		isEmpty = false;
+		
+		if(debug)
+			System.err.println("Setting tile " + ((Tile)task).getCol() + " " + ((Tile)task).getRow());
+		
+		notify();
+	}
+
+	/**
+	 * Gets a tile from the pipe
+	 * @return
+	 */
+	public synchronized AtomicTask getAtomicTask() {
+		if(debug)
+			System.out.println("0-Getting tile ");
+		while( isEmpty == true ) {
+			try {
+				wait();
+			} catch( InterruptedException e ) {
+			}
+		}
+
+		AtomicTask task = buffer.poll() ;
+		
+		if(debug)
+			System.out.println("1-Getting tile " + ((Tile)task).getCol() + " " + ((Tile)task).getRow());
+		
+		if( getSize() == 0 )
+			isEmpty = true;
+
+		return task;
+	}
+	
+	/**
+	 * Returns the number of elements in the queue
+	 * @return
+	 */
+	public synchronized int getSize() {
+		return buffer.size();
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.gvsig.raster.cache.tile.pool.TilePipe#clear()
+	 */
+	public void clear() {
+		synchronized (buffer) {
+			buffer.clear();
+		}
+	}
+}

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/java/org/gvsig/raster/cache/tile/impl/pool/TilePipeImpl.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
===================================================================
--- org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/resources/META-INF/services/org.gvsig.tools.library.Library	(revision 0)
+++ org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl/src/main/resources/META-INF/services/org.gvsig.tools.library.Library	(revision 3222)
@@ -0,0 +1 @@
+org.gvsig.raster.cache.tile.impl.TileCacheDefaultImplLibrary

Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1/org.gvsig.raster.cache.lib.impl
___________________________________________________________________
Added: svn:ignore
   + .classpath

.settings

target

.project



Property changes on: org.gvsig.raster.cache/tags/org.gvsig.raster.cache-2.2.1
___________________________________________________________________
Added: svn:ignore
   + .project
target
.settings
.pom.xml.swp


