Hi,

Thanks for your answer. I added mapPane.setReset(true) just after I 
added my context (which contains the layers) to the JMapPane (mapPane), 
but I still have no image... What's wrong?

Sofie

Martin Schmitz wrote:
> Call JMapPane.setReset( true ) after adding (all) new layer(s)...
>
> Martin Schmitz schrieb:
>   
>> Call JMapPane.setReset( true ) after adding (all) new layer(s)...
>>
>> sofiedemeyer schrieb:
>>     
>>> Hi,
>>>
>>> I am a newbee in the use of geotools. I just wanted to test the 
>>> abilities of
>>> geotools with a simple example: displaying 2 points. But when I 
>>> execute the
>>> code (see below), nothing is seen on the screen, only the background.
>>> Can anyone help me? What am I doing wrong?
>>>
>>> Thanks for your help,
>>>
>>> Sofie
>>>
>>> import org.geotools.map.*;
>>> import org.geotools.gui.swing.*;
>>> import org.geotools.renderer.*;
>>> import org.geotools.renderer.lite.*;
>>> import org.geotools.geometry.*;
>>> import org.geotools.feature.*;
>>> import org.geotools.styling.*;
>>> import org.geotools.referencing.crs.*;
>>>
>>> import com.vividsolutions.jts.geom.*;
>>>
>>> import javax.swing.*;
>>> //import java.awt.*;
>>> import java.util.*;
>>>
>>> public class Visualisation {
>>>         MapContext context = null;
>>>         public Visualisation(){
>>>         try{
>>>             System.out.println("Context: "+context);
>>>             context = new DefaultMapContext();
>>>
>>>             context.setTitle("MapTitle");
>>>             context.setContactInformation("ContactInformation");
>>>             context.setAbstract("Abstract");
>>>
>>>             //Create feature collection
>>>             AttributeType[] types = new AttributeType[1];
>>>             types[0] = AttributeTypeFactory.newAttributeType("centre",
>>> Point.class, false, 0, null, DefaultGeographicCRS.WGS84);
>>>
>>>             FeatureType pointType = 
>>> FeatureTypeFactory.newFeatureType(types,
>>> "pointfeature");
>>>
>>>             GeometryFactory geomFac = new GeometryFactory();
>>>             Point point1 = geomFac.createPoint(new Coordinate(0.0, 0.0));
>>>             Point point2 = geomFac.createPoint(new Coordinate(100.0,
>>> 100.0));
>>>             Feature feature1 = pointType.create(new Object[]{point1});
>>>             Feature feature2 = pointType.create(new Object[]{point2});
>>>
>>>             FeatureCollection fc = FeatureCollections.newCollection();
>>>             fc.add(feature1);
>>>             fc.add(feature2);
>>>
>>>             //Create the map style
>>>             StyleBuilder sb = new StyleBuilder(); Style style =
>>> sb.createStyle();
>>>             Mark circle = sb.createMark(sb.MARK_CIRCLE, 
>>> java.awt.Color.RED);
>>>             Graphic graph2 = sb.createGraphic(null, circle, null, 1, 100,
>>> 0);
>>>             PointSymbolizer pointSymbolizer =
>>> sb.createPointSymbolizer(graph2);
>>>             
>>> style.addFeatureTypeStyle(sb.createFeatureTypeStyle("point", new
>>> Symbolizer[]{pointSymbolizer}));
>>>                         //Create layer from style
>>>             MapLayer aLayer = new DefaultMapLayer(fc, style, "layer1");
>>>
>>>             //Add layer to map
>>>             context.addLayer(aLayer);
>>>                         System.out.println("Context: "+context);
>>>                         show();
>>>         }catch(Exception e){ e.printStackTrace(); }
>>>     }
>>>         public void show(){
>>>                 JMapPane mapPane = new JMapPane();
>>>         mapPane.setContext(context);
>>>         mapPane.setRenderer(new StreamingRenderer());
>>>                 JFrame frame = new JFrame();
>>>         frame.setTitle("Visualisation");
>>>         frame.setContentPane(mapPane);
>>>         frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
>>>         frame.setSize(640,480);
>>>         frame.setVisible(true);
>>>     }
>>>
>>> }
>>>       
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Geotools-gt2-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>   

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to