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