1 3 package org.faceless.pdf; 4 5 import java.io.*; 6 import java.util.*; 7 import java.awt.Color ; 8 9 27 public final class FormButton extends FormElement 28 { 29 FormButton(org.faceless.pdf2.FormButton b) 30 { 31 super(b); 32 } 33 34 40 public FormButton() 41 { 42 this(null,0,0,0,0); 43 } 44 45 53 public FormButton(PDFPage page, float x1, float y1, float x2, float y2) 54 { 55 super(new org.faceless.pdf2.FormButton(page==null ? null : page.page, x1, y1, x2, y2)); 56 } 57 58 78 public void setStyle(PDFStyle text, PDFStyle background) 79 { 80 List l = element.getAnnotations(); 81 for (int i=0;i<l.size();i++) { 82 org.faceless.pdf2.WidgetAnnotation annot = element.getAnnotation(i); 83 annot.setTextStyle(text==null ? null : text.style); 84 annot.setBackgroundStyle(background==null ? null : background.style); 85 } 86 } 87 88 100 public void setImage(PDFImage image) 101 { 102 List l = element.getAnnotations(); 103 for (int i=0;i<l.size();i++) { 104 org.faceless.pdf2.WidgetAnnotation annot = element.getAnnotation(i); 105 annot.setButtonImage(image==null ? null : image.image); 106 } 107 } 108 109 123 public void setValue(String label) 124 { 125 List l = element.getAnnotations(); 126 for (int i=0;i<l.size();i++) { 127 org.faceless.pdf2.WidgetAnnotation annot = element.getAnnotation(i); 128 annot.setValue(label); 129 } 130 } 131 132 137 public String getValue() 138 { 139 if (element.getAnnotations().size()>0) { 140 org.faceless.pdf2.WidgetAnnotation annot = element.getAnnotation(0); 141 return annot.getValue(); 142 } else { 143 return null; 144 } 145 } 146 147 155 public void setAction(PDFAction action) 156 { 157 List l = element.getAnnotations(); 158 for (int i=0;i<l.size();i++) { 159 org.faceless.pdf2.WidgetAnnotation annot = element.getAnnotation(i); 160 annot.setAction(org.faceless.pdf2.Event.CLICK, action==null ? null : action.action); 161 } 162 } 163 164 172 public PDFAction getAction() 173 { 174 if (element.getAnnotations().size()>0) { 175 org.faceless.pdf2.WidgetAnnotation annot = element.getAnnotation(0); 176 return (PDFAction)PeeredObject.getPeer(annot.getAction(org.faceless.pdf2.Event.CLICK)); 177 } else { 178 return null; 179 } 180 } 181 } 182 | Popular Tags |