[Schmitzm-commits] r606 - in branches/1.0-gt2-2.6: dist src/schmitzm/geotools/gui src/skrueger/geotools
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed Dec 9 15:46:32 CET 2009
Author: alfonx
Date: 2009-12-09 15:46:29 +0100 (Wed, 09 Dec 2009)
New Revision: 606
Modified:
branches/1.0-gt2-2.6/dist/schmitzm-1.0-gt2-2.6.jar
branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/SelectableXMapPane.java
branches/1.0-gt2-2.6/src/skrueger/geotools/XMapPane.java
Log:
Moved some methods from selectablXMapPane to XMapPane because they have nothing to do with selection
Modified: branches/1.0-gt2-2.6/dist/schmitzm-1.0-gt2-2.6.jar
===================================================================
(Binary files differ)
Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/SelectableXMapPane.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/SelectableXMapPane.java 2009-12-09 14:22:41 UTC (rev 605)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/SelectableXMapPane.java 2009-12-09 14:46:29 UTC (rev 606)
@@ -43,8 +43,6 @@
import java.util.Hashtable;
import java.util.Map;
-import javax.swing.JList;
-
import org.apache.log4j.Logger;
import org.geotools.coverage.grid.GeneralGridEnvelope;
import org.geotools.coverage.grid.GridCoverage2D;
@@ -53,7 +51,6 @@
import org.geotools.coverage.grid.io.AbstractGridFormat;
import org.geotools.data.FeatureSource;
import org.geotools.data.memory.MemoryFeatureCollection;
-import org.geotools.factory.GeoTools;
import org.geotools.feature.FeatureCollection;
import org.geotools.filter.GeometryFilterImpl;
import org.geotools.geometry.GeneralEnvelope;
@@ -369,162 +366,7 @@
}
-
/**
- * Aktiviert oder deaktiviert das AntiAliasing for diese
- * {@link SelectableXMapPane}. AntiALiasing ist besonders fuer
- * Textbeschriftung sehr schoen, verbraucht aber auch mehr Performance.
- *
- * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
- * Krüger</a>
- */
- public void setAntiAliasing(final boolean aa) {
- // LOGGER.info("Setting AntiAliasing for this JMapPane to " + aa);
- RenderingHints java2DHints = super.getJava2dHints();
- if (java2DHints == null)
- java2DHints = GeoTools.getDefaultHints();
- java2DHints.put(RenderingHints.KEY_ANTIALIASING,
- aa ? RenderingHints.VALUE_ANTIALIAS_ON
- : RenderingHints.VALUE_ANTIALIAS_OFF);
- java2DHints.put(RenderingHints.KEY_TEXT_ANTIALIASING,
- aa ? RenderingHints.VALUE_TEXT_ANTIALIAS_ON
- : RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
- java2DHints.put(RenderingHints.KEY_RENDERING,
- aa ? RenderingHints.VALUE_RENDER_QUALITY
- : RenderingHints.VALUE_RENDER_SPEED);
- super.setJava2dHints(java2DHints);
- }
-
- /**
- * Setzt den Kartenausschnitt auf die Ausdehnung eines bestimmten Layers.
- * Macht nichts, wenn {@code null} uebergeben wird.
- *
- * <br>
- *
- * @param layer
- * ein Layer
- */
- public void zoomToLayer(MapLayer layer) {
- if (layer == null)
- return;
- try {
-
- // BB umrechnen von Layer-CRS in Map-CRS
- final CoordinateReferenceSystem targetCRS = getMapContext()
- .getCoordinateReferenceSystem();
- final CoordinateReferenceSystem sourceCRS = layer
- .getFeatureSource().getSchema()
- .getCoordinateReferenceSystem();
-
- Envelope mapAreaNew;
- if (!CRS.equalsIgnoreMetadata(sourceCRS, targetCRS)) {
- mapAreaNew = JTSUtil.transformEnvelope(layer.getFeatureSource()
- .getBounds(), sourceCRS, targetCRS);
- } else {
- try {
- mapAreaNew = layer.getFeatureSource().getBounds();
- } catch (java.lang.IllegalArgumentException e) {
- LOGGER.error("Can't calc layers bounds...", e);
- mapAreaNew = null;
-
- /**
- *
- 23.10.2009 11:20:50
- * org.geotools.data.shapefile.shp.PolygonHandler read
- * WARNUNG: only one hole in this polygon record ERROR
- * JMapPane zoomToLayer Zoom to layer did not terminate
- * correctly java.lang.IllegalArgumentException: Points of
- * LinearRing do not form a closed linestring at
- * com.vividsolutions
- * .jts.geom.LinearRing.validateConstruction
- * (LinearRing.java:105) at
- * com.vividsolutions.jts.geom.LinearRing
- * .<init>(LinearRing.java:100) at
- * com.vividsolutions.jts.geom
- * .GeometryFactory.createLinearRing
- * (GeometryFactory.java:339) at
- * org.geotools.data.shapefile.
- * shp.PolygonHandler.read(PolygonHandler.java:188) at
- * org.geotools
- * .data.shapefile.shp.ShapefileReader$Record.shape
- * (ShapefileReader.java:106) at
- * org.geotools.data.shapefile.
- * ShapefileAttributeReader.next(
- * ShapefileAttributeReader.java:157) at
- * org.geotools.data.shapefile
- * .indexed.IndexedShapefileAttributeReader
- * .next(IndexedShapefileAttributeReader.java:122) at
- * org.geotools
- * .data.FIDFeatureReader.next(FIDFeatureReader.java:96) at
- * org.geotools.data.FIDFeatureReader.next(FIDFeatureReader.
- * java:55) at org.geotools.data.MaxFeatureReader.next(
- * MaxFeatureReader.java:61) at
- * org.geotools.data.MaxFeatureReader
- * .next(MaxFeatureReader.java:61)
- **/
- }
- }
-
- // Kartenbereich um 10% vergroessern, damit z.B. auch ein
- // Punkt-Layer,
- // welches nur aus 2 Punnkten besteht, sichtbar ist (Punkte liegen
- // sonst
- // genau auf dem Rand der angezeigten Flaeche)
-
- if (mapAreaNew != null) {
- mapAreaNew.expandBy(mapAreaNew.getWidth() * 0.1, mapAreaNew
- .getHeight() * 0.1);
- setMapArea(mapAreaNew);
- } else {
- LOGGER
- .warn("Couldn't transformEnvelope when zooming to the layer");
- }
- } catch (Exception err) {
- LOGGER.error("Zoom to layer did not terminate correctly", err);
- }
- }
-
- /**
- * Zooms the {@link SelectableXMapPane} to the {@link Envelope} of a layer.
- *
- * <br>
- * A refresh of the map is not done automatically
- *
- * @param index
- * Index of the {@link MapLayer} in the {@link MapContext} (from
- * back to top)
- *
- * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
- * Krüger</a>
- */
- public void zoomToLayer(int index) {
- final MapContext context = getMapContext();
- if (context != null)
- zoomToLayer(context.getLayer(index));
- }
-
- /**
- * Zooms the {@link SelectableXMapPane} to the {@link Envelope} of the
- * selected layer. The layer is selected by the idx, counting from front to
- * back, like humans would expect in a {@link JList}
- *
- * <br>
- * A refresh of the map is not done automatically
- *
- *
- *
- * @param index
- * Reverse index of the {@link MapLayer} in the
- * {@link MapContext}
- *
- * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
- * Krüger</a>
- */
- public void zoomToLayerIdxReverse(int index) {
- zoomToLayer(getMapContext().getLayerCount() - 1 - index);
- }
-
- /**
* Liefert die Anzahl der Einheiten, die ein Bildschirm-Pixel darstellt. Die
* Einheit ist die Grundeinheit des CRS
*/
Modified: branches/1.0-gt2-2.6/src/skrueger/geotools/XMapPane.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/geotools/XMapPane.java 2009-12-09 14:22:41 UTC (rev 605)
+++ branches/1.0-gt2-2.6/src/skrueger/geotools/XMapPane.java 2009-12-09 14:46:29 UTC (rev 606)
@@ -26,10 +26,12 @@
import java.util.Map;
import java.util.Vector;
+import javax.swing.JList;
import javax.swing.Timer;
import javax.swing.border.Border;
import org.apache.log4j.Logger;
+import org.geotools.factory.GeoTools;
import org.geotools.feature.FeatureCollection;
import org.geotools.geometry.jts.JTS;
import org.geotools.geometry.jts.ReferencedEnvelope;
@@ -412,8 +414,7 @@
@Override
public void layerChanged(final MapLayerListEvent event) {
- // localRenderer = GTUtil.createGTRenderer();
- getLocalRenderer().setContext(getMapContext());
+// getLocalRenderer().setContext(getMapContext()); geht doch auch ohne?!?!? wow...
requestStartRendering();
}
@@ -1101,10 +1102,6 @@
return finalImage;
}
- public RenderingHints getJava2dHints() {
- return java2dHints;
- }
-
/**
* Lazyly initializes a {@link BufferedImage} for the background renderer.
*/
@@ -2043,6 +2040,10 @@
updateCursor();
}
+ private RenderingHints getJava2dHints() {
+ return java2dHints;
+ }
+
/**
* Transformiert einen Geo-Koordinaten-Bereich in Fenster-Koordinaten.
*
@@ -2428,4 +2429,166 @@
return localRenderer;
}
+
+
+ /**
+ * Setzt den Kartenausschnitt auf die Ausdehnung eines bestimmten Layers.
+ * Macht nichts, wenn {@code null} uebergeben wird.
+ *
+ * <br>
+ *
+ * @param layer
+ * ein Layer
+ */
+ public void zoomToLayer(MapLayer layer) {
+ if (layer == null)
+ return;
+ try {
+
+ // BB umrechnen von Layer-CRS in Map-CRS
+ final CoordinateReferenceSystem targetCRS = getMapContext()
+ .getCoordinateReferenceSystem();
+ final CoordinateReferenceSystem sourceCRS = layer
+ .getFeatureSource().getSchema()
+ .getCoordinateReferenceSystem();
+
+ Envelope mapAreaNew;
+ if (!CRS.equalsIgnoreMetadata(sourceCRS, targetCRS)) {
+ mapAreaNew = JTSUtil.transformEnvelope(layer.getFeatureSource()
+ .getBounds(), sourceCRS, targetCRS);
+ } else {
+ try {
+ mapAreaNew = layer.getFeatureSource().getBounds();
+ } catch (java.lang.IllegalArgumentException e) {
+ LOGGER.error("Can't calc layers bounds...", e);
+ mapAreaNew = null;
+
+ /**
+ *
+ 23.10.2009 11:20:50
+ * org.geotools.data.shapefile.shp.PolygonHandler read
+ * WARNUNG: only one hole in this polygon record ERROR
+ * JMapPane zoomToLayer Zoom to layer did not terminate
+ * correctly java.lang.IllegalArgumentException: Points of
+ * LinearRing do not form a closed linestring at
+ * com.vividsolutions
+ * .jts.geom.LinearRing.validateConstruction
+ * (LinearRing.java:105) at
+ * com.vividsolutions.jts.geom.LinearRing
+ * .<init>(LinearRing.java:100) at
+ * com.vividsolutions.jts.geom
+ * .GeometryFactory.createLinearRing
+ * (GeometryFactory.java:339) at
+ * org.geotools.data.shapefile.
+ * shp.PolygonHandler.read(PolygonHandler.java:188) at
+ * org.geotools
+ * .data.shapefile.shp.ShapefileReader$Record.shape
+ * (ShapefileReader.java:106) at
+ * org.geotools.data.shapefile.
+ * ShapefileAttributeReader.next(
+ * ShapefileAttributeReader.java:157) at
+ * org.geotools.data.shapefile
+ * .indexed.IndexedShapefileAttributeReader
+ * .next(IndexedShapefileAttributeReader.java:122) at
+ * org.geotools
+ * .data.FIDFeatureReader.next(FIDFeatureReader.java:96) at
+ * org.geotools.data.FIDFeatureReader.next(FIDFeatureReader.
+ * java:55) at org.geotools.data.MaxFeatureReader.next(
+ * MaxFeatureReader.java:61) at
+ * org.geotools.data.MaxFeatureReader
+ * .next(MaxFeatureReader.java:61)
+ **/
+ }
+ }
+
+ // Kartenbereich um 10% vergroessern, damit z.B. auch ein
+ // Punkt-Layer,
+ // welches nur aus 2 Punnkten besteht, sichtbar ist (Punkte liegen
+ // sonst
+ // genau auf dem Rand der angezeigten Flaeche)
+
+ if (mapAreaNew != null) {
+ mapAreaNew.expandBy(mapAreaNew.getWidth() * 0.1, mapAreaNew
+ .getHeight() * 0.1);
+ setMapArea(mapAreaNew);
+ } else {
+ LOGGER
+ .warn("Couldn't transformEnvelope when zooming to the layer");
+ }
+ } catch (Exception err) {
+ LOGGER.error("Zoom to layer did not terminate correctly", err);
+ }
+ }
+
+ /**
+ * Zooms the {@link SelectableXMapPane} to the {@link Envelope} of a layer.
+ *
+ * <br>
+ * A refresh of the map is not done automatically
+ *
+ * @param index
+ * Index of the {@link MapLayer} in the {@link MapContext} (from
+ * back to top)
+ *
+ * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
+ * Krüger</a>
+ */
+ public void zoomToLayer(int index) {
+ final MapContext context = getMapContext();
+ if (context != null)
+ zoomToLayer(context.getLayer(index));
+ }
+
+ /**
+ * Zooms the {@link SelectableXMapPane} to the {@link Envelope} of the
+ * selected layer. The layer is selected by the idx, counting from front to
+ * back, like humans would expect in a {@link JList}
+ *
+ * <br>
+ * A refresh of the map is not done automatically
+ *
+ *
+ *
+ * @param index
+ * Reverse index of the {@link MapLayer} in the
+ * {@link MapContext}
+ *
+ * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
+ * Krüger</a>
+ */
+ public void zoomToLayerIdxReverse(int index) {
+ zoomToLayer(getMapContext().getLayerCount() - 1 - index);
+ }
+
+
+
+
+
+ /**
+ * Aktiviert oder deaktiviert das AntiAliasing for diese
+ * {@link SelectableXMapPane}. AntiALiasing ist besonders fuer
+ * Textbeschriftung sehr schoen, verbraucht aber auch mehr Performance.
+ *
+ * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
+ * Krüger</a>
+ */
+ public void setAntiAliasing(final boolean aa) {
+ // LOGGER.info("Setting AntiAliasing for this JMapPane to " + aa);
+ RenderingHints java2DHints = java2dHints;
+ if (java2DHints == null) {
+ java2DHints = GeoTools.getDefaultHints();
+ }
+
+ java2DHints.put(RenderingHints.KEY_ANTIALIASING,
+ aa ? RenderingHints.VALUE_ANTIALIAS_ON
+ : RenderingHints.VALUE_ANTIALIAS_OFF);
+ java2DHints.put(RenderingHints.KEY_TEXT_ANTIALIASING,
+ aa ? RenderingHints.VALUE_TEXT_ANTIALIAS_ON
+ : RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
+ java2DHints.put(RenderingHints.KEY_RENDERING,
+ aa ? RenderingHints.VALUE_RENDER_QUALITY
+ : RenderingHints.VALUE_RENDER_SPEED);
+
+ }
+
}
More information about the Schmitzm-commits
mailing list