Source Code Cross Referenced for ImageUtil.java in  » Graphic-Library » fop » org » apache » fop » render » rtf » rtflib » tools » 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 » Graphic Library » fop » org.apache.fop.render.rtf.rtflib.tools 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        /* $Id: ImageUtil.java 426576 2006-07-28 15:44:37Z jeremias $ */
019:
020:        /*
021:         * This file is part of the RTF library of the FOP project, which was originally
022:         * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and by other
023:         * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to
024:         * the FOP project.
025:         */
026:
027:        package org.apache.fop.render.rtf.rtflib.tools;
028:
029:        /**  Misc.utilities for images handling
030:         *  This class belongs to the <fo:external-graphic> tag processing.
031:         *  @author <a href="mailto:a.putz@skynamics.com">Andreas Putz</a>
032:         */
033:        public class ImageUtil {
034:
035:            //////////////////////////////////////////////////
036:            // @@ Construction
037:            //////////////////////////////////////////////////
038:
039:            /**
040:             * Private constructor.
041:             */
042:            private ImageUtil() {
043:            }
044:
045:            //////////////////////////////////////////////////
046:            // @@ Public static methods
047:            //////////////////////////////////////////////////
048:
049:            /**
050:             * Determines the digits from a string.
051:             *
052:             * @param value String with digits
053:             *
054:             * @return -1      There is no digit
055:             *         number  The digits as integer
056:             */
057:            public static int getInt(String value) {
058:                String retString = new String();
059:                StringBuffer s = new StringBuffer(value);
060:                int len = s.length();
061:
062:                for (int i = 0; i < len; i++) {
063:                    if (Character.isDigit(s.charAt(i))) {
064:                        retString += s.charAt(i);
065:                    } else {
066:                        //for example "600.0pt" has to be exited,
067:                        //when the dot is reached.
068:                        break;
069:                    }
070:                }
071:
072:                if (retString.length() == 0) {
073:                    return -1;
074:                } else {
075:                    return Integer.parseInt(retString);
076:                }
077:            }
078:
079:            /**
080:             * Checks the string for percent character at the end of string.
081:             *
082:             * @param value String with digits
083:             *
084:             * @return true    The string contains a % value
085:             *         false   Other string
086:             */
087:            public static boolean isPercent(String value) {
088:                if (value.endsWith("%")) {
089:                    return true;
090:
091:                }
092:
093:                return false;
094:            }
095:
096:            /**
097:             * Compares two hexadecimal values.
098:             *
099:             * @param pattern Target
100:             * @param data Data
101:             * @param searchAt Position to start compare
102:             * @param searchForward Direction to compare byte arrays
103:             *
104:             * @return true    If equal
105:             *         false   If different
106:             */
107:            public static boolean compareHexValues(byte[] pattern, byte[] data,
108:                    int searchAt, boolean searchForward) {
109:                if (searchAt >= data.length) {
110:                    return false;
111:
112:                }
113:
114:                int pLen = pattern.length;
115:
116:                if (searchForward) {
117:                    if (pLen >= (data.length - searchAt)) {
118:                        return false;
119:
120:                    }
121:
122:                    for (int i = 0; i < pLen; i++) {
123:                        if (pattern[i] != data[searchAt + i]) {
124:                            return false;
125:                        }
126:                    }
127:
128:                    return true;
129:                } else {
130:                    if (pLen > (searchAt + 1)) {
131:                        return false;
132:
133:                    }
134:
135:                    for (int i = 0; i < pLen; i++) {
136:                        if (pattern[pLen - i - 1] != data[searchAt - i]) {
137:                            return false;
138:                        }
139:                    }
140:
141:                    return true;
142:                }
143:            }
144:
145:            /**
146:             * Determines a integer value from a hexadecimal byte array.
147:             *
148:             * @param data Image
149:             * @param startAt Start index to read from
150:             * @param length Number of data elements to read
151:             * @param searchForward True if searching forward, False if not (??)
152:             *
153:             * @return integer
154:             */
155:            public static int getIntFromByteArray(byte[] data, int startAt,
156:                    int length, boolean searchForward) {
157:                int bit = 8;
158:                int bitMoving = length * bit;
159:                int retVal = 0;
160:
161:                if (startAt >= data.length) {
162:                    return retVal;
163:
164:                }
165:
166:                if (searchForward) {
167:                    if (length >= (data.length - startAt)) {
168:                        return retVal;
169:
170:                    }
171:
172:                    for (int i = 0; i < length; i++) {
173:                        bitMoving -= bit;
174:                        int iData = (int) data[startAt + i];
175:                        if (iData < 0) {
176:                            iData += 256;
177:                        }
178:                        retVal += iData << bitMoving;
179:                    }
180:                } else {
181:                    if (length > (startAt + 1)) {
182:                        return retVal;
183:
184:                    }
185:
186:                    for (int i = 0; i < length; i++) {
187:                        bitMoving -= bit;
188:                        int iData = (int) data[startAt - i];
189:                        if (iData < 0) {
190:                            iData += 256;
191:                        }
192:                        retVal += iData << bitMoving;
193:                    }
194:                }
195:
196:                return retVal;
197:            }
198:        }
ww__w_._j_a___v_a2___s___.___c__o___m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.