13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 |
* Lesser General Public License for more details. |
* Lesser General Public License for more details. |
15 |
*/ |
*/ |
16 |
package org.geotools.gui.swing; |
package gtmig.org.geotools.swing; |
17 |
|
|
18 |
/** |
/** |
19 |
* <b>Xulu:<br> |
* <b>Xulu:<br> |
58 |
import javax.swing.JPanel; |
import javax.swing.JPanel; |
59 |
|
|
60 |
import org.apache.log4j.Logger; |
import org.apache.log4j.Logger; |
61 |
import org.geotools.feature.FeatureCollection; |
import org.geotools.geometry.jts.ReferencedEnvelope; |
|
import org.geotools.filter.IllegalFilterException; |
|
|
import org.geotools.gui.swing.event.HighlightChangeListener; |
|
|
import org.geotools.gui.swing.event.HighlightChangedEvent; |
|
|
import org.geotools.gui.swing.event.SelectionChangeListener; |
|
|
import org.geotools.gui.swing.event.SelectionChangedEvent; |
|
|
import org.geotools.map.DefaultMapContext; |
|
62 |
import org.geotools.map.MapContext; |
import org.geotools.map.MapContext; |
|
import org.geotools.map.MapLayer; |
|
63 |
import org.geotools.map.event.MapLayerListEvent; |
import org.geotools.map.event.MapLayerListEvent; |
64 |
import org.geotools.map.event.MapLayerListListener; |
import org.geotools.map.event.MapLayerListListener; |
|
import org.geotools.referencing.crs.DefaultGeographicCRS; |
|
65 |
import org.geotools.renderer.GTRenderer; |
import org.geotools.renderer.GTRenderer; |
66 |
|
import org.geotools.renderer.label.LabelCacheImpl; |
67 |
import org.geotools.renderer.lite.LabelCache; |
import org.geotools.renderer.lite.LabelCache; |
|
import org.geotools.renderer.lite.LabelCacheDefault; |
|
68 |
import org.geotools.renderer.lite.StreamingRenderer; |
import org.geotools.renderer.lite.StreamingRenderer; |
69 |
import org.geotools.styling.Graphic; |
import org.geotools.renderer.shape.ShapefileRenderer; |
|
import org.geotools.styling.LineSymbolizer; |
|
|
import org.geotools.styling.Mark; |
|
|
import org.geotools.styling.PointSymbolizer; |
|
|
import org.geotools.styling.PolygonSymbolizer; |
|
|
import org.geotools.styling.Style; |
|
|
import org.geotools.styling.StyleBuilder; |
|
|
import org.geotools.styling.StyleFactory; |
|
|
import org.opengis.filter.Filter; |
|
70 |
import org.opengis.filter.FilterFactory2; |
import org.opengis.filter.FilterFactory2; |
71 |
import org.opengis.referencing.crs.CoordinateReferenceSystem; |
import org.opengis.referencing.crs.CoordinateReferenceSystem; |
72 |
|
|
74 |
|
|
75 |
import com.vividsolutions.jts.geom.Coordinate; |
import com.vividsolutions.jts.geom.Coordinate; |
76 |
import com.vividsolutions.jts.geom.Envelope; |
import com.vividsolutions.jts.geom.Envelope; |
|
import com.vividsolutions.jts.geom.Geometry; |
|
77 |
import com.vividsolutions.jts.geom.GeometryFactory; |
import com.vividsolutions.jts.geom.GeometryFactory; |
78 |
|
|
79 |
public class JMapPane extends JPanel implements MouseListener, |
public class JMapPane extends JPanel implements MouseListener, |
80 |
MouseMotionListener, HighlightChangeListener, SelectionChangeListener, |
MouseMotionListener, PropertyChangeListener, MapLayerListListener { |
|
PropertyChangeListener, MapLayerListListener { |
|
81 |
private static Logger LOGGER = Logger.getLogger(JMapPane.class.getName()); |
private static Logger LOGGER = Logger.getLogger(JMapPane.class.getName()); |
82 |
|
|
83 |
private static final long serialVersionUID = -8647971481359690499L; |
private static final long serialVersionUID = -8647971481359690499L; |
92 |
|
|
93 |
public static final int Select = 4; |
public static final int Select = 4; |
94 |
|
|
|
private static final int POLYGON = 0; |
|
|
|
|
|
private static final int LINE = 1; |
|
|
|
|
|
private static final int POINT = 2; |
|
|
|
|
95 |
/** |
/** |
96 |
* what renders the map |
* what renders the map |
97 |
*/ |
*/ |
98 |
GTRenderer renderer; |
GTRenderer renderer; |
99 |
|
|
|
private GTRenderer highlightRenderer, selectionRenderer; |
|
|
|
|
100 |
/** |
/** |
101 |
* the map context to render |
* the map context to render |
102 |
*/ |
*/ |
103 |
MapContext context; |
MapContext context; |
104 |
|
|
|
private MapContext selectionContext; |
|
|
|
|
105 |
/** |
/** |
106 |
* the area of the map to draw |
* the area of the map to draw |
107 |
*/ |
*/ |
|
// xulu.sc |
|
|
// Envelope mapArea; |
|
108 |
protected Envelope mapArea; |
protected Envelope mapArea; |
|
// xulu.ec |
|
109 |
|
|
110 |
/** |
/** |
111 |
* the size of the pane last time we drew |
* the size of the pane last time we drew |
112 |
*/ |
*/ |
|
// xulu.sc |
|
|
// private Rectangle oldRect = null; |
|
113 |
protected Rectangle oldRect = null; |
protected Rectangle oldRect = null; |
|
// xulu.ec |
|
114 |
|
|
115 |
/** |
/** |
116 |
* the last map area drawn. |
* the last map area drawn. |
117 |
*/ |
*/ |
|
// xulu.sc |
|
|
// private Envelope oldMapArea = null; |
|
118 |
protected Envelope oldMapArea = null; |
protected Envelope oldMapArea = null; |
|
// xulu.ec |
|
119 |
|
|
120 |
/** |
/** |
121 |
* the base image of the map |
* the base image of the map |
122 |
*/ |
*/ |
123 |
protected BufferedImage baseImage, panningImage; |
protected BufferedImage baseImage, panningImage; |
|
// SK: private BufferedImage baseImage, panningImage; |
|
|
|
|
|
/** |
|
|
* image of selection |
|
|
*/ |
|
|
private BufferedImage selectImage; |
|
|
|
|
|
/** |
|
|
* style for selected items |
|
|
*/ |
|
|
private Style selectionStyle; |
|
|
|
|
|
/** |
|
|
* layer that selection works on |
|
|
*/ |
|
|
private MapLayer selectionLayer; |
|
|
|
|
|
/** |
|
|
* layer that highlight works on |
|
|
*/ |
|
|
private MapLayer highlightLayer; |
|
|
|
|
|
/** |
|
|
* the object which manages highlighting |
|
|
*/ |
|
|
private HighlightManager highlightManager; |
|
|
|
|
|
/** |
|
|
* is highlighting on or off |
|
|
*/ |
|
|
private boolean highlight = true; |
|
124 |
|
|
125 |
/** |
/** |
126 |
* a factory for filters |
* a factory for filters |
132 |
*/ |
*/ |
133 |
GeometryFactory gf = new GeometryFactory(); // FactoryFinder.getGeometryFactory(null); |
GeometryFactory gf = new GeometryFactory(); // FactoryFinder.getGeometryFactory(null); |
134 |
|
|
|
/** |
|
|
* the collections of features to be selected or highlighted |
|
|
*/ |
|
|
FeatureCollection selection; |
|
|
|
|
|
/** |
|
|
* the collections of features to be selected or highlighted |
|
|
*/ |
|
|
FeatureCollection highlightFeature; |
|
|
|
|
135 |
private int state = ZoomIn; |
private int state = ZoomIn; |
136 |
|
|
137 |
/** |
/** |
139 |
*/ |
*/ |
140 |
private double zoomFactor = 2.0; |
private double zoomFactor = 2.0; |
141 |
|
|
|
Style lineHighlightStyle; |
|
|
|
|
|
Style pointHighlightStyle; |
|
|
|
|
|
Style polygonHighlightStyle; |
|
|
|
|
|
Style polygonSelectionStyle; |
|
|
|
|
|
Style pointSelectionStyle; |
|
|
|
|
|
Style lineSelectionStyle; |
|
|
|
|
142 |
boolean changed = true; |
boolean changed = true; |
143 |
|
|
144 |
LabelCache labelCache = new LabelCacheDefault(); |
LabelCache labelCache = new LabelCacheImpl(); |
145 |
|
|
|
// xulu.sc |
|
|
// private boolean reset = false; |
|
146 |
protected boolean reset = false; |
protected boolean reset = false; |
|
// xulu.ec |
|
147 |
|
|
148 |
int startX; |
int startX; |
149 |
|
|
150 |
int startY; |
int startY; |
151 |
|
|
152 |
|
/** |
153 |
|
* If not <code>null</code>, the {@link JMapPane} will not allow to zoom/pan |
154 |
|
* out of that area |
155 |
|
**/ |
156 |
|
private Envelope maxExtend = null; |
157 |
|
|
158 |
|
// /** |
159 |
|
// * Is max. 1 or 0 of the 2 axised allowed to extend the maxExtend? If |
160 |
|
// * <code>true</code> the extends has to be fully inside maxExtend |
161 |
|
// **/ |
162 |
|
// boolean maxExtendForceMode = true; |
163 |
|
|
164 |
private boolean clickable; |
private boolean clickable; |
165 |
|
|
166 |
int lastX; |
int lastX; |
167 |
|
|
168 |
int lastY; |
int lastY; |
169 |
|
|
|
private SelectionManager selectionManager; |
|
|
// xulu.sn |
|
170 |
private Double maxZoomScale = Double.MIN_VALUE; |
private Double maxZoomScale = Double.MIN_VALUE; |
171 |
private Double minZoomScale = Double.MAX_VALUE; |
private Double minZoomScale = Double.MAX_VALUE; |
|
// xulu.en |
|
172 |
|
|
|
// sk.sn |
|
173 |
/** |
/** |
174 |
* Wenn true, dann wurde PANNING via mouseDraged-Events begonnen. Dieses |
* Wenn true, dann wurde PANNING via mouseDraged-Events begonnen. Dieses |
175 |
* Flag wird benutzt um nur einmal den passenden Cursor nur einmal zu |
* Flag wird benutzt um nur einmal den passenden Cursor nur einmal zu |
177 |
*/ |
*/ |
178 |
private boolean panning_started = false; |
private boolean panning_started = false; |
179 |
|
|
|
// sk.en |
|
|
|
|
180 |
public JMapPane() { |
public JMapPane() { |
181 |
this(null, true, null, null); |
this(null, true, null, null); |
182 |
} |
} |
189 |
* @param context |
* @param context |
190 |
* - the map context to display |
* - the map context to display |
191 |
*/ |
*/ |
192 |
public JMapPane(GTRenderer render, MapContext context) { |
public JMapPane(final GTRenderer render, final MapContext context) { |
193 |
this(null, true, render, context); |
this(null, true, render, context); |
194 |
} |
} |
195 |
|
|
205 |
* @param context |
* @param context |
206 |
* - what to draw |
* - what to draw |
207 |
*/ |
*/ |
208 |
public JMapPane(LayoutManager layout, boolean isDoubleBuffered, |
public JMapPane(final LayoutManager layout, final boolean isDoubleBuffered, |
209 |
GTRenderer render, MapContext context) { |
final GTRenderer render, final MapContext context) { |
210 |
super(layout, isDoubleBuffered); |
super(layout, isDoubleBuffered); |
211 |
|
|
212 |
ff = (FilterFactory2) org.geotools.factory.CommonFactoryFinder |
ff = (FilterFactory2) org.geotools.factory.CommonFactoryFinder |
217 |
|
|
218 |
this.addMouseListener(this); |
this.addMouseListener(this); |
219 |
this.addMouseMotionListener(this); |
this.addMouseMotionListener(this); |
|
setHighlightManager(new HighlightManager(highlightLayer)); |
|
|
setSelectionManager(new SelectionManager(selectionLayer)); |
|
|
lineHighlightStyle = setupStyle(LINE, Color.red); |
|
|
|
|
|
pointHighlightStyle = setupStyle(POINT, Color.red); |
|
|
|
|
|
polygonHighlightStyle = setupStyle(POLYGON, Color.red); |
|
|
|
|
|
polygonSelectionStyle = setupStyle(POLYGON, Color.cyan); |
|
|
|
|
|
pointSelectionStyle = setupStyle(POINT, Color.cyan); |
|
|
|
|
|
lineSelectionStyle = setupStyle(LINE, Color.cyan); |
|
220 |
setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); |
setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); |
221 |
} |
} |
222 |
|
|
227 |
return renderer; |
return renderer; |
228 |
} |
} |
229 |
|
|
230 |
public void setRenderer(GTRenderer renderer) { |
public void setRenderer(final GTRenderer renderer) { |
231 |
Map hints = new HashMap(); |
Map<Object, Object> hints = new HashMap<Object, Object>(); |
232 |
if (renderer instanceof StreamingRenderer) { |
|
233 |
|
this.renderer = renderer; |
234 |
|
|
235 |
|
if (renderer instanceof StreamingRenderer |
236 |
|
|| renderer instanceof ShapefileRenderer) { |
237 |
hints = renderer.getRendererHints(); |
hints = renderer.getRendererHints(); |
238 |
if (hints == null) { |
if (hints == null) { |
239 |
hints = new HashMap(); |
hints = new HashMap<Object, Object>(); |
240 |
} |
} |
241 |
if (hints.containsKey(StreamingRenderer.LABEL_CACHE_KEY)) { |
if (hints.containsKey(StreamingRenderer.LABEL_CACHE_KEY)) { |
242 |
labelCache = (LabelCache) hints |
labelCache = (LabelCache) hints |
244 |
} else { |
} else { |
245 |
hints.put(StreamingRenderer.LABEL_CACHE_KEY, labelCache); |
hints.put(StreamingRenderer.LABEL_CACHE_KEY, labelCache); |
246 |
} |
} |
247 |
|
|
248 |
|
hints.put("memoryPreloadingEnabled", Boolean.TRUE); |
249 |
|
|
250 |
renderer.setRendererHints(hints); |
renderer.setRendererHints(hints); |
251 |
} |
} |
252 |
|
|
253 |
this.renderer = renderer; |
// this.highlightRenderer = new StreamingRenderer(); |
254 |
this.highlightRenderer = new StreamingRenderer(); |
// this.selectionRenderer = new StreamingRenderer(); |
255 |
this.selectionRenderer = new StreamingRenderer(); |
|
256 |
|
// highlightRenderer.setRendererHints(hints); |
257 |
|
// selectionRenderer.setRendererHints(hints); |
258 |
|
|
259 |
hints.put("memoryPreloadingEnabled", Boolean.FALSE); |
// renderer.setRendererHints(hints); |
|
highlightRenderer.setRendererHints(hints); |
|
|
selectionRenderer.setRendererHints(hints); |
|
260 |
|
|
261 |
if (this.context != null) { |
if (this.context != null) { |
262 |
this.renderer.setContext(this.context); |
this.renderer.setContext(this.context); |
267 |
return context; |
return context; |
268 |
} |
} |
269 |
|
|
270 |
public void setContext(MapContext context) { |
public void setContext(final MapContext context) { |
271 |
if (this.context != null) { |
if (this.context != null) { |
272 |
this.context.removeMapLayerListListener(this); |
this.context.removeMapLayerListListener(this); |
273 |
} |
} |
287 |
return mapArea; |
return mapArea; |
288 |
} |
} |
289 |
|
|
290 |
public void setMapArea(Envelope mapArea) { |
public void setMapArea(final Envelope mapArea) { |
291 |
this.mapArea = mapArea; |
this.mapArea = mapArea; |
292 |
} |
} |
293 |
|
|
295 |
return state; |
return state; |
296 |
} |
} |
297 |
|
|
298 |
public void setState(int state) { |
public void setState(final int state) { |
299 |
this.state = state; |
this.state = state; |
300 |
|
|
301 |
// System.out.println("State: " + state); |
// System.out.println("State: " + state); |
305 |
return zoomFactor; |
return zoomFactor; |
306 |
} |
} |
307 |
|
|
308 |
public void setZoomFactor(double zoomFactor) { |
public void setZoomFactor(final double zoomFactor) { |
309 |
this.zoomFactor = zoomFactor; |
this.zoomFactor = zoomFactor; |
310 |
} |
} |
311 |
|
|
312 |
public MapLayer getSelectionLayer() { |
protected void paintComponent(final Graphics g) { |
|
return selectionLayer; |
|
|
} |
|
|
|
|
|
public void setSelectionLayer(MapLayer selectionLayer) { |
|
|
this.selectionLayer = selectionLayer; |
|
|
if (selectionManager != null) { |
|
|
selectionManager.setSelectionLayer(selectionLayer); |
|
|
} |
|
|
} |
|
|
|
|
|
public boolean isHighlight() { |
|
|
return highlight; |
|
|
} |
|
|
|
|
|
public void setHighlight(boolean highlight) { |
|
|
this.highlight = highlight; |
|
|
} |
|
|
|
|
|
public MapLayer getHighlightLayer() { |
|
|
return highlightLayer; |
|
|
} |
|
|
|
|
|
public void setHighlightLayer(MapLayer highlightLayer) { |
|
|
this.highlightLayer = highlightLayer; |
|
|
|
|
|
if (highlightManager != null) { |
|
|
highlightManager.setHighlightLayer(highlightLayer); |
|
|
} |
|
|
} |
|
|
|
|
|
public HighlightManager getHighlightManager() { |
|
|
return highlightManager; |
|
|
} |
|
|
|
|
|
public void setHighlightManager(HighlightManager highlightManager) { |
|
|
this.highlightManager = highlightManager; |
|
|
this.highlightManager.addHighlightChangeListener(this); |
|
|
this.addMouseMotionListener(this.highlightManager); |
|
|
} |
|
|
|
|
|
public Style getLineHighlightStyle() { |
|
|
return lineHighlightStyle; |
|
|
} |
|
|
|
|
|
public void setLineHighlightStyle(Style lineHighlightStyle) { |
|
|
this.lineHighlightStyle = lineHighlightStyle; |
|
|
} |
|
|
|
|
|
public Style getLineSelectionStyle() { |
|
|
return lineSelectionStyle; |
|
|
} |
|
|
|
|
|
public void setLineSelectionStyle(Style lineSelectionStyle) { |
|
|
this.lineSelectionStyle = lineSelectionStyle; |
|
|
} |
|
|
|
|
|
public Style getPointHighlightStyle() { |
|
|
return pointHighlightStyle; |
|
|
} |
|
|
|
|
|
public void setPointHighlightStyle(Style pointHighlightStyle) { |
|
|
this.pointHighlightStyle = pointHighlightStyle; |
|
|
} |
|
|
|
|
|
public Style getPointSelectionStyle() { |
|
|
return pointSelectionStyle; |
|
|
} |
|
|
|
|
|
public void setPointSelectionStyle(Style pointSelectionStyle) { |
|
|
this.pointSelectionStyle = pointSelectionStyle; |
|
|
} |
|
|
|
|
|
public Style getPolygonHighlightStyle() { |
|
|
return polygonHighlightStyle; |
|
|
} |
|
|
|
|
|
public void setPolygonHighlightStyle(Style polygonHighlightStyle) { |
|
|
this.polygonHighlightStyle = polygonHighlightStyle; |
|
|
} |
|
|
|
|
|
public Style getPolygonSelectionStyle() { |
|
|
return polygonSelectionStyle; |
|
|
} |
|
|
|
|
|
public void setPolygonSelectionStyle(Style polygonSelectionStyle) { |
|
|
this.polygonSelectionStyle = polygonSelectionStyle; |
|
|
} |
|
|
|
|
|
protected void paintComponent(Graphics g) { |
|
313 |
super.paintComponent(g); |
super.paintComponent(g); |
314 |
|
|
315 |
if ((renderer == null) || (mapArea == null)) { |
if ((renderer == null) || (mapArea == null)) { |
316 |
return; |
return; |
317 |
} |
} |
318 |
|
|
319 |
Rectangle r = getBounds(); |
final Rectangle r = getBounds(); |
320 |
Rectangle dr = new Rectangle(r.width, r.height); |
final Rectangle dr = new Rectangle(r.width, r.height); |
321 |
|
|
322 |
if (!r.equals(oldRect) || reset) { |
if (!r.equals(oldRect) || reset) { |
323 |
if (!r.equals(oldRect) && (mapArea == null)) { |
if (!r.equals(oldRect) && (mapArea == null)) { |
324 |
try { |
try { |
325 |
mapArea = context.getLayerBounds(); |
mapArea = context.getLayerBounds(); |
326 |
} catch (IOException e) { |
} catch (final IOException e) { |
327 |
// TODO Auto-generated catch block |
LOGGER.warn("context.getLayerBounds()", e); |
|
e.printStackTrace(); |
|
328 |
} |
} |
329 |
} |
} |
330 |
|
|
352 |
baseImage = new BufferedImage(dr.width, dr.height, |
baseImage = new BufferedImage(dr.width, dr.height, |
353 |
BufferedImage.TYPE_INT_ARGB); |
BufferedImage.TYPE_INT_ARGB); |
354 |
|
|
355 |
Graphics2D ig = baseImage.createGraphics(); |
final Graphics2D ig = baseImage.createGraphics(); |
356 |
/* System.out.println("rendering"); */ |
/* System.out.println("rendering"); */ |
357 |
renderer.setContext(context); |
if (renderer.getContext() != null) |
358 |
|
renderer.setContext(context); |
359 |
labelCache.clear(); // work around anoying labelcache bug |
labelCache.clear(); // work around anoying labelcache bug |
360 |
|
|
361 |
// draw the map |
// draw the map |
362 |
renderer.paint((Graphics2D) ig, dr, mapArea); |
renderer.paint((Graphics2D) ig, dr, mapArea); |
363 |
|
|
364 |
// TODO , nur machen, wenn panning beginnt |
// TODO nur machen, wenn panning beginnt |
365 |
panningImage = new BufferedImage(dr.width, dr.height, |
panningImage = new BufferedImage(dr.width, dr.height, |
366 |
BufferedImage.TYPE_INT_RGB); |
BufferedImage.TYPE_INT_RGB); |
367 |
|
|
368 |
} |
} |
369 |
|
|
370 |
((Graphics2D) g).drawImage(baseImage, 0, 0, this); |
((Graphics2D) g).drawImage(baseImage, 0, 0, this); |
|
|
|
|
if ((selection != null) && (selection.size() > 0)) { |
|
|
// paint selection |
|
|
|
|
|
String type = selectionLayer.getFeatureSource().getSchema() |
|
|
.getDefaultGeometry().getType().getName(); |
|
|
/* String type = selection.getDefaultGeometry().getGeometryType(); */ |
|
|
/* System.out.println(type); */ |
|
|
if (type == null) |
|
|
type = "polygon"; |
|
|
|
|
|
/* String type = "point"; */ |
|
|
|
|
|
if (type.toLowerCase().endsWith("polygon")) { |
|
|
selectionStyle = polygonSelectionStyle; |
|
|
} else if (type.toLowerCase().endsWith("point")) { |
|
|
selectionStyle = pointSelectionStyle; |
|
|
} else if (type.toLowerCase().endsWith("line")) { |
|
|
selectionStyle = lineSelectionStyle; |
|
|
} |
|
|
|
|
|
selectionContext = new DefaultMapContext(DefaultGeographicCRS.WGS84); |
|
|
|
|
|
selectionContext.addLayer(selection, selectionStyle); |
|
|
selectionRenderer.setContext(selectionContext); |
|
|
|
|
|
selectImage = new BufferedImage(dr.width, dr.height, |
|
|
BufferedImage.TYPE_INT_ARGB); |
|
|
|
|
|
Graphics2D ig = selectImage.createGraphics(); |
|
|
/* System.out.println("rendering selection"); */ |
|
|
selectionRenderer.paint((Graphics2D) ig, dr, mapArea); |
|
|
|
|
|
((Graphics2D) g).drawImage(selectImage, 0, 0, this); |
|
|
} |
|
|
|
|
|
if (highlight && (highlightFeature != null) |
|
|
&& (highlightFeature.size() > 0)) { |
|
|
/* |
|
|
* String type = selection.getDefaultGeometry().getGeometryType(); |
|
|
* System.out.println(type); if(type==null) type="polygon"; |
|
|
*/ |
|
|
String type = highlightLayer.getFeatureSource().getSchema() |
|
|
.getDefaultGeometry().getType().getName(); |
|
|
/* String type = selection.getDefaultGeometry().getGeometryType(); */ |
|
|
// System.out.println(type); |
|
|
if (type == null) |
|
|
type = "polygon"; |
|
|
|
|
|
/* String type = "point"; */ |
|
|
Style highlightStyle = null; |
|
|
if (type.toLowerCase().endsWith("polygon")) { |
|
|
highlightStyle = polygonHighlightStyle; |
|
|
} else if (type.toLowerCase().endsWith("point")) { |
|
|
highlightStyle = pointHighlightStyle; |
|
|
} else if (type.toLowerCase().endsWith("line")) { |
|
|
highlightStyle = lineHighlightStyle; |
|
|
} |
|
|
|
|
|
MapContext highlightContext = new DefaultMapContext( |
|
|
DefaultGeographicCRS.WGS84); |
|
|
|
|
|
highlightContext.addLayer(highlightFeature, highlightStyle); |
|
|
highlightRenderer.setContext(highlightContext); |
|
|
|
|
|
/* System.out.println("rendering highlight"); */ |
|
|
highlightRenderer.paint((Graphics2D) g, dr, mapArea); |
|
|
} |
|
371 |
} |
} |
372 |
|
|
373 |
private Envelope fixAspectRatio(Rectangle r, Envelope mapArea) { |
private Envelope fixAspectRatio(final Rectangle r, final Envelope mapArea) { |
374 |
|
|
375 |
double mapWidth = mapArea.getWidth(); /* get the extent of the map */ |
final double mapWidth = mapArea.getWidth(); /* get the extent of the map */ |
376 |
double mapHeight = mapArea.getHeight(); |
final double mapHeight = mapArea.getHeight(); |
377 |
double scaleX = r.getWidth() / mapArea.getWidth(); /* |
final double scaleX = r.getWidth() / mapArea.getWidth(); /* |
378 |
* calculate the new |
* calculate the |
379 |
* scale |
* new scale |
380 |
*/ |
*/ |
381 |
|
|
382 |
double scaleY = r.getHeight() / mapArea.getHeight(); |
final double scaleY = r.getHeight() / mapArea.getHeight(); |
383 |
double scale = 1.0; // stupid compiler! |
double scale = 1.0; // stupid compiler! |
384 |
|
|
385 |
if (scaleX < scaleY) { /* pick the smaller scale */ |
if (scaleX > scaleY) { /* pick the smaller scale */ |
386 |
scale = scaleX; |
scale = scaleX; |
387 |
} else { |
} else { |
388 |
scale = scaleY; |
scale = scaleY; |
389 |
} |
} |
390 |
|
|
391 |
/* calculate the difference in width and height of the new extent */ |
/* calculate the difference in width and height of the new extent */ |
392 |
double deltaX = /* Math.abs */((r.getWidth() / scale) - mapWidth); |
final double deltaX = /* Math.abs */((r.getWidth() / scale) - mapWidth); |
393 |
double deltaY = /* Math.abs */((r.getHeight() / scale) - mapHeight); |
final double deltaY = /* Math.abs */((r.getHeight() / scale) - mapHeight); |
394 |
|
|
395 |
/* |
/* |
396 |
* System.out.println("delta x " + deltaX); |
* System.out.println("delta x " + deltaX); |
398 |
*/ |
*/ |
399 |
|
|
400 |
/* create the new extent */ |
/* create the new extent */ |
401 |
Coordinate ll = new Coordinate(mapArea.getMinX() - (deltaX / 2.0), |
final Coordinate ll = new Coordinate( |
402 |
mapArea.getMinY() - (deltaY / 2.0)); |
mapArea.getMinX() - (deltaX / 2.0), mapArea.getMinY() |
403 |
Coordinate ur = new Coordinate(mapArea.getMaxX() + (deltaX / 2.0), |
- (deltaY / 2.0)); |
404 |
mapArea.getMaxY() + (deltaY / 2.0)); |
final Coordinate ur = new Coordinate( |
405 |
|
mapArea.getMaxX() + (deltaX / 2.0), mapArea.getMaxY() |
406 |
|
+ (deltaY / 2.0)); |
407 |
|
|
408 |
return new Envelope(ll, ur); |
return new Envelope(ll, ur); |
409 |
} |
} |
410 |
|
|
411 |
public void doSelection(double x, double y, MapLayer layer) { |
public void mouseClicked(final MouseEvent e) { |
412 |
|
if (mapArea == null) |
|
Geometry geometry = gf.createPoint(new Coordinate(x, y)); |
|
|
|
|
|
// org.opengis.geometry.Geometry geometry = new Point(); |
|
|
|
|
|
findFeature(geometry, layer); |
|
|
|
|
|
} |
|
|
|
|
|
/** |
|
|
* @param geometry |
|
|
* - a geometry to construct the filter with |
|
|
* @param i |
|
|
* - the index of the layer to search |
|
|
* @throws IndexOutOfBoundsException |
|
|
*/ |
|
|
private void findFeature(Geometry geometry, MapLayer layer) |
|
|
throws IndexOutOfBoundsException { |
|
|
org.opengis.filter.spatial.BinarySpatialOperator f = null; |
|
|
|
|
|
if ((context == null) || (layer == null)) { |
|
413 |
return; |
return; |
|
} |
|
|
|
|
|
try { |
|
|
String name = layer.getFeatureSource().getSchema() |
|
|
.getDefaultGeometry().getLocalName(); |
|
|
|
|
|
if (name == "") { |
|
|
name = "the_geom"; |
|
|
} |
|
|
|
|
|
try { |
|
|
f = ff.contains(ff.property(name), ff.literal(geometry)); |
|
|
if (selectionManager != null) { |
|
|
// System.out.println("selection changed"); |
|
|
selectionManager.selectionChanged(this, f); |
|
|
|
|
|
} |
|
|
} catch (IllegalFilterException e) { |
|
|
// TODO Auto-generated catch block |
|
|
e.printStackTrace(); |
|
|
} |
|
|
|
|
|
/* |
|
|
* // f.addLeftGeometry(ff.property(name)); // |
|
|
* System.out.println("looking with " + f); FeatureCollection fc = |
|
|
* layer.getFeatureSource().getFeatures(f); |
|
|
* |
|
|
* |
|
|
* |
|
|
* if (fcol == null) { fcol = fc; |
|
|
* |
|
|
* // here we should set the defaultgeom type } else { |
|
|
* fcol.addAll(fc); } |
|
|
*/ |
|
|
|
|
|
/* |
|
|
* GeometryAttributeType gat = |
|
|
* layer.getFeatureSource().getSchema().getDefaultGeometry(); |
|
|
* fcol.setDefaultGeometry((Geometry)gat.createDefaultValue()); |
|
|
*/ |
|
|
|
|
|
/* |
|
|
* Iterator fi = fc.iterator(); while (fi.hasNext()) { Feature feat |
|
|
* = (Feature) fi.next(); System.out.println("selected " + |
|
|
* feat.getAttribute("STATE_NAME")); } |
|
|
*/ |
|
|
} catch (IllegalFilterException e) { |
|
|
// TODO Auto-generated catch block |
|
|
e.printStackTrace(); |
|
|
} |
|
|
return; |
|
|
} |
|
|
|
|
|
public void mouseClicked(MouseEvent e) { |
|
414 |
// System.out.println("before area "+mapArea+"\nw:"+mapArea.getWidth()+" |
// System.out.println("before area "+mapArea+"\nw:"+mapArea.getWidth()+" |
415 |
// h:"+mapArea.getHeight()); |
// h:"+mapArea.getHeight()); |
416 |
Rectangle bounds = this.getBounds(); |
final Rectangle bounds = this.getBounds(); |
417 |
double x = (double) (e.getX()); |
final double x = (double) (e.getX()); |
418 |
double y = (double) (e.getY()); |
final double y = (double) (e.getY()); |
419 |
double width = mapArea.getWidth(); |
final double width = mapArea.getWidth(); |
420 |
double height = mapArea.getHeight(); |
final double height = mapArea.getHeight(); |
421 |
// xulu.sc |
// xulu.sc |
422 |
// double width2 = mapArea.getWidth() / 2.0; |
// double width2 = mapArea.getWidth() / 2.0; |
423 |
// double height2 = mapArea.getHeight() / 2.0; |
// double height2 = mapArea.getHeight() / 2.0; |
424 |
double width2 = width / 2.0; |
final double width2 = width / 2.0; |
425 |
double height2 = height / 2.0; |
final double height2 = height / 2.0; |
426 |
// xulu.ec |
// xulu.ec |
427 |
double mapX = ((x * width) / (double) bounds.width) + mapArea.getMinX(); |
final double mapX = ((x * width) / (double) bounds.width) |
428 |
double mapY = (((bounds.getHeight() - y) * height) / (double) bounds.height) |
+ mapArea.getMinX(); |
429 |
|
final double mapY = (((bounds.getHeight() - y) * height) / (double) bounds.height) |
430 |
+ mapArea.getMinY(); |
+ mapArea.getMinY(); |
431 |
|
|
432 |
/* |
/* |
456 |
zlevel = 1.0 / zoomFactor; |
zlevel = 1.0 / zoomFactor; |
457 |
|
|
458 |
break; |
break; |
459 |
|
// |
460 |
case Select: |
// case Select: |
461 |
doSelection(mapX, mapY, selectionLayer); |
// doSelection(mapX, mapY, selectionLayer); |
462 |
|
// |
463 |
return; |
// return; |
464 |
|
|
465 |
default: |
default: |
466 |
return; |
return; |
467 |
} |
} |
468 |
|
|
469 |
Coordinate ll = new Coordinate(mapX - (width2 / zlevel), mapY |
final Coordinate ll = new Coordinate(mapX - (width2 / zlevel), mapY |
470 |
- (height2 / zlevel)); |
- (height2 / zlevel)); |
471 |
Coordinate ur = new Coordinate(mapX + (width2 / zlevel), mapY |
final Coordinate ur = new Coordinate(mapX + (width2 / zlevel), mapY |
472 |
+ (height2 / zlevel)); |
+ (height2 / zlevel)); |
473 |
// xulu.sc SK: Check for min/max scale |
// xulu.sc SK: Check for min/max scale |
474 |
// mapArea = new Envelope(ll, ur); |
// mapArea = new Envelope(ll, ur); |
483 |
repaint(); |
repaint(); |
484 |
} |
} |
485 |
|
|
486 |
public void mouseEntered(MouseEvent e) { |
public void mouseEntered(final MouseEvent e) { |
487 |
} |
} |
488 |
|
|
489 |
public void mouseExited(MouseEvent e) { |
public void mouseExited(final MouseEvent e) { |
490 |
} |
} |
491 |
|
|
492 |
public void mousePressed(MouseEvent e) { |
public void mousePressed(final MouseEvent e) { |
493 |
startX = e.getX(); |
startX = e.getX(); |
494 |
startY = e.getY(); |
startY = e.getY(); |
495 |
lastX = 0; |
lastX = 0; |
496 |
lastY = 0; |
lastY = 0; |
497 |
} |
} |
498 |
|
|
499 |
public void mouseReleased(MouseEvent e) { |
public void mouseReleased(final MouseEvent e) { |
500 |
int endX = e.getX(); |
final int endX = e.getX(); |
501 |
int endY = e.getY(); |
final int endY = e.getY(); |
502 |
|
|
503 |
processDrag(startX, startY, endX, endY, e); |
processDrag(startX, startY, endX, endY, e); |
504 |
lastX = 0; |
lastX = 0; |
510 |
panning_started = false; |
panning_started = false; |
511 |
} |
} |
512 |
|
|
513 |
public void mouseDragged(MouseEvent e) { |
public void mouseDragged(final MouseEvent e) { |
514 |
Graphics graphics = this.getGraphics(); |
final Graphics graphics = this.getGraphics(); |
515 |
int x = e.getX(); |
final int x = e.getX(); |
516 |
int y = e.getY(); |
final int y = e.getY(); |
517 |
|
|
518 |
if ((state == JMapPane.Pan) |
if ((state == JMapPane.Pan) |
519 |
|| ((e.getModifiersEx() & InputEvent.BUTTON3_DOWN_MASK) != 0)) { |
|| ((e.getModifiersEx() & InputEvent.BUTTON3_DOWN_MASK) != 0)) { |
527 |
|
|
528 |
// move the image with the mouse |
// move the image with the mouse |
529 |
if ((lastX > 0) && (lastY > 0)) { |
if ((lastX > 0) && (lastY > 0)) { |
530 |
int dx = lastX - startX; |
final int dx = lastX - startX; |
531 |
int dy = lastY - startY; |
final int dy = lastY - startY; |
532 |
// System.out.println("translate "+dx+","+dy); |
// System.out.println("translate "+dx+","+dy); |
533 |
final Graphics2D g2 = panningImage.createGraphics(); |
final Graphics2D g2 = panningImage.createGraphics(); |
534 |
g2.setBackground(new Color(240, 240, 240)); // TODO richtige |
g2.setBackground(new Color(240, 240, 240)); // TODO richtige |
535 |
// farbe? am besten |
// farbe? am besten |
536 |
// vom L&F die |
// vom L&F die |
537 |
// hintergrundfarbe |
// hintergrundfarbe |
538 |
// auslesen... |
// auslesen... |
539 |
|
|
540 |
g2.clearRect(0, 0, this.getWidth(), this.getHeight()); |
g2.clearRect(0, 0, this.getWidth(), this.getHeight()); |
541 |
g2.drawImage(baseImage, dx, dy, this); |
g2.drawImage(baseImage, dx, dy, this); |
542 |
graphics.drawImage(panningImage, 0, 0, this); |
graphics.drawImage(panningImage, 0, 0, this); |
558 |
lastX = x; |
lastX = x; |
559 |
lastY = y; |
lastY = y; |
560 |
drawRectangle(graphics); |
drawRectangle(graphics); |
|
} else if (state == JMapPane.Select && selectionLayer != null) { |
|
|
|
|
|
// construct a new bbox filter |
|
|
Rectangle bounds = this.getBounds(); |
|
|
|
|
|
double mapWidth = mapArea.getWidth(); |
|
|
double mapHeight = mapArea.getHeight(); |
|
|
|
|
|
double x1 = ((this.startX * mapWidth) / (double) bounds.width) |
|
|
+ mapArea.getMinX(); |
|
|
double y1 = (((bounds.getHeight() - this.startY) * mapHeight) / (double) bounds.height) |
|
|
+ mapArea.getMinY(); |
|
|
double x2 = ((x * mapWidth) / (double) bounds.width) |
|
|
+ mapArea.getMinX(); |
|
|
double y2 = (((bounds.getHeight() - y) * mapHeight) / (double) bounds.height) |
|
|
+ mapArea.getMinY(); |
|
|
double left = Math.min(x1, x2); |
|
|
double right = Math.max(x1, x2); |
|
|
double bottom = Math.min(y1, y2); |
|
|
double top = Math.max(y1, y2); |
|
|
|
|
|
String name = selectionLayer.getFeatureSource().getSchema() |
|
|
.getDefaultGeometry().getName(); |
|
|
|
|
|
if (name == "") { |
|
|
name = "the_geom"; |
|
|
} |
|
|
Filter bb = ff.bbox(ff.property(name), left, bottom, right, top, |
|
|
getContext().getCoordinateReferenceSystem().toString()); |
|
|
if (selectionManager != null) { |
|
|
selectionManager.selectionChanged(this, bb); |
|
|
} |
|
|
|
|
|
graphics.setXORMode(Color.green); |
|
|
|
|
|
/* |
|
|
* if ((lastX > 0) && (lastY > 0)) { drawRectangle(graphics); } |
|
|
*/ |
|
|
|
|
|
// draw new box |
|
|
lastX = x; |
|
|
lastY = y; |
|
|
drawRectangle(graphics); |
|
561 |
} |
} |
562 |
|
// else if (state == JMapPane.Select && selectionLayer != null) { |
563 |
|
// |
564 |
|
// // construct a new bbox filter |
565 |
|
// final Rectangle bounds = this.getBounds(); |
566 |
|
// |
567 |
|
// final double mapWidth = mapArea.getWidth(); |
568 |
|
// final double mapHeight = mapArea.getHeight(); |
569 |
|
// |
570 |
|
// final double x1 = ((this.startX * mapWidth) / (double) bounds.width) |
571 |
|
// + mapArea.getMinX(); |
572 |
|
// final double y1 = (((bounds.getHeight() - this.startY) * mapHeight) / |
573 |
|
// (double) bounds.height) |
574 |
|
// + mapArea.getMinY(); |
575 |
|
// final double x2 = ((x * mapWidth) / (double) bounds.width) |
576 |
|
// + mapArea.getMinX(); |
577 |
|
// final double y2 = (((bounds.getHeight() - y) * mapHeight) / (double) |
578 |
|
// bounds.height) |
579 |
|
// + mapArea.getMinY(); |
580 |
|
// final double left = Math.min(x1, x2); |
581 |
|
// final double right = Math.max(x1, x2); |
582 |
|
// final double bottom = Math.min(y1, y2); |
583 |
|
// final double top = Math.max(y1, y2); |
584 |
|
// |
585 |
|
// String name = selectionLayer.getFeatureSource().getSchema() |
586 |
|
// .getDefaultGeometry().getName(); |
587 |
|
// |
588 |
|
// if (name == "") { |
589 |
|
// name = "the_geom"; |
590 |
|
// } |
591 |
|
// final Filter bb = ff.bbox(ff.property(name), left, bottom, right, |
592 |
|
// top, |
593 |
|
// getContext().getCoordinateReferenceSystem().toString()); |
594 |
|
// if (selectionManager != null) { |
595 |
|
// selectionManager.selectionChanged(this, bb); |
596 |
|
// } |
597 |
|
// |
598 |
|
// graphics.setXORMode(Color.green); |
599 |
|
// |
600 |
|
// /* |
601 |
|
// * if ((lastX > 0) && (lastY > 0)) { drawRectangle(graphics); } |
602 |
|
// */ |
603 |
|
// |
604 |
|
// // draw new box |
605 |
|
// lastX = x; |
606 |
|
// lastY = y; |
607 |
|
// drawRectangle(graphics); |
608 |
|
// } |
609 |
|
|
610 |
} |
} |
611 |
|
|
613 |
// private void processDrag(int x1, int y1, int x2, int y2) { |
// private void processDrag(int x1, int y1, int x2, int y2) { |
614 |
// sk.ce |
// sk.ce |
615 |
protected void processDrag(final int x1, final int y1, final int x2, |
protected void processDrag(final int x1, final int y1, final int x2, |
616 |
final int y2, MouseEvent e) { |
final int y2, final MouseEvent e) { |
617 |
|
|
618 |
/**** |
/**** |
619 |
* If no layer is availabe we dont want a NullPointerException |
* If no layer is availabe we dont want a NullPointerException |
632 |
return; |
return; |
633 |
} |
} |
634 |
|
|
635 |
Rectangle bounds = this.getBounds(); |
final Rectangle bounds = this.getBounds(); |
636 |
|
|
637 |
double mapWidth = mapArea.getWidth(); |
final double mapWidth = mapArea.getWidth(); |
638 |
double mapHeight = mapArea.getHeight(); |
final double mapHeight = mapArea.getHeight(); |
639 |
|
|
640 |
double startX = ((x1 * mapWidth) / (double) bounds.width) |
final double startX = ((x1 * mapWidth) / (double) bounds.width) |
641 |
+ mapArea.getMinX(); |
+ mapArea.getMinX(); |
642 |
double startY = (((bounds.getHeight() - y1) * mapHeight) / (double) bounds.height) |
final double startY = (((bounds.getHeight() - y1) * mapHeight) / (double) bounds.height) |
643 |
+ mapArea.getMinY(); |
+ mapArea.getMinY(); |
644 |
double endX = ((x2 * mapWidth) / (double) bounds.width) |
final double endX = ((x2 * mapWidth) / (double) bounds.width) |
645 |
+ mapArea.getMinX(); |
+ mapArea.getMinX(); |
646 |
double endY = (((bounds.getHeight() - y2) * mapHeight) / (double) bounds.height) |
final double endY = (((bounds.getHeight() - y2) * mapHeight) / (double) bounds.height) |
647 |
+ mapArea.getMinY(); |
+ mapArea.getMinY(); |
648 |
|
|
649 |
if ((state == JMapPane.Pan) || (e.getButton() == MouseEvent.BUTTON3)) { |
if ((state == JMapPane.Pan) || (e.getButton() == MouseEvent.BUTTON3)) { |
650 |
// move the image with the mouse |
// move the image with the mouse |
651 |
// calculate X offsets from start point to the end Point |
// calculate X offsets from start point to the end Point |
652 |
double deltaX1 = endX - startX; |
final double deltaX1 = endX - startX; |
653 |
|
|
654 |
// System.out.println("deltaX " + deltaX1); |
// System.out.println("deltaX " + deltaX1); |
655 |
// new edges |
// new edges |
656 |
double left = mapArea.getMinX() - deltaX1; |
final double left = mapArea.getMinX() - deltaX1; |
657 |
double right = mapArea.getMaxX() - deltaX1; |
final double right = mapArea.getMaxX() - deltaX1; |
658 |
|
|
659 |
// now for Y |
// now for Y |
660 |
double deltaY1 = endY - startY; |
final double deltaY1 = endY - startY; |
661 |
|
|
662 |
// System.out.println("deltaY " + deltaY1); |
// System.out.println("deltaY " + deltaY1); |
663 |
double bottom = mapArea.getMinY() - deltaY1; |
final double bottom = mapArea.getMinY() - deltaY1; |
664 |
double top = mapArea.getMaxY() - deltaY1; |
final double top = mapArea.getMaxY() - deltaY1; |
665 |
Coordinate ll = new Coordinate(left, bottom); |
final Coordinate ll = new Coordinate(left, bottom); |
666 |
Coordinate ur = new Coordinate(right, top); |
final Coordinate ur = new Coordinate(right, top); |
667 |
// xulu.sc |
// xulu.sc |
668 |
// mapArea = fixAspectRatio(this.getBounds(), new Envelope(ll, ur)); |
// mapArea = fixAspectRatio(this.getBounds(), new Envelope(ll, ur)); |
669 |
setMapArea(fixAspectRatio(this.getBounds(), new Envelope(ll, ur))); |
setMapArea(fixAspectRatio(this.getBounds(), new Envelope(ll, ur))); |
678 |
|
|
679 |
drawRectangle(this.getGraphics()); |
drawRectangle(this.getGraphics()); |
680 |
// make the dragged rectangle (in map coords) the new BBOX |
// make the dragged rectangle (in map coords) the new BBOX |
681 |
double left = Math.min(startX, endX); |
final double left = Math.min(startX, endX); |
682 |
double right = Math.max(startX, endX); |
final double right = Math.max(startX, endX); |
683 |
double bottom = Math.min(startY, endY); |
final double bottom = Math.min(startY, endY); |
684 |
double top = Math.max(startY, endY); |
final double top = Math.max(startY, endY); |
685 |
Coordinate ll = new Coordinate(left, bottom); |
final Coordinate ll = new Coordinate(left, bottom); |
686 |
Coordinate ur = new Coordinate(right, top); |
final Coordinate ur = new Coordinate(right, top); |
687 |
// xulu.sc |
// xulu.sc |
688 |
|
|
689 |
// mapArea = fixAspectRatio(this.getBounds(), new Envelope(ll, ur)); |
// mapArea = fixAspectRatio(this.getBounds(), new Envelope(ll, ur)); |
690 |
setMapArea(bestAllowedMapArea(new Envelope(ll, ur))); |
setMapArea(bestAllowedMapArea(new Envelope(ll, ur))); |
691 |
|
|
692 |
// sk.sc |
// sk.sc |
693 |
// { |
// { |
694 |
// // SK tries to paint a preview of the zoom ;-9 aha.... well |
// // SK tries to paint a preview of the zoom ;-9 aha.... well |
695 |
// Graphics2D graphics = (Graphics2D) JMapPane.this.getGraphics(); |
// Graphics2D graphics = (Graphics2D) JMapPane.this.getGraphics(); |
696 |
// graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, |
// graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, |
697 |
// RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR); |
// RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR); |
698 |
// graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, |
// graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, |
699 |
// RenderingHints.VALUE_ANTIALIAS_OFF); |
// RenderingHints.VALUE_ANTIALIAS_OFF); |
700 |
// graphics.setRenderingHint(RenderingHints.KEY_RENDERING, |
// graphics.setRenderingHint(RenderingHints.KEY_RENDERING, |
701 |
// RenderingHints.VALUE_RENDER_SPEED); |
// RenderingHints.VALUE_RENDER_SPEED); |
702 |
// graphics.drawImage(baseImage, 0, 0, JMapPane.this.getWidth(), |
// graphics.drawImage(baseImage, 0, 0, JMapPane.this.getWidth(), |
703 |
// JMapPane.this.getHeight(), x1, y1, x2, y2, null); |
// JMapPane.this.getHeight(), x1, y1, x2, y2, null); |
704 |
// } |
// } |
705 |
// xulu.ec |
// xulu.ec |
706 |
} else if (state == JMapPane.ZoomOut) { |
} else if (state == JMapPane.ZoomOut) { |
707 |
drawRectangle(this.getGraphics()); |
drawRectangle(this.getGraphics()); |
708 |
|
|
709 |
// make the dragged rectangle in screen coords the new map size? |
// make the dragged rectangle in screen coords the new map size? |
710 |
double left = Math.min(startX, endX); |
final double left = Math.min(startX, endX); |
711 |
double right = Math.max(startX, endX); |
final double right = Math.max(startX, endX); |
712 |
double bottom = Math.min(startY, endY); |
final double bottom = Math.min(startY, endY); |
713 |
double top = Math.max(startY, endY); |
final double top = Math.max(startY, endY); |
714 |
double nWidth = (mapWidth * mapWidth) / (right - left); |
final double nWidth = (mapWidth * mapWidth) / (right - left); |
715 |
double nHeight = (mapHeight * mapHeight) / (top - bottom); |
final double nHeight = (mapHeight * mapHeight) / (top - bottom); |
716 |
double deltaX1 = left - mapArea.getMinX(); |
final double deltaX1 = left - mapArea.getMinX(); |
717 |
double nDeltaX1 = (deltaX1 * nWidth) / mapWidth; |
final double nDeltaX1 = (deltaX1 * nWidth) / mapWidth; |
718 |
double deltaY1 = bottom - mapArea.getMinY(); |
final double deltaY1 = bottom - mapArea.getMinY(); |
719 |
double nDeltaY1 = (deltaY1 * nHeight) / mapHeight; |
final double nDeltaY1 = (deltaY1 * nHeight) / mapHeight; |
720 |
Coordinate ll = new Coordinate(mapArea.getMinX() - nDeltaX1, |
final Coordinate ll = new Coordinate(mapArea.getMinX() - nDeltaX1, |
721 |
mapArea.getMinY() - nDeltaY1); |
mapArea.getMinY() - nDeltaY1); |
722 |
double deltaX2 = mapArea.getMaxX() - right; |
final double deltaX2 = mapArea.getMaxX() - right; |
723 |
double nDeltaX2 = (deltaX2 * nWidth) / mapWidth; |
final double nDeltaX2 = (deltaX2 * nWidth) / mapWidth; |
724 |
double deltaY2 = mapArea.getMaxY() - top; |
final double deltaY2 = mapArea.getMaxY() - top; |
725 |
double nDeltaY2 = (deltaY2 * nHeight) / mapHeight; |
final double nDeltaY2 = (deltaY2 * nHeight) / mapHeight; |
726 |
Coordinate ur = new Coordinate(mapArea.getMaxX() + nDeltaX2, |
final Coordinate ur = new Coordinate(mapArea.getMaxX() + nDeltaX2, |
727 |
mapArea.getMaxY() + nDeltaY2); |
mapArea.getMaxY() + nDeltaY2); |
728 |
// xulu.sc |
// xulu.sc |
729 |
// mapArea = fixAspectRatio(this.getBounds(), new Envelope(ll, ur)); |
// mapArea = fixAspectRatio(this.getBounds(), new Envelope(ll, ur)); |
730 |
setMapArea(bestAllowedMapArea(new Envelope(ll, ur))); |
setMapArea(bestAllowedMapArea(new Envelope(ll, ur))); |
731 |
|
|
732 |
// xulu.ec |
// xulu.ec |
|
} else if (state == JMapPane.Select && selectionLayer != null) { |
|
|
double left = Math.min(startX, endX); |
|
|
double right = Math.max(startX, endX); |
|
|
double bottom = Math.min(startY, endY); |
|
|
double top = Math.max(startY, endY); |
|
|
|
|
|
String name = selectionLayer.getFeatureSource().getSchema() |
|
|
.getDefaultGeometry().getLocalName(); |
|
|
|
|
|
if (name == "") { |
|
|
name = "the_geom"; |
|
|
} |
|
|
Filter bb = ff.bbox(ff.property(name), left, bottom, right, top, |
|
|
getContext().getCoordinateReferenceSystem().toString()); |
|
|
// System.out.println(bb.toString()); |
|
|
if (selectionManager != null) { |
|
|
selectionManager.selectionChanged(this, bb); |
|
|
} |
|
|
/* |
|
|
* FeatureCollection fc; selection = null; try { fc = |
|
|
* selectionLayer.getFeatureSource().getFeatures(bb); selection = |
|
|
* fc; } catch (IOException e) { e.printStackTrace(); } |
|
|
*/ |
|
733 |
} |
} |
734 |
|
// else if (state == JMapPane.Select && selectionLayer != null) { |
735 |
|
// final double left = Math.min(startX, endX); |
736 |
|
// final double right = Math.max(startX, endX); |
737 |
|
// final double bottom = Math.min(startY, endY); |
738 |
|
// final double top = Math.max(startY, endY); |
739 |
|
// |
740 |
|
// String name = selectionLayer.getFeatureSource().getSchema() |
741 |
|
// .getDefaultGeometry().getLocalName(); |
742 |
|
// |
743 |
|
// if (name == "") { |
744 |
|
// name = "the_geom"; |
745 |
|
// } |
746 |
|
// final Filter bb = ff.bbox(ff.property(name), left, bottom, right, |
747 |
|
// top, |
748 |
|
// getContext().getCoordinateReferenceSystem().toString()); |
749 |
|
// // System.out.println(bb.toString()); |
750 |
|
// if (selectionManager != null) { |
751 |
|
// selectionManager.selectionChanged(this, bb); |
752 |
|
// } |
753 |
|
// /* |
754 |
|
// * FeatureCollection fc; selection = null; try { fc = |
755 |
|
// * selectionLayer.getFeatureSource().getFeatures(bb); selection = |
756 |
|
// * fc; } catch (IOException e) { e.printStackTrace(); } |
757 |
|
// */ |
758 |
|
// } |
759 |
|
|
760 |
// xulu.so |
// xulu.so |
761 |
// setMapArea(mapArea); |
// setMapArea(mapArea); |
767 |
return clickable; |
return clickable; |
768 |
} |
} |
769 |
|
|
770 |
private org.geotools.styling.Style setupStyle(int type, Color color) { |
// |
771 |
StyleFactory sf = org.geotools.factory.CommonFactoryFinder |
// private org.geotools.styling.Style setupStyle(final int type, final Color |
772 |
.getStyleFactory(null); |
// color) { |
773 |
StyleBuilder sb = new StyleBuilder(); |
// final StyleFactory sf = org.geotools.factory.CommonFactoryFinder |
774 |
|
// .getStyleFactory(null); |
775 |
org.geotools.styling.Style s = sf.createStyle(); |
// final StyleBuilder sb = new StyleBuilder(); |
776 |
s.setTitle("selection"); |
// |
777 |
|
// org.geotools.styling.Style s = sf.createStyle(); |
778 |
// TODO parameterise the color |
// s.setTitle("selection"); |
779 |
PolygonSymbolizer ps = sb.createPolygonSymbolizer(color); |
// |
780 |
ps.setStroke(sb.createStroke(color)); |
// // TODO parameterise the color |
781 |
|
// final PolygonSymbolizer ps = sb.createPolygonSymbolizer(color); |
782 |
LineSymbolizer ls = sb.createLineSymbolizer(color); |
// ps.setStroke(sb.createStroke(color)); |
783 |
Graphic h = sb.createGraphic(); |
// |
784 |
h.setMarks(new Mark[] { sb.createMark("square", color) }); |
// final LineSymbolizer ls = sb.createLineSymbolizer(color); |
785 |
|
// final Graphic h = sb.createGraphic(); |
786 |
PointSymbolizer pts = sb.createPointSymbolizer(h); |
// h.setMarks(new Mark[] { sb.createMark("square", color) }); |
787 |
|
// |
788 |
// Rule r = sb.createRule(new Symbolizer[]{ps,ls,pts}); |
// final PointSymbolizer pts = sb.createPointSymbolizer(h); |
789 |
switch (type) { |
// |
790 |
case POLYGON: |
// // Rule r = sb.createRule(new Symbolizer[]{ps,ls,pts}); |
791 |
s = sb.createStyle(ps); |
// switch (type) { |
792 |
|
// case POLYGON: |
793 |
break; |
// s = sb.createStyle(ps); |
794 |
|
// |
795 |
case POINT: |
// break; |
796 |
s = sb.createStyle(pts); |
// |
797 |
|
// case POINT: |
798 |
break; |
// s = sb.createStyle(pts); |
799 |
|
// |
800 |
|
// break; |
801 |
|
// |
802 |
|
// case LINE: |
803 |
|
// s = sb.createStyle(ls); |
804 |
|
// } |
805 |
|
// |
806 |
|
// return s; |
807 |
|
// } |
808 |
|
|
809 |
case LINE: |
public void propertyChange(final PropertyChangeEvent evt) { |
810 |
s = sb.createStyle(ls); |
final String prop = evt.getPropertyName(); |
|
} |
|
|
|
|
|
return s; |
|
|
} |
|
|
|
|
|
public void highlightChanged(HighlightChangedEvent e) { |
|
|
org.opengis.filter.Filter f = e.getFilter(); |
|
|
|
|
|
try { |
|
|
highlightFeature = highlightLayer.getFeatureSource().getFeatures(f); |
|
|
} catch (IOException e1) { |
|
|
// TODO Auto-generated catch block |
|
|
e1.printStackTrace(); |
|
|
} |
|
|
|
|
|
repaint(); |
|
|
} |
|
|
|
|
|
public void propertyChange(PropertyChangeEvent evt) { |
|
|
String prop = evt.getPropertyName(); |
|
811 |
|
|
812 |
if (prop.equalsIgnoreCase("crs")) { |
if (prop.equalsIgnoreCase("crs")) { |
813 |
context.setAreaOfInterest(context.getAreaOfInterest(), |
context.setAreaOfInterest(context.getAreaOfInterest(), |
819 |
return reset; |
return reset; |
820 |
} |
} |
821 |
|
|
822 |
public void setReset(boolean reset) { |
public void setReset(final boolean reset) { |
823 |
this.reset = reset; |
this.reset = reset; |
824 |
} |
} |
825 |
|
|
826 |
public void layerAdded(MapLayerListEvent event) { |
public void layerAdded(final MapLayerListEvent event) { |
827 |
changed = true; |
changed = true; |
828 |
|
|
829 |
if (context.getLayers().length == 1) { // the first one |
if (context.getLayers().length == 1) { // the first one |
835 |
if (mapArea == null) |
if (mapArea == null) |
836 |
mapArea = context.getLayerBounds(); |
mapArea = context.getLayerBounds(); |
837 |
// xulu.ec |
// xulu.ec |
838 |
} catch (IOException e) { |
} catch (final IOException e) { |
839 |
// TODO Auto-generated catch block |
// TODO Auto-generated catch block |
840 |
e.printStackTrace(); |
e.printStackTrace(); |
841 |
} |
} |
846 |
repaint(); |
repaint(); |
847 |
} |
} |
848 |
|
|
849 |
public void layerRemoved(MapLayerListEvent event) { |
public void layerRemoved(final MapLayerListEvent event) { |
850 |
changed = true; |
changed = true; |
851 |
repaint(); |
repaint(); |
852 |
} |
} |
853 |
|
|
854 |
public void layerChanged(MapLayerListEvent event) { |
public void layerChanged(final MapLayerListEvent event) { |
855 |
changed = true; |
changed = true; |
856 |
// System.out.println("layer changed - repaint"); |
// System.out.println("layer changed - repaint"); |
857 |
repaint(); |
repaint(); |
858 |
} |
} |
859 |
|
|
860 |
public void layerMoved(MapLayerListEvent event) { |
public void layerMoved(final MapLayerListEvent event) { |
861 |
changed = true; |
changed = true; |
862 |
repaint(); |
repaint(); |
863 |
} |
} |
864 |
|
|
865 |
protected void drawRectangle(Graphics graphics) { |
protected void drawRectangle(final Graphics graphics) { |
866 |
// undraw last box/draw new box |
// undraw last box/draw new box |
867 |
int left = Math.min(startX, lastX); |
final int left = Math.min(startX, lastX); |
868 |
int right = Math.max(startX, lastX); |
final int right = Math.max(startX, lastX); |
869 |
int top = Math.max(startY, lastY); |
final int top = Math.max(startY, lastY); |
870 |
int bottom = Math.min(startY, lastY); |
final int bottom = Math.min(startY, lastY); |
871 |
int width = right - left; |
final int width = right - left; |
872 |
int height = top - bottom; |
final int height = top - bottom; |
873 |
// System.out.println("drawing rect("+left+","+bottom+","+ width+","+ |
// System.out.println("drawing rect("+left+","+bottom+","+ width+","+ |
874 |
// height+")"); |
// height+")"); |
875 |
graphics.drawRect(left, bottom, width, height); |
graphics.drawRect(left, bottom, width, height); |
881 |
* |
* |
882 |
* @param clickable |
* @param clickable |
883 |
*/ |
*/ |
884 |
public void setClickable(boolean clickable) { |
public void setClickable(final boolean clickable) { |
885 |
this.clickable = clickable; |
this.clickable = clickable; |
886 |
} |
} |
887 |
|
|
888 |
public void mouseMoved(MouseEvent e) { |
public void mouseMoved(final MouseEvent e) { |
|
} |
|
|
|
|
|
public FeatureCollection getSelection() { |
|
|
return selection; |
|
|
} |
|
|
|
|
|
public void setSelection(FeatureCollection selection) { |
|
|
this.selection = selection; |
|
|
repaint(); |
|
|
} |
|
|
|
|
|
/* |
|
|
* (non-Javadoc) |
|
|
* |
|
|
* @see |
|
|
* org.geotools.gui.swing.event.SelectionChangeListener#selectionChanged |
|
|
* (org.geotools.gui.swing.event.SelectionChangedEvent) |
|
|
*/ |
|
|
public void selectionChanged(SelectionChangedEvent e) { |
|
|
|
|
|
try { |
|
|
selection = selectionLayer.getFeatureSource().getFeatures( |
|
|
e.getFilter()); |
|
|
repaint(); |
|
|
} catch (IOException e1) { |
|
|
e1.printStackTrace(); |
|
|
} |
|
|
} |
|
|
|
|
|
public SelectionManager getSelectionManager() { |
|
|
return selectionManager; |
|
|
} |
|
|
|
|
|
public void setSelectionManager(SelectionManager selectionManager) { |
|
|
this.selectionManager = selectionManager; |
|
|
this.selectionManager.addSelectionChangeListener(this); |
|
|
|
|
889 |
} |
} |
890 |
|
|
891 |
// xulu.sn |
// xulu.sn |
906 |
if (env == null) |
if (env == null) |
907 |
return env; |
return env; |
908 |
|
|
909 |
|
Envelope newArea = null; |
910 |
|
|
911 |
/** |
/** |
912 |
* Correct the aspect Ratio before we check the rest. Otherwise we might |
* Correct the aspect Ratio before we check the rest. Otherwise we might |
913 |
* easily fail. |
* easily fail. |
914 |
*/ |
*/ |
915 |
env = fixAspectRatio(this.getBounds(), env); |
env = fixAspectRatio(this.getBounds(), env); |
916 |
|
|
917 |
double scale = env.getWidth() / getWidth(); |
final double scale = env.getWidth() / getWidth(); |
918 |
double centerX = env.getMinX() + env.getWidth() / 2.; |
final double centerX = env.getMinX() + env.getWidth() / 2.; |
919 |
double centerY = env.getMinY() + env.getHeight() / 2.; |
final double centerY = env.getMinY() + env.getHeight() / 2.; |
920 |
double newWidth2; |
double newWidth2 = 0; |
921 |
double newHeight2; |
double newHeight2 = 0; |
922 |
if (scale < getMaxZoomScale()) { |
if (scale < getMaxZoomScale()) { |
923 |
// **************************************************************************** |
// **************************************************************************** |
924 |
// Wir zoomen weiter rein als erlaubt => Anpassen des envelope |
// Wir zoomen weiter rein als erlaubt => Anpassen des envelope |
935 |
// **************************************************************************** |
// **************************************************************************** |
936 |
// Die mapArea / der Envelope ist ist gueltig! Keine Aenderungen |
// Die mapArea / der Envelope ist ist gueltig! Keine Aenderungen |
937 |
// **************************************************************************** |
// **************************************************************************** |
938 |
return env; |
newArea = env; |
939 |
} |
} |
940 |
|
|
941 |
Coordinate ll = new Coordinate(centerX - newWidth2, centerY |
if (newArea == null) { |
|
- newHeight2); |
|
|
Coordinate ur = new Coordinate(centerX + newWidth2, centerY |
|
|
+ newHeight2); |
|
942 |
|
|
943 |
return new Envelope(ll, ur); |
final Coordinate ll = new Coordinate(centerX - newWidth2, centerY |
944 |
|
- newHeight2); |
945 |
|
final Coordinate ur = new Coordinate(centerX + newWidth2, centerY |
946 |
|
+ newHeight2); |
947 |
|
|
948 |
|
newArea = new Envelope(ll, ur); |
949 |
|
} |
950 |
|
|
951 |
|
if (getMaxExtend() != null) { |
952 |
|
|
953 |
|
while (!getMaxExtend().contains(newArea)) { |
954 |
|
/* |
955 |
|
* If a maxExtend is set, we have to honour that... |
956 |
|
*/ |
957 |
|
|
958 |
|
// Exceeds top? Move down and maybe cut |
959 |
|
if (newArea.getMaxY() > maxExtend.getMaxY()) { |
960 |
|
double divY = newArea.getMaxY() - maxExtend.getMaxY(); |
961 |
|
LOGGER.debug("Moving area down by " + divY); |
962 |
|
|
963 |
|
newArea = new Envelope(new Coordinate(newArea.getMinX(), |
964 |
|
newArea.getMinY() - divY), new Coordinate(newArea |
965 |
|
.getMaxX(), newArea.getMaxY() - divY)); |
966 |
|
|
967 |
|
if (newArea.getMinY() < maxExtend.getMinY()) { |
968 |
|
LOGGER.debug("Now it exeeds the bottom border.. cut!"); |
969 |
|
// And cut the bottom if it moved out of the area |
970 |
|
newArea = new Envelope(new Coordinate( |
971 |
|
newArea.getMinX(), maxExtend.getMinY()), |
972 |
|
new Coordinate(newArea.getMaxX(), newArea |
973 |
|
.getMaxY())); |
974 |
|
|
975 |
|
LOGGER.debug("and fix aspect ratio"); |
976 |
|
|
977 |
|
newArea = fixAspectRatio(this.getBounds(), newArea); |
978 |
|
} |
979 |
|
} |
980 |
|
|
981 |
|
// Exceeds bottom? Move up and maybe cut |
982 |
|
if (newArea.getMinY() < maxExtend.getMinY()) { |
983 |
|
double divY = newArea.getMinY() - maxExtend.getMinY(); |
984 |
|
LOGGER.debug("Moving area up by " + divY); |
985 |
|
|
986 |
|
newArea = new Envelope(new Coordinate(newArea.getMinX(), |
987 |
|
newArea.getMinY() - divY), new Coordinate(newArea |
988 |
|
.getMaxX(), newArea.getMaxY() - divY)); |
989 |
|
|
990 |
|
if (newArea.getMaxY() > maxExtend.getMaxY()) { |
991 |
|
LOGGER.debug("Now it exeeds the top border.. cut!"); |
992 |
|
// And cut the bottom if it moved out of the area |
993 |
|
newArea = new Envelope(new Coordinate( |
994 |
|
newArea.getMinX(), newArea.getMinY()), |
995 |
|
new Coordinate(newArea.getMaxX(), maxExtend |
996 |
|
.getMaxY())); |
997 |
|
|
998 |
|
LOGGER.debug("and fix aspect ratio"); |
999 |
|
|
1000 |
|
newArea = fixAspectRatio(this.getBounds(), newArea); |
1001 |
|
} |
1002 |
|
} |
1003 |
|
|
1004 |
|
// Exceeds to the right? move and maybe cut |
1005 |
|
if (newArea.getMaxX() > maxExtend.getMaxX()) { |
1006 |
|
|
1007 |
|
// Move left.. |
1008 |
|
double divX = newArea.getMaxX() - maxExtend.getMaxX(); |
1009 |
|
LOGGER.debug("Moving area left by " + divX); |
1010 |
|
|
1011 |
|
newArea = new Envelope(new Coordinate(newArea.getMinX() |
1012 |
|
- divX, newArea.getMinY()), new Coordinate(newArea |
1013 |
|
.getMaxX() |
1014 |
|
- divX, newArea.getMaxY())); |
1015 |
|
|
1016 |
|
if (newArea.getMinX() < maxExtend.getMinX()) { |
1017 |
|
LOGGER.debug("Now it exeeds the left border.. cut!"); |
1018 |
|
// And cut the left if it moved out of the area |
1019 |
|
newArea = new Envelope(new Coordinate(maxExtend |
1020 |
|
.getMinX(), newArea.getMinY()), new Coordinate( |
1021 |
|
newArea.getMaxX(), newArea.getMaxY())); |
1022 |
|
|
1023 |
|
LOGGER.debug("and fix aspect ratio"); |
1024 |
|
|
1025 |
|
newArea = fixAspectRatio(this.getBounds(), newArea); |
1026 |
|
} |
1027 |
|
} |
1028 |
|
|
1029 |
|
// Exceeds to the left? move and maybe cut |
1030 |
|
if (newArea.getMinX() < maxExtend.getMinX()) { |
1031 |
|
|
1032 |
|
// Move right.. |
1033 |
|
double divX = newArea.getMinX() - maxExtend.getMinX(); |
1034 |
|
LOGGER.debug("Moving area right by " + divX); |
1035 |
|
|
1036 |
|
newArea = new Envelope(new Coordinate(newArea.getMinX() |
1037 |
|
- divX, newArea.getMinY()), new Coordinate(newArea |
1038 |
|
.getMaxX() |
1039 |
|
- divX, newArea.getMaxY())); |
1040 |
|
|
1041 |
|
if (newArea.getMaxX() > maxExtend.getMaxX()) { |
1042 |
|
LOGGER.debug("Now it exeeds the right border.. cut!"); |
1043 |
|
// And cut the left if it moved out of the area |
1044 |
|
newArea = new Envelope(new Coordinate( |
1045 |
|
newArea.getMinX(), newArea.getMinY()), |
1046 |
|
new Coordinate(maxExtend.getMaxX(), newArea |
1047 |
|
.getMaxY())); |
1048 |
|
|
1049 |
|
LOGGER.debug("and fix aspect ratio"); |
1050 |
|
|
1051 |
|
newArea = fixAspectRatio(this.getBounds(), newArea); |
1052 |
|
} |
1053 |
|
} |
1054 |
|
|
1055 |
|
} |
1056 |
|
|
1057 |
|
} |
1058 |
|
|
1059 |
|
return newArea; |
1060 |
} |
} |
1061 |
|
|
1062 |
/** |
/** |
1088 |
* @author <a href="mailto:[email protected]">Stefan Alfons |
* @author <a href="mailto:[email protected]">Stefan Alfons |
1089 |
* Krüger</a> |
* Krüger</a> |
1090 |
*/ |
*/ |
1091 |
public void setMaxZoomScale(Double maxZoomScale) { |
public void setMaxZoomScale(final Double maxZoomScale) { |
|
// System.out.println("setting max scale to "+maxZoomScale); |
|
1092 |
this.maxZoomScale = maxZoomScale; |
this.maxZoomScale = maxZoomScale; |
1093 |
} |
} |
1094 |
|
|
1099 |
* @author <a href="mailto:[email protected]">Stefan Alfons |
* @author <a href="mailto:[email protected]">Stefan Alfons |
1100 |
* Krüger</a> |
* Krüger</a> |
1101 |
*/ |
*/ |
1102 |
public void setMinZoomScale(Double minZoomScale) { |
public void setMinZoomScale(final Double minZoomScale) { |
1103 |
this.minZoomScale = minZoomScale; |
this.minZoomScale = minZoomScale; |
1104 |
} |
} |
1105 |
// xulu.en |
|
1106 |
|
/** |
1107 |
|
* Defines an evelope of the viwable area. The JMapPane will never show |
1108 |
|
* anything outside of this extend. |
1109 |
|
* |
1110 |
|
* @param maxExtend |
1111 |
|
* <code>null</code> to not have this restriction. |
1112 |
|
*/ |
1113 |
|
public void setMaxExtend(Envelope maxExtend) { |
1114 |
|
this.maxExtend = maxExtend; |
1115 |
|
} |
1116 |
|
|
1117 |
|
/** |
1118 |
|
* Returns the evelope of the viewable area. The JMapPane will never show |
1119 |
|
* anything outside of this extend. |
1120 |
|
* |
1121 |
|
* @param maxExtend |
1122 |
|
* <code>null</code> to not have this restriction. |
1123 |
|
*/ |
1124 |
|
|
1125 |
|
public Envelope getMaxExtend() { |
1126 |
|
return maxExtend; |
1127 |
|
} |
1128 |
|
|
1129 |
} |
} |