root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / layout / fframes / FFrameScaleBar.java @ 2970
History | View | Annotate | Download (36.6 KB)
1 | 312 | fernando | /*
|
---|---|---|---|
2 | * Created on 20-feb-2004
|
||
3 | *
|
||
4 | */
|
||
5 | 1103 | fjp | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
6 | *
|
||
7 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
8 | *
|
||
9 | * This program is free software; you can redistribute it and/or
|
||
10 | * modify it under the terms of the GNU General Public License
|
||
11 | * as published by the Free Software Foundation; either version 2
|
||
12 | * of the License, or (at your option) any later version.
|
||
13 | *
|
||
14 | * This program is distributed in the hope that it will be useful,
|
||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
17 | * GNU General Public License for more details.
|
||
18 | *
|
||
19 | * You should have received a copy of the GNU General Public License
|
||
20 | * along with this program; if not, write to the Free Software
|
||
21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
22 | *
|
||
23 | * For more information, contact:
|
||
24 | *
|
||
25 | * Generalitat Valenciana
|
||
26 | * Conselleria d'Infraestructures i Transport
|
||
27 | * Av. Blasco Ib??ez, 50
|
||
28 | * 46010 VALENCIA
|
||
29 | * SPAIN
|
||
30 | *
|
||
31 | * +34 963862235
|
||
32 | * gvsig@gva.es
|
||
33 | * www.gvsig.gva.es
|
||
34 | *
|
||
35 | * or
|
||
36 | *
|
||
37 | * IVER T.I. S.A
|
||
38 | * Salamanca 50
|
||
39 | * 46005 Valencia
|
||
40 | * Spain
|
||
41 | *
|
||
42 | * +34 963163400
|
||
43 | * dac@iver.es
|
||
44 | */
|
||
45 | 312 | fernando | package com.iver.cit.gvsig.gui.layout.fframes; |
46 | |||
47 | 2762 | caballero | import com.iver.andami.PluginServices; |
48 | |||
49 | import com.iver.cit.gvsig.LayoutControls; |
||
50 | import com.iver.cit.gvsig.fmap.DriverException; |
||
51 | import com.iver.cit.gvsig.fmap.FMap; |
||
52 | import com.iver.cit.gvsig.gui.layout.Attributes; |
||
53 | import com.iver.cit.gvsig.gui.layout.FLayoutUtilities; |
||
54 | import com.iver.cit.gvsig.gui.layout.Layout; |
||
55 | |||
56 | import com.iver.utiles.StringUtilities; |
||
57 | import com.iver.utiles.XMLEntity; |
||
58 | |||
59 | 1073 | vcaballero | import java.awt.BasicStroke; |
60 | import java.awt.Color; |
||
61 | import java.awt.Font; |
||
62 | import java.awt.Graphics; |
||
63 | import java.awt.Graphics2D; |
||
64 | import java.awt.geom.AffineTransform; |
||
65 | import java.awt.geom.Point2D; |
||
66 | import java.awt.geom.Rectangle2D; |
||
67 | import java.awt.image.BufferedImage; |
||
68 | 2762 | caballero | |
69 | 1073 | vcaballero | import java.util.ArrayList; |
70 | |||
71 | |||
72 | 312 | fernando | /**
|
73 | * FFrame para introducir una barra de escala en el Layout.
|
||
74 | *
|
||
75 | * @author Vicente Caballero Navarro
|
||
76 | */
|
||
77 | 2915 | caballero | public class FFrameScaleBar extends FFrame implements IFFrameViewDependence{ |
78 | 2762 | caballero | private static final int NUMERO = 0; |
79 | private static final int BARRA1 = 1; |
||
80 | private static final int BARRA2 = 2; |
||
81 | private static final int BARRA3 = 3; |
||
82 | private static final int BARRA4 = 4; |
||
83 | private double DIFDOWN = 1.5; |
||
84 | private double DIFL = 30; |
||
85 | private double DIFR = 30; |
||
86 | private double DIFUP = 10; |
||
87 | private boolean m_bIntervalSet = false; |
||
88 | private int m_style = NUMERO; |
||
89 | private int m_units = 1; //Metros |
||
90 | private int m_mapUnits = 1; //unidad de medida de la vista(Metros) |
||
91 | private long m_interval = 1; |
||
92 | private int m_numinterval = 3; |
||
93 | private int m_numleft = 2; |
||
94 | private double m_height = 0; |
||
95 | private FFrameView fframeview = null; |
||
96 | private double m_typeUnit = Attributes.CHANGE[1]; //METROS; |
||
97 | private String m_nameUnit = null; |
||
98 | private double m_numUnit = 0; |
||
99 | private double m_dif = 1; |
||
100 | private int m_hasleft = 0; |
||
101 | private Font m_f = new Font("SansSerif", Font.PLAIN, 9); |
||
102 | private Color barcolor = Color.black; |
||
103 | private Color textcolor = Color.black; |
||
104 | private boolean showNameUnits = true; |
||
105 | private boolean showDescription = false; |
||
106 | private boolean aboveName = false; |
||
107 | private boolean aboveIntervals = true; |
||
108 | private boolean aboveDescription = false; |
||
109 | private String description = ""; |
||
110 | 398 | vcaballero | |
111 | 2762 | caballero | /**
|
112 | * Creates a new FFrameScaleBar object.
|
||
113 | */
|
||
114 | public FFrameScaleBar() {
|
||
115 | } |
||
116 | 312 | fernando | |
117 | 2762 | caballero | /**
|
118 | * Inserta el FFrameView sobre el que obtener la escala gr?fica.
|
||
119 | *
|
||
120 | * @param f FFrameView sobre el que obtener la escala.
|
||
121 | */
|
||
122 | public void setFFrameView(FFrameView f) { |
||
123 | fframeview = f; |
||
124 | setMapUnits(f.getMapUnits()); |
||
125 | setHeight(f.getBoundBox().height); |
||
126 | description = "escala 1:" + String.valueOf(fframeview.getScale()); |
||
127 | } |
||
128 | 312 | fernando | |
129 | 2762 | caballero | /**
|
130 | * Devuelve el FFrameView que se representa con la escala.
|
||
131 | *
|
||
132 | * @return FFrameView a representar.
|
||
133 | */
|
||
134 | public FFrameView getFFrameView() {
|
||
135 | return fframeview;
|
||
136 | } |
||
137 | 312 | fernando | |
138 | 2762 | caballero | /**
|
139 | * Devuelve el FMap de la vista que se representa en la escala.
|
||
140 | *
|
||
141 | * @return FMap.
|
||
142 | */
|
||
143 | public FMap getFMap() {
|
||
144 | return fframeview.getFMap();
|
||
145 | } |
||
146 | 312 | fernando | |
147 | 2762 | caballero | /**
|
148 | * Rellenar el estilo de barra de escala que se elige.
|
||
149 | *
|
||
150 | * @param s entero que representa el tipo de barra seleccionada.
|
||
151 | */
|
||
152 | public void setStyle(int s) { |
||
153 | m_style = s; |
||
154 | } |
||
155 | 312 | fernando | |
156 | 2762 | caballero | /**
|
157 | * Devuelve el tipo de escala a dibujar.
|
||
158 | *
|
||
159 | * @return entero.
|
||
160 | */
|
||
161 | public int getStyle() { |
||
162 | return m_style;
|
||
163 | } |
||
164 | 312 | fernando | |
165 | 2762 | caballero | /**
|
166 | * Rellenar el tama?o de un intervalo.
|
||
167 | *
|
||
168 | * @param s tama?o de un intervalo.
|
||
169 | */
|
||
170 | public void setInterval(long s) { |
||
171 | m_interval = s; |
||
172 | 312 | fernando | |
173 | 2762 | caballero | if (m_numleft != 0) { |
174 | m_hasleft = 1;
|
||
175 | } |
||
176 | 312 | fernando | |
177 | 2762 | caballero | Rectangle2D.Double rect = getBoundBox();
|
178 | double difL = (rect.width / DIFL);
|
||
179 | double difR = (rect.width / DIFR);
|
||
180 | double n = (rect.width - difL - difR);
|
||
181 | m_numUnit = (m_interval * m_typeUnit) / getScaleView(); |
||
182 | m_numinterval = (int) (n / m_numUnit) - m_hasleft;
|
||
183 | m_dif = 1;
|
||
184 | } |
||
185 | 312 | fernando | |
186 | 2762 | caballero | /**
|
187 | * Devuelve el valor del intervalo.
|
||
188 | *
|
||
189 | * @return long.
|
||
190 | */
|
||
191 | public long obtainInterval() { |
||
192 | if (fframeview != null) { |
||
193 | Rectangle2D.Double rect = getBoundBox();
|
||
194 | 312 | fernando | |
195 | 2762 | caballero | if (m_numleft != 0) { |
196 | m_hasleft = 1;
|
||
197 | } |
||
198 | 312 | fernando | |
199 | 2762 | caballero | double difL = (rect.width / DIFL);
|
200 | double difR = (rect.width / DIFR);
|
||
201 | double n = (rect.width - difL - difR);
|
||
202 | m_numUnit = n / (m_numinterval + m_hasleft); |
||
203 | 312 | fernando | |
204 | 2762 | caballero | double scaleXunit = (m_numUnit * getScaleView()) / m_typeUnit;
|
205 | m_dif = getExact(scaleXunit); |
||
206 | m_numUnit = m_numUnit * m_dif; |
||
207 | m_interval = (long) (scaleXunit * m_dif);
|
||
208 | 312 | fernando | |
209 | 2762 | caballero | return m_interval;
|
210 | } |
||
211 | 312 | fernando | |
212 | 2762 | caballero | return 0; |
213 | } |
||
214 | 312 | fernando | |
215 | 2762 | caballero | /**
|
216 | * Rellenar el n?mero de intervalos.
|
||
217 | *
|
||
218 | * @param s n?mero de intervalos.
|
||
219 | */
|
||
220 | public void setNumInterval(int s) { |
||
221 | m_numinterval = s; |
||
222 | 312 | fernando | |
223 | 2762 | caballero | if (m_numleft != 0) { |
224 | m_hasleft = 1;
|
||
225 | } |
||
226 | 312 | fernando | |
227 | 2762 | caballero | Rectangle2D.Double rect = getBoundBox();
|
228 | double difL = (rect.width / DIFL);
|
||
229 | double difR = (rect.width / DIFR);
|
||
230 | double n = (rect.width - difL - difR);
|
||
231 | m_numUnit = n / (m_numinterval + m_hasleft); |
||
232 | 312 | fernando | |
233 | 2762 | caballero | double scaleXunit = (m_numUnit * getScaleView()) / m_typeUnit;
|
234 | m_dif = getExact(scaleXunit); |
||
235 | m_numUnit = m_numUnit * m_dif; |
||
236 | m_interval = (long) (scaleXunit * m_dif);
|
||
237 | } |
||
238 | 312 | fernando | |
239 | 2762 | caballero | /**
|
240 | * Devuelve el n?mero de intervalos por encima del cero.
|
||
241 | *
|
||
242 | * @return entero.
|
||
243 | */
|
||
244 | public int getNumInterval() { |
||
245 | return m_numinterval;
|
||
246 | } |
||
247 | 312 | fernando | |
248 | 2762 | caballero | /**
|
249 | * Rellenar el n?mero de intervalos a la izquierda del cero.
|
||
250 | *
|
||
251 | * @param s n?mero de intervalos a la izquierda.
|
||
252 | */
|
||
253 | public void setNumLeft(int s) { |
||
254 | m_numleft = s; |
||
255 | } |
||
256 | 312 | fernando | |
257 | 2762 | caballero | /**
|
258 | * Devuelve el n?mero de intervalos en los que se quiere particionar el
|
||
259 | * intervalo que se queda por debajo del cero.
|
||
260 | *
|
||
261 | * @return entero.
|
||
262 | */
|
||
263 | public int getNumLeft() { |
||
264 | return m_numleft;
|
||
265 | } |
||
266 | 312 | fernando | |
267 | 2762 | caballero | /**
|
268 | * Seleccionar ,a true, si se quiere o, a false, si no mantener los
|
||
269 | * intervalos.
|
||
270 | *
|
||
271 | * @param b boolean a true si se quiere mantener los intervalos.
|
||
272 | */
|
||
273 | public void setIntervalSet(boolean b) { |
||
274 | m_bIntervalSet = b; |
||
275 | } |
||
276 | 312 | fernando | |
277 | 2762 | caballero | /**
|
278 | * Seleccionar la unidad de medida a representar en la barra de escala.
|
||
279 | *
|
||
280 | * @param s entero que representa la unidad de medida que se selecciona.
|
||
281 | */
|
||
282 | public void setUnits(int s) { |
||
283 | m_units = s; |
||
284 | m_typeUnit = Attributes.CHANGE[s];
|
||
285 | m_nameUnit = Attributes.NAMES[s];
|
||
286 | } |
||
287 | 312 | fernando | |
288 | 2762 | caballero | /**
|
289 | * Devuelve un entero que representa el tipo de unidades que representamos.
|
||
290 | *
|
||
291 | * @return entero.
|
||
292 | */
|
||
293 | public int getUnits() { |
||
294 | return m_units;
|
||
295 | } |
||
296 | 312 | fernando | |
297 | 2762 | caballero | /**
|
298 | * Devuelve el long que representa el intervalo.
|
||
299 | *
|
||
300 | * @return Intervalo.
|
||
301 | */
|
||
302 | public long getInterval() { |
||
303 | return m_interval;
|
||
304 | } |
||
305 | 312 | fernando | |
306 | 2762 | caballero | /**
|
307 | * Rellenar el rect?ngulo de la vista sobre la que se obtiene la escala.
|
||
308 | *
|
||
309 | * @param d Rect?ngulo.
|
||
310 | */
|
||
311 | public void setHeight(double d) { |
||
312 | m_height = d; |
||
313 | } |
||
314 | 312 | fernando | |
315 | 2762 | caballero | /**
|
316 | * Rellena la unidad de medida en la que est? la vista.
|
||
317 | *
|
||
318 | * @param i entero que representa la unidad de medida de la vista.
|
||
319 | */
|
||
320 | public void setMapUnits(int i) { |
||
321 | m_mapUnits = i; |
||
322 | } |
||
323 | 312 | fernando | |
324 | 2762 | caballero | /**
|
325 | * Devuelve la escala de la vista seleccionada.
|
||
326 | *
|
||
327 | * @return la escala de la vista.
|
||
328 | */
|
||
329 | private long getScaleView() { |
||
330 | return fframeview.getScale();
|
||
331 | } |
||
332 | 312 | fernando | |
333 | 2762 | caballero | /**
|
334 | * M?todo que dibuja sobre el graphics que se le pasa como par?metro, seg?n
|
||
335 | * la transformada afin que se debe de aplicar y el rect?ngulo que se debe
|
||
336 | * de dibujar.
|
||
337 | *
|
||
338 | * @param g Graphics
|
||
339 | * @param at Transformada afin.
|
||
340 | * @param rv rect?ngulo sobre el que hacer un clip.
|
||
341 | * @param imgBase Image para acelerar el dibujado.
|
||
342 | */
|
||
343 | public void draw(Graphics2D g, AffineTransform at, Rectangle2D rv, |
||
344 | BufferedImage imgBase) {
|
||
345 | Rectangle2D.Double r = getBoundingBox(at);
|
||
346 | g.rotate(Math.toRadians(getRotation()), r.x + (r.width / 2), |
||
347 | r.y + (r.height / 2));
|
||
348 | 312 | fernando | |
349 | 2762 | caballero | if (intersects(rv, r)) {
|
350 | if ((fframeview == null) || (fframeview.getFMap() == null)) { |
||
351 | drawEmpty(g); |
||
352 | } else {
|
||
353 | switch (m_style) {
|
||
354 | case (NUMERO):
|
||
355 | 312 | fernando | |
356 | 2762 | caballero | double scalex = r.getWidth() / (8); |
357 | g.setColor(textcolor); |
||
358 | 312 | fernando | |
359 | 2762 | caballero | if (m_f != null) { |
360 | m_f = new Font(m_f.getFontName(), m_f.getStyle(), |
||
361 | (int) (scalex));
|
||
362 | g.setFont(m_f); |
||
363 | } |
||
364 | 312 | fernando | |
365 | 2762 | caballero | g.drawString(" 1:" + getScaleView(), (int) r.x, |
366 | (int) (r.y + (r.height / 2))); |
||
367 | 312 | fernando | |
368 | 2762 | caballero | break;
|
369 | 312 | fernando | |
370 | 2762 | caballero | case (BARRA1):
|
371 | case (BARRA2):
|
||
372 | case (BARRA3):
|
||
373 | case (BARRA4):
|
||
374 | drawBar(m_style, g, at); |
||
375 | 398 | vcaballero | |
376 | 2762 | caballero | break;
|
377 | } |
||
378 | } |
||
379 | } |
||
380 | 398 | vcaballero | |
381 | 2762 | caballero | g.rotate(Math.toRadians(-getRotation()), r.x + (r.width / 2), |
382 | r.y + (r.height / 2));
|
||
383 | } |
||
384 | 398 | vcaballero | |
385 | 2762 | caballero | /**
|
386 | * Rellena con el rect?ngulo que se pasa como par?metro el boundBox(en
|
||
387 | * cent?metros) del fframe del cual con una transformaci?n se podr?
|
||
388 | * calcular el BoundingBox (en pixels).
|
||
389 | *
|
||
390 | * @param r Rect?ngulo en cent?metros.
|
||
391 | */
|
||
392 | public void setBoundBox(Rectangle2D.Double r) { |
||
393 | if ((m_numUnit < 1) || (fframeview == null) || |
||
394 | (fframeview.getFMap() == null)) {
|
||
395 | super.setBoundBox(r);
|
||
396 | 312 | fernando | |
397 | 2762 | caballero | return;
|
398 | } |
||
399 | 312 | fernando | |
400 | 2762 | caballero | double difL = (r.width / DIFL);
|
401 | double difR = (r.width / DIFR);
|
||
402 | 312 | fernando | |
403 | 2762 | caballero | if (m_bIntervalSet) {
|
404 | m_numinterval = (int) (((r.width - (difL + difR)) * m_dif) / m_numUnit) -
|
||
405 | m_hasleft; |
||
406 | } |
||
407 | 312 | fernando | |
408 | 2762 | caballero | if (m_numinterval < 1) { |
409 | m_numinterval = 1;
|
||
410 | r.width = ((m_numinterval + m_hasleft) * m_numUnit) + difL + difR; |
||
411 | } |
||
412 | 312 | fernando | |
413 | 2762 | caballero | getBoundBox().setRect(r.getX(), r.getY(), r.getWidth(), r.getHeight()); |
414 | } |
||
415 | 312 | fernando | |
416 | 2762 | caballero | /**
|
417 | * Dibuja sobre el Graphics la escala gr?fica.
|
||
418 | *
|
||
419 | * @param type Tipo de barra.
|
||
420 | * @param g Graphics sobre el que dibujar.
|
||
421 | * @param at Matriz de transformaci?n.
|
||
422 | */
|
||
423 | private void drawBar(int type, Graphics2D g, AffineTransform at) { |
||
424 | Rectangle2D.Double rect = getBoundBox();
|
||
425 | Rectangle2D.Double r = getBoundingBox(at);
|
||
426 | double numleft = m_numleft;
|
||
427 | initDistances(); |
||
428 | 312 | fernando | |
429 | 2762 | caballero | double difDown = (rect.height / DIFDOWN);
|
430 | double difUp = (rect.height / DIFUP);
|
||
431 | double difL = (rect.width / DIFL);
|
||
432 | double difR = (rect.width / DIFR);
|
||
433 | double n = (rect.width - difL - difR);
|
||
434 | 312 | fernando | |
435 | 2762 | caballero | setDescripcion("escala 1:" + String.valueOf(fframeview.getScale())); |
436 | g.setStroke(new BasicStroke(0)); |
||
437 | 312 | fernando | |
438 | 2762 | caballero | if (!m_bIntervalSet) {
|
439 | m_numUnit = n / (m_numinterval + m_hasleft); |
||
440 | 398 | vcaballero | |
441 | 2762 | caballero | double scaleXunit = (m_numUnit * getScaleView()) / m_typeUnit;
|
442 | m_dif = getExact(scaleXunit); |
||
443 | m_numUnit = m_numUnit * m_dif; |
||
444 | m_interval = (long) (scaleXunit * m_dif);
|
||
445 | } |
||
446 | 398 | vcaballero | |
447 | 2762 | caballero | if (m_bIntervalSet) {
|
448 | m_numUnit = (m_interval * m_typeUnit) / (m_dif * getScaleView()); |
||
449 | m_numinterval = (int) (((rect.width - (difL + difR)) * m_dif) / m_numUnit) -
|
||
450 | m_hasleft; |
||
451 | } |
||
452 | 312 | fernando | |
453 | 2762 | caballero | if (m_numinterval < 1) { |
454 | m_numinterval = 1;
|
||
455 | rect.width = ((m_numinterval + m_hasleft) * m_numUnit) + difL + |
||
456 | difR; |
||
457 | } |
||
458 | 312 | fernando | |
459 | 2762 | caballero | double h = 0; |
460 | 312 | fernando | |
461 | 2762 | caballero | if (type == BARRA1) {
|
462 | h = (rect.height - (difUp + difDown)); |
||
463 | } else if ((type == BARRA2) || (type == BARRA3)) { |
||
464 | h = (rect.height - (difUp + difDown)) / 2;
|
||
465 | } |
||
466 | 312 | fernando | |
467 | 2762 | caballero | //Dibujar el rect?ngulo que bordea todo.
|
468 | Rectangle2D.Double rectotal = (FLayoutUtilities.fromSheetRect(new Rectangle2D.Double((rect.x + |
||
469 | difL), (rect.y + difUp), |
||
470 | m_numUnit * (m_hasleft + m_numinterval), h), at)); |
||
471 | g.setColor(Color.white);
|
||
472 | g.fillRect((int) rectotal.x, (int) rectotal.y, (int) (rectotal.width), |
||
473 | (int) rectotal.height);
|
||
474 | g.setColor(barcolor); |
||
475 | 312 | fernando | |
476 | 2762 | caballero | if (m_f != null) { |
477 | m_f = new Font(m_f.getFontName(), m_f.getStyle(), |
||
478 | (int) (r.getHeight() / 4)); |
||
479 | } else {
|
||
480 | m_f = new Font("SansSerif", Font.PLAIN, (int) (r.getHeight() / 4)); |
||
481 | } |
||
482 | 312 | fernando | |
483 | 2762 | caballero | g.setFont(m_f); |
484 | 312 | fernando | |
485 | 2762 | caballero | //Derecha del cero
|
486 | for (int i = 0; i < m_numinterval; i++) { |
||
487 | Rectangle2D.Double recder = FLayoutUtilities.fromSheetRect(new Rectangle2D.Double((rect.x + |
||
488 | (difL) + ((m_numUnit * i) + (m_hasleft * m_numUnit))), |
||
489 | (rect.y + (difUp)), (m_numUnit), |
||
490 | (rect.height - (difUp + difDown)) / 2), at);
|
||
491 | Rectangle2D.Double recderB = FLayoutUtilities.fromSheetRect(new Rectangle2D.Double((rect.x + |
||
492 | (difL) + ((m_numUnit * i) + (m_hasleft * m_numUnit))), |
||
493 | (rect.y + difUp) + |
||
494 | ((rect.height - (difUp + difDown)) / 2), (m_numUnit),
|
||
495 | ((rect.height - (difUp + difDown)) / 2)), at);
|
||
496 | 398 | vcaballero | |
497 | 2762 | caballero | // Correcci?n cuando la altura en pixels del rect?ngulo es impar.
|
498 | rectotal.y = recder.y; |
||
499 | recderB.height = rectotal.height - recder.height + 0.5;
|
||
500 | 398 | vcaballero | |
501 | 2762 | caballero | /**
|
502 | * if (i == (m_numinterval - 1)) { if (recder.getMaxX() !=
|
||
503 | * rectotal.getMaxX()) { recder.width = (recder.width +
|
||
504 | * recder.getMaxX()) - rectotal.getMaxX(); } if (recderB.getMaxX()
|
||
505 | * != rectotal.getMaxX()) { recderB.width = (recderB.width +
|
||
506 | * recderB.getMaxX()) - rectotal.getMaxX(); }} if
|
||
507 | * (recderB.getMaxY() != rectotal.getMaxY()) { recderB.height =
|
||
508 | * (recderB.height + recderB.getMaxY()) - rectotal.getMaxY(); }
|
||
509 | */
|
||
510 | if ((m_numleft % 2) == 0) { |
||
511 | if ((i % 2) == 0) { |
||
512 | if ((type == BARRA1) || (type == BARRA2)) {
|
||
513 | fillRect(g, recder); |
||
514 | } else if (type == BARRA3) { |
||
515 | g.drawRect((int) recder.x, (int) recder.y, |
||
516 | (int) recder.width, (int) recder.height); |
||
517 | } |
||
518 | } else if (type == BARRA1) { |
||
519 | fillRect(g, recderB); |
||
520 | } |
||
521 | } else {
|
||
522 | if ((i % 2) != 0) { |
||
523 | if ((type == BARRA1) || (type == BARRA2)) {
|
||
524 | fillRect(g, recder); |
||
525 | } else if (type == BARRA3) { |
||
526 | g.drawRect((int) recderB.x, (int) recderB.y, |
||
527 | (int) recderB.width, (int) recderB.height); |
||
528 | } |
||
529 | } else if (type == BARRA1) { |
||
530 | fillRect(g, recderB); |
||
531 | } |
||
532 | } |
||
533 | 312 | fernando | |
534 | 2762 | caballero | long inter = (long) (m_interval * i); |
535 | Long l = new Long(inter); |
||
536 | 312 | fernando | |
537 | 2762 | caballero | int pos = ((int) (r.getHeight() / 4) * l.toString().length()) / 4; |
538 | 312 | fernando | |
539 | 2762 | caballero | Point2D.Double p = null; |
540 | 312 | fernando | |
541 | 2762 | caballero | if (isAboveIntervals()) {
|
542 | p = new Point2D.Double(recder.x - pos, |
||
543 | r.getMinY() + (r.getHeight() / DIFUP)); |
||
544 | } else {
|
||
545 | p = new Point2D.Double(recder.x - pos, |
||
546 | ((r.getHeight() / 4) + r.getMaxY()) -
|
||
547 | (r.getHeight() / DIFDOWN)); |
||
548 | } |
||
549 | 398 | vcaballero | |
550 | 2762 | caballero | drawInterval(g, inter, p); |
551 | } |
||
552 | 398 | vcaballero | |
553 | 2762 | caballero | //?ltimo n?mero a dibujar.
|
554 | long inter = (long) (m_interval * m_numinterval); |
||
555 | Long l = new Long(inter); |
||
556 | 312 | fernando | |
557 | 2762 | caballero | int pos = ((int) (r.getHeight() / 4) * l.toString().length()) / 4; |
558 | 398 | vcaballero | |
559 | 2762 | caballero | Point2D.Double p = null; |
560 | 312 | fernando | |
561 | 2762 | caballero | if (isAboveIntervals()) {
|
562 | p = new Point2D.Double(rectotal.getMaxX() - pos, |
||
563 | r.getMinY() + (r.getHeight() / DIFUP)); |
||
564 | } else {
|
||
565 | p = new Point2D.Double(rectotal.getMaxX() - pos, |
||
566 | ((r.getHeight() / 4) + r.getMaxY()) -
|
||
567 | (r.getHeight() / DIFDOWN)); |
||
568 | } |
||
569 | 312 | fernando | |
570 | 2762 | caballero | drawInterval(g, inter, p); |
571 | 312 | fernando | |
572 | 2762 | caballero | //Izquierda del cero
|
573 | for (int i = 0; i < m_numleft; i++) { |
||
574 | Rectangle2D.Double reciz = FLayoutUtilities.fromSheetRect(new Rectangle2D.Double((rect.x + |
||
575 | difL + ((m_numUnit / m_numleft) * i)), |
||
576 | (rect.y + difUp), (m_numUnit / numleft), |
||
577 | (rect.height - (difUp + difDown)) / 2), at);
|
||
578 | Rectangle2D.Double recizB = FLayoutUtilities.fromSheetRect(new Rectangle2D.Double((rect.x + |
||
579 | difL + ((m_numUnit / m_numleft) * i)), |
||
580 | (rect.y + difUp) + |
||
581 | ((rect.height - (difUp + difDown)) / 2),
|
||
582 | (m_numUnit / numleft), |
||
583 | ((rect.height - (difUp + difDown)) / 2)), at);
|
||
584 | 312 | fernando | |
585 | 2762 | caballero | //Correcci?n cuando la altura en pixels del rectangulo es impar.
|
586 | reciz.y = rectotal.y; |
||
587 | recizB.height = rectotal.height - reciz.height + 0.5;
|
||
588 | 312 | fernando | |
589 | 2762 | caballero | if ((i % 2) == 0) { |
590 | if ((type == BARRA1) || (type == BARRA2)) {
|
||
591 | fillRect(g, reciz); |
||
592 | } else if (type == BARRA3) { |
||
593 | g.drawRect((int) reciz.x, (int) reciz.y, (int) reciz.width, |
||
594 | (int) reciz.height);
|
||
595 | } |
||
596 | } else if (type == BARRA1) { |
||
597 | fillRect(g, recizB); |
||
598 | } |
||
599 | } |
||
600 | 312 | fernando | |
601 | 2762 | caballero | if (m_numleft > 0) { |
602 | inter = (long) (m_interval);
|
||
603 | l = new Long(inter); |
||
604 | 312 | fernando | |
605 | 2762 | caballero | pos = ((int) (r.getHeight() / 4) * l.toString().length()) / 4; |
606 | 312 | fernando | |
607 | 2762 | caballero | if (isAboveIntervals()) {
|
608 | p = new Point2D.Double(rectotal.x - pos, |
||
609 | r.getMinY() + (r.getHeight() / DIFUP)); |
||
610 | } else {
|
||
611 | p = new Point2D.Double(rectotal.x - pos, |
||
612 | ((r.getHeight() / 4) + r.getMaxY()) -
|
||
613 | (r.getHeight() / DIFDOWN)); |
||
614 | } |
||
615 | 398 | vcaballero | |
616 | 2762 | caballero | drawInterval(g, inter, p); |
617 | } |
||
618 | 398 | vcaballero | |
619 | 2762 | caballero | //En el caso de que se pida como n?mro de intervalos a la izquierda del 0, se reajusta el tama?o del rect?ngulo exterior de la escala gr?fica.
|
620 | if (m_numleft == 0) { |
||
621 | Rectangle2D.Double recAux = FLayoutUtilities.fromSheetRect(new Rectangle2D.Double((rect.x + |
||
622 | difL + ((m_numUnit / 1) * 0)), (rect.y + difUp), |
||
623 | (m_numUnit / 1), (rect.height - (difUp + difDown)) / 2), |
||
624 | at); |
||
625 | rectotal.x = rectotal.x + recAux.width; |
||
626 | rectotal.width = rectotal.width - recAux.width; |
||
627 | } |
||
628 | 398 | vcaballero | |
629 | 2762 | caballero | //Se dibuja el rect?ngulo que bordea toda la escala gr?fica.
|
630 | g.drawRect((int) rectotal.x, (int) rectotal.y, (int) (rectotal.width), |
||
631 | (int) rectotal.height);
|
||
632 | 398 | vcaballero | |
633 | 2762 | caballero | drawNameUnits(g, rect, at); |
634 | drawDescription(g, rect, at); |
||
635 | } |
||
636 | 398 | vcaballero | |
637 | 2762 | caballero | /**
|
638 | * Inicializa las distancias de la barra de escala.
|
||
639 | */
|
||
640 | private void initDistances() { |
||
641 | int numUp = 0; |
||
642 | int numDown = 0; |
||
643 | 398 | vcaballero | |
644 | 2762 | caballero | DIFDOWN = 30;
|
645 | DIFL = 40;
|
||
646 | DIFR = 40;
|
||
647 | DIFUP = 30;
|
||
648 | 398 | vcaballero | |
649 | 2762 | caballero | if (isAboveName()) {
|
650 | numUp++; |
||
651 | } else {
|
||
652 | numDown++; |
||
653 | } |
||
654 | 312 | fernando | |
655 | 2762 | caballero | if (isAboveIntervals()) {
|
656 | numUp++; |
||
657 | } else {
|
||
658 | numDown++; |
||
659 | } |
||
660 | 312 | fernando | |
661 | 2762 | caballero | if (isAboveDescription()) {
|
662 | numUp++; |
||
663 | } else {
|
||
664 | numDown++; |
||
665 | } |
||
666 | 312 | fernando | |
667 | 2762 | caballero | if (numDown == 1) { |
668 | DIFDOWN = 3;
|
||
669 | } else if (numDown == 2) { |
||
670 | DIFDOWN = 2;
|
||
671 | } else if (numDown == 3) { |
||
672 | DIFDOWN = 1.2;
|
||
673 | } |
||
674 | 312 | fernando | |
675 | 2762 | caballero | if (numUp == 1) { |
676 | DIFUP = 3;
|
||
677 | } else if (numUp == 2) { |
||
678 | DIFUP = 2;
|
||
679 | } else if (numUp == 3) { |
||
680 | DIFUP = 1.2;
|
||
681 | } |
||
682 | } |
||
683 | 312 | fernando | |
684 | 2762 | caballero | /**
|
685 | * Dibuja sobre el Graphics el nombre de la unidad de medida de la escala.
|
||
686 | *
|
||
687 | * @param g Graphics sobre el que se dibuja.
|
||
688 | * @param rec Rect?ngulo que ocupa la escala gr?fica.
|
||
689 | * @param at Matriz de transformaci?n.
|
||
690 | */
|
||
691 | private void drawNameUnits(Graphics g, Rectangle2D.Double rec, |
||
692 | AffineTransform at) {
|
||
693 | // Nombre de las unidades utilizadas.
|
||
694 | Point2D.Double p = null; |
||
695 | 312 | fernando | |
696 | 2762 | caballero | if (isShowNameUnits()) {
|
697 | if (isAboveName()) {
|
||
698 | p = new Point2D.Double(rec.getCenterX() - |
||
699 | ((rec.getHeight() * (m_nameUnit.length() / 6)) / 4), |
||
700 | (rec.getMinY() + (rec.getHeight() / (DIFUP))) - |
||
701 | (rec.getHeight() / 2));
|
||
702 | } else {
|
||
703 | p = new Point2D.Double(rec.getCenterX() - |
||
704 | ((rec.getHeight() * (m_nameUnit.length() / 6)) / 4), |
||
705 | (rec.getHeight() / 1.4) +
|
||
706 | (rec.getMaxY() - (rec.getHeight() / (DIFDOWN)))); |
||
707 | } |
||
708 | 312 | fernando | |
709 | 2762 | caballero | p = FLayoutUtilities.fromSheetPoint(p, at); |
710 | g.setColor(textcolor); |
||
711 | g.drawString(m_nameUnit, (int) p.x, (int) p.y); |
||
712 | } |
||
713 | } |
||
714 | 312 | fernando | |
715 | 2762 | caballero | /**
|
716 | * Dibuja sobre el Graphics la descripci?n que por defecto sera la escala.
|
||
717 | *
|
||
718 | * @param g Graphics sobre el que se dibuja.
|
||
719 | * @param rec Rect?ngulo que ocupa la escala gr?fica.
|
||
720 | * @param at Matriz de transformaci?n.
|
||
721 | */
|
||
722 | private void drawDescription(Graphics g, Rectangle2D.Double rec, |
||
723 | AffineTransform at) {
|
||
724 | Point2D.Double p = null; |
||
725 | 312 | fernando | |
726 | 2762 | caballero | if (isShowDescription()) {
|
727 | if (isAboveDescription()) {
|
||
728 | p = new Point2D.Double(rec.getCenterX() - |
||
729 | ((rec.getHeight() * (getDescripcion().length() / 6)) / 4), |
||
730 | (rec.getMinY() + (rec.getHeight() / (DIFUP))) - |
||
731 | (rec.getHeight() / 5));
|
||
732 | } else {
|
||
733 | p = new Point2D.Double(rec.getCenterX() - |
||
734 | ((rec.getHeight() * (getDescripcion().length() / 6)) / 4), |
||
735 | (rec.getHeight() / 2) +
|
||
736 | (rec.getMaxY() - (rec.getHeight() / (DIFDOWN)))); |
||
737 | } |
||
738 | 312 | fernando | |
739 | 2762 | caballero | p = FLayoutUtilities.fromSheetPoint(p, at); |
740 | g.setColor(textcolor); |
||
741 | g.drawString(getDescripcion(), (int) p.x, (int) p.y); |
||
742 | } |
||
743 | } |
||
744 | 312 | fernando | |
745 | 2762 | caballero | /**
|
746 | * Rellena la fuente utilizada para dibujar los intervalos y la unidad de
|
||
747 | * medida utilizada.
|
||
748 | *
|
||
749 | * @param f fuente a utilizar.
|
||
750 | */
|
||
751 | public void setFont(Font f) { |
||
752 | m_f = f; |
||
753 | } |
||
754 | 312 | fernando | |
755 | 2762 | caballero | /**
|
756 | * Devuelve la fuente con la que se est? dibujando sobre el graphics.
|
||
757 | *
|
||
758 | * @return fuente utilizada.
|
||
759 | */
|
||
760 | public Font getFont() { |
||
761 | return new Font(m_f.getFontName(), m_f.getStyle(), 9); |
||
762 | } |
||
763 | 398 | vcaballero | |
764 | 2762 | caballero | /**
|
765 | * Devuelve si el intervalo es variable o si por el contrario es fijo.
|
||
766 | *
|
||
767 | * @return true si el intervalo es fijo.
|
||
768 | */
|
||
769 | public boolean isbIntervalSet() { |
||
770 | return m_bIntervalSet;
|
||
771 | } |
||
772 | 312 | fernando | |
773 | 2762 | caballero | /**
|
774 | * Especificar si el intervalo se debe mantener o es variable.
|
||
775 | *
|
||
776 | * @param b si se quiere mantener el intervalo especificado.
|
||
777 | */
|
||
778 | public void setbIntervalSet(boolean b) { |
||
779 | m_bIntervalSet = b; |
||
780 | } |
||
781 | 312 | fernando | |
782 | 2762 | caballero | /**
|
783 | * Devuelve el porcentaje por el cual hay que multiplicar el intervalo
|
||
784 | * para conseguir un intervalo redondeado, de momento con una cifra
|
||
785 | * significativas(NUM=1).
|
||
786 | *
|
||
787 | * @param total intervalo.
|
||
788 | *
|
||
789 | * @return Porcentaje
|
||
790 | */
|
||
791 | private double getExact(double total) { |
||
792 | int NUM = 1; |
||
793 | double t = 0; |
||
794 | double dif = 1; |
||
795 | Double d = new Double(total); |
||
796 | Long l = new Long(d.longValue()); |
||
797 | int num = l.toString().length();
|
||
798 | t = ((long) (total / Math.pow(10, num - NUM)) * Math.pow(10, num - NUM)); |
||
799 | dif = t / total; |
||
800 | 312 | fernando | |
801 | 2762 | caballero | return dif;
|
802 | } |
||
803 | 312 | fernando | |
804 | 2762 | caballero | /**
|
805 | * Rellena un rect?ngulo.
|
||
806 | *
|
||
807 | * @param g Graphics sobre el que dibujar.
|
||
808 | * @param r Rect?ngulo a rellenar.
|
||
809 | */
|
||
810 | private void fillRect(Graphics2D g, Rectangle2D.Double r) { |
||
811 | g.fillRect((int) r.x, (int) r.y, (int) r.width, (int) r.height); |
||
812 | } |
||
813 | 312 | fernando | |
814 | 2762 | caballero | /**
|
815 | * Escribe sobre el Graphics y en la posici?n indicada el tama?o del
|
||
816 | * intervalo.
|
||
817 | *
|
||
818 | * @param g Graphics sobre el que dibujar.
|
||
819 | * @param inter Valor del intervalo.
|
||
820 | * @param p Punto donde dibujarlo.
|
||
821 | */
|
||
822 | private void drawInterval(Graphics2D g, long inter, Point2D.Double p) { |
||
823 | Long l = new Long(inter); |
||
824 | g.setColor(textcolor); |
||
825 | g.drawString(l.toString(), (int) p.x, (int) p.y); |
||
826 | g.setColor(barcolor); |
||
827 | } |
||
828 | 312 | fernando | |
829 | 2762 | caballero | /**
|
830 | * @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#getXMLEntity()
|
||
831 | */
|
||
832 | public XMLEntity getXMLEntity() {
|
||
833 | XMLEntity xml = new XMLEntity();
|
||
834 | xml.putProperty("className", this.getClass().getName()); |
||
835 | xml.putProperty("m_name", m_name);
|
||
836 | xml.putProperty("x", getBoundBox().x);
|
||
837 | xml.putProperty("y", getBoundBox().y);
|
||
838 | xml.putProperty("w", getBoundBox().width);
|
||
839 | xml.putProperty("h", getBoundBox().height);
|
||
840 | xml.putProperty("m_Selected", m_Selected);
|
||
841 | xml.putProperty("type", Layout.RECTANGLESCALEBAR);
|
||
842 | xml.putProperty("m_bIntervalSet", m_bIntervalSet);
|
||
843 | xml.putProperty("m_dif", m_dif);
|
||
844 | xml.putProperty("m_hasleft", m_hasleft);
|
||
845 | xml.putProperty("m_nameUnit", m_nameUnit);
|
||
846 | xml.putProperty("m_numUnit", m_numUnit);
|
||
847 | 398 | vcaballero | |
848 | 2762 | caballero | xml.putProperty("m_height", m_height);
|
849 | 398 | vcaballero | |
850 | 2762 | caballero | xml.putProperty("m_style", m_style);
|
851 | xml.putProperty("m_units", m_units);
|
||
852 | xml.putProperty("m_interval", m_interval);
|
||
853 | xml.putProperty("m_numinterval", m_numinterval);
|
||
854 | xml.putProperty("m_numleft", m_numleft);
|
||
855 | xml.putProperty("m_mapUnits", m_mapUnits);
|
||
856 | xml.putProperty("fontName", m_f.getFontName());
|
||
857 | xml.putProperty("fontStyle", m_f.getStyle());
|
||
858 | xml.putProperty("tag", getTag());
|
||
859 | xml.putProperty("m_rotation", getRotation());
|
||
860 | 398 | vcaballero | |
861 | 2762 | caballero | LayoutControls lc = (LayoutControls) PluginServices.getExtension(LayoutControls.class); |
862 | Layout layout = lc.getLayout(); |
||
863 | ArrayList fframes = layout.getFFrames();
|
||
864 | 398 | vcaballero | |
865 | 2762 | caballero | for (int i = 0; i < fframes.size(); i++) { |
866 | if (fframes.get(i) instanceof FFrameView) { |
||
867 | if ((fframeview != null) && |
||
868 | fframeview.getView().getName().equals(((FFrameView) fframes |
||
869 | .get(i)).getView() |
||
870 | .getName())) { |
||
871 | xml.putProperty("index", i);
|
||
872 | } |
||
873 | } |
||
874 | } |
||
875 | 398 | vcaballero | |
876 | 2762 | caballero | xml.putProperty("barcolor", StringUtilities.color2String(barcolor));
|
877 | xml.putProperty("textcolor", StringUtilities.color2String(textcolor));
|
||
878 | xml.putProperty("showNameUnits", showNameUnits);
|
||
879 | xml.putProperty("showDescription", showDescription);
|
||
880 | xml.putProperty("aboveName", aboveName);
|
||
881 | xml.putProperty("aboveIntervals", aboveIntervals);
|
||
882 | xml.putProperty("aboveDescription", aboveDescription);
|
||
883 | xml.putProperty("description", description);
|
||
884 | 398 | vcaballero | |
885 | 2762 | caballero | return xml;
|
886 | } |
||
887 | 1073 | vcaballero | |
888 | 2762 | caballero | /**
|
889 | * @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#setXMLEntity(com.iver.utiles.XMLEntity,
|
||
890 | * com.iver.cit.gvsig.project.Project)
|
||
891 | */
|
||
892 | public void setXMLEntity03(XMLEntity xml, Layout l) { |
||
893 | if (xml.getIntProperty("m_Selected") != 0) { |
||
894 | this.setSelected(true); |
||
895 | } else {
|
||
896 | this.setSelected(false); |
||
897 | } |
||
898 | 398 | vcaballero | |
899 | 2762 | caballero | this.m_bIntervalSet = xml.getBooleanProperty("m_bIntervalSet"); |
900 | this.m_dif = xml.getDoubleProperty("m_dif"); |
||
901 | this.m_hasleft = xml.getIntProperty("m_hasleft"); |
||
902 | this.m_nameUnit = xml.getStringProperty("m_nameUnit"); |
||
903 | this.m_numUnit = xml.getDoubleProperty("m_numUnit"); |
||
904 | 686 | vcaballero | |
905 | 2762 | caballero | this.m_height = xml.getDoubleProperty("m_height"); |
906 | 398 | vcaballero | |
907 | 2762 | caballero | this.m_style = xml.getIntProperty("m_style"); |
908 | this.m_interval = xml.getLongProperty("m_interval"); |
||
909 | this.m_numinterval = xml.getIntProperty("m_numinterval"); |
||
910 | this.m_numleft = xml.getIntProperty("m_numleft"); |
||
911 | this.m_mapUnits = xml.getIntProperty("m_mapUnits"); |
||
912 | this.m_f = new Font(xml.getStringProperty("fontName"), |
||
913 | xml.getIntProperty("fontStyle"), 9); |
||
914 | 398 | vcaballero | |
915 | 2762 | caballero | ArrayList fframes = l.getFFrames();
|
916 | fframeview = (FFrameView) fframes.get(xml.getIntProperty("index"));
|
||
917 | 649 | vcaballero | |
918 | 2762 | caballero | if (xml.contains("description")) { //Comprobar que es de la versi?n que cambia el di?logo. |
919 | this.barcolor = StringUtilities.string2Color(xml.getStringProperty(
|
||
920 | "barcolor"));
|
||
921 | this.textcolor = StringUtilities.string2Color(xml.getStringProperty(
|
||
922 | "textcolor"));
|
||
923 | this.showNameUnits = xml.getBooleanProperty("showNameUnits"); |
||
924 | this.showDescription = xml.getBooleanProperty("showDescription"); |
||
925 | this.aboveName = xml.getBooleanProperty("aboveName"); |
||
926 | this.aboveIntervals = xml.getBooleanProperty("aboveIntervals"); |
||
927 | this.aboveDescription = xml.getBooleanProperty("aboveDescription"); |
||
928 | this.description = xml.getStringProperty("description"); |
||
929 | } |
||
930 | } |
||
931 | 649 | vcaballero | |
932 | 2762 | caballero | /**
|
933 | * @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#setXMLEntity(com.iver.utiles.XMLEntity,
|
||
934 | * com.iver.cit.gvsig.project.Project)
|
||
935 | */
|
||
936 | public void setXMLEntity(XMLEntity xml, Layout l) { |
||
937 | if (xml.getIntProperty("m_Selected") != 0) { |
||
938 | this.setSelected(true); |
||
939 | } else {
|
||
940 | this.setSelected(false); |
||
941 | } |
||
942 | 649 | vcaballero | |
943 | 2762 | caballero | this.m_bIntervalSet = xml.getBooleanProperty("m_bIntervalSet"); |
944 | this.m_dif = xml.getDoubleProperty("m_dif"); |
||
945 | this.m_hasleft = xml.getIntProperty("m_hasleft"); |
||
946 | this.m_nameUnit = xml.getStringProperty("m_nameUnit"); |
||
947 | this.m_numUnit = xml.getDoubleProperty("m_numUnit"); |
||
948 | 649 | vcaballero | |
949 | 2762 | caballero | this.m_height = xml.getDoubleProperty("m_height"); |
950 | 1073 | vcaballero | |
951 | 2762 | caballero | this.m_style = xml.getIntProperty("m_style"); |
952 | this.m_interval = xml.getLongProperty("m_interval"); |
||
953 | this.m_numinterval = xml.getIntProperty("m_numinterval"); |
||
954 | this.m_numleft = xml.getIntProperty("m_numleft"); |
||
955 | this.m_mapUnits = xml.getIntProperty("m_mapUnits"); |
||
956 | this.m_f = new Font(xml.getStringProperty("fontName"), |
||
957 | xml.getIntProperty("fontStyle"), 9); |
||
958 | setRotation(xml.getDoubleProperty("m_rotation"));
|
||
959 | 649 | vcaballero | |
960 | 2762 | caballero | ArrayList fframes = l.getFFrames();
|
961 | 2183 | fernando | |
962 | 2762 | caballero | if (xml.contains("index")) { |
963 | fframeview = (FFrameView) fframes.get(xml.getIntProperty("index"));
|
||
964 | } |
||
965 | 2183 | fernando | |
966 | 2762 | caballero | if (xml.contains("description")) { //Comprobar que es de la versi?n que cambia el di?logo. |
967 | this.barcolor = StringUtilities.string2Color(xml.getStringProperty(
|
||
968 | "barcolor"));
|
||
969 | this.textcolor = StringUtilities.string2Color(xml.getStringProperty(
|
||
970 | "textcolor"));
|
||
971 | this.showNameUnits = xml.getBooleanProperty("showNameUnits"); |
||
972 | this.showDescription = xml.getBooleanProperty("showDescription"); |
||
973 | this.aboveName = xml.getBooleanProperty("aboveName"); |
||
974 | this.aboveIntervals = xml.getBooleanProperty("aboveIntervals"); |
||
975 | this.aboveDescription = xml.getBooleanProperty("aboveDescription"); |
||
976 | this.description = xml.getStringProperty("description"); |
||
977 | } |
||
978 | } |
||
979 | 2183 | fernando | |
980 | 2762 | caballero | /**
|
981 | * @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#getNameFFrame()
|
||
982 | */
|
||
983 | public String getNameFFrame() { |
||
984 | return PluginServices.getText(this, "escala") + num; |
||
985 | } |
||
986 | 2183 | fernando | |
987 | 2762 | caballero | /**
|
988 | * Inserta el color de la escala gr?fica.
|
||
989 | *
|
||
990 | * @param color Color de la escala gr?fica.
|
||
991 | */
|
||
992 | public void setBarColor(Color color) { |
||
993 | barcolor = color; |
||
994 | } |
||
995 | 649 | vcaballero | |
996 | 2762 | caballero | /**
|
997 | * Inserta el color del texto.
|
||
998 | *
|
||
999 | * @param color Color del texto.
|
||
1000 | */
|
||
1001 | public void setTextColor(Color color) { |
||
1002 | textcolor = color; |
||
1003 | } |
||
1004 | 649 | vcaballero | |
1005 | 2762 | caballero | /**
|
1006 | * Devuelve el color de la escala gr?fica.
|
||
1007 | *
|
||
1008 | * @return Color de la escala gr?fica.
|
||
1009 | */
|
||
1010 | public Color getBarColor() { |
||
1011 | return barcolor;
|
||
1012 | } |
||
1013 | 649 | vcaballero | |
1014 | 2762 | caballero | /**
|
1015 | * Devuelve el color del texto.
|
||
1016 | *
|
||
1017 | * @return Color del texto.
|
||
1018 | */
|
||
1019 | public Color getTextColor() { |
||
1020 | return textcolor;
|
||
1021 | } |
||
1022 | 649 | vcaballero | |
1023 | 2762 | caballero | /**
|
1024 | * Devuelve true si se debe mostrar el nombre de las unidades de medida de
|
||
1025 | * la escala gr?fica.
|
||
1026 | *
|
||
1027 | * @return True si se muestra las unidades de medida.
|
||
1028 | */
|
||
1029 | public boolean isShowNameUnits() { |
||
1030 | return showNameUnits;
|
||
1031 | } |
||
1032 | 649 | vcaballero | |
1033 | 2762 | caballero | /**
|
1034 | * Inserta si se debe de mostrar el nombre de las unidades de medida o no.
|
||
1035 | *
|
||
1036 | * @param showNameUnits True si se muestra el nombre de las unidades de
|
||
1037 | * medida.
|
||
1038 | */
|
||
1039 | public void setShowNameUnits(boolean showNameUnits) { |
||
1040 | this.showNameUnits = showNameUnits;
|
||
1041 | } |
||
1042 | 649 | vcaballero | |
1043 | 2762 | caballero | /**
|
1044 | * Devuelve true si se muestra la descripci?n a la parte de arriba de la
|
||
1045 | * escala gr?fica.
|
||
1046 | *
|
||
1047 | * @return True si se muestra arriba de la escala gr?fica.
|
||
1048 | */
|
||
1049 | public boolean isAboveDescription() { |
||
1050 | return aboveDescription;
|
||
1051 | } |
||
1052 | 649 | vcaballero | |
1053 | 2762 | caballero | /**
|
1054 | * Introduce true si se muestra arriba de la escala gr?fica la descripci?n.
|
||
1055 | *
|
||
1056 | * @param aboveDescription True si se muestra arriba la descripci?n.
|
||
1057 | */
|
||
1058 | public void setAboveDescription(boolean aboveDescription) { |
||
1059 | this.aboveDescription = aboveDescription;
|
||
1060 | } |
||
1061 | 649 | vcaballero | |
1062 | 2762 | caballero | /**
|
1063 | * Devuelve true si se muestran a la parte de arriba los valores de los
|
||
1064 | * intervalos.
|
||
1065 | *
|
||
1066 | * @return True si se muestran arriba de la escala gr?fica.
|
||
1067 | */
|
||
1068 | public boolean isAboveIntervals() { |
||
1069 | return aboveIntervals;
|
||
1070 | } |
||
1071 | 649 | vcaballero | |
1072 | 2762 | caballero | /**
|
1073 | * Inserta si se muestran los valores de los intervalos a la parte de
|
||
1074 | * arriba de la escala o debajo.
|
||
1075 | *
|
||
1076 | * @param aboveIntervals True si se muestran los valores de los intervalos
|
||
1077 | * a la parte de arriba de la escala gr?fica.
|
||
1078 | */
|
||
1079 | public void setAboveIntervals(boolean aboveIntervals) { |
||
1080 | this.aboveIntervals = aboveIntervals;
|
||
1081 | } |
||
1082 | 649 | vcaballero | |
1083 | 2762 | caballero | /**
|
1084 | * Devuelve si se muestra a la parte de arriba de la escala gr?fica el
|
||
1085 | * nombre de las unidades de medida o debajo.
|
||
1086 | *
|
||
1087 | * @return True si se muestra a la parte de arriba de la escala gr?fica.
|
||
1088 | */
|
||
1089 | public boolean isAboveName() { |
||
1090 | return aboveName;
|
||
1091 | } |
||
1092 | 649 | vcaballero | |
1093 | 2762 | caballero | /**
|
1094 | * Inserta si el nombre se muestra a la parte de arriba de la escala
|
||
1095 | * gr?fica o a la parte de abajo.
|
||
1096 | *
|
||
1097 | * @param aboveName True si se muestra a la parte de arriba de la escala
|
||
1098 | * gr?fica.
|
||
1099 | */
|
||
1100 | public void setAboveName(boolean aboveName) { |
||
1101 | this.aboveName = aboveName;
|
||
1102 | } |
||
1103 | 649 | vcaballero | |
1104 | 2762 | caballero | /**
|
1105 | * Devuelve si se debe mostrar la descripci?n o no.
|
||
1106 | *
|
||
1107 | * @return True si se muestra la descripci?n.
|
||
1108 | */
|
||
1109 | public boolean isShowDescription() { |
||
1110 | return showDescription;
|
||
1111 | } |
||
1112 | 649 | vcaballero | |
1113 | 2762 | caballero | /**
|
1114 | * Inserta si se muestra o no la descripci?n.
|
||
1115 | *
|
||
1116 | * @param showDescription True si se muestra la descripci?n.
|
||
1117 | */
|
||
1118 | public void setShowDescription(boolean showDescription) { |
||
1119 | this.showDescription = showDescription;
|
||
1120 | } |
||
1121 | 649 | vcaballero | |
1122 | 2762 | caballero | /**
|
1123 | * Devuelve la descripci?n de la escala.
|
||
1124 | *
|
||
1125 | * @return Descripci?n de la escala.
|
||
1126 | */
|
||
1127 | public String getDescripcion() { |
||
1128 | return description;
|
||
1129 | } |
||
1130 | 649 | vcaballero | |
1131 | 2762 | caballero | /**
|
1132 | * Inserta la descripci?n de la escala.
|
||
1133 | *
|
||
1134 | * @param descripcion Descripci?n de la escala.
|
||
1135 | */
|
||
1136 | public void setDescripcion(String descripcion) { |
||
1137 | this.description = descripcion;
|
||
1138 | } |
||
1139 | 649 | vcaballero | |
1140 | 2762 | caballero | /**
|
1141 | * @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#print(java.awt.Graphics2D,
|
||
1142 | * java.awt.geom.AffineTransform)
|
||
1143 | */
|
||
1144 | public void print(Graphics2D g, AffineTransform at) |
||
1145 | throws DriverException {
|
||
1146 | draw(g, at, null, null); |
||
1147 | } |
||
1148 | 312 | fernando | } |