svn - r34323 - trunk/spike/web/sphinx/source/examples

1 message Options
Embed this post
Permalink
svn_geotools

svn - r34323 - trunk/spike/web/sphinx/source/examples

Reply Threaded More More options
Print post
Permalink
Author: mbedward
Date: 2009-11-04 07:24:34 -0500 (Wed, 04 Nov 2009)
New Revision: 34323

Added:
   trunk/spike/web/sphinx/source/examples/stylefunctionlab.rst
Modified:
   trunk/spike/web/sphinx/source/examples/index.rst
Log:
New Style Function Lab page for examples - not finished

Modified: trunk/spike/web/sphinx/source/examples/index.rst
===================================================================
--- trunk/spike/web/sphinx/source/examples/index.rst 2009-11-04 12:17:11 UTC (rev 34322)
+++ trunk/spike/web/sphinx/source/examples/index.rst 2009-11-04 12:24:34 UTC (rev 34323)
@@ -10,5 +10,6 @@
    crslab
    querylab
    stylelab
+   stylefunctionlab
    imagelab
    selectionlab

Added: trunk/spike/web/sphinx/source/examples/stylefunctionlab.rst
===================================================================
--- trunk/spike/web/sphinx/source/examples/stylefunctionlab.rst                        (rev 0)
+++ trunk/spike/web/sphinx/source/examples/stylefunctionlab.rst 2009-11-04 12:24:34 UTC (rev 34323)
@@ -0,0 +1,114 @@
+.. _stylefunctionlab:
+
+Style Function Lab
+==================
+
+In :ref:`stylelab` we showed how to create simple rendering styles for features. In this lab we are going to
+look at a slightly more complex example: displaying a shapfile with a style that uses a colour lookup table indexed
+by the values of a chosen feature attribute.
+
+This lab uses GeoTools version 2.6.0
+
+Dependencies
+------------
+
+Please ensure your pom.xml includes the following::
+
+    <dependencies>
+        <dependency>
+            <groupId>org.geotools</groupId>
+            <artifactId>gt-shapefile</artifactId>
+            <version>${geotools.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.geotools</groupId>
+            <artifactId>gt-epsg-hsql</artifactId>
+            <version>${geotools.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.geotools</groupId>
+            <artifactId>gt-swing</artifactId>
+            <version>${geotools.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.geotools</groupId>
+            <artifactId>gt-render</artifactId>
+            <version>${geotools.version}</version>
+            <!-- For this module we explicitly exclude some of its own -->
+            <!-- dependencies from being downloaded because they are   -->
+            <!-- big and we don't need them                            -->
+            <exclusions>
+                <exclusion>
+                    <groupId>org.apache.xmlgraphics</groupId>
+                    <artifactId>batik-transcoder</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+    </dependencies>
+
+You can set the *geotools.version* property somewhere near the top of your pom.xml (see the :ref:`quickstart` if you're not sure how to do this).
+
+Example
+-------
+
+The example code is available
+ * Directly from svn: StyleFunctionLab.java_
+ * Included in the demo directory when you download the GeoTools source code
+
+.. _StyleFunctionLab.java: http://svn.osgeo.org/geotools/trunk/demo/example/src/main/java/org/geotools/demo/StyleFunctionLab.java 
+
+Main application and display method
+-----------------------------------
+
+Please create the file **StyleFunctionLab.java** then copy and paste in the following code:
+
+   .. literalinclude:: ../../../../../demo/example/src/main/java/org/geotools/demo/StyleFunctionLab.java
+      :language: java
+      :start-after: // docs start source
+      :end-before: // docs end display
+
+If you worked through the :ref:`stylelab` most of this code will be *deja vu*. The only change is that we're now prompting the user to
+select a feature attribute and passing the name of this to a new **createStyle** method. Let's look at that method now.
+
+Creating a dynamic Style
+------------------------
+
+   .. literalinclude:: ../../../../../demo/example/src/main/java/org/geotools/demo/StyleFunctionLab.java
+      :language: java
+      :start-after: // docs start create style
+      :end-before: // docs end create style
+
+In :ref:`stylelab` we created Fill and Stroke objects with *literal* (ie. constant) expressions like this:
+
+.. sourcecode:: java
+
+        // create a partially opaque outline stroke
+        Stroke stroke = styleFactory.createStroke(
+                filterFactory.literal(Color.BLUE),
+                filterFactory.literal(1),
+                filterFactory.literal(0.5));
+
+        // create a partial opaque fill
+        Fill fill = styleFactory.createFill(
+                filterFactory.literal(Color.CYAN),
+                filterFactory.literal(0.5));
+    
+But in the method above, we've replaced the constant colour expressions with a reference to the filter function **ColorLookupFunction** to make
+feature colours dynamic, ie. each feature will be coloured based on its value for the selected attribute.
+
+The custom filter function
+--------------------------
+
+GeoTools provides a huge selection of filter functions that can be used not only to control all aspects of display but also to query feature
+data in complex ways. This topic will be explored further in some of the other Labs.
+
+Meanwhile, we're going to look at how to create a custom function that GeoTools will call to provide colours as it draws each feature in the
+shapefile. Here is the function code:
+
+   .. literalinclude:: ../../../../../demo/example/src/main/java/org/geotools/demo/StyleFunctionLab.java
+      :language: java
+      :start-after: // docs start function
+      :end-before: // docs end source
+
+*To be continued...*
+


------------------------------------------------------------------------------
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