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