Revision 17500
trunk/libraries/libRaster/src/org/gvsig/raster/datastruct/ColorTable.java | ||
---|---|---|
734 | 734 |
|
735 | 735 |
return true; |
736 | 736 |
} |
737 |
|
|
738 |
/** |
|
739 |
* Establece la tabla de color actual en los rangos de limite especificados |
|
740 |
* por parametros, distribuyendolo proporcionalmente. |
|
741 |
* @param min |
|
742 |
* @param max |
|
743 |
* @param compress |
|
744 |
*/ |
|
745 |
public void createColorTableInRange(double min, double max, boolean compress) { |
|
746 |
ColorItem colorItem; |
|
747 |
double max2 = Double.NEGATIVE_INFINITY; |
|
748 |
double min2 = Double.POSITIVE_INFINITY; |
|
749 |
|
|
750 |
if (min > max) { |
|
751 |
double aux = min; |
|
752 |
min = max; |
|
753 |
max = aux; |
|
754 |
} |
|
755 |
|
|
756 |
ArrayList arrayList = new ArrayList(); |
|
757 |
ArrayList items = getColorItems(); |
|
758 |
|
|
759 |
// Actualizamos el maximo y minimo del array |
|
760 |
for (int i = 0; i < items.size(); i++) { |
|
761 |
colorItem = (ColorItem) items.get(i); |
|
762 |
if (colorItem.getValue() > max2) |
|
763 |
max2 = colorItem.getValue(); |
|
764 |
if (colorItem.getValue() < min2) |
|
765 |
min2 = colorItem.getValue(); |
|
766 |
} |
|
767 |
|
|
768 |
// A?adir el minimo |
|
769 |
if (items.size() > 0) |
|
770 |
colorItem = (ColorItem) items.get(0); |
|
771 |
else { |
|
772 |
colorItem = new ColorItem(); |
|
773 |
colorItem.setValue(0); |
|
774 |
colorItem.setColor(Color.black); |
|
775 |
} |
|
776 |
|
|
777 |
arrayList.add(colorItem); |
|
778 |
|
|
779 |
for (int i = 0; i < items.size(); i++) { |
|
780 |
colorItem = (ColorItem) items.get(i); |
|
781 |
colorItem.setValue(min + (((colorItem.getValue() - min2) * (max - min)) / (max2 - min2))); |
|
782 |
arrayList.add(colorItem); |
|
783 |
} |
|
784 |
|
|
785 |
// A?adir el maximo |
|
786 |
if (items.size() > 0) |
|
787 |
colorItem = (ColorItem) items.get(items.size() - 1); |
|
788 |
else { |
|
789 |
colorItem = new ColorItem(); |
|
790 |
colorItem.setValue(255); |
|
791 |
colorItem.setColor(Color.white); |
|
792 |
} |
|
793 |
arrayList.add(colorItem); |
|
794 |
|
|
795 |
createPaletteFromColorItems(arrayList, compress); |
|
796 |
} |
|
737 | 797 |
} |
Also available in: Unified diff