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


001:        package com.vividsolutions.jump.workbench.imagery.mrsid;
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.io.BufferedReader;
035:        import java.io.File;
036:        import java.io.FileReader;
037:
038:        import com.vividsolutions.jump.JUMPException;
039:
040:        public class SIDInfo {
041:            private String fileName;
042:            private int pixelWidth;
043:            private int pixelHeight;
044:            private double xres;
045:            private double xrot;
046:            private double yrot;
047:            private double yres;
048:            private double upper_left_x; //realworld coords
049:            private double upper_left_y; //realworld coords
050:
051:            private int numLevels;
052:            private String colorSpace;
053:
054:            SIDInfo(String fileName, int pixelWidth, int pixelHeight,
055:                    double xres, double xrot, double yrot, double yres,
056:                    double ulx, double uly, int numLevels, String colorSpace) {
057:                this .fileName = fileName;
058:                this .pixelWidth = pixelWidth;
059:                this .pixelHeight = pixelHeight;
060:                this .xres = xres;
061:                this .xrot = xrot;
062:                this .yrot = yrot;
063:                this .yres = yres;
064:                this .upper_left_x = ulx;
065:                this .upper_left_y = uly;
066:                this .numLevels = numLevels;
067:                this .colorSpace = colorSpace;
068:            }
069:
070:            String getFileName() {
071:                return fileName;
072:            }
073:
074:            int getPixelWidth() {
075:                return pixelWidth;
076:            }
077:
078:            int getPixelHeight() {
079:                return pixelHeight;
080:            }
081:
082:            double getXRes() {
083:                return xres;
084:            }
085:
086:            double getXRot() {
087:                return xrot;
088:            }
089:
090:            double getYRot() {
091:                return yrot;
092:            }
093:
094:            double getYRes() {
095:                return yres;
096:            }
097:
098:            double getUpperLeftX() {
099:                return upper_left_x;
100:            }
101:
102:            double getUpperLeftY() {
103:                return upper_left_y;
104:            }
105:
106:            int getNumLevels() {
107:                return numLevels;
108:            }
109:
110:            String getColorSpace() {
111:                return colorSpace;
112:            }
113:
114:            static SIDInfo readInfo(String sidFilename) throws JUMPException {
115:                int sidPixelWidth = 0;
116:                int sidPixelHeight = 0;
117:                double sid_xres = 1;
118:                double sid_xrot = 0;
119:                double sid_yrot = 0;
120:                double sid_yres = 1;
121:                double sid_ulx = 0; //realworld coords
122:                double sid_uly = 0; //realworld coords
123:                int maxLevel = 0;
124:
125:                int numInfoItems = 0;
126:                String colorSpace = null;
127:
128:                try {
129:                    File file = File.createTempFile("MrSIDinfo", "txt");
130:                    String[] runStr = { MrSIDImageFactory.MRSIDINFO,
131:                            sidFilename,
132:                            //                    "-sid",
133:                            "-quiet", "-log", file.getPath() };
134:
135:                    Process p = Runtime.getRuntime().exec(runStr);
136:                    p.waitFor();
137:                    p.destroy();
138:
139:                    if (!(file.exists() && file.isFile() && file.canRead()))
140:                        return null; //this could happen if mrsidinfo.exe couldn't produce a file
141:
142:                    //read the info
143:                    FileReader fin = new FileReader(file);
144:                    BufferedReader in = new BufferedReader(fin);
145:                    String lineIn = in.readLine();
146:
147:                    while (in.ready()) {
148:                        String value = "";
149:
150:                        if (lineIn.indexOf("width:") != -1) {
151:                            value = lineIn.substring(lineIn.indexOf(":") + 1);
152:                            sidPixelWidth = Integer.parseInt(value.trim());
153:                            numInfoItems++;
154:                        }
155:
156:                        if (lineIn.indexOf("height:") != -1) {
157:                            value = lineIn.substring(lineIn.indexOf(":") + 1);
158:                            sidPixelHeight = Integer.parseInt(value.trim());
159:                            numInfoItems++;
160:                        }
161:
162:                        if (lineIn.indexOf("number of levels:") != -1) {
163:                            value = lineIn.substring(lineIn.indexOf(":") + 1);
164:                            maxLevel = Integer.parseInt(value.trim());
165:                            numInfoItems++;
166:                        }
167:
168:                        if (lineIn.indexOf("X UL:") != -1) {
169:                            value = lineIn.substring(lineIn.indexOf(":") + 1);
170:                            sid_ulx = Double.parseDouble(value.trim());
171:                            numInfoItems++;
172:                        }
173:
174:                        if (lineIn.indexOf("Y UL:") != -1) {
175:                            value = lineIn.substring(lineIn.indexOf(":") + 1);
176:                            sid_uly = Double.parseDouble(value.trim());
177:                            numInfoItems++;
178:                        }
179:
180:                        if (lineIn.indexOf("X res:") != -1) {
181:                            value = lineIn.substring(lineIn.indexOf(":") + 1);
182:                            sid_xres = Double.parseDouble(value.trim());
183:                            numInfoItems++;
184:                        }
185:
186:                        if (lineIn.indexOf("Y res:") != -1) {
187:                            value = lineIn.substring(lineIn.indexOf(":") + 1);
188:                            sid_yres = Double.parseDouble(value.trim());
189:                            numInfoItems++;
190:                        }
191:
192:                        if (lineIn.indexOf("color space:") != -1) {
193:                            value = lineIn.substring(lineIn.indexOf(":") + 1);
194:                            colorSpace = value.trim();
195:                            numInfoItems++;
196:                        }
197:
198:                        lineIn = in.readLine();
199:                    }
200:
201:                    in.close();
202:                    fin.close();
203:
204:                    if (numInfoItems == 8)
205:                        return new SIDInfo(sidFilename, sidPixelWidth,
206:                                sidPixelHeight, sid_xres, sid_xrot, sid_yrot,
207:                                sid_yres, sid_ulx, sid_uly, maxLevel,
208:                                colorSpace);
209:                    else
210:                        return null;
211:
212:                } catch (Throwable t) {
213:                    throw new JUMPException(t.getMessage());
214:                }
215:            }
216:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.