Revision 2328 org.gvsig.raster/branches/org.gvsig.raster_dataaccess_refactoring/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/store/properties/DataStoreColorInterpretation.java
DataStoreColorInterpretation.java | ||
---|---|---|
39 | 39 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
40 | 40 |
*/ |
41 | 41 |
public class DataStoreColorInterpretation implements ColorInterpretation { |
42 |
public static final String PERSISTENCE_NAME = "Color_Interpretation_Persistent"; |
|
43 |
|
|
44 | 42 |
/** |
45 | 43 |
* Interpretaci?n de color para cada banda |
46 | 44 |
*/ |
... | ... | |
77 | 75 |
} |
78 | 76 |
|
79 | 77 |
public static DataStoreColorInterpretation createPaletteInterpretation() { |
80 |
return new DataStoreColorInterpretation(new String[]{PAL_BAND});
|
|
78 |
return new DataStoreColorInterpretation(PALETTE);
|
|
81 | 79 |
} |
82 | 80 |
|
83 | 81 |
/** |
... | ... | |
85 | 83 |
* @return DatasetColorInterpretation |
86 | 84 |
*/ |
87 | 85 |
public static DataStoreColorInterpretation createGrayInterpretation() { |
88 |
return new DataStoreColorInterpretation(new String[]{GRAY_BAND});
|
|
86 |
return new DataStoreColorInterpretation(GRAYSCALE);
|
|
89 | 87 |
} |
90 | 88 |
|
91 | 89 |
/** |
... | ... | |
93 | 91 |
* @return DatasetColorInterpretation |
94 | 92 |
*/ |
95 | 93 |
public static DataStoreColorInterpretation createRGBAInterpretation() { |
96 |
return new DataStoreColorInterpretation(new String[]{RED_BAND, GREEN_BAND, BLUE_BAND, ALPHA_BAND});
|
|
94 |
return new DataStoreColorInterpretation(ARGB);
|
|
97 | 95 |
} |
98 | 96 |
|
99 | 97 |
/** |
... | ... | |
101 | 99 |
* @return DatasetColorInterpretation |
102 | 100 |
*/ |
103 | 101 |
public static DataStoreColorInterpretation createRGBInterpretation() { |
104 |
return new DataStoreColorInterpretation(new String[]{RED_BAND, GREEN_BAND, BLUE_BAND});
|
|
102 |
return new DataStoreColorInterpretation(RGB);
|
|
105 | 103 |
} |
106 | 104 |
|
107 | 105 |
/** |
108 | 106 |
* Constructor que inicializa el n?mero de valores de la interpretaci?n de |
109 | 107 |
* color. Implica asignar posteriormente los valores a las bandas. |
110 | 108 |
*/ |
111 |
public DataStoreColorInterpretation(int values) {
|
|
112 |
colorInterpretation = new String[values];
|
|
109 |
public DataStoreColorInterpretation(int bandCount) {
|
|
110 |
colorInterpretation = new String[bandCount];
|
|
113 | 111 |
} |
114 | 112 |
|
113 |
public DataStoreColorInterpretation(String colorInterpretationConstant) { |
|
114 |
if(colorInterpretationConstant.equals(RGB)) { |
|
115 |
colorInterpretation = new String[]{RED_BAND, GREEN_BAND, BLUE_BAND}; |
|
116 |
} |
|
117 |
if(colorInterpretationConstant.equals(BGR)) { |
|
118 |
colorInterpretation = new String[]{BLUE_BAND, GREEN_BAND, RED_BAND}; |
|
119 |
} |
|
120 |
if(colorInterpretationConstant.equals(ARGB)) { |
|
121 |
colorInterpretation = new String[]{RED_BAND, GREEN_BAND, BLUE_BAND, ALPHA_BAND}; |
|
122 |
} |
|
123 |
if(colorInterpretationConstant.equals(GRAYSCALE)) { |
|
124 |
colorInterpretation = new String[]{GRAY_BAND}; |
|
125 |
} |
|
126 |
if(colorInterpretationConstant.equals(PALETTE)) { |
|
127 |
colorInterpretation = new String[]{PAL_BAND}; |
|
128 |
} |
|
129 |
} |
|
130 |
|
|
115 | 131 |
/** |
116 | 132 |
* Inicializa el vector de cadenas que contendr?n el nombre de la interpretaci?n |
117 | 133 |
* de color asignada a cada banda. Este valor es el devuelto por la imagen. |
... | ... | |
348 | 364 |
return ci; |
349 | 365 |
} |
350 | 366 |
|
351 |
public static void registerPersistence() {
|
|
367 |
public static DynStruct registerDynClass() {
|
|
352 | 368 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
353 |
DynStruct definition = manager.addDefinition( |
|
354 |
DataStoreColorInterpretation.class, |
|
355 |
PERSISTENCE_NAME, |
|
356 |
"Color interpretation Persistent definition (FIXME)", |
|
357 |
null, |
|
358 |
null |
|
359 |
); |
|
360 |
definition.addDynFieldList("colorinterpretation").setClassOfItems(String.class).setMandatory(false); |
|
369 |
DynStruct definition = manager.getDefinition("Color_Interpretation_Persistent"); |
|
370 |
if( definition == null ) { |
|
371 |
definition = manager.addDefinition( |
|
372 |
DataStoreColorInterpretation.class, |
|
373 |
"Color_Interpretation_Persistent", |
|
374 |
"Color interpretation Persistent definition (FIXME)", |
|
375 |
null, |
|
376 |
null |
|
377 |
); |
|
378 |
} |
|
379 |
|
|
380 |
definition.addDynFieldList("colorinterpretation") |
|
381 |
.setClassOfItems(String.class) |
|
382 |
.setMandatory(false); |
|
383 |
|
|
384 |
return definition; |
|
361 | 385 |
} |
362 | 386 |
|
363 | 387 |
public void saveToState(PersistentState state) throws PersistenceException { |
Also available in: Unified diff