<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
</style>
</head>
<body class='hmmessage'>
Well, now I tested all with the DefaultPortrayService, but I still get the same distorted picture.... :-(<br><br>Here is the code of my TestFrame, the TestPanel class is just a simple JPanel with an overridden paintComponent that does a drawImage.<br><br>Does someone have an idea ?<br><br>Thanks,<br><br>Sam<br><br>/*<br> * To change this template, choose Tools | Templates<br> * and open the template in the editor.<br> */<br><br>package testgo2nm;<br><br><br>import java.awt.Dimension;<br>import java.awt.RenderingHints;<br>import java.net.URL;<br>import java.util.logging.Level;<br>import java.util.logging.Logger;<br>import org.geotoolkit.display.exception.PortrayalException;<br>import org.geotoolkit.display2d.service.DefaultPortrayalService;<br>import org.geotoolkit.gui.swing.go2.JMap2D;<br>import org.geotoolkit.map.MapBuilder;<br>import org.geotoolkit.map.MapContext;<br>import org.geotoolkit.map.MapLayer;<br>import org.geotoolkit.referencing.CRS;<br>import org.geotoolkit.referencing.crs.DefaultGeographicCRS;<br>import org.geotoolkit.wms.WebMapServer;<br>import org.geotoolkit.wms.map.WMSMapLayer;<br>import org.geotoolkit.wms.xml.AbstractWMSCapabilities;<br>import org.opengis.referencing.FactoryException;<br>import org.opengis.referencing.NoSuchAuthorityCodeException;<br>import org.opengis.referencing.crs.CoordinateReferenceSystem;<br>import org.opengis.referencing.operation.TransformException;<br><br>/**<br> *<br> * @author<br> */<br>public class TestFrame extends javax.swing.JFrame{<br> JMap2D mapWidget;<br> final MapLayer layer;<br><br> //If we want to test the display using a simple image, then enable testpanel and add it to the JFrame instead of mapWidget<br> //see below. !We need the picture some_picture.png!<br> TestPanel testPanel;<br><br> MapContext context;<br><br> public TestFrame(){<br> this.setSize(400, 400);<br> this.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);<br> mapWidget = new JMap2D();<br> context = MapBuilder.createContext(DefaultGeographicCRS.WGS84);<br><br> CoordinateReferenceSystem objectCRS = null;<br><br> try {<br> objectCRS = CRS.decode("EPSG:4326");<br> } catch (NoSuchAuthorityCodeException ex) {<br> Logger.getLogger(TestFrame.class.getName()).log(Level.SEVERE, null, ex);<br> } catch (FactoryException ex) {<br> Logger.getLogger(TestFrame.class.getName()).log(Level.SEVERE, null, ex);<br> }<br><br> mapWidget.getContainer().setContext(context);<br><br> mapWidget.getCanvas().setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);<br> mapWidget.getCanvas().getController().setAutoRepaint(true);<br><br> // add(mapWidget);<br> // testPanel = new TestPanel();<br> // add(testPanel);<br> <br> try {<br> mapWidget.getCanvas().getController().setObjectiveCRS(objectCRS);<br> } catch (TransformException ex) {<br> Logger.getLogger(TestFrame.class.getName()).log(Level.SEVERE, null, ex);<br> }<br> //mapWidget.getCanvas().getController() is the place to change the point of view, dimension, coordinates, etc<br><br> System.out.println("Obj : " + mapWidget.getCanvas().getObjectiveCRS().toWKT());<br> System.out.println("Dev : " + mapWidget.getCanvas().getDeviceCRS().toWKT());<br> System.out.println("Dis : " + mapWidget.getCanvas().getDisplayCRS().toWKT());<br><br><br> System.out.println("Context: (" + context.getAreaOfInterest().getLowerCorner().getCoordinate()[0]<br> + ":" + context.getAreaOfInterest().getLowerCorner().getCoordinate()[1] + ") , ("<br> + context.getAreaOfInterest().getUpperCorner().getCoordinate()[0] + ":" +<br> context.getAreaOfInterest().getUpperCorner().getCoordinate()[1]+")" );<br><br> //Let's grab an image from WMS<br><br> WebMapServer server = null;<br> //final String url = "http://www2.demis.nl/WMS/wms.asp?wms=BlueMarble";<br> //final String featureName = "EarthImage";<br><br> final String url = "http://www2.demis.nl/WMS/wms.asp?wms=WorldMap";<br> final String featureName = "Countries";<br><br> final String version = "1.1.1";<br><br> WebMapServer temp = null;<br><br> try {<br> temp = new WebMapServer(new URL(url),version);<br> } catch (Exception ex) {<br> Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex);<br> }<br><br> server = temp;<br><br> if(server != null){<br> layer = new WMSMapLayer(server,featureName);<br> }else{<br> layer = MapBuilder.createEmptyMapLayer();<br> }<br><br> final AbstractWMSCapabilities capa = server.getCapabilities(); //Ask the server for its capabilities<br><br> //Display the layers names<br><br> if(capa instanceof org.geotoolkit.wms.xml.v130.WMSCapabilities){<br> org.geotoolkit.wms.xml.v130.WMSCapabilities cp13 =<br> (org.geotoolkit.wms.xml.v130.WMSCapabilities) capa;<br> for(org.geotoolkit.wms.xml.v130.Layer tmpLayer : cp13.getCapability().getLayer().getLayer()){<br> System.out.println("Layer v130 " + tmpLayer.getName());<br> }<br> }else if(capa instanceof org.geotoolkit.wms.xml.v111.WMT_MS_Capabilities){<br> org.geotoolkit.wms.xml.v111.WMT_MS_Capabilities cp11 =<br> (org.geotoolkit.wms.xml.v111.WMT_MS_Capabilities) capa;<br> for(org.geotoolkit.wms.xml.v111.Layer tmpLayer : cp11.getCapability().getLayer().getLayer()){<br> System.out.println("Layer v111 " + tmpLayer.getName());<br> }<br> }<br><br> context.layers().add(layer);<br><br> try {<br><br> testPanel = new TestPanel(DefaultPortrayalService.portray(context, context.getAreaOfInterest(), new Dimension(400, 400), false));<br><br> add(testPanel);<br> } catch (PortrayalException ex) {<br> Logger.getLogger(TestFrame.class.getName()).log(Level.SEVERE, null, ex);<br> }<br> }<br>}<br><br><br /><hr />Plus de 2 mio de Suisses utilisent Windows Live ! <a href='http://www.microsoft.com/switzerland/windows/fr/windowslive/default.aspx' target='_new'>Découvrez les services gratuits.</a></body>
</html>