Hi, That was exactly what i was trying to do, attempting to pass the return value from the function createStyle method into the mapcontext. Sorry for the confusion, it makes a little more sense now. What i did in my ConstructMap.java code was created a style variable, and color c variable and set that to equal to the return value of the createStyle function i.e
style = constrStyle.createStyle(myFeatureTypeName, c); mapContext.addLayer(myFeatureSource,style); i ran my app, and selected my .shp file, it never appeared, which i am assuming it has to do with the function addLayer(). So what i did was in the function, public void addLayer(FeatureSource<SimpleFeatureType, SimpleFeature> featureSource, Style style) { System.out.println("inside addlayer function"); } i created a simple statement to ouput, just to check that the flow of control does go here. Unfortunately, it does not and therefore does not show the print statment. I know that the linestyle has been created and the type names are being stored in the featureSource, but i dont know why it would not be showing?? Here is my constructmap.java code ConstructMap( ) throws Exception { this.constrStyle = new ConstructStyle(); this.c = null; SwingFrame swingFr = new SwingFrame(); // Declare file instance File file = new File("C:/Cavendish_map_data/map_01_data.shp"); // Declare ShapefileDataStore represents the file on disk // Store file location in myShapeFile DataStore myShapeFileStore = new ShapefileDataStore(file.toURI().toURL()); myFeatureTypeNames = myShapeFileStore.getTypeNames(); myFeatureTypeName = myFeatureTypeNames[0]; //Create FeatureSource object which is about the information inside the file itself(features) FeatureSource<SimpleFeatureType, SimpleFeature> myFeatureSource; myFeatureSource = myShapeFileStore.getFeatureSource(myFeatureTypeName); // Create FeatureType which will represent features as objects // use getSchema to access myFeatureSource e.g roads FeatureType myFeatureTypeSchema = myFeatureSource.getSchema(); // Create crs object to store geometry CoordinateReferenceSystem myCrs = myFeatureTypeSchema.getCoordinateReferenceSystem(); // Delcaire MapContext object to help build my map using crs MapContext mapContext = new DefaultMapContext(myCrs); // Pass file and feature schema referrence to myCreateStyle function //constrStyle.myCreateStyle(file, myFeatureTypeSchema); // Add featuresource and style to a layer style = constrStyle.createStyle(myFeatureTypeName, c ); mapContext.addLayer(myFeatureSource, style); // pass over the mapContext param to SwingFrame class to deal with showing the map swingFr.displayMap(mapContext); setTitle(Title); Again, your help would be much greatful, thanks. Michael Bedward wrote: > > Hi Luong, > > I don't quite understand what you're trying to do, but passing an > instance of your ConstructStyle class to the map context or whatever > won't work because it is NOT a Style object. What you want to pass it > is the return value of the createStyle method. > > If you want a separate style helper class you could have one with > static methodsj. For example... > > public class ConstructStyle { > > public static Style constructLineStyle(String featureTypeName, Color > c) { > ... > } > > // insert other style methods for polygons etc. > } > > then in your map building code when you need a style for a feature type... > > Style style = ConstructStyle.constructLineStyle(myTypeName, myColour); > > Michael > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by: > SourcForge Community > SourceForge wants to tell your story. > http://p.sf.net/sfu/sf-spreadtheword > _______________________________________________ > Geotools-gt2-users mailing list > Geotools-gt2-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users > > -- View this message in context: http://n2.nabble.com/Styling-problem-tp2227157p2254660.html Sent from the geotools-gt2-users mailing list archive at Nabble.com. ------------------------------------------------------------------------------ This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword _______________________________________________ Geotools-gt2-users mailing list Geotools-gt2-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users