root / tags / Root_v061 / applications / appgvSIG / src / com / iver / cit / gvsig / gui / layout / fframes / FFrameLegend.java @ 4812
History | View | Annotate | Download (23.4 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.gui.layout.fframes; |
42 |
|
43 |
import com.iver.andami.PluginServices; |
44 |
|
45 |
import com.iver.cit.gvsig.fmap.DriverException; |
46 |
import com.iver.cit.gvsig.fmap.core.v02.FGraphicUtilities; |
47 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
48 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
49 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
50 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.AlphanumericData; |
51 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.Classifiable; |
52 |
import com.iver.cit.gvsig.fmap.rendering.ClassifiedLegendInfo; |
53 |
import com.iver.cit.gvsig.gui.layout.FLayoutUtilities; |
54 |
import com.iver.cit.gvsig.gui.layout.Layout; |
55 |
import com.iver.cit.gvsig.gui.project.SaveException; |
56 |
|
57 |
import com.iver.utiles.XMLEntity; |
58 |
|
59 |
import java.awt.Color; |
60 |
import java.awt.Font; |
61 |
import java.awt.Graphics2D; |
62 |
import java.awt.Rectangle; |
63 |
import java.awt.geom.AffineTransform; |
64 |
import java.awt.geom.Rectangle2D; |
65 |
import java.awt.image.BufferedImage; |
66 |
|
67 |
import java.util.ArrayList; |
68 |
|
69 |
|
70 |
/**
|
71 |
* FFrame para introducir una leyenda en el Layout.
|
72 |
*
|
73 |
* @author Vicente Caballero Navarro
|
74 |
*/
|
75 |
public class FFrameLegend extends FFrame implements IFFrameViewDependence { |
76 |
private static final int PRESENTACION = 0; |
77 |
private static final int BORRADOR = 1; |
78 |
private int m_quality = 0; |
79 |
private int m_viewing = 0; |
80 |
private Font m_f = new Font("Monospaced", Font.PLAIN, 9); |
81 |
private FFrameView fframeview = null; |
82 |
private int num = 0; |
83 |
private int m_max; |
84 |
private int m_numLayers; |
85 |
private FLayers layers = null; |
86 |
private int dependenceIndex=-1; |
87 |
|
88 |
/**
|
89 |
* Rellena la calidad que se quiere aplicar.
|
90 |
*
|
91 |
* @param q entero que representa la calidad a aplicar.
|
92 |
*/
|
93 |
public void setQuality(int q) { |
94 |
m_quality = q; |
95 |
} |
96 |
|
97 |
/**
|
98 |
* Devuelve un entero que representa la calidad que est? seleccionada.
|
99 |
*
|
100 |
* @return tipo de calidad selccionada.
|
101 |
*/
|
102 |
public int getQuality() { |
103 |
return m_quality;
|
104 |
} |
105 |
|
106 |
/**
|
107 |
* Devuelve un entero que representa la forma en que se actualiza la vista.
|
108 |
*
|
109 |
* @return forma que se actualiza la vista.
|
110 |
*/
|
111 |
public int getViewing() { |
112 |
return m_viewing;
|
113 |
} |
114 |
|
115 |
/**
|
116 |
* Inserta una FFrameView de donde se obtiene la informaci?n de las capas
|
117 |
* para generar la leyenda.
|
118 |
*
|
119 |
* @param f FFrameView para obtener los nombres de las capas.
|
120 |
*/
|
121 |
public void setFFrameDependence(IFFrame f) { |
122 |
fframeview = (FFrameView) f; |
123 |
} |
124 |
|
125 |
/**
|
126 |
* Devuelve el FFrameView utilizado para obtener la leyenda.
|
127 |
*
|
128 |
* @return FFrameView utilizado.
|
129 |
*/
|
130 |
public IFFrame getFFrameDependence() {
|
131 |
return fframeview;
|
132 |
} |
133 |
|
134 |
/**
|
135 |
* Rellena la forma de actualizar la vista.
|
136 |
*
|
137 |
* @param v entero que representa la forma de actualizar la vista.
|
138 |
*/
|
139 |
public void setViewing(int v) { |
140 |
m_viewing = v; |
141 |
} |
142 |
|
143 |
/**
|
144 |
* M?todo que dibuja sobre el graphics que se le pasa como par?metro, seg?n
|
145 |
* la transformada afin que se debe de aplicar y el rect?ngulo que se debe
|
146 |
* de dibujar.
|
147 |
*
|
148 |
* @param g Graphics
|
149 |
* @param at Transformada afin.
|
150 |
* @param rv rect?ngulo sobre el que hacer un clip.
|
151 |
* @param imgBase Imagen para acelerar el dibujado.
|
152 |
*
|
153 |
* @throws DriverException
|
154 |
*/
|
155 |
public void draw(Graphics2D g, AffineTransform at, Rectangle2D rv, |
156 |
BufferedImage imgBase) throws DriverException { |
157 |
Rectangle2D.Double re = getBoundingBox(at);
|
158 |
g.rotate(Math.toRadians(getRotation()), re.x + (re.width / 2), |
159 |
re.y + (re.height / 2));
|
160 |
|
161 |
if ((fframeview != null) && (fframeview.getFMap() != null)) { |
162 |
layers = fframeview.getFMap().getLayers(); |
163 |
} |
164 |
|
165 |
m_max = 0;
|
166 |
m_numLayers = 0;
|
167 |
|
168 |
if (intersects(rv, re)) {
|
169 |
if (layers == null) { //Si no se ha seleccionado ninguna vista para crear la leyenda. |
170 |
drawEmpty(g); |
171 |
} else if ((rv == null) || (getQuality() == PRESENTACION)) { |
172 |
m_numLayers = getSizeNum(layers); |
173 |
|
174 |
double h = re.getHeight() / m_numLayers;
|
175 |
int[] n = new int[1]; |
176 |
n[0] = 0; |
177 |
drawTheme(g, re, h, layers, n, Font.PLAIN);
|
178 |
} else if (getQuality() == BORRADOR) { //Si se selecciona la calidad BORRADOR. |
179 |
drawDraft(g); |
180 |
} |
181 |
} |
182 |
|
183 |
g.rotate(Math.toRadians(-getRotation()), re.x + (re.width / 2), |
184 |
re.y + (re.height / 2));
|
185 |
} |
186 |
|
187 |
/**
|
188 |
* Dibuja el nombre u s?mbolo de la capa que se pasa como par?metro.
|
189 |
*
|
190 |
* @param g Graphics2D sobre el que se dibuja.
|
191 |
* @param re Rectangle a rellenar.
|
192 |
* @param h Altura en pixels.
|
193 |
* @param layers Capa a representar.
|
194 |
* @param n ?ndice de la capa a dibujar.
|
195 |
* @param typeFont DOCUMENT ME!
|
196 |
*
|
197 |
* @throws DriverException
|
198 |
*/
|
199 |
private void drawTheme(Graphics2D g, Rectangle2D re, double h, |
200 |
FLayers layers, int[] n, int typeFont) throws DriverException { |
201 |
float sizefont = 0; |
202 |
|
203 |
if ((re.getHeight() / m_numLayers) < (re.getWidth() /(m_max * 0.7))) { |
204 |
sizefont = (float) (re.getHeight() / m_numLayers);
|
205 |
} else {
|
206 |
sizefont = (float) (re.getWidth() / (m_max * 0.7)); |
207 |
} |
208 |
//////Se recorren los layers dibujando el s?mbolo y su nombre sobre el graphics
|
209 |
for (int i = 0; i < layers.getLayersCount(); i++) { |
210 |
FLayer layer = (FLayer) layers.getLayer(i); |
211 |
|
212 |
if (layer.isVisible()) {
|
213 |
if (layer instanceof FLayers) { |
214 |
n[0]++;
|
215 |
|
216 |
double dX = 0; |
217 |
double dY = n[0] * h; |
218 |
double xl = (re.getX() + dX);
|
219 |
double yl = (re.getY() + dY);
|
220 |
|
221 |
drawNameLegend(g, layer.getName(), re, sizefont, |
222 |
(xl - (re.getWidth() / 5)), yl, h, Font.BOLD); |
223 |
n[0]++;
|
224 |
drawTheme(g, re, h, (FLayers) layer, n, Font.ITALIC);
|
225 |
n[0]++;
|
226 |
} else if (layer instanceof AlphanumericData) { |
227 |
AlphanumericData cO = (AlphanumericData) layer; |
228 |
|
229 |
if (((Classifiable) cO).getLegend() instanceof ClassifiedLegendInfo) { |
230 |
ClassifiedLegendInfo cli = (ClassifiedLegendInfo) ((Classifiable) cO).getLegend(); |
231 |
double dX = 0; |
232 |
double dY = n[0] * h; |
233 |
|
234 |
double xl = (re.getX() + dX);
|
235 |
double yl = (re.getY() + dY);
|
236 |
drawNameLegend(g, layer.getName(), re, sizefont, |
237 |
(xl - (re.getWidth() / 5)), yl, h, typeFont);
|
238 |
n[0]++;
|
239 |
|
240 |
for (int j = 0; j < cli.getValues().length; j++) { |
241 |
dY = n[0] * h;
|
242 |
|
243 |
xl = (re.getX() + dX); |
244 |
yl = (re.getY() + dY); |
245 |
|
246 |
String s = cli.getDescriptions()[j];
|
247 |
drawNameLegend(g, s, re, sizefont, xl, yl, h, |
248 |
typeFont); |
249 |
|
250 |
FSymbol fs2d = cli.getSymbols()[j]; |
251 |
drawSymbolLegend(g, re, xl, yl, fs2d, sizefont, |
252 |
((Classifiable) cO).getShapeType(), h); |
253 |
|
254 |
n[0]++;
|
255 |
} |
256 |
} else {
|
257 |
double dX = 0; |
258 |
double dY = n[0] * h; |
259 |
|
260 |
double xl = (re.getX() + dX);
|
261 |
double yl = (re.getY() + dY);
|
262 |
drawNameLegend(g, layer.getName(), re, sizefont, xl, |
263 |
yl, h, typeFont); |
264 |
|
265 |
FSymbol fs2d = ((Classifiable) cO).getLegend() |
266 |
.getDefaultSymbol(); |
267 |
|
268 |
drawSymbolLegend(g, re, xl, yl, fs2d, sizefont, |
269 |
((Classifiable) cO).getShapeType(), h); |
270 |
n[0]++;
|
271 |
} |
272 |
} |
273 |
} |
274 |
} |
275 |
} |
276 |
|
277 |
/**
|
278 |
* Dibuja sobre el graphics el nombre de la capa que se pasa como
|
279 |
* par?metro.
|
280 |
*
|
281 |
* @param g Graphics2D sobre el que dibujar.
|
282 |
* @param name Nombre de la capa.
|
283 |
* @param re Rect?ngulo a ocupar por el nombre.
|
284 |
* @param sizefont tama?o de la fuente.
|
285 |
* @param x Posici?n X.
|
286 |
* @param y Posici?n Y.
|
287 |
* @param h Altura.
|
288 |
* @param typeFont DOCUMENT ME!
|
289 |
*/
|
290 |
private void drawNameLegend(Graphics2D g, String name, Rectangle2D re, |
291 |
float sizefont, double x, double y, double h, int typeFont) { |
292 |
Font f = new Font("SansSerif", typeFont, (int) sizefont); |
293 |
g.setFont(f); |
294 |
g.setColor(Color.black);
|
295 |
g.drawString(name, (float) (x + (re.getWidth() / 4)), |
296 |
(float) (y + (h / 2))); |
297 |
} |
298 |
|
299 |
/**
|
300 |
* A?ade al Layout un nuevo FFrameText a partir de los par?metros de
|
301 |
* entrada.
|
302 |
*
|
303 |
* @param layout Layout sobre el que se crea el nuevo FFrame.
|
304 |
* @param name Texto.
|
305 |
* @param re Rect?ngulo del FFrame.
|
306 |
* @param sizefont tama?o de la fuente.
|
307 |
* @param x Posici?n X.
|
308 |
* @param y Posici?n Y.
|
309 |
* @param h Altura.
|
310 |
*/
|
311 |
private void toFFrameText(Layout layout, String name, double wT,double hT, |
312 |
float sizefont, double x, double y, double h) { |
313 |
double wl = (wT / 1.5); |
314 |
double haux = hT/(m_numLayers*1.3);//(sizefont * 0.7); |
315 |
if (haux>(wl/3)){ |
316 |
haux=wl/3;
|
317 |
} |
318 |
Rectangle2D rAux = new Rectangle2D.Double(x, ((y + (h / 2)) - haux), wl, haux); |
319 |
FFrameText text = new FFrameText();
|
320 |
text.setFixedFontSize(true);
|
321 |
text.setFontSize((int) sizefont);
|
322 |
text.setBoundBox(FLayoutUtilities.toSheetRect(rAux, layout.getAT())); |
323 |
text.addText(name); |
324 |
layout.addFFrame(text, false, true); |
325 |
} |
326 |
|
327 |
/**
|
328 |
* Dibuja sobre el Graphics2D el s?mbolo.
|
329 |
*
|
330 |
* @param g Graphics2D.
|
331 |
* @param re Rect?ngulo a cubrir por el s?mbolo.
|
332 |
* @param x Posici?n X.
|
333 |
* @param y Posici?n Y.
|
334 |
* @param fs2d S?mbolo a dibujar.
|
335 |
* @param sizefont Tama?o de la fuente.
|
336 |
* @param type Tipo de s?mbolo.
|
337 |
* @param h Altura.
|
338 |
*/
|
339 |
private void drawSymbolLegend(Graphics2D g, Rectangle2D re, double x, |
340 |
double y, FSymbol fs2d, float sizefont, int type, double h) { |
341 |
double pW = 5; |
342 |
double wl = (re.getWidth() / pW);
|
343 |
double haux = (sizefont * 0.7); |
344 |
Font font = fs2d.getFont();
|
345 |
|
346 |
if (font != null) { |
347 |
fs2d.setFont(new Font(font.getFontName(), font.getStyle(), |
348 |
(int) (wl / 6))); |
349 |
} |
350 |
|
351 |
FGraphicUtilities.DrawSymbol(g, new AffineTransform(), |
352 |
new Rectangle((int) x, (int) ((y + (h / 2)) - haux), (int) wl, |
353 |
(int) haux), fs2d);
|
354 |
} |
355 |
|
356 |
/**
|
357 |
* A?ade al Layout un nuevo FFrameSymbol.
|
358 |
*
|
359 |
* @param layout Layout sobe el que se a?ade el FFrame.
|
360 |
* @param re Rect?ngulo del FFrame.
|
361 |
* @param x Posici?n X.
|
362 |
* @param y Posici?n Y.
|
363 |
* @param fs2d S?mbolo a a?adir.
|
364 |
* @param sizefont tama?o de la fuente.
|
365 |
* @param type Tipo de s?mbolo.
|
366 |
* @param h Altura.
|
367 |
*/
|
368 |
private void toFFrameSymbol(Layout layout, double wT, double hT,double x, |
369 |
double y, FSymbol fs2d, int type, double h) { |
370 |
double pW = 5; |
371 |
double wl = (wT / pW);
|
372 |
double haux = hT/(m_numLayers*1.3);//(sizefont * 0.7); |
373 |
if (haux>(wT/4.5)){ |
374 |
haux=wT/4.5;
|
375 |
} |
376 |
Rectangle2D rAux3 = new Rectangle2D.Double(x, ((y + (h / 2)) - haux), |
377 |
wl, haux); |
378 |
FFrameSymbol symbol = new FFrameSymbol();
|
379 |
symbol.setBoundBox(FLayoutUtilities.toSheetRect(rAux3, layout.getAT())); |
380 |
symbol.setSymbol(fs2d, type); |
381 |
layout.addFFrame(symbol, false, true); |
382 |
} |
383 |
|
384 |
/**
|
385 |
* Devuelve el n?mero total de capas incluyendo las subcapas.
|
386 |
*
|
387 |
* @param layers Capa a contar.
|
388 |
*
|
389 |
* @return N?mero de capas y subcapas.
|
390 |
*/
|
391 |
private int getSizeNum(FLayers layers) { |
392 |
int n = 0; |
393 |
|
394 |
/////Aqu? hay que calcular cuantos layers y sublayers hay, para saber que distancias dejar entre uno y otro.
|
395 |
///y adem?s el tama?o de cada uno de ellos para saber que anchura dejar.
|
396 |
for (int i = 0; i < layers.getLayersCount(); i++) { |
397 |
FLayer layer = (FLayer) layers.getLayer(i); |
398 |
|
399 |
if (layer.isVisible()) {
|
400 |
if (layer.getName().length() > m_max) {
|
401 |
m_max = layer.getName().length(); |
402 |
} |
403 |
|
404 |
if (layer instanceof FLayers) { |
405 |
n = n + 3;
|
406 |
n += getSizeNum((FLayers) layer); //m_numLayers += getNumInLyrGroup((FLayers) layer);
|
407 |
} else if (layer instanceof AlphanumericData) { |
408 |
AlphanumericData cO = (AlphanumericData) layer; |
409 |
n++; |
410 |
|
411 |
if (((Classifiable) cO).getLegend() instanceof ClassifiedLegendInfo) { |
412 |
ClassifiedLegendInfo cli = (ClassifiedLegendInfo) ((Classifiable) cO).getLegend(); |
413 |
|
414 |
for (int j = 0; j < cli.getValues().length; j++) { |
415 |
String s = cli.getDescriptions()[j];
|
416 |
|
417 |
if (s.length() > m_max) {
|
418 |
m_max = s.length(); |
419 |
} |
420 |
|
421 |
n++; |
422 |
} |
423 |
} |
424 |
} |
425 |
} |
426 |
} |
427 |
|
428 |
return n;
|
429 |
} |
430 |
|
431 |
/**
|
432 |
* Transforma el FFrameLegend en diferentes FFrameSymbol y FFrameText.
|
433 |
*
|
434 |
* @param layout Layout sobre el que a?adir los FFrame nuevos y sobre el
|
435 |
* que elimnar el FFrameLegend anterior.
|
436 |
*/
|
437 |
public void toFFrames(Layout layout) { |
438 |
Rectangle2D rectangle = getBoundingBox(null); |
439 |
Rectangle2D r=getBoundBox();
|
440 |
double h = rectangle.getHeight() / m_numLayers;
|
441 |
FLayers lays = layers; |
442 |
toFFrames(layout, lays, rectangle,r.getWidth(),r.getHeight(), h, 0);
|
443 |
layout.getFFrames().remove(this);
|
444 |
} |
445 |
|
446 |
/**
|
447 |
* Transforma el FFrameLegend en diferentes FFrameSymbol y FFrameText.
|
448 |
*
|
449 |
* @param layout Referencia al Layout.
|
450 |
* @param lays Layers a a?adir
|
451 |
* @param rectangle Rect?ngulo del FFrameLegend.
|
452 |
* @param h Altura
|
453 |
* @param n n?mero de Capa a?adida.
|
454 |
*
|
455 |
* @return n?mero de Capa a a?adir.
|
456 |
*/
|
457 |
public int toFFrames(Layout layout, FLayers lays, Rectangle2D rectangle,double wT,double hT, |
458 |
double h, int n) { |
459 |
int N=39; |
460 |
float sizefont = 0; |
461 |
|
462 |
if ((rectangle.getHeight() / m_numLayers) < (wT*N / (m_max * 0.7))) { |
463 |
sizefont = (float) (hT*N / m_numLayers);
|
464 |
} else {
|
465 |
sizefont = (float) (wT*N /(m_max * 0.7)); |
466 |
} |
467 |
////// Se recorren los layers dibujando el s?mbolo y su nombre sobre el graphics
|
468 |
for (int i = 0; i < lays.getLayersCount(); i++) { |
469 |
FLayer layer = (FLayer) lays.getLayer(i); |
470 |
|
471 |
if (layer.isVisible()) {
|
472 |
if (layer instanceof FLayers) { |
473 |
rectangle.setRect(rectangle.getX(), |
474 |
rectangle.getY() + (h * n), rectangle.getWidth(), |
475 |
rectangle.getHeight()); |
476 |
n += toFFrames(layout, lays,rectangle, wT,hT, h, n); //drawTheme(g, re, h, layers, n);
|
477 |
} else if (layer instanceof AlphanumericData) { |
478 |
AlphanumericData cO = (AlphanumericData) layer; |
479 |
|
480 |
if (((Classifiable) cO).getLegend() instanceof ClassifiedLegendInfo) { |
481 |
ClassifiedLegendInfo cli = (ClassifiedLegendInfo) ((Classifiable) cO).getLegend(); |
482 |
double dX = rectangle.getWidth() / 4; |
483 |
double dY = n * h;
|
484 |
|
485 |
double xl = (rectangle.getX() + dX);
|
486 |
double yl = (rectangle.getY() + dY);
|
487 |
toFFrameText(layout, layer.getName(), rectangle.getWidth(),rectangle.getHeight(), |
488 |
sizefont, xl, yl, h); |
489 |
n++; |
490 |
|
491 |
for (int j = 0; j < cli.getValues().length; j++) { |
492 |
dY = n * h; |
493 |
|
494 |
xl = (rectangle.getX() + dX); |
495 |
yl = (rectangle.getY() + dY); |
496 |
|
497 |
String s = cli.getDescriptions()[j];
|
498 |
toFFrameText(layout, s, rectangle.getWidth(),rectangle.getHeight(),sizefont, xl, |
499 |
yl, h); |
500 |
|
501 |
FSymbol fs2d = cli.getSymbols()[j]; |
502 |
|
503 |
try {
|
504 |
toFFrameSymbol(layout, rectangle.getWidth(),rectangle.getHeight(), |
505 |
rectangle.getX(), yl, fs2d, |
506 |
((Classifiable) cO).getShapeType(), h); |
507 |
} catch (DriverException e) {
|
508 |
e.printStackTrace(); |
509 |
} |
510 |
|
511 |
n++; |
512 |
} |
513 |
} else {
|
514 |
double dX = rectangle.getWidth() / 4; |
515 |
double dY = n * h;
|
516 |
|
517 |
double xl = (rectangle.getX() + dX);
|
518 |
double yl = (rectangle.getY() + dY);
|
519 |
|
520 |
toFFrameText(layout, layer.getName(), rectangle.getWidth(),rectangle.getHeight(), |
521 |
sizefont, xl, yl , h); |
522 |
|
523 |
FSymbol fs2d = ((Classifiable) cO).getLegend() |
524 |
.getDefaultSymbol(); |
525 |
|
526 |
try {
|
527 |
toFFrameSymbol(layout, rectangle.getWidth(),rectangle.getHeight(), rectangle.getX(), |
528 |
yl, fs2d, |
529 |
((Classifiable) cO).getShapeType(), h); |
530 |
} catch (DriverException e) {
|
531 |
e.printStackTrace(); |
532 |
} |
533 |
|
534 |
n++; |
535 |
} |
536 |
} |
537 |
} |
538 |
} |
539 |
|
540 |
return n;
|
541 |
} |
542 |
|
543 |
/**
|
544 |
* Rellena la fuente a utilizar al dibujar los String sobre el graphics.
|
545 |
*
|
546 |
* @param f Font.
|
547 |
*/
|
548 |
public void setFont(Font f) { |
549 |
m_f = f; |
550 |
} |
551 |
|
552 |
/**
|
553 |
* Devuelve la fuente que esta utilizando.
|
554 |
*
|
555 |
* @return Font.
|
556 |
*/
|
557 |
public Font getFont() { |
558 |
if (m_f != null) { |
559 |
return new Font(m_f.getFontName(), m_f.getStyle(), 9); |
560 |
} |
561 |
|
562 |
return null; |
563 |
} |
564 |
|
565 |
/**
|
566 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#getXMLEntity()
|
567 |
*/
|
568 |
public XMLEntity getXMLEntity() throws SaveException{ |
569 |
XMLEntity xml = new XMLEntity();
|
570 |
try{
|
571 |
xml.putProperty("className", this.getClass().getName()); |
572 |
xml.putProperty("m_name", m_name);
|
573 |
xml.putProperty("x", getBoundBox().x);
|
574 |
xml.putProperty("y", getBoundBox().y);
|
575 |
xml.putProperty("w", getBoundBox().width);
|
576 |
xml.putProperty("h", getBoundBox().height);
|
577 |
xml.putProperty("m_Selected", m_Selected);
|
578 |
xml.putProperty("type", Layout.RECTANGLELEGEND);
|
579 |
xml.putProperty("m_numLayers", m_numLayers);
|
580 |
xml.putProperty("m_max", m_max);
|
581 |
xml.putProperty("m_quality", m_quality);
|
582 |
xml.putProperty("m_viewing", m_viewing);
|
583 |
xml.putProperty("fontName", m_f.getFontName());
|
584 |
xml.putProperty("fontStyle", m_f.getStyle());
|
585 |
xml.putProperty("tag", getTag());
|
586 |
xml.putProperty("m_rotation", getRotation());
|
587 |
|
588 |
if (fframeview != null){ |
589 |
Layout layout = fframeview.getLayout(); |
590 |
IFFrame[] fframes = layout.getAllFFrames();
|
591 |
|
592 |
for (int i = 0; i < fframes.length; i++) { |
593 |
if (fframeview.equals(fframes[i])) {
|
594 |
xml.putProperty("index", i);
|
595 |
} |
596 |
} |
597 |
} |
598 |
}catch (Exception e) { |
599 |
throw new SaveException(e,this.getClass().getName()); |
600 |
} |
601 |
return xml;
|
602 |
} |
603 |
|
604 |
/**
|
605 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#setXMLEntity(com.iver.utiles.XMLEntity,
|
606 |
* com.iver.cit.gvsig.project.Project)
|
607 |
*/
|
608 |
public void setXMLEntity03(XMLEntity xml, Layout l) { |
609 |
if (xml.getIntProperty("m_Selected") != 0) { |
610 |
this.setSelected(true); |
611 |
} else {
|
612 |
this.setSelected(false); |
613 |
} |
614 |
|
615 |
this.m_numLayers = xml.getIntProperty("m_numLayers"); |
616 |
this.m_max = xml.getIntProperty("m_max"); |
617 |
this.m_quality = xml.getIntProperty("m_quality"); |
618 |
this.m_viewing = xml.getIntProperty("m_viewing"); |
619 |
this.m_f = new Font(xml.getStringProperty("fontName"), |
620 |
xml.getIntProperty("fontStyle"), 9); |
621 |
|
622 |
ArrayList fframes = l.getFFrames();
|
623 |
fframeview = (FFrameView) fframes.get(xml.getIntProperty("index"));
|
624 |
} |
625 |
|
626 |
/**
|
627 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#setXMLEntity(com.iver.utiles.XMLEntity,
|
628 |
* com.iver.cit.gvsig.project.Project)
|
629 |
*/
|
630 |
public void setXMLEntity(XMLEntity xml) { |
631 |
if (xml.getIntProperty("m_Selected") != 0) { |
632 |
this.setSelected(true); |
633 |
} else {
|
634 |
this.setSelected(false); |
635 |
} |
636 |
|
637 |
this.m_numLayers = xml.getIntProperty("m_numLayers"); |
638 |
this.m_max = xml.getIntProperty("m_max"); |
639 |
this.m_quality = xml.getIntProperty("m_quality"); |
640 |
this.m_viewing = xml.getIntProperty("m_viewing"); |
641 |
this.m_f = new Font(xml.getStringProperty("fontName"), |
642 |
xml.getIntProperty("fontStyle"), 9); |
643 |
setRotation(xml.getDoubleProperty("m_rotation"));
|
644 |
|
645 |
if (xml.contains("index")) { |
646 |
dependenceIndex = xml.getIntProperty("index");
|
647 |
} |
648 |
} |
649 |
|
650 |
/**
|
651 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#getNameFFrame()
|
652 |
*/
|
653 |
public String getNameFFrame() { |
654 |
return PluginServices.getText(this, "leyenda") + num; |
655 |
} |
656 |
|
657 |
/**
|
658 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#print(java.awt.Graphics2D,
|
659 |
* java.awt.geom.AffineTransform)
|
660 |
*/
|
661 |
public void print(Graphics2D g, AffineTransform at) |
662 |
throws DriverException {
|
663 |
draw(g, at, null, null); |
664 |
} |
665 |
|
666 |
/**
|
667 |
* Actualiza las dependencias que tenga este FFrame con el resto.
|
668 |
*
|
669 |
* @param fframes Resto de FFrames.
|
670 |
*/
|
671 |
public void initDependence(IFFrame[] fframes) { |
672 |
if (dependenceIndex!=-1 && fframes[dependenceIndex] instanceof FFrameView) |
673 |
fframeview = (FFrameView) fframes[dependenceIndex]; |
674 |
} |
675 |
|
676 |
public void initialize() { |
677 |
// TODO Auto-generated method stub
|
678 |
|
679 |
} |
680 |
} |