1 3 package org.faceless.pdf; 4 5 import java.io.*; 6 import java.util.*; 7 import java.awt.Color ; 8 import org.faceless.util.OrderedMap; 9 10 37 public final class FormRadioButton extends FormElement 38 { 39 FormRadioButton(org.faceless.pdf2.FormRadioButton b) 40 { 41 super(b); 42 } 43 44 49 public FormRadioButton() 50 { 51 super(new org.faceless.pdf2.FormRadioButton()); 52 } 53 54 65 public PDFAnnotation setButton(String value, PDFPage page, float x1, float y1, float x2, float y2) 66 { 67 return (PDFAnnotation)PeeredObject.getPeer(((org.faceless.pdf2.FormRadioButton)element).addAnnotation(value, page==null ? null : page.page, x1, y1, x2, y2)); 68 } 69 70 100 public void setStyle(int style, Color centercolor, PDFStyle background) 101 { 102 char newstyle = org.faceless.pdf2.PDFStyle.FORMRADIOBUTTONSTYLE_CIRCLE; 103 104 org.faceless.pdf2.PDFStyle backstyle = (background==null ? null : background.style); 105 org.faceless.pdf2.PDFStyle textstyle = new org.faceless.pdf2.PDFStyle(); 106 textstyle.setFillColor(centercolor==null ? backstyle==null ? Color.black : backstyle.getLineColor() : centercolor); 107 textstyle.setFormRadioButtonStyle(newstyle); 108 textstyle.setFont(new org.faceless.pdf2.StandardFont(org.faceless.pdf2.StandardFont.ZAPFDINGBATS), 0); 109 110 for (int i=0;i<element.getAnnotations().size();i++) { 111 org.faceless.pdf2.WidgetAnnotation annot = element.getAnnotation(i); 112 annot.setTextStyle(textstyle); 113 annot.setBackgroundStyle(backstyle); 114 } 115 } 116 117 127 public Map getOptions() 128 { 129 Map m = new OrderedMap(); 130 List l = element.getAnnotations(); 131 for (int i=0;i<l.size();i++) { 132 org.faceless.pdf2.WidgetAnnotation annot = element.getAnnotation(i); 133 m.put(annot.getValue(), PeeredObject.getPeer(annot)); 134 } 135 return Collections.unmodifiableMap(m); 136 } 137 138 145 public void setValue(String value) 146 { 147 ((org.faceless.pdf2.FormRadioButton)element).setValue(value); 148 } 149 150 155 public String getValue() 156 { 157 return ((org.faceless.pdf2.FormRadioButton)element).getValue(); 158 } 159 160 167 public void setDefaultValue(boolean value) 168 { 169 String v = value ? element.getAnnotation(0).getValue() : null; 170 ((org.faceless.pdf2.FormRadioButton)element).setDefaultValue(v); 171 } 172 173 178 public String getDefaultValue() 179 { 180 return ((org.faceless.pdf2.FormRadioButton)element).getDefaultValue(); 181 } 182 } 183 | Popular Tags |