svn-gvsig-desktop / tags / Root_v061 / applications / appgvSIG / src / com / iver / cit / gvsig / gui / layout / fframes / FFrameText.java @ 4812
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 |
* 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,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,at) * myScale;
|
297 |
int sizeBorder=(int)FLayoutUtilities.fromSheetDistance(frameBorderSize,at); |
298 |
if (sizeBorder > 1) { |
299 |
System.out.println("borderSize = " + sizeBorder); |
300 |
|
301 |
int scaledBorderSize = (int) (sizeBorder * myScale); |
302 |
|
303 |
for (int i = scaledBorderSize - 1; i > 0; i--) |
304 |
g.drawRect((int) raux.x - i, (int) raux.y - i, |
305 |
(int) raux.width + (2 * i), |
306 |
(int) raux.height + (2 * i)); |
307 |
} |
308 |
|
309 |
// Recalibro el rectangulo para establecer el ?rea donde se dibujan las fuentes
|
310 |
// al ?rea marcada con el rat?n menos la distancia al marco especificada
|
311 |
raux.setRect(raux.getX() + scaledCellPadding, |
312 |
raux.getY() + scaledCellPadding, |
313 |
raux.getWidth() - (scaledCellPadding * 2),
|
314 |
raux.getHeight() - (scaledCellPadding * 2));
|
315 |
} |
316 |
|
317 |
g.setColor(textColor); |
318 |
|
319 |
drawText(raux, scaledFontSize, g); |
320 |
g.rotate(Math.toRadians(-getRotation()),
|
321 |
raux.x + (raux.width / 2), raux.y + (raux.height / 2)); |
322 |
} |
323 |
} |
324 |
|
325 |
raux = null;
|
326 |
} |
327 |
|
328 |
/**
|
329 |
* Dibuja el texto sobre el graphics con el tama?o adecuado.
|
330 |
*
|
331 |
* @param r Rect?ngulo sobre el que dibujar.
|
332 |
* @param sfs Tama?o aproximado del texto.
|
333 |
* @param g Graphics sobre el que dibujar el texto.
|
334 |
*/
|
335 |
private void drawText(Rectangle2D r, int sfs, Graphics2D g) { |
336 |
int minSFS = Integer.MAX_VALUE; |
337 |
FontRenderContext frc = g.getFontRenderContext();
|
338 |
int ht = (int) (r.getHeight() / m_text.size()); |
339 |
|
340 |
if (isFontSizeFixed()) {
|
341 |
minSFS = sfs; |
342 |
} else {
|
343 |
for (int i = 0; i < m_text.size(); i++) { |
344 |
if (!((String) m_text.get(i)).equals("")) { |
345 |
TextLayout textaux = new TextLayout((String) m_text.get(i), |
346 |
m_f, frc); |
347 |
Rectangle2D txtBound = textaux.getBounds();
|
348 |
double difW = txtBound.getWidth() / r.getWidth();
|
349 |
double difH = (txtBound.getHeight() * m_text.size()) / (r.getHeight());
|
350 |
|
351 |
if (difW > difH) {
|
352 |
if (minSFS > sfs) {
|
353 |
minSFS = (int) (sfs / difW);
|
354 |
} |
355 |
} else {
|
356 |
if (minSFS > sfs) {
|
357 |
minSFS = (int) (sfs / difH);
|
358 |
} |
359 |
} |
360 |
} |
361 |
} |
362 |
} |
363 |
|
364 |
TextLayout textLayout = null; |
365 |
|
366 |
for (int i = 0; i < m_text.size(); i++) { |
367 |
if (!((String) m_text.get(i)).equals("")) { |
368 |
m_f = new Font(m_f.getFontName(), m_f.getStyle(), minSFS); |
369 |
|
370 |
textLayout = new TextLayout((String) m_text.get(i), m_f, frc); |
371 |
|
372 |
Rectangle2D txtBound = textLayout.getBounds();
|
373 |
float difW = (float) (r.getWidth() - txtBound.getWidth()); |
374 |
|
375 |
switch (m_pos) {
|
376 |
case (LEFT):
|
377 |
textLayout.draw(g, (float) r.getX(),
|
378 |
(float) (r.getY() + (ht * (i + 1)))); |
379 |
|
380 |
break;
|
381 |
|
382 |
case (CENTER):
|
383 |
textLayout.draw(g, (float) r.getX() + (difW / 2), |
384 |
(float) (r.getY() + (ht * (i + 1)))); |
385 |
|
386 |
break;
|
387 |
|
388 |
case (RIGTH):
|
389 |
textLayout.draw(g, (float) r.getX() + difW,
|
390 |
(float) (r.getY() + (ht * (i + 1)))); //- (ht / 2)))); |
391 |
|
392 |
break;
|
393 |
} |
394 |
} |
395 |
} |
396 |
} |
397 |
|
398 |
/**
|
399 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#print(java.awt.Graphics2D,
|
400 |
* java.awt.geom.AffineTransform)
|
401 |
*/
|
402 |
public void print(Graphics2D g, AffineTransform at) { |
403 |
draw(g, at, null, null); |
404 |
} |
405 |
|
406 |
/**
|
407 |
* Rellenar el texto que se quiere a?adir al Layout.
|
408 |
*
|
409 |
* @param s String a a?adir.
|
410 |
*/
|
411 |
public void addText(String s) { |
412 |
m_text.add(s); |
413 |
} |
414 |
|
415 |
/**
|
416 |
* Devuelve el ArrayList que contiene las l?neas de texto.
|
417 |
*
|
418 |
* @return ArrayList.
|
419 |
*/
|
420 |
public ArrayList getText() { |
421 |
return m_text;
|
422 |
} |
423 |
|
424 |
/**
|
425 |
* Seleccionar si se quiere un tama?o fijo o adecuado a la escala.
|
426 |
*
|
427 |
* @param b true si se quiere tama?o fijo.
|
428 |
*/
|
429 |
public void setSizeFixed(boolean b) { |
430 |
m_isFixed = b; |
431 |
} |
432 |
|
433 |
/**
|
434 |
* Devuelve si est? fijado el tama?o.
|
435 |
*
|
436 |
* @return True si est? fijado el tama?o.
|
437 |
*/
|
438 |
public boolean isSizeFixed() { |
439 |
return m_isFixed;
|
440 |
} |
441 |
|
442 |
/**
|
443 |
* @throws SaveException
|
444 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#getXMLEntity()
|
445 |
*/
|
446 |
public XMLEntity getXMLEntity() throws SaveException { |
447 |
XMLEntity xml = new XMLEntity();
|
448 |
try{
|
449 |
xml.putProperty("className", this.getClass().getName()); |
450 |
xml.putProperty("m_name", m_name);
|
451 |
xml.putProperty("x", getBoundBox().x);
|
452 |
xml.putProperty("y", getBoundBox().y);
|
453 |
xml.putProperty("w", getBoundBox().width);
|
454 |
xml.putProperty("h", getBoundBox().height);
|
455 |
xml.putProperty("m_Selected", m_Selected);
|
456 |
xml.putProperty("type", Layout.RECTANGLETEXT);
|
457 |
|
458 |
String[] s = (String[]) m_text.toArray(new String[0]); |
459 |
xml.putProperty("s", s);
|
460 |
xml.putProperty("m_isFixed", m_isFixed);
|
461 |
if (m_isFixed) xml.putProperty("fontSize",m_f.getSize()); |
462 |
xml.putProperty("m_rotation", getRotation());
|
463 |
xml.putProperty("m_pos", m_pos);
|
464 |
|
465 |
xml.putProperty("fontName", m_f.getName());
|
466 |
xml.putProperty("fontStyle", m_f.getStyle());
|
467 |
xml.putProperty("tag", getTag());
|
468 |
xml.putProperty("textColor", StringUtilities.color2String(textColor));
|
469 |
|
470 |
xml.putProperty("transicionPixelsMilimetros",transicionPixelsMilimetros);
|
471 |
// jaume
|
472 |
xml.putProperty("cellPadding", cellPadding);
|
473 |
xml.putProperty("fontSize", fontSize);
|
474 |
xml.putProperty("fixedFontSize", fixedFontSize);
|
475 |
xml.putProperty("surrounded", surrounded);
|
476 |
xml.putProperty("hasTitle", hasTitle);
|
477 |
xml.putProperty("title", title);
|
478 |
xml.putProperty("titleSize", titleSize);
|
479 |
xml.putProperty("frameBorderSize", frameBorderSize);
|
480 |
xml.putProperty("frameColor", StringUtilities.color2String(frameColor));
|
481 |
xml.putProperty("titleColor", StringUtilities.color2String(titleColor));
|
482 |
}catch (Exception e) { |
483 |
throw new SaveException(e,this.getClass().getName()); |
484 |
} |
485 |
return xml;
|
486 |
} |
487 |
|
488 |
/**
|
489 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#setXMLEntity(com.iver.utiles.XMLEntity,
|
490 |
* com.iver.cit.gvsig.project.Project)
|
491 |
*/
|
492 |
public void setXMLEntity03(XMLEntity xml, Layout l) { |
493 |
if (xml.getIntProperty("m_Selected") != 0) { |
494 |
this.setSelected(true); |
495 |
} else {
|
496 |
this.setSelected(false); |
497 |
} |
498 |
|
499 |
String[] s = xml.getStringArrayProperty("s"); |
500 |
|
501 |
for (int i = 0; i < s.length; i++) { |
502 |
this.m_text.add(s[i]);
|
503 |
} |
504 |
|
505 |
this.m_isFixed = xml.getBooleanProperty("m_isFixed"); |
506 |
this.m_pos = xml.getIntProperty("m_pos"); |
507 |
setRotation(xml.getDoubleProperty("m_rotation"));
|
508 |
|
509 |
this.m_f = new Font(xml.getStringProperty("fontName"), |
510 |
xml.getIntProperty("fontStyle"), 9); |
511 |
|
512 |
if (xml.contains("textColor")) { |
513 |
this.textColor = StringUtilities.string2Color(xml.getStringProperty(
|
514 |
"textColor"));
|
515 |
} |
516 |
} |
517 |
|
518 |
/**
|
519 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#setXMLEntity(com.iver.utiles.XMLEntity,
|
520 |
* com.iver.cit.gvsig.project.Project)
|
521 |
*/
|
522 |
public void setXMLEntity(XMLEntity xml) { |
523 |
if (xml.getIntProperty("m_Selected") != 0) { |
524 |
this.setSelected(true); |
525 |
} else {
|
526 |
this.setSelected(false); |
527 |
} |
528 |
|
529 |
String[] s = xml.getStringArrayProperty("s"); |
530 |
|
531 |
for (int i = 0; i < s.length; i++) { |
532 |
this.m_text.add(s[i]);
|
533 |
} |
534 |
|
535 |
this.m_isFixed = xml.getBooleanProperty("m_isFixed"); |
536 |
int size=9; |
537 |
if (m_isFixed && xml.contains("fontSize")) size=xml.getIntProperty("fontSize"); |
538 |
this.m_pos = xml.getIntProperty("m_pos"); |
539 |
setRotation(xml.getDoubleProperty("m_rotation"));
|
540 |
this.m_f = new Font(xml.getStringProperty("fontName"), |
541 |
xml.getIntProperty("fontStyle"), size);
|
542 |
|
543 |
if (xml.contains("textColor")) { |
544 |
this.textColor = StringUtilities.string2Color(xml.getStringProperty(
|
545 |
"textColor"));
|
546 |
} |
547 |
|
548 |
// jaume
|
549 |
if (xml.contains("cellPadding")) { |
550 |
this.cellPadding = xml.getDoubleProperty("cellPadding"); |
551 |
} |
552 |
|
553 |
if (xml.contains("fontSize")) { |
554 |
this.fontSize = xml.getIntProperty("fontSize"); |
555 |
} |
556 |
|
557 |
if (xml.contains("fixedFontSize")) { |
558 |
this.fixedFontSize = xml.getBooleanProperty("fixedFontSize"); |
559 |
} |
560 |
|
561 |
if (xml.contains("surrounded")) { |
562 |
this.surrounded = xml.getBooleanProperty("surrounded"); |
563 |
} |
564 |
|
565 |
if (xml.contains("hasTitle")) { |
566 |
this.hasTitle = xml.getBooleanProperty("hasTitle"); |
567 |
} |
568 |
|
569 |
if (xml.contains("title")) { |
570 |
this.title = xml.getStringProperty("title"); |
571 |
} |
572 |
|
573 |
if (xml.contains("titleSize")) { |
574 |
this.titleSize = xml.getIntProperty("titleSize"); |
575 |
} |
576 |
|
577 |
if (xml.contains("frameBorderSize")) { |
578 |
this.frameBorderSize = xml.getDoubleProperty("frameBorderSize"); |
579 |
} |
580 |
|
581 |
if (xml.contains("frameColor")) { |
582 |
this.frameColor = StringUtilities.string2Color(xml.getStringProperty(
|
583 |
"frameColor"));
|
584 |
} |
585 |
|
586 |
if (xml.contains("titleColor")) { |
587 |
this.titleColor = StringUtilities.string2Color(xml.getStringProperty(
|
588 |
"titleColor"));
|
589 |
} |
590 |
if (!xml.contains("transicionPixelsMilimetros")){ |
591 |
cellPadding=0.05;
|
592 |
frameBorderSize=0.01;
|
593 |
} |
594 |
} |
595 |
|
596 |
/**
|
597 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#getNameFFrame()
|
598 |
*/
|
599 |
public String getNameFFrame() { |
600 |
return PluginServices.getText(this, "texto") + num; |
601 |
} |
602 |
|
603 |
/**
|
604 |
* Sets FFrameText to draw an involving rectangle
|
605 |
*
|
606 |
* @param b
|
607 |
*/
|
608 |
public void setSurrounded(boolean b) { |
609 |
surrounded = b; |
610 |
} |
611 |
|
612 |
/**
|
613 |
* True if the FFrameText is set to draw an involving rectangle, or false
|
614 |
* if not.
|
615 |
*
|
616 |
* @return boolean
|
617 |
*/
|
618 |
public boolean isSurrounded() { |
619 |
return surrounded;
|
620 |
} |
621 |
|
622 |
/**
|
623 |
* Sets the gap between the involving rectangle and the text
|
624 |
*
|
625 |
* @param i
|
626 |
*/
|
627 |
public void setCellPadding(double i) { |
628 |
cellPadding = i; |
629 |
} |
630 |
|
631 |
/**
|
632 |
* Devuelve true si tiene un t?tulo.
|
633 |
*
|
634 |
* @return
|
635 |
*/
|
636 |
public boolean hasTitle() { |
637 |
return hasTitle;
|
638 |
} |
639 |
|
640 |
/**
|
641 |
* Devuelve un string con el t?tulo.
|
642 |
*
|
643 |
* @return
|
644 |
*/
|
645 |
public String getTitle() { |
646 |
return title;
|
647 |
} |
648 |
|
649 |
/**
|
650 |
* Inserta true si tiene t?tulo
|
651 |
*
|
652 |
* @param b
|
653 |
*/
|
654 |
public void setHasTitle(boolean b) { |
655 |
hasTitle = b; |
656 |
} |
657 |
|
658 |
/**
|
659 |
* Inserta un string con el t?tulo.
|
660 |
*
|
661 |
* @param text
|
662 |
*/
|
663 |
public void setTitle(String text) { |
664 |
title = text; |
665 |
} |
666 |
|
667 |
/**
|
668 |
* Devuelve el tama?o del t?tulo.
|
669 |
*
|
670 |
* @return
|
671 |
*/
|
672 |
public int getTitleSize() { |
673 |
return titleSize;
|
674 |
} |
675 |
|
676 |
/**
|
677 |
* Inserta el tama?o del t?tulo.
|
678 |
*
|
679 |
* @param size DOCUMENT ME!
|
680 |
*/
|
681 |
public void setTitleSize(int size) { |
682 |
titleSize = size; |
683 |
} |
684 |
|
685 |
/**
|
686 |
* Inserta el tama?o del borde.
|
687 |
*
|
688 |
* @param size
|
689 |
*/
|
690 |
public void setFrameBorderSize(double size) { |
691 |
frameBorderSize = size; |
692 |
} |
693 |
|
694 |
/**
|
695 |
* Devuelve el tama?o del borde.
|
696 |
*
|
697 |
* @return
|
698 |
*/
|
699 |
public double getFrameBorderSize() { |
700 |
return frameBorderSize;
|
701 |
} |
702 |
|
703 |
/**
|
704 |
* DOCUMENT ME!
|
705 |
*
|
706 |
* @param frameColor
|
707 |
*/
|
708 |
public void setFrameColor(Color frameColor) { |
709 |
this.frameColor = frameColor;
|
710 |
} |
711 |
|
712 |
/**
|
713 |
* DOCUMENT ME!
|
714 |
*
|
715 |
* @param titleColor DOCUMENT ME!
|
716 |
*/
|
717 |
public void setTitleColor(Color titleColor) { |
718 |
this.titleColor = titleColor;
|
719 |
} |
720 |
|
721 |
/**
|
722 |
* DOCUMENT ME!
|
723 |
*
|
724 |
* @return DOCUMENT ME!
|
725 |
*/
|
726 |
public Color getFrameColor() { |
727 |
return frameColor;
|
728 |
} |
729 |
|
730 |
/**
|
731 |
* DOCUMENT ME!
|
732 |
*
|
733 |
* @return DOCUMENT ME!
|
734 |
*/
|
735 |
public Color getTitleColor() { |
736 |
return titleColor;
|
737 |
} |
738 |
|
739 |
/**
|
740 |
* Use this method if you want the text in the FFrameText to be removed.
|
741 |
*/
|
742 |
public void clearText() { |
743 |
m_text.clear(); |
744 |
} |
745 |
|
746 |
public void initialize() { |
747 |
// TODO Auto-generated method stub
|
748 |
|
749 |
} |
750 |
} |