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: /**
033: * The flags of an annotation.
034: * <p>
035: * The flags are bits of an integer.<br>
036: * The following bits are defined (more may exist).
037: * </p>
038: * <ul>
039: * <li>0: default
040: * <li>1: Invisible
041: * <li>2: Hidden
042: * <li>3: Print
043: * <li>4: NoZoom
044: * <li>5: NoRotate
045: * <li>6: NoView
046: * <li>7: ReadOnly
047: * <li>8: Locked
048: * <li>9: ToggleNoView
049: * </ul>
050: */
051: public class AnnotationFlags extends AbstractBitFlags {
052: final static public int Bit_Invisible = 1; // Bit position 1
053:
054: final static public int Bit_Hidden = 1 << 1; // Bit position 2
055:
056: final static public int Bit_Print = 1 << 2; // Bit position 3
057:
058: final static public int Bit_NoZoom = 1 << 3;
059:
060: final static public int Bit_NoRotate = 1 << 4;
061:
062: final static public int Bit_NoView = 1 << 5;
063:
064: final static public int Bit_ReadOnly = 1 << 6;
065:
066: final static public int Bit_Locked = 1 << 7;
067:
068: final static public int Bit_ToggleNoView = 1 << 8;
069:
070: final static public int Bit_LockedContents = 1 << 9;
071:
072: private PDAnnotation annotation;
073:
074: public AnnotationFlags(PDAnnotation annotation) {
075: this .annotation = annotation;
076: }
077:
078: public void setHidden(boolean f) {
079: set(Bit_Hidden, f);
080: }
081:
082: public boolean isHidden() {
083: return isSetAnd(Bit_Hidden);
084: }
085:
086: public void setInvisible(boolean f) {
087: set(Bit_Invisible, f);
088: }
089:
090: public boolean isInvisible() {
091: return isSetAnd(Bit_Invisible);
092: }
093:
094: public void setLocked(boolean f) {
095: set(Bit_Locked, f);
096: }
097:
098: public boolean isLocked() {
099: return isSetAnd(Bit_Locked);
100: }
101:
102: public void setNoRotate(boolean f) {
103: set(Bit_NoRotate, f);
104: }
105:
106: public boolean isNoRotate() {
107: return isSetAnd(Bit_NoRotate);
108: }
109:
110: public void setNoView(boolean f) {
111: set(Bit_NoView, f);
112: }
113:
114: public boolean isNoView() {
115: return isSetAnd(Bit_NoView);
116: }
117:
118: public void setNoZoom(boolean f) {
119: set(Bit_NoZoom, f);
120: }
121:
122: public boolean isNoZoom() {
123: return isSetAnd(Bit_NoZoom);
124: }
125:
126: public void setPrint(boolean f) {
127: set(Bit_Print, f);
128: }
129:
130: public boolean isPrint() {
131: return isSetAnd(Bit_Print);
132: }
133:
134: public void setReadOnly(boolean f) {
135: set(Bit_ReadOnly, f);
136: }
137:
138: public boolean isReadOnly() {
139: return isSetAnd(Bit_ReadOnly);
140: }
141:
142: public void setToggleNoView(boolean f) {
143: set(Bit_ToggleNoView, f);
144: }
145:
146: public void setLockedContents(boolean f) {
147: set(Bit_LockedContents, f);
148: }
149:
150: public boolean isToggleNoView() {
151: return isSetAnd(Bit_ToggleNoView);
152: }
153:
154: public boolean isLockedContents() {
155: return isSetAnd(Bit_LockedContents);
156: }
157:
158: protected PDAnnotation getAnnotation() {
159: return annotation;
160: }
161:
162: protected void setValue(int newValue) {
163: getAnnotation().basicSetFlags(newValue);
164: }
165:
166: protected int getValue() {
167: return getAnnotation().basicGetFlags();
168: }
169: }
|