Appearance appearance = widget.getAppearance();
if(appearance == null)
{widget.setAppearance(appearance = new Appearance(document));}
AppearanceStates normalAppearance = appearance.getNormal();
FormXObject onState = new FormXObject(document);
normalAppearance.put(PdfName.Yes,onState);
//TODO:verify!!!
// appearance.getRollover().put(PdfName.Yes,onState);
// appearance.getDown().put(PdfName.Yes,onState);
// appearance.getRollover().put(PdfName.Off,offState);
// appearance.getDown().put(PdfName.Off,offState);
Rectangle2D widgetBox = widget.getBox();
Dimension2D size = new Dimension(widgetBox.getWidth(),widgetBox.getHeight());
Rectangle2D frame = new Rectangle2D.Double(0,0,size.getWidth(),size.getHeight());
{
onState.setSize(size);
PrimitiveComposer composer = new PrimitiveComposer(onState);
composer.beginLocalState();
composer.setFillColor(getBackColor());
composer.setStrokeColor(getForeColor());
composer.drawRectangle(frame);
composer.fillStroke();
composer.end();
BlockComposer blockComposer = new BlockComposer(composer);
blockComposer.begin(frame,AlignmentXEnum.Center,AlignmentYEnum.Middle);
composer.setFillColor(getForeColor());
composer.setFont(
new StandardType1Font(
document,
StandardType1Font.FamilyEnum.ZapfDingbats,
true,
false
),
(float)(size.getHeight() * 0.8)
);
blockComposer.showText(new String(new char[]{getCheckSymbol()}));
blockComposer.end();
composer.flush();
}
FormXObject offState = new FormXObject(document);
normalAppearance.put(PdfName.Off,offState);
{
offState.setSize(size);
PrimitiveComposer composer = new PrimitiveComposer(offState);