1 31 package org.pdfbox.pdmodel.interactive.annotation; 32 33 import org.pdfbox.cos.COSArray; 34 import org.pdfbox.cos.COSDictionary; 35 import org.pdfbox.cos.COSName; 36 import org.pdfbox.pdmodel.graphics.color.PDGamma; 37 38 45 public class PDAnnotationLine extends PDAnnotationMarkup 46 { 47 48 49 53 54 57 public static final String IT_LINE_ARROW = "LineArrow"; 58 59 62 public static final String IT_LINE_DIMENSION = "LineDimension"; 63 64 68 69 72 public static final String LE_SQUARE = "Square"; 73 74 77 public static final String LE_CIRCLE = "Circle"; 78 79 82 public static final String LE_DIAMOND = "Diamond"; 83 84 87 public static final String LE_OPEN_ARROW = "OpenArrow"; 88 89 92 public static final String LE_CLOSED_ARROW = "ClosedArrow"; 93 94 97 public static final String LE_NONE = "None"; 98 99 102 public static final String LE_BUTT = "Butt"; 103 104 107 public static final String LE_R_OPEN_ARROW = "ROpenArrow"; 108 109 112 public static final String LE_R_CLOSED_ARROW = "RClosedArrow"; 113 114 117 public static final String LE_SLASH = "Slash"; 118 119 122 public static final String SUB_TYPE = "Line"; 123 124 127 public PDAnnotationLine() 128 { 129 super(); 130 getDictionary().setItem( COSName.SUBTYPE, COSName.getPDFName( SUB_TYPE ) ); 131 setLine( new float[] { 0, 0, 0, 0 } ); 133 134 } 135 136 143 public PDAnnotationLine( COSDictionary field ) 144 { 145 super( field ); 146 } 147 148 156 public void setLine( float[] l ) 157 { 158 COSArray newL = new COSArray(); 159 newL.setFloatArray( l ); 160 getDictionary().setItem( "L", newL ); 161 } 162 163 170 public float[] getLine() 171 { 172 COSArray l = (COSArray) getDictionary().getDictionaryObject( "L" ); 173 return l.toFloatArray(); 174 } 175 176 182 public void setStartPointEndingStyle( String style ) 183 { 184 if( style == null ) 185 { 186 style = LE_NONE; 187 } 188 COSArray array = (COSArray)getDictionary().getDictionaryObject( "LE" ); 189 if( array == null ) 190 { 191 array = new COSArray(); 192 array.add( COSName.getPDFName( style ) ); 193 array.add( COSName.getPDFName( LE_NONE ) ); 194 getDictionary().setItem( "LE", array ); 195 } 196 else 197 { 198 array.setName( 0, style ); 199 } 200 } 201 202 208 public String getStartPointEndingStyle() 209 { 210 String retval = LE_NONE; 211 COSArray array = (COSArray)getDictionary().getDictionaryObject( "LE" ); 212 if( array != null ) 213 { 214 retval = array.getName( 0 ); 215 } 216 217 return retval; 218 } 219 220 226 public void setEndPointEndingStyle( String style ) 227 { 228 if( style == null ) 229 { 230 style = LE_NONE; 231 } 232 COSArray array = (COSArray)getDictionary().getDictionaryObject( "LE" ); 233 if( array == null ) 234 { 235 array = new COSArray(); 236 array.add( COSName.getPDFName( LE_NONE ) ); 237 array.add( COSName.getPDFName( style ) ); 238 getDictionary().setItem( "LE", array ); 239 } 240 else 241 { 242 array.setName( 1, style ); 243 } 244 } 245 246 252 public String getEndPointEndingStyle() 253 { 254 String retval = LE_NONE; 255 COSArray array = (COSArray)getDictionary().getDictionaryObject( "LE" ); 256 if( array != null ) 257 { 258 retval = array.getName( 1 ); 259 } 260 261 return retval; 262 } 263 264 272 public void setInteriorColour( PDGamma ic ) 273 { 274 getDictionary().setItem( "IC", ic ); 275 } 276 277 285 public PDGamma getInteriorColour() 286 { 287 288 COSArray ic = (COSArray) getDictionary().getDictionaryObject( "IC" ); 289 if (ic != null) 290 { 291 return new PDGamma( ic ); 292 } 293 else 294 { 295 return null; 296 } 297 } 298 299 305 public void setCaption( boolean cap ) 306 { 307 getDictionary().setBoolean( "Cap", cap ); 308 } 309 310 315 public boolean getCaption() 316 { 317 return getDictionary().getBoolean( "Cap", false ); 318 } 319 320 } | Popular Tags |