1 31 package org.pdfbox.pdmodel.interactive.pagenavigation; 32 33 import org.pdfbox.cos.COSArray; 34 import org.pdfbox.cos.COSBase; 35 import org.pdfbox.cos.COSDictionary; 36 import org.pdfbox.cos.COSName; 37 38 import org.pdfbox.pdmodel.PDPage; 39 import org.pdfbox.pdmodel.common.COSObjectable; 40 import org.pdfbox.pdmodel.common.PDRectangle; 41 42 48 public class PDThreadBead implements COSObjectable 49 { 50 51 52 private COSDictionary bead; 53 54 59 public PDThreadBead( COSDictionary b ) 60 { 61 bead = b; 62 } 63 64 68 public PDThreadBead() 69 { 70 bead = new COSDictionary(); 71 bead.setName( "Type", "Bead" ); 72 setNextBead( this ); 73 setPreviousBead( this ); 74 } 75 76 81 public COSDictionary getDictionary() 82 { 83 return bead; 84 } 85 86 91 public COSBase getCOSObject() 92 { 93 return bead; 94 } 95 96 102 public PDThread getThread() 103 { 104 PDThread retval = null; 105 COSDictionary dic = (COSDictionary)bead.getDictionaryObject( "T" ); 106 if( dic != null ) 107 { 108 retval = new PDThread( dic ); 109 } 110 return retval; 111 } 112 113 119 public void setThread( PDThread thread ) 120 { 121 bead.setItem( "T", thread ); 122 } 123 124 130 public PDThreadBead getNextBead() 131 { 132 return new PDThreadBead( (COSDictionary) bead.getDictionaryObject( "N" ) ); 133 } 134 135 140 protected void setNextBead( PDThreadBead next ) 141 { 142 bead.setItem( "N", next ); 143 } 144 145 151 public PDThreadBead getPreviousBead() 152 { 153 return new PDThreadBead( (COSDictionary) bead.getDictionaryObject( "V" ) ); 154 } 155 156 161 protected void setPreviousBead( PDThreadBead previous ) 162 { 163 bead.setItem( "V", previous ); 164 } 165 166 172 public void appendBead( PDThreadBead append ) 173 { 174 PDThreadBead nextBead = getNextBead(); 175 nextBead.setPreviousBead( append ); 176 append.setNextBead( nextBead ); 177 setNextBead( append ); 178 append.setPreviousBead( this ); 179 } 180 181 186 public PDPage getPage() 187 { 188 PDPage page = null; 189 COSDictionary dic = (COSDictionary)bead.getDictionaryObject( "P" ); 190 if( dic != null ) 191 { 192 page = new PDPage( dic ); 193 } 194 return page; 195 } 196 197 204 public void setPage( PDPage page ) 205 { 206 bead.setItem( "P", page ); 207 } 208 209 214 public PDRectangle getRectangle() 215 { 216 PDRectangle rect = null; 217 COSArray array = (COSArray)bead.getDictionaryObject( COSName.R ); 218 if( array != null ) 219 { 220 rect = new PDRectangle( array ); 221 } 222 return rect; 223 } 224 225 230 public void setRectangle( PDRectangle rect ) 231 { 232 bead.setItem( COSName.R, rect ); 233 } 234 } | Popular Tags |