1 3 package org.faceless.pdf; 4 5 import java.util.*; 6 7 19 public final class PDFAction extends PeeredObject 20 { 21 29 public static final int METHOD_HTTP_GET = 4+8; 30 31 44 public static final int METHOD_HTTP_IMAGEMAP_GET = 4+8+16; 45 46 50 public static final int METHOD_HTTP_POST = 4; 51 52 59 public static final int METHOD_HTTP_IMAGEMAP_POST = 4+16; 60 61 65 public static final int METHOD_FDF = 0; 66 67 72 public static final int METHOD_XML = 32; 73 74 80 public static final int METHOD_FDF_WITH_ALL_ANNOTATIONS = 128; 81 82 90 public static final int METHOD_FDF_WITH_MY_ANNOTATIONS = 128+1024; 91 92 97 public static final int METHOD_PDF = 256; 98 99 100 final org.faceless.pdf2.PDFAction action; 101 102 PDFAction(org.faceless.pdf2.PDFAction action) 103 { 104 this.action=action; 105 } 106 107 Object getPeer() 108 { 109 return action; 110 } 111 112 118 public static PDFAction goTo(PDFPage page) 119 { 120 return new PDFAction(org.faceless.pdf2.PDFAction.goTo(page.page)); 121 } 122 123 131 public static PDFAction goTo(PDFPage page, float x, float y, float zoom) 132 { 133 return new PDFAction(org.faceless.pdf2.PDFAction.goTo(page.page,x,y,zoom)); 134 } 135 136 142 public static PDFAction goToFit(PDFPage page) 143 { 144 return new PDFAction(org.faceless.pdf2.PDFAction.goToFit(page.page)); 145 } 146 147 155 public static PDFAction goToFitWidth(PDFPage page, float y) 156 { 157 return new PDFAction(org.faceless.pdf2.PDFAction.goToFitWidth(page.page,y)); 158 } 159 160 168 public static PDFAction goToFitHeight(PDFPage page, float x) 169 { 170 return new PDFAction(org.faceless.pdf2.PDFAction.goToFitHeight(page.page,x)); 171 } 172 173 183 public static PDFAction goToFitRectangle(PDFPage page, float left, float bottom, float width, float height) 184 { 185 return new PDFAction(org.faceless.pdf2.PDFAction.goToFitRectangle(page.page,left,bottom,width,height)); 186 } 187 188 192 public static PDFAction goToURL(java.net.URL url) 193 { 194 return new PDFAction(org.faceless.pdf2.PDFAction.goToURL(url)); 195 } 196 197 205 public static PDFAction goToURL(java.net.URL url, boolean isImageMap) 206 { 207 return new PDFAction(org.faceless.pdf2.PDFAction.goToURL(url,isImageMap)); 208 } 209 210 217 public static PDFAction playSound(PDFSound sound) 218 { 219 return new PDFAction(org.faceless.pdf2.PDFAction.playSound(sound.sound)); 220 } 221 222 230 public static PDFAction playSound(PDFSound sound, int volume, boolean repeat, boolean mix) 231 { 232 return new PDFAction(org.faceless.pdf2.PDFAction.playSound(sound.sound, volume, repeat, mix)); 233 } 234 235 259 public static PDFAction named(String name) 260 { 261 return new PDFAction(org.faceless.pdf2.PDFAction.named(name)); 262 } 263 264 271 public static PDFAction showElement(FormElement element) 272 { 273 return (PDFAction)PeeredObject.getPeer(org.faceless.pdf2.PDFAction.showWidget(element.element.getAnnotation(0))); 274 } 275 276 282 public static PDFAction hideElement(FormElement element) 283 { 284 return (PDFAction)PeeredObject.getPeer(org.faceless.pdf2.PDFAction.hideWidget(element.element.getAnnotation(0))); 285 } 286 287 301 public static PDFAction formSubmit(String url, int method) 302 { 303 int newmethod; 304 if (method==METHOD_FDF) newmethod=org.faceless.pdf2.PDFAction.METHOD_FDF; 305 else if (method==METHOD_PDF) newmethod=org.faceless.pdf2.PDFAction.METHOD_PDF; 306 else if (method==METHOD_HTTP_POST) newmethod=org.faceless.pdf2.PDFAction.METHOD_HTTP_POST; 307 else if (method==METHOD_HTTP_IMAGEMAP_POST) newmethod=org.faceless.pdf2.PDFAction.METHOD_HTTP_IMAGEMAP_POST; 308 else if (method==METHOD_XML) newmethod=org.faceless.pdf2.PDFAction.METHOD_XML; 309 else if (method==METHOD_FDF_WITH_ALL_ANNOTATIONS) newmethod=org.faceless.pdf2.PDFAction.METHOD_FDF_WITH_ALL_ANNOTATIONS; 310 else if (method==METHOD_FDF_WITH_MY_ANNOTATIONS) newmethod=org.faceless.pdf2.PDFAction.METHOD_FDF_WITH_MY_ANNOTATIONS; 311 else throw new IllegalArgumentException ("No such method type"); 312 313 return new PDFAction(org.faceless.pdf2.PDFAction.formSubmit(url, newmethod)); 314 } 315 316 322 public static PDFAction formReset() 323 { 324 return new PDFAction(org.faceless.pdf2.PDFAction.formReset()); 325 } 326 327 335 public static PDFAction formImportData(String file) 336 { 337 return new PDFAction(org.faceless.pdf2.PDFAction.formImportData(file)); 338 } 339 340 354 public static PDFAction formJavaScript(String javascript) 355 { 356 return new PDFAction(org.faceless.pdf2.PDFAction.formJavaScript(javascript)); 357 } 358 359 371 public void setNext(PDFAction a) 372 { 373 action.setNext(a==null ? null : a.action); 374 } 375 376 381 public PDFAction getNext() 382 { 383 return (PDFAction)PeeredObject.getPeer(action.getNext()); 384 } 385 386 401 public String getType() 402 { 403 return action.getType(); 404 } 405 406 413 public PDFPage getPage() 414 { 415 return (PDFPage)PeeredObject.getPeer(action.getPage()); 416 } 417 418 424 public PDFSound getSound() 425 { 426 return (PDFSound)PeeredObject.getPeer(action.getSound()); 427 } 428 429 435 public PDFAnnotation getAnnotation() 436 { 437 return (PDFAnnotation)PeeredObject.getPeer(action.getAnnotation()); 438 } 439 440 446 public String getJavaScript() 447 { 448 return action.getJavaScript(); 449 } 450 451 458 public String getURL() 459 { 460 return action.getURL(); 461 } 462 463 470 public int getFormSubmitMethod() 471 { 472 return action.getFormSubmitMethod(); 473 } 474 475 491 public float[] getGoToCoordinates() 492 { 493 return action.getGoToCoordinates(); 494 } 495 496 public String toString() 497 { 498 String t = getType(); 499 String out = "<action type=\""+t+"\""; 500 if (getJavaScript()!=null) out+=" javascript=\""+getJavaScript()+"\""; 501 if (getSound()!=null) out+=" sound=\""+getSound()+"\""; 502 if (getPage()!=null) out+=" page=\""+getPage()+"\""; 503 if (getNext()!=null) out+=" next=\""+getNext()+"\""; 504 float[] f = getGoToCoordinates(); 505 if (f.length>0) { 506 out+=" coords="; 507 for (int i=0;i<f.length;i++) { 508 out += (i==0 ? "\"" : ",")+f[i]; 509 } 510 out+="\""; 511 } 512 return out+"/>"; 513 } 514 } 515 | Popular Tags |