svn-gvsig-desktop / branches / FMap_piloto_CAD_Layout_version / libraries / libFMap / src / com / iver / cit / gvsig / fmap / rendering / LegendFactory.java @ 1763
History | View | Annotate | Download (5.42 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 | 531 | vcaballero | import com.hardcode.gdbms.engine.data.DriverException; |
44 | 1034 | vcaballero | |
45 | 458 | fjp | import com.iver.cit.gvsig.fmap.core.FShape; |
46 | 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 | 1034 | vcaballero | |
50 | 413 | vcaballero | import com.iver.utiles.XMLEntity; |
51 | 214 | fernando | |
52 | |||
53 | 326 | fernando | /**
|
54 | 1034 | vcaballero | * Clase factoria de las diferentes leyendas.
|
55 | 326 | fernando | *
|
56 | * @author Fernando Gonz?lez Cort?s
|
||
57 | */
|
||
58 | 214 | fernando | public class LegendFactory { |
59 | 1034 | vcaballero | public static FSymbol DEFAULT_POINT_SYMBOL = new FSymbol(FConstant.SYMBOL_TYPE_POINT); |
60 | public static FSymbol DEFAULT_LINE_SYMBOL = new FSymbol(FConstant.SYMBOL_TYPE_LINE); |
||
61 | public static FSymbol DEFAULT_POLYGON_SYMBOL = new FSymbol(FConstant.SYMBOL_TYPE_FILL); |
||
62 | 326 | fernando | |
63 | 1034 | vcaballero | // TODO Descomentar esto cuando se tenga la interfaz de datos
|
64 | 326 | fernando | |
65 | 1034 | vcaballero | /*
|
66 | * 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
|
||
67 | *
|
||
68 | public static Legend createIntervalLegend(FRecordset data, int valueField, int labelField ) {
|
||
69 | }
|
||
70 | /*
|
||
71 | * 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
|
||
72 | *
|
||
73 | public static Legend createUniqueValueLegend(FRecordset data, int valueField, int labelField ) {
|
||
74 | }
|
||
75 | */
|
||
76 | 326 | fernando | |
77 | 1034 | vcaballero | /**
|
78 | * Crea un objeto renderer de s?mbolo ?nico con las caracter?sticas que se
|
||
79 | * pasan como par?metro
|
||
80 | *
|
||
81 | * @param shapeType Tipo de shape.
|
||
82 | *
|
||
83 | * @return VectorialLegend.
|
||
84 | */
|
||
85 | public static VectorialLegend createSingleSymbolLegend(int shapeType) { |
||
86 | switch (shapeType) {
|
||
87 | case FShape.POINT:
|
||
88 | return new SingleSymbolLegend(new FSymbol( |
||
89 | FConstant.SYMBOL_TYPE_POINT)); |
||
90 | |||
91 | case FShape.LINE:
|
||
92 | return new SingleSymbolLegend(new FSymbol( |
||
93 | FConstant.SYMBOL_TYPE_LINE)); |
||
94 | |||
95 | case FShape.POLYGON:
|
||
96 | return new SingleSymbolLegend(new FSymbol( |
||
97 | FConstant.SYMBOL_TYPE_FILL)); |
||
98 | 458 | fjp | } |
99 | 214 | fernando | |
100 | 1034 | vcaballero | return new SingleSymbolLegend(new FSymbol(FConstant.SYMBOL_TYPE_FILL)); |
101 | } |
||
102 | |||
103 | /**
|
||
104 | * Crea un objeto VectorialUniqueValueLegend vac?o, dispuesto para cargar
|
||
105 | * s?mbolos
|
||
106 | *
|
||
107 | * @param shapeType Tipo de shape.
|
||
108 | *
|
||
109 | * @return VectorialUniqueValueLegend.
|
||
110 | */
|
||
111 | public static VectorialUniqueValueLegend createVectorialUniqueValueLegend( |
||
112 | int shapeType) {
|
||
113 | return new VectorialUniqueValueLegend(shapeType); |
||
114 | } |
||
115 | |||
116 | /**
|
||
117 | * Crea un objeto VectorialIntervalLegend vac?o, dispuesto para cargar
|
||
118 | * s?mbolos
|
||
119 | *
|
||
120 | * @param shapeType tipo de shape.
|
||
121 | *
|
||
122 | * @return VectorialIntervalLegend
|
||
123 | */
|
||
124 | public static VectorialIntervalLegend createVectorialIntervalLegend( |
||
125 | int shapeType) {
|
||
126 | return new VectorialIntervalLegend(shapeType); |
||
127 | } |
||
128 | |||
129 | /**
|
||
130 | * Obtiene un objeto con las propiedades del renderer. Este m?todo se
|
||
131 | * invocar? con el fin de guardar el s?mbolo en disco.
|
||
132 | *
|
||
133 | * @param r VectorialLegend.
|
||
134 | *
|
||
135 | * @return XMLEntity.
|
||
136 | *
|
||
137 | * @throws DriverException
|
||
138 | */
|
||
139 | public static XMLEntity getXMLEntity(VectorialLegend r) |
||
140 | throws DriverException {
|
||
141 | XMLEntity xml = r.getXMLEntity(); |
||
142 | |||
143 | return xml;
|
||
144 | } |
||
145 | |||
146 | /**
|
||
147 | * Crea un renderer con la informaci?n contenida en el objeto XMLEntity
|
||
148 | *
|
||
149 | * @param xml XMLEntity.
|
||
150 | *
|
||
151 | * @return VectorialLegend
|
||
152 | *
|
||
153 | * @throws XMLException
|
||
154 | */
|
||
155 | public static VectorialLegend createFromXML(XMLEntity xml) |
||
156 | throws XMLException {
|
||
157 | //TODO Implementar bien
|
||
158 | try {
|
||
159 | VectorialLegend vl = null;
|
||
160 | 1094 | vcaballero | Class clase = Class.forName(xml.getStringProperty("className")); |
161 | 1034 | vcaballero | vl = (VectorialLegend) clase.newInstance(); |
162 | vl.setXMLEntity(xml); |
||
163 | |||
164 | return vl;
|
||
165 | } catch (ClassNotFoundException e) { |
||
166 | 490 | fernando | throw new XMLException(e); |
167 | } catch (InstantiationException e) { |
||
168 | throw new XMLException(e); |
||
169 | } catch (IllegalAccessException e) { |
||
170 | throw new XMLException(e); |
||
171 | } |
||
172 | 1034 | vcaballero | } |
173 | 214 | fernando | |
174 | 1034 | vcaballero | /**
|
175 | * Clona la leyenda.
|
||
176 | *
|
||
177 | * @param l VectorialLegend a clonar.
|
||
178 | *
|
||
179 | * @return VectorialLegend cloando.
|
||
180 | *
|
||
181 | * @throws XMLException
|
||
182 | * @throws DriverException
|
||
183 | */
|
||
184 | public static VectorialLegend cloneLegend(VectorialLegend l) |
||
185 | throws XMLException, DriverException {
|
||
186 | return createFromXML(getXMLEntity(l));
|
||
187 | } |
||
188 | 214 | fernando | } |