Revision 12823 trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/colortable/ui/ColorTableIconPainter.java
ColorTableIconPainter.java | ||
---|---|---|
18 | 18 |
*/ |
19 | 19 |
package org.gvsig.rastertools.colortable.ui; |
20 | 20 |
|
21 |
import java.awt.Color; |
|
22 | 21 |
import java.awt.Graphics2D; |
23 |
import java.awt.Rectangle; |
|
24 |
import java.util.ArrayList; |
|
25 | 22 |
|
26 | 23 |
import org.gvsig.gui.beans.listview.IIconPaint; |
27 |
import org.gvsig.raster.datastruct.ColorItem; |
|
28 | 24 |
import org.gvsig.raster.datastruct.ColorTable; |
25 |
|
|
26 |
import com.iver.cit.gvsig.gui.styling.ColorTablePaint; |
|
29 | 27 |
/** |
28 |
* Usa el ColorTablePaint de appgvSIG para dibujar iconos con gradientes en |
|
29 |
* un ListViewComponent |
|
30 | 30 |
* |
31 | 31 |
* @version 29/06/2007 |
32 | 32 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
33 | 33 |
*/ |
34 |
public class ColorTableIconPainter implements IIconPaint { |
|
35 |
private ColorTable colorTable; |
|
34 |
public class ColorTableIconPainter extends ColorTablePaint implements IIconPaint { |
|
36 | 35 |
|
36 |
/** |
|
37 |
* Construye un ColorTableIconPainter |
|
38 |
* @param colorTable |
|
39 |
*/ |
|
37 | 40 |
public ColorTableIconPainter(ColorTable colorTable) { |
38 |
this.colorTable = colorTable;
|
|
41 |
super(colorTable);
|
|
39 | 42 |
} |
40 | 43 |
|
41 |
public void setInterpolated(boolean value) { |
|
42 |
colorTable.setInterpolated(value); |
|
44 |
public void paint(Graphics2D g, boolean isSelected) { |
|
45 |
System.out.println("a"); |
|
46 |
super.paint(g, isSelected); |
|
43 | 47 |
} |
44 | 48 |
|
45 |
public ArrayList getColorItems() { |
|
46 |
return colorTable.getColorItems(); |
|
47 |
} |
|
48 | 49 |
|
49 |
public ColorTable getColorTable() { |
|
50 |
return colorTable; |
|
51 |
} |
|
52 |
|
|
53 |
public void setColorItems(ArrayList value, boolean interpolated, boolean compress) { |
|
54 |
colorTable.createPaletteFromColorItems(value, compress); |
|
55 |
setInterpolated(interpolated); |
|
56 |
} |
|
57 |
|
|
58 |
public void paint(Graphics2D g, boolean isSelected) { |
|
59 |
Rectangle area = g.getClipBounds(); |
|
60 |
|
|
61 |
int x1 = area.x; |
|
62 |
int x2 = area.x + area.width - 1; |
|
63 |
|
|
64 |
if (colorTable.getColorItems().size()>=1) { |
|
65 |
double min = ((ColorItem) colorTable.getColorItems().get(0)).getValue(); |
|
66 |
double max = ((ColorItem) colorTable.getColorItems().get(colorTable.getColorItems().size()-1)).getValue(); |
|
67 |
for (int i = area.x; i < (area.x + area.width); i++) { |
|
68 |
double pos = min + (((max - min) * (i - area.x)) / (area.width - 2)); |
|
69 |
|
|
70 |
byte[] col3 = colorTable.getRGBByBand(pos); |
|
71 |
g.setColor(new Color(col3[0] & 0xff, col3[1] & 0xff, col3[2] & 0xff)); |
|
72 |
g.drawLine(i, area.y, i, area.y + area.height); |
|
73 |
} |
|
74 |
} else { |
|
75 |
g.setColor(new Color(224, 224, 224)); |
|
76 |
g.fillRect(x1, area.y, x2 - x1, area.height - 1); |
|
77 |
} |
|
78 |
if (isSelected) |
|
79 |
g.setColor(Color.black); |
|
80 |
else |
|
81 |
g.setColor(new Color(96, 96, 96)); |
|
82 |
g.drawRect(x1, area.y, x2 - x1, area.height - 1); |
|
83 |
} |
|
84 | 50 |
} |
Also available in: Unified diff