Source Code Cross Referenced for GeoReferencedRaster.java in  » GIS » openjump » com » vividsolutions » jump » workbench » imagery » geotiff » 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 » openjump » com.vividsolutions.jump.workbench.imagery.geotiff 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.vividsolutions.jump.workbench.imagery.geotiff;
002:
003:        /*
004:         * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI 
005:         * for visualizing and manipulating spatial features with geometry and attributes.
006:         *
007:         * Copyright (C) 2003 Vivid Solutions
008:         * 
009:         * This program is free software; you can redistribute it and/or
010:         * modify it under the terms of the GNU General Public License
011:         * as published by the Free Software Foundation; either version 2
012:         * of the License, or (at your option) any later version.
013:         * 
014:         * This program is distributed in the hope that it will be useful,
015:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
016:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
017:         * GNU General Public License for more details.
018:         * 
019:         * You should have received a copy of the GNU General Public License
020:         * along with this program; if not, write to the Free Software
021:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
022:         * 
023:         * For more information, contact:
024:         *
025:         * Vivid Solutions
026:         * Suite #1A
027:         * 2328 Government Street
028:         * Victoria BC  V8T 5G5
029:         * Canada
030:         *
031:         * (250)385-6040
032:         * www.vividsolutions.com
033:         */
034:        import java.awt.geom.AffineTransform;
035:        import java.awt.geom.Point2D;
036:        import java.awt.image.renderable.ParameterBlock;
037:
038:        import javax.media.jai.JAI;
039:        import javax.media.jai.RenderedOp;
040:
041:        import com.vividsolutions.jts.geom.Coordinate;
042:        import com.vividsolutions.jts.geom.Envelope;
043:
044:        public abstract class GeoReferencedRaster {
045:            protected String imageFileLocation;
046:            protected RenderedOp src = null;
047:            Envelope envModel_image;
048:
049:            // Image enhancement
050:            double[] min;
051:            double[] max;
052:
053:            Coordinate coorRasterTiff_tiepointLT;
054:            Coordinate coorModel_tiepointLT;
055:
056:            private double dblModelUnitsPerRasterUnit_X;
057:            private double dblModelUnitsPerRasterUnit_Y;
058:
059:            public GeoReferencedRaster(String imageFileLocation)
060:                    throws Exception {
061:                this .imageFileLocation = imageFileLocation;
062:            }
063:
064:            /**
065:             * Basic fetchRasters retrieves a raster from a file. To get a raster from
066:             * somewhere else, override this method in subclasses.
067:             */
068:            protected void fetchRaster() throws Exception {
069:                src = JAI.create("fileload", imageFileLocation);
070:            }
071:
072:            protected void readRasterfile() throws Exception {
073:                // ===========================
074:                // Load the image, any format.
075:                // ===========================
076:                fetchRaster();
077:
078:                // ======================================
079:                // Image can be distorted, make it square
080:                // in modelspace.
081:                // ======================================
082:                normalize(src);
083:            }
084:
085:            /**
086:             * Convert a coordinate from rasterspace to modelspace.
087:             *
088:             * @param coorRaster
089:             *          coordinate in rasterspace
090:             * @return coordinate in modelspace
091:             */
092:            private Coordinate rasterToModelSpace(Coordinate coorRaster) {
093:                Coordinate coorModel = new Coordinate();
094:
095:                coorModel.x = coorModel_tiepointLT.x
096:                        + (coorRaster.x - coorRasterTiff_tiepointLT.x)
097:                        * dblModelUnitsPerRasterUnit_X;
098:                coorModel.y = coorModel_tiepointLT.y
099:                        - (coorRaster.y + coorRasterTiff_tiepointLT.y)
100:                        * dblModelUnitsPerRasterUnit_Y;
101:                coorModel.z = 0;
102:
103:                return coorModel;
104:            }
105:
106:            /**
107:             * This method must be overridden if an image is not a square image in
108:             * modelspace. It should be transformed to make it a square image in
109:             * modelspace.
110:             *
111:             * @param image
112:             */
113:            protected void normalize(RenderedOp image) {
114:            }
115:
116:            /**
117:             * @return
118:             */
119:            public Coordinate getCoorModel_tiepointLT() {
120:                return coorModel_tiepointLT;
121:            }
122:
123:            /**
124:             * @return
125:             */
126:            public Coordinate getCoorRasterTiff_tiepointLT() {
127:                return coorRasterTiff_tiepointLT;
128:            }
129:
130:            /**
131:             * @return
132:             */
133:            public double getDblModelUnitsPerRasterUnit_X() {
134:                return dblModelUnitsPerRasterUnit_X;
135:            }
136:
137:            /**
138:             * @return
139:             */
140:            public double getDblModelUnitsPerRasterUnit_Y() {
141:                return dblModelUnitsPerRasterUnit_Y;
142:            }
143:
144:            public RenderedOp getImage() throws Exception {
145:                if (src == null)
146:                    readRasterfile();
147:                return src;
148:            }
149:
150:            void setEnvelope() {
151:                //    try
152:                //    {
153:                Coordinate coorRaster_imageLB = new Coordinate(
154:                        coorRasterTiff_tiepointLT.x, src.getHeight() - 1, 0);
155:                Coordinate coorRaster_imageRT = new Coordinate(
156:                        src.getWidth() - 1, 0, 0);
157:                Coordinate coorModel_imageLB = rasterToModelSpace(coorRaster_imageLB);
158:                Coordinate coorModel_imageRT = rasterToModelSpace(coorRaster_imageRT);
159:
160:                envModel_image = new Envelope(coorModel_imageLB,
161:                        coorModel_imageRT);
162:            }
163:
164:            /**
165:             * @param coordinate
166:             */
167:            public void setCoorModel_tiepointLT(Coordinate coordinate) {
168:                coorModel_tiepointLT = coordinate;
169:                setEnvelope();
170:            }
171:
172:            /**
173:             * @param coordinate
174:             */
175:            public void setCoorRasterTiff_tiepointLT(Coordinate coordinate) {
176:                coorRasterTiff_tiepointLT = coordinate;
177:                //setEnvelope();
178:            }
179:
180:            /**
181:             * @param d
182:             */
183:            public void setDblModelUnitsPerRasterUnit_X(double d) {
184:                dblModelUnitsPerRasterUnit_X = d;
185:                //setEnvelope();
186:            }
187:
188:            /**
189:             * @param d
190:             */
191:            public void setDblModelUnitsPerRasterUnit_Y(double d) {
192:                dblModelUnitsPerRasterUnit_Y = d;
193:                setEnvelope();
194:            }
195:
196:            public void setAffineTransformation(AffineTransform transform) {
197:                double scaleX = Math.abs(transform.getScaleX());
198:                double scaleY = Math.abs(transform.getScaleY());
199:
200:                setDblModelUnitsPerRasterUnit_X(scaleX);
201:                setDblModelUnitsPerRasterUnit_Y(scaleY);
202:
203:                Point2D rasterLT = new Point2D.Double(src.getMinX(), src
204:                        .getMinY());
205:                Point2D modelLT = new Point2D.Double();
206:                transform.transform(rasterLT, modelLT);
207:
208:                setCoorRasterTiff_tiepointLT(new Coordinate(rasterLT.getX(),
209:                        rasterLT.getY()));
210:                setCoorModel_tiepointLT(new Coordinate(modelLT.getX(), modelLT
211:                        .getY()));
212:            }
213:
214:            public RenderedOp fullContrast() {
215:                int bands = src.getNumBands();
216:                double[] constants = new double[bands];
217:                double[] offsets = new double[bands];
218:                for (int i = 0; i < bands; i++) {
219:                    constants[i] = 1.2 * 255 / (max[i] - min[i]);
220:                    offsets[i] = 255 * min[i] / (min[i] - max[i]);
221:                }
222:
223:                ParameterBlock pb = new ParameterBlock();
224:                pb.addSource(src);
225:                pb.add(constants);
226:                pb.add(offsets);
227:                return JAI.create("rescale", pb, null);
228:            }
229:
230:            public Envelope getEnvelope() {
231:                return envModel_image;
232:            }
233:
234:            public double[] getMinimumExtreme() {
235:                return min;
236:            }
237:
238:            public double[] getMaximumExtreme() {
239:                return max;
240:            }
241:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.