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.COSDictionary;
033: import org.pdfbox.cos.COSName;
034:
035: /**
036: * This is the class that represents a text annotation.
037: *
038: * @author Paul King
039: * @version $Revision: 1.1 $
040: */
041: public class PDAnnotationText extends PDAnnotationMarkup {
042:
043: /*
044: * The various values of the Text as defined in the PDF 1.6 reference Table
045: * 8.19
046: */
047:
048: /**
049: * Constant for the name of a text annotation.
050: */
051: public static final String NAME_COMMENT = "Comment";
052:
053: /**
054: * Constant for the name of a text annotation.
055: */
056: public static final String NAME_KEY = "Key";
057:
058: /**
059: * Constant for the name of a text annotation.
060: */
061: public static final String NAME_NOTE = "Note";
062:
063: /**
064: * Constant for the name of a text annotation.
065: */
066: public static final String NAME_HELP = "Help";
067:
068: /**
069: * Constant for the name of a text annotation.
070: */
071: public static final String NAME_NEW_PARAGRAPH = "NewParagraph";
072:
073: /**
074: * Constant for the name of a text annotation.
075: */
076: public static final String NAME_PARAGRAPH = "Paragraph";
077:
078: /**
079: * Constant for the name of a text annotation.
080: */
081: public static final String NAME_INSERT = "Insert";
082:
083: /**
084: * The type of annotation.
085: */
086: public static final String SUB_TYPE = "Text";
087:
088: /**
089: * Constructor.
090: */
091: public PDAnnotationText() {
092: super ();
093: getDictionary().setItem(COSName.SUBTYPE,
094: COSName.getPDFName(SUB_TYPE));
095: }
096:
097: /**
098: * Creates a Text annotation from a COSDictionary, expected to be a correct
099: * object definition.
100: *
101: * @param field
102: * the PDF objet to represent as a field.
103: */
104: public PDAnnotationText(COSDictionary field) {
105: super (field);
106: }
107:
108: /**
109: * This will set inital state of the annotation, open or closed.
110: *
111: * @param open
112: * Boolean value, true = open false = closed
113: */
114: public void setOpen(boolean open) {
115: getDictionary().setBoolean(COSName.getPDFName("Open"), open);
116: }
117:
118: /**
119: * This will retrieve the initial state of the annotation, open Or closed
120: * (default closed).
121: *
122: * @return The initial state, true = open false = closed
123: */
124: public boolean getOpen() {
125: return getDictionary().getBoolean(COSName.getPDFName("Open"),
126: false);
127: }
128:
129: /**
130: * This will set the name (and hence appearance, AP taking precedence) For
131: * this annotation. See the NAME_XXX constants for valid values.
132: *
133: * @param name
134: * The name of the annotation
135: */
136: public void setName(String name) {
137: getDictionary().setName(COSName.NAME, name);
138: }
139:
140: /**
141: * This will retrieve the name (and hence appearance, AP taking precedence)
142: * For this annotation. The default is NOTE.
143: *
144: * @return The name of this annotation, see the NAME_XXX constants.
145: */
146: public String getName() {
147: return getDictionary().getNameAsString(COSName.NAME, NAME_NOTE);
148: }
149:
150: }
|