svn-document-layout / trunk / org.gvsig.app.document.layout2.app / org.gvsig.app.document.layout2.app.mainplugin / src / main / java / org / gvsig / app / project / documents / layout / Size.java @ 287
History | View | Annotate | Download (3.33 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.app.project.documents.layout; |
23 |
|
24 |
import org.gvsig.tools.ToolsLocator; |
25 |
import org.gvsig.tools.dynobject.DynStruct; |
26 |
import org.gvsig.tools.persistence.PersistenceManager; |
27 |
import org.gvsig.tools.persistence.Persistent; |
28 |
import org.gvsig.tools.persistence.PersistentState; |
29 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
30 |
|
31 |
/**
|
32 |
* Clase que almacena la altura y anchura de un folio.
|
33 |
*
|
34 |
* @author Vicente Caballero Navarro
|
35 |
*/
|
36 |
public class Size implements Persistent { |
37 |
|
38 |
public static final String PERSISTENCE_DEFINITION_NAME = "Size"; |
39 |
private static final String HEIGHT_FIELD = "height"; |
40 |
private static final String WIDTH_FIELD = "width"; |
41 |
|
42 |
private double alto; |
43 |
private double ancho; |
44 |
|
45 |
public Size() {
|
46 |
|
47 |
} |
48 |
|
49 |
/**
|
50 |
* Creates a new Size object.
|
51 |
*
|
52 |
* @param al
|
53 |
* Altura
|
54 |
* @param an
|
55 |
* Anchura
|
56 |
*/
|
57 |
public Size(double al, double an) { |
58 |
alto = al; |
59 |
ancho = an; |
60 |
} |
61 |
|
62 |
/**
|
63 |
* Gets the height of the sheet, measured in centimeters.
|
64 |
*
|
65 |
* @return Height.
|
66 |
*/
|
67 |
public double getHeight() { |
68 |
return alto;
|
69 |
} |
70 |
|
71 |
/**
|
72 |
* Gets the width of the sheet, measured in centimeters.
|
73 |
*
|
74 |
* @return Width of the sheet.
|
75 |
*/
|
76 |
public double getWidth() { |
77 |
return ancho;
|
78 |
} |
79 |
|
80 |
/**
|
81 |
* @deprecated Use {@link #getWidth()} instead
|
82 |
*/
|
83 |
public double getAncho() { |
84 |
return getWidth();
|
85 |
} |
86 |
/**
|
87 |
* @deprecated Use {@link #getHeight()} instead
|
88 |
*/
|
89 |
public double getAlto() { |
90 |
return getHeight();
|
91 |
} |
92 |
|
93 |
public static void registerPersistent() { |
94 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
95 |
if (manager.getDefinition(PERSISTENCE_DEFINITION_NAME) == null) { |
96 |
DynStruct definition = |
97 |
manager.addDefinition(Size.class, PERSISTENCE_DEFINITION_NAME, |
98 |
"Size persistence definition", null, null); |
99 |
|
100 |
definition.addDynFieldDouble(HEIGHT_FIELD).setMandatory(true);
|
101 |
definition.addDynFieldDouble(WIDTH_FIELD).setMandatory(true);
|
102 |
} |
103 |
} |
104 |
|
105 |
public void loadFromState(PersistentState state) |
106 |
throws PersistenceException {
|
107 |
alto = state.getDouble(HEIGHT_FIELD); |
108 |
ancho = state.getDouble(WIDTH_FIELD); |
109 |
} |
110 |
|
111 |
public void saveToState(PersistentState state) throws PersistenceException { |
112 |
state.set(HEIGHT_FIELD, alto); |
113 |
state.set(WIDTH_FIELD, ancho); |
114 |
} |
115 |
} |