Source Code Cross Referenced for FloatRasterDemo.java in  » GIS » GeoTools-2.4.1 » org » geotools » demo » coverage » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » GIS » GeoTools 2.4.1 » org.geotools.demo.coverage 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


01:        /*
02:         *    Geotools2 - OpenSource mapping toolkit
03:         *    (C) 2002, Geotools Project Managment Committee (PMC)
04:         *
05:         *    This library is free software; you can redistribute it and/or
06:         *    modify it under the terms of the GNU Lesser General Public
07:         *    License as published by the Free Software Foundation;
08:         *    version 2.1 of the License.
09:         *
10:         *    This library is distributed in the hope that it will be useful,
11:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
12:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13:         *    Lesser General Public License for more details.
14:         */
15:        package org.geotools.demo.coverage;
16:
17:        // J2SE and JAI dependencies
18:        import java.awt.Color;
19:        import java.awt.image.DataBuffer;
20:        import java.awt.image.WritableRaster;
21:        import javax.media.jai.RasterFactory;
22:
23:        // GeoAPI dependencies
24:        import org.opengis.coverage.grid.GridCoverage;
25:        import org.opengis.spatialschema.geometry.Envelope;
26:        import org.opengis.referencing.crs.CoordinateReferenceSystem;
27:
28:        // Geotools dependencies
29:        import org.geotools.geometry.Envelope2D;
30:        import org.geotools.coverage.FactoryFinder;
31:        import org.geotools.coverage.grid.GridCoverage2D;
32:        import org.geotools.coverage.grid.GridCoverageFactory;
33:        import org.geotools.referencing.crs.DefaultGeographicCRS;
34:
35:        /**
36:         * A simple demo computing a {@linkplain WritableRaster raster} and displaying it. The raster uses
37:         * {@code float} data type with arbitrary sample values. This demo consider the image as one and
38:         * only one tile. Consequently, sample values are set directly in the raster (no need to deal for
39:         * multi-tiles).
40:         *
41:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/demo/coverage/src/main/java/org/geotools/demo/coverage/FloatRasterDemo.java $
42:         * @version $Id: FloatRasterDemo.java 18471 2006-03-06 13:10:10Z desruisseaux $
43:         * @author Martin Desruisseaux
44:         */
45:        public class FloatRasterDemo extends junit.framework.TestCase {
46:            /**
47:             * Run the demo.
48:             */
49:            public static void main(String[] args) {
50:                /*
51:                 * Set the pixel values.  Because we use only one tile with one band, the code below
52:                 * is pretty similar to the code we would have if we were just setting the values in
53:                 * a matrix.
54:                 */
55:                final int width = 500;
56:                final int height = 500;
57:                WritableRaster raster = RasterFactory.createBandedRaster(
58:                        DataBuffer.TYPE_FLOAT, width, height, 1, null);
59:                for (int y = 0; y < height; y++) {
60:                    for (int x = 0; x < width; x++) {
61:                        raster.setSample(x, y, 0, x + y);
62:                    }
63:                }
64:                /*
65:                 * Set some metadata (the CRS, the geographic envelope, etc.) and display the image.
66:                 * The display may be slow, since the translation from floating-point values to some
67:                 * color (or grayscale) is performed on the fly everytime the image is rendered.
68:                 */
69:                CoordinateReferenceSystem crs = DefaultGeographicCRS.WGS84;
70:                Envelope envelope = new Envelope2D(crs, 0, 0, 30, 30);
71:                GridCoverageFactory factory = FactoryFinder
72:                        .getGridCoverageFactory(null);
73:                GridCoverage gc = factory.create("My grayscale coverage",
74:                        raster, envelope);
75:                ((GridCoverage2D) gc).show(); // Convenience method specific to Geotools.
76:                /*
77:                 * The above example created a grayscale image. The example below creates a new grid
78:                 * coverage for the same data, but using a specified color map. Note that the factory
79:                 * used allows more details to be specified, for example units. Setting some of those
80:                 * arguments to null (as in this example) lets GridCoverage computes automatically a
81:                 * default value.
82:                 */
83:                Color[] colors = new Color[] { Color.BLUE, Color.CYAN,
84:                        Color.WHITE, Color.YELLOW, Color.RED };
85:                gc = factory.create("My colored coverage", raster, envelope,
86:                        null, null, null, new Color[][] { colors }, null);
87:                ((GridCoverage2D) gc).geophysics(false).show();
88:            }
89:
90:            public void testCoverage() {
91:                main(null);
92:            }
93:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.