001: /*
002: * Copyright (c) 2007, intarsys consulting GmbH
003: *
004: * Redistribution and use in source and binary forms, with or without
005: * modification, are permitted provided that the following conditions are met:
006: *
007: * - Redistributions of source code must retain the above copyright notice,
008: * this list of conditions and the following disclaimer.
009: *
010: * - 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: *
014: * - Neither the name of intarsys nor the names of its contributors may be used
015: * to endorse or promote products derived from this software without specific
016: * prior written permission.
017: *
018: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
020: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
021: * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
022: * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
023: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
024: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
025: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
026: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
027: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
028: * POSSIBILITY OF SUCH DAMAGE.
029: */
030: package de.intarsys.pdf.pd;
031:
032: import de.intarsys.pdf.cds.CDSDate;
033: import de.intarsys.pdf.cos.COSBasedObject;
034: import de.intarsys.pdf.cos.COSName;
035: import de.intarsys.pdf.cos.COSObject;
036:
037: /**
038: * The implementation of a popup window definition within the document. The
039: * popup window is associated with other annotations to enable the user to give
040: * comments and replies.
041: */
042: public class PDPopupAnnotation extends PDAnnotation {
043: /**
044: * The meta class implementation
045: */
046: static public class MetaClass extends PDAnnotation.MetaClass {
047: protected MetaClass(Class instanceClass) {
048: super (instanceClass);
049: }
050:
051: protected COSBasedObject doCreateCOSBasedObject(COSObject object) {
052: return new PDPopupAnnotation(object);
053: }
054: }
055:
056: /** The meta class instance */
057: static public final MetaClass META = new MetaClass(MetaClass.class
058: .getDeclaringClass());
059:
060: public static final COSName CN_Subtype_Popup = COSName
061: .constant("Popup");
062:
063: public static final COSName DK_T = COSName.constant("T");
064:
065: public static final COSName DK_Parent = COSName.constant("Parent");
066:
067: public static final COSName DK_Open = COSName.constant("Open");
068:
069: protected PDPopupAnnotation(COSObject object) {
070: super (object);
071: }
072:
073: public String getText() {
074: PDAnnotation parent = getParent();
075: if (parent == null) {
076: return getFieldString(DK_T, "");
077: } else {
078: return parent.getFieldString(DK_T, "");
079: }
080: }
081:
082: public PDAnnotation getParent() {
083: return (PDAnnotation) PDAnnotation.META
084: .createFromCos(cosGetField(DK_Parent));
085: }
086:
087: public void setParent(PDAnnotation parent) {
088: setFieldObject(DK_Parent, parent);
089: }
090:
091: public String getContents() {
092: PDAnnotation parent = getParent();
093: if (parent == null) {
094: return super .getContents();
095: } else {
096: return parent.getContents();
097: }
098: }
099:
100: public void setContents(String contents) {
101: PDAnnotation parent = getParent();
102: if (parent == null) {
103: setFieldMLString(DK_Contents, contents);
104: } else {
105: parent.setFieldMLString(DK_Contents, contents);
106: }
107: }
108:
109: public String getSubject() {
110: PDAnnotation parent = getParent();
111: if (parent == null) {
112: return getFieldString(PDMarkupAnnotation.DK_Subj, "");
113: } else {
114: return parent
115: .getFieldString(PDMarkupAnnotation.DK_Subj, "");
116: }
117: }
118:
119: public PDPage getPage() {
120: PDAnnotation parent = getParent();
121: if (parent == null) {
122: return super .getPage();
123: } else {
124: return parent.getPage();
125: }
126: }
127:
128: public void setSubject(String subject) {
129: PDAnnotation parent = getParent();
130: if (parent == null) {
131: setFieldString(PDMarkupAnnotation.DK_Subj, subject);
132: } else {
133: parent.setFieldString(PDMarkupAnnotation.DK_Subj, subject);
134: }
135: }
136:
137: public CDSDate getModified() {
138: PDAnnotation parent = getParent();
139: if (parent == null) {
140: return super .getModified();
141: } else {
142: return parent.getModified();
143: }
144: }
145:
146: public float[] getColor() {
147: PDAnnotation parent = getParent();
148: if (parent == null) {
149: return super .getColor();
150: } else {
151: return parent.getColor();
152: }
153: }
154:
155: public boolean isOpen() {
156: return getFieldBoolean(DK_Open, false);
157: }
158:
159: public void setOpen(boolean open) {
160: setFieldBoolean(DK_Open, open);
161: }
162:
163: /*
164: * (non-Javadoc)
165: *
166: * @see de.intarsys.pdf.pd.PDObject#cosGetExpectedSubtype()
167: */
168: protected COSName cosGetExpectedSubtype() {
169: return CN_Subtype_Popup;
170: }
171:
172: public String getSubtypeLabel() {
173: return "Popup";
174: }
175: }
|