svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / fmap / raster / legend / ColorTableLegend.java @ 12488
History | View | Annotate | Download (3.92 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007 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.fmap.raster.legend; |
20 |
|
21 |
import java.awt.Color; |
22 |
|
23 |
import org.gvsig.raster.datastruct.ColorItem; |
24 |
import org.gvsig.raster.datastruct.ColorTable; |
25 |
|
26 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
27 |
import com.iver.cit.gvsig.fmap.core.symbols.SimpleFillSymbol; |
28 |
import com.iver.cit.gvsig.fmap.core.symbols.SimpleLineSymbol; |
29 |
import com.iver.cit.gvsig.fmap.layers.XMLException; |
30 |
import com.iver.cit.gvsig.fmap.rendering.IClassifiedLegend; |
31 |
import com.iver.cit.gvsig.fmap.rendering.ILegend; |
32 |
import com.iver.utiles.XMLEntity; |
33 |
|
34 |
/**
|
35 |
* Leyenda para tablas de color aplicadas a un raster.
|
36 |
*
|
37 |
* @version 27/06/2007
|
38 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
39 |
*
|
40 |
*/
|
41 |
public class ColorTableLegend implements IClassifiedLegend { |
42 |
|
43 |
ISymbol[] symbols = null; |
44 |
String[] desc = null; |
45 |
|
46 |
/**
|
47 |
* Crea una leyenda de tipo ColorTableLegend a partir de un objeto ColorTable
|
48 |
* @param colorTable
|
49 |
* @return ColorTableLegend
|
50 |
*/
|
51 |
public static ColorTableLegend createLegend(ColorTable colorTable) { |
52 |
SimpleLineSymbol line = new SimpleLineSymbol();
|
53 |
line.setLineColor(Color.BLACK);
|
54 |
ISymbol[] symbol = new ISymbol[colorTable.getColorItems().size()]; |
55 |
String[] desc = new String[colorTable.getColorItems().size()]; |
56 |
|
57 |
for (int i = 0; i < colorTable.getColorItems().size(); i++) { |
58 |
SimpleFillSymbol s = new SimpleFillSymbol();
|
59 |
s.setOutline(line); |
60 |
s.setFillColor(((ColorItem) colorTable.getColorItems().get(i)).getColor()); |
61 |
if (i < (colorTable.getColorItems().size() - 1)) |
62 |
desc[i] = "[" + ((ColorItem) colorTable.getColorItems().get(i)).getValue() + " , " + ((ColorItem) colorTable.getColorItems().get(i + 1)).getValue() + "[ " + ((ColorItem) colorTable.getColorItems().get(i)).getNameClass(); |
63 |
else
|
64 |
desc[i] = "[" + ((ColorItem) colorTable.getColorItems().get(i)).getValue() + "] " + ((ColorItem) colorTable.getColorItems().get(i)).getNameClass(); |
65 |
symbol[i] = s; |
66 |
} |
67 |
|
68 |
return new ColorTableLegend(symbol, desc); |
69 |
} |
70 |
|
71 |
/**
|
72 |
* Leyenda para tablas de color raster.
|
73 |
* @param s Lista de simbolos
|
74 |
* @param d Lista de descripciones de simbolos
|
75 |
*/
|
76 |
public ColorTableLegend (ISymbol[] s, String[] d) { |
77 |
symbols = s; |
78 |
desc = d; |
79 |
} |
80 |
|
81 |
/*
|
82 |
* (non-Javadoc)
|
83 |
* @see com.iver.cit.gvsig.fmap.rendering.IClassifiedLegend#getDescriptions()
|
84 |
*/
|
85 |
public String[] getDescriptions() { |
86 |
return desc;
|
87 |
} |
88 |
|
89 |
/*
|
90 |
* (non-Javadoc)
|
91 |
* @see com.iver.cit.gvsig.fmap.rendering.IClassifiedLegend#getSymbols()
|
92 |
*/
|
93 |
public ISymbol[] getSymbols() { |
94 |
return symbols;
|
95 |
} |
96 |
|
97 |
/*
|
98 |
* (non-Javadoc)
|
99 |
* @see com.iver.cit.gvsig.fmap.rendering.IClassifiedLegend#getValues()
|
100 |
*/
|
101 |
public Object[] getValues() { |
102 |
return null; |
103 |
} |
104 |
|
105 |
/*
|
106 |
* (non-Javadoc)
|
107 |
* @see com.iver.cit.gvsig.fmap.rendering.ILegend#cloneLegend()
|
108 |
*/
|
109 |
public ILegend cloneLegend() throws XMLException { |
110 |
return null; |
111 |
} |
112 |
|
113 |
public ISymbol getDefaultSymbol() {
|
114 |
return null; |
115 |
} |
116 |
|
117 |
/*
|
118 |
* (non-Javadoc)
|
119 |
* @see com.iver.cit.gvsig.fmap.rendering.ILegend#getSLDString(java.lang.String)
|
120 |
*/
|
121 |
public String getSLDString(String layerName) { |
122 |
return null; |
123 |
} |
124 |
|
125 |
/*
|
126 |
* (non-Javadoc)
|
127 |
* @see com.iver.cit.gvsig.fmap.rendering.ILegend#getXMLEntity()
|
128 |
*/
|
129 |
public XMLEntity getXMLEntity() {
|
130 |
return null; |
131 |
} |
132 |
|
133 |
} |