root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / rendering / LegendFactory.java @ 13032
History | View | Annotate | Download (6.51 KB)
1 | 1100 | fjp | /* 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 | 214 | fernando | package com.iver.cit.gvsig.fmap.rendering; |
42 | |||
43 | 1828 | fernando | import com.hardcode.gdbms.engine.data.driver.DriverException; |
44 | 458 | fjp | import com.iver.cit.gvsig.fmap.core.FShape; |
45 | 10815 | jaume | import com.iver.cit.gvsig.fmap.core.SymbologyFactory; |
46 | 458 | fjp | import com.iver.cit.gvsig.fmap.core.v02.FConstant; |
47 | import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
||
48 | 490 | fernando | import com.iver.cit.gvsig.fmap.layers.XMLException; |
49 | 413 | vcaballero | import com.iver.utiles.XMLEntity; |
50 | 214 | fernando | |
51 | |||
52 | 326 | fernando | /**
|
53 | 1034 | vcaballero | * Clase factoria de las diferentes leyendas.
|
54 | 326 | fernando | *
|
55 | * @author Fernando Gonz?lez Cort?s
|
||
56 | */
|
||
57 | 214 | fernando | public class LegendFactory { |
58 | 10815 | jaume | /*public static FSymbol DEFAULT_POINT_SYMBOL = new FSymbol(FConstant.SYMBOL_TYPE_POINT);
|
59 | 1034 | vcaballero | public static FSymbol DEFAULT_LINE_SYMBOL = new FSymbol(FConstant.SYMBOL_TYPE_LINE);
|
60 | 10815 | jaume | public static FSymbol DEFAULT_POLYGON_SYMBOL = new FSymbol(FConstant.SYMBOL_TYPE_FILL);*/
|
61 | 326 | fernando | |
62 | 1034 | vcaballero | // TODO Descomentar esto cuando se tenga la interfaz de datos
|
63 | 326 | fernando | |
64 | 1034 | vcaballero | /*
|
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 | 326 | fernando | |
76 | 1034 | vcaballero | /**
|
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 | 11558 | jaume | public static IVectorialLegend createSingleSymbolLegend(int shapeType) { |
85 | 10815 | jaume | /*switch (shapeType) {
|
86 | 1034 | vcaballero | case FShape.POINT:
|
87 | 10815 | jaume | return new SingleSymbolLegend(
|
88 | SymbologyFactory.createDefaultMarkerSymbol());
|
||
89 | 1034 | vcaballero | |
90 | case FShape.LINE:
|
||
91 | 10815 | jaume | return new SingleSymbolLegend(
|
92 | SymbologyFactory.createDefaultLineSymbol());
|
||
93 | 1034 | vcaballero | |
94 | case FShape.POLYGON:
|
||
95 | 10815 | jaume | return new SingleSymbolLegend(
|
96 | SymbologyFactory.createDefaultFillSymbol());
|
||
97 | 2199 | vcaballero | case FShape.MULTIPOINT:
|
98 | 10815 | jaume | return new SingleSymbolLegend(
|
99 | SymbologyFactory.createDefaultMarkerSymbol());
|
||
100 | 4213 | caballero | case FShape.TEXT:
|
101 | 10815 | jaume | return new SingleSymbolLegend(
|
102 | SymbologyFactory.createDefaultTextSymbol());
|
||
103 | 458 | fjp | }
|
104 | 214 | fernando | |
105 | 10815 | jaume | return new SingleSymbolLegend(
|
106 | SymbologyFactory.createDefaultFillSymbol());
|
||
107 | */
|
||
108 | return new SingleSymbolLegend( |
||
109 | SymbologyFactory.createDefaultSymbolByShapeType(shapeType)); |
||
110 | |||
111 | 1034 | vcaballero | } |
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 | 11558 | jaume | public static XMLEntity getXMLEntity(IVectorialLegend r) |
150 | 1034 | vcaballero | 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 | 11558 | jaume | public static IVectorialLegend createFromXML03(XMLEntity xml) |
166 | 2183 | fernando | throws XMLException {
|
167 | //TODO Implementar bien
|
||
168 | try {
|
||
169 | 11558 | jaume | IVectorialLegend vl = null;
|
170 | 2183 | fernando | Class clase = Class.forName(xml.getStringProperty("className")); |
171 | 11558 | jaume | vl = (IVectorialLegend) clase.newInstance(); |
172 | 2183 | fernando | 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 | 11558 | jaume | public static IVectorialLegend createFromXML(XMLEntity xml) |
194 | 1034 | vcaballero | throws XMLException {
|
195 | //TODO Implementar bien
|
||
196 | try {
|
||
197 | 11558 | jaume | IVectorialLegend vl = null;
|
198 | 1094 | vcaballero | Class clase = Class.forName(xml.getStringProperty("className")); |
199 | 11558 | jaume | vl = (IVectorialLegend) clase.newInstance(); |
200 | 1034 | vcaballero | vl.setXMLEntity(xml); |
201 | |||
202 | return vl;
|
||
203 | } catch (ClassNotFoundException e) { |
||
204 | 490 | fernando | throw new XMLException(e); |
205 | } catch (InstantiationException e) { |
||
206 | throw new XMLException(e); |
||
207 | } catch (IllegalAccessException e) { |
||
208 | throw new XMLException(e); |
||
209 | } |
||
210 | 1034 | vcaballero | } |
211 | 214 | fernando | |
212 | 1034 | vcaballero | /**
|
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 | 11558 | jaume | public static IVectorialLegend cloneLegend(IVectorialLegend l) |
223 | 1034 | vcaballero | throws XMLException, DriverException {
|
224 | return createFromXML(getXMLEntity(l));
|
||
225 | } |
||
226 | 214 | fernando | } |