Source Code Cross Referenced for PDAnnotationLine.java in  » PDF » PDFBox-0.7.3 » org » pdfbox » pdmodel » interactive » annotation » 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 » PDFBox 0.7.3 » org.pdfbox.pdmodel.interactive.annotation 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Copyright (c) 2003, www.pdfbox.org
003:         * All rights reserved.
004:         *
005:         * Redistribution and use in source and binary forms, with or without
006:         * modification, are permitted provided that the following conditions are met:
007:         *
008:         * 1. Redistributions of source code must retain the above copyright notice,
009:         *    this list of conditions and the following disclaimer.
010:         * 2. 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:         * 3. Neither the name of pdfbox; nor the names of its
014:         *    contributors may be used to endorse or promote products derived from this
015:         *    software without specific prior written permission.
016:         *
017:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
018:         * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
019:         * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
020:         * DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
021:         * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
022:         * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
023:         * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
024:         * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
025:         * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
026:         * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
027:         *
028:         * http://www.pdfbox.org
029:         *
030:         */package org.pdfbox.pdmodel.interactive.annotation;
031:
032:        import org.pdfbox.cos.COSArray;
033:        import org.pdfbox.cos.COSDictionary;
034:        import org.pdfbox.cos.COSName;
035:        import org.pdfbox.pdmodel.graphics.color.PDGamma;
036:
037:        /**
038:         * This is the class that represents a line annotation.
039:         * Introduced in PDF 1.3 specification
040:         * 
041:         * @author Paul King
042:         * @version $Revision: 1.1 $
043:         */
044:        public class PDAnnotationLine extends PDAnnotationMarkup {
045:
046:            /*
047:             * The various values for intent (get/setIT, see the PDF 1.6 reference Table
048:             * 8.22
049:             */
050:
051:            /**
052:             * Constant for annotation intent of Arrow.
053:             */
054:            public static final String IT_LINE_ARROW = "LineArrow";
055:
056:            /**
057:             * Constant for annotation intent of a dimension line.
058:             */
059:            public static final String IT_LINE_DIMENSION = "LineDimension";
060:
061:            /*
062:             * The various values for line ending styles, see the PDF 1.6 reference
063:             * Table 8.23
064:             */
065:
066:            /**
067:             * Constant for a square line ending.
068:             */
069:            public static final String LE_SQUARE = "Square";
070:
071:            /**
072:             * Constant for a circle line ending.
073:             */
074:            public static final String LE_CIRCLE = "Circle";
075:
076:            /**
077:             * Constant for a diamond line ending.
078:             */
079:            public static final String LE_DIAMOND = "Diamond";
080:
081:            /**
082:             * Constant for a open arrow line ending.
083:             */
084:            public static final String LE_OPEN_ARROW = "OpenArrow";
085:
086:            /**
087:             * Constant for a closed arrow line ending.
088:             */
089:            public static final String LE_CLOSED_ARROW = "ClosedArrow";
090:
091:            /**
092:             * Constant for no line ending.
093:             */
094:            public static final String LE_NONE = "None";
095:
096:            /**
097:             * Constant for a butt line ending.
098:             */
099:            public static final String LE_BUTT = "Butt";
100:
101:            /**
102:             * Constant for a reversed open arrow line ending.
103:             */
104:            public static final String LE_R_OPEN_ARROW = "ROpenArrow";
105:
106:            /**
107:             * Constant for a revered closed arrow line ending.
108:             */
109:            public static final String LE_R_CLOSED_ARROW = "RClosedArrow";
110:
111:            /**
112:             * Constant for a slash line ending.
113:             */
114:            public static final String LE_SLASH = "Slash";
115:
116:            /**
117:             * The type of annotation.
118:             */
119:            public static final String SUB_TYPE = "Line";
120:
121:            /**
122:             * Constructor.
123:             */
124:            public PDAnnotationLine() {
125:                super ();
126:                getDictionary().setItem(COSName.SUBTYPE,
127:                        COSName.getPDFName(SUB_TYPE));
128:                // Dictionary value L is mandatory, fill in with arbitary value
129:                setLine(new float[] { 0, 0, 0, 0 });
130:
131:            }
132:
133:            /**
134:             * Creates a Line annotation from a COSDictionary, expected to be a correct
135:             * object definition.
136:             * 
137:             * @param field
138:             *            the PDF objet to represent as a field.
139:             */
140:            public PDAnnotationLine(COSDictionary field) {
141:                super (field);
142:            }
143:
144:            /**
145:             * This will set start and end coordinates of the line (or leader line if LL
146:             * entry is set).
147:             * 
148:             * @param l
149:             *            array of 4 floats [x1, y1, x2, y2] line start and end points
150:             *            in default user space.
151:             */
152:            public void setLine(float[] l) {
153:                COSArray newL = new COSArray();
154:                newL.setFloatArray(l);
155:                getDictionary().setItem("L", newL);
156:            }
157:
158:            /**
159:             * This will retrieve the start and end coordinates of the line (or leader
160:             * line if LL entry is set).
161:             * 
162:             * @return array of floats [x1, y1, x2, y2] line start and end points in
163:             *         default user space.
164:             */
165:            public float[] getLine() {
166:                COSArray l = (COSArray) getDictionary()
167:                        .getDictionaryObject("L");
168:                return l.toFloatArray();
169:            }
170:
171:            /**
172:             * This will set the line ending style for the start point, 
173:             * see the LE_ constants for the possible values.
174:             * 
175:             * @param style The new style.
176:             */
177:            public void setStartPointEndingStyle(String style) {
178:                if (style == null) {
179:                    style = LE_NONE;
180:                }
181:                COSArray array = (COSArray) getDictionary()
182:                        .getDictionaryObject("LE");
183:                if (array == null) {
184:                    array = new COSArray();
185:                    array.add(COSName.getPDFName(style));
186:                    array.add(COSName.getPDFName(LE_NONE));
187:                    getDictionary().setItem("LE", array);
188:                } else {
189:                    array.setName(0, style);
190:                }
191:            }
192:
193:            /**
194:             * This will retrieve the line ending style for the start point, 
195:             * possible values shown in the LE_ constants section.
196:             * 
197:             * @return The ending style for the start point.
198:             */
199:            public String getStartPointEndingStyle() {
200:                String retval = LE_NONE;
201:                COSArray array = (COSArray) getDictionary()
202:                        .getDictionaryObject("LE");
203:                if (array != null) {
204:                    retval = array.getName(0);
205:                }
206:
207:                return retval;
208:            }
209:
210:            /**
211:             * This will set the line ending style for the end point, 
212:             * see the LE_ constants for the possible values.
213:             * 
214:             * @param style The new style.
215:             */
216:            public void setEndPointEndingStyle(String style) {
217:                if (style == null) {
218:                    style = LE_NONE;
219:                }
220:                COSArray array = (COSArray) getDictionary()
221:                        .getDictionaryObject("LE");
222:                if (array == null) {
223:                    array = new COSArray();
224:                    array.add(COSName.getPDFName(LE_NONE));
225:                    array.add(COSName.getPDFName(style));
226:                    getDictionary().setItem("LE", array);
227:                } else {
228:                    array.setName(1, style);
229:                }
230:            }
231:
232:            /**
233:             * This will retrieve the line ending style for the end point, 
234:             * possible values shown in the LE_ constants section.
235:             * 
236:             * @return The ending style for the end point.
237:             */
238:            public String getEndPointEndingStyle() {
239:                String retval = LE_NONE;
240:                COSArray array = (COSArray) getDictionary()
241:                        .getDictionaryObject("LE");
242:                if (array != null) {
243:                    retval = array.getName(1);
244:                }
245:
246:                return retval;
247:            }
248:
249:            /**
250:             * This will set interior colour of the line endings defined in the LE
251:             * entry. Colour is in DeviceRGB colourspace.
252:             * 
253:             * @param ic
254:             *            colour in the DeviceRGB colourspace.
255:             * 
256:             */
257:            public void setInteriorColour(PDGamma ic) {
258:                getDictionary().setItem("IC", ic);
259:            }
260:
261:            /**
262:             * This will retrieve the interior colour of the line endings defined in the
263:             * LE entry. Colour is in DeviceRGB colourspace.
264:             * 
265:             * 
266:             * @return PDGamma object representing the colour.
267:             * 
268:             */
269:            public PDGamma getInteriorColour() {
270:
271:                COSArray ic = (COSArray) getDictionary().getDictionaryObject(
272:                        "IC");
273:                if (ic != null) {
274:                    return new PDGamma(ic);
275:                } else {
276:                    return null;
277:                }
278:            }
279:
280:            /**
281:             * This will set if the contents are shown as a caption to the line.
282:             * 
283:             * @param cap
284:             *            Boolean value.
285:             */
286:            public void setCaption(boolean cap) {
287:                getDictionary().setBoolean("Cap", cap);
288:            }
289:
290:            /**
291:             * This will retrieve if the contents are shown as a caption or not.
292:             * 
293:             * @return boolean if the content is shown as a caption.
294:             */
295:            public boolean getCaption() {
296:                return getDictionary().getBoolean("Cap", false);
297:            }
298:
299:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.