179 |
179 |
*/
|
180 |
180 |
public FFrameView() {
|
181 |
181 |
num++;
|
|
182 |
// logger.info("Create FFrameView "+ Integer.toHexString(this.hashCode()));
|
182 |
183 |
createListeners();
|
183 |
184 |
}
|
184 |
185 |
|
185 |
|
protected void createListeners() {
|
186 |
|
viewDocListener = new ViewDocListener();
|
187 |
|
ownMapContextListener = new OwnMapContextListener();
|
188 |
|
}
|
189 |
|
|
190 |
186 |
/**
|
191 |
187 |
* Returns a description of the FFrame
|
192 |
188 |
*
|
... | ... | |
284 |
280 |
public void setViewMapContext(MapContext viewMapContext) {
|
285 |
281 |
Envelope oldEnvelope = null;
|
286 |
282 |
if (mapContext!=null) {
|
287 |
|
clearOwnListeners(mapContext);
|
|
283 |
removeOwnListeners();
|
288 |
284 |
if (mapContext.getViewPort()!=null) {
|
289 |
285 |
oldEnvelope = mapContext.getViewPort().getEnvelope();
|
290 |
286 |
}
|
... | ... | |
320 |
316 |
newViewPort.setImageSize(new Dimension((int) getBoundingBox(at).width,
|
321 |
317 |
(int) getBoundingBox(at).height));
|
322 |
318 |
newViewPort.setDPI(getDrawPaperDPI());
|
323 |
|
setListeners();
|
|
319 |
addAllListeners();
|
324 |
320 |
updateScaleCtrl();
|
325 |
321 |
setTocModel();
|
326 |
322 |
} catch (CloneNotSupportedException e1) {
|
... | ... | |
335 |
331 |
* also used to synchronize the FFrameView with
|
336 |
332 |
* the associated View, depending on the selected scale type
|
337 |
333 |
*
|
338 |
|
* @param viewMapContext
|
|
334 |
* @param dvd
|
339 |
335 |
*/
|
340 |
336 |
public void setView(ViewDocument dvd) {
|
341 |
|
ViewDocument oldDoc = viewDocument;
|
342 |
|
if (oldDoc!=null) {
|
343 |
|
if (oldDoc.getMapContext()!=null) {
|
344 |
|
clearViewListeners(oldDoc.getMapContext());
|
345 |
|
}
|
346 |
|
}
|
|
337 |
removeViewListeners();
|
347 |
338 |
viewDocument = dvd;
|
348 |
339 |
if (dvd!=null) {
|
349 |
340 |
setViewMapContext(dvd.getMapContext());
|
|
341 |
} else {
|
|
342 |
setViewMapContext(null);
|
350 |
343 |
}
|
351 |
|
else {
|
352 |
|
setViewMapContext(null);
|
353 |
|
}
|
354 |
344 |
}
|
355 |
345 |
|
356 |
346 |
/**
|
... | ... | |
842 |
832 |
}
|
843 |
833 |
}
|
844 |
834 |
|
845 |
|
/**
|
846 |
|
* This method deals with places where this fframeview and the cloned
|
847 |
|
* fframeview (frame) are registered as listeners. The goal should be
|
848 |
|
* leaving the cloned instance (frame) as listener in the same way
|
849 |
|
* that 'this' instance is doing.
|
850 |
|
*/
|
851 |
|
protected void cloneActions(FFrameView frame) {
|
852 |
|
}
|
853 |
|
|
854 |
|
public Object clone() throws CloneNotSupportedException {
|
|
835 |
@Override
|
|
836 |
public FFrameView clone() throws CloneNotSupportedException {
|
|
837 |
// logger.info("clone FFrameView "+ Integer.toHexString(this.hashCode()));
|
855 |
838 |
FFrameView frame = (FFrameView) super.clone();
|
856 |
839 |
frame.createListeners(); // necessary to create the listeners within the right scope
|
857 |
840 |
frame.setView(this.getView());
|
858 |
|
|
|
841 |
frame.removeAllListeners(); // remove listeners add by setView
|
|
842 |
|
859 |
843 |
if (grid != null) {
|
860 |
844 |
FFrameGrid newGrid = (FFrameGrid) this.grid.clone();
|
861 |
845 |
newGrid.setFFrameDependence(frame);
|
862 |
846 |
frame.setGrid(newGrid);
|
863 |
847 |
}
|
864 |
|
cloneActions(frame);
|
|
848 |
// logger.info("cloned FFrameView "+ Integer.toHexString(frame.hashCode()));
|
865 |
849 |
return frame;
|
866 |
850 |
}
|
867 |
851 |
|
... | ... | |
1089 |
1073 |
b_validCache = false;
|
1090 |
1074 |
}
|
1091 |
1075 |
|
1092 |
|
protected void resetListeners() {
|
1093 |
|
if (this.getMapContext()!=null) {
|
1094 |
|
clearOwnListeners(this.getMapContext());
|
1095 |
|
}
|
1096 |
|
if (this.getView()!=null && this.getView().getMapContext()!=null) {
|
1097 |
|
clearViewListeners(this.getView().getMapContext());
|
1098 |
|
}
|
1099 |
|
setListeners();
|
|
1076 |
protected void createListeners() {
|
|
1077 |
this.removeAllListeners();
|
|
1078 |
viewDocListener = new ViewDocListener(this);
|
|
1079 |
ownMapContextListener = new OwnMapContextListener(this);
|
|
1080 |
// logger.info("createListeners.viewDocListener "+ viewDocListener.getID());
|
|
1081 |
// logger.info("createListeners.ownMapContextListener "+ ownMapContextListener.getID());
|
1100 |
1082 |
}
|
1101 |
1083 |
|
1102 |
|
protected void setListeners() {
|
1103 |
|
if (getView()!=null) {
|
1104 |
|
if (syncLayers) {
|
1105 |
|
getView().getMapContext().addLayerListener(viewDocListener);
|
1106 |
|
getView().getMapContext().getLayers().addLayerCollectionListener(viewDocListener);
|
1107 |
|
getView().getMapContext().addAtomicEventListener(viewDocListener);
|
1108 |
|
}
|
1109 |
|
if (getExtentSynced()) {
|
1110 |
|
getView().getMapContext().getViewPort().addViewPortListener(viewDocListener);
|
1111 |
|
}
|
1112 |
|
}
|
1113 |
|
if (getMapContext()!=null) {
|
1114 |
|
getMapContext().addLayerListener(ownMapContextListener);
|
1115 |
|
getMapContext().getLayers().addLayerCollectionListener(ownMapContextListener);
|
1116 |
|
getMapContext().getViewPort().addViewPortListener(ownMapContextListener);
|
1117 |
|
}
|
|
1084 |
protected void addAllListeners() {
|
|
1085 |
if( viewDocListener == null && ownMapContextListener == null ) {
|
|
1086 |
this.createListeners();
|
|
1087 |
}
|
|
1088 |
if (getView() != null) {
|
|
1089 |
if (syncLayers) {
|
|
1090 |
getView().getMapContext().addLayerListener(viewDocListener);
|
|
1091 |
getView().getMapContext().getLayers().addLayerCollectionListener(viewDocListener);
|
|
1092 |
getView().getMapContext().addAtomicEventListener(viewDocListener);
|
|
1093 |
}
|
|
1094 |
if (getExtentSynced()) {
|
|
1095 |
getView().getMapContext().getViewPort().addViewPortListener(viewDocListener);
|
|
1096 |
}
|
|
1097 |
}
|
|
1098 |
if (getMapContext() != null) {
|
|
1099 |
getMapContext().addLayerListener(ownMapContextListener);
|
|
1100 |
getMapContext().getLayers().addLayerCollectionListener(ownMapContextListener);
|
|
1101 |
getMapContext().getViewPort().addViewPortListener(ownMapContextListener);
|
|
1102 |
}
|
|
1103 |
// logger.info("addAllListeners.viewDocListener " + viewDocListener.getID());
|
|
1104 |
// logger.info("addAllListeners.ownMapContextListener " + ownMapContextListener.getID());
|
|
1105 |
|
1118 |
1106 |
}
|
1119 |
|
protected void clearOwnListeners(MapContext mapContext) {
|
1120 |
|
mapContext.removeLayerListener(ownMapContextListener);
|
1121 |
|
mapContext.getViewPort().removeViewPortListener(ownMapContextListener);
|
1122 |
|
mapContext.getLayers().removeLayerCollectionListener(ownMapContextListener);
|
|
1107 |
|
|
1108 |
protected void resetAllListeners() {
|
|
1109 |
this.removeAllListeners();
|
|
1110 |
this.addAllListeners();
|
1123 |
1111 |
}
|
1124 |
|
protected void clearViewListeners(MapContext mapContext) {
|
1125 |
|
mapContext.removeLayerListener(viewDocListener);
|
1126 |
|
mapContext.getViewPort().removeViewPortListener(viewDocListener);
|
1127 |
|
mapContext.getLayers().removeLayerCollectionListener(viewDocListener);
|
1128 |
|
mapContext.removeAtomicEventListener(viewDocListener);
|
|
1112 |
|
|
1113 |
protected void removeAllListeners() {
|
|
1114 |
removeOwnListeners();
|
|
1115 |
removeViewListeners();
|
1129 |
1116 |
}
|
1130 |
1117 |
|
1131 |
|
/*
|
1132 |
|
* (non-Javadoc)
|
1133 |
|
* @see org.gvsig.tools.dispose.Disposable#dispose()
|
1134 |
|
*/
|
1135 |
|
public void dispose() {
|
1136 |
|
try {
|
1137 |
|
if (this.getMapContext()!=null) {
|
1138 |
|
clearOwnListeners(this.getMapContext());
|
1139 |
|
}
|
1140 |
|
if (this.getView()!=null && this.getView().getMapContext()!=null) {
|
1141 |
|
clearViewListeners(this.getView().getMapContext());
|
1142 |
|
}
|
1143 |
|
}
|
1144 |
|
catch (Exception ex) {}
|
1145 |
|
this.viewDocument = null;
|
1146 |
|
this.mapContext = null;
|
1147 |
|
}
|
|
1118 |
protected void removeOwnListeners() {
|
|
1119 |
if( this.ownMapContextListener == null ) {
|
|
1120 |
return;
|
|
1121 |
}
|
|
1122 |
if( this.mapContext==null ) {
|
|
1123 |
return;
|
|
1124 |
}
|
|
1125 |
this.mapContext.removeLayerListener(ownMapContextListener);
|
|
1126 |
this.mapContext.getViewPort().removeViewPortListener(ownMapContextListener);
|
|
1127 |
this.mapContext.getLayers().removeLayerCollectionListener(ownMapContextListener);
|
|
1128 |
// logger.info("removeOwnListeners.ownMapContextListener " + ownMapContextListener.getID());
|
|
1129 |
}
|
1148 |
1130 |
|
|
1131 |
protected void removeViewListeners() {
|
|
1132 |
if( this.viewDocListener == null ) {
|
|
1133 |
return;
|
|
1134 |
}
|
|
1135 |
if( this.getView()==null ) {
|
|
1136 |
return;
|
|
1137 |
}
|
|
1138 |
MapContext mapContext = this.getView().getMapContext();
|
|
1139 |
if( mapContext == null ) {
|
|
1140 |
return;
|
|
1141 |
}
|
|
1142 |
mapContext.removeLayerListener(viewDocListener);
|
|
1143 |
mapContext.getViewPort().removeViewPortListener(viewDocListener);
|
|
1144 |
mapContext.getLayers().removeLayerCollectionListener(viewDocListener);
|
|
1145 |
mapContext.removeAtomicEventListener(viewDocListener);
|
|
1146 |
// logger.info("removeViewListeners.viewDocListener " + viewDocListener.getID());
|
|
1147 |
}
|
|
1148 |
|
|
1149 |
@Override
|
|
1150 |
public void dispose() {
|
|
1151 |
this.removeAllListeners();
|
|
1152 |
this.viewDocListener = null;
|
|
1153 |
this.ownMapContextListener = null;
|
|
1154 |
this.viewDocument = null;
|
|
1155 |
this.mapContext = null;
|
|
1156 |
}
|
|
1157 |
|
1149 |
1158 |
public void frameRemoved() {
|
1150 |
|
if (mapContext!=null) {
|
1151 |
|
clearOwnListeners(mapContext);
|
1152 |
|
}
|
1153 |
|
if (this.getView()!=null && this.getView().getMapContext()!=null) {
|
1154 |
|
clearViewListeners(this.getView().getMapContext());
|
1155 |
|
}
|
|
1159 |
this.removeAllListeners();
|
1156 |
1160 |
if (b_hasToc && getLayoutContext()!=null) {
|
1157 |
1161 |
getLayoutContext().setTocModel(null);
|
1158 |
1162 |
}
|
... | ... | |
1160 |
1164 |
}
|
1161 |
1165 |
|
1162 |
1166 |
public void frameAdded() {
|
1163 |
|
setListeners();
|
|
1167 |
addAllListeners();
|
1164 |
1168 |
setTocModel();
|
1165 |
1169 |
updateScaleCtrl();
|
1166 |
1170 |
}
|
... | ... | |
1197 |
1201 |
|
1198 |
1202 |
public void setLayerSynced(boolean synced) {
|
1199 |
1203 |
syncLayers = synced;
|
1200 |
|
resetListeners();
|
|
1204 |
resetAllListeners();
|
1201 |
1205 |
}
|
1202 |
1206 |
|
1203 |
1207 |
public boolean getExtentSynced() {
|
... | ... | |
1206 |
1210 |
|
1207 |
1211 |
public void setExtentSynced(boolean synced) {
|
1208 |
1212 |
syncExtents = synced;
|
1209 |
|
resetListeners();
|
|
1213 |
resetAllListeners();
|
1210 |
1214 |
}
|
1211 |
1215 |
|
1212 |
1216 |
/**
|
... | ... | |
1257 |
1261 |
|
1258 |
1262 |
return GeometryLocator.getGeometryManager().createEnvelope(minX, minY, maxX, maxY, SUBTYPES.GEOM2D);
|
1259 |
1263 |
}
|
1260 |
|
}
|
1261 |
|
catch (LocatorException e) {}
|
1262 |
|
catch (CreateEnvelopeException e) {}
|
|
1264 |
} catch (Exception e) {
|
|
1265 |
}
|
1263 |
1266 |
return newEnvelope;
|
1264 |
1267 |
}
|
1265 |
1268 |
|
1266 |
|
private class ViewDocListener
|
|
1269 |
protected boolean isDrawing() {
|
|
1270 |
return this.b_drawing;
|
|
1271 |
}
|
|
1272 |
|
|
1273 |
protected boolean isUpdating() {
|
|
1274 |
return this.b_updating;
|
|
1275 |
}
|
|
1276 |
|
|
1277 |
protected boolean skipFirstChangeExtent() {
|
|
1278 |
if( this.b_frameInitialized ) {
|
|
1279 |
return false;
|
|
1280 |
}
|
|
1281 |
this.b_frameInitialized = true;
|
|
1282 |
return true;
|
|
1283 |
}
|
|
1284 |
|
|
1285 |
protected boolean isSyncLayers() {
|
|
1286 |
return this.syncLayers;
|
|
1287 |
}
|
|
1288 |
|
|
1289 |
protected void beginUpdate() {
|
|
1290 |
this.b_updating = true;
|
|
1291 |
}
|
|
1292 |
|
|
1293 |
protected void endUpdate() {
|
|
1294 |
this.b_updating = false;
|
|
1295 |
}
|
|
1296 |
|
|
1297 |
@Override
|
|
1298 |
public SCALE_TYPE getScaleType() {
|
|
1299 |
return this.scaleType ;
|
|
1300 |
}
|
|
1301 |
|
|
1302 |
public Double getFixedScale() {
|
|
1303 |
return this.fixedScale;
|
|
1304 |
}
|
|
1305 |
|
|
1306 |
public Envelope getFixedExtent() {
|
|
1307 |
return this.fixedExtent;
|
|
1308 |
}
|
|
1309 |
|
|
1310 |
private class ViewDocListener
|
1267 |
1311 |
implements ViewPortListener, LegendListener, LayerCollectionListener, AtomicEventListener {
|
1268 |
1312 |
|
1269 |
|
public void extentChanged(ExtentEvent e) {
|
1270 |
|
if (!b_updating && getExtentSynced()) {
|
1271 |
|
if (!b_frameInitialized) {
|
1272 |
|
b_frameInitialized = true;
|
1273 |
|
return;
|
1274 |
|
}
|
1275 |
|
b_updating = true;
|
1276 |
|
if (getMapContext()!=null) {
|
1277 |
|
if (scaleType==SCALE_TYPE.FIXED_EXTENT) {
|
1278 |
|
getView().getMapContext().getViewPort().setEnvelope(fixedExtent);
|
1279 |
|
}
|
1280 |
|
else {
|
1281 |
|
getMapContext().getViewPort().setEnvelope(calculateNewExtent());
|
1282 |
|
if (scaleType==SCALE_TYPE.FIXED_SCALE) {
|
1283 |
|
getMapContext().setScaleView(Math.round(fixedScale));
|
1284 |
|
getView().getMapContext().getViewPort().setEnvelope(getMapContext().getViewPort().getAdjustedEnvelope());
|
1285 |
|
}
|
1286 |
|
updateScaleCtrl();
|
1287 |
|
invalidateLayout();
|
1288 |
|
}
|
1289 |
|
}
|
1290 |
|
b_updating = false;
|
1291 |
|
}
|
1292 |
|
}
|
|
1313 |
public ViewDocListener(FFrameView fview) {
|
1293 |
1314 |
|
|
1315 |
}
|
|
1316 |
|
|
1317 |
@Override
|
|
1318 |
public void extentChanged(ExtentEvent e) {
|
|
1319 |
if( isUpdating() ) {
|
|
1320 |
return;
|
|
1321 |
}
|
|
1322 |
if( skipFirstChangeExtent() ) {
|
|
1323 |
return;
|
|
1324 |
}
|
|
1325 |
if( !getExtentSynced() ) {
|
|
1326 |
return;
|
|
1327 |
}
|
|
1328 |
// logger.info("viewdoc-mapcontext.extentChanged " + this.getID());
|
|
1329 |
try {
|
|
1330 |
beginUpdate();
|
|
1331 |
if (getMapContext() != null) {
|
|
1332 |
if (null == getScaleType()) {
|
|
1333 |
getMapContext().getViewPort().setEnvelope(calculateNewExtent());
|
|
1334 |
} else switch (getScaleType()) {
|
|
1335 |
case FIXED_EXTENT:
|
|
1336 |
getView().getMapContext().getViewPort().setEnvelope(getFixedExtent());
|
|
1337 |
break;
|
|
1338 |
case FIXED_SCALE:
|
|
1339 |
getMapContext().setScaleView(Math.round(getFixedScale()));
|
|
1340 |
getView().getMapContext().getViewPort().setEnvelope(getMapContext().getViewPort().getAdjustedEnvelope());
|
|
1341 |
break;
|
|
1342 |
default:
|
|
1343 |
getMapContext().getViewPort().setEnvelope(calculateNewExtent());
|
|
1344 |
break;
|
|
1345 |
}
|
|
1346 |
updateScaleCtrl();
|
|
1347 |
invalidateLayout();
|
|
1348 |
}
|
|
1349 |
} finally {
|
|
1350 |
endUpdate();
|
|
1351 |
}
|
|
1352 |
}
|
|
1353 |
|
1294 |
1354 |
public void backColorChanged(ColorEvent e) {
|
1295 |
|
if (!b_updating && syncLayers) {
|
|
1355 |
if (!isUpdating() && isSyncLayers()) {
|
1296 |
1356 |
if (getMapContext()!=null) {
|
1297 |
|
b_updating = true;
|
1298 |
|
mapContext.getViewPort().setBackColor(e.getNewColor());
|
|
1357 |
beginUpdate();
|
|
1358 |
getMapContext().getViewPort().setBackColor(e.getNewColor());
|
1299 |
1359 |
invalidateLayout();
|
1300 |
|
b_updating = true;
|
|
1360 |
endUpdate();
|
1301 |
1361 |
}
|
1302 |
1362 |
}
|
1303 |
1363 |
}
|
1304 |
1364 |
|
1305 |
1365 |
public void projectionChanged(ProjectionEvent e) {
|
1306 |
|
if (!b_updating && getExtentSynced()) {
|
|
1366 |
if (!isUpdating() && getExtentSynced()) {
|
1307 |
1367 |
if (getMapContext()!=null) {
|
1308 |
|
b_updating = true;
|
|
1368 |
beginUpdate();
|
1309 |
1369 |
getMapContext().getViewPort().setProjection(e.getNewProjection());
|
1310 |
1370 |
invalidateLayout();
|
1311 |
1371 |
// FIXME: force also a view redraw someway??
|
1312 |
|
b_updating = false;
|
|
1372 |
endUpdate();
|
1313 |
1373 |
}
|
1314 |
1374 |
}
|
1315 |
1375 |
}
|
1316 |
1376 |
|
1317 |
1377 |
public void conditionalRedraw() {
|
1318 |
|
if (!b_updating && syncLayers) {
|
1319 |
|
b_updating = true;
|
|
1378 |
if (!isUpdating() && isSyncLayers()) {
|
|
1379 |
beginUpdate();
|
1320 |
1380 |
invalidateLayout();
|
1321 |
1381 |
// the view should also receive the event and update automatically
|
1322 |
|
b_updating = false;
|
|
1382 |
endUpdate();
|
1323 |
1383 |
}
|
1324 |
1384 |
}
|
1325 |
1385 |
|
... | ... | |
1386 |
1446 |
}
|
1387 |
1447 |
}
|
1388 |
1448 |
|
1389 |
|
private class OwnMapContextListener
|
1390 |
|
implements ViewPortListener, LegendListener, LayerCollectionListener {
|
|
1449 |
|
|
1450 |
private class OwnMapContextListener
|
|
1451 |
implements ViewPortListener, LegendListener, LayerCollectionListener {
|
1391 |
1452 |
|
1392 |
|
public void extentChanged(ExtentEvent e) {
|
1393 |
|
if (!b_drawing && !b_updating) {
|
1394 |
|
b_updating = true;
|
1395 |
|
if (scaleType==SCALE_TYPE.FIXED_EXTENT) {
|
1396 |
|
getMapContext().getViewPort().setEnvelope(fixedExtent);
|
1397 |
|
}
|
1398 |
|
else {
|
1399 |
|
Envelope newEnvelope;
|
1400 |
|
if (scaleType==SCALE_TYPE.FIXED_SCALE && fixedScale!=null) {
|
1401 |
|
getMapContext().setScaleView(Math.round(fixedScale));
|
1402 |
|
newEnvelope = getMapContext().getViewPort().getAdjustedEnvelope();
|
1403 |
|
}
|
1404 |
|
else {
|
1405 |
|
newEnvelope = e.getNewExtent();
|
1406 |
|
}
|
1407 |
|
if (getView()!=null) {
|
1408 |
|
if (getExtentSynced()){
|
1409 |
|
getView().getMapContext().getViewPort().setEnvelope(newEnvelope);
|
1410 |
|
}
|
1411 |
|
}
|
1412 |
|
}
|
1413 |
|
updateScaleCtrl();
|
1414 |
|
invalidateLayout();
|
1415 |
|
b_updating = false;
|
1416 |
|
}
|
1417 |
|
}
|
|
1453 |
public OwnMapContextListener(FFrameView fview) {
|
1418 |
1454 |
|
1419 |
|
public void backColorChanged(ColorEvent e) {
|
1420 |
|
if (!b_updating) {
|
1421 |
|
if (getView()!=null) {
|
1422 |
|
b_updating = true;
|
1423 |
|
if (getLayerSynced()) {
|
1424 |
|
getView().getMapContext().getViewPort().setBackColor(e.getNewColor());
|
1425 |
|
}
|
1426 |
|
invalidateLayout();
|
1427 |
|
b_updating = false;
|
1428 |
|
}
|
1429 |
|
}
|
1430 |
|
}
|
|
1455 |
}
|
|
1456 |
|
|
1457 |
@Override
|
|
1458 |
public void extentChanged(ExtentEvent e) {
|
|
1459 |
if( isDrawing() ) {
|
|
1460 |
return;
|
|
1461 |
}
|
|
1462 |
if( isUpdating() ) {
|
|
1463 |
return;
|
|
1464 |
}
|
|
1465 |
try {
|
|
1466 |
// logger.info("layout-mapcontext.extentChanged "+this.getID());
|
|
1467 |
beginUpdate();
|
|
1468 |
if (getScaleType() == SCALE_TYPE.FIXED_EXTENT) {
|
|
1469 |
getMapContext().getViewPort().setEnvelope(getFixedExtent());
|
|
1470 |
} else {
|
|
1471 |
Envelope newEnvelope;
|
|
1472 |
if (getScaleType() == SCALE_TYPE.FIXED_SCALE && getFixedScale() != null) {
|
|
1473 |
getMapContext().setScaleView(Math.round(getFixedScale()));
|
|
1474 |
newEnvelope = getMapContext().getViewPort().getAdjustedEnvelope();
|
|
1475 |
} else {
|
|
1476 |
newEnvelope = e.getNewExtent();
|
|
1477 |
}
|
|
1478 |
if (getView() != null) {
|
|
1479 |
if (getExtentSynced()) {
|
|
1480 |
getView().getMapContext().getViewPort().setEnvelope(newEnvelope);
|
|
1481 |
}
|
|
1482 |
}
|
|
1483 |
}
|
|
1484 |
updateScaleCtrl();
|
|
1485 |
invalidateLayout();
|
|
1486 |
} finally {
|
|
1487 |
endUpdate();
|
|
1488 |
}
|
|
1489 |
}
|
1431 |
1490 |
|
1432 |
|
public void projectionChanged(ProjectionEvent e) {
|
1433 |
|
if (!b_updating && getExtentSynced()) {
|
1434 |
|
if (getView()!=null) {
|
1435 |
|
b_updating = true;
|
1436 |
|
if (getLayerSynced()) {
|
1437 |
|
getView().getMapContext().getViewPort().setProjection(e.getNewProjection());
|
1438 |
|
}
|
1439 |
|
invalidateLayout();
|
1440 |
|
// FIXME: force also a view redraw someway??
|
1441 |
|
b_updating = false;
|
1442 |
|
}
|
1443 |
|
}
|
1444 |
|
}
|
|
1491 |
@Override
|
|
1492 |
public void backColorChanged(ColorEvent e) {
|
|
1493 |
if (!isUpdating()) {
|
|
1494 |
if (getView() != null) {
|
|
1495 |
try {
|
|
1496 |
beginUpdate();
|
|
1497 |
if (getLayerSynced()) {
|
|
1498 |
getView().getMapContext().getViewPort().setBackColor(e.getNewColor());
|
|
1499 |
}
|
|
1500 |
invalidateLayout();
|
|
1501 |
} finally {
|
|
1502 |
endUpdate();
|
|
1503 |
}
|
|
1504 |
}
|
|
1505 |
}
|
|
1506 |
}
|
1445 |
1507 |
|
1446 |
|
public void conditionalRedraw() {
|
1447 |
|
if (!b_updating) {
|
1448 |
|
b_updating = true;
|
1449 |
|
invalidateLayout();
|
1450 |
|
// the view should also receive the event and update automatically
|
1451 |
|
b_updating = false;
|
1452 |
|
}
|
1453 |
|
}
|
|
1508 |
@Override
|
|
1509 |
public void projectionChanged(ProjectionEvent e) {
|
|
1510 |
if (!isUpdating() && getExtentSynced()) {
|
|
1511 |
if (getView() != null) {
|
|
1512 |
try {
|
|
1513 |
beginUpdate();
|
|
1514 |
if (getLayerSynced()) {
|
|
1515 |
getView().getMapContext().getViewPort().setProjection(e.getNewProjection());
|
|
1516 |
}
|
|
1517 |
invalidateLayout();
|
|
1518 |
// FIXME: force also a view redraw someway??
|
|
1519 |
} finally {
|
|
1520 |
endUpdate();
|
|
1521 |
}
|
|
1522 |
}
|
|
1523 |
}
|
|
1524 |
}
|
1454 |
1525 |
|
1455 |
|
public void legendChanged(final LegendChangedEvent e) {
|
1456 |
|
conditionalRedraw();
|
1457 |
|
refreshToc();
|
1458 |
|
}
|
|
1526 |
public void conditionalRedraw() {
|
|
1527 |
if (!isUpdating()) {
|
|
1528 |
try {
|
|
1529 |
beginUpdate();
|
|
1530 |
invalidateLayout();
|
|
1531 |
// the view should also receive the event and update automatically
|
|
1532 |
} finally {
|
|
1533 |
endUpdate();
|
|
1534 |
}
|
|
1535 |
}
|
|
1536 |
}
|
1459 |
1537 |
|
1460 |
|
public void layerAdded(final LayerCollectionEvent e) {
|
1461 |
|
// necessary to set an envelope when the first layer is added
|
1462 |
|
if (!b_updating && getMapContext().getViewPort().getEnvelope()==null) {
|
1463 |
|
try {
|
1464 |
|
b_updating = true;
|
1465 |
|
fullExtent();
|
|
1538 |
@Override
|
|
1539 |
public void legendChanged(final LegendChangedEvent e) {
|
|
1540 |
conditionalRedraw();
|
|
1541 |
refreshToc();
|
|
1542 |
}
|
1466 |
1543 |
|
1467 |
|
} catch (ReadException e1) {
|
1468 |
|
} finally {
|
1469 |
|
b_updating = false;
|
1470 |
|
}
|
1471 |
|
}
|
1472 |
|
conditionalRedraw();
|
1473 |
|
refreshToc();
|
1474 |
|
}
|
|
1544 |
@Override
|
|
1545 |
public void layerAdded(final LayerCollectionEvent e) {
|
|
1546 |
// necessary to set an envelope when the first layer is added
|
|
1547 |
if (!isUpdating() && getMapContext().getViewPort().getEnvelope() == null) {
|
|
1548 |
try {
|
|
1549 |
beginUpdate();
|
|
1550 |
fullExtent();
|
1475 |
1551 |
|
1476 |
|
public void layerMoved(final LayerPositionEvent e) {
|
1477 |
|
conditionalRedraw();
|
1478 |
|
refreshToc();
|
1479 |
|
}
|
|
1552 |
} catch (ReadException e1) {
|
|
1553 |
} finally {
|
|
1554 |
endUpdate();
|
|
1555 |
}
|
|
1556 |
}
|
|
1557 |
conditionalRedraw();
|
|
1558 |
refreshToc();
|
|
1559 |
}
|
1480 |
1560 |
|
1481 |
|
public void layerRemoved(final LayerCollectionEvent e) {
|
1482 |
|
conditionalRedraw();
|
1483 |
|
refreshToc();
|
1484 |
|
}
|
|
1561 |
@Override
|
|
1562 |
public void layerMoved(final LayerPositionEvent e) {
|
|
1563 |
conditionalRedraw();
|
|
1564 |
refreshToc();
|
|
1565 |
}
|
1485 |
1566 |
|
1486 |
|
public void layerAdding(LayerCollectionEvent e)
|
1487 |
|
throws CancelationException {
|
1488 |
|
// nothing neededO
|
|
1567 |
@Override
|
|
1568 |
public void layerRemoved(final LayerCollectionEvent e) {
|
|
1569 |
conditionalRedraw();
|
|
1570 |
refreshToc();
|
|
1571 |
}
|
1489 |
1572 |
|
1490 |
|
}
|
|
1573 |
@Override
|
|
1574 |
public void layerAdding(LayerCollectionEvent e)
|
|
1575 |
throws CancelationException {
|
|
1576 |
// nothing neededO
|
1491 |
1577 |
|
1492 |
|
public void layerMoving(LayerPositionEvent e)
|
1493 |
|
throws CancelationException {
|
1494 |
|
// nothing needed
|
|
1578 |
}
|
1495 |
1579 |
|
1496 |
|
}
|
|
1580 |
@Override
|
|
1581 |
public void layerMoving(LayerPositionEvent e)
|
|
1582 |
throws CancelationException {
|
|
1583 |
// nothing needed
|
1497 |
1584 |
|
1498 |
|
public void layerRemoving(LayerCollectionEvent e)
|
1499 |
|
throws CancelationException {
|
1500 |
|
// nothing needed
|
|
1585 |
}
|
1501 |
1586 |
|
1502 |
|
}
|
|
1587 |
@Override
|
|
1588 |
public void layerRemoving(LayerCollectionEvent e)
|
|
1589 |
throws CancelationException {
|
|
1590 |
// nothing needed
|
1503 |
1591 |
|
1504 |
|
public void visibilityChanged(LayerCollectionEvent e)
|
1505 |
|
throws CancelationException {
|
1506 |
|
conditionalRedraw();
|
1507 |
|
}
|
1508 |
|
}
|
|
1592 |
}
|
1509 |
1593 |
|
|
1594 |
@Override
|
|
1595 |
public void visibilityChanged(LayerCollectionEvent e)
|
|
1596 |
throws CancelationException {
|
|
1597 |
conditionalRedraw();
|
|
1598 |
}
|
|
1599 |
}
|
|
1600 |
|
1510 |
1601 |
public void setExtent(Envelope extent) {
|
1511 |
1602 |
if (getScaleType()==SCALE_TYPE.NORMAL) {
|
1512 |
1603 |
getMapContext().getViewPort().setEnvelope(extent);
|
1513 |
1604 |
}
|
1514 |
1605 |
}
|
1515 |
1606 |
|
1516 |
|
public SCALE_TYPE getScaleType() {
|
1517 |
|
return scaleType ;
|
1518 |
|
}
|
1519 |
|
|
1520 |
1607 |
public void setScaleType(SCALE_TYPE scaleType) {
|
1521 |
1608 |
this.scaleType = scaleType;
|
1522 |
1609 |
}
|