[Schmitzm-commits] r1221 - in trunk/src: schmitzm/geotools/gui skrueger/geotools
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed Nov 3 14:29:18 CET 2010
Author: alfonx
Date: 2010-11-03 14:29:17 +0100 (Wed, 03 Nov 2010)
New Revision: 1221
Modified:
trunk/src/schmitzm/geotools/gui/GeoMapPane.java
trunk/src/schmitzm/geotools/gui/MapContextControlPane.java
trunk/src/schmitzm/geotools/gui/XMapPane.java
trunk/src/skrueger/geotools/CrsLabel.java
trunk/src/skrueger/geotools/MapPaneToolBar.java
trunk/src/skrueger/geotools/MapView.java
Log:
Added a Lable to show the CRS to MpaView
Modified: trunk/src/schmitzm/geotools/gui/GeoMapPane.java
===================================================================
--- trunk/src/schmitzm/geotools/gui/GeoMapPane.java 2010-11-03 13:09:32 UTC (rev 1220)
+++ trunk/src/schmitzm/geotools/gui/GeoMapPane.java 2010-11-03 13:29:17 UTC (rev 1221)
@@ -42,16 +42,13 @@
import org.geotools.renderer.lite.StreamingRenderer;
import org.geotools.renderer.shape.ShapefileRenderer;
import org.geotools.resources.CRSUtilities;
-import org.opengis.referencing.FactoryException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.cs.CoordinateSystem;
-import org.opengis.referencing.operation.TransformException;
import schmitzm.geotools.GTUtil;
import schmitzm.geotools.map.event.JMapPaneListener;
import schmitzm.geotools.map.event.MapAreaChangedEvent;
import schmitzm.geotools.map.event.ScaleChangedEvent;
-import schmitzm.swing.ExceptionDialog;
import schmitzm.swing.JPanel;
import schmitzm.swing.SwingUtil;
@@ -130,41 +127,7 @@
*/
private boolean disposed = false;
- private CoordinateReferenceSystem forceCrs;
-
/**
- * Allows to set a CRS that should be used for the {@link MapContext}, no
- * matter which CRS the bottom layer has.
- */
- public void setForceCrs(CoordinateReferenceSystem crs) {
- forceCrs = crs;
-
- try {
- getMapContext().setCoordinateReferenceSystem(
- forceCrs);
- } catch (TransformException e) {
- ExceptionDialog.show(this, e);
- } catch (FactoryException e) {
- ExceptionDialog.show(this, e);
- }
- }
-
- /**
- * Allows to set a CRS that should be used for the {@link MapContext}, no
- * matter which CRS the bottom layer has.
- */
- public CoordinateReferenceSystem getForceCrs() {
- return forceCrs;
- }
-
- /**
- * <code>true</code> if a forceCrs has been defined.
- */
- public boolean isForceCrs() {
- return forceCrs == null;
- }
-
- /**
* Erzeugt ein neues {@code GeoMapPane}.
*/
public GeoMapPane() {
Modified: trunk/src/schmitzm/geotools/gui/MapContextControlPane.java
===================================================================
--- trunk/src/schmitzm/geotools/gui/MapContextControlPane.java 2010-11-03 13:09:32 UTC (rev 1220)
+++ trunk/src/schmitzm/geotools/gui/MapContextControlPane.java 2010-11-03 13:29:17 UTC (rev 1221)
@@ -527,7 +527,7 @@
context.moveLayer(currIdx, currIdx - 1);
// Menu "Zoom to layer"
if (source == zoomToLayer)
- mapPane.zoomToLayer(layer);
+ mapPane.zoomToLayer(layer, false);
// Menu "Remove layer"
if (source == removeLayer)
context.removeLayer(layer);
Modified: trunk/src/schmitzm/geotools/gui/XMapPane.java
===================================================================
--- trunk/src/schmitzm/geotools/gui/XMapPane.java 2010-11-03 13:09:32 UTC (rev 1220)
+++ trunk/src/schmitzm/geotools/gui/XMapPane.java 2010-11-03 13:29:17 UTC (rev 1221)
@@ -73,6 +73,7 @@
import schmitzm.geotools.map.event.MapLayerAdapter;
import schmitzm.geotools.styling.StylingUtil;
import schmitzm.lang.LangUtil;
+import schmitzm.swing.ExceptionDialog;
import schmitzm.swing.JPanel;
import schmitzm.swing.SwingUtil;
import schmitzm.swing.event.MouseInputType;
@@ -109,7 +110,41 @@
*/
public class XMapPane extends JPanel {
+ // TODO still unused
+ private CoordinateReferenceSystem forceCrs;
+
/**
+ * //TODO still unused Allows to set a CRS that should be used for the
+ * {@link MapContext}, no matter which CRS the bottom layer has.
+ */
+ public void setForceCrs(CoordinateReferenceSystem crs) {
+ forceCrs = crs;
+
+ try {
+ getMapContext().setCoordinateReferenceSystem(forceCrs);
+ } catch (TransformException e) {
+ ExceptionDialog.show(this, e);
+ } catch (FactoryException e) {
+ ExceptionDialog.show(this, e);
+ }
+ }
+
+ /**
+ * Allows to set a CRS that should be used for the {@link MapContext}, no
+ * matter which CRS the bottom layer has.
+ */
+ public CoordinateReferenceSystem getForceCrs() {
+ return forceCrs;
+ }
+
+ /**
+ * <code>true</code> if a forceCrs has been defined.
+ */
+ public boolean isForceCrs() {
+ return forceCrs == null;
+ }
+
+ /**
* If {@link #maxExtend} is <code>null</code> the following rules are used
* to create a default maximum.
* <ul>
@@ -1429,7 +1464,7 @@
}
/**
- * Returns null
+ * Returns null
*/
public AffineTransform getWorldToScreenTransform() {
if (worldToScreen == null) {
@@ -2626,14 +2661,23 @@
*
* <br>
*
+ * @param switchCrs
+ * if <code>true</code>, the mapcontext will be switched to use
+ * the CRS of the layer
* @param layer
* ein Layer
*/
- public void zoomToLayer(MapLayer layer) {
+ public void zoomToLayer(MapLayer layer, boolean switchCrs) {
if (layer == null)
return;
try {
+ if (switchCrs) {
+ getMapContext().setCoordinateReferenceSystem(
+ layer.getFeatureSource().getSchema()
+ .getCoordinateReferenceSystem());
+ }
+
// BB umrechnen von Layer-CRS in Map-CRS
final CoordinateReferenceSystem targetCRS = getMapContext()
.getCoordinateReferenceSystem();
@@ -2728,10 +2772,10 @@
*
* @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
*/
- public void zoomToLayer(int index) {
+ public void zoomToLayer(int index, boolean switchCrs) {
final MapContext context = getMapContext();
if (context != null)
- zoomToLayer(context.getLayer(index));
+ zoomToLayer(context.getLayer(index), switchCrs);
}
/**
@@ -2750,8 +2794,8 @@
*
* @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
*/
- public void zoomToLayerIdxReverse(int index) {
- zoomToLayer(getMapContext().getLayerCount() - 1 - index);
+ public void zoomToLayerIdxReverse(int index, boolean switchCrs) {
+ zoomToLayer(getMapContext().getLayerCount() - 1 - index, switchCrs);
}
/**
Modified: trunk/src/skrueger/geotools/CrsLabel.java
===================================================================
--- trunk/src/skrueger/geotools/CrsLabel.java 2010-11-03 13:09:32 UTC (rev 1220)
+++ trunk/src/skrueger/geotools/CrsLabel.java 2010-11-03 13:29:17 UTC (rev 1221)
@@ -15,7 +15,7 @@
updateCrs();
}
};
-
+
private final SelectableXMapPane mapPane;
CrsLabel(SelectableXMapPane mapPane) {
@@ -29,10 +29,11 @@
public void updateCrs() {
try {
- setText(mapPane.getMapContext().getCoordinateReferenceSystem()
- .getName().toString());
+ setText("CRS:"
+ + mapPane.getMapContext().getCoordinateReferenceSystem()
+ .getName().toString());
} catch (Exception e) {
- setText("");
+ setText("CRS:" + "NONE");
}
}
Modified: trunk/src/skrueger/geotools/MapPaneToolBar.java
===================================================================
--- trunk/src/skrueger/geotools/MapPaneToolBar.java 2010-11-03 13:09:32 UTC (rev 1220)
+++ trunk/src/skrueger/geotools/MapPaneToolBar.java 2010-11-03 13:29:17 UTC (rev 1221)
@@ -168,7 +168,6 @@
}
};
- private CrsLabel crsViewer;
/**
* Creates a new toolbar. Notice: This toolbar does nothing until
@@ -266,12 +265,12 @@
init();
}
- private CrsLabel getCrsComponent() {
- if (crsViewer == null) {
- crsViewer = new CrsLabel(this.mapPane);
- }
- return crsViewer;
- }
+// private CrsLabel getCrsComponent() {
+// if (crsViewer == null) {
+// crsViewer = new CrsLabel(this.mapPane);
+// }
+// return crsViewer;
+// }
/**
* Sets the {@link SelectableXMapPane} controlled by this tool bar.
@@ -349,8 +348,6 @@
// set the selected tool enabled
setSelectedTool(selectedTool);
- add(getCrsComponent());
-
}
@Override
Modified: trunk/src/skrueger/geotools/MapView.java
===================================================================
--- trunk/src/skrueger/geotools/MapView.java 2010-11-03 13:09:32 UTC (rev 1220)
+++ trunk/src/skrueger/geotools/MapView.java 2010-11-03 13:29:17 UTC (rev 1221)
@@ -126,7 +126,8 @@
*/
JPanel newRight = new JPanel(new MigLayout("center, wrap 1", "[grow]",
"[][grow]"));
- newRight.add(getToolBar());
+ newRight.add(getToolBar(), "split 2");
+ newRight.add(new CrsLabel(getGeoMapPane().getMapPane()), "align right");
newRight.add(getGeoMapPane(), "growx, growy");
getSplitPane().add(newRight);
More information about the Schmitzm-commits
mailing list