Bundle-RequiredExecutionEnvironment: J2SE-1.5
Import-Package: com.vividsolutions.jts.geom;version="1.10.0",
javax.jcr;version="2.0.0",
+ javax.measure.converter,
+ javax.media.jai;version="1.1.3";resolution:=optional,
+ javax.vecmath,
+ org.argeo,
org.argeo.geotools.jcr,
org.argeo.geotools.styling,
org.argeo.gis.ui,
org.geotools.geometry,
org.geotools.geometry.jts,
org.geotools.map,
+ org.geotools.referencing,
+ org.geotools.referencing.crs,
org.geotools.renderer,
org.geotools.renderer.lite,
org.geotools.styling,
org.geotools.swing.tool,
org.opengis.feature,
org.opengis.feature.simple,
- org.opengis.geometry
+ org.opengis.geometry,
+ org.opengis.referencing.crs
--- /dev/null
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.argeo.commons.gis</groupId>
+ <version>0.3.4-SNAPSHOT</version>
+ <artifactId>plugins</artifactId>
+ <relativePath>..</relativePath>
+ </parent>
+ <artifactId>org.argeo.gis.ui.rcp.swing</artifactId>
+ <name>Commons GIS RCP Swing</name>
+ <packaging>jar</packaging>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <!-- Commons -->
+ <dependency>
+ <groupId>org.argeo.commons.basic</groupId>
+ <artifactId>org.argeo.basic.nodeps</artifactId>
+ <version>0.3.4-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.argeo.commons.gis</groupId>
+ <artifactId>org.argeo.gis.ui</artifactId>
+ <version>0.3.4-SNAPSHOT</version>
+ </dependency>
+
+ <!-- RCP only dependency, needed at compile time -->
+ <dependency>
+ <groupId>org.argeo.commons.eclipse</groupId>
+ <artifactId>org.argeo.eclipse.dep.rcp</artifactId>
+ <version>0.3.4-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
import javax.jcr.Node;
+import org.argeo.ArgeoException;
import org.argeo.geotools.jcr.GeoJcrMapper;
import org.argeo.geotools.styling.StylingUtils;
import org.argeo.gis.ui.AbstractMapViewer;
import org.geotools.map.DefaultMapLayer;
import org.geotools.map.MapContext;
import org.geotools.map.MapLayer;
+import org.geotools.referencing.CRS;
import org.geotools.renderer.lite.StreamingRenderer;
import org.geotools.styling.Style;
import org.geotools.swing.JMapPane;
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
/** Map viewer implementation based on GeoTools Swing components. */
public class SwingMapViewer extends AbstractMapViewer {
versatileZoomTool = new VersatileZoomTool();
mapPane.setCursorTool(versatileZoomTool);
mapPane.setBackground(Color.WHITE);
-
frame.add(mapPane);
setControl(embedded);
public void setAreaOfInterest(ReferencedEnvelope areaOfInterest) {
// mapPane.getMapContext().setAreaOfInterest(areaOfInterest);
- mapPane.setDisplayArea(areaOfInterest);
+ CoordinateReferenceSystem crs = mapPane.getMapContext()
+ .getCoordinateReferenceSystem();
+
+ ReferencedEnvelope toDisplay;
+ if (crs != null)
+ try {
+ toDisplay = areaOfInterest.transform(crs, true);
+ } catch (Exception e) {
+ throw new ArgeoException("Cannot reproject " + areaOfInterest,
+ e);
+ }
+ else
+ toDisplay = areaOfInterest;
+ mapPane.setDisplayArea(toDisplay);
+ }
+
+ public void setCoordinateReferenceSystem(String crs) {
+ try {
+ CoordinateReferenceSystem crsObj = CRS.decode(crs);
+ mapPane.getMapContext().setCoordinateReferenceSystem(crsObj);
+ mapPane.repaint();
+ } catch (Exception e) {
+ throw new ArgeoException("Cannot set CRS '" + crs + "'", e);
+ }
+
}
}