svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / fmap / raster / legend / ColorTableLegend.java @ 12942
History | View | Annotate | Download (4.09 KB)
1 | 12425 | nacho | /* 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 | 12488 | bsanchez | import org.gvsig.raster.datastruct.ColorItem; |
24 | 12425 | nacho | 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 | 12488 | bsanchez | *
|
37 | 12425 | nacho | * @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 | 12488 | bsanchez | |
46 | 12425 | nacho | /**
|
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 | 12488 | bsanchez | 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 | 12425 | nacho | SimpleFillSymbol s = new SimpleFillSymbol();
|
59 | s.setOutline(line); |
||
60 | 12488 | bsanchez | 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 | 12425 | nacho | symbol[i] = s; |
66 | } |
||
67 | 12488 | bsanchez | |
68 | 12425 | nacho | return new ColorTableLegend(symbol, desc); |
69 | } |
||
70 | 12488 | bsanchez | |
71 | 12425 | nacho | /**
|
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 | 12488 | bsanchez | |
81 | 12425 | nacho | /*
|
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 | 12488 | bsanchez | |
133 | 12942 | bsanchez | public String getClassName() { |
134 | // TODO Auto-generated method stub
|
||
135 | return null; |
||
136 | } |
||
137 | |||
138 | public void setXMLEntity(XMLEntity xml) { |
||
139 | // TODO Auto-generated method stub
|
||
140 | |||
141 | } |
||
142 | |||
143 | 12425 | nacho | } |