root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / layout / Attributes.java @ 10910
History | View | Annotate | Download (29.8 KB)
1 |
/*
|
---|---|
2 |
* Created on 25-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; |
46 |
|
47 |
import java.awt.Rectangle; |
48 |
import java.awt.geom.Point2D; |
49 |
import java.awt.geom.Rectangle2D; |
50 |
import java.awt.print.PageFormat; |
51 |
import java.awt.print.Paper; |
52 |
import java.text.NumberFormat; |
53 |
|
54 |
import javax.print.attribute.HashPrintRequestAttributeSet; |
55 |
import javax.print.attribute.PrintRequestAttributeSet; |
56 |
import javax.print.attribute.standard.Copies; |
57 |
import javax.print.attribute.standard.Fidelity; |
58 |
import javax.print.attribute.standard.Media; |
59 |
import javax.print.attribute.standard.MediaPrintableArea; |
60 |
import javax.print.attribute.standard.MediaSizeName; |
61 |
import javax.print.attribute.standard.OrientationRequested; |
62 |
import javax.print.attribute.standard.PrintQuality; |
63 |
import javax.print.attribute.standard.Sides; |
64 |
|
65 |
import com.iver.andami.PluginServices; |
66 |
import com.iver.utiles.XMLEntity; |
67 |
|
68 |
|
69 |
/**
|
70 |
* Attributes of Layout.
|
71 |
*
|
72 |
* @author Vicente Caballero Navarro
|
73 |
*/
|
74 |
public class Attributes { |
75 |
/** Array of doubles containg the change factro from <b>CENTIMETERS</b> to KILOMETERS, METERS, CENTIMETERS, MILLIMETERS, MILES, YARDS, FEET, INCHES, DECIMAL DEGREES*/
|
76 |
/* Do not alter the order and the values of this array, if you need append values.*/
|
77 |
public static final double[] CHANGE = { |
78 |
100000, 100, 1, 0.1, 160934.4, 91.44, 30.48, 2.54, 8.983152841195214E-6 |
79 |
}; |
80 |
/* Do not alter the order and the values of this array, if you need append values.*/
|
81 |
public static final String[] NAMES= {"Kilometros","Metros","Centimetros","Milimetros","Millas","Yardas","Pies","Pulgadas","Grados"}; |
82 |
public static final String DEGREES="Coordenadas"; |
83 |
/* Do not alter the order and the values of this array, if you need append values.*/
|
84 |
public static final double[] UNIT = { |
85 |
0.0000025, 0.0025, 0.25, 2.5, 0.0000025, 0.025, 0.025, 0.25 |
86 |
}; |
87 |
public static final int HIGH = 0; |
88 |
public static final int NORMAL = 1; |
89 |
public static final int DRAFT = 2; |
90 |
|
91 |
// Para impresi?n
|
92 |
public final static double PULGADA = 2.54; |
93 |
|
94 |
//public final static Size CUSTOM_PAPER_SIZE = new Size(8.5, 11.0);
|
95 |
public final static Size STANDARD_LETTER_PAPER_SIZE = new Size(8.5, 11.0); |
96 |
public final static Size STANDARD_FOLIO_PAPER_SIZE = new Size(8.5, 13.0); |
97 |
public final static Size STANDARD_LEGAL_PAPER_SIZE = new Size(8.5, 14.0); |
98 |
public final static Size STANDARD_TABLOID_PAPER_SIZE = new Size(11.0, 17.0); |
99 |
public final static Size METRIC_A0_PAPER_SIZE = new Size(118.9, 84.1); |
100 |
public final static Size METRIC_A1_PAPER_SIZE = new Size(84.1, 59.4); |
101 |
public final static Size METRIC_A2_PAPER_SIZE = new Size(59.4, 42.0); |
102 |
public final static Size METRIC_A3_PAPER_SIZE = new Size(42.0, 29.7); |
103 |
public final static Size METRIC_A4_PAPER_SIZE = new Size(29.7, 21.0); |
104 |
public final static Size METRIC_A5_PAPER_SIZE = new Size(21.0, 14.8); |
105 |
public final static Size ANSI_ENG_A_PAPER_SIZE = new Size(11.0, 8.5); |
106 |
public final static Size ANSI_ENG_B_PAPER_SIZE = new Size(17.0, 11.0); |
107 |
public final static Size ANSI_ENG_C_PAPER_SIZE = new Size(22.0, 17.0); |
108 |
public final static Size ANSI_ENG_D_PAPER_SIZE = new Size(34.0, 22.0); |
109 |
public final static Size ANSI_ENG_E_PAPER_SIZE = new Size(44.0, 34.0); |
110 |
public final static Size ANSI_ARCH_A_PAPER_SIZE = new Size(12.0, 9.0); |
111 |
public final static Size ANSI_ARCH_B_PAPER_SIZE = new Size(18.0, 12.0); |
112 |
public final static Size ANSI_ARCH_C_PAPER_SIZE = new Size(24.0, 18.0); |
113 |
public final static Size ANSI_ARCH_D_PAPER_SIZE = new Size(36.0, 24.0); |
114 |
public final static Size ANSI_ARCH_E_PAPER_SIZE = new Size(42.0, 30.0); |
115 |
public static Size CUSTOM_PAPER_SIZE = new Size(100.0, 100.0); |
116 |
public final static int PRINT = 0; |
117 |
public final static int CUSTOM = 6; |
118 |
public final static int A0 = 5; |
119 |
public final static int A1 = 4; |
120 |
public final static int A2 = 3; |
121 |
public final static int A3 = 2; |
122 |
public final static int A4 = 1; |
123 |
public static int DPI = 300; |
124 |
public static int DPISCREEN = 72; |
125 |
public static Rectangle clipRect = new Rectangle(); |
126 |
private static Point2D defaultGridGap; |
127 |
|
128 |
// static {
|
129 |
// new Attributes();
|
130 |
// }
|
131 |
|
132 |
private PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet(); |
133 |
private MediaSizeName m_type = MediaSizeName.ISO_A4; |
134 |
private boolean m_isLandSel; |
135 |
private OrientationRequested m_Orientation; |
136 |
private double m_TypeUnit = CHANGE[2]; //CENTIMETROS; |
137 |
private String m_NameUnit; |
138 |
private Double m_numX=null; |
139 |
private Double m_numY=null; |
140 |
private double m_unitX = 0; |
141 |
private double m_unitY = 0; |
142 |
private boolean hasmargin; |
143 |
private int m_resolutionSel = NORMAL; |
144 |
private int m_typeSel = PRINT; |
145 |
private int m_selTypeUnit = 2; |
146 |
public Size m_sizePaper = new Size(METRIC_A4_PAPER_SIZE.getAlto(), |
147 |
METRIC_A4_PAPER_SIZE.getAncho()); |
148 |
public double[] m_area = { PULGADA, PULGADA, PULGADA, PULGADA }; |
149 |
private double anchoXalto = m_sizePaper.getAlto() / m_sizePaper.getAncho(); |
150 |
private Size m_sizeinUnits = m_sizePaper;
|
151 |
private PrintQuality m_resolution=PrintQuality.NORMAL; |
152 |
/**
|
153 |
* Create a new object of Attributes.
|
154 |
*
|
155 |
*/
|
156 |
public Attributes() { |
157 |
m_NameUnit = NAMES[2];
|
158 |
m_type = MediaSizeName.ISO_A4;
|
159 |
m_isLandSel = true;
|
160 |
setSizeinUnits(m_isLandSel); |
161 |
|
162 |
hasmargin = false;
|
163 |
m_Orientation = OrientationRequested.LANDSCAPE;
|
164 |
attributes.add(new Copies(1)); |
165 |
attributes.add(MediaSizeName.ISO_A4);
|
166 |
attributes.add(Sides.ONE_SIDED);
|
167 |
attributes.add(Fidelity.FIDELITY_FALSE);
|
168 |
attributes.add(PrintQuality.NORMAL);
|
169 |
|
170 |
setType(m_typeSel); |
171 |
|
172 |
attributes.add(new MediaPrintableArea(0, 0, |
173 |
(float) ((m_sizePaper.getAlto() * DPISCREEN) / PULGADA),
|
174 |
(float) ((m_sizePaper.getAncho() * DPISCREEN) / PULGADA),
|
175 |
MediaPrintableArea.MM));
|
176 |
} |
177 |
|
178 |
/**
|
179 |
* Inserts the Layout's properties to print.
|
180 |
*
|
181 |
* @param typeSel Type of sheet.
|
182 |
* @param units Units.
|
183 |
* @param isLand True if the sheet is horizontal.
|
184 |
* @param margin True if the sheet has margin.
|
185 |
* @param resolution Type of quality of resolution.
|
186 |
* @param area Printing area.
|
187 |
*/
|
188 |
public void setSelectedOptions(int typeSel, int units, boolean isLand, |
189 |
boolean margin, int resolution, double[] area) { |
190 |
setType(typeSel); |
191 |
setUnit(units); |
192 |
setIsLandScape(isLand); |
193 |
hasmargin = margin; |
194 |
setResolution(resolution); |
195 |
m_area = area; |
196 |
} |
197 |
|
198 |
/**
|
199 |
* Returns a PageFormat with the properties of printing.
|
200 |
*
|
201 |
* @return PageFormat
|
202 |
*/
|
203 |
public PageFormat getPageFormat() { |
204 |
PageFormat pf1 = new PageFormat(); |
205 |
Paper paper = pf1.getPaper();
|
206 |
|
207 |
if (isLandSpace()) {
|
208 |
pf1.setOrientation(0);
|
209 |
paper.setSize((m_sizePaper.getAncho() * DPISCREEN) / PULGADA, |
210 |
(m_sizePaper.getAlto() * DPISCREEN) / PULGADA); |
211 |
|
212 |
double aux = m_area[0]; |
213 |
m_area[0] = m_area[3]; |
214 |
m_area[3] = m_area[1]; |
215 |
m_area[1] = m_area[2]; |
216 |
m_area[2] = aux;
|
217 |
paper.setImageableArea(getInPixels(m_area[2]),
|
218 |
getInPixels(m_area[0]),
|
219 |
getInPixels(m_sizeinUnits.getAncho() - m_area[2] - m_area[3]), |
220 |
getInPixels(m_sizeinUnits.getAlto() - m_area[0] - m_area[1])); |
221 |
} else {
|
222 |
pf1.setOrientation(1);
|
223 |
paper.setSize((m_sizePaper.getAlto() * DPISCREEN) / PULGADA, |
224 |
(m_sizePaper.getAncho() * DPISCREEN) / PULGADA); |
225 |
paper.setImageableArea(getInPixels(m_area[2]),
|
226 |
getInPixels(m_area[0]),
|
227 |
getInPixels(m_sizeinUnits.getAlto() - m_area[2] - m_area[3]), |
228 |
getInPixels(m_sizeinUnits.getAncho() - m_area[0] - m_area[1])); |
229 |
} |
230 |
|
231 |
pf1.setPaper(paper); |
232 |
|
233 |
return pf1;
|
234 |
} |
235 |
|
236 |
/**
|
237 |
* Changes centimeters to pixels.
|
238 |
*
|
239 |
* @param d Centimeters.
|
240 |
*
|
241 |
* @return Pixels.
|
242 |
*/
|
243 |
private double getInPixels(double d) { |
244 |
return d * (DPISCREEN / PULGADA);
|
245 |
} |
246 |
|
247 |
/**
|
248 |
* Changes pixels to centimeters.
|
249 |
*
|
250 |
* @param d Pixel.
|
251 |
*
|
252 |
* @return Centimeters.
|
253 |
*/
|
254 |
private double getInCM(double d) { |
255 |
return d / (DPISCREEN / PULGADA);
|
256 |
} |
257 |
|
258 |
/**
|
259 |
* Returns the printing area.
|
260 |
*
|
261 |
* @return Rectangle Area.
|
262 |
*/
|
263 |
public Rectangle2D getArea() { |
264 |
Rectangle2D.Double rect = new Rectangle2D.Double(); |
265 |
rect.setRect(m_area[0], m_area[1], |
266 |
m_sizePaper.getAncho() - m_area[0] - m_area[2], |
267 |
m_sizePaper.getAlto() - m_area[1] - m_area[3]); |
268 |
|
269 |
return rect;
|
270 |
} |
271 |
|
272 |
/**
|
273 |
* Inserts the attributes with a PageFormat.
|
274 |
*
|
275 |
* @param pf PageFormat.
|
276 |
*/
|
277 |
public void setPageFormat(PageFormat pf) { |
278 |
Size size = null;
|
279 |
|
280 |
if (pf.getOrientation() == 0) { |
281 |
setIsLandScape(true);
|
282 |
m_Orientation = OrientationRequested.LANDSCAPE;
|
283 |
size = new Size(pf.getHeight(), pf.getWidth());
|
284 |
} else {
|
285 |
setIsLandScape(false);
|
286 |
m_Orientation = OrientationRequested.PORTRAIT;
|
287 |
size = new Size(pf.getHeight(), pf.getWidth());
|
288 |
} |
289 |
|
290 |
attributes.add(m_Orientation); |
291 |
|
292 |
//area
|
293 |
m_area[0] = getInCM(pf.getImageableY());
|
294 |
m_area[2] = getInCM(pf.getImageableX());
|
295 |
m_area[1] = m_sizePaper.getAlto() - getInCM(pf.getImageableHeight()) -
|
296 |
m_area[0];
|
297 |
m_area[3] = m_sizePaper.getAncho() - getInCM(pf.getImageableWidth()) -
|
298 |
m_area[2];
|
299 |
|
300 |
// tipo formato
|
301 |
if (isLandSpace()) {
|
302 |
//double aux = m_area[0];
|
303 |
//m_area[0] = m_area[3];
|
304 |
//m_area[3] = m_area[1];
|
305 |
//m_area[1] = m_area[2];
|
306 |
//m_area[2] = aux;
|
307 |
attributes.add(new MediaPrintableArea((float) (m_area[2] * 10), |
308 |
(float) (m_area[0] * 10), |
309 |
(float) (m_sizeinUnits.getAlto() - m_area[0] - m_area[1]) * 10, |
310 |
(float) (m_sizeinUnits.getAncho() - m_area[2] - m_area[3]) * 10, |
311 |
MediaPrintableArea.MM));
|
312 |
} else {
|
313 |
attributes.add(new MediaPrintableArea((float) (m_area[0] * 10), |
314 |
(float) (m_area[1] * 10), |
315 |
(float) (getInCM(pf.getImageableWidth()) * 10), |
316 |
(float) (getInCM(pf.getImageableHeight()) * 10), |
317 |
MediaPrintableArea.MM));
|
318 |
} |
319 |
|
320 |
setType(getTypePaper(size)); |
321 |
} |
322 |
|
323 |
/**
|
324 |
* Returns a PrintRequestAttributeSet with all properties to the PrintDialog.
|
325 |
*
|
326 |
* @return PrintRequestAttributesSet.
|
327 |
*/
|
328 |
public PrintRequestAttributeSet toPrintAttributes() { |
329 |
HashPrintRequestAttributeSet resul = new HashPrintRequestAttributeSet(); |
330 |
|
331 |
setType(m_typeSel); |
332 |
|
333 |
resul.add(m_type); |
334 |
|
335 |
//units, no hace falta a?adirlo a attributes
|
336 |
resul.add(m_Orientation); |
337 |
setArea(m_area); |
338 |
resul.add(new MediaPrintableArea(0, 0, |
339 |
(float) ((m_sizePaper.getAlto() * DPISCREEN) / PULGADA),
|
340 |
(float) ((m_sizePaper.getAncho() * DPISCREEN) / PULGADA),
|
341 |
MediaPrintableArea.MM));
|
342 |
|
343 |
resul.add(m_resolution); |
344 |
//resul.add(new PrinterResolution(DPI,DPI,PrinterResolution.DPI));
|
345 |
return resul;
|
346 |
} |
347 |
|
348 |
/**
|
349 |
* Inserts printing area.
|
350 |
*
|
351 |
* @param area Printing area.
|
352 |
*/
|
353 |
private void setArea(double[] area) { |
354 |
if (!isLandSpace()) {
|
355 |
attributes.add(new MediaPrintableArea((float) (area[2] * 10), |
356 |
(float) (area[0] * 10), |
357 |
(float) ((m_sizePaper.getAncho() - area[2] - area[3]) * 10), |
358 |
(float) ((m_sizePaper.getAlto() - area[0] - area[1]) * 10), |
359 |
MediaPrintableArea.MM));
|
360 |
|
361 |
clipRect.setRect((area[2] / PULGADA * DPI),
|
362 |
area[0] / PULGADA * DPI,
|
363 |
(m_sizePaper.getAncho() - area[2] - area[3]) / PULGADA * DPI, |
364 |
(m_sizePaper.getAlto() - area[0] - area[1]) / PULGADA * DPI); |
365 |
} else {
|
366 |
attributes.add(new MediaPrintableArea((float) (area[0] * 10), |
367 |
(float) (area[3] * 10), |
368 |
(float) ((m_sizePaper.getAlto() - area[0] - area[1]) * 10), |
369 |
(float) ((m_sizePaper.getAncho() - area[3] - area[2]) * 10), |
370 |
MediaPrintableArea.MM));
|
371 |
|
372 |
clipRect.setRect((area[1] / PULGADA * DPI),
|
373 |
area[2] / PULGADA * DPI,
|
374 |
(m_sizePaper.getAncho() - area[1] - area[0]) / PULGADA * DPI, |
375 |
(m_sizePaper.getAlto() - area[2] - area[3]) / PULGADA * DPI); |
376 |
} |
377 |
} |
378 |
|
379 |
/**
|
380 |
* Returns true if the margin should be used.
|
381 |
*
|
382 |
* @return True if margin should be used.
|
383 |
*/
|
384 |
public boolean isMargin() { |
385 |
return hasmargin;
|
386 |
} |
387 |
|
388 |
/**
|
389 |
* Returns the resolution of properties to print.
|
390 |
*
|
391 |
* @return Resolution.
|
392 |
*/
|
393 |
public int getResolution() { |
394 |
return m_resolutionSel;
|
395 |
} |
396 |
|
397 |
/**
|
398 |
* Inserts the resolution to apply at printing.
|
399 |
*
|
400 |
* @param i Type of resolution.
|
401 |
*
|
402 |
* The type of resolution can be:
|
403 |
*
|
404 |
* DRAFT: 27 dpi.
|
405 |
* NORMAL: 300 dpi.
|
406 |
* HIGH: 600 dpi.
|
407 |
*/
|
408 |
private void setResolution(int i) { |
409 |
m_resolutionSel = i; |
410 |
|
411 |
switch (i) {
|
412 |
case (HIGH):
|
413 |
|
414 |
m_resolution=PrintQuality.HIGH;
|
415 |
DPI = 600;
|
416 |
|
417 |
break;
|
418 |
|
419 |
case (NORMAL):
|
420 |
|
421 |
m_resolution=PrintQuality.NORMAL;
|
422 |
DPI = 300;
|
423 |
|
424 |
break;
|
425 |
|
426 |
case (DRAFT):
|
427 |
|
428 |
m_resolution=PrintQuality.DRAFT;
|
429 |
DPI = 72;
|
430 |
|
431 |
break;
|
432 |
} |
433 |
} |
434 |
|
435 |
/**
|
436 |
* Returns attributes of PrintDialog.
|
437 |
*
|
438 |
* @return Attributes of printing.
|
439 |
*/
|
440 |
public PrintRequestAttributeSet getAttributes() { |
441 |
return attributes;
|
442 |
} |
443 |
|
444 |
/**
|
445 |
* Returns True if the position of sheet is horizontal or vertical.
|
446 |
*
|
447 |
* @return True if position is horizontal.
|
448 |
*/
|
449 |
public boolean isLandSpace() { |
450 |
return m_isLandSel;
|
451 |
} |
452 |
|
453 |
/**
|
454 |
* Returns the format of sheet.
|
455 |
*
|
456 |
* @return Format of sheet.
|
457 |
*/
|
458 |
public int getType() { |
459 |
return m_typeSel;
|
460 |
} |
461 |
|
462 |
/**
|
463 |
* Inserts the number of units to define the coords X grid.
|
464 |
*
|
465 |
* @param d number of units to define the grid.
|
466 |
*/
|
467 |
public void setNumUnitsX(double d) { |
468 |
m_numX = new Double(d); |
469 |
} |
470 |
|
471 |
/**
|
472 |
* Returns the number of pixels that represents a unit of coords X.
|
473 |
*
|
474 |
* @return Number of pixels coords X.
|
475 |
*/
|
476 |
|
477 |
public double getNumUnitsX() { |
478 |
if (m_numX == null) |
479 |
m_numX = new Double(getDefaultGridGap().getX()); |
480 |
return m_numX.doubleValue();
|
481 |
} |
482 |
|
483 |
/**
|
484 |
* Returns the number of pixels that represents a unit of coords Y.
|
485 |
*
|
486 |
* @return Number of pixels coords Y.
|
487 |
*/
|
488 |
|
489 |
public double getNumUnitsY() { |
490 |
if (m_numY == null) |
491 |
m_numY = new Double(getDefaultGridGap().getY()); |
492 |
return m_numY.doubleValue();
|
493 |
} |
494 |
|
495 |
/**
|
496 |
* Inserts the number of units to define the coords X grid.
|
497 |
*
|
498 |
* @param d number of units to define the grid.
|
499 |
*/
|
500 |
public void setNumUnitsY(double d) { |
501 |
m_numY = new Double(d); |
502 |
} |
503 |
|
504 |
/**
|
505 |
* Inserts true if the sheet is horizontal or false if is vertical.
|
506 |
*
|
507 |
* @param b True if sheet is horizontal.
|
508 |
*/
|
509 |
public void setIsLandScape(boolean b) { |
510 |
m_isLandSel = b; |
511 |
setType(m_typeSel); |
512 |
|
513 |
if (m_isLandSel) {
|
514 |
m_Orientation = OrientationRequested.LANDSCAPE;
|
515 |
} else {
|
516 |
m_Orientation = OrientationRequested.PORTRAIT;
|
517 |
} |
518 |
} |
519 |
|
520 |
/**
|
521 |
* Inserts the type of sheet to show.
|
522 |
*
|
523 |
* @param t Type of sheet.
|
524 |
*/
|
525 |
public void setType(int t) { |
526 |
m_typeSel = t; |
527 |
|
528 |
//m_sizePaper=getSizePaper(t);
|
529 |
switch (t) {
|
530 |
case (PRINT):
|
531 |
m_type = ((MediaSizeName) attributes.get(Media.class)); |
532 |
|
533 |
if (isLandSpace()) {
|
534 |
m_sizePaper = new Size(METRIC_A4_PAPER_SIZE.getAncho(),
|
535 |
METRIC_A4_PAPER_SIZE.getAlto()); |
536 |
} else {
|
537 |
m_sizePaper = METRIC_A4_PAPER_SIZE; |
538 |
} |
539 |
|
540 |
break;
|
541 |
|
542 |
case (A4):
|
543 |
m_type = MediaSizeName.ISO_A4;
|
544 |
|
545 |
if (isLandSpace()) {
|
546 |
m_sizePaper = new Size(METRIC_A4_PAPER_SIZE.getAncho(),
|
547 |
METRIC_A4_PAPER_SIZE.getAlto()); |
548 |
} else {
|
549 |
m_sizePaper = METRIC_A4_PAPER_SIZE; |
550 |
} |
551 |
|
552 |
break;
|
553 |
|
554 |
case (A3):
|
555 |
m_type = MediaSizeName.ISO_A3;
|
556 |
|
557 |
if (isLandSpace()) {
|
558 |
m_sizePaper = new Size(METRIC_A3_PAPER_SIZE.getAncho(),
|
559 |
METRIC_A3_PAPER_SIZE.getAlto()); |
560 |
} else {
|
561 |
m_sizePaper = METRIC_A3_PAPER_SIZE; |
562 |
} |
563 |
|
564 |
break;
|
565 |
|
566 |
case (A2):
|
567 |
m_type = MediaSizeName.ISO_A2;
|
568 |
|
569 |
if (isLandSpace()) {
|
570 |
m_sizePaper = new Size(METRIC_A2_PAPER_SIZE.getAncho(),
|
571 |
METRIC_A2_PAPER_SIZE.getAlto()); |
572 |
} else {
|
573 |
m_sizePaper = METRIC_A2_PAPER_SIZE; |
574 |
} |
575 |
|
576 |
break;
|
577 |
|
578 |
case (A1):
|
579 |
m_type = MediaSizeName.ISO_A1;
|
580 |
|
581 |
if (isLandSpace()) {
|
582 |
m_sizePaper = new Size(METRIC_A1_PAPER_SIZE.getAncho(),
|
583 |
METRIC_A1_PAPER_SIZE.getAlto()); |
584 |
} else {
|
585 |
m_sizePaper = METRIC_A1_PAPER_SIZE; |
586 |
} |
587 |
|
588 |
break;
|
589 |
|
590 |
case (A0):
|
591 |
m_type = MediaSizeName.ISO_A0;
|
592 |
|
593 |
if (isLandSpace()) {
|
594 |
m_sizePaper = new Size(METRIC_A0_PAPER_SIZE.getAncho(),
|
595 |
METRIC_A0_PAPER_SIZE.getAlto()); |
596 |
} else {
|
597 |
m_sizePaper = METRIC_A0_PAPER_SIZE; |
598 |
} |
599 |
|
600 |
break;
|
601 |
|
602 |
case (CUSTOM):
|
603 |
m_type = MediaSizeName.PERSONAL_ENVELOPE;
|
604 |
|
605 |
if (isLandSpace()) {
|
606 |
m_sizePaper = new Size(CUSTOM_PAPER_SIZE.getAncho(),
|
607 |
CUSTOM_PAPER_SIZE.getAlto()); |
608 |
} else {
|
609 |
m_sizePaper = CUSTOM_PAPER_SIZE; |
610 |
} |
611 |
|
612 |
break;
|
613 |
} |
614 |
|
615 |
setSizeinUnits(isLandSpace()); |
616 |
m_sizeinUnits = getSizeInUnits(); |
617 |
} |
618 |
|
619 |
/**
|
620 |
* Returns the size of sheet.
|
621 |
*
|
622 |
* @param isLand True if is horizontal and false if is vertical.
|
623 |
* @param type Type of sheet.
|
624 |
*
|
625 |
* @return Size of sheet with these properties.
|
626 |
*/
|
627 |
public Size getSizeinUnits(boolean isLand, int type) { |
628 |
Size size = null;
|
629 |
|
630 |
switch (type) {
|
631 |
case (PRINT):
|
632 |
|
633 |
if (isLand) {
|
634 |
size = new Size(METRIC_A4_PAPER_SIZE.getAncho(),
|
635 |
METRIC_A4_PAPER_SIZE.getAlto()); |
636 |
} else {
|
637 |
size = METRIC_A4_PAPER_SIZE; |
638 |
} |
639 |
|
640 |
break;
|
641 |
|
642 |
case (A4):
|
643 |
|
644 |
if (isLand) {
|
645 |
size = new Size(METRIC_A4_PAPER_SIZE.getAncho(),
|
646 |
METRIC_A4_PAPER_SIZE.getAlto()); |
647 |
} else {
|
648 |
size = METRIC_A4_PAPER_SIZE; |
649 |
} |
650 |
|
651 |
break;
|
652 |
|
653 |
case (A3):
|
654 |
|
655 |
if (isLand) {
|
656 |
size = new Size(METRIC_A3_PAPER_SIZE.getAncho(),
|
657 |
METRIC_A3_PAPER_SIZE.getAlto()); |
658 |
} else {
|
659 |
size = METRIC_A3_PAPER_SIZE; |
660 |
} |
661 |
|
662 |
break;
|
663 |
|
664 |
case (A2):
|
665 |
|
666 |
if (isLand) {
|
667 |
size = new Size(METRIC_A2_PAPER_SIZE.getAncho(),
|
668 |
METRIC_A2_PAPER_SIZE.getAlto()); |
669 |
} else {
|
670 |
size = METRIC_A2_PAPER_SIZE; |
671 |
} |
672 |
|
673 |
break;
|
674 |
|
675 |
case (A1):
|
676 |
|
677 |
if (isLand) {
|
678 |
size = new Size(METRIC_A1_PAPER_SIZE.getAncho(),
|
679 |
METRIC_A1_PAPER_SIZE.getAlto()); |
680 |
} else {
|
681 |
size = METRIC_A1_PAPER_SIZE; |
682 |
} |
683 |
|
684 |
break;
|
685 |
|
686 |
case (A0):
|
687 |
|
688 |
if (isLand) {
|
689 |
size = new Size(METRIC_A0_PAPER_SIZE.getAncho(),
|
690 |
METRIC_A0_PAPER_SIZE.getAlto()); |
691 |
} else {
|
692 |
size = METRIC_A0_PAPER_SIZE; |
693 |
} |
694 |
|
695 |
break;
|
696 |
|
697 |
case (CUSTOM):
|
698 |
|
699 |
if (isLand) {
|
700 |
size = new Size(CUSTOM_PAPER_SIZE.getAncho(),
|
701 |
CUSTOM_PAPER_SIZE.getAlto()); |
702 |
} else {
|
703 |
size = CUSTOM_PAPER_SIZE; |
704 |
} |
705 |
|
706 |
break;
|
707 |
} |
708 |
|
709 |
m_sizeinUnits = new Size(size.getAlto() / m_TypeUnit,
|
710 |
size.getAncho() / m_TypeUnit); |
711 |
|
712 |
return m_sizeinUnits;
|
713 |
} |
714 |
|
715 |
/**
|
716 |
* Retunrs the type of units is in use.
|
717 |
*
|
718 |
* @return Type of units.
|
719 |
*/
|
720 |
public int getSelTypeUnit() { |
721 |
return m_selTypeUnit;
|
722 |
} |
723 |
|
724 |
/**
|
725 |
* Returns the name of units.
|
726 |
*
|
727 |
* @return String Name of units.
|
728 |
*/
|
729 |
public String getNameUnit() { |
730 |
return m_NameUnit;
|
731 |
} |
732 |
|
733 |
/**
|
734 |
* Selecting the type of unit that is utilized in the Layout, by default is in centimetres.
|
735 |
*
|
736 |
* @param sel Type of unit.
|
737 |
*/
|
738 |
public void setUnit(int sel) { |
739 |
m_selTypeUnit = sel; |
740 |
m_TypeUnit = CHANGE[sel]; |
741 |
m_NameUnit = NAMES[sel]; |
742 |
m_numX = m_numY = new Double(UNIT[sel]); |
743 |
} |
744 |
|
745 |
/**
|
746 |
* Actualize to date m_sizeinUnits with the height and width of the sheet
|
747 |
* in the units of mediated selected.
|
748 |
*
|
749 |
* @param b True if is horizontal.
|
750 |
*/
|
751 |
public void setSizeinUnits(boolean b) { |
752 |
if (b) {
|
753 |
m_sizeinUnits = new Size(m_sizePaper.getAlto() / m_TypeUnit,
|
754 |
m_sizePaper.getAncho() / m_TypeUnit); |
755 |
} else {
|
756 |
m_sizeinUnits = new Size(m_sizePaper.getAncho() / m_TypeUnit,
|
757 |
m_sizePaper.getAlto() / m_TypeUnit); |
758 |
} |
759 |
} |
760 |
|
761 |
/**
|
762 |
* Returns a double in the unit of measure selected from the double in centimeters.
|
763 |
*
|
764 |
* @param d Distance in centimeters.
|
765 |
*
|
766 |
* @return Distance in the unit measure selected.
|
767 |
*/
|
768 |
public double toUnits(double d) { |
769 |
NumberFormat nf = NumberFormat.getInstance(); |
770 |
nf.setMaximumFractionDigits(2);
|
771 |
|
772 |
String s = String.valueOf(nf.format(d)); |
773 |
s = s.replace(',', '.'); |
774 |
|
775 |
return (Double.valueOf(s).doubleValue() / m_TypeUnit); |
776 |
} |
777 |
|
778 |
/**
|
779 |
* Returns a double in centimeters from the the unit of measure selected.
|
780 |
*
|
781 |
* @param d Distance in the unit measure selected.
|
782 |
*
|
783 |
* @return Distance in centimeters.
|
784 |
*/
|
785 |
public double fromUnits(double d) { |
786 |
return (d * m_TypeUnit);
|
787 |
} |
788 |
|
789 |
/**
|
790 |
* Returns one centimeter in pixels on screen in this moment.
|
791 |
*
|
792 |
* @param rect Rectangle of sheet.
|
793 |
*
|
794 |
* @return Pixels from centimeter.
|
795 |
*/
|
796 |
public double getPixXCm(Rectangle2D rect) { |
797 |
double value = m_sizePaper.getAncho();
|
798 |
double cm = CHANGE[2]; |
799 |
double unidades = 0; |
800 |
unidades = ((rect.getMaxX() - rect.getMinX()) /((value / cm))); |
801 |
return unidades;
|
802 |
} |
803 |
|
804 |
/**
|
805 |
* Inserts the number of pixels of one centimeter of X.
|
806 |
*
|
807 |
* @param rect Rectangle of sheet.
|
808 |
*/
|
809 |
public void setDistanceUnitX(Rectangle2D rect) { |
810 |
double value = m_sizePaper.getAncho();
|
811 |
double unidades = ((rect.getMaxX() - rect.getMinX()) / ((value / m_TypeUnit) / getNumUnitsX()));
|
812 |
m_unitX = unidades; |
813 |
} |
814 |
|
815 |
/**
|
816 |
* Inserts the number of pixels of one centimeter of Y.
|
817 |
*
|
818 |
* @param rect Rectangle of sheet.
|
819 |
*/
|
820 |
public void setDistanceUnitY(Rectangle2D rect) { |
821 |
double value = m_sizePaper.getAncho();
|
822 |
double unidades = ((rect.getMaxX() - rect.getMinX()) / ((value / m_TypeUnit) / getNumUnitsY()));
|
823 |
m_unitY = unidades; |
824 |
} |
825 |
|
826 |
/**
|
827 |
* Obtains the rectangle that represents the sheet with the characteristics
|
828 |
* that contains attributes
|
829 |
*
|
830 |
* @param rect rectangle.
|
831 |
*
|
832 |
*/
|
833 |
public void obtainRect(Rectangle2D rect) { |
834 |
double value1 = 0; |
835 |
double value2 = 0; |
836 |
|
837 |
// if (!isPrint) {
|
838 |
// if (isLandSpace()) {
|
839 |
// anchoXalto = m_sizePaper.getAncho() / m_sizePaper.getAlto();
|
840 |
// rect = getRectangleLandscape(rect, w, h);
|
841 |
// } else {
|
842 |
// anchoXalto = m_sizePaper.getAlto() / m_sizePaper.getAncho();
|
843 |
// rect = getRectanglePortrait(rect, w, h);
|
844 |
// }
|
845 |
// } else {
|
846 |
value1 = m_sizePaper.getAncho(); |
847 |
value2 = m_sizePaper.getAlto(); |
848 |
rect.setRect(0, 0, ((value1 / PULGADA) * DPI), |
849 |
((value2 / PULGADA) * DPI)); |
850 |
// }
|
851 |
|
852 |
setDistanceUnitX(rect); |
853 |
setDistanceUnitY(rect); |
854 |
} |
855 |
|
856 |
/**
|
857 |
* It obtains the rect that is adjusted to the size of the window,
|
858 |
* to see the full extent of horizontal layout.
|
859 |
*
|
860 |
* @param rect Rectangle sheet.
|
861 |
* @param w Width of Layout.
|
862 |
* @param h Height of Layout.
|
863 |
*
|
864 |
* @return Rectangle modified.
|
865 |
*/
|
866 |
public Rectangle2D.Double getRectangleLandscape(Rectangle2D rect, |
867 |
int w, int h) { |
868 |
Rectangle2D.Double rectaux = new Rectangle2D.Double(); |
869 |
int x0 = (int) rect.getMinX(); |
870 |
int y0 = (int) rect.getMinY(); |
871 |
int y1;
|
872 |
int x1;
|
873 |
y1 = (h - (2 * y0));
|
874 |
x1 = (int) (y1 * anchoXalto);
|
875 |
|
876 |
if (((int) (((h) - (2 * y0)) * anchoXalto)) > ((w) - (2 * x0))) { |
877 |
x1 = ((w) - (2 * x0));
|
878 |
y1 = (int) (x1 / anchoXalto);
|
879 |
} |
880 |
|
881 |
rectaux.setRect(x0, y0, x1, y1); |
882 |
|
883 |
return rectaux;
|
884 |
} |
885 |
|
886 |
/**
|
887 |
* Returns the size of sheet in the units of measure selected.
|
888 |
*
|
889 |
* @return Size of sheet.
|
890 |
*/
|
891 |
public Size getSizeInUnits() {
|
892 |
return m_sizeinUnits;
|
893 |
} |
894 |
|
895 |
/**
|
896 |
* It obtains the rect that is adjusted to the size of the window,
|
897 |
* to see the full extent of vertical layout.
|
898 |
*
|
899 |
* @param rect Rectangle sheet.
|
900 |
* @param w Width of Layout.
|
901 |
* @param h Height of Layout.
|
902 |
*
|
903 |
* @return Rectangle modified.
|
904 |
*/
|
905 |
public Rectangle2D.Double getRectanglePortrait(Rectangle2D rect, |
906 |
int w, int h) { |
907 |
Rectangle2D.Double rectaux = new Rectangle2D.Double(); |
908 |
int x0 = (int) rect.getMinX(); |
909 |
int y0 = (int) rect.getMinY(); |
910 |
int y1;
|
911 |
int x1;
|
912 |
x1 = (w - (2 * x0));
|
913 |
y1 = (int) (x1 * anchoXalto);
|
914 |
|
915 |
if (((int) (((w) - (2 * x0)) * anchoXalto)) > ((h) - (2 * y0))) { |
916 |
y1 = (h - (2 * y0));
|
917 |
x1 = (int) (y1 / anchoXalto);
|
918 |
} |
919 |
|
920 |
rectaux.setRect(x0, y0, x1, y1); |
921 |
|
922 |
return rectaux;
|
923 |
} |
924 |
|
925 |
/**
|
926 |
* It obtains the type of format from the size.
|
927 |
*
|
928 |
* @param size Size of sheet.
|
929 |
*
|
930 |
* @return Type of sheet.
|
931 |
*/
|
932 |
private int getTypePaper(Size size) { |
933 |
int tol = 1; |
934 |
Size auxSize = size; |
935 |
|
936 |
if (isLandSpace()) {
|
937 |
auxSize = new Size(size.getAncho(), size.getAlto());
|
938 |
} |
939 |
|
940 |
if ((((auxSize.getAncho() * PULGADA) / DPISCREEN) < (tol +
|
941 |
METRIC_A4_PAPER_SIZE.getAncho())) && |
942 |
(((auxSize.getAlto() * PULGADA) / DPISCREEN) < (tol + |
943 |
METRIC_A4_PAPER_SIZE.getAlto()))) { |
944 |
return A4;
|
945 |
} else if ((((auxSize.getAncho() * PULGADA) / DPISCREEN) < (tol + |
946 |
METRIC_A3_PAPER_SIZE.getAncho())) && |
947 |
(((auxSize.getAlto() * PULGADA) / DPISCREEN) < (tol + |
948 |
METRIC_A3_PAPER_SIZE.getAlto()))) { |
949 |
return A3;
|
950 |
} else if ((((auxSize.getAncho() * PULGADA) / DPISCREEN) < (tol + |
951 |
METRIC_A2_PAPER_SIZE.getAncho())) && |
952 |
(((auxSize.getAlto() * PULGADA) / DPISCREEN) < (tol + |
953 |
METRIC_A2_PAPER_SIZE.getAlto()))) { |
954 |
return A2;
|
955 |
} else if ((((auxSize.getAncho() * PULGADA) / DPISCREEN) < (tol + |
956 |
METRIC_A1_PAPER_SIZE.getAncho())) && |
957 |
(((auxSize.getAlto() * PULGADA) / DPISCREEN) < (tol + |
958 |
METRIC_A1_PAPER_SIZE.getAlto()))) { |
959 |
return A1;
|
960 |
} else if ((((auxSize.getAncho() * PULGADA) / DPISCREEN) < (tol + |
961 |
METRIC_A0_PAPER_SIZE.getAncho())) && |
962 |
(((auxSize.getAlto() * PULGADA) / DPISCREEN) < (tol + |
963 |
METRIC_A0_PAPER_SIZE.getAlto()))) { |
964 |
return A0;
|
965 |
} |
966 |
|
967 |
return A4;
|
968 |
} |
969 |
|
970 |
/**
|
971 |
* It returns an Object XMLEntity with the information the necessary attributes
|
972 |
* to be able later to create again the original object.
|
973 |
*
|
974 |
* @return XMLEntity.
|
975 |
*
|
976 |
*/
|
977 |
public XMLEntity getXMLEntity() {
|
978 |
XMLEntity xml = new XMLEntity();
|
979 |
xml.putProperty("className",this.getClass().getName()); |
980 |
xml.putProperty("DPI", DPI);
|
981 |
xml.putProperty("DPISCREEN", DPISCREEN);
|
982 |
xml.putProperty("m_TypeUnit", m_TypeUnit);
|
983 |
xml.putProperty("m_numX", m_numX);
|
984 |
xml.putProperty("m_numY", m_numY);
|
985 |
xml.putProperty("m_unitX", m_unitX);
|
986 |
xml.putProperty("m_unitY", m_unitY);
|
987 |
xml.putProperty("hasmargin", hasmargin);
|
988 |
xml.putProperty("m_resolutionSel", m_resolutionSel);
|
989 |
xml.putProperty("m_typeSel", m_typeSel);
|
990 |
xml.putProperty("m_selTypeUnit", m_selTypeUnit);
|
991 |
xml.addChild(m_sizePaper.getXMLEntity()); |
992 |
xml.putProperty("m_area", m_area);
|
993 |
xml.putProperty("anchoXalto", anchoXalto);
|
994 |
xml.addChild(m_sizeinUnits.getXMLEntity()); |
995 |
|
996 |
// Landscape
|
997 |
xml.putProperty("m_isLandSel", m_isLandSel);
|
998 |
|
999 |
return xml;
|
1000 |
} |
1001 |
|
1002 |
/**
|
1003 |
* It returns an Object of this class from a XMLEntity.
|
1004 |
*
|
1005 |
*
|
1006 |
* @param xml XMLEntity
|
1007 |
*
|
1008 |
* @return Object of Attributes.
|
1009 |
*/
|
1010 |
public static Attributes createAtributes(XMLEntity xml) { |
1011 |
Attributes atri = new Attributes(); |
1012 |
DPI = xml.getIntProperty("DPI");
|
1013 |
if (DPI==300){ |
1014 |
atri.m_resolution=PrintQuality.NORMAL;
|
1015 |
}else if (DPI==600){ |
1016 |
atri.m_resolution=PrintQuality.HIGH;
|
1017 |
}else if (DPI==72){ |
1018 |
atri.m_resolution=PrintQuality.DRAFT;
|
1019 |
} |
1020 |
DPISCREEN = xml.getIntProperty("DPISCREEN");
|
1021 |
atri.m_TypeUnit = xml.getDoubleProperty("m_TypeUnit");
|
1022 |
atri.setNumUnitsX(xml.getDoubleProperty("m_numX"));
|
1023 |
atri.setNumUnitsY(xml.getDoubleProperty("m_numY"));
|
1024 |
atri.m_unitX = xml.getDoubleProperty("m_unitX");
|
1025 |
atri.m_unitY = xml.getDoubleProperty("m_unitY");
|
1026 |
atri.hasmargin = xml.getBooleanProperty("hasmargin");
|
1027 |
atri.m_resolutionSel = xml.getIntProperty("m_resolutionSel");
|
1028 |
atri.m_typeSel = xml.getIntProperty("m_typeSel");
|
1029 |
atri.m_selTypeUnit = xml.getIntProperty("m_selTypeUnit");
|
1030 |
atri.m_sizePaper = Size.createSize(xml.getChild(0));
|
1031 |
|
1032 |
if (atri.hasmargin) {
|
1033 |
atri.m_area = xml.getDoubleArrayProperty("m_area");
|
1034 |
} |
1035 |
|
1036 |
atri.anchoXalto = xml.getDoubleProperty("anchoXalto");
|
1037 |
atri.m_sizeinUnits = Size.createSize(xml.getChild(1));
|
1038 |
atri.m_isLandSel = xml.getBooleanProperty("m_isLandSel");
|
1039 |
atri.setIsLandScape(atri.m_isLandSel); |
1040 |
return atri;
|
1041 |
} |
1042 |
|
1043 |
/**
|
1044 |
* It returns an Object of this class from a XMLEntity.
|
1045 |
*
|
1046 |
*
|
1047 |
* @param xml XMLEntity
|
1048 |
*
|
1049 |
* @return Object of Attributes.
|
1050 |
*/
|
1051 |
public static Attributes createAtributes03(XMLEntity xml) { |
1052 |
Attributes atri = new Attributes(); |
1053 |
DPI = xml.getIntProperty("DPI");
|
1054 |
if (DPI==300){ |
1055 |
atri.m_resolution=PrintQuality.NORMAL;
|
1056 |
}else if (DPI==600){ |
1057 |
atri.m_resolution=PrintQuality.HIGH;
|
1058 |
}else if (DPI==72){ |
1059 |
atri.m_resolution=PrintQuality.DRAFT;
|
1060 |
} |
1061 |
DPISCREEN = xml.getIntProperty("DPISCREEN");
|
1062 |
atri.m_TypeUnit = xml.getDoubleProperty("m_TypeUnit");
|
1063 |
atri.setNumUnitsX(xml.getDoubleProperty("m_numX"));
|
1064 |
atri.setNumUnitsY(xml.getDoubleProperty("m_numY"));
|
1065 |
atri.m_unitX = xml.getDoubleProperty("m_unitX");
|
1066 |
atri.m_unitY = xml.getDoubleProperty("m_unitY");
|
1067 |
atri.hasmargin = xml.getBooleanProperty("hasmargin");
|
1068 |
atri.m_resolutionSel = xml.getIntProperty("m_resolutionSel");
|
1069 |
atri.m_typeSel = xml.getIntProperty("m_typeSel");
|
1070 |
atri.m_selTypeUnit = xml.getIntProperty("m_selTypeUnit");
|
1071 |
atri.m_sizePaper = Size.createSize(xml.getChild(0));
|
1072 |
|
1073 |
if (atri.hasmargin) {
|
1074 |
atri.m_area = xml.getDoubleArrayProperty("m_area");
|
1075 |
} |
1076 |
|
1077 |
atri.anchoXalto = xml.getDoubleProperty("anchoXalto");
|
1078 |
atri.m_sizeinUnits = Size.createSize(xml.getChild(1));
|
1079 |
atri.m_isLandSel = xml.getBooleanProperty("m_isLandSel");
|
1080 |
atri.setIsLandScape(atri.m_isLandSel); |
1081 |
return atri;
|
1082 |
} |
1083 |
/**
|
1084 |
* Inserts the default number of pixels that represents a unit of grid.
|
1085 |
*
|
1086 |
* @param hGap Horizontal distance.
|
1087 |
* @param vGap Vertical distance.
|
1088 |
*/
|
1089 |
public static void setDefaultGridGap(double hGap, double vGap) { |
1090 |
defaultGridGap = new Point2D.Double(hGap, vGap); |
1091 |
} |
1092 |
/**
|
1093 |
* Returns the default number of pixels that represents a unit of grid.
|
1094 |
*
|
1095 |
* @return Number of pixels of grid.
|
1096 |
*/
|
1097 |
public static Point2D getDefaultGridGap() { |
1098 |
if (defaultGridGap == null){ |
1099 |
XMLEntity xml = PluginServices.getPluginServices("com.iver.cit.gvsig").getPersistentXML();
|
1100 |
double hGap = xml.contains("DefaultLayoutGridHorizontalGapX") ? xml.getDoubleProperty("DefaultLayoutGridHorizontalGapX"): 0.25; |
1101 |
double vGap = xml.contains("DefaultLayoutGridHorizontalGapY") ? xml.getDoubleProperty("DefaultLayoutGridHorizontalGapY"): 0.25; |
1102 |
defaultGridGap = new Point2D.Double(hGap, vGap); |
1103 |
} |
1104 |
return defaultGridGap;
|
1105 |
} |
1106 |
|
1107 |
/**
|
1108 |
* Devuelve el n?mero de pixels que representa a la unidad que est?
|
1109 |
* seleccionada.
|
1110 |
*
|
1111 |
* @return n?mero de pixels que representa la unidad seleccionada.
|
1112 |
*/
|
1113 |
public double getUnitInPixelsY() { |
1114 |
return m_unitY;
|
1115 |
} |
1116 |
|
1117 |
/**
|
1118 |
* Devuelve el n?mero de pixels que representa a la unidad que est?
|
1119 |
* seleccionada.
|
1120 |
*
|
1121 |
* @return n?mero de pixels que representa la unidad seleccionada.
|
1122 |
*/
|
1123 |
public double getUnitInPixelsX() { |
1124 |
return m_unitX;
|
1125 |
} |
1126 |
|
1127 |
} |