svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / layout / fframes / FFrameText.java @ 4203
History | View | Annotate | Download (22 KB)
1 |
/*
|
---|---|
2 |
* Created on 22-jun-2004
|
3 |
*
|
4 |
*/
|
5 |
/* 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 |
package com.iver.cit.gvsig.gui.layout.fframes; |
46 |
|
47 |
import com.iver.andami.PluginServices; |
48 |
|
49 |
import com.iver.cit.gvsig.gui.layout.FLayoutUtilities; |
50 |
import com.iver.cit.gvsig.gui.layout.Layout; |
51 |
import com.iver.cit.gvsig.gui.project.SaveException; |
52 |
|
53 |
import com.iver.utiles.StringUtilities; |
54 |
import com.iver.utiles.XMLEntity; |
55 |
|
56 |
import java.awt.Color; |
57 |
import java.awt.Font; |
58 |
import java.awt.Graphics2D; |
59 |
import java.awt.font.FontRenderContext; |
60 |
import java.awt.font.TextLayout; |
61 |
import java.awt.geom.AffineTransform; |
62 |
import java.awt.geom.Rectangle2D; |
63 |
import java.awt.image.BufferedImage; |
64 |
|
65 |
import java.util.ArrayList; |
66 |
|
67 |
|
68 |
/**
|
69 |
* FFrame para introducir un texto en el Layout.
|
70 |
*
|
71 |
* @author Vicente Caballero Navarro
|
72 |
*/
|
73 |
public class FFrameText extends FFrame { |
74 |
/** Localizaci?n del texto. */
|
75 |
public static final int LEFT = 0; |
76 |
public static final int CENTER = 1; |
77 |
public static final int RIGTH = 2; |
78 |
private ArrayList m_text = new ArrayList(); |
79 |
private boolean m_isFixed = false; |
80 |
private int m_pos = LEFT; |
81 |
private Color textColor = Color.BLACK; |
82 |
|
83 |
//jaume
|
84 |
private boolean surrounded = false; // The text field is surrounded by a rectangle |
85 |
private double cellPadding = 0; // The gap between the the text field and the surrounding rectangle |
86 |
private boolean fixedFontSize = false; // The text field font size is constant fixed to the folio's size |
87 |
private int fontSize; // Text field's font size |
88 |
private boolean hasTitle; // The text field has title |
89 |
private String title; // The text for the title |
90 |
private int titleSize; // The title's font size |
91 |
private double frameBorderSize = 0; // The surrounding rectangle's border size |
92 |
private Color frameColor = Color.BLACK; // The surrounding rectangle's color |
93 |
private Color titleColor = Color.BLACK; // The title's color |
94 |
private Font m_f = null; |
95 |
private boolean transicionPixelsMilimetros = true; |
96 |
|
97 |
/**
|
98 |
* Crea un nuevo FFrameText.
|
99 |
*/
|
100 |
public FFrameText() {
|
101 |
m_f = new Font("SansSerif", Font.PLAIN, 9); |
102 |
} |
103 |
|
104 |
/**
|
105 |
* Inserta la fuente del texto.
|
106 |
*
|
107 |
* @param f Fuente del texto.
|
108 |
*/
|
109 |
public void setFont(Font f) { |
110 |
m_f = f; |
111 |
} |
112 |
|
113 |
/**
|
114 |
* Devuelve el color del texto del FFrameText.
|
115 |
*
|
116 |
* @return Color del texto.
|
117 |
*/
|
118 |
public Color getTextColor() { |
119 |
return textColor;
|
120 |
} |
121 |
|
122 |
/**
|
123 |
* Obtiene el fixedFontSize
|
124 |
*
|
125 |
* @return boolean
|
126 |
*/
|
127 |
public boolean isFontSizeFixed() { |
128 |
return fixedFontSize;
|
129 |
} |
130 |
|
131 |
/**
|
132 |
* Establece fixedFontSize
|
133 |
*
|
134 |
* @param fixedFontSize
|
135 |
*/
|
136 |
public void setFixedFontSize(boolean fixedFontSize) { |
137 |
this.fixedFontSize = fixedFontSize;
|
138 |
} |
139 |
|
140 |
/**
|
141 |
* Obtiene el fontSize
|
142 |
*
|
143 |
* @return int
|
144 |
*/
|
145 |
public int getFontSize() { |
146 |
return fontSize;
|
147 |
} |
148 |
|
149 |
/**
|
150 |
* Establece fontSize
|
151 |
*
|
152 |
* @param fontSize
|
153 |
*/
|
154 |
public void setFontSize(int fontSize) { |
155 |
this.fontSize = fontSize;
|
156 |
} |
157 |
|
158 |
/**
|
159 |
* Obtiene el cellPadding
|
160 |
*
|
161 |
* @return int
|
162 |
*/
|
163 |
public double getCellPadding() { |
164 |
return cellPadding;
|
165 |
} |
166 |
|
167 |
/**
|
168 |
* Inserta el color del texto a escribir.
|
169 |
*
|
170 |
* @param color Color del texto.
|
171 |
*/
|
172 |
public void setTextColor(Color color) { |
173 |
textColor = color; |
174 |
} |
175 |
|
176 |
/**
|
177 |
* Devuelve la fuente del texto.
|
178 |
*
|
179 |
* @return Fuente del texto.
|
180 |
*/
|
181 |
public Font getFont() { |
182 |
return new Font(m_f.getFontName(), m_f.getStyle(), 9); |
183 |
} |
184 |
|
185 |
/**
|
186 |
* Devuelve la posici?n izquierda, centro o derecha del texto.
|
187 |
*
|
188 |
* @return Posici?n del texto.
|
189 |
*/
|
190 |
public int getPos() { |
191 |
return m_pos;
|
192 |
} |
193 |
|
194 |
/**
|
195 |
* Pone la posici?n izquierda, centro o derecha del texto.
|
196 |
*
|
197 |
* @param p 0=LEFT,1=CENTER,2=RIGTH.
|
198 |
*/
|
199 |
public void setPos(int p) { |
200 |
m_pos = p; |
201 |
} |
202 |
|
203 |
/**
|
204 |
* M?todo que dibuja sobre el graphics que se le pasa como par?metro, seg?n
|
205 |
* la transformada afin que se debe de aplicar y el rect?ngulo que se debe
|
206 |
* de dibujar.
|
207 |
*
|
208 |
* @param g Graphics
|
209 |
* @param at Transformada af?n.
|
210 |
* @param rv rect?ngulo sobre el que hacer un clip.
|
211 |
* @param imgBase Imagen para acelerar el dibujado.
|
212 |
*/
|
213 |
public void draw(Graphics2D g, AffineTransform at, Rectangle2D rv, |
214 |
BufferedImage imgBase) {
|
215 |
g.setColor(Color.BLACK);
|
216 |
|
217 |
Rectangle2D.Double rec = getBoundingBox(at);
|
218 |
Rectangle2D.Double raux = (Rectangle2D.Double) rec.clone(); |
219 |
g.rotate(Math.toRadians(getRotation()), raux.x + (raux.width / 2), |
220 |
raux.y + (raux.height / 2));
|
221 |
|
222 |
int longmax = 1; |
223 |
|
224 |
if (intersects(rv, raux)) { // comprueba que no cae fuera de la pantalla |
225 |
|
226 |
if (m_text.isEmpty()) {
|
227 |
drawEmpty(g); |
228 |
} else {
|
229 |
for (int i = 0; i < m_text.size(); i++) { |
230 |
if (m_text.get(i) == null) { |
231 |
m_text.set(i, "<NULL>");
|
232 |
} |
233 |
|
234 |
if (((String) m_text.get(i)).length() > longmax) { |
235 |
longmax = ((String) m_text.get(i)).length();
|
236 |
} |
237 |
} |
238 |
|
239 |
FontRenderContext frc = g.getFontRenderContext();
|
240 |
int scaledFontSize;
|
241 |
|
242 |
// TODO myScale es la escala sobre la que se extraen todos los escalados. Esto
|
243 |
// funciona bien tal cual est? si la ratio de aspecto (alto/ancho) del folio es constante
|
244 |
// porque se toma como medidas el ancho del folio real y el ancho del folio en pantalla.
|
245 |
// No se que pasar? si la ratio cambia, por ejemplo si se usan USLetter en lugar de DIN A4
|
246 |
double myScale = at.getScaleX() * 0.0234; //FLayoutUtilities.fromSheetDistance(folio.getAncho(),at)/rv.getWidth(); |
247 |
|
248 |
// Distinguish when the font has fixed size or not
|
249 |
if (isFontSizeFixed()) {
|
250 |
scaledFontSize = (int) (myScale * fontSize);
|
251 |
} else {
|
252 |
scaledFontSize = ((int) (raux.width)) / longmax;
|
253 |
|
254 |
if (scaledFontSize > (int) ((raux.height) / m_text.size())) { |
255 |
scaledFontSize = (int) ((raux.height) / m_text.size());
|
256 |
} |
257 |
} |
258 |
|
259 |
if (m_f != null) { |
260 |
// Aqu? se ajusta a partir de las caracter?sticas de la fuente, una nueva fuente con el tama?o ajustado.
|
261 |
m_f = new Font(m_f.getFontName(), m_f.getStyle(), |
262 |
scaledFontSize); |
263 |
} else {
|
264 |
// Aqu? pasa cuando se abre el di?logo para seleccionar un tipo de fuente y se cierra sin haber seleccionado ninguna.
|
265 |
m_f = new Font("SansSerif", Font.PLAIN, scaledFontSize); |
266 |
} |
267 |
|
268 |
// Draw the text title if it exists
|
269 |
if (hasTitle()) {
|
270 |
int scaledTitleFontSize = (int) (myScale * titleSize); |
271 |
int gap = 3; |
272 |
|
273 |
if (isSurrounded()) {
|
274 |
// Para evitar que el marco se pinte sobre el t?tulo
|
275 |
gap += (int) (FLayoutUtilities.fromSheetDistance(frameBorderSize,
|
276 |
at) * myScale); |
277 |
} |
278 |
|
279 |
g.setColor(titleColor); |
280 |
|
281 |
Font titleFont = new Font(m_f.getFontName(), |
282 |
m_f.getStyle(), scaledTitleFontSize); |
283 |
|
284 |
if (!getTitle().equals("")) { |
285 |
TextLayout titleTextLayout = new TextLayout(getTitle(), |
286 |
titleFont, frc); |
287 |
titleTextLayout.draw(g, (float) raux.getX(),
|
288 |
(float) (raux.getY() - (gap * myScale)));
|
289 |
} |
290 |
} |
291 |
|
292 |
// Draw the frame involving the text if it exists
|
293 |
if (isSurrounded()) {
|
294 |
g.setColor(frameColor); |
295 |
g.drawRect((int) raux.x, (int) raux.y, (int) raux.width, |
296 |
(int) raux.height);
|
297 |
|
298 |
double scaledCellPadding = FLayoutUtilities.fromSheetDistance(cellPadding,
|
299 |
at) * myScale; |
300 |
int sizeBorder = (int) FLayoutUtilities.fromSheetDistance(frameBorderSize, |
301 |
at); |
302 |
|
303 |
if (sizeBorder > 1) { |
304 |
System.out.println("borderSize = " + sizeBorder); |
305 |
|
306 |
int scaledBorderSize = (int) (sizeBorder * myScale); |
307 |
|
308 |
for (int i = scaledBorderSize - 1; i > 0; i--) |
309 |
g.drawRect((int) raux.x - i, (int) raux.y - i, |
310 |
(int) raux.width + (2 * i), |
311 |
(int) raux.height + (2 * i)); |
312 |
} |
313 |
|
314 |
// Recalibro el rectangulo para establecer el ?rea donde se dibujan las fuentes
|
315 |
// al ?rea marcada con el rat?n menos la distancia al marco especificada
|
316 |
raux.setRect(raux.getX() + scaledCellPadding, |
317 |
raux.getY() + scaledCellPadding, |
318 |
raux.getWidth() - (scaledCellPadding * 2),
|
319 |
raux.getHeight() - (scaledCellPadding * 2));
|
320 |
} |
321 |
|
322 |
g.setColor(textColor); |
323 |
|
324 |
drawText(raux, scaledFontSize, g); |
325 |
g.rotate(Math.toRadians(-getRotation()),
|
326 |
raux.x + (raux.width / 2), raux.y + (raux.height / 2)); |
327 |
} |
328 |
} |
329 |
|
330 |
raux = null;
|
331 |
} |
332 |
|
333 |
/**
|
334 |
* Dibuja el texto sobre el graphics con el tama?o adecuado.
|
335 |
*
|
336 |
* @param r Rect?ngulo sobre el que dibujar.
|
337 |
* @param sfs Tama?o aproximado del texto.
|
338 |
* @param g Graphics sobre el que dibujar el texto.
|
339 |
*/
|
340 |
private void drawText(Rectangle2D r, int sfs, Graphics2D g) { |
341 |
int minSFS = Integer.MAX_VALUE; |
342 |
FontRenderContext frc = g.getFontRenderContext();
|
343 |
int ht = (int) (r.getHeight() / m_text.size()); |
344 |
|
345 |
if (isFontSizeFixed()) {
|
346 |
minSFS = sfs; |
347 |
} else {
|
348 |
for (int i = 0; i < m_text.size(); i++) { |
349 |
if (!((String) m_text.get(i)).equals("")) { |
350 |
TextLayout textaux = new TextLayout((String) m_text.get(i), |
351 |
m_f, frc); |
352 |
Rectangle2D txtBound = textaux.getBounds();
|
353 |
double difW = txtBound.getWidth() / r.getWidth();
|
354 |
double difH = (txtBound.getHeight() * m_text.size()) / (r.getHeight());
|
355 |
|
356 |
if (difW > difH) {
|
357 |
if (minSFS > sfs) {
|
358 |
minSFS = (int) (sfs / difW);
|
359 |
} |
360 |
} else {
|
361 |
if (minSFS > sfs) {
|
362 |
minSFS = (int) (sfs / difH);
|
363 |
} |
364 |
} |
365 |
} |
366 |
} |
367 |
} |
368 |
|
369 |
TextLayout textLayout = null; |
370 |
|
371 |
for (int i = 0; i < m_text.size(); i++) { |
372 |
if (!((String) m_text.get(i)).equals("")) { |
373 |
m_f = new Font(m_f.getFontName(), m_f.getStyle(), minSFS); |
374 |
|
375 |
textLayout = new TextLayout((String) m_text.get(i), m_f, frc); |
376 |
|
377 |
Rectangle2D txtBound = textLayout.getBounds();
|
378 |
float difW = (float) (r.getWidth() - txtBound.getWidth()); |
379 |
|
380 |
switch (m_pos) {
|
381 |
case (LEFT):
|
382 |
textLayout.draw(g, (float) r.getX(),
|
383 |
(float) (r.getY() + (ht * (i + 1)))); |
384 |
|
385 |
break;
|
386 |
|
387 |
case (CENTER):
|
388 |
textLayout.draw(g, (float) r.getX() + (difW / 2), |
389 |
(float) (r.getY() + (ht * (i + 1)))); |
390 |
|
391 |
break;
|
392 |
|
393 |
case (RIGTH):
|
394 |
textLayout.draw(g, (float) r.getX() + difW,
|
395 |
(float) (r.getY() + (ht * (i + 1)))); //- (ht / 2)))); |
396 |
|
397 |
break;
|
398 |
} |
399 |
} |
400 |
} |
401 |
} |
402 |
|
403 |
/**
|
404 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#print(java.awt.Graphics2D,
|
405 |
* java.awt.geom.AffineTransform)
|
406 |
*/
|
407 |
public void print(Graphics2D g, AffineTransform at) { |
408 |
draw(g, at, null, null); |
409 |
} |
410 |
|
411 |
/**
|
412 |
* Rellenar el texto que se quiere a?adir al Layout.
|
413 |
*
|
414 |
* @param s String a a?adir.
|
415 |
*/
|
416 |
public void addText(String s) { |
417 |
m_text.add(s); |
418 |
} |
419 |
|
420 |
/**
|
421 |
* Devuelve el ArrayList que contiene las l?neas de texto.
|
422 |
*
|
423 |
* @return ArrayList.
|
424 |
*/
|
425 |
public ArrayList getText() { |
426 |
return m_text;
|
427 |
} |
428 |
|
429 |
/**
|
430 |
* Seleccionar si se quiere un tama?o fijo o adecuado a la escala.
|
431 |
*
|
432 |
* @param b true si se quiere tama?o fijo.
|
433 |
*/
|
434 |
public void setSizeFixed(boolean b) { |
435 |
m_isFixed = b; |
436 |
} |
437 |
|
438 |
/**
|
439 |
* Devuelve si est? fijado el tama?o.
|
440 |
*
|
441 |
* @return True si est? fijado el tama?o.
|
442 |
*/
|
443 |
public boolean isSizeFixed() { |
444 |
return m_isFixed;
|
445 |
} |
446 |
|
447 |
/**
|
448 |
* DOCUMENT ME!
|
449 |
*
|
450 |
* @return DOCUMENT ME!
|
451 |
*
|
452 |
* @throws SaveException
|
453 |
*
|
454 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#getXMLEntity()
|
455 |
*/
|
456 |
public XMLEntity getXMLEntity() throws SaveException { |
457 |
XMLEntity xml = super.getXMLEntity();
|
458 |
|
459 |
try {
|
460 |
xml.putProperty("type", Layout.RECTANGLETEXT);
|
461 |
|
462 |
String[] s = (String[]) m_text.toArray(new String[0]); |
463 |
xml.putProperty("s", s);
|
464 |
xml.putProperty("m_isFixed", m_isFixed);
|
465 |
|
466 |
if (m_isFixed) {
|
467 |
xml.putProperty("fontSize", m_f.getSize());
|
468 |
} |
469 |
|
470 |
xml.putProperty("m_pos", m_pos);
|
471 |
|
472 |
xml.putProperty("fontName", m_f.getName());
|
473 |
xml.putProperty("fontStyle", m_f.getStyle());
|
474 |
xml.putProperty("textColor", StringUtilities.color2String(textColor));
|
475 |
|
476 |
xml.putProperty("transicionPixelsMilimetros",
|
477 |
transicionPixelsMilimetros); |
478 |
|
479 |
// jaume
|
480 |
xml.putProperty("cellPadding", cellPadding);
|
481 |
xml.putProperty("fontSize", fontSize);
|
482 |
xml.putProperty("fixedFontSize", fixedFontSize);
|
483 |
xml.putProperty("surrounded", surrounded);
|
484 |
xml.putProperty("hasTitle", hasTitle);
|
485 |
xml.putProperty("title", title);
|
486 |
xml.putProperty("titleSize", titleSize);
|
487 |
xml.putProperty("frameBorderSize", frameBorderSize);
|
488 |
xml.putProperty("frameColor",
|
489 |
StringUtilities.color2String(frameColor)); |
490 |
xml.putProperty("titleColor",
|
491 |
StringUtilities.color2String(titleColor)); |
492 |
} catch (Exception e) { |
493 |
throw new SaveException(e, this.getClass().getName()); |
494 |
} |
495 |
|
496 |
return xml;
|
497 |
} |
498 |
|
499 |
/**
|
500 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#setXMLEntity(com.iver.utiles.XMLEntity,
|
501 |
* com.iver.cit.gvsig.project.Project)
|
502 |
*/
|
503 |
public void setXMLEntity03(XMLEntity xml, Layout l) { |
504 |
if (xml.getIntProperty("m_Selected") != 0) { |
505 |
this.setSelected(true); |
506 |
} else {
|
507 |
this.setSelected(false); |
508 |
} |
509 |
|
510 |
String[] s = xml.getStringArrayProperty("s"); |
511 |
|
512 |
for (int i = 0; i < s.length; i++) { |
513 |
this.m_text.add(s[i]);
|
514 |
} |
515 |
|
516 |
this.m_isFixed = xml.getBooleanProperty("m_isFixed"); |
517 |
this.m_pos = xml.getIntProperty("m_pos"); |
518 |
setRotation(xml.getDoubleProperty("m_rotation"));
|
519 |
|
520 |
this.m_f = new Font(xml.getStringProperty("fontName"), |
521 |
xml.getIntProperty("fontStyle"), 9); |
522 |
|
523 |
if (xml.contains("textColor")) { |
524 |
this.textColor = StringUtilities.string2Color(xml.getStringProperty(
|
525 |
"textColor"));
|
526 |
} |
527 |
} |
528 |
|
529 |
/**
|
530 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#setXMLEntity(com.iver.utiles.XMLEntity,
|
531 |
* com.iver.cit.gvsig.project.Project)
|
532 |
*/
|
533 |
public void setXMLEntity(XMLEntity xml) { |
534 |
if (xml.getIntProperty("m_Selected") != 0) { |
535 |
this.setSelected(true); |
536 |
} else {
|
537 |
this.setSelected(false); |
538 |
} |
539 |
|
540 |
String[] s = xml.getStringArrayProperty("s"); |
541 |
|
542 |
for (int i = 0; i < s.length; i++) { |
543 |
this.m_text.add(s[i]);
|
544 |
} |
545 |
|
546 |
this.m_isFixed = xml.getBooleanProperty("m_isFixed"); |
547 |
|
548 |
int size = 9; |
549 |
|
550 |
if (m_isFixed && xml.contains("fontSize")) { |
551 |
size = xml.getIntProperty("fontSize");
|
552 |
} |
553 |
|
554 |
this.m_pos = xml.getIntProperty("m_pos"); |
555 |
setRotation(xml.getDoubleProperty("m_rotation"));
|
556 |
this.m_f = new Font(xml.getStringProperty("fontName"), |
557 |
xml.getIntProperty("fontStyle"), size);
|
558 |
|
559 |
if (xml.contains("textColor")) { |
560 |
this.textColor = StringUtilities.string2Color(xml.getStringProperty(
|
561 |
"textColor"));
|
562 |
} |
563 |
|
564 |
// jaume
|
565 |
if (xml.contains("cellPadding")) { |
566 |
this.cellPadding = xml.getDoubleProperty("cellPadding"); |
567 |
} |
568 |
|
569 |
if (xml.contains("fontSize")) { |
570 |
this.fontSize = xml.getIntProperty("fontSize"); |
571 |
} |
572 |
|
573 |
if (xml.contains("fixedFontSize")) { |
574 |
this.fixedFontSize = xml.getBooleanProperty("fixedFontSize"); |
575 |
} |
576 |
|
577 |
if (xml.contains("surrounded")) { |
578 |
this.surrounded = xml.getBooleanProperty("surrounded"); |
579 |
} |
580 |
|
581 |
if (xml.contains("hasTitle")) { |
582 |
this.hasTitle = xml.getBooleanProperty("hasTitle"); |
583 |
} |
584 |
|
585 |
if (xml.contains("title")) { |
586 |
this.title = xml.getStringProperty("title"); |
587 |
} |
588 |
|
589 |
if (xml.contains("titleSize")) { |
590 |
this.titleSize = xml.getIntProperty("titleSize"); |
591 |
} |
592 |
|
593 |
if (xml.contains("frameBorderSize")) { |
594 |
this.frameBorderSize = xml.getDoubleProperty("frameBorderSize"); |
595 |
} |
596 |
|
597 |
if (xml.contains("frameColor")) { |
598 |
this.frameColor = StringUtilities.string2Color(xml.getStringProperty(
|
599 |
"frameColor"));
|
600 |
} |
601 |
|
602 |
if (xml.contains("titleColor")) { |
603 |
this.titleColor = StringUtilities.string2Color(xml.getStringProperty(
|
604 |
"titleColor"));
|
605 |
} |
606 |
|
607 |
if (!xml.contains("transicionPixelsMilimetros")) { |
608 |
cellPadding = 0.05;
|
609 |
frameBorderSize = 0.01;
|
610 |
} |
611 |
} |
612 |
|
613 |
/**
|
614 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#getNameFFrame()
|
615 |
*/
|
616 |
public String getNameFFrame() { |
617 |
return PluginServices.getText(this, "texto") + num; |
618 |
} |
619 |
|
620 |
/**
|
621 |
* Sets FFrameText to draw an involving rectangle
|
622 |
*
|
623 |
* @param b
|
624 |
*/
|
625 |
public void setSurrounded(boolean b) { |
626 |
surrounded = b; |
627 |
} |
628 |
|
629 |
/**
|
630 |
* True if the FFrameText is set to draw an involving rectangle, or false
|
631 |
* if not.
|
632 |
*
|
633 |
* @return boolean
|
634 |
*/
|
635 |
public boolean isSurrounded() { |
636 |
return surrounded;
|
637 |
} |
638 |
|
639 |
/**
|
640 |
* Sets the gap between the involving rectangle and the text
|
641 |
*
|
642 |
* @param i
|
643 |
*/
|
644 |
public void setCellPadding(double i) { |
645 |
cellPadding = i; |
646 |
} |
647 |
|
648 |
/**
|
649 |
* Devuelve true si tiene un t?tulo.
|
650 |
*
|
651 |
* @return
|
652 |
*/
|
653 |
public boolean hasTitle() { |
654 |
return hasTitle;
|
655 |
} |
656 |
|
657 |
/**
|
658 |
* Devuelve un string con el t?tulo.
|
659 |
*
|
660 |
* @return
|
661 |
*/
|
662 |
public String getTitle() { |
663 |
return title;
|
664 |
} |
665 |
|
666 |
/**
|
667 |
* Inserta true si tiene t?tulo
|
668 |
*
|
669 |
* @param b
|
670 |
*/
|
671 |
public void setHasTitle(boolean b) { |
672 |
hasTitle = b; |
673 |
} |
674 |
|
675 |
/**
|
676 |
* Inserta un string con el t?tulo.
|
677 |
*
|
678 |
* @param text
|
679 |
*/
|
680 |
public void setTitle(String text) { |
681 |
title = text; |
682 |
} |
683 |
|
684 |
/**
|
685 |
* Devuelve el tama?o del t?tulo.
|
686 |
*
|
687 |
* @return
|
688 |
*/
|
689 |
public int getTitleSize() { |
690 |
return titleSize;
|
691 |
} |
692 |
|
693 |
/**
|
694 |
* Inserta el tama?o del t?tulo.
|
695 |
*
|
696 |
* @param size DOCUMENT ME!
|
697 |
*/
|
698 |
public void setTitleSize(int size) { |
699 |
titleSize = size; |
700 |
} |
701 |
|
702 |
/**
|
703 |
* Inserta el tama?o del borde.
|
704 |
*
|
705 |
* @param size
|
706 |
*/
|
707 |
public void setFrameBorderSize(double size) { |
708 |
frameBorderSize = size; |
709 |
} |
710 |
|
711 |
/**
|
712 |
* Devuelve el tama?o del borde.
|
713 |
*
|
714 |
* @return
|
715 |
*/
|
716 |
public double getFrameBorderSize() { |
717 |
return frameBorderSize;
|
718 |
} |
719 |
|
720 |
/**
|
721 |
* DOCUMENT ME!
|
722 |
*
|
723 |
* @param frameColor
|
724 |
*/
|
725 |
public void setFrameColor(Color frameColor) { |
726 |
this.frameColor = frameColor;
|
727 |
} |
728 |
|
729 |
/**
|
730 |
* DOCUMENT ME!
|
731 |
*
|
732 |
* @param titleColor DOCUMENT ME!
|
733 |
*/
|
734 |
public void setTitleColor(Color titleColor) { |
735 |
this.titleColor = titleColor;
|
736 |
} |
737 |
|
738 |
/**
|
739 |
* DOCUMENT ME!
|
740 |
*
|
741 |
* @return DOCUMENT ME!
|
742 |
*/
|
743 |
public Color getFrameColor() { |
744 |
return frameColor;
|
745 |
} |
746 |
|
747 |
/**
|
748 |
* DOCUMENT ME!
|
749 |
*
|
750 |
* @return DOCUMENT ME!
|
751 |
*/
|
752 |
public Color getTitleColor() { |
753 |
return titleColor;
|
754 |
} |
755 |
|
756 |
/**
|
757 |
* Use this method if you want the text in the FFrameText to be removed.
|
758 |
*/
|
759 |
public void clearText() { |
760 |
m_text.clear(); |
761 |
} |
762 |
|
763 |
public void initialize() { |
764 |
// TODO Auto-generated method stub
|
765 |
|
766 |
} |
767 |
} |