Revision 42286 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/MapContext.java
MapContext.java | ||
---|---|---|
3 | 3 |
* |
4 | 4 |
* Copyright (C) 2007-2013 gvSIG Association. |
5 | 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.
|
|
6 |
* This program is free software; you can redistribute it and/or modify it under
|
|
7 |
* the terms of the GNU General Public License as published by the Free Software
|
|
8 |
* Foundation; either version 3 of the License, or (at your option) any later
|
|
9 |
* version. |
|
10 | 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.
|
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
13 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
14 |
* details. |
|
15 | 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. |
|
16 |
* You should have received a copy of the GNU General Public License along with |
|
17 |
* this program; if not, write to the Free Software Foundation, Inc., 51 |
|
18 |
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
20 | 19 |
* |
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
|
20 |
* For any additional information, do not hesitate to contact us at info AT
|
|
21 |
* gvsig.com, or visit our website www.gvsig.com. |
|
23 | 22 |
*/ |
24 | 23 |
package org.gvsig.fmap.mapcontext; |
25 | 24 |
|
... | ... | |
82 | 81 |
import org.gvsig.tools.util.Callable; |
83 | 82 |
import org.gvsig.tools.visitor.Visitor; |
84 | 83 |
|
85 |
|
|
86 | 84 |
/** |
87 |
* <p>The <code>MapContext</code> class represents the model and a part of the control and view around graphical layers |
|
88 |
* used by {@link MapControl MapControl}.</p> |
|
85 |
* <p> |
|
86 |
* The <code>MapContext</code> class represents the model and a part of the |
|
87 |
* control and view around graphical layers used by |
|
88 |
* {@link MapControl MapControl}.</p> |
|
89 | 89 |
* |
90 |
* <p>An instance of <code>MapContext</code> is made up with: |
|
90 |
* <p> |
|
91 |
* An instance of <code>MapContext</code> is made up with: |
|
91 | 92 |
* <ul> |
92 | 93 |
* <li>a hierarchy of {@link FLayers FLayers} nodes |
93 | 94 |
* <li>a {@link GraphicLayer GraphicLayer} layer |
94 | 95 |
* <li>a {@link ViewPort ViewPort} |
95 | 96 |
* <li>an {@link EventBuffer EventButter} |
96 |
* <li>some {@link com.iver.cit.gvsig.fmap.layers.LegendListener LegendListener}s |
|
97 |
* <li>some |
|
98 |
* {@link com.iver.cit.gvsig.fmap.layers.LegendListener LegendListener}s |
|
97 | 99 |
* <li>some {@link LayerDrawingListener LayerDrawingListener}s |
98 | 100 |
* <li>some {@link ErrorListener ErrorListener}s |
99 | 101 |
* </ul> |
... | ... | |
102 | 104 |
* @author Fernando Gonz?lez Cort?s |
103 | 105 |
*/ |
104 | 106 |
public class MapContext extends AbstractDisposable implements Projected, |
105 |
Persistent, Observer { |
|
106 |
/** |
|
107 |
* <p>Defines the value which a unit of a distance measurement must be divided to obtain its equivalent <b>in meters</b>.</p> |
|
108 |
* |
|
109 |
* <p><b><i>Conversion values of distance measurements:</i></b> |
|
110 |
* <ul> |
|
111 |
* <li><code>MapContext.CHANGEM[0]</code>: kilometer |
|
112 |
* <li><code>MapContext.CHANGEM[1]</code>: meter |
|
113 |
* <li><code>MapContext.CHANGEM[2]</code>: centimeter |
|
114 |
* <li><code>MapContext.CHANGEM[3]</code>: millimeter |
|
115 |
* <li><code>MapContext.CHANGEM[4]</code>: international statute mile |
|
116 |
* <li><code>MapContext.CHANGEM[5]</code>: yard |
|
117 |
* <li><code>MapContext.CHANGEM[6]</code>: foot |
|
118 |
* <li><code>MapContext.CHANGEM[7]</code>: inch |
|
119 |
* <li><code>MapContext.CHANGEM[8]</code>: grade |
|
120 |
* </ul> |
|
121 |
* |
|
122 |
* <p><h3>Examples:</h3> |
|
123 |
* <pre>1 international statute mile / MapContext.CHANGEM[4] = X meters</pre> |
|
124 |
* <pre>1 kilometer / MapContext.CHANGEM[0] = X meters</pre> |
|
125 |
* <pre>1 grade / MapContext.CHANGEM[8] = X meters</pre> |
|
126 |
* </p> |
|
127 |
* |
|
128 |
* <p><h3>Grade conversion value: <code>MapContext.CHANGEM[8]</code></h3> |
|
129 |
* The value of <code>MapContext.CHANGEM[8]</code> represents the meters of a straight line between two |
|
130 |
* points on the Earth surface that are 1 grade far each other of the center of the Earth. This value has been calculated using |
|
131 |
* a radius approximated of R<sub>Earth</sub>=6.37846082678100774672e6 meters, according these equations: |
|
132 |
* <pre>D = 2 * (sin (1)) * R<sub>Earth</sub></pre> |
|
133 |
* <pre>MapContext.CHANGEM[8] = 1 / D</pre> |
|
134 |
* <h4>Explanation:</h4> |
|
135 |
* We get an isosceles triangle with the center of the Earth and the 2 points on the surface. This triangle can be divided into |
|
136 |
* two rectangle triangles. We know two values, the angle of 1 grade, that will be 0.50 grades in each triangle, and the Earth radius that |
|
137 |
* is the hypotenuse. Then we apply trigonometry and get the distance <i>D</i> between both points on the Earth surface.</p> |
|
138 |
* <p>Now we only must invert that value to obtain <code>MapContext.CHANGEM[8]</code>.</p> |
|
139 |
*@deprecated use getDistanceTrans2Meter() |
|
140 |
*/ |
|
141 |
public static final double[] CHANGEM = { 1000, 1, 0.01, 0.001, 1609.344, |
|
142 |
0.9144, 0.3048, 0.0254, 1/8.983152841195214E-6 }; |
|
107 |
Persistent, Observer { |
|
143 | 108 |
|
109 |
/** |
|
110 |
* <p> |
|
111 |
* Defines the value which a unit of a distance measurement must be divided |
|
112 |
* to obtain its equivalent <b>in meters</b>.</p> |
|
113 |
* |
|
114 |
* <p> |
|
115 |
* <b><i>Conversion values of distance measurements:</i></b> |
|
116 |
* <ul> |
|
117 |
* <li><code>MapContext.CHANGEM[0]</code>: kilometer |
|
118 |
* <li><code>MapContext.CHANGEM[1]</code>: meter |
|
119 |
* <li><code>MapContext.CHANGEM[2]</code>: centimeter |
|
120 |
* <li><code>MapContext.CHANGEM[3]</code>: millimeter |
|
121 |
* <li><code>MapContext.CHANGEM[4]</code>: international statute mile |
|
122 |
* <li><code>MapContext.CHANGEM[5]</code>: yard |
|
123 |
* <li><code>MapContext.CHANGEM[6]</code>: foot |
|
124 |
* <li><code>MapContext.CHANGEM[7]</code>: inch |
|
125 |
* <li><code>MapContext.CHANGEM[8]</code>: grade |
|
126 |
* </ul> |
|
127 |
* |
|
128 |
* <p> |
|
129 |
* <h3>Examples:</h3> |
|
130 |
* <pre>1 international statute mile / MapContext.CHANGEM[4] = X meters</pre> |
|
131 |
* <pre>1 kilometer / MapContext.CHANGEM[0] = X meters</pre> |
|
132 |
* <pre>1 grade / MapContext.CHANGEM[8] = X meters</pre> |
|
133 |
* </p> |
|
134 |
* |
|
135 |
* <p> |
|
136 |
* <h3>Grade conversion value: <code>MapContext.CHANGEM[8]</code></h3> |
|
137 |
* The value of <code>MapContext.CHANGEM[8]</code> represents the meters of |
|
138 |
* a straight line between two points on the Earth surface that are 1 grade |
|
139 |
* far each other of the center of the Earth. This value has been calculated |
|
140 |
* using a radius approximated of R<sub>Earth</sub>=6.37846082678100774672e6 |
|
141 |
* meters, according these equations: |
|
142 |
* <pre>D = 2 * (sin (1)) * R<sub>Earth</sub></pre> |
|
143 |
* <pre>MapContext.CHANGEM[8] = 1 / D</pre> |
|
144 |
* <h4>Explanation:</h4> |
|
145 |
* We get an isosceles triangle with the center of the Earth and the 2 |
|
146 |
* points on the surface. This triangle can be divided into two rectangle |
|
147 |
* triangles. We know two values, the angle of 1 grade, that will be 0.50 |
|
148 |
* grades in each triangle, and the Earth radius that is the hypotenuse. |
|
149 |
* Then we apply trigonometry and get the distance <i>D</i> between both |
|
150 |
* points on the Earth surface.</p> |
|
151 |
* <p> |
|
152 |
* Now we only must invert that value to obtain |
|
153 |
* <code>MapContext.CHANGEM[8]</code>.</p> |
|
154 |
* |
|
155 |
* @deprecated use getDistanceTrans2Meter() |
|
156 |
*/ |
|
157 |
public static final double[] CHANGEM = {1000, 1, 0.01, 0.001, 1609.344, |
|
158 |
0.9144, 0.3048, 0.0254, 1 / 8.983152841195214E-6}; |
|
144 | 159 |
|
145 |
public static ArrayList AREANAMES=new ArrayList();
|
|
146 |
public static ArrayList AREAABBR=new ArrayList();
|
|
147 |
public static ArrayList AREATRANS2METER=new ArrayList();
|
|
160 |
public static ArrayList AREANAMES = new ArrayList();
|
|
161 |
public static ArrayList AREAABBR = new ArrayList();
|
|
162 |
public static ArrayList AREATRANS2METER = new ArrayList();
|
|
148 | 163 |
|
149 |
public static ArrayList DISTANCENAMES=new ArrayList();
|
|
150 |
public static ArrayList DISTANCEABBR=new ArrayList();
|
|
151 |
public static ArrayList DISTANCETRANS2METER=new ArrayList();
|
|
164 |
public static ArrayList DISTANCENAMES = new ArrayList();
|
|
165 |
public static ArrayList DISTANCEABBR = new ArrayList();
|
|
166 |
public static ArrayList DISTANCETRANS2METER = new ArrayList();
|
|
152 | 167 |
|
153 |
static{
|
|
154 |
MapContext.addDistanceUnit("Kilometros","Km",1000);
|
|
155 |
MapContext.addDistanceUnit("Metros","m",1);
|
|
156 |
MapContext.addDistanceUnit("Centimetros","cm",0.01);
|
|
157 |
MapContext.addDistanceUnit("Milimetros","mm",0.001);
|
|
158 |
MapContext.addDistanceUnit("Millas","mi",1609.344);
|
|
159 |
MapContext.addDistanceUnit("Yardas","Ya",0.9144);
|
|
160 |
MapContext.addDistanceUnit("Pies","ft",0.3048);
|
|
161 |
MapContext.addDistanceUnit("Pulgadas","inche",0.0254);
|
|
162 |
MapContext.addDistanceUnit("Grados","?",1/8.983152841195214E-6);
|
|
168 |
static {
|
|
169 |
MapContext.addDistanceUnit("Kilometros", "Km", 1000);
|
|
170 |
MapContext.addDistanceUnit("Metros", "m", 1);
|
|
171 |
MapContext.addDistanceUnit("Centimetros", "cm", 0.01);
|
|
172 |
MapContext.addDistanceUnit("Milimetros", "mm", 0.001);
|
|
173 |
MapContext.addDistanceUnit("Millas", "mi", 1609.344);
|
|
174 |
MapContext.addDistanceUnit("Yardas", "Ya", 0.9144);
|
|
175 |
MapContext.addDistanceUnit("Pies", "ft", 0.3048);
|
|
176 |
MapContext.addDistanceUnit("Pulgadas", "inche", 0.0254);
|
|
177 |
MapContext.addDistanceUnit("Grados", "?", 1 / 8.983152841195214E-6);
|
|
163 | 178 |
|
164 |
MapContext.addAreaUnit("Kilometros","Km",true,1000);
|
|
165 |
MapContext.addAreaUnit("Metros","m",true,1);
|
|
166 |
MapContext.addAreaUnit("Centimetros","cm",true,0.01);
|
|
167 |
MapContext.addAreaUnit("Milimetros","mm",true,0.001);
|
|
168 |
MapContext.addAreaUnit("Millas","mi",true,1609.344);
|
|
169 |
MapContext.addAreaUnit("Yardas","Ya",true,0.9144);
|
|
170 |
MapContext.addAreaUnit("Pies","ft",true,0.3048);
|
|
171 |
MapContext.addAreaUnit("Pulgadas","inche",true,0.0254);
|
|
172 |
MapContext.addAreaUnit("Grados","?",true,1/8.983152841195214E-6);
|
|
179 |
MapContext.addAreaUnit("Kilometros", "Km", true, 1000);
|
|
180 |
MapContext.addAreaUnit("Metros", "m", true, 1);
|
|
181 |
MapContext.addAreaUnit("Centimetros", "cm", true, 0.01);
|
|
182 |
MapContext.addAreaUnit("Milimetros", "mm", true, 0.001);
|
|
183 |
MapContext.addAreaUnit("Millas", "mi", true, 1609.344);
|
|
184 |
MapContext.addAreaUnit("Yardas", "Ya", true, 0.9144);
|
|
185 |
MapContext.addAreaUnit("Pies", "ft", true, 0.3048);
|
|
186 |
MapContext.addAreaUnit("Pulgadas", "inche", true, 0.0254);
|
|
187 |
MapContext.addAreaUnit("Grados", "?", true, 1 / 8.983152841195214E-6);
|
|
173 | 188 |
|
174 |
|
|
175 | 189 |
} |
176 |
|
|
177 |
private static final GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
|
178 |
|
|
179 |
private static final MapContextManager mapContextManager = MapContextLocator |
|
180 |
.getMapContextManager(); |
|
181 |
|
|
182 |
private static final Logger logger = LoggerFactory.getLogger(MapContext.class); |
|
183 | 190 |
|
184 |
/** |
|
185 |
* <p>Determines the number of frames.</p> |
|
186 |
* |
|
187 |
* <p>Number of updates per second that the timer will invoke repaint this component.</p> |
|
188 |
*/ |
|
191 |
private static final GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
|
192 |
|
|
193 |
private static final MapContextManager mapContextManager = MapContextLocator |
|
194 |
.getMapContextManager(); |
|
195 |
|
|
196 |
private static final Logger logger = LoggerFactory.getLogger(MapContext.class); |
|
197 |
|
|
198 |
/** |
|
199 |
* <p> |
|
200 |
* Determines the number of frames.</p> |
|
201 |
* |
|
202 |
* <p> |
|
203 |
* Number of updates per second that the timer will invoke repaint this |
|
204 |
* component.</p> |
|
205 |
*/ |
|
189 | 206 |
private static int drawFrameRate = 3; |
207 |
|
|
190 | 208 |
/** |
191 |
* <p>Returns the draw frame rate.</p> |
|
192 |
* |
|
193 |
* <p>Draw frame rate is the number of repaints of this <code>MapControl</code> instance that timer invokes per second.</p> |
|
194 |
* |
|
195 |
* @return number of repaints of this <code>MapControl</code> instance that timer invokes per second |
|
196 |
* |
|
197 |
* @see #applyFrameRate() |
|
198 |
* @see #setDrawFrameRate(int) |
|
199 |
*/ |
|
200 |
public static int getDrawFrameRate() { |
|
201 |
return drawFrameRate; |
|
202 |
} |
|
209 |
* <p> |
|
210 |
* Returns the draw frame rate.</p> |
|
211 |
* |
|
212 |
* <p> |
|
213 |
* Draw frame rate is the number of repaints of this <code>MapControl</code> |
|
214 |
* instance that timer invokes per second.</p> |
|
215 |
* |
|
216 |
* @return number of repaints of this <code>MapControl</code> instance that |
|
217 |
* timer invokes per second |
|
218 |
* |
|
219 |
* @see #applyFrameRate() |
|
220 |
* @see #setDrawFrameRate(int) |
|
221 |
*/ |
|
222 |
public static int getDrawFrameRate() { |
|
223 |
return drawFrameRate; |
|
224 |
} |
|
203 | 225 |
|
204 |
/** |
|
205 |
* <p>Sets the draw frame rate.</p> |
|
206 |
* |
|
207 |
* <p>Draw frame rate is the number of repaints of this <code>MapControl</code> instance that timer invokes per second.</p> |
|
208 |
* |
|
209 |
* @param drawFrameRate number of repaints of this <code>MapControl</code> instance that timer invokes per second |
|
210 |
* |
|
211 |
* @see #applyFrameRate() |
|
212 |
* @see #getDrawFrameRate() |
|
213 |
*/ |
|
214 |
public static void setDrawFrameRate(int dFR) { |
|
215 |
drawFrameRate = dFR; |
|
216 |
} |
|
217 |
public static void addAreaUnit(String name, String abbr,boolean isLinear,double trans2meter){ |
|
218 |
if (!AREANAMES.contains(name)){ |
|
219 |
AREANAMES.add(name); |
|
220 |
String pow=""; |
|
221 |
if (isLinear) { |
|
222 |
pow=String.valueOf((char)178); |
|
223 |
} |
|
224 |
AREAABBR.add(abbr+pow); |
|
225 |
AREATRANS2METER.add(new Double(trans2meter)); |
|
226 |
} |
|
227 |
} |
|
228 |
public static String[] getAreaNames(){ |
|
229 |
return (String[])AREANAMES.toArray(new String[0]); |
|
230 |
} |
|
231 |
public static String[] getAreaAbbr(){ |
|
232 |
return (String[])AREAABBR.toArray(new String[0]); |
|
233 |
} |
|
234 |
public static double[] getAreaTrans2Meter(){ |
|
235 |
int size=AREATRANS2METER.size(); |
|
236 |
double[] trans2meters=new double[size]; |
|
237 |
for (int i = 0; i < size; i++) { |
|
238 |
trans2meters[i]=((Double)AREATRANS2METER.get(i)).doubleValue(); |
|
239 |
} |
|
240 |
return trans2meters; |
|
241 |
} |
|
242 |
public static String getOfLinear(int i) { |
|
243 |
if (((String)AREAABBR.get(i)).toLowerCase().endsWith(String.valueOf((char)178))){ |
|
244 |
return String.valueOf((char)178); |
|
245 |
} |
|
246 |
return ""; |
|
247 |
} |
|
248 |
public static void addDistanceUnit(String name, String abbr,double trans2meter){ |
|
249 |
if (!DISTANCENAMES.contains(name)){ |
|
250 |
DISTANCENAMES.add(name); |
|
251 |
DISTANCEABBR.add(abbr); |
|
252 |
DISTANCETRANS2METER.add(new Double(trans2meter)); |
|
253 |
} |
|
254 |
} |
|
255 |
public static String[] getDistanceNames(){ |
|
256 |
return (String[])DISTANCENAMES.toArray(new String[0]); |
|
257 |
} |
|
258 |
|
|
259 |
public String getDistanceName() { |
|
260 |
return (String) DISTANCENAMES.get( this.getViewPort().getDistanceUnits() ); |
|
261 |
} |
|
262 |
|
|
263 |
public static String[] getDistanceAbbr(){ |
|
264 |
return (String[])DISTANCEABBR.toArray(new String[0]); |
|
265 |
} |
|
266 |
public static double[] getDistanceTrans2Meter(){ |
|
267 |
int size=DISTANCETRANS2METER.size(); |
|
268 |
double[] trans2meters=new double[size]; |
|
269 |
for (int i = 0; i < size; i++) { |
|
270 |
trans2meters[i]=((Double)DISTANCETRANS2METER.get(i)).doubleValue(); |
|
271 |
} |
|
272 |
return trans2meters; |
|
273 |
} |
|
274 |
public static int getDistancePosition(String s){ |
|
275 |
for (int i = 0; i < DISTANCENAMES.size(); i++) { |
|
276 |
if (DISTANCENAMES.get(i).equals(s)){ |
|
277 |
return i; |
|
278 |
} |
|
279 |
} |
|
280 |
return 0; |
|
281 |
} |
|
226 |
/** |
|
227 |
* <p> |
|
228 |
* Sets the draw frame rate.</p> |
|
229 |
* |
|
230 |
* <p> |
|
231 |
* Draw frame rate is the number of repaints of this <code>MapControl</code> |
|
232 |
* instance that timer invokes per second.</p> |
|
233 |
* |
|
234 |
* @param drawFrameRate number of repaints of this <code>MapControl</code> |
|
235 |
* instance that timer invokes per second |
|
236 |
* |
|
237 |
* @see #applyFrameRate() |
|
238 |
* @see #getDrawFrameRate() |
|
239 |
*/ |
|
240 |
public static void setDrawFrameRate(int dFR) { |
|
241 |
drawFrameRate = dFR; |
|
242 |
} |
|
282 | 243 |
|
283 |
/** |
|
284 |
* <p>Defines the value which a unit of a distance measurement must be divided to obtain its equivalent <b>in centimeters</b>.</p> |
|
285 |
* |
|
286 |
* <p><b><i>Conversion values of distance measurements:</i></b> |
|
287 |
* <ul> |
|
288 |
* <li><code>MapContext.CHANGE[0]</code>: kilometer |
|
289 |
* <li><code>MapContext.CHANGE[1]</code>: meter |
|
290 |
* <li><code>MapContext.CHANGE[2]</code>: centimeter |
|
291 |
* <li><code>MapContext.CHANGE[3]</code>: millimeter |
|
292 |
* <li><code>MapContext.CHANGE[4]</code>: international statute mile |
|
293 |
* <li><code>MapContext.CHANGE[5]</code>: yard |
|
294 |
* <li><code>MapContext.CHANGE[6]</code>: foot |
|
295 |
* <li><code>MapContext.CHANGE[7]</code>: inch |
|
296 |
* <li><code>MapContext.CHANGE[8]</code>: grade |
|
297 |
* </ul> |
|
298 |
* |
|
299 |
* <p><h3>Examples:</h3> |
|
300 |
* <pre>1 international statute mile / MapContext.CHANGE[4] = X centimeters</pre> |
|
301 |
* <pre>1 kilometer / MapContext.CHANGE[0] = X centimeters</pre> |
|
302 |
* <pre>1 grade / MapContext.CHANGE[8] = X centimeters</pre> |
|
303 |
* </p> |
|
304 |
* |
|
305 |
* <p><h3>Grade conversion value: <code>MapContext.CHANGE[8]</code></h3> |
|
306 |
* The value of <code>MapContext.CHANGE[8]</code> represents the centimeters of a straight line between two |
|
307 |
* points on the Earth surface that are 1 grade far each other of the center of the Earth. This value has been calculated using |
|
308 |
* a radius approximated of R<sub>Earth</sub>=6.37846082678100774672e6 meters, according these equations: |
|
309 |
* <pre>D = 2 * (sin (1)) * R<sub>Earth</sub></pre> |
|
310 |
* <pre>MapContext.CHANGE[8] = 1 / D</pre> |
|
311 |
* <h4>Explanation:</h4> |
|
312 |
* We get an isosceles triangle with the center of the Earth and the 2 points on the surface. This triangle can be divided into |
|
313 |
* two rectangle triangles. We know two values, the angle of 1 grade, that will be 0.50 grades in each triangle, and the Earth radius that |
|
314 |
* is the hypotenuse. Then we apply trigonometry and get the distance <i>D</i> between both points on the Earth surface.</p> |
|
315 |
* <p>Now we only must invert that value to obtain <code>MapContext.CHANGE[8]</code>.</p> |
|
316 |
* @deprecated use getDistanceTrans2Meter() * 100 |
|
317 |
*/ |
|
318 |
public static final double[] CHANGE = { 100000, 100, 1, 0.1, 160934.4, |
|
319 |
91.44, 30.48, 2.54, 1/8.983152841195214E-4 }; |
|
244 |
public static void addAreaUnit(String name, String abbr, boolean isLinear, double trans2meter) { |
|
245 |
if (!AREANAMES.contains(name)) { |
|
246 |
AREANAMES.add(name); |
|
247 |
String pow = ""; |
|
248 |
if (isLinear) { |
|
249 |
pow = String.valueOf((char) 178); |
|
250 |
} |
|
251 |
AREAABBR.add(abbr + pow); |
|
252 |
AREATRANS2METER.add(new Double(trans2meter)); |
|
253 |
} |
|
254 |
} |
|
320 | 255 |
|
321 |
/* Do not alter the order and the values of this array, if you need append values.*/ |
|
322 |
/** |
|
323 |
* <p>Gets the name of all distance measurements supported by <code>MapContext</code>.</p> |
|
324 |
*/ |
|
256 |
public static String[] getAreaNames() { |
|
257 |
return (String[]) AREANAMES.toArray(new String[0]); |
|
258 |
} |
|
259 |
|
|
260 |
public static String[] getAreaAbbr() { |
|
261 |
return (String[]) AREAABBR.toArray(new String[0]); |
|
262 |
} |
|
263 |
|
|
264 |
public static double[] getAreaTrans2Meter() { |
|
265 |
int size = AREATRANS2METER.size(); |
|
266 |
double[] trans2meters = new double[size]; |
|
267 |
for (int i = 0; i < size; i++) { |
|
268 |
trans2meters[i] = ((Double) AREATRANS2METER.get(i)).doubleValue(); |
|
269 |
} |
|
270 |
return trans2meters; |
|
271 |
} |
|
272 |
|
|
273 |
public static String getOfLinear(int i) { |
|
274 |
if (((String) AREAABBR.get(i)).toLowerCase().endsWith(String.valueOf((char) 178))) { |
|
275 |
return String.valueOf((char) 178); |
|
276 |
} |
|
277 |
return ""; |
|
278 |
} |
|
279 |
|
|
280 |
public static void addDistanceUnit(String name, String abbr, double trans2meter) { |
|
281 |
if (!DISTANCENAMES.contains(name)) { |
|
282 |
DISTANCENAMES.add(name); |
|
283 |
DISTANCEABBR.add(abbr); |
|
284 |
DISTANCETRANS2METER.add(new Double(trans2meter)); |
|
285 |
} |
|
286 |
} |
|
287 |
|
|
288 |
public static String[] getDistanceNames() { |
|
289 |
return (String[]) DISTANCENAMES.toArray(new String[0]); |
|
290 |
} |
|
291 |
|
|
292 |
public String getDistanceName() { |
|
293 |
return (String) DISTANCENAMES.get(this.getViewPort().getDistanceUnits()); |
|
294 |
} |
|
295 |
|
|
296 |
public static String[] getDistanceAbbr() { |
|
297 |
return (String[]) DISTANCEABBR.toArray(new String[0]); |
|
298 |
} |
|
299 |
|
|
300 |
public static double[] getDistanceTrans2Meter() { |
|
301 |
int size = DISTANCETRANS2METER.size(); |
|
302 |
double[] trans2meters = new double[size]; |
|
303 |
for (int i = 0; i < size; i++) { |
|
304 |
trans2meters[i] = ((Double) DISTANCETRANS2METER.get(i)).doubleValue(); |
|
305 |
} |
|
306 |
return trans2meters; |
|
307 |
} |
|
308 |
|
|
309 |
public static int getDistancePosition(String s) { |
|
310 |
for (int i = 0; i < DISTANCENAMES.size(); i++) { |
|
311 |
if (DISTANCENAMES.get(i).equals(s)) { |
|
312 |
return i; |
|
313 |
} |
|
314 |
} |
|
315 |
return 0; |
|
316 |
} |
|
317 |
|
|
318 |
/** |
|
319 |
* <p> |
|
320 |
* Defines the value which a unit of a distance measurement must be divided |
|
321 |
* to obtain its equivalent <b>in centimeters</b>.</p> |
|
322 |
* |
|
323 |
* <p> |
|
324 |
* <b><i>Conversion values of distance measurements:</i></b> |
|
325 |
* <ul> |
|
326 |
* <li><code>MapContext.CHANGE[0]</code>: kilometer |
|
327 |
* <li><code>MapContext.CHANGE[1]</code>: meter |
|
328 |
* <li><code>MapContext.CHANGE[2]</code>: centimeter |
|
329 |
* <li><code>MapContext.CHANGE[3]</code>: millimeter |
|
330 |
* <li><code>MapContext.CHANGE[4]</code>: international statute mile |
|
331 |
* <li><code>MapContext.CHANGE[5]</code>: yard |
|
332 |
* <li><code>MapContext.CHANGE[6]</code>: foot |
|
333 |
* <li><code>MapContext.CHANGE[7]</code>: inch |
|
334 |
* <li><code>MapContext.CHANGE[8]</code>: grade |
|
335 |
* </ul> |
|
336 |
* |
|
337 |
* <p> |
|
338 |
* <h3>Examples:</h3> |
|
339 |
* <pre>1 international statute mile / MapContext.CHANGE[4] = X centimeters</pre> |
|
340 |
* <pre>1 kilometer / MapContext.CHANGE[0] = X centimeters</pre> |
|
341 |
* <pre>1 grade / MapContext.CHANGE[8] = X centimeters</pre> |
|
342 |
* </p> |
|
343 |
* |
|
344 |
* <p> |
|
345 |
* <h3>Grade conversion value: <code>MapContext.CHANGE[8]</code></h3> |
|
346 |
* The value of <code>MapContext.CHANGE[8]</code> represents the centimeters |
|
347 |
* of a straight line between two points on the Earth surface that are 1 |
|
348 |
* grade far each other of the center of the Earth. This value has been |
|
349 |
* calculated using a radius approximated of |
|
350 |
* R<sub>Earth</sub>=6.37846082678100774672e6 meters, according these |
|
351 |
* equations: |
|
352 |
* <pre>D = 2 * (sin (1)) * R<sub>Earth</sub></pre> |
|
353 |
* <pre>MapContext.CHANGE[8] = 1 / D</pre> |
|
354 |
* <h4>Explanation:</h4> |
|
355 |
* We get an isosceles triangle with the center of the Earth and the 2 |
|
356 |
* points on the surface. This triangle can be divided into two rectangle |
|
357 |
* triangles. We know two values, the angle of 1 grade, that will be 0.50 |
|
358 |
* grades in each triangle, and the Earth radius that is the hypotenuse. |
|
359 |
* Then we apply trigonometry and get the distance <i>D</i> between both |
|
360 |
* points on the Earth surface.</p> |
|
361 |
* <p> |
|
362 |
* Now we only must invert that value to obtain |
|
363 |
* <code>MapContext.CHANGE[8]</code>.</p> |
|
364 |
* |
|
365 |
* @deprecated use getDistanceTrans2Meter() * 100 |
|
366 |
*/ |
|
367 |
public static final double[] CHANGE = {100000, 100, 1, 0.1, 160934.4, |
|
368 |
91.44, 30.48, 2.54, 1 / 8.983152841195214E-4}; |
|
369 |
|
|
370 |
/* Do not alter the order and the values of this array, if you need append values.*/ |
|
371 |
/** |
|
372 |
* <p> |
|
373 |
* Gets the name of all distance measurements supported by |
|
374 |
* <code>MapContext</code>.</p> |
|
375 |
*/ |
|
325 | 376 |
// public static final String[] NAMES= { |
326 | 377 |
// Messages.getString("Kilometros"), |
327 | 378 |
// Messages.getString("Metros"), |
... | ... | |
333 | 384 |
// Messages.getString("Pulgadas"), |
334 | 385 |
// Messages.getString("Grados"), |
335 | 386 |
// }; |
387 |
public static final int EQUALS = 0; |
|
336 | 388 |
|
337 |
public static final int EQUALS = 0;
|
|
389 |
public static final int DISJOINT = 1;
|
|
338 | 390 |
|
339 |
public static final int DISJOINT = 1;
|
|
391 |
public static final int INTERSECTS = 2;
|
|
340 | 392 |
|
341 |
public static final int INTERSECTS = 2;
|
|
393 |
public static final int TOUCHES = 3;
|
|
342 | 394 |
|
343 |
public static final int TOUCHES = 3;
|
|
395 |
public static final int CROSSES = 4;
|
|
344 | 396 |
|
345 |
public static final int CROSSES = 4;
|
|
397 |
public static final int WITHIN = 5;
|
|
346 | 398 |
|
347 |
public static final int WITHIN = 5;
|
|
399 |
public static final int CONTAINS = 6;
|
|
348 | 400 |
|
349 |
public static final int CONTAINS = 6;
|
|
401 |
public static final int OVERLAPS = 7;
|
|
350 | 402 |
|
351 |
public static final int OVERLAPS = 7; |
|
403 |
/** |
|
404 |
* A hierarchy of {@link FLayers FLayers} nodes. |
|
405 |
* |
|
406 |
* @see #getLayers() |
|
407 |
* @see #print(Graphics2D, double, PrintAttributes) |
|
408 |
*/ |
|
409 |
protected FLayers layers; |
|
352 | 410 |
|
353 |
/** |
|
354 |
* A hierarchy of {@link FLayers FLayers} nodes. |
|
355 |
* |
|
356 |
* @see #getLayers() |
|
357 |
* @see #print(Graphics2D, double, PrintAttributes) |
|
358 |
*/ |
|
359 |
protected FLayers layers; |
|
411 |
/** |
|
412 |
* A layer with graphical items: geometries and symbols. |
|
413 |
* |
|
414 |
* @see #getGraphicsLayer() |
|
415 |
* @see #setGraphicsLayer(GraphicLayer) |
|
416 |
* @see #print(Graphics2D, double, PrintAttributes) |
|
417 |
*/ |
|
418 |
private GraphicLayer tracLayer = null; |
|
419 |
//MapContextLocator.getMapContextManager().createGraphicsLayer(getProjection()); |
|
360 | 420 |
|
361 |
/** |
|
362 |
* A layer with graphical items: geometries and symbols. |
|
363 |
* |
|
364 |
* @see #getGraphicsLayer() |
|
365 |
* @see #setGraphicsLayer(GraphicLayer) |
|
366 |
* @see #print(Graphics2D, double, PrintAttributes) |
|
367 |
*/ |
|
368 |
private GraphicLayer tracLayer = null; |
|
369 |
//MapContextLocator.getMapContextManager().createGraphicsLayer(getProjection()); |
|
421 |
/** |
|
422 |
* Information for draw layers in a view. |
|
423 |
* |
|
424 |
* @see #getViewPort() |
|
425 |
* @see #setViewPort(ViewPort) |
|
426 |
*/ |
|
427 |
private ViewPort viewPort; |
|
370 | 428 |
|
371 |
/** |
|
372 |
* Information for draw layers in a view. |
|
373 |
* |
|
374 |
* @see #getViewPort() |
|
375 |
* @see #setViewPort(ViewPort) |
|
376 |
*/ |
|
377 |
private ViewPort viewPort; |
|
378 |
|
|
379 | 429 |
// private ArrayList invalidationListeners = new ArrayList(); |
430 |
/** |
|
431 |
* Array list with all {@link LegendListener LegendListener} registered to |
|
432 |
* this map. |
|
433 |
* |
|
434 |
* @see #addLayerListener(LegendListener) |
|
435 |
* @see #removeLayerListener(LegendListener) |
|
436 |
* @see #callLegendChanged() |
|
437 |
*/ |
|
438 |
private ArrayList legendListeners = new ArrayList(); |
|
380 | 439 |
|
381 |
/** |
|
382 |
* Array list with all {@link LegendListener LegendListener} registered to this map. |
|
383 |
* |
|
384 |
* @see #addLayerListener(LegendListener) |
|
385 |
* @see #removeLayerListener(LegendListener) |
|
386 |
* @see #callLegendChanged() |
|
387 |
*/ |
|
388 |
private ArrayList legendListeners = new ArrayList(); |
|
440 |
/** |
|
441 |
* Array list with all {@link LayerDrawingListener LayerDrawingListener} |
|
442 |
* registered to this map. |
|
443 |
* |
|
444 |
* @see #addLayerDrawingListener(LayerDrawingListener) |
|
445 |
* @see #removeLayerDrawListener(LayerDrawingListener) |
|
446 |
* @see #fireLayerDrawingEvent(LayerDrawEvent) |
|
447 |
*/ |
|
448 |
private ArrayList layerDrawingListeners = new ArrayList(); |
|
389 | 449 |
|
390 |
/** |
|
391 |
* Array list with all {@link LayerDrawingListener LayerDrawingListener} registered to this map. |
|
392 |
* |
|
393 |
* @see #addLayerDrawingListener(LayerDrawingListener) |
|
394 |
* @see #removeLayerDrawListener(LayerDrawingListener) |
|
395 |
* @see #fireLayerDrawingEvent(LayerDrawEvent) |
|
396 |
*/ |
|
397 |
private ArrayList layerDrawingListeners = new ArrayList(); |
|
450 |
/** |
|
451 |
* <p> |
|
452 |
* Buffer that is used to store and eject events produced on this map: |
|
453 |
* <ul> |
|
454 |
* <li>Layer collection events. |
|
455 |
* <li>View port events. |
|
456 |
* <li>Atomic events. |
|
457 |
* <li>Layer events. |
|
458 |
* <li>Legend events on a {@link Classificable Classificable} layer. |
|
459 |
* <li>Selection events on an {@link AlphanumericData AlphanumericData} data |
|
460 |
* layer. |
|
461 |
* </ul> |
|
462 |
* </p> |
|
463 |
* |
|
464 |
* @see #addAtomicEventListener(AtomicEventListener) |
|
465 |
* @see #removeAtomicEventListener(AtomicEventListener) |
|
466 |
* @see #beginAtomicEvent() |
|
467 |
* @see #endAtomicEvent() |
|
468 |
*/ |
|
469 |
private EventBuffer eventBuffer = new EventBuffer(); |
|
398 | 470 |
|
399 |
/** |
|
400 |
* <p>Buffer that is used to store and eject events produced on this map: |
|
401 |
* <ul> |
|
402 |
* <li>Layer collection events. |
|
403 |
* <li>View port events. |
|
404 |
* <li>Atomic events. |
|
405 |
* <li>Layer events. |
|
406 |
* <li>Legend events on a {@link Classificable Classificable} layer. |
|
407 |
* <li>Selection events on an {@link AlphanumericData AlphanumericData} data layer. |
|
408 |
* </ul> |
|
409 |
* </p> |
|
410 |
* |
|
411 |
* @see #addAtomicEventListener(AtomicEventListener) |
|
412 |
* @see #removeAtomicEventListener(AtomicEventListener) |
|
413 |
* @see #beginAtomicEvent() |
|
414 |
* @see #endAtomicEvent() |
|
415 |
*/ |
|
416 |
private EventBuffer eventBuffer = new EventBuffer(); |
|
471 |
/** |
|
472 |
* Event listener for the collection of layers of this map. |
|
473 |
*/ |
|
474 |
private LayerEventListener layerEventListener = null; |
|
417 | 475 |
|
418 |
/** |
|
419 |
* Event listener for the collection of layers of this map. |
|
420 |
*/ |
|
421 |
private LayerEventListener layerEventListener = null; |
|
476 |
/** |
|
477 |
* List with information of all errors produced on all layers. |
|
478 |
* |
|
479 |
* @see #addLayerError(String) |
|
480 |
* @see #getLayersError() |
|
481 |
* @see #clearErrors() |
|
482 |
*/ |
|
483 |
private ArrayList layersError = new ArrayList(); |
|
422 | 484 |
|
423 |
/** |
|
424 |
* List with information of all errors produced on all layers. |
|
425 |
* |
|
426 |
* @see #addLayerError(String) |
|
427 |
* @see #getLayersError() |
|
428 |
* @see #clearErrors() |
|
429 |
*/ |
|
430 |
private ArrayList layersError = new ArrayList(); |
|
485 |
/** |
|
486 |
* Array list with all {@link ErrorListener ErrorListener} registered to |
|
487 |
* this map. |
|
488 |
* |
|
489 |
* @see #addErrorListener(ErrorListener) |
|
490 |
* @see #removeErrorListener(LegendListener) |
|
491 |
* @see #reportDriverExceptions(String, List) |
|
492 |
*/ |
|
493 |
private ArrayList errorListeners = new ArrayList(); |
|
431 | 494 |
|
432 |
/** |
|
433 |
* Array list with all {@link ErrorListener ErrorListener} registered to this map. |
|
434 |
* |
|
435 |
* @see #addErrorListener(ErrorListener) |
|
436 |
* @see #removeErrorListener(LegendListener) |
|
437 |
* @see #reportDriverExceptions(String, List) |
|
438 |
*/ |
|
439 |
private ArrayList errorListeners = new ArrayList(); |
|
440 |
|
|
441 |
|
|
442 |
|
|
443 |
|
|
444 |
/** |
|
445 |
* Layer order manager decides position of layers added to this |
|
446 |
* map context. |
|
447 |
*/ |
|
495 |
/** |
|
496 |
* Layer order manager decides position of layers added to this map context. |
|
497 |
*/ |
|
448 | 498 |
private LayerOrderManager orderManager = null; |
449 | 499 |
|
450 |
|
|
451 |
|
|
452 |
|
|
453 | 500 |
// public static ResourceBundle myResourceBundle = |
454 |
// ResourceBundle.getBundle("FMap"); |
|
501 |
// ResourceBundle.getBundle("FMap"); |
|
502 |
/** |
|
503 |
* <p> |
|
504 |
* Default <i>zoom in</i> factor.</p> |
|
505 |
* <p> |
|
506 |
* Doing a <i>zoom in</i> operation, decreases the focal distance and |
|
507 |
* increases the eyesight angle to the surface. This allows view an smaller |
|
508 |
* area but with the items bigger.</p> |
|
509 |
*/ |
|
510 |
public static double ZOOMINFACTOR = 2; |
|
455 | 511 |
|
456 |
/** |
|
457 |
* <p>Default <i>zoom in</i> factor.</p> |
|
458 |
* <p>Doing a <i>zoom in</i> operation, decreases the focal distance and increases the eyesight angle to the surface. This allows view an smaller |
|
459 |
* area but with the items bigger.</p> |
|
460 |
*/ |
|
461 |
public static double ZOOMINFACTOR=2; |
|
512 |
/** |
|
513 |
* <p> |
|
514 |
* Default <i>zoom out</i> factor.</p> |
|
515 |
* <p> |
|
516 |
* Doing a <i>zoom out</i> operation, increases the focal distance and |
|
517 |
* decreases the eyesight angle to the surface. This allows view a bigger |
|
518 |
* area but with the items smaller.</p> |
|
519 |
*/ |
|
520 |
public static double ZOOMOUTFACTOR = 0.5; |
|
462 | 521 |
|
463 |
/** |
|
464 |
* <p>Default <i>zoom out</i> factor.</p> |
|
465 |
* <p>Doing a <i>zoom out</i> operation, increases the focal distance and decreases the eyesight angle to the surface. This allows view a bigger |
|
466 |
* area but with the items smaller.</p> |
|
467 |
*/ |
|
468 |
public static double ZOOMOUTFACTOR=0.5; |
|
522 |
/** |
|
523 |
* * Draw version of the context. It's used for know when de componend has |
|
524 |
* changed any visualization property |
|
525 |
* |
|
526 |
* @see getDrawVersion |
|
527 |
* @see updateDrawVersion |
|
528 |
*/ |
|
529 |
private long drawVersion = 0L; |
|
469 | 530 |
|
470 |
/** |
|
471 |
* * Draw version of the context. It's used for know when de componend has |
|
472 |
* changed any visualization property |
|
473 |
* |
|
474 |
* @see getDrawVersion |
|
475 |
* @see updateDrawVersion |
|
476 |
*/ |
|
477 |
private long drawVersion= 0L; |
|
478 |
|
|
479 |
private long layersVersion = 0L; |
|
480 |
private long viewPortVersion = 0L; |
|
481 |
private long graphicsLayerVersion = 0L; |
|
531 |
private long layersVersion = 0L; |
|
532 |
private long viewPortVersion = 0L; |
|
533 |
private long graphicsLayerVersion = 0L; |
|
482 | 534 |
|
483 |
/**
|
|
484 |
* Object to Manage Draw of MapContext
|
|
485 |
*/
|
|
486 |
private MapContextDrawer mapContextDrawer= null;
|
|
535 |
/**
|
|
536 |
* Object to Manage Draw of MapContext
|
|
537 |
*/
|
|
538 |
private MapContextDrawer mapContextDrawer = null;
|
|
487 | 539 |
|
488 |
/**
|
|
489 |
* Object to Manage Draw of MapContext
|
|
490 |
*/
|
|
491 |
private Class mapContextDrawerClass = null;
|
|
540 |
/**
|
|
541 |
* Object to Manage Draw of MapContext
|
|
542 |
*/
|
|
543 |
private Class mapContextDrawerClass = null;
|
|
492 | 544 |
|
493 |
/** |
|
494 |
* <p>Color used to represent the selections.</p> |
|
495 |
*/ |
|
496 |
private static Color selectionColor = Color.YELLOW; |
|
497 |
private ArrayList layersToSnap = new ArrayList(); |
|
545 |
/** |
|
546 |
* <p> |
|
547 |
* Color used to represent the selections.</p> |
|
548 |
*/ |
|
549 |
private static Color selectionColor = Color.YELLOW; |
|
550 |
private ArrayList layersToSnap = new ArrayList(); |
|
498 | 551 |
|
552 |
/** |
|
553 |
* <p> |
|
554 |
* Gets the color used to represent the selections.</p> |
|
555 |
* |
|
556 |
* @return color used to represent the selections |
|
557 |
*/ |
|
558 |
public static Color getSelectionColor() { |
|
559 |
return selectionColor; |
|
560 |
} |
|
499 | 561 |
|
500 |
/** |
|
501 |
* <p>Gets the color used to represent the selections.</p> |
|
502 |
* |
|
503 |
* @return color used to represent the selections |
|
504 |
*/ |
|
505 |
public static Color getSelectionColor() { |
|
506 |
return selectionColor; |
|
507 |
} |
|
562 |
/** |
|
563 |
* <p> |
|
564 |
* Sets the color used to represent the selections.</p> |
|
565 |
* |
|
566 |
* @param selectionColor color used to represent the selections |
|
567 |
*/ |
|
568 |
public static void setSelectionColor(Color selectionColor) { |
|
569 |
MapContext.selectionColor = selectionColor; |
|
570 |
} |
|
508 | 571 |
|
509 |
/** |
|
510 |
* <p>Sets the color used to represent the selections.</p> |
|
511 |
* |
|
512 |
* @param selectionColor color used to represent the selections |
|
513 |
*/ |
|
514 |
public static void setSelectionColor(Color selectionColor) { |
|
515 |
MapContext.selectionColor = selectionColor; |
|
516 |
} |
|
517 |
|
|
518 |
/** |
|
519 |
* <p>Creates a new map context with the drawing information defined in the view port argument, and |
|
520 |
* without layers.</p> |
|
521 |
* |
|
522 |
* @param vp information for drawing the layers of this map in the available rectangular area according a projection |
|
523 |
*/ |
|
524 |
public MapContext(ViewPort vp) { |
|
572 |
/** |
|
573 |
* <p> |
|
574 |
* Creates a new map context with the drawing information defined in the |
|
575 |
* view port argument, and without layers.</p> |
|
576 |
* |
|
577 |
* @param vp information for drawing the layers of this map in the available |
|
578 |
* rectangular area according a projection |
|
579 |
*/ |
|
580 |
public MapContext(ViewPort vp) { |
|
525 | 581 |
this(new FLayers(), vp); |
526 |
}
|
|
582 |
}
|
|
527 | 583 |
|
528 |
public MapContext() { } |
|
584 |
public MapContext() { |
|
585 |
} |
|
529 | 586 |
|
530 |
/** |
|
531 |
* <p>Creates a new map context with the layers and the drawing information defined in the view port arguments.</p> |
|
532 |
* |
|
533 |
* @param fLayers the initial hierarchy of nodes of layers that this map will have |
|
534 |
* @param vp information for drawing the layers of this map in the available rectangular area according a projection |
|
535 |
*/ |
|
536 |
public MapContext(FLayers fLayers, ViewPort vp) { |
|
537 |
this.layers = fLayers; |
|
538 |
|
|
539 |
layerEventListener = new LayerEventListener(); |
|
587 |
/** |
|
588 |
* <p> |
|
589 |
* Creates a new map context with the layers and the drawing information |
|
590 |
* defined in the view port arguments.</p> |
|
591 |
* |
|
592 |
* @param fLayers the initial hierarchy of nodes of layers that this map |
|
593 |
* will have |
|
594 |
* @param vp information for drawing the layers of this map in the available |
|
595 |
* rectangular area according a projection |
|
596 |
*/ |
|
597 |
public MapContext(FLayers fLayers, ViewPort vp) { |
|
598 |
this.layers = fLayers; |
|
540 | 599 |
|
541 |
if (layers != null) { |
|
542 |
layers.setMapContext(this); |
|
543 |
layers.addLayerCollectionListener(layerEventListener); |
|
544 |
layers.addLayerCollectionListener(eventBuffer); |
|
545 |
} |
|
600 |
layerEventListener = new LayerEventListener(); |
|
546 | 601 |
|
547 |
setViewPort(vp); |
|
548 |
} |
|
602 |
if (layers != null) { |
|
603 |
layers.setMapContext(this); |
|
604 |
layers.addLayerCollectionListener(layerEventListener); |
|
605 |
layers.addLayerCollectionListener(eventBuffer); |
|
606 |
} |
|
549 | 607 |
|
550 |
/** |
|
551 |
* <p>Reports to all driver error listeners registered of a bundle of driver exceptions caused in the same map atomic transaction.</p> |
|
552 |
* |
|
553 |
* @param introductoryText introductory text specified by developer. If <code>null</code>, use "" |
|
554 |
* @param driverExceptions list with a bundle of driver exceptions caught during an atomic event |
|
555 |
* |
|
556 |
* @see #addErrorListener(ErrorListener) |
|
557 |
* @see #removeErrorListener(LegendListener) |
|
558 |
*/ |
|
559 |
public synchronized void reportDriverExceptions(String introductoryText, |
|
560 |
List driverExceptions){ |
|
561 |
for (int i = 0; i < errorListeners.size(); i++) { |
|
562 |
((ErrorListener) errorListeners.get(i)). |
|
563 |
reportDriverExceptions(introductoryText, driverExceptions); |
|
564 |
} |
|
565 |
} |
|
608 |
setViewPort(vp); |
|
609 |
} |
|
566 | 610 |
|
567 |
/** |
|
568 |
* <p>Adds the specified legend listener (if didn't exist) to receive legend events from this map.</p> |
|
569 |
* |
|
570 |
* @param listener the legend listener |
|
571 |
* |
|
572 |
* @see #removeLayerListener(LegendListener) |
|
573 |
* @see #callLegendChanged() |
|
574 |
*/ |
|
575 |
public void addLayerListener(LegendListener listener) { |
|
576 |
if (!legendListeners.contains(listener)){ |
|
577 |
legendListeners.add(listener); |
|
578 |
} |
|
579 |
} |
|
611 |
/** |
|
612 |
* <p> |
|
613 |
* Reports to all driver error listeners registered of a bundle of driver |
|
614 |
* exceptions caused in the same map atomic transaction.</p> |
|
615 |
* |
|
616 |
* @param introductoryText introductory text specified by developer. If |
|
617 |
* <code>null</code>, use "" |
|
618 |
* @param driverExceptions list with a bundle of driver exceptions caught |
|
619 |
* during an atomic event |
|
620 |
* |
|
621 |
* @see #addErrorListener(ErrorListener) |
|
622 |
* @see #removeErrorListener(LegendListener) |
|
623 |
*/ |
|
624 |
public synchronized void reportDriverExceptions(String introductoryText, |
|
625 |
List driverExceptions) { |
|
626 |
for (int i = 0; i < errorListeners.size(); i++) { |
|
627 |
((ErrorListener) errorListeners.get(i)). |
|
628 |
reportDriverExceptions(introductoryText, driverExceptions); |
|
629 |
} |
|
630 |
} |
|
631 |
|
|
632 |
/** |
|
633 |
* <p> |
|
634 |
* Adds the specified legend listener (if didn't exist) to receive legend |
|
635 |
* events from this map.</p> |
|
636 |
* |
|
637 |
* @param listener the legend listener |
|
638 |
* |
|
639 |
* @see #removeLayerListener(LegendListener) |
|
640 |
* @see #callLegendChanged() |
|
641 |
*/ |
|
642 |
public void addLayerListener(LegendListener listener) { |
|
643 |
if (!legendListeners.contains(listener)) { |
|
644 |
legendListeners.add(listener); |
|
645 |
} |
|
646 |
} |
|
580 | 647 |
// SUGERENCIA DE PABLO |
581 |
// public void addLegendListener(LegendListener listener) {
|
|
582 |
// if (!legendListeners.contains(listener))
|
|
583 |
// legendListeners.add(listener);
|
|
584 |
// }
|
|
648 |
// public void addLegendListener(LegendListener listener) {
|
|
649 |
// if (!legendListeners.contains(listener))
|
|
650 |
// legendListeners.add(listener);
|
|
651 |
// }
|
|
585 | 652 |
|
586 |
/** |
|
587 |
* <p>Adds the specified layer drawing listener to catch and handle drawing events from layers of this map.</p> |
|
588 |
* |
|
589 |
* @param listener the listener to add |
|
590 |
* |
|
591 |
* @see #removeLayerDrawListener(LayerDrawingListener) |
|
592 |
* @see #fireLayerDrawingEvent(LayerDrawEvent) |
|
593 |
*/ |
|
594 |
public void addLayerDrawingListener(LayerDrawingListener listener) { |
|
595 |
layerDrawingListeners.add(listener); |
|
596 |
} |
|
653 |
/** |
|
654 |
* <p> |
|
655 |
* Adds the specified layer drawing listener to catch and handle drawing |
|
656 |
* events from layers of this map.</p> |
|
657 |
* |
|
658 |
* @param listener the listener to add |
|
659 |
* |
|
660 |
* @see #removeLayerDrawListener(LayerDrawingListener) |
|
661 |
* @see #fireLayerDrawingEvent(LayerDrawEvent) |
|
662 |
*/ |
|
663 |
public void addLayerDrawingListener(LayerDrawingListener listener) { |
|
664 |
layerDrawingListeners.add(listener); |
|
665 |
} |
|
597 | 666 |
|
598 |
/** |
|
599 |
* <p>Removes the specified layer drawing listener from this map.</p> |
|
600 |
* |
|
601 |
* @param listener the listener to remove |
|
602 |
* |
|
603 |
* @see #addLayerDrawingListener(LayerDrawingListener) |
|
604 |
* @see #fireLayerDrawingEvent(LayerDrawEvent) |
|
605 |
*/ |
|
606 |
public void removeLayerDrawListener(LayerDrawingListener listener) { |
|
607 |
layerDrawingListeners.remove(listener); |
|
608 |
} |
|
667 |
/** |
|
668 |
* <p> |
|
669 |
* Removes the specified layer drawing listener from this map.</p> |
|
670 |
* |
|
671 |
* @param listener the listener to remove |
|
672 |
* |
|
673 |
* @see #addLayerDrawingListener(LayerDrawingListener) |
|
674 |
* @see #fireLayerDrawingEvent(LayerDrawEvent) |
|
675 |
*/ |
|
676 |
public void removeLayerDrawListener(LayerDrawingListener listener) { |
|
677 |
layerDrawingListeners.remove(listener); |
|
678 |
} |
|
609 | 679 |
|
610 |
/** |
|
611 |
* <p>Adds the specified error listener to receive error events from this map.</p> |
|
612 |
* |
|
613 |
* @param listener the listener to add |
|
614 |
* |
|
615 |
* @see #removeErrorListener(LegendListener) |
|
616 |
* @see #reportDriverExceptions(String, List) |
|
617 |
*/ |
|
618 |
public void addErrorListener(ErrorListener listener) { |
|
619 |
errorListeners.add(listener); |
|
620 |
} |
|
680 |
/** |
|
681 |
* <p> |
|
682 |
* Adds the specified error listener to receive error events from this |
|
683 |
* map.</p> |
|
684 |
* |
|
685 |
* @param listener the listener to add |
|
686 |
* |
|
687 |
* @see #removeErrorListener(LegendListener) |
|
688 |
* @see #reportDriverExceptions(String, List) |
|
689 |
*/ |
|
690 |
public void addErrorListener(ErrorListener listener) { |
|
691 |
errorListeners.add(listener); |
|
692 |
} |
|
621 | 693 |
|
622 |
/** |
|
623 |
* <p>Removes the specified error listener from this map.</p> |
|
624 |
* |
|
625 |
* @param listener the listener to remove |
|
626 |
* |
|
627 |
* @see #addErrorListener(ErrorListener) |
|
628 |
* @see #reportDriverExceptions(String, List) |
|
629 |
*/ |
|
630 |
public void removeErrorListener(LegendListener listener) { |
|
631 |
legendListeners.remove(listener); |
|
632 |
} |
|
694 |
/** |
|
695 |
* <p> |
|
696 |
* Removes the specified error listener from this map.</p> |
|
697 |
* |
|
698 |
* @param listener the listener to remove |
|
699 |
* |
|
700 |
* @see #addErrorListener(ErrorListener) |
|
701 |
* @see #reportDriverExceptions(String, List) |
|
702 |
*/ |
|
703 |
public void removeErrorListener(LegendListener listener) { |
|
704 |
legendListeners.remove(listener); |
|
705 |
} |
|
633 | 706 |
|
634 | 707 |
// SUGERENCIA DE PABLO: |
635 |
//public void removeErrorListener(ErrorListener listener) { |
|
636 |
// errorListeners.remove(listener); |
|
637 |
//} |
|
708 |
//public void removeErrorListener(ErrorListener listener) { |
|
709 |
// errorListeners.remove(listener); |
|
710 |
//} |
|
711 |
/** |
|
712 |
* <p> |
|
713 |
* Notifies to all legend listeners registered, that one legend has |
|
714 |
* changed.</p> |
|
715 |
* <p> |
|
716 |
* This method must be called only if it's wanted to reflect a legend |
|
717 |
* change.</p> |
|
718 |
* |
|
719 |
* @see #addLayerListener(LegendListener) |
|
720 |
* @see #removeLayerListener(LegendListener) |
|
721 |
*/ |
|
722 |
public synchronized void callLegendChanged() { |
|
723 |
for (int i = 0; i < legendListeners.size(); i++) { |
|
724 |
((LegendListener) legendListeners.get(i)).legendChanged(null); |
|
725 |
} |
|
726 |
// getLayers().moveTo(0,0); |
|
727 |
} |
|
638 | 728 |
|
639 |
/** |
|
640 |
* <p>Notifies to all legend listeners registered, that one legend has changed.</p> |
|
641 |
* <p>This method must be called only if it's wanted to reflect a legend change.</p> |
|
642 |
* |
|
643 |
* @see #addLayerListener(LegendListener) |
|
644 |
* @see #removeLayerListener(LegendListener) |
|
645 |
*/ |
|
646 |
public synchronized void callLegendChanged() { |
|
647 |
for (int i = 0; i < legendListeners.size(); i++) { |
|
648 |
((LegendListener) legendListeners.get(i)).legendChanged(null); |
|
649 |
} |
|
650 |
// getLayers().moveTo(0,0); |
|
651 |
} |
|
729 |
/** |
|
730 |
* <p> |
|
731 |
* Fires a layer drawing event to all |
|
732 |
* {@link LayerDrawingListener LayerDrawingListener} listeners registered, |
|
733 |
* distinguishing the kind of event.</p> |
|
734 |
* |
|
735 |
* @param e the event |
|
736 |
* |
|
737 |
* @see #addLayerDrawingListener(LayerDrawingListener) |
|
738 |
* @see #removeLayerDrawListener(LayerDrawingListener) |
|
739 |
*/ |
|
740 |
public synchronized void fireLayerDrawingEvent(LayerDrawEvent e) { |
|
741 |
for (int i = 0; i < layerDrawingListeners.size(); i++) { |
|
742 |
LayerDrawingListener listener = (LayerDrawingListener) layerDrawingListeners.get(i); |
|
743 |
switch (e.getEventType()) { |
|
744 |
case LayerDrawEvent.LAYER_BEFORE_DRAW: |
|
745 |
listener.beforeLayerDraw(e); |
|
746 |
break; |
|
747 |
case LayerDrawEvent.LAYER_AFTER_DRAW: |
|
748 |
listener.afterLayerDraw(e); |
|
749 |
break; |
|
750 |
case LayerDrawEvent.GRAPHICLAYER_BEFORE_DRAW: |
|
751 |
listener.beforeGraphicLayerDraw(e); |
|
752 |
break; |
|
753 |
case LayerDrawEvent.GRAPHICLAYER_AFTER_DRAW: |
|
754 |
listener.afterLayerGraphicDraw(e); |
|
755 |
break; |
|
756 |
} |
|
757 |
} |
|
758 |
// getLayers().moveTo(0,0); |
|
759 |
} |
|
652 | 760 |
|
653 |
/** |
|
654 |
* <p>Fires a layer drawing event to all {@link LayerDrawingListener LayerDrawingListener} listeners registered, |
|
655 |
* distinguishing the kind of event.</p> |
|
656 |
* |
|
657 |
* @param e the event |
|
658 |
* |
|
659 |
* @see #addLayerDrawingListener(LayerDrawingListener) |
|
660 |
* @see #removeLayerDrawListener(LayerDrawingListener) |
|
661 |
*/ |
|
662 |
public synchronized void fireLayerDrawingEvent(LayerDrawEvent e) { |
|
663 |
for (int i = 0; i < layerDrawingListeners.size(); i++) |
|
664 |
{ |
|
665 |
LayerDrawingListener listener = (LayerDrawingListener) layerDrawingListeners.get(i); |
|
666 |
switch (e.getEventType()) |
|
667 |
{ |
|
668 |
case LayerDrawEvent.LAYER_BEFORE_DRAW: |
|
669 |
listener.beforeLayerDraw(e); |
|
670 |
break; |
|
671 |
case LayerDrawEvent.LAYER_AFTER_DRAW: |
|
672 |
listener.afterLayerDraw(e); |
|
673 |
break; |
|
674 |
case LayerDrawEvent.GRAPHICLAYER_BEFORE_DRAW: |
|
675 |
listener.beforeGraphicLayerDraw(e); |
|
676 |
break; |
|
677 |
case LayerDrawEvent.GRAPHICLAYER_AFTER_DRAW: |
|
678 |
listener.afterLayerGraphicDraw(e); |
|
679 |
break; |
|
680 |
} |
|
681 |
} |
|
682 |
// getLayers().moveTo(0,0); |
|
683 |
} |
|
761 |
/** |
|
762 |
* <p> |
|
763 |
* Notifies to all error listeners registered, that one error has been |
|
764 |
* produced.</p> |
|
765 |
* |
|
766 |
* @param e the event with information of the error |
|
767 |
* |
|
768 |
* @see #addErrorListener(ErrorListener) |
|
769 |
* @see #removeErrorListener(LegendListener) |
|
770 |
* @see #reportDriverExceptions(String, List) |
|
771 |
*/ |
|
772 |
public synchronized void callNewErrorEvent(ErrorEvent e) { |
|
773 |
for (int i = 0; i < errorListeners.size(); i++) { |
|
774 |
((ErrorListener) errorListeners.get(i)).errorThrown(e); |
|
775 |
} |
|
776 |
errorListeners.clear(); |
|
777 |
// getLayers().moveTo(0,0); |
|
778 |
} |
|
684 | 779 |
|
685 |
/** |
|
686 |
* <p>Notifies to all error listeners registered, that one error has been produced.</p> |
|
687 |
* |
|
688 |
* @param e the event with information of the error |
|
689 |
* |
|
690 |
* @see #addErrorListener(ErrorListener) |
|
691 |
* @see #removeErrorListener(LegendListener) |
|
692 |
* @see #reportDriverExceptions(String, List) |
|
693 |
*/ |
|
694 |
public synchronized void callNewErrorEvent(ErrorEvent e) { |
|
695 |
for (int i = 0; i < errorListeners.size(); i++) { |
|
696 |
((ErrorListener) errorListeners.get(i)).errorThrown(e); |
|
697 |
} |
|
698 |
errorListeners.clear(); |
|
699 |
// getLayers().moveTo(0,0); |
|
700 |
} |
|
780 |
/** |
|
781 |
* <p> |
|
782 |
* Removes the specified layer listener from this map.</p> |
|
783 |
* |
|
784 |
* @param listener the listener to remove |
|
785 |
* |
|
786 |
* @see #addLayerListener(LegendListener) |
|
787 |
* @see #callLegendChanged() |
|
788 |
*/ |
|
789 |
public void removeLayerListener(LegendListener listener) { |
|
790 |
legendListeners.remove(listener); |
|
791 |
} |
|
701 | 792 |
|
702 |
/** |
|
703 |
* <p>Removes the specified layer listener from this map.</p> |
|
704 |
* |
|
705 |
* @param listener the listener to remove |
|
706 |
* |
|
707 |
* @see #addLayerListener(LegendListener) |
|
708 |
* @see #callLegendChanged() |
|
709 |
*/ |
|
710 |
public void removeLayerListener(LegendListener listener) { |
|
711 |
legendListeners.remove(listener); |
|
712 |
} |
|
713 |
|
|
714 | 793 |
// SUGERENCIA DE PABLO: |
715 |
// public void removeLegendListener(LegendListener listener) { |
|
716 |
// legendListeners.remove(listener); |
|
717 |
// } |
|
794 |
// public void removeLegendListener(LegendListener listener) { |
|
795 |
// legendListeners.remove(listener); |
|
796 |
// } |
|
797 |
/** |
|
798 |
* <p> |
|
799 |
* Returns the hierarchy of {@link FLayers FLayers} nodes stored in this |
|
800 |
* map.</p> |
|
801 |
* |
|
802 |
* @return the hierarchy of nodes of layers stored in this map |
|
803 |
*/ |
|
804 |
public FLayers getLayers() { |
|
805 |
return layers; |
|
806 |
} |
|
718 | 807 |
|
719 |
/** |
|
720 |
* <p>Returns the hierarchy of {@link FLayers FLayers} nodes stored in this map.</p> |
|
721 |
* |
|
722 |
* @return the hierarchy of nodes of layers stored in this map |
|
723 |
*/ |
|
724 |
public FLayers getLayers() { |
|
725 |
return layers; |
|
726 |
} |
|
808 |
/** |
|
809 |
* <p> |
|
810 |
* Draws the visible layers of this map according its view port, on the |
|
811 |
* image parameter.</p> |
|
812 |
* |
|
813 |
* @param b image with an accessible buffer of image data |
|
814 |
*/ |
|
815 |
public void drawLabels(BufferedImage b) { |
|
816 |
} |
|
727 | 817 |
|
728 |
/** |
|
729 |
* <p>Draws the visible layers of this map according its view port, on the image parameter.</p> |
|
730 |
* |
|
731 |
* @param b image with an accessible buffer of image data |
|
732 |
*/ |
|
733 |
public void drawLabels(BufferedImage b) { |
|
734 |
} |
|
818 |
/** |
|
819 |
* @see #redraw() |
|
820 |
*/ |
|
821 |
public void invalidate() { |
|
822 |
updateDrawVersion(); |
|
823 |
// Small hack to let the MapControl receive an event and repaint |
|
824 |
FLayer layer; |
|
825 |
if (layers.getLayersCount() > 0) { |
|
826 |
layer = layers.getLayer(layers.getLayersCount() - 1); |
|
827 |
} else { |
|
828 |
layer = getGraphicsLayer(); |
|
829 |
} |
|
830 |
LayerPositionEvent layerMovedEvent = LayerPositionEvent |
|
831 |
.createLayerMovedEvent( |
|
832 |
layer, 0, 0); |
|
833 |
eventBuffer.layerMoved(layerMovedEvent); |
|
834 |
} |
|
735 | 835 |
|
736 |
/** |
|
737 |
* @see #redraw() |
|
738 |
*/ |
|
739 |
public void invalidate() { |
|
740 |
updateDrawVersion(); |
|
741 |
// Small hack to let the MapControl receive an event and repaint |
|
742 |
FLayer layer; |
|
743 |
if (layers.getLayersCount() > 0) { |
|
744 |
layer = layers.getLayer(layers.getLayersCount() - 1); |
|
745 |
} |
|
746 |
else { |
|
747 |
layer = getGraphicsLayer(); |
|
748 |
} |
|
749 |
LayerPositionEvent layerMovedEvent = LayerPositionEvent |
|
750 |
.createLayerMovedEvent( |
|
751 |
layer, 0, 0); |
|
752 |
eventBuffer.layerMoved(layerMovedEvent); |
|
753 |
} |
|
754 |
|
|
755 | 836 |
/** |
756 | 837 |
* <p> |
757 | 838 |
* Prints the layers of this map using the {@link Graphics2D Graphics2D} |
758 | 839 |
* argument, that usually is the {@link Graphics Graphics} of the printer. |
759 | 840 |
* </p> |
760 |
* |
|
761 |
* @param g |
|
762 |
* for rendering 2-dimensional shapes, text and images on the |
|
763 |
* Java(tm) platform |
|
764 |
* @param scale |
|
765 |
* the scale of the view. Must be between |
|
766 |
* {@linkplain FLayer#getMinScale()} and |
|
767 |
* {@linkplain FLayer#getMaxScale()}. |
|
768 |
* @param properties |
|
769 |
* a set with the settings to be applied to a whole print job and |
|
770 |
* to all the documents in the print job |
|
771 |
* @throws MapContextException |
|
772 |
* if there is an error getting the instance of MapContextDrawer |
|
773 |
* |
|
774 |
* @throws ReadDriverException |
|
775 |
* if fails reading with driver. |
|
776 |
* |
|
841 |
* |
|
842 |
* @param g for rendering 2-dimensional shapes, text and images on the |
|
843 |
* Java(tm) platform |
|
844 |
* @param scale the scale of the view. Must be between |
|
845 |
* {@linkplain FLayer#getMinScale()} and {@linkplain FLayer#getMaxScale()}. |
|
846 |
* @param properties a set with the settings to be applied to a whole print |
|
847 |
* job and to all the documents in the print job |
|
848 |
* @throws MapContextException if there is an error getting the instance of |
|
849 |
* MapContextDrawer |
|
850 |
* |
|
851 |
* @throws ReadDriverException if fails reading with driver. |
|
852 |
* |
|
777 | 853 |
* @see GraphicLayer#draw(BufferedImage, Graphics2D, ViewPort, Cancellable, |
778 |
* double)
|
|
854 |
* double) |
|
779 | 855 |
*/ |
780 |
public void print(Graphics2D g, double scale,
|
|
781 |
PrintAttributes properties) throws ReadException,
|
|
856 |
public void print(Graphics2D g, double scale,
|
|
857 |
PrintAttributes properties) throws ReadException,
|
|
782 | 858 |
MapContextException { |
783 |
|
|
784 |
CompatLocator.getGraphicsUtils().setRenderingHintsForPrinting(g); |
|
785 | 859 |
|
786 |
Cancellable cancel = new Cancellable() { |
|
787 |
public boolean isCanceled() { |
|
788 |
return false; |
|
789 |
} |
|
860 |
CompatLocator.getGraphicsUtils().setRenderingHintsForPrinting(g); |
|
790 | 861 |
|
791 |
public void setCanceled(boolean canceled) { |
|
792 |
// No queremos que se pueda cancelar la impresi�n. |
|
862 |
Cancellable cancel = new Cancellable() { |
|
863 |
public boolean isCanceled() { |
|
864 |
return false; |
|
865 |
} |
|
793 | 866 |
|
794 |
} |
|
795 |
}; |
|
796 |
this.getMapContextDrawer().print(this.layers, g, cancel, scale,properties); |
|
797 |
if (tracLayer != null) { |
|
798 |
tracLayer.draw(null, g, viewPort, cancel, scale); |
|
799 |
} |
|
800 |
} |
|
867 |
public void setCanceled(boolean canceled) { |
|
868 |
// No queremos que se pueda cancelar la impresi�n. |
|
801 | 869 |
|
802 |
/** |
|
803 |
* <p>Returns a new <code>MapContext</code> instance with the information of the <code>vp</code> argument, and the layers of this map.</p> |
|
804 |
* |
|
805 |
* @param vp information for drawing the layers of this map in the available rectangular area according a projection |
|
806 |
* |
|
807 |
* @return a new <code>MapContext</code> instance projected by <code>vp</code> |
|
808 |
*/ |
|
809 |
public MapContext createNewFMap(ViewPort vp) { |
|
810 |
MapContext ret = new MapContext(vp); |
|
811 |
ret.layers = this.layers; |
|
870 |
} |
|
871 |
}; |
|
872 |
this.getMapContextDrawer().print(this.layers, g, cancel, scale, properties); |
|
873 |
if (tracLayer != null) { |
|
874 |
tracLayer.draw(null, g, viewPort, cancel, scale); |
|
875 |
} |
|
876 |
} |
|
812 | 877 |
|
813 |
return ret; |
|
814 |
} |
|
878 |
/** |
|
879 |
* <p> |
|
880 |
* Returns a new <code>MapContext</code> instance with the information of |
|
881 |
* the <code>vp</code> argument, and the layers of this map.</p> |
|
882 |
* |
|
883 |
* @param vp information for drawing the layers of this map in the available |
|
884 |
* rectangular area according a projection |
|
885 |
* |
|
886 |
* @return a new <code>MapContext</code> instance projected by |
|
887 |
* <code>vp</code> |
|
888 |
*/ |
|
889 |
public MapContext createNewFMap(ViewPort vp) { |
|
890 |
MapContext ret = new MapContext(vp); |
|
891 |
ret.layers = this.layers; |
|
815 | 892 |
|
816 |
/** |
|
817 |
* <p>Creates a new independent <code>MapContext</code> instance, that has a clone of the layers and the view port of this one.</p> |
|
818 |
* <p>The new map will have the same data source drivers to avoid waste memory, and work faster.</p> |
|
819 |
* |
|
820 |
* @return the new <code>MapContext</code> instance |
|
821 |
* |
|
822 |
* @throws XMLException if fails cloning the view port or a layer |
|
823 |
* |
|
824 |
* @see FLayer#cloneLayer() |
|
825 |
* @see ViewPort#cloneViewPort() |
|
826 |
*/ |
|
827 |
public MapContext cloneFMap() { |
|
828 |
ViewPort vp; |
|
893 |
return ret; |
|
894 |
} |
|
895 |
|
|
896 |
/** |
|
897 |
* <p> |
|
898 |
* Creates a new independent <code>MapContext</code> instance, that has a |
|
899 |
* clone of the layers and the view port of this one.</p> |
|
900 |
* <p> |
|
901 |
* The new map will have the same data source drivers to avoid waste memory, |
|
902 |
* and work faster.</p> |
|
903 |
* |
|
904 |
* @return the new <code>MapContext</code> instance |
|
905 |
* |
Also available in: Unified diff