Source Code Cross Referenced for Annotation.java in  » PDF » pdf-itext » com » lowagie » text » 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 » pdf itext » com.lowagie.text 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: Annotation.java 2748 2007-05-12 15:11:48Z blowagie $
003:         * $Name$
004:         *
005:         * Copyright 1999, 2000, 2001, 2002 by Bruno Lowagie.
006:         *
007:         * The contents of this file are subject to the Mozilla Public License Version 1.1
008:         * (the "License"); you may not use this file except in compliance with the License.
009:         * You may obtain a copy of the License at http://www.mozilla.org/MPL/
010:         *
011:         * Software distributed under the License is distributed on an "AS IS" basis,
012:         * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
013:         * for the specific language governing rights and limitations under the License.
014:         *
015:         * The Original Code is 'iText, a free JAVA-PDF library'.
016:         *
017:         * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
018:         * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
019:         * All Rights Reserved.
020:         * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
021:         * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
022:         *
023:         * Contributor(s): all the names of the contributors are added in the source code
024:         * where applicable.
025:         *
026:         * Alternatively, the contents of this file may be used under the terms of the
027:         * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
028:         * provisions of LGPL are applicable instead of those above.  If you wish to
029:         * allow use of your version of this file only under the terms of the LGPL
030:         * License and not to allow others to use your version of this file under
031:         * the MPL, indicate your decision by deleting the provisions above and
032:         * replace them with the notice and other provisions required by the LGPL.
033:         * If you do not delete the provisions above, a recipient may use your version
034:         * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
035:         *
036:         * This library is free software; you can redistribute it and/or modify it
037:         * under the terms of the MPL as stated above or under the terms of the GNU
038:         * Library General Public License as published by the Free Software Foundation;
039:         * either version 2 of the License, or any later version.
040:         *
041:         * This library is distributed in the hope that it will be useful, but WITHOUT
042:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
043:         * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
044:         * details.
045:         *
046:         * If you didn't download this code from the following link, you should check if
047:         * you aren't using an obsolete version:
048:         * http://www.lowagie.com/iText/
049:         */
050:
051:        package com.lowagie.text;
052:
053:        import java.net.URL;
054:        import java.util.ArrayList;
055:        import java.util.HashMap;
056:
057:        /**
058:         * An <CODE>Annotation</CODE> is a little note that can be added to a page on
059:         * a document.
060:         * 
061:         * @see Element
062:         * @see Anchor
063:         */
064:
065:        public class Annotation implements  Element {
066:
067:            // membervariables
068:
069:            /** This is a possible annotation type. */
070:            public static final int TEXT = 0;
071:
072:            /** This is a possible annotation type. */
073:            public static final int URL_NET = 1;
074:
075:            /** This is a possible annotation type. */
076:            public static final int URL_AS_STRING = 2;
077:
078:            /** This is a possible annotation type. */
079:            public static final int FILE_DEST = 3;
080:
081:            /** This is a possible annotation type. */
082:            public static final int FILE_PAGE = 4;
083:
084:            /** This is a possible annotation type. */
085:            public static final int NAMED_DEST = 5;
086:
087:            /** This is a possible annotation type. */
088:            public static final int LAUNCH = 6;
089:
090:            /** This is a possible annotation type. */
091:            public static final int SCREEN = 7;
092:
093:            /** This is a possible attribute. */
094:            public static final String TITLE = "title";
095:
096:            /** This is a possible attribute. */
097:            public static final String CONTENT = "content";
098:
099:            /** This is a possible attribute. */
100:            public static final String URL = "url";
101:
102:            /** This is a possible attribute. */
103:            public static final String FILE = "file";
104:
105:            /** This is a possible attribute. */
106:            public static final String DESTINATION = "destination";
107:
108:            /** This is a possible attribute. */
109:            public static final String PAGE = "page";
110:
111:            /** This is a possible attribute. */
112:            public static final String NAMED = "named";
113:
114:            /** This is a possible attribute. */
115:            public static final String APPLICATION = "application";
116:
117:            /** This is a possible attribute. */
118:            public static final String PARAMETERS = "parameters";
119:
120:            /** This is a possible attribute. */
121:            public static final String OPERATION = "operation";
122:
123:            /** This is a possible attribute. */
124:            public static final String DEFAULTDIR = "defaultdir";
125:
126:            /** This is a possible attribute. */
127:            public static final String LLX = "llx";
128:
129:            /** This is a possible attribute. */
130:            public static final String LLY = "lly";
131:
132:            /** This is a possible attribute. */
133:            public static final String URX = "urx";
134:
135:            /** This is a possible attribute. */
136:            public static final String URY = "ury";
137:
138:            /** This is a possible attribute. */
139:            public static final String MIMETYPE = "mime";
140:
141:            /** This is the type of annotation. */
142:            protected int annotationtype;
143:
144:            /** This is the title of the <CODE>Annotation</CODE>. */
145:            protected HashMap annotationAttributes = new HashMap();
146:
147:            /** This is the lower left x-value */
148:            protected float llx = Float.NaN;
149:
150:            /** This is the lower left y-value */
151:            protected float lly = Float.NaN;
152:
153:            /** This is the upper right x-value */
154:            protected float urx = Float.NaN;
155:
156:            /** This is the upper right y-value */
157:            protected float ury = Float.NaN;
158:
159:            // constructors
160:
161:            /**
162:             * Constructs an <CODE>Annotation</CODE> with a certain title and some
163:             * text.
164:             * 
165:             * @param llx
166:             *            lower left x coordinate
167:             * @param lly
168:             *            lower left y coordinate
169:             * @param urx
170:             *            upper right x coordinate
171:             * @param ury
172:             *            upper right y coordinate
173:             */
174:            private Annotation(float llx, float lly, float urx, float ury) {
175:                this .llx = llx;
176:                this .lly = lly;
177:                this .urx = urx;
178:                this .ury = ury;
179:            }
180:
181:            /**
182:             * Copy constructor.
183:             */
184:            public Annotation(Annotation an) {
185:                annotationtype = an.annotationtype;
186:                annotationAttributes = an.annotationAttributes;
187:                llx = an.llx;
188:                lly = an.lly;
189:                urx = an.urx;
190:                ury = an.ury;
191:            }
192:
193:            /**
194:             * Constructs an <CODE>Annotation</CODE> with a certain title and some
195:             * text.
196:             * 
197:             * @param title
198:             *            the title of the annotation
199:             * @param text
200:             *            the content of the annotation
201:             */
202:            public Annotation(String title, String text) {
203:                annotationtype = TEXT;
204:                annotationAttributes.put(TITLE, title);
205:                annotationAttributes.put(CONTENT, text);
206:            }
207:
208:            /**
209:             * Constructs an <CODE>Annotation</CODE> with a certain title and some
210:             * text.
211:             * 
212:             * @param title
213:             *            the title of the annotation
214:             * @param text
215:             *            the content of the annotation
216:             * @param llx
217:             *            the lower left x-value
218:             * @param lly
219:             *            the lower left y-value
220:             * @param urx
221:             *            the upper right x-value
222:             * @param ury
223:             *            the upper right y-value
224:             */
225:            public Annotation(String title, String text, float llx, float lly,
226:                    float urx, float ury) {
227:                this (llx, lly, urx, ury);
228:                annotationtype = TEXT;
229:                annotationAttributes.put(TITLE, title);
230:                annotationAttributes.put(CONTENT, text);
231:            }
232:
233:            /**
234:             * Constructs an <CODE>Annotation</CODE>.
235:             * 
236:             * @param llx
237:             *            the lower left x-value
238:             * @param lly
239:             *            the lower left y-value
240:             * @param urx
241:             *            the upper right x-value
242:             * @param ury
243:             *            the upper right y-value
244:             * @param url
245:             *            the external reference
246:             */
247:            public Annotation(float llx, float lly, float urx, float ury,
248:                    URL url) {
249:                this (llx, lly, urx, ury);
250:                annotationtype = URL_NET;
251:                annotationAttributes.put(URL, url);
252:            }
253:
254:            /**
255:             * Constructs an <CODE>Annotation</CODE>.
256:             * 
257:             * @param llx
258:             *            the lower left x-value
259:             * @param lly
260:             *            the lower left y-value
261:             * @param urx
262:             *            the upper right x-value
263:             * @param ury
264:             *            the upper right y-value
265:             * @param url
266:             *            the external reference
267:             */
268:            public Annotation(float llx, float lly, float urx, float ury,
269:                    String url) {
270:                this (llx, lly, urx, ury);
271:                annotationtype = URL_AS_STRING;
272:                annotationAttributes.put(FILE, url);
273:            }
274:
275:            /**
276:             * Constructs an <CODE>Annotation</CODE>.
277:             * 
278:             * @param llx
279:             *            the lower left x-value
280:             * @param lly
281:             *            the lower left y-value
282:             * @param urx
283:             *            the upper right x-value
284:             * @param ury
285:             *            the upper right y-value
286:             * @param file
287:             *            an external PDF file
288:             * @param dest
289:             *            the destination in this file
290:             */
291:            public Annotation(float llx, float lly, float urx, float ury,
292:                    String file, String dest) {
293:                this (llx, lly, urx, ury);
294:                annotationtype = FILE_DEST;
295:                annotationAttributes.put(FILE, file);
296:                annotationAttributes.put(DESTINATION, dest);
297:            }
298:
299:            /**
300:             * Creates a Screen anotation to embed media clips
301:             * 
302:             * @param llx
303:             * @param lly
304:             * @param urx
305:             * @param ury
306:             * @param moviePath
307:             *            path to the media clip file
308:             * @param mimeType
309:             *            mime type of the media
310:             * @param showOnDisplay
311:             *            if true play on display of the page
312:             */
313:            public Annotation(float llx, float lly, float urx, float ury,
314:                    String moviePath, String mimeType, boolean showOnDisplay) {
315:                this (llx, lly, urx, ury);
316:                annotationtype = SCREEN;
317:                annotationAttributes.put(FILE, moviePath);
318:                annotationAttributes.put(MIMETYPE, mimeType);
319:                annotationAttributes.put(PARAMETERS, new boolean[] {
320:                        false /* embedded */, showOnDisplay });
321:            }
322:
323:            /**
324:             * Constructs an <CODE>Annotation</CODE>.
325:             * 
326:             * @param llx
327:             *            the lower left x-value
328:             * @param lly
329:             *            the lower left y-value
330:             * @param urx
331:             *            the upper right x-value
332:             * @param ury
333:             *            the upper right y-value
334:             * @param file
335:             *            an external PDF file
336:             * @param page
337:             *            a page number in this file
338:             */
339:            public Annotation(float llx, float lly, float urx, float ury,
340:                    String file, int page) {
341:                this (llx, lly, urx, ury);
342:                annotationtype = FILE_PAGE;
343:                annotationAttributes.put(FILE, file);
344:                annotationAttributes.put(PAGE, new Integer(page));
345:            }
346:
347:            /**
348:             * Constructs an <CODE>Annotation</CODE>.
349:             * 
350:             * @param llx
351:             *            the lower left x-value
352:             * @param lly
353:             *            the lower left y-value
354:             * @param urx
355:             *            the upper right x-value
356:             * @param ury
357:             *            the upper right y-value
358:             * @param named
359:             *            a named destination in this file
360:             */
361:            public Annotation(float llx, float lly, float urx, float ury,
362:                    int named) {
363:                this (llx, lly, urx, ury);
364:                annotationtype = NAMED_DEST;
365:                annotationAttributes.put(NAMED, new Integer(named));
366:            }
367:
368:            /**
369:             * Constructs an <CODE>Annotation</CODE>.
370:             * 
371:             * @param llx
372:             *            the lower left x-value
373:             * @param lly
374:             *            the lower left y-value
375:             * @param urx
376:             *            the upper right x-value
377:             * @param ury
378:             *            the upper right y-value
379:             * @param application
380:             *            an external application
381:             * @param parameters
382:             *            parameters to pass to this application
383:             * @param operation
384:             *            the operation to pass to this application
385:             * @param defaultdir
386:             *            the default directory to run this application in
387:             */
388:            public Annotation(float llx, float lly, float urx, float ury,
389:                    String application, String parameters, String operation,
390:                    String defaultdir) {
391:                this (llx, lly, urx, ury);
392:                annotationtype = LAUNCH;
393:                annotationAttributes.put(APPLICATION, application);
394:                annotationAttributes.put(PARAMETERS, parameters);
395:                annotationAttributes.put(OPERATION, operation);
396:                annotationAttributes.put(DEFAULTDIR, defaultdir);
397:            }
398:
399:            // implementation of the Element-methods
400:
401:            /**
402:             * Gets the type of the text element.
403:             * 
404:             * @return a type
405:             */
406:            public int type() {
407:                return Element.ANNOTATION;
408:            }
409:
410:            /**
411:             * Processes the element by adding it (or the different parts) to an <CODE>
412:             * ElementListener</CODE>.
413:             * 
414:             * @param listener
415:             *            an <CODE>ElementListener</CODE>
416:             * @return <CODE>true</CODE> if the element was processed successfully
417:             */
418:            public boolean process(ElementListener listener) {
419:                try {
420:                    return listener.add(this );
421:                } catch (DocumentException de) {
422:                    return false;
423:                }
424:            }
425:
426:            /**
427:             * Gets all the chunks in this element.
428:             * 
429:             * @return an <CODE>ArrayList</CODE>
430:             */
431:
432:            public ArrayList getChunks() {
433:                return new ArrayList();
434:            }
435:
436:            // methods
437:
438:            /**
439:             * Sets the dimensions of this annotation.
440:             * 
441:             * @param llx
442:             *            the lower left x-value
443:             * @param lly
444:             *            the lower left y-value
445:             * @param urx
446:             *            the upper right x-value
447:             * @param ury
448:             *            the upper right y-value
449:             */
450:            public void setDimensions(float llx, float lly, float urx, float ury) {
451:                this .llx = llx;
452:                this .lly = lly;
453:                this .urx = urx;
454:                this .ury = ury;
455:            }
456:
457:            // methods to retrieve information
458:
459:            /**
460:             * Returns the lower left x-value.
461:             * 
462:             * @return a value
463:             */
464:            public float llx() {
465:                return llx;
466:            }
467:
468:            /**
469:             * Returns the lower left y-value.
470:             * 
471:             * @return a value
472:             */
473:            public float lly() {
474:                return lly;
475:            }
476:
477:            /**
478:             * Returns the uppper right x-value.
479:             * 
480:             * @return a value
481:             */
482:            public float urx() {
483:                return urx;
484:            }
485:
486:            /**
487:             * Returns the uppper right y-value.
488:             * 
489:             * @return a value
490:             */
491:            public float ury() {
492:                return ury;
493:            }
494:
495:            /**
496:             * Returns the lower left x-value.
497:             * 
498:             * @param def
499:             *            the default value
500:             * @return a value
501:             */
502:            public float llx(float def) {
503:                if (Float.isNaN(llx))
504:                    return def;
505:                return llx;
506:            }
507:
508:            /**
509:             * Returns the lower left y-value.
510:             * 
511:             * @param def
512:             *            the default value
513:             * @return a value
514:             */
515:            public float lly(float def) {
516:                if (Float.isNaN(lly))
517:                    return def;
518:                return lly;
519:            }
520:
521:            /**
522:             * Returns the upper right x-value.
523:             * 
524:             * @param def
525:             *            the default value
526:             * @return a value
527:             */
528:            public float urx(float def) {
529:                if (Float.isNaN(urx))
530:                    return def;
531:                return urx;
532:            }
533:
534:            /**
535:             * Returns the upper right y-value.
536:             * 
537:             * @param def
538:             *            the default value
539:             * @return a value
540:             */
541:            public float ury(float def) {
542:                if (Float.isNaN(ury))
543:                    return def;
544:                return ury;
545:            }
546:
547:            /**
548:             * Returns the type of this <CODE>Annotation</CODE>.
549:             * 
550:             * @return a type
551:             */
552:            public int annotationType() {
553:                return annotationtype;
554:            }
555:
556:            /**
557:             * Returns the title of this <CODE>Annotation</CODE>.
558:             * 
559:             * @return a name
560:             */
561:            public String title() {
562:                String s = (String) annotationAttributes.get(TITLE);
563:                if (s == null)
564:                    s = "";
565:                return s;
566:            }
567:
568:            /**
569:             * Gets the content of this <CODE>Annotation</CODE>.
570:             * 
571:             * @return a reference
572:             */
573:            public String content() {
574:                String s = (String) annotationAttributes.get(CONTENT);
575:                if (s == null)
576:                    s = "";
577:                return s;
578:            }
579:
580:            /**
581:             * Gets the content of this <CODE>Annotation</CODE>.
582:             * 
583:             * @return a reference
584:             */
585:            public HashMap attributes() {
586:                return annotationAttributes;
587:            }
588:
589:            /**
590:             * Returns an <CODE>Annotation</CODE> that has been constructed taking in
591:             * account the value of some <VAR>attributes </VAR>.
592:             * 
593:             * @param attributes
594:             *            Some attributes
595:             * @deprecated Use ElementFactory.getAnnotation(attributes)
596:             */
597:            public Annotation(java.util.Properties attributes) {
598:                this(com.lowagie.text.factories.ElementFactory
599:                        .getAnnotation(attributes));
600:            }
601:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.