svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / layout / fframes / FFrameLegend.java @ 3183
History | View | Annotate | Download (24.1 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; |
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 |
//////Se recorren los layers dibujando el s?mbolo y su nombre sobre el graphics
|
202 |
for (int i = 0; i < layers.getLayersCount(); i++) { |
203 |
FLayer layer = (FLayer) layers.getLayer(i); |
204 |
|
205 |
if (layer.isVisible()) {
|
206 |
if (layer instanceof FLayers) { |
207 |
n[0]++;
|
208 |
|
209 |
float sizefont = 0; |
210 |
double dX = 0; |
211 |
double dY = n[0] * h; |
212 |
double xl = (re.getX() + dX);
|
213 |
double yl = (re.getY() + dY);
|
214 |
|
215 |
if ((re.getHeight() / m_numLayers) < (re.getWidth() / 8)) { |
216 |
sizefont = (float) (re.getHeight() / m_numLayers);
|
217 |
} else {
|
218 |
sizefont = (float) (re.getWidth() / (m_max * 0.7)); |
219 |
} |
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 |
float sizefont = 0; |
237 |
|
238 |
if ((re.getHeight() / m_numLayers) < (re.getWidth() / 8)) { |
239 |
sizefont = (float) (re.getHeight() / m_numLayers);
|
240 |
} else {
|
241 |
sizefont = (float) (re.getWidth() / (m_max * 0.7)); |
242 |
} |
243 |
|
244 |
drawNameLegend(g, layer.getName(), re, sizefont, |
245 |
(xl - (re.getWidth() / 5)), yl, h, typeFont);
|
246 |
n[0]++;
|
247 |
|
248 |
for (int j = 0; j < cli.getValues().length; j++) { |
249 |
dY = n[0] * h;
|
250 |
|
251 |
xl = (re.getX() + dX); |
252 |
yl = (re.getY() + dY); |
253 |
|
254 |
String s = cli.getDescriptions()[j];
|
255 |
drawNameLegend(g, s, re, sizefont, xl, yl, h, |
256 |
typeFont); |
257 |
|
258 |
FSymbol fs2d = cli.getSymbols()[j]; |
259 |
drawSymbolLegend(g, re, xl, yl, fs2d, sizefont, |
260 |
((Classifiable) cO).getShapeType(), h); |
261 |
|
262 |
n[0]++;
|
263 |
} |
264 |
} else {
|
265 |
double dX = 0; |
266 |
double dY = n[0] * h; |
267 |
|
268 |
double xl = (re.getX() + dX);
|
269 |
double yl = (re.getY() + dY);
|
270 |
float sizefont = 0; |
271 |
|
272 |
if ((re.getHeight() / m_numLayers) < (re.getWidth() / 8)) { |
273 |
sizefont = (float) (re.getHeight() / m_numLayers);
|
274 |
} else {
|
275 |
sizefont = (float) (re.getWidth() / (m_max * 0.7)); |
276 |
} |
277 |
|
278 |
drawNameLegend(g, layer.getName(), re, sizefont, xl, |
279 |
yl, h, typeFont); |
280 |
|
281 |
FSymbol fs2d = ((Classifiable) cO).getLegend() |
282 |
.getDefaultSymbol(); |
283 |
|
284 |
drawSymbolLegend(g, re, xl, yl, fs2d, sizefont, |
285 |
((Classifiable) cO).getShapeType(), h); |
286 |
n[0]++;
|
287 |
} |
288 |
} |
289 |
} |
290 |
} |
291 |
} |
292 |
|
293 |
/**
|
294 |
* Dibuja sobre el graphics el nombre de la capa que se pasa como
|
295 |
* par?metro.
|
296 |
*
|
297 |
* @param g Graphics2D sobre el que dibujar.
|
298 |
* @param name Nombre de la capa.
|
299 |
* @param re Rect?ngulo a ocupar por el nombre.
|
300 |
* @param sizefont tama?o de la fuente.
|
301 |
* @param x Posici?n X.
|
302 |
* @param y Posici?n Y.
|
303 |
* @param h Altura.
|
304 |
* @param typeFont DOCUMENT ME!
|
305 |
*/
|
306 |
private void drawNameLegend(Graphics2D g, String name, Rectangle2D re, |
307 |
float sizefont, double x, double y, double h, int typeFont) { |
308 |
Font f = new Font("SansSerif", typeFont, (int) sizefont); |
309 |
g.setFont(f); |
310 |
g.setColor(Color.black);
|
311 |
g.drawString(name, (float) (x + (re.getWidth() / 4)), |
312 |
(float) (y + (h / 2))); |
313 |
} |
314 |
|
315 |
/**
|
316 |
* A?ade al Layout un nuevo FFrameText a partir de los par?metros de
|
317 |
* entrada.
|
318 |
*
|
319 |
* @param layout Layout sobre el que se crea el nuevo FFrame.
|
320 |
* @param name Texto.
|
321 |
* @param re Rect?ngulo del FFrame.
|
322 |
* @param sizefont tama?o de la fuente.
|
323 |
* @param x Posici?n X.
|
324 |
* @param y Posici?n Y.
|
325 |
* @param h Altura.
|
326 |
*/
|
327 |
private void toFFrameText(Layout layout, String name, Rectangle2D re, |
328 |
float sizefont, double x, double y, double h) { |
329 |
double wl = (re.getWidth() / 1.5); |
330 |
double haux = (sizefont * 0.7); |
331 |
Rectangle2D rAux = new Rectangle2D.Double(x, y, wl, haux); |
332 |
FFrameText text = new FFrameText();
|
333 |
text.setFixedFontSize(true);
|
334 |
text.setFontSize((int) sizefont);
|
335 |
text.setBoundBox(FLayoutUtilities.toSheetRect(rAux, layout.getAT())); |
336 |
text.addText(name); |
337 |
layout.addFFrame(text, false, true); |
338 |
} |
339 |
|
340 |
/**
|
341 |
* Dibuja sobre el Graphics2D el s?mbolo.
|
342 |
*
|
343 |
* @param g Graphics2D.
|
344 |
* @param re Rect?ngulo a cubrir por el s?mbolo.
|
345 |
* @param x Posici?n X.
|
346 |
* @param y Posici?n Y.
|
347 |
* @param fs2d S?mbolo a dibujar.
|
348 |
* @param sizefont Tama?o de la fuente.
|
349 |
* @param type Tipo de s?mbolo.
|
350 |
* @param h Altura.
|
351 |
*/
|
352 |
private void drawSymbolLegend(Graphics2D g, Rectangle2D re, double x, |
353 |
double y, FSymbol fs2d, float sizefont, int type, double h) { |
354 |
double pW = 5; |
355 |
double wl = (re.getWidth() / pW);
|
356 |
double haux = (sizefont * 0.7); |
357 |
Font font = fs2d.getFont();
|
358 |
|
359 |
if (font != null) { |
360 |
fs2d.setFont(new Font(font.getFontName(), font.getStyle(), |
361 |
(int) (wl / 6))); |
362 |
} |
363 |
|
364 |
FGraphicUtilities.DrawSymbol(g, new AffineTransform(), |
365 |
new Rectangle((int) x, (int) ((y + (h / 2)) - haux), (int) wl, |
366 |
(int) haux), fs2d);
|
367 |
} |
368 |
|
369 |
/**
|
370 |
* A?ade al Layout un nuevo FFrameSymbol.
|
371 |
*
|
372 |
* @param layout Layout sobe el que se a?ade el FFrame.
|
373 |
* @param re Rect?ngulo del FFrame.
|
374 |
* @param x Posici?n X.
|
375 |
* @param y Posici?n Y.
|
376 |
* @param fs2d S?mbolo a a?adir.
|
377 |
* @param sizefont tama?o de la fuente.
|
378 |
* @param type Tipo de s?mbolo.
|
379 |
* @param h Altura.
|
380 |
*/
|
381 |
private void toFFrameSymbol(Layout layout, Rectangle2D re, double x, |
382 |
double y, FSymbol fs2d, float sizefont, int type, double h) { |
383 |
double pW = 5; |
384 |
double wl = (re.getWidth() / pW);
|
385 |
double haux = (sizefont * 0.7); |
386 |
Rectangle2D rAux3 = new Rectangle2D.Double(x, ((y + (h / 2)) - haux), |
387 |
wl, haux); |
388 |
FFrameSymbol symbol = new FFrameSymbol();
|
389 |
symbol.setBoundBox(FLayoutUtilities.toSheetRect(rAux3, layout.getAT())); |
390 |
symbol.setSymbol(fs2d, type); |
391 |
layout.addFFrame(symbol, false, true); |
392 |
} |
393 |
|
394 |
/**
|
395 |
* Devuelve el n?mero total de capas incluyendo las subcapas.
|
396 |
*
|
397 |
* @param layers Capa a contar.
|
398 |
*
|
399 |
* @return N?mero de capas y subcapas.
|
400 |
*/
|
401 |
private int getSizeNum(FLayers layers) { |
402 |
int n = 0; |
403 |
|
404 |
/////Aqu? hay que calcular cuantos layers y sublayers hay, para saber que distancias dejar entre uno y otro.
|
405 |
///y adem?s el tama?o de cada uno de ellos para saber que anchura dejar.
|
406 |
for (int i = 0; i < layers.getLayersCount(); i++) { |
407 |
FLayer layer = (FLayer) layers.getLayer(i); |
408 |
|
409 |
if (layer.isVisible()) {
|
410 |
if (layer.getName().length() > m_max) {
|
411 |
m_max = layer.getName().length(); |
412 |
} |
413 |
|
414 |
if (layer instanceof FLayers) { |
415 |
n = n + 3;
|
416 |
n += getSizeNum((FLayers) layer); //m_numLayers += getNumInLyrGroup((FLayers) layer);
|
417 |
} else if (layer instanceof AlphanumericData) { |
418 |
AlphanumericData cO = (AlphanumericData) layer; |
419 |
n++; |
420 |
|
421 |
if (((Classifiable) cO).getLegend() instanceof ClassifiedLegendInfo) { |
422 |
ClassifiedLegendInfo cli = (ClassifiedLegendInfo) ((Classifiable) cO).getLegend(); |
423 |
|
424 |
for (int j = 0; j < cli.getValues().length; j++) { |
425 |
String s = cli.getDescriptions()[j];
|
426 |
|
427 |
if (s.length() > m_max) {
|
428 |
m_max = s.length(); |
429 |
} |
430 |
|
431 |
n++; |
432 |
} |
433 |
} |
434 |
} |
435 |
} |
436 |
} |
437 |
|
438 |
return n;
|
439 |
} |
440 |
|
441 |
/**
|
442 |
* Transforma el FFrameLegend en diferentes FFrameSymbol y FFrameText.
|
443 |
*
|
444 |
* @param layout Layout sobre el que a?adir los FFrame nuevos y sobre el
|
445 |
* que elimnar el FFrameLegend anterior.
|
446 |
*/
|
447 |
public void toFFrames(Layout layout) { |
448 |
Rectangle2D rectangle = getBoundingBox(null); |
449 |
double h = rectangle.getHeight() / m_numLayers;
|
450 |
FLayers lays = layers; |
451 |
toFFrames(layout, lays, rectangle, h, 0);
|
452 |
layout.getFFrames().remove(this);
|
453 |
} |
454 |
|
455 |
/**
|
456 |
* Transforma el FFrameLegend en diferentes FFrameSymbol y FFrameText.
|
457 |
*
|
458 |
* @param layout Referencia al Layout.
|
459 |
* @param lays Layers a a?adir
|
460 |
* @param rectangle Rect?ngulo del FFrameLegend.
|
461 |
* @param h Altura
|
462 |
* @param n n?mero de Capa a?adida.
|
463 |
*
|
464 |
* @return n?mero de Capa a a?adir.
|
465 |
*/
|
466 |
public int toFFrames(Layout layout, FLayers lays, Rectangle2D rectangle, |
467 |
double h, int n) { |
468 |
////// Se recorren los layers dibujando el s?mbolo y su nombre sobre el graphics
|
469 |
for (int i = 0; i < lays.getLayersCount(); i++) { |
470 |
FLayer layer = (FLayer) lays.getLayer(i); |
471 |
|
472 |
if (layer.isVisible()) {
|
473 |
if (layer instanceof FLayers) { |
474 |
rectangle.setRect(rectangle.getX(), |
475 |
rectangle.getY() + (h * n), rectangle.getWidth(), |
476 |
rectangle.getHeight()); |
477 |
n += toFFrames(layout, lays, rectangle, h, n); //drawTheme(g, re, h, layers, n);
|
478 |
} else if (layer instanceof AlphanumericData) { |
479 |
AlphanumericData cO = (AlphanumericData) layer; |
480 |
|
481 |
if (((Classifiable) cO).getLegend() instanceof ClassifiedLegendInfo) { |
482 |
ClassifiedLegendInfo cli = (ClassifiedLegendInfo) ((Classifiable) cO).getLegend(); |
483 |
double dX = rectangle.getWidth() / 4; |
484 |
double dY = n * h;
|
485 |
|
486 |
double xl = (rectangle.getX() + dX);
|
487 |
double yl = (rectangle.getY() + dY);
|
488 |
float sizefont = 0; |
489 |
|
490 |
if ((rectangle.getHeight() / m_numLayers) < (rectangle.getWidth() / 8)) { |
491 |
sizefont = (float) (rectangle.getHeight() / m_numLayers);
|
492 |
} else {
|
493 |
sizefont = (float) (rectangle.getWidth() / 8); |
494 |
} |
495 |
|
496 |
toFFrameText(layout, layer.getName(), rectangle, |
497 |
sizefont, xl, yl + (h / 4), h);
|
498 |
n++; |
499 |
|
500 |
for (int j = 0; j < cli.getValues().length; j++) { |
501 |
dY = n * h; |
502 |
|
503 |
xl = (rectangle.getX() + dX); |
504 |
yl = (rectangle.getY() + dY); |
505 |
|
506 |
String s = cli.getDescriptions()[j];
|
507 |
toFFrameText(layout, s, rectangle, sizefont, xl, |
508 |
yl + (h / 4), h);
|
509 |
|
510 |
FSymbol fs2d = cli.getSymbols()[j]; |
511 |
|
512 |
try {
|
513 |
toFFrameSymbol(layout, rectangle, |
514 |
rectangle.getX(), yl, fs2d, sizefont, |
515 |
((Classifiable) cO).getShapeType(), h); |
516 |
} catch (DriverException e) {
|
517 |
e.printStackTrace(); |
518 |
} |
519 |
|
520 |
n++; |
521 |
} |
522 |
} else {
|
523 |
double dX = rectangle.getWidth() / 4; |
524 |
double dY = n * h;
|
525 |
|
526 |
double xl = (rectangle.getX() + dX);
|
527 |
double yl = (rectangle.getY() + dY);
|
528 |
float sizefont = 0; |
529 |
|
530 |
if ((rectangle.getHeight() / m_numLayers) < (rectangle.getWidth() / 8)) { |
531 |
sizefont = (float) (rectangle.getHeight() / m_numLayers);
|
532 |
} else {
|
533 |
sizefont = (float) (rectangle.getWidth() / 8); |
534 |
} |
535 |
|
536 |
toFFrameText(layout, layer.getName(), rectangle, |
537 |
sizefont, xl, yl + (h / 4), h);
|
538 |
|
539 |
FSymbol fs2d = ((Classifiable) cO).getLegend() |
540 |
.getDefaultSymbol(); |
541 |
|
542 |
try {
|
543 |
toFFrameSymbol(layout, rectangle, rectangle.getX(), |
544 |
yl, fs2d, sizefont, |
545 |
((Classifiable) cO).getShapeType(), h); |
546 |
} catch (DriverException e) {
|
547 |
e.printStackTrace(); |
548 |
} |
549 |
|
550 |
n++; |
551 |
} |
552 |
} |
553 |
} |
554 |
} |
555 |
|
556 |
return n;
|
557 |
} |
558 |
|
559 |
/**
|
560 |
* Rellena la fuente a utilizar al dibujar los String sobre el graphics.
|
561 |
*
|
562 |
* @param f Font.
|
563 |
*/
|
564 |
public void setFont(Font f) { |
565 |
m_f = f; |
566 |
} |
567 |
|
568 |
/**
|
569 |
* Devuelve la fuente que esta utilizando.
|
570 |
*
|
571 |
* @return Font.
|
572 |
*/
|
573 |
public Font getFont() { |
574 |
if (m_f != null) { |
575 |
return new Font(m_f.getFontName(), m_f.getStyle(), 9); |
576 |
} |
577 |
|
578 |
return null; |
579 |
} |
580 |
|
581 |
/**
|
582 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#getXMLEntity()
|
583 |
*/
|
584 |
public XMLEntity getXMLEntity() throws SaveException{ |
585 |
XMLEntity xml = new XMLEntity();
|
586 |
try{
|
587 |
xml.putProperty("className", this.getClass().getName()); |
588 |
xml.putProperty("m_name", m_name);
|
589 |
xml.putProperty("x", getBoundBox().x);
|
590 |
xml.putProperty("y", getBoundBox().y);
|
591 |
xml.putProperty("w", getBoundBox().width);
|
592 |
xml.putProperty("h", getBoundBox().height);
|
593 |
xml.putProperty("m_Selected", m_Selected);
|
594 |
xml.putProperty("type", Layout.RECTANGLELEGEND);
|
595 |
xml.putProperty("m_numLayers", m_numLayers);
|
596 |
xml.putProperty("m_max", m_max);
|
597 |
xml.putProperty("m_quality", m_quality);
|
598 |
xml.putProperty("m_viewing", m_viewing);
|
599 |
xml.putProperty("fontName", m_f.getFontName());
|
600 |
xml.putProperty("fontStyle", m_f.getStyle());
|
601 |
xml.putProperty("tag", getTag());
|
602 |
xml.putProperty("m_rotation", getRotation());
|
603 |
|
604 |
Layout layout = fframeview.getLayout(); |
605 |
IFFrame[] fframes = layout.getAllFFrames();
|
606 |
|
607 |
for (int i = 0; i < fframes.length; i++) { |
608 |
if ((fframeview != null) && |
609 |
fframeview.equals(fframes[i])) { |
610 |
xml.putProperty("index", i);
|
611 |
} |
612 |
} |
613 |
}catch (Exception e) { |
614 |
throw new SaveException(e,this.getClass().getName()); |
615 |
} |
616 |
return xml;
|
617 |
} |
618 |
|
619 |
/**
|
620 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#setXMLEntity(com.iver.utiles.XMLEntity,
|
621 |
* com.iver.cit.gvsig.project.Project)
|
622 |
*/
|
623 |
public void setXMLEntity03(XMLEntity xml, Layout l) { |
624 |
if (xml.getIntProperty("m_Selected") != 0) { |
625 |
this.setSelected(true); |
626 |
} else {
|
627 |
this.setSelected(false); |
628 |
} |
629 |
|
630 |
this.m_numLayers = xml.getIntProperty("m_numLayers"); |
631 |
this.m_max = xml.getIntProperty("m_max"); |
632 |
this.m_quality = xml.getIntProperty("m_quality"); |
633 |
this.m_viewing = xml.getIntProperty("m_viewing"); |
634 |
this.m_f = new Font(xml.getStringProperty("fontName"), |
635 |
xml.getIntProperty("fontStyle"), 9); |
636 |
|
637 |
ArrayList fframes = l.getFFrames();
|
638 |
fframeview = (FFrameView) fframes.get(xml.getIntProperty("index"));
|
639 |
} |
640 |
|
641 |
/**
|
642 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#setXMLEntity(com.iver.utiles.XMLEntity,
|
643 |
* com.iver.cit.gvsig.project.Project)
|
644 |
*/
|
645 |
public void setXMLEntity(XMLEntity xml) { |
646 |
if (xml.getIntProperty("m_Selected") != 0) { |
647 |
this.setSelected(true); |
648 |
} else {
|
649 |
this.setSelected(false); |
650 |
} |
651 |
|
652 |
this.m_numLayers = xml.getIntProperty("m_numLayers"); |
653 |
this.m_max = xml.getIntProperty("m_max"); |
654 |
this.m_quality = xml.getIntProperty("m_quality"); |
655 |
this.m_viewing = xml.getIntProperty("m_viewing"); |
656 |
this.m_f = new Font(xml.getStringProperty("fontName"), |
657 |
xml.getIntProperty("fontStyle"), 9); |
658 |
setRotation(xml.getDoubleProperty("m_rotation"));
|
659 |
|
660 |
if (xml.contains("index")) { |
661 |
dependenceIndex = xml.getIntProperty("index");
|
662 |
} |
663 |
} |
664 |
|
665 |
/**
|
666 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#getNameFFrame()
|
667 |
*/
|
668 |
public String getNameFFrame() { |
669 |
return PluginServices.getText(this, "leyenda") + num; |
670 |
} |
671 |
|
672 |
/**
|
673 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#print(java.awt.Graphics2D,
|
674 |
* java.awt.geom.AffineTransform)
|
675 |
*/
|
676 |
public void print(Graphics2D g, AffineTransform at) |
677 |
throws DriverException {
|
678 |
draw(g, at, null, null); |
679 |
} |
680 |
|
681 |
/**
|
682 |
* Actualiza las dependencias que tenga este FFrame con el resto.
|
683 |
*
|
684 |
* @param fframes Resto de FFrames.
|
685 |
*/
|
686 |
public void initDependence(IFFrame[] fframes) { |
687 |
fframeview = (FFrameView) fframes[dependenceIndex]; |
688 |
} |
689 |
} |