Source Code Cross Referenced for PSState.java in  » Graphic-Library » xmlgraphics-commons-1.2 » org » apache » xmlgraphics » ps » 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 » xmlgraphics commons 1.2 » org.apache.xmlgraphics.ps 
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: PSState.java 548990 2007-06-20 08:28:52Z jeremias $ */
019:
020:        package org.apache.xmlgraphics.ps;
021:
022:        import java.io.IOException;
023:        import java.io.Serializable;
024:        import java.util.List;
025:        import java.awt.Color;
026:        import java.awt.geom.AffineTransform;
027:
028:        /**
029:         * This class holds the current state of the PostScript interpreter.
030:         * 
031:         * @version $Id: PSState.java 548990 2007-06-20 08:28:52Z jeremias $
032:         */
033:        public class PSState implements  Serializable {
034:
035:            /** Default for setdash */
036:            public static final String DEFAULT_DASH = "[] 0";
037:            /** Default color in PostScript */
038:            public static final Color DEFAULT_RGB_COLOR = Color.black;
039:
040:            private AffineTransform transform = new AffineTransform();
041:            private List transformConcatList = new java.util.ArrayList();
042:
043:            private int linecap = 0;
044:            private double linewidth = 1.0f;
045:            private String dashpattern = DEFAULT_DASH;
046:            private Color color = DEFAULT_RGB_COLOR;
047:
048:            //Font state
049:            private String fontname;
050:            private float fontsize;
051:
052:            /**
053:             * Default constructor
054:             */
055:            public PSState() {
056:                //nop
057:            }
058:
059:            /**
060:             * Copy constructor
061:             * @param org the original to copy from
062:             * @param copyTransforms true if the list of matrix concats should be cloned, too
063:             */
064:            public PSState(PSState org, boolean copyTransforms) {
065:                this .transform = (AffineTransform) org.transform.clone();
066:                if (copyTransforms) {
067:                    this .transformConcatList.addAll(org.transformConcatList);
068:                }
069:                this .linecap = org.linecap;
070:                this .linewidth = org.linewidth;
071:                this .dashpattern = org.dashpattern;
072:                this .color = org.color;
073:                this .fontname = org.fontname;
074:                this .fontsize = org.fontsize;
075:            }
076:
077:            /**
078:             * Returns the transform.
079:             * @return the current transformation matrix
080:             */
081:            public AffineTransform getTransform() {
082:                return this .transform;
083:            }
084:
085:            /**
086:             * Check the current transform.
087:             * The transform for the current state is the combination of all
088:             * transforms in the current state. The parameter is compared
089:             * against this current transform.
090:             *
091:             * @param tf the transform the check against
092:             * @return true if the new transform is different then the current transform
093:             */
094:            public boolean checkTransform(AffineTransform tf) {
095:                return !tf.equals(this .transform);
096:            }
097:
098:            /**
099:             * Concats the given transformation matrix with the current one.
100:             * @param transform The new transformation matrix
101:             */
102:            public void concatMatrix(AffineTransform transform) {
103:                this .transformConcatList.add(transform);
104:                this .transform.concatenate(transform);
105:            }
106:
107:            /**
108:             * Establishes the specified line cap.
109:             * @param value line cap (0, 1 or 2) as defined by the setlinecap command
110:             * @return true if the line cap changed compared to the previous setting
111:             */
112:            public boolean useLineCap(int value) {
113:                if (linecap != value) {
114:                    linecap = value;
115:                    return true;
116:                } else {
117:                    return false;
118:                }
119:            }
120:
121:            /**
122:             * Establishes the specified line width.
123:             * @param value line width as defined by the setlinewidth command
124:             * @return true if the line width changed compared to the previous setting
125:             */
126:            public boolean useLineWidth(double value) {
127:                if (linewidth != value) {
128:                    linewidth = value;
129:                    return true;
130:                } else {
131:                    return false;
132:                }
133:            }
134:
135:            /**
136:             * Establishes the specified dash.
137:             * @param pattern dash pattern as defined by the setdash command
138:             * @return true if the dash pattern changed compared to the previous setting
139:             */
140:            public boolean useDash(String pattern) {
141:                if (!dashpattern.equals(pattern)) {
142:                    dashpattern = pattern;
143:                    return true;
144:                } else {
145:                    return false;
146:                }
147:            }
148:
149:            /**
150:             * Establishes the specified color (RGB).
151:             * @param value color as defined by the setrgbcolor command
152:             * @return true if the color changed compared to the previous setting
153:             */
154:            public boolean useColor(Color value) {
155:                if (!color.equals(value)) {
156:                    color = value;
157:                    return true;
158:                } else {
159:                    return false;
160:                }
161:            }
162:
163:            /**
164:             * Establishes the specified font and size.
165:             * @param name name of the font for the "F" command (see FOP Std Proc Set)
166:             * @param size size of the font
167:             * @return true if the font changed compared to the previous setting
168:             */
169:            public boolean useFont(String name, float size) {
170:                if (name == null) {
171:                    throw new NullPointerException("font name must not be null");
172:                }
173:                if (fontname == null || !fontname.equals(name)
174:                        || fontsize != size) {
175:                    fontname = name;
176:                    fontsize = size;
177:                    return true;
178:                } else {
179:                    return false;
180:                }
181:            }
182:
183:            /**
184:             * Reestablishes the graphics state represented by this instance by issueing the
185:             * necessary commands.
186:             * @param gen The generator to use for output
187:             * @exception IOException In case of an I/O problem
188:             */
189:            public void reestablish(PSGenerator gen) throws IOException {
190:                for (int i = 0, len = transformConcatList.size(); i < len; i++) {
191:                    gen.concatMatrix((AffineTransform) transformConcatList
192:                            .get(i));
193:                }
194:                gen.useLineCap(linecap);
195:                gen.useLineWidth(linewidth);
196:                gen.useDash(dashpattern);
197:                gen.useColor(color);
198:                if (fontname != null) {
199:                    gen.useFont(fontname, fontsize);
200:                }
201:            }
202:
203:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.