Source Code Cross Referenced for TextState.java in  » PDF » jPod » de » intarsys » pdf » content » 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 » jPod » de.intarsys.pdf.content 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2007, intarsys consulting GmbH
003:         *
004:         * Redistribution and use in source and binary forms, with or without
005:         * modification, are permitted provided that the following conditions are met:
006:         *
007:         * - Redistributions of source code must retain the above copyright notice,
008:         *   this list of conditions and the following disclaimer.
009:         *
010:         * - Redistributions in binary form must reproduce the above copyright notice,
011:         *   this list of conditions and the following disclaimer in the documentation
012:         *   and/or other materials provided with the distribution.
013:         *
014:         * - Neither the name of intarsys nor the names of its contributors may be used
015:         *   to endorse or promote products derived from this software without specific
016:         *   prior written permission.
017:         *
018:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019:         * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
020:         * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
021:         * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
022:         * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
023:         * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
024:         * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
025:         * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
026:         * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
027:         * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
028:         * POSSIBILITY OF SUCH DAMAGE.
029:         */
030:        package de.intarsys.pdf.content;
031:
032:        import java.awt.geom.AffineTransform;
033:
034:        import de.intarsys.pdf.font.PDFont;
035:
036:        /**
037:         * This class summarizes all state information that is used to render characters
038:         * in the current context, such as font, font size etc.
039:         */
040:        public class TextState {
041:            public static final int RENDERING_MODE_CLIP = 7;
042:
043:            public static final int RENDERING_MODE_FILL = 0;
044:
045:            public static final int RENDERING_MODE_FILL_CLIP = 4;
046:
047:            public static final int RENDERING_MODE_FILL_STROKE = 2;
048:
049:            public static final int RENDERING_MODE_FILL_STROKE_CLIP = 6;
050:
051:            public static final int RENDERING_MODE_NONE = 3;
052:
053:            public static final int RENDERING_MODE_STROKE = 1;
054:
055:            public static final int RENDERING_MODE_STROKE_CLIP = 5;
056:
057:            class TextStateFacade implements  ICSTextState {
058:            }
059:
060:            protected ICSTextState facade = new TextStateFacade();
061:
062:            /**
063:             * character spacing, unscaled text units
064:             * 
065:             * <p>
066:             * initial value: 0
067:             * </p>
068:             */
069:            private float charSpacing;
070:
071:            /**
072:             * the PDFont to use for this text piece
073:             * 
074:             * <p>
075:             * initial value: undefined
076:             * </p>
077:             */
078:            private PDFont font;
079:
080:            /**
081:             * the font scaling
082:             * 
083:             * <p>
084:             * initial value: undefined
085:             * </p>
086:             */
087:            private float fontSize;
088:
089:            /**
090:             * percentage of normal width
091:             * 
092:             * <p>
093:             * initial value: 100
094:             * </p>
095:             */
096:            private float horizontalScaling;
097:
098:            private float horizontalScalingFactor;
099:
100:            private boolean knockout;
101:
102:            /**
103:             * text leading, unscaled text units
104:             * 
105:             * <p>
106:             * initial value: 0
107:             * </p>
108:             */
109:            private float leading;
110:
111:            /**
112:             * rendering mode, enumeration
113:             * 
114:             * <p>
115:             * initial value: 0
116:             * </p>
117:             */
118:            private int renderingMode;
119:
120:            /**
121:             * text rise, unscaled text units
122:             * 
123:             * <p>
124:             * initial value: 0
125:             * </p>
126:             * 
127:             * <pre>
128:             *         todo 2 apply text rise to vertical coordinate
129:             * </pre>
130:             */
131:            private float rise;
132:
133:            /**
134:             * The text line matrix.
135:             * 
136:             * <p>
137:             * This is a temporary attribute that keeps track of the state of tm at the
138:             * start of a new line.
139:             * </p>
140:             */
141:            private AffineTransform tlm;
142:
143:            /**
144:             * The text matrix.
145:             */
146:            private AffineTransform tm;
147:
148:            /**
149:             * word spacing, unscaled text units
150:             * 
151:             * <p>
152:             * initial value: 0
153:             * </p>
154:             */
155:            private float wordSpacing;
156:
157:            public TextState() {
158:                charSpacing = 0;
159:                horizontalScaling = 100;
160:                horizontalScalingFactor = 1;
161:                knockout = true;
162:                leading = 0;
163:                renderingMode = 0;
164:                rise = 0;
165:                tlm = new AffineTransform();
166:                tm = new AffineTransform();
167:                wordSpacing = 0;
168:            }
169:
170:            protected TextState(TextState other) {
171:                charSpacing = other.charSpacing;
172:                font = other.font;
173:                fontSize = other.fontSize;
174:                horizontalScaling = other.horizontalScaling;
175:                horizontalScalingFactor = other.horizontalScalingFactor;
176:                knockout = other.knockout;
177:                leading = other.leading;
178:                renderingMode = other.renderingMode;
179:                rise = other.rise;
180:                tlm = other.tlm;
181:                tm = other.tm;
182:                wordSpacing = other.wordSpacing;
183:            }
184:
185:            public void begin() {
186:                setTransform(1, 0, 0, 1, 0, 0);
187:            }
188:
189:            public TextState copy() {
190:                return new TextState(this );
191:            }
192:
193:            public void end() {
194:                // end a text object
195:            }
196:
197:            public float getCharSpacing() {
198:                return charSpacing;
199:            }
200:
201:            public PDFont getFont() {
202:                return font;
203:            }
204:
205:            public float getFontSize() {
206:                return fontSize;
207:            }
208:
209:            public float getHorizontalScaling() {
210:                return horizontalScaling;
211:            }
212:
213:            public float getHorizontalScalingFactor() {
214:                return horizontalScalingFactor;
215:            }
216:
217:            public float getLeading() {
218:                return leading;
219:            }
220:
221:            public int getRenderingMode() {
222:                return renderingMode;
223:            }
224:
225:            public float getRise() {
226:                return rise;
227:            }
228:
229:            public AffineTransform getTextMatrix() {
230:                return tm;
231:            }
232:
233:            public AffineTransform getTextLineMatrix() {
234:                return tlm;
235:            }
236:
237:            public float getWordSpacing() {
238:                return wordSpacing;
239:            }
240:
241:            /**
242:             * Answer <code>true</code> if the actual font in the text state is equal
243:             * to <code>queryFont</code> and <code>queryFontSize</code>.
244:             * 
245:             * @param queryFont
246:             *            the font to be compared
247:             * @param queryFontSize
248:             *            the font size to be compared
249:             * 
250:             * @return True if the actual font is equal.
251:             */
252:            public boolean isFont(PDFont queryFont, float queryFontSize) {
253:                return ((font != null) && font.equals(queryFont))
254:                        && (fontSize == queryFontSize);
255:            }
256:
257:            public boolean isKnockout() {
258:                return knockout;
259:            }
260:
261:            public void tlmMove(float dx, float dy) {
262:                // move text line
263:                tlm.translate(dx, dy);
264:                // restart text matrix
265:                tm.setTransform(tlm);
266:            }
267:
268:            public void tmMove(float dx, float dy) {
269:                // move
270:                tm.translate(dx, dy);
271:            }
272:
273:            public void tmMoveTo(float x, float y) {
274:                // move to
275:                float dx = x - (float) tm.getTranslateX();
276:                float dy = y - (float) tm.getTranslateY();
277:                tm.translate(dx, dy);
278:            }
279:
280:            public void setCharSpacing(float paramCharSpacing) {
281:                charSpacing = paramCharSpacing;
282:            }
283:
284:            public void setFont(PDFont paramFont, float size) {
285:                font = paramFont;
286:                fontSize = size;
287:            }
288:
289:            public void setHorizontalScaling(float paramHorizontalScaling) {
290:                horizontalScaling = paramHorizontalScaling;
291:                horizontalScalingFactor = horizontalScaling / 100f;
292:            }
293:
294:            public void setKnockout(boolean paramKnockout) {
295:                knockout = paramKnockout;
296:            }
297:
298:            public void setLeading(float paramLeading) {
299:                leading = paramLeading;
300:            }
301:
302:            public void setRenderingMode(int paramRenderingMode) {
303:                renderingMode = paramRenderingMode;
304:            }
305:
306:            public void setRise(float paramRise) {
307:                rise = paramRise;
308:            }
309:
310:            public void setTransform(float a, float b, float c, float d,
311:                    float e, float f) {
312:                // reset text line matrix
313:                tlm.setTransform(a, b, c, d, e, f);
314:                // reset text matrix
315:                tm.setTransform(a, b, c, d, e, f);
316:            }
317:
318:            public void setWordSpacing(float paramWordSpacing) {
319:                wordSpacing = paramWordSpacing;
320:            }
321:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.