Revision 8588 org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.legend/org.gvsig.raster.lib.legend.impl/src/main/java/org/gvsig/raster/lib/legend/impl/DefaultRasterLegend.java
DefaultRasterLegend.java | ||
---|---|---|
46 | 46 |
import org.gvsig.raster.lib.legend.api.colorinterpretation.ColorInterpretation; |
47 | 47 |
import org.gvsig.raster.lib.legend.api.colorinterpretation.ColorInterpretationNotification; |
48 | 48 |
import org.gvsig.raster.lib.legend.api.colortable.ColorTable; |
49 |
import org.gvsig.raster.lib.legend.impl.operations.brightness.BrightnessOperation; |
|
50 |
import org.gvsig.raster.lib.legend.impl.operations.colorbalancecmy.ColorBalanceCMYOperation; |
|
51 |
import org.gvsig.raster.lib.legend.impl.operations.colorbalancehsl.ColorBalanceHSLOperation; |
|
52 |
import org.gvsig.raster.lib.legend.impl.operations.colorbalancergb.ColorBalanceRGBOperation; |
|
53 |
import org.gvsig.raster.lib.legend.impl.operations.colortable.ColorTableOperation; |
|
54 |
import org.gvsig.raster.lib.legend.impl.operations.contrast.ContrastOperation; |
|
49 | 55 |
import org.gvsig.raster.lib.legend.impl.operations.equalization.EqualizationOperation; |
56 |
import org.gvsig.raster.lib.legend.impl.operations.hsltorgb.HSLToRGBOperation; |
|
57 |
import org.gvsig.raster.lib.legend.impl.operations.rgbtocmyk.RGBToCMYKOperation; |
|
58 |
import org.gvsig.raster.lib.legend.impl.operations.rgbtohsl.RGBToHSLOperation; |
|
50 | 59 |
import org.gvsig.tools.ToolsLocator; |
51 | 60 |
import org.gvsig.tools.dispose.DisposeUtils; |
52 | 61 |
import org.gvsig.tools.dynobject.DynObject; |
... | ... | |
247 | 256 |
try { |
248 | 257 |
if (this.colorInterpretation.isPalette()) { |
249 | 258 |
// Draw buffer with table color |
250 |
image = drawPaletteBuffer(graphics, bufferToDraw, colorInterpretation, transparency, filters); |
|
259 |
// image = drawPaletteBuffer(graphics, bufferToDraw, colorInterpretation, transparency, filters); |
|
260 |
|
|
261 |
|
|
262 |
//Pruebas de filtros |
|
263 |
|
|
264 |
BufferManager bufferManager = BufferLocator.getBufferManager(); |
|
265 |
DynObject parameters = bufferManager.createOperationParameters("ColorTable"); |
|
266 |
parameters.setDynValue(ColorTableOperation.COLOR_INTERPRETATION_PARAM, colorInterpretation); |
|
267 |
|
|
268 |
try { |
|
269 |
Buffer tempBuffer = bufferManager.execute("ColorTable", bufferToDraw, parameters); |
|
270 |
ColorInterpretation outputColorInterpretation = (ColorInterpretation) parameters.getDynValue(ColorTableOperation.OUTPUT_COLOR_INTERPRETATION_PARAM); |
|
271 |
image = drawRGBBuffer(graphics, tempBuffer, outputColorInterpretation, transparency, filters); |
|
272 |
|
|
273 |
|
|
274 |
|
|
275 |
} catch (BufferOperationException e) { |
|
276 |
// TODO Auto-generated catch block |
|
277 |
e.printStackTrace(); |
|
278 |
} |
|
279 |
|
|
280 |
|
|
281 |
//Fin de pruebas de filtros |
|
282 |
|
|
283 |
|
|
284 |
|
|
285 |
|
|
251 | 286 |
} else if (this.colorInterpretation.hasAnyGrayBand()) { |
252 | 287 |
// Draw buffer with gray scale |
253 | 288 |
image = drawGrayBuffer(graphics, bufferToDraw, transparency, filters); |
... | ... | |
351 | 386 |
Buffer byteBuffer = convertToByteBuffer(buffer); |
352 | 387 |
Buffer bufferToDraw = byteBuffer; |
353 | 388 |
|
354 |
//Pruebas de filtros |
|
389 |
// //Pruebas de filtros |
|
390 |
// |
|
391 |
// BufferManager bufferManager = BufferLocator.getBufferManager(); |
|
392 |
// DynObject parameters = bufferManager.createOperationParameters("RGBToHSL"); |
|
393 |
// parameters.setDynValue(RGBToHSLOperation.COLOR_INTERPRETATION_PARAM, colorInterpretation); |
|
394 |
// |
|
395 |
//// parameters.setDynValue(ColorBalanceHSLOperation.LIGHTNESS_PARAM, 50); |
|
396 |
//// parameters.setDynValue(ColorBalanceHSLOperation.SATURATION_PARAM, 25); |
|
397 |
//// parameters.setDynValue(FirstDerivativeOperation.UMBRAL_PARAM, 0); |
|
398 |
//// double customK[][] = {{-1,-1,-1},{-1,9,-1},{-1,-1,-1}}; |
|
399 |
//// Kernel customKernel = bufferManager.createKernel(customK); |
|
400 |
//// parameters.setDynValue(ConvolutionOperation.OPERATOR_PARAM, ConvolutionOperation.CUSTOM_OPERATOR_STRING); |
|
401 |
//// parameters.setDynValue(ConvolutionOperation.CUSTOM_KERNEL_PARAM, customKernel); |
|
402 |
//// parameters.setDynValue(FirstDerivativeOperation.COMPARE_PARAM, true); |
|
403 |
// try { |
|
404 |
// Buffer tempBuffer = bufferManager.execute("RGBToHSL", byteBuffer, parameters); |
|
405 |
// ColorInterpretation outputColorInterpretation = (ColorInterpretation) parameters.getDynValue(RGBToHSLOperation.OUTPUT_COLOR_INTERPRETATION_PARAM); |
|
406 |
// |
|
407 |
//// return drawHSLBuffer(graphics, tempBuffer, outputColorInterpretation, transparency, filters); |
|
408 |
// |
|
409 |
//// bufferToDraw = tempBuffer; |
|
410 |
// |
|
411 |
// DynObject parameters2 = bufferManager.createOperationParameters("HSLToRGB"); |
|
412 |
// parameters2.setDynValue(HSLToRGBOperation.COLOR_INTERPRETATION_PARAM, outputColorInterpretation); |
|
413 |
// bufferToDraw = bufferManager.execute("HSLToRGB", tempBuffer, parameters2); |
|
414 |
// colorInterpretation = (ColorInterpretation) parameters2.getDynValue(HSLToRGBOperation.OUTPUT_COLOR_INTERPRETATION_PARAM); |
|
415 |
// |
|
416 |
// } catch (BufferOperationException e) { |
|
417 |
// // TODO Auto-generated catch block |
|
418 |
// e.printStackTrace(); |
|
419 |
// } |
|
420 |
// |
|
421 |
// |
|
422 |
// //Fin de pruebas de filtros |
|
355 | 423 |
|
356 |
BufferManager bufferManager = BufferLocator.getBufferManager(); |
|
357 |
DynObject parameters = bufferManager.createOperationParameters("Equalization"); |
|
358 |
parameters.setDynValue(EqualizationOperation.COLOR_INTERPRETATION_PARAM, colorInterpretation); |
|
359 |
// parameters.setDynValue(FirstDerivativeOperation.UMBRAL_PARAM, 0); |
|
360 |
// double customK[][] = {{-1,-1,-1},{-1,9,-1},{-1,-1,-1}}; |
|
361 |
// Kernel customKernel = bufferManager.createKernel(customK); |
|
362 |
// parameters.setDynValue(ConvolutionOperation.OPERATOR_PARAM, ConvolutionOperation.CUSTOM_OPERATOR_STRING); |
|
363 |
// parameters.setDynValue(ConvolutionOperation.CUSTOM_KERNEL_PARAM, customKernel); |
|
364 |
// parameters.setDynValue(FirstDerivativeOperation.COMPARE_PARAM, true); |
|
365 |
try { |
|
366 |
bufferToDraw = bufferManager.execute("Equalization", byteBuffer, parameters); |
|
367 |
} catch (BufferOperationException e) { |
|
368 |
// TODO Auto-generated catch block |
|
369 |
e.printStackTrace(); |
|
370 |
} |
|
371 |
|
|
372 |
//Fin de pruebas de filtros |
|
373 |
|
|
374 | 424 |
BufferedImage image = null; |
375 | 425 |
|
376 | 426 |
if (colorInterpretation.isRGB() || colorInterpretation.isRGBA() || colorInterpretation.hasAnyRGBBand()) { |
377 |
image = ToolsSwingLocator.getToolsSwingManager().createBufferedImage(buffer.getColumns(), buffer.getRows(),
|
|
427 |
image = ToolsSwingLocator.getToolsSwingManager().createBufferedImage(bufferToDraw.getColumns(), bufferToDraw.getRows(),
|
|
378 | 428 |
BufferedImage.TYPE_INT_ARGB); |
379 | 429 |
} else if (colorInterpretation.isBGR()) { |
380 |
image = ToolsSwingLocator.getToolsSwingManager().createBufferedImage(buffer.getColumns(), buffer.getRows(),
|
|
430 |
image = ToolsSwingLocator.getToolsSwingManager().createBufferedImage(bufferToDraw.getColumns(), bufferToDraw.getRows(),
|
|
381 | 431 |
BufferedImage.TYPE_INT_BGR); |
382 | 432 |
} |
383 | 433 |
|
... | ... | |
409 | 459 |
alphaBand = bufferToDraw.getBand(alphaBandIndex); |
410 | 460 |
} |
411 | 461 |
|
412 |
for (int i = 0; i < buffer.getRows(); i++) { |
|
413 |
for (int j = 0; j < buffer.getColumns(); j++) { |
|
462 |
for (int i = 0; i < bufferToDraw.getRows(); i++) {
|
|
463 |
for (int j = 0; j < bufferToDraw.getColumns(); j++) {
|
|
414 | 464 |
|
415 | 465 |
int alphaByteValue = 255; |
416 | 466 |
int redByteValue = 0; |
Also available in: Unified diff