KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > pdfbox > pdmodel > interactive > annotation > PDAnnotationText


1 /**
2  * Copyright (c) 2003, www.pdfbox.org
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  * 3. Neither the name of pdfbox; nor the names of its
14  * contributors may be used to endorse or promote products derived from this
15  * software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * http://www.pdfbox.org
29  *
30  */

31 package org.pdfbox.pdmodel.interactive.annotation;
32
33 import org.pdfbox.cos.COSDictionary;
34 import org.pdfbox.cos.COSName;
35
36 /**
37  * This is the class that represents a text annotation.
38  *
39  * @author Paul King
40  * @version $Revision: 1.1 $
41  */

42 public class PDAnnotationText extends PDAnnotationMarkup
43 {
44
45     /*
46      * The various values of the Text as defined in the PDF 1.6 reference Table
47      * 8.19
48      */

49
50     /**
51      * Constant for the name of a text annotation.
52      */

53     public static final String JavaDoc NAME_COMMENT = "Comment";
54
55     /**
56      * Constant for the name of a text annotation.
57      */

58     public static final String JavaDoc NAME_KEY = "Key";
59
60     /**
61      * Constant for the name of a text annotation.
62      */

63     public static final String JavaDoc NAME_NOTE = "Note";
64
65     /**
66      * Constant for the name of a text annotation.
67      */

68     public static final String JavaDoc NAME_HELP = "Help";
69
70     /**
71      * Constant for the name of a text annotation.
72      */

73     public static final String JavaDoc NAME_NEW_PARAGRAPH = "NewParagraph";
74
75     /**
76      * Constant for the name of a text annotation.
77      */

78     public static final String JavaDoc NAME_PARAGRAPH = "Paragraph";
79
80     /**
81      * Constant for the name of a text annotation.
82      */

83     public static final String JavaDoc NAME_INSERT = "Insert";
84
85     /**
86      * The type of annotation.
87      */

88     public static final String JavaDoc SUB_TYPE = "Text";
89
90     /**
91      * Constructor.
92      */

93     public PDAnnotationText()
94     {
95         super();
96         getDictionary()
97                 .setItem( COSName.SUBTYPE, COSName.getPDFName( SUB_TYPE ) );
98     }
99
100     /**
101      * Creates a Text annotation from a COSDictionary, expected to be a correct
102      * object definition.
103      *
104      * @param field
105      * the PDF objet to represent as a field.
106      */

107     public PDAnnotationText( COSDictionary field )
108     {
109         super( field );
110     }
111
112     /**
113      * This will set inital state of the annotation, open or closed.
114      *
115      * @param open
116      * Boolean value, true = open false = closed
117      */

118     public void setOpen( boolean open )
119     {
120         getDictionary().setBoolean( COSName.getPDFName( "Open" ), open );
121     }
122
123     /**
124      * This will retrieve the initial state of the annotation, open Or closed
125      * (default closed).
126      *
127      * @return The initial state, true = open false = closed
128      */

129     public boolean getOpen()
130     {
131         return getDictionary().getBoolean( COSName.getPDFName( "Open" ), false );
132     }
133
134     /**
135      * This will set the name (and hence appearance, AP taking precedence) For
136      * this annotation. See the NAME_XXX constants for valid values.
137      *
138      * @param name
139      * The name of the annotation
140      */

141     public void setName( String JavaDoc name )
142     {
143         getDictionary().setName( COSName.NAME, name );
144     }
145
146     /**
147      * This will retrieve the name (and hence appearance, AP taking precedence)
148      * For this annotation. The default is NOTE.
149      *
150      * @return The name of this annotation, see the NAME_XXX constants.
151      */

152     public String JavaDoc getName()
153     {
154         return getDictionary().getNameAsString( COSName.NAME, NAME_NOTE );
155     }
156
157 }
Popular Tags