Source Code Cross Referenced for Image.java in  » PDF » PDFClown-0.0.5 » it » stefanochizzolini » clown » documents » contents » entities » 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 » PDF » PDFClown 0.0.5 » it.stefanochizzolini.clown.documents.contents.entities 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:          Copyright © 2006,2007 Stefano Chizzolini. http://clown.stefanochizzolini.it
003:
004:          Contributors:
005:         * Stefano Chizzolini (original code developer, http://www.stefanochizzolini.it):
006:              contributed code is Copyright © 2006,2007 by Stefano Chizzolini.
007:
008:          This file should be part of the source code distribution of "PDF Clown library"
009:          (the Program): see the accompanying README files for more info.
010:
011:          This Program is free software; you can redistribute it and/or modify it under
012:          the terms of the GNU General Public License as published by the Free Software
013:          Foundation; either version 2 of the License, or (at your option) any later version.
014:
015:          This Program is distributed in the hope that it will be useful, but WITHOUT ANY
016:          WARRANTY, either expressed or implied; without even the implied warranty of
017:          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License for more details.
018:
019:          You should have received a copy of the GNU General Public License along with this
020:          Program (see README files); if not, go to the GNU website (http://www.gnu.org/).
021:
022:          Redistribution and use, with or without modification, are permitted provided that such
023:          redistributions retain the above copyright notice, license and disclaimer, along with
024:          this list of conditions.
025:         */
026:
027:        package it.stefanochizzolini.clown.documents.contents.entities;
028:
029:        import it.stefanochizzolini.clown.bytes.FileInputStream;
030:        import it.stefanochizzolini.clown.bytes.IInputStream;
031:        import it.stefanochizzolini.clown.documents.contents.objects.ContentObject;
032:
033:        /**
034:         Abstract image object [PDF:1.6:4.8].
035:         @version 0.0.5
036:         */
037:        public abstract class Image extends Entity {
038:            // <class>
039:            // <static>
040:            // <interface>
041:            // <public>
042:            public static Image get(String path) {
043:                try {
044:                    return get(new FileInputStream(
045:                            new java.io.RandomAccessFile(path, "r")));
046:                } catch (Exception e) {
047:                    throw new RuntimeException(e);
048:                }
049:            }
050:
051:            public static Image get(java.io.File file) {
052:                return get(file.getPath());
053:            }
054:
055:            public static Image get(IInputStream stream) {
056:                try {
057:                    // Get the format identifier!
058:                    byte[] formatMarkerBytes = new byte[2];
059:                    stream.read(formatMarkerBytes);
060:
061:                    // Is JPEG?
062:                    if (formatMarkerBytes[0] == (byte) 0xFF
063:                            && formatMarkerBytes[1] == (byte) 0xD8) // JPEG.
064:                    /*
065:                      NOTE: JPEG files are identified by a SOI (Start Of Image) marker [ISO 10918-1].
066:                     */
067:                    {
068:                        return new JpegImage(stream);
069:                    } else // Unknown.
070:                    {
071:                        return null;
072:                    }
073:                } catch (Exception e) {
074:                    throw new RuntimeException(e);
075:                }
076:            }
077:
078:            // </public>
079:            // </interface>
080:            // </static>
081:
082:            // <dynamic>
083:            // <fields>
084:            private int bitsPerComponent;
085:            private int height;
086:            private int width;
087:
088:            private IInputStream stream;
089:
090:            // </fields>
091:
092:            // <constructors>
093:            protected Image(IInputStream stream) {
094:                this .stream = stream;
095:            }
096:
097:            // </constructors>
098:
099:            // <interface>
100:            // <public>
101:            /**
102:              Gets the number of bits per color component [PDF:1.6:4.8.2].
103:             */
104:            public int getBitsPerComponent() {
105:                return bitsPerComponent;
106:            }
107:
108:            /**
109:              Gets the height of the image in samples [PDF:1.6:4.8.2].
110:             */
111:            public int getHeight() {
112:                return height;
113:            }
114:
115:            /**
116:              Gets the width of the image in samples [PDF:1.6:4.8.2].
117:             */
118:            public int getWidth() {
119:                return width;
120:            }
121:
122:            /**
123:              @version 0.0.5
124:             */
125:            /*
126:              NOTE: Image entities are tipically self-contained, so we don't need to contextualize them.
127:             */
128:            public ContentObject toInlineObject() {
129:                return toInlineObject(null);
130:            }
131:
132:            // </public>
133:
134:            // <protected>
135:            /**
136:              Gets the underlying stream.
137:             */
138:            protected IInputStream getStream() {
139:                return stream;
140:            }
141:
142:            /**
143:              Sets the number of bits per color component [PDF:1.6:4.8.2].
144:             */
145:            protected void setBitsPerComponent(int value) {
146:                bitsPerComponent = value;
147:            }
148:
149:            /**
150:              Sets the height of the image in samples [PDF:1.6:4.8.2].
151:             */
152:            protected void setHeight(int value) {
153:                height = value;
154:            }
155:
156:            /**
157:              Sets the width of the image in samples [PDF:1.6:4.8.2].
158:             */
159:            protected void setWidth(int value) {
160:                width = value;
161:            }
162:            // </protected>
163:            // </interface>
164:            // </dynamic>
165:            // </class>
166:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.