Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.labeling.app / org.gvsig.labeling.app.mainplugin / src / main / java / org / gvsig / labeling / placements / MultiShapePlacementConstraints.java @ 40911

History | View | Annotate | Download (5.23 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package org.gvsig.labeling.placements;
42

    
43
import org.gvsig.fmap.mapcontext.rendering.legend.styling.IPlacementConstraints;
44
import org.gvsig.tools.ToolsLocator;
45
import org.gvsig.tools.dynobject.DynStruct;
46
import org.gvsig.tools.persistence.PersistenceManager;
47
import org.gvsig.tools.persistence.PersistentState;
48
import org.gvsig.tools.persistence.exception.PersistenceException;
49

    
50
/**
51
 *
52
 * MultiShapePlacementConstraints.java
53
 *
54
 *
55
 * @author jaume dominguez faus - jaume.dominguez@iver.es Apr 1, 2008
56
 *
57
 */
58
public class MultiShapePlacementConstraints extends AbstractPlacementConstraints {
59

    
60
        public static final String MULTI_SHAPE_PLACEMENT_CONSTRAINTS_PERSISTENCE_NAME =
61
                        "MULTI_SHAPE_PLACEMENT_CONSTRAINTS_PERSISTENCE_NAME";
62
        
63
        private PolygonPlacementConstraints polygonConstraints;
64
        private LinePlacementConstraints lineConstraints;
65
        private PointPlacementConstraints pointConstraints;
66

    
67

    
68
        public MultiShapePlacementConstraints() { }
69

    
70
        public MultiShapePlacementConstraints(
71
                        PointPlacementConstraints pointConstraints,
72
                        LinePlacementConstraints lineConstraints,
73
                        PolygonPlacementConstraints polygonConstraints) {
74
                this.pointConstraints = pointConstraints;
75
                this.lineConstraints = lineConstraints;
76
                this.polygonConstraints = polygonConstraints;
77

    
78
        }
79

    
80
        public void setPolygonConstraints(PolygonPlacementConstraints p) {
81
                this.polygonConstraints = p;
82
        }
83

    
84
        public void setLineConstraints(LinePlacementConstraints l) {
85
                this.lineConstraints = l;
86
        }
87

    
88
        public void setPointConstraints(PointPlacementConstraints p) {
89
                this.pointConstraints = p;
90
        }
91

    
92
        public PolygonPlacementConstraints getPolygonConstraints() {
93
                return polygonConstraints;
94
        }
95

    
96
        public LinePlacementConstraints getLineConstraints() {
97
                return lineConstraints;
98
        }
99

    
100
        public PointPlacementConstraints getPointConstraints() {
101
                return pointConstraints;
102
        }
103
        
104
        // ======================================
105
        
106
        public void saveToState(PersistentState state) throws PersistenceException {
107
                
108
                super.saveToState(state);
109
                state.set("pointConstraints", this.pointConstraints);
110
                state.set("lineConstraints", this.lineConstraints);
111
                state.set("polygonConstraints", this.polygonConstraints);
112
        }
113

    
114
        public void loadFromState(PersistentState state) throws PersistenceException {
115
                
116
                super.loadFromState(state);
117
                this.pointConstraints = (PointPlacementConstraints)
118
                                state.get("pointConstraints");
119
                this.lineConstraints = (LinePlacementConstraints)
120
                                state.get("lineConstraints");
121
                this.polygonConstraints = (PolygonPlacementConstraints)
122
                                state.get("polygonConstraints");
123
                
124
        }
125

    
126
        public static void registerPersistent() {
127
                
128
                PersistenceManager manager = ToolsLocator.getPersistenceManager();
129
                if( manager.getDefinition(MULTI_SHAPE_PLACEMENT_CONSTRAINTS_PERSISTENCE_NAME) == null ) {
130
                        DynStruct definition = manager.addDefinition(
131
                                        MultiShapePlacementConstraints.class,
132
                                        MULTI_SHAPE_PLACEMENT_CONSTRAINTS_PERSISTENCE_NAME,
133
                                        MULTI_SHAPE_PLACEMENT_CONSTRAINTS_PERSISTENCE_NAME +" Persistence definition",
134
                                        null, 
135
                                        null);
136
                        
137
                        definition.extend(manager.getDefinition(
138
                                        AbstractPlacementConstraints.PLACEMENT_CONSTRAINTS_PERSISTENCE_NAME));
139
                        
140
                        definition.addDynFieldObject("pointConstraints").setClassOfValue(
141
                                        PointPlacementConstraints.class).setMandatory(true);
142
                        definition.addDynFieldObject("lineConstraints").setClassOfValue(
143
                                        LinePlacementConstraints.class).setMandatory(true);
144
                        definition.addDynFieldObject("polygonConstraints").setClassOfValue(
145
                                        PolygonPlacementConstraints.class).setMandatory(true);
146
                }                
147
        }
148
        
149
        public Object clone() throws CloneNotSupportedException {
150
                
151
                
152
                PointPlacementConstraints point_co = null;
153
                LinePlacementConstraints line_co = null;
154
                PolygonPlacementConstraints poly_co = null;
155
                
156
                try {
157
                        point_co = (PointPlacementConstraints) pointConstraints.clone();
158
                        line_co = (LinePlacementConstraints) lineConstraints.clone();
159
                        poly_co = (PolygonPlacementConstraints) polygonConstraints.clone();
160
                } catch (CloneNotSupportedException ce) {
161
                        throw ce;
162
                }
163
                
164
                MultiShapePlacementConstraints resp =
165
                                new MultiShapePlacementConstraints(point_co, line_co, poly_co);
166
                return resp;
167
        }
168

    
169
}