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