svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.symbology / org.gvsig.symbology.lib / org.gvsig.symbology.lib.impl / src / main / java / org / gvsig / symbology / fmap / mapcontext / rendering / legend / styling / ZoomConstraintsImpl.java @ 40560
History | View | Annotate | Download (4.39 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
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 3
|
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 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
/* CVS MESSAGES:
|
25 |
*
|
26 |
* $Id: ZoomConstraintsImpl.java 10671 2007-03-09 08:33:43Z jaume $
|
27 |
* $Log$
|
28 |
* Revision 1.2 2007-03-09 08:33:43 jaume
|
29 |
* *** empty log message ***
|
30 |
*
|
31 |
* Revision 1.1.2.2 2007/02/15 16:23:44 jaume
|
32 |
* *** empty log message ***
|
33 |
*
|
34 |
* Revision 1.1.2.1 2007/02/09 07:47:05 jaume
|
35 |
* Isymbol moved
|
36 |
*
|
37 |
* Revision 1.1.2.1 2007/01/30 18:10:45 jaume
|
38 |
* start commiting labeling stuff
|
39 |
*
|
40 |
*
|
41 |
*/
|
42 |
package org.gvsig.symbology.fmap.mapcontext.rendering.legend.styling; |
43 |
|
44 |
|
45 |
import org.gvsig.fmap.mapcontext.rendering.legend.styling.IZoomConstraints; |
46 |
import org.gvsig.tools.ToolsLocator; |
47 |
import org.gvsig.tools.dynobject.DynStruct; |
48 |
import org.gvsig.tools.persistence.PersistenceManager; |
49 |
import org.gvsig.tools.persistence.PersistentState; |
50 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
51 |
import org.gvsig.tools.util.Callable; |
52 |
|
53 |
/**
|
54 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
55 |
*/
|
56 |
public class ZoomConstraintsImpl implements IZoomConstraints { |
57 |
private static final String FIELD_MIN_SCALE = "minScale"; |
58 |
private static final String FIELD_MAX_SCALE = "maxScale"; |
59 |
private static final String FIELD_MODE = "mode"; |
60 |
private static final String ZOOM_CONSTRAINTS_IMPL_PERSISTENCE_DEFINITION_NAME = |
61 |
"ZoomConstraintsImpl";
|
62 |
/**
|
63 |
* @uml.property name="mode"
|
64 |
*/
|
65 |
private int mode = DEFINED_BY_THE_LAYER; |
66 |
/**
|
67 |
* @uml.property name="minScale"
|
68 |
*/
|
69 |
private long minScale = -1; |
70 |
/**
|
71 |
* @uml.property name="maxScale"
|
72 |
*/
|
73 |
private long maxScale = -1; |
74 |
|
75 |
/**
|
76 |
* @param mode
|
77 |
* @uml.property name="mode"
|
78 |
*/
|
79 |
public void setMode(int mode) { |
80 |
if (mode != DEFINED_BY_THE_LAYER &&
|
81 |
mode != DEFINED_BY_THE_USER) |
82 |
throw new IllegalArgumentException(); |
83 |
this.mode = mode;
|
84 |
} |
85 |
|
86 |
/**
|
87 |
* @return
|
88 |
* @uml.property name="maxScale"
|
89 |
*/
|
90 |
public long getMaxScale() { |
91 |
return maxScale;
|
92 |
} |
93 |
|
94 |
/**
|
95 |
* @param maxScale
|
96 |
* @uml.property name="maxScale"
|
97 |
*/
|
98 |
public void setMaxScale(long maxScale) { |
99 |
this.maxScale = maxScale;
|
100 |
} |
101 |
|
102 |
/**
|
103 |
* @return
|
104 |
* @uml.property name="minScale"
|
105 |
*/
|
106 |
public long getMinScale() { |
107 |
return minScale;
|
108 |
} |
109 |
|
110 |
/**
|
111 |
* @param minScale
|
112 |
* @uml.property name="minScale"
|
113 |
*/
|
114 |
public void setMinScale(long minScale) { |
115 |
this.minScale = minScale;
|
116 |
} |
117 |
|
118 |
public boolean isUserDefined() { |
119 |
return mode == DEFINED_BY_THE_USER;
|
120 |
} |
121 |
|
122 |
public boolean isLayerDefined() { |
123 |
return mode == DEFINED_BY_THE_LAYER;
|
124 |
} |
125 |
|
126 |
public void loadFromState(PersistentState state) |
127 |
throws PersistenceException {
|
128 |
setMode(state.getInt(FIELD_MODE)); |
129 |
setMaxScale(state.getLong(FIELD_MAX_SCALE)); |
130 |
setMinScale(state.getLong(FIELD_MIN_SCALE)); |
131 |
} |
132 |
|
133 |
public void saveToState(PersistentState state) throws PersistenceException { |
134 |
state.set(FIELD_MODE, mode); |
135 |
state.set(FIELD_MAX_SCALE, getMaxScale()); |
136 |
state.set(FIELD_MIN_SCALE, getMinScale()); |
137 |
} |
138 |
|
139 |
public static class RegisterPersistence implements Callable { |
140 |
|
141 |
public Object call() throws Exception { |
142 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
143 |
if( manager.getDefinition(ZOOM_CONSTRAINTS_IMPL_PERSISTENCE_DEFINITION_NAME)==null ) { |
144 |
DynStruct definition = manager.addDefinition( |
145 |
ZoomConstraintsImpl.class, |
146 |
ZOOM_CONSTRAINTS_IMPL_PERSISTENCE_DEFINITION_NAME, |
147 |
ZOOM_CONSTRAINTS_IMPL_PERSISTENCE_DEFINITION_NAME+" Persistence definition",
|
148 |
null,
|
149 |
null
|
150 |
); |
151 |
definition.addDynFieldInt(FIELD_MODE).setMandatory(true);
|
152 |
definition.addDynFieldLong(FIELD_MIN_SCALE).setMandatory(true);
|
153 |
definition.addDynFieldLong(FIELD_MAX_SCALE).setMandatory(true);
|
154 |
} |
155 |
return Boolean.TRUE; |
156 |
} |
157 |
|
158 |
} |
159 |
|
160 |
|
161 |
|
162 |
} |