Source Code Cross Referenced for SliceImageReader.java in  » GIS » GeoTools-2.4.1 » it » geosolutions » imageio » plugins » slices2D » 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 » it.geosolutions.imageio.plugins.slices2D 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package it.geosolutions.imageio.plugins.slices2D;
002:
003:        import java.awt.Transparency;
004:        import java.awt.color.ColorSpace;
005:        import java.awt.image.BufferedImage;
006:        import java.awt.image.ColorModel;
007:        import java.awt.image.ComponentColorModel;
008:        import java.awt.image.DataBuffer;
009:        import java.awt.image.SampleModel;
010:        import java.io.File;
011:        import java.io.IOException;
012:        import java.util.Iterator;
013:        import java.util.logging.Logger;
014:
015:        import javax.imageio.ImageReadParam;
016:        import javax.imageio.ImageReader;
017:        import javax.imageio.metadata.IIOMetadata;
018:        import javax.imageio.spi.ImageReaderSpi;
019:
020:        import com.sun.media.imageioimpl.common.ImageUtil;
021:        import com.sun.media.jai.codecimpl.util.RasterFactory;
022:
023:        /**
024:         * An abstract super class which need to be extended by any specific format's
025:         * <code>ImageReader</code> to work with 2D datasets.
026:         * 
027:         * @author Romagnoli Daniele
028:         */
029:        public abstract class SliceImageReader extends ImageReader implements 
030:                IndexManager {
031:            private static final Logger LOGGER = org.geotools.util.logging.Logging
032:                    .getLogger("it.geosolutions.imageio.plugins.slices2D");
033:
034:            /** set it to <code>true</code> when initialization has been performed */
035:            protected boolean isInitialized = false;
036:
037:            /** The originating <code>File</code> */
038:            protected File originatingFile = null;
039:
040:            protected SliceImageReader(ImageReaderSpi originatingProvider) {
041:                super (originatingProvider);
042:            }
043:
044:            /** Implements this method to allow structure initialization. */
045:            protected abstract void initialize() throws IOException;
046:
047:            public abstract int getHeight(int imageIndex) throws IOException;
048:
049:            public abstract int getWidth(int imageIndex) throws IOException;
050:
051:            /**
052:             * Specific implementation of the read Operation. Any format's reader need
053:             * to implement its own version of the read operation.
054:             */
055:            public abstract BufferedImage read(int imageIndex,
056:                    ImageReadParam param) throws IOException;
057:
058:            /** return imageMetadata related to a specific product or subdataset. */
059:            public abstract IIOMetadata getImageMetadata(int imageIndex)
060:                    throws IOException;
061:
062:            /** return streamMetadata related to the whole source. */
063:            public abstract IIOMetadata getStreamMetadata() throws IOException;
064:
065:            public abstract Iterator getImageTypes(int imageIndex)
066:                    throws IOException;
067:
068:            /**
069:             * Utilty method returning a proper <code>ColorModel</code> given an input
070:             * <code>SampleModel</code>
071:             * 
072:             * @param sm
073:             *            The <code>SampleModel</code> for which we need to create a
074:             *            compatible <code>ColorModel</code>.
075:             * 
076:             * @return the created <code>ColorModel</code>
077:             */
078:            protected ColorModel retrieveColorModel(final SampleModel sm) {
079:                final int nBands = sm.getNumBands();
080:                final int bufferType = sm.getDataType();
081:                ColorModel cm = null;
082:                ColorSpace cs = null;
083:                if (nBands > 1) {
084:                    // Number of Bands > 1.
085:                    // ImageUtil.createColorModel provides to Creates a
086:                    // ColorModel that may be used with the specified
087:                    // SampleModel
088:                    cm = ImageUtil.createColorModel(sm);
089:                    if (cm == null)
090:                        LOGGER.info("There are no ColorModels found");
091:
092:                } else if ((bufferType == DataBuffer.TYPE_BYTE)
093:                        || (bufferType == DataBuffer.TYPE_USHORT)
094:                        || (bufferType == DataBuffer.TYPE_INT)
095:                        || (bufferType == DataBuffer.TYPE_FLOAT)
096:                        || (bufferType == DataBuffer.TYPE_DOUBLE)) {
097:
098:                    // Just one band. Using the built-in Gray Scale Color Space
099:                    cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
100:                    cm = RasterFactory.createComponentColorModel(bufferType, // dataType
101:                            cs, // color space
102:                            false, // has alpha
103:                            false, // is alphaPremultiplied
104:                            Transparency.OPAQUE); // transparency
105:                } else {
106:                    if (bufferType == DataBuffer.TYPE_SHORT) {
107:                        // Just one band. Using the built-in Gray Scale Color
108:                        // Space
109:                        cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
110:                        cm = new ComponentColorModel(cs, false, false,
111:                                Transparency.OPAQUE, DataBuffer.TYPE_SHORT);
112:                    }
113:                }
114:                return cm;
115:            }
116:
117:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.