1 3 package org.faceless.pdf; 4 5 import java.io.*; 6 import java.util.*; 7 import java.awt.Color ; 8 9 40 public final class FormCheckbox extends FormElement 41 { 42 FormCheckbox(org.faceless.pdf2.FormCheckbox b) 43 { 44 super(b); 45 } 46 47 53 public FormCheckbox() 54 { 55 this(null,0,0,0,0); 56 } 57 58 66 public FormCheckbox(PDFPage page, float x1, float y1, float x2, float y2) 67 { 68 super(new org.faceless.pdf2.FormCheckbox(page==null ? null : page.page, x1, y1, x2, y2)); 69 } 70 71 101 public void setStyle(int style, Color centercolor, PDFStyle background) 102 { 103 char newstyle = org.faceless.pdf2.PDFStyle.FORMRADIOBUTTONSTYLE_CHECK; 104 105 org.faceless.pdf2.PDFStyle backstyle = (background==null ? null : background.style); 106 org.faceless.pdf2.PDFStyle textstyle = new org.faceless.pdf2.PDFStyle(); 107 textstyle.setFillColor(centercolor==null ? backstyle==null ? Color.black : backstyle.getLineColor() : centercolor); 108 textstyle.setFormCheckboxStyle(newstyle); 109 textstyle.setFont(new org.faceless.pdf2.StandardFont(org.faceless.pdf2.StandardFont.ZAPFDINGBATS), 0); 110 111 for (int i=0;i<element.getAnnotations().size();i++) { 112 org.faceless.pdf2.WidgetAnnotation annot = element.getAnnotation(i); 113 annot.setTextStyle(textstyle); 114 annot.setBackgroundStyle(backstyle); 115 } 116 } 117 118 123 public void setValue(boolean value) 124 { 125 String v = value ? element.getAnnotation(0).getValue() : null; 126 ((org.faceless.pdf2.FormCheckbox)element).setValue(v); 127 } 128 129 134 public boolean getValue() 135 { 136 String v = ((org.faceless.pdf2.FormCheckbox)element).getValue(); 137 return v!=null; 138 } 139 140 146 public void setDefaultValue(boolean value) 147 { 148 String v = value ? element.getAnnotation(0).getValue() : null; 149 ((org.faceless.pdf2.FormCheckbox)element).setDefaultValue(v); 150 } 151 152 157 public boolean getDefaultValue() 158 { 159 String v = ((org.faceless.pdf2.FormCheckbox)element).getDefaultValue(); 160 return v!=null; 161 } 162 } 163 | Popular Tags |