|
|
|
svn_geotools
|
Author: mbedward
Date: 2009-11-04 07:12:01 -0500 (Wed, 04 Nov 2009) New Revision: 34321 Modified: trunk/demo/example/src/main/java/org/geotools/demo/CRSLab.java trunk/demo/example/src/main/java/org/geotools/demo/QueryLab.java trunk/demo/example/src/main/java/org/geotools/demo/StyleFunctionLab.java trunk/demo/example/src/main/java/org/geotools/demo/swing/ShapefileViewer.java Log: Added docs and sphinx markers to StyleFunctionLab Updated CRSLab for new JMapFrame status bar with crs button Fixed licence in ShapefileViewer Modified: trunk/demo/example/src/main/java/org/geotools/demo/CRSLab.java =================================================================== --- trunk/demo/example/src/main/java/org/geotools/demo/CRSLab.java 2009-11-04 10:53:06 UTC (rev 34320) +++ trunk/demo/example/src/main/java/org/geotools/demo/CRSLab.java 2009-11-04 12:12:01 UTC (rev 34321) @@ -18,7 +18,6 @@ import java.io.Serializable; import java.util.HashMap; import java.util.Map; -import javax.swing.AbstractAction; import javax.swing.Action; import javax.swing.JButton; import javax.swing.JOptionPane; @@ -41,7 +40,6 @@ import org.geotools.map.DefaultMapContext; import org.geotools.map.MapContext; import org.geotools.referencing.CRS; -import org.geotools.swing.JCRSChooser; import org.geotools.swing.JMapFrame; import org.geotools.swing.ProgressWindow; import org.geotools.swing.action.SafeAction; @@ -106,9 +104,8 @@ mapFrame.enableStatusBar(true); JToolBar toolbar = mapFrame.getToolBar(); - toolbar.add( new JButton( new ChangeCRSAction() ) ); - toolbar.add( new JButton( new ExportShapefileAction() ) ); toolbar.add( new JButton( new ValidateGeometryAction() ) ); + toolbar.add( new JButton( new ExportShapefileAction() ) ); /* * Display the map frame. When it is closed the application @@ -297,34 +294,6 @@ // docs end validate - // docs start crs action - /** - * This class performs the task of changing the CRS of the map display - * when the toolbar button is pressed. It also supplies the name and - * tool tip for the button. - */ - class ChangeCRSAction extends AbstractAction { - - ChangeCRSAction() { - super("Reproject..."); - putValue(Action.SHORT_DESCRIPTION, "Display features with in a new CRS"); - } - - public void actionPerformed(ActionEvent arg0) { - try { - CoordinateReferenceSystem crs = JCRSChooser.showDialog( - null, "Coordinate Reference System", "Choose a new projection:", null); - if (crs != null) { - map.setCoordinateReferenceSystem(crs); - } - } catch (Exception ex) { - System.out.println("Could not use crs " + ex); - } - } - } - - // docs end crs action - // docs start export action /** * This class performs the task of exporting the features to a new shapefile Modified: trunk/demo/example/src/main/java/org/geotools/demo/QueryLab.java =================================================================== --- trunk/demo/example/src/main/java/org/geotools/demo/QueryLab.java 2009-11-04 10:53:06 UTC (rev 34320) +++ trunk/demo/example/src/main/java/org/geotools/demo/QueryLab.java 2009-11-04 12:12:01 UTC (rev 34321) @@ -137,8 +137,8 @@ * To modify this example to work with a PostGIS database instead just replace 'new * ShapefileDataStoreFactory()' in the line below with 'new PostgisDataStoreFactory()' */ - //JDataStoreWizard wizard = new JDataStoreWizard(new ShapefileDataStoreFactory()); - JDataStoreWizard wizard = new JDataStoreWizard(new PostgisDataStoreFactory()); + JDataStoreWizard wizard = new JDataStoreWizard(new ShapefileDataStoreFactory()); + //JDataStoreWizard wizard = new JDataStoreWizard(new PostgisDataStoreFactory()); int result = wizard.showModalDialog(); if (result != JWizard.FINISH) { System.exit(0); Modified: trunk/demo/example/src/main/java/org/geotools/demo/StyleFunctionLab.java =================================================================== --- trunk/demo/example/src/main/java/org/geotools/demo/StyleFunctionLab.java 2009-11-04 10:53:06 UTC (rev 34320) +++ trunk/demo/example/src/main/java/org/geotools/demo/StyleFunctionLab.java 2009-11-04 12:12:01 UTC (rev 34321) @@ -1,3 +1,4 @@ +// docs start source /* * GeoTools - The Open Source Java GIS Tookit * http://geotools.org @@ -59,9 +60,9 @@ } /** - * Display - * @param file - * @throws Exception + * Connect to the shapefile and prompt the user to choose a feature + * attribute to base line and fill colours on. A colour will be + * generated for each unique value of the chosen attribute. */ private void displayShapefile(File file) throws Exception { FileDataStore store = FileDataStoreFinder.getDataStore(file); @@ -71,6 +72,10 @@ MapContext map = new DefaultMapContext(); map.setTitle("Filter Function Lab"); + /* + * Prompt the user for the feature attribute used to + * determine the line and fill colour for each feature + */ FeatureType type = featureSource.getSchema(); PropertyDescriptor geomDesc = type.getGeometryDescriptor(); List<String> attributeNames = new ArrayList<String>(); @@ -86,6 +91,9 @@ JOptionPane.PLAIN_MESSAGE, null, attributeNames.toArray(), null); + /** + * Create the Style and display the shapefile + */ if (selection != null) { Style style = createStyle(featureSource, (String)selection); map.addLayer(featureSource, style); @@ -94,7 +102,10 @@ JMapFrame.showMap(map); } } + + // docs end display + // docs start create style /** * Create a rendering style to display features from the given feature source * by matching unique values of the specified feature attribute to colours @@ -105,47 +116,56 @@ private Style createStyle(FeatureSource featureSource, String attributeName) throws Exception { - FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null); - StyleFactory sf = CommonFactoryFinder.getStyleFactory(null); + FilterFactory2 filterFactory = CommonFactoryFinder.getFilterFactory2(null); + StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory(null); - UniqueColourFunction colourFn = new UniqueColourFunction( - featureSource.getFeatures(), ff.property(attributeName)); - Fill fill = sf.createFill(colourFn); - Stroke stroke = sf.createStroke(colourFn, ff.literal(1.0f)); + ColorLookupFunction colourFn = new ColorLookupFunction( + featureSource.getFeatures(), filterFactory.property(attributeName)); + Stroke stroke = styleFactory.createStroke( + colourFn, // function to choose feature colour + filterFactory.literal(1.0f), // line width + filterFactory.literal(1.0f)); // opacity + + Fill fill = styleFactory.createFill( + colourFn, // function to choose feature colour + filterFactory.literal(1.0f)); // opacity + Class<?> geomClass = featureSource.getSchema().getGeometryDescriptor().getType().getBinding(); Symbolizer sym = null; if (Polygon.class.isAssignableFrom(geomClass) || MultiPolygon.class.isAssignableFrom(geomClass)) { - sym = sf.createPolygonSymbolizer(stroke, fill, null); + sym = styleFactory.createPolygonSymbolizer(stroke, fill, null); } else if (LineString.class.isAssignableFrom(geomClass) || MultiLineString.class.isAssignableFrom(geomClass)) { - sym = sf.createLineSymbolizer(stroke, null); + sym = styleFactory.createLineSymbolizer(stroke, null); } else { - Graphic gr = sf.createDefaultGraphic(); + Graphic gr = styleFactory.createDefaultGraphic(); gr.graphicalSymbols().clear(); - Mark mark = sf.getCircleMark(); + Mark mark = styleFactory.getCircleMark(); mark.setFill(fill); mark.setStroke(stroke); gr.graphicalSymbols().add(mark); - gr.setSize(ff.literal(10.0f)); - sym = sf.createPointSymbolizer(gr, null); + gr.setSize(filterFactory.literal(10.0f)); + sym = styleFactory.createPointSymbolizer(gr, null); } Style style = SLD.wrapSymbolizers(sym); return style; } + // docs end create style:w + // docs start function /** * A function to dynamically allocate colours to features. It works with a lookup table * where the key is a user-specified feature attribute. Colours are generated using * a simple colour ramp algorithm. */ - static class UniqueColourFunction extends FunctionExpressionImpl { + static class ColorLookupFunction extends FunctionExpressionImpl { private static final float INITIAL_HUE = 0.1f; private final FeatureCollection collection; @@ -169,7 +189,7 @@ * @param colourAttribute a literal expression that specifies the feature attribute * to use for colour lookup */ - public UniqueColourFunction(FeatureCollection collection, Expression colourAttribute) { + public ColorLookupFunction(FeatureCollection collection, Expression colourAttribute) { super("UniqueColour"); this.collection = collection; @@ -236,3 +256,4 @@ } } +// docs end source Modified: trunk/demo/example/src/main/java/org/geotools/demo/swing/ShapefileViewer.java =================================================================== --- trunk/demo/example/src/main/java/org/geotools/demo/swing/ShapefileViewer.java 2009-11-04 10:53:06 UTC (rev 34320) +++ trunk/demo/example/src/main/java/org/geotools/demo/swing/ShapefileViewer.java 2009-11-04 12:12:01 UTC (rev 34321) @@ -1,18 +1,11 @@ /* - * GeoTools - The Open Source Java GIS Toolkit + * GeoTools - The Open Source Java GIS Tookit * http://geotools.org * - * (C) 2002-2008, Open Source Geospatial Foundation (OSGeo) + * (C) 2006-2008, Open Source Geospatial Foundation (OSGeo) * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This file is hereby placed into the Public Domain. This means anyone is + * free to do whatever they wish with this file. Use it well and enjoy! */ package org.geotools.demo.swing; ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ GeoTools-commits mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/geotools-commits |
||||||||||||||||
| Free Embeddable Forum Powered by Nabble | Help |