root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / rendering / LegendFactory.java @ 13032
History | View | Annotate | Download (6.51 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 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 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package com.iver.cit.gvsig.fmap.rendering; |
42 |
|
43 |
import com.hardcode.gdbms.engine.data.driver.DriverException; |
44 |
import com.iver.cit.gvsig.fmap.core.FShape; |
45 |
import com.iver.cit.gvsig.fmap.core.SymbologyFactory; |
46 |
import com.iver.cit.gvsig.fmap.core.v02.FConstant; |
47 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
48 |
import com.iver.cit.gvsig.fmap.layers.XMLException; |
49 |
import com.iver.utiles.XMLEntity; |
50 |
|
51 |
|
52 |
/**
|
53 |
* Clase factoria de las diferentes leyendas.
|
54 |
*
|
55 |
* @author Fernando Gonz?lez Cort?s
|
56 |
*/
|
57 |
public class LegendFactory { |
58 |
/*public static FSymbol DEFAULT_POINT_SYMBOL = new FSymbol(FConstant.SYMBOL_TYPE_POINT);
|
59 |
public static FSymbol DEFAULT_LINE_SYMBOL = new FSymbol(FConstant.SYMBOL_TYPE_LINE);
|
60 |
public static FSymbol DEFAULT_POLYGON_SYMBOL = new FSymbol(FConstant.SYMBOL_TYPE_FILL);*/
|
61 |
|
62 |
// TODO Descomentar esto cuando se tenga la interfaz de datos
|
63 |
|
64 |
/*
|
65 |
* Crea un objeto renderer de valor ?nico con las caracter?sticas que se pasan como par?metro y con los s?mbolos por defecto. En funci?n de la carga del sistema se podr? crear un FRenderer que almacene la referencia al FRecordset, o un FRenderer que haga cach? de los valores necesarios
|
66 |
*
|
67 |
public static Legend createIntervalLegend(FRecordset data, int valueField, int labelField ) {
|
68 |
}
|
69 |
/*
|
70 |
* Crea un objeto renderer de valor ?nico con las caracter?sticas que se pasan como par?metro y con los s?mbolos por defecto. En funci?n de la carga del sistema se podr? crear un FRenderer que almacene la referencia al FRecordset, o un FRenderer que haga cach? de los valores necesarios
|
71 |
*
|
72 |
public static Legend createUniqueValueLegend(FRecordset data, int valueField, int labelField ) {
|
73 |
}
|
74 |
*/
|
75 |
|
76 |
/**
|
77 |
* Crea un objeto renderer de s?mbolo ?nico con las caracter?sticas que se
|
78 |
* pasan como par?metro
|
79 |
*
|
80 |
* @param shapeType Tipo de shape.
|
81 |
*
|
82 |
* @return VectorialLegend.
|
83 |
*/
|
84 |
public static IVectorialLegend createSingleSymbolLegend(int shapeType) { |
85 |
/*switch (shapeType) {
|
86 |
case FShape.POINT:
|
87 |
return new SingleSymbolLegend(
|
88 |
SymbologyFactory.createDefaultMarkerSymbol());
|
89 |
|
90 |
case FShape.LINE:
|
91 |
return new SingleSymbolLegend(
|
92 |
SymbologyFactory.createDefaultLineSymbol());
|
93 |
|
94 |
case FShape.POLYGON:
|
95 |
return new SingleSymbolLegend(
|
96 |
SymbologyFactory.createDefaultFillSymbol());
|
97 |
case FShape.MULTIPOINT:
|
98 |
return new SingleSymbolLegend(
|
99 |
SymbologyFactory.createDefaultMarkerSymbol());
|
100 |
case FShape.TEXT:
|
101 |
return new SingleSymbolLegend(
|
102 |
SymbologyFactory.createDefaultTextSymbol());
|
103 |
}
|
104 |
|
105 |
return new SingleSymbolLegend(
|
106 |
SymbologyFactory.createDefaultFillSymbol());
|
107 |
*/
|
108 |
return new SingleSymbolLegend( |
109 |
SymbologyFactory.createDefaultSymbolByShapeType(shapeType)); |
110 |
|
111 |
} |
112 |
|
113 |
/**
|
114 |
* Crea un objeto VectorialUniqueValueLegend vac?o, dispuesto para cargar
|
115 |
* s?mbolos
|
116 |
*
|
117 |
* @param shapeType Tipo de shape.
|
118 |
*
|
119 |
* @return VectorialUniqueValueLegend.
|
120 |
*/
|
121 |
public static VectorialUniqueValueLegend createVectorialUniqueValueLegend( |
122 |
int shapeType) {
|
123 |
return new VectorialUniqueValueLegend(shapeType); |
124 |
} |
125 |
|
126 |
/**
|
127 |
* Crea un objeto VectorialIntervalLegend vac?o, dispuesto para cargar
|
128 |
* s?mbolos
|
129 |
*
|
130 |
* @param shapeType tipo de shape.
|
131 |
*
|
132 |
* @return VectorialIntervalLegend
|
133 |
*/
|
134 |
public static VectorialIntervalLegend createVectorialIntervalLegend( |
135 |
int shapeType) {
|
136 |
return new VectorialIntervalLegend(shapeType); |
137 |
} |
138 |
|
139 |
/**
|
140 |
* Obtiene un objeto con las propiedades del renderer. Este m?todo se
|
141 |
* invocar? con el fin de guardar el s?mbolo en disco.
|
142 |
*
|
143 |
* @param r VectorialLegend.
|
144 |
*
|
145 |
* @return XMLEntity.
|
146 |
*
|
147 |
* @throws DriverException
|
148 |
*/
|
149 |
public static XMLEntity getXMLEntity(IVectorialLegend r) |
150 |
throws DriverException {
|
151 |
XMLEntity xml = r.getXMLEntity(); |
152 |
|
153 |
return xml;
|
154 |
} |
155 |
|
156 |
/**
|
157 |
* Crea un renderer con la informaci?n contenida en el objeto XMLEntity
|
158 |
*
|
159 |
* @param xml XMLEntity.
|
160 |
*
|
161 |
* @return VectorialLegend
|
162 |
*
|
163 |
* @throws XMLException
|
164 |
*/
|
165 |
public static IVectorialLegend createFromXML03(XMLEntity xml) |
166 |
throws XMLException {
|
167 |
//TODO Implementar bien
|
168 |
try {
|
169 |
IVectorialLegend vl = null;
|
170 |
Class clase = Class.forName(xml.getStringProperty("className")); |
171 |
vl = (IVectorialLegend) clase.newInstance(); |
172 |
vl.setXMLEntity03(xml); |
173 |
|
174 |
return vl;
|
175 |
} catch (ClassNotFoundException e) { |
176 |
throw new XMLException(e); |
177 |
} catch (InstantiationException e) { |
178 |
throw new XMLException(e); |
179 |
} catch (IllegalAccessException e) { |
180 |
throw new XMLException(e); |
181 |
} |
182 |
} |
183 |
|
184 |
/**
|
185 |
* Crea un renderer con la informaci?n contenida en el objeto XMLEntity
|
186 |
*
|
187 |
* @param xml XMLEntity.
|
188 |
*
|
189 |
* @return VectorialLegend
|
190 |
*
|
191 |
* @throws XMLException
|
192 |
*/
|
193 |
public static IVectorialLegend createFromXML(XMLEntity xml) |
194 |
throws XMLException {
|
195 |
//TODO Implementar bien
|
196 |
try {
|
197 |
IVectorialLegend vl = null;
|
198 |
Class clase = Class.forName(xml.getStringProperty("className")); |
199 |
vl = (IVectorialLegend) clase.newInstance(); |
200 |
vl.setXMLEntity(xml); |
201 |
|
202 |
return vl;
|
203 |
} catch (ClassNotFoundException e) { |
204 |
throw new XMLException(e); |
205 |
} catch (InstantiationException e) { |
206 |
throw new XMLException(e); |
207 |
} catch (IllegalAccessException e) { |
208 |
throw new XMLException(e); |
209 |
} |
210 |
} |
211 |
|
212 |
/**
|
213 |
* Clona la leyenda.
|
214 |
*
|
215 |
* @param l VectorialLegend a clonar.
|
216 |
*
|
217 |
* @return VectorialLegend cloando.
|
218 |
*
|
219 |
* @throws XMLException
|
220 |
* @throws DriverException
|
221 |
*/
|
222 |
public static IVectorialLegend cloneLegend(IVectorialLegend l) |
223 |
throws XMLException, DriverException {
|
224 |
return createFromXML(getXMLEntity(l));
|
225 |
} |
226 |
} |