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