svn-gvsig-desktop / trunk / libraries / libRaster / src / org / gvsig / raster / dataset / Band.java @ 15969
History | View | Annotate | Download (5 KB)
1 | 10939 | nacho | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2006 IVER T.I. and Generalitat Valenciana.
|
||
4 | *
|
||
5 | * This program is free software; you can redistribute it and/or
|
||
6 | * modify it under the terms of the GNU General Public License
|
||
7 | * as published by the Free Software Foundation; either version 2
|
||
8 | * of the License, or (at your option) any later version.
|
||
9 | *
|
||
10 | * This program is distributed in the hope that it will be useful,
|
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | * GNU General Public License for more details.
|
||
14 | *
|
||
15 | * You should have received a copy of the GNU General Public License
|
||
16 | * along with this program; if not, write to the Free Software
|
||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
18 | */
|
||
19 | package org.gvsig.raster.dataset; |
||
20 | |||
21 | 13540 | nacho | import java.util.ArrayList; |
22 | 10939 | nacho | |
23 | 13540 | nacho | |
24 | 10939 | nacho | /**
|
25 | * Clase que representa a una banda de un fichero.
|
||
26 | * @author Nacho Brodin (nachobrodin@gmail.com)
|
||
27 | */
|
||
28 | public class Band { |
||
29 | //Nombre del fichero al que pertenece la banda
|
||
30 | private String fileName = ""; |
||
31 | 13540 | nacho | //Lista de nombre de otros ficheros que forman la banda. Esto es util para CompositeDataset que est? compuesto por un mosaico de ficheros.
|
32 | private ArrayList additionalName = new ArrayList(); |
||
33 | 10939 | nacho | //Posici?n en el fichero de la banda
|
34 | private int position = -1; |
||
35 | //Tipo de dato de la banda
|
||
36 | private int dataType = IBuffer.TYPE_BYTE; |
||
37 | //lista de bandas del buffer donde se dibuja esta banda de imagen. Cada elemento
|
||
38 | //del vector es un n?mero que corresponde con el n?mero de banda del buffer donde se escribe esta
|
||
39 | private int[] rasterBufBandToDrawList = null; |
||
40 | |||
41 | public Band(String f, int p, int dt){ |
||
42 | setFileName(f); |
||
43 | setPosition(p); |
||
44 | setDataType(dt); |
||
45 | } |
||
46 | |||
47 | 11413 | nacho | /*
|
48 | * (non-Javadoc)
|
||
49 | * @see java.lang.Object#clone()
|
||
50 | */
|
||
51 | public Object clone() { |
||
52 | Band result = new Band(fileName, position, dataType);
|
||
53 | if(rasterBufBandToDrawList != null) { |
||
54 | int[] drawBands = new int[rasterBufBandToDrawList.length]; |
||
55 | for (int i = 0; i < rasterBufBandToDrawList.length; i++) |
||
56 | drawBands[i] = rasterBufBandToDrawList[i]; |
||
57 | } |
||
58 | return result;
|
||
59 | } |
||
60 | |||
61 | 10939 | nacho | /**
|
62 | * Resetea la asignaci?n de dibujado de las bandas de la imagen
|
||
63 | * sobre el DataImage cuando se hace un update para esta banda.
|
||
64 | */
|
||
65 | public void clearDrawableBands(){ |
||
66 | rasterBufBandToDrawList = null;
|
||
67 | } |
||
68 | |||
69 | //******************************
|
||
70 | //Setters and Getters
|
||
71 | //******************************
|
||
72 | |||
73 | /**
|
||
74 | * Obtiene las banda del RasterBuf sobre la que se pinta
|
||
75 | * este objeto banda
|
||
76 | * @return bandas del RasterBuf
|
||
77 | */
|
||
78 | 12151 | nacho | public int[] getBufferBandListToDraw() { |
79 | 10939 | nacho | return rasterBufBandToDrawList;
|
80 | } |
||
81 | |||
82 | |||
83 | |||
84 | /**
|
||
85 | * Dice si la banda se est? dibujando en el buffers de salida.
|
||
86 | * @return true si la banda se est? dibujando y false si no se est? haciendo
|
||
87 | */
|
||
88 | public boolean isDrawing(){ |
||
89 | if(this.rasterBufBandToDrawList == null) |
||
90 | return false; |
||
91 | return true; |
||
92 | } |
||
93 | |||
94 | /**
|
||
95 | * Asigna una banda del RasterBuf sobre la que se pinta
|
||
96 | * este objeto banda
|
||
97 | * @param rasterBufBandToDraw banda del RasterBuf
|
||
98 | */
|
||
99 | public void setPositionToDrawInBuffer(int rasterBufBandToDraw) { |
||
100 | 12151 | nacho | if(rasterBufBandToDrawList == null) { |
101 | 10939 | nacho | rasterBufBandToDrawList = new int[1]; |
102 | rasterBufBandToDrawList[0] = rasterBufBandToDraw;
|
||
103 | }else{
|
||
104 | int[] auxList = new int[rasterBufBandToDrawList.length + 1]; |
||
105 | 12151 | nacho | for(int i = 0; i < rasterBufBandToDrawList.length; i++) |
106 | 10939 | nacho | auxList[i] = rasterBufBandToDrawList[i]; |
107 | auxList[rasterBufBandToDrawList.length] = rasterBufBandToDraw; |
||
108 | rasterBufBandToDrawList = auxList; |
||
109 | } |
||
110 | } |
||
111 | |||
112 | /**
|
||
113 | * Obtiene el nombre del fichero al que pertenece la banda
|
||
114 | * @return String con el nombre del fichero al
|
||
115 | * que pertenece la banda
|
||
116 | */
|
||
117 | public String getFileName() { |
||
118 | return fileName;
|
||
119 | } |
||
120 | |||
121 | /**
|
||
122 | * Asigna el nombre del fichero al que pertenece la banda
|
||
123 | * @param fileName String con el nombre del fichero al
|
||
124 | * que pertenece la banda
|
||
125 | */
|
||
126 | public void setFileName(String fileName) { |
||
127 | this.fileName = fileName;
|
||
128 | } |
||
129 | |||
130 | /**
|
||
131 | * Obtiene la posici?n de la banda en el fichero
|
||
132 | * @return entero con la posici?n de la banda en el fichero
|
||
133 | */
|
||
134 | public int getPosition() { |
||
135 | return position;
|
||
136 | } |
||
137 | |||
138 | /**
|
||
139 | * Asigna la posici?n de la banda en el fichero
|
||
140 | * @param position Posici?n de la banda en el fichero
|
||
141 | */
|
||
142 | public void setPosition(int position) { |
||
143 | this.position = position;
|
||
144 | } |
||
145 | |||
146 | /**
|
||
147 | * Obtiene el tipo de dato de la banda
|
||
148 | * @return entero con el tipo de dato
|
||
149 | */
|
||
150 | public int getDataType() { |
||
151 | return dataType;
|
||
152 | } |
||
153 | |||
154 | /**
|
||
155 | * Asigna el tipo de dato de la banda
|
||
156 | * @param datatype entero con el tipo de dato de la banda
|
||
157 | */
|
||
158 | public void setDataType(int dataType) { |
||
159 | this.dataType = dataType;
|
||
160 | } |
||
161 | 13540 | nacho | |
162 | /**
|
||
163 | * Asigna un nombre de fichero adicional al principal. Esto es util para
|
||
164 | * mosaicos de raster donde una banda est? compuesta por multiples ficheros.
|
||
165 | */
|
||
166 | public void setAdditionalName(String fileName) { |
||
167 | additionalName.add(fileName); |
||
168 | } |
||
169 | |||
170 | /**
|
||
171 | * Obtiene la lista de nombres de fichero adicionales.
|
||
172 | * @return String[]
|
||
173 | */
|
||
174 | public String[] getAdditionalName() { |
||
175 | return (String[])additionalName.toArray(); |
||
176 | } |
||
177 | 10939 | nacho | } |