software.authoring
Class FormMaker

java.lang.Object
  extended by software.authoring.FormMaker
Direct Known Subclasses:
FormMaker

public class FormMaker
extends java.lang.Object

It generates a pdf form as a blank ballot. The form contains all the javascript logic and is created from the geometry, the Election Spec and a pdf background

Author:
stefan

Constructor Summary
FormMaker(org.gwu.voting.standardFormat.electionSpecification.ElectionSpecification es, BallotGeometry geom)
          creates the javascript to put in the pdf from the ElectionSpec and from jsFunctions.js .
 
Method Summary
static int getFontSize(float w, float h, java.lang.String zero, com.lowagie.text.pdf.BaseFont font)
          increases the size from 0 to until the string does not fit in a rectangle (width,heigth).
static int getFontSize(com.lowagie.text.Rectangle rect, com.lowagie.text.pdf.BaseFont font)
           
static int getFontSize(com.lowagie.text.Rectangle rect, java.lang.String zero, com.lowagie.text.pdf.BaseFont font)
          increases the size from 0 to until the string does not fit in the rectangle It returns three quarters from this maximum size.
 java.lang.String getJsFunctions()
           
 java.lang.String getJsInitValues()
           
 org.gwu.voting.standardFormat.basic.Question[] getQs()
           
static void main(java.lang.String[] args)
          debug method
 void make(java.lang.String background, java.lang.String outFile)
          creates a pdf from representing a ballot, with the only thing missing being the letters.
 com.lowagie.text.pdf.PdfFormField makeButtonAlignmentMark(com.lowagie.text.Rectangle possition, java.lang.String name)
           
 com.lowagie.text.pdf.PdfFormField makeButtonFinishVoting(com.lowagie.text.Rectangle possition, java.lang.String name, java.lang.String text)
           
 com.lowagie.text.pdf.PdfFormField makeButtonHighlightCandidate(com.lowagie.text.Rectangle possition, java.lang.String name)
           
 com.lowagie.text.pdf.PdfFormField makeButtonOrangeBoth(com.lowagie.text.Rectangle possition, java.lang.String name)
           
 com.lowagie.text.pdf.PdfFormField makeButtonOrangeBottom(com.lowagie.text.Rectangle possition, java.lang.String name)
           
 com.lowagie.text.pdf.PdfFormField makeButtonOrangeTop(com.lowagie.text.Rectangle possition, java.lang.String name)
           
 com.lowagie.text.pdf.PdfFormField makeButtonTopHoles(com.lowagie.text.Rectangle possition, java.lang.String name)
           
 com.lowagie.text.pdf.PdfFormField makeButtonVoteBottom(com.lowagie.text.Rectangle possition, java.lang.String name)
           
 com.lowagie.text.pdf.PdfFormField makeButtonVoteTop(com.lowagie.text.Rectangle possition, java.lang.String name)
           
 com.lowagie.text.pdf.PdfFormField makeText(com.lowagie.text.Rectangle possition, java.lang.String name, com.lowagie.text.pdf.BaseFont font, int fontSize)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FormMaker

public FormMaker(org.gwu.voting.standardFormat.electionSpecification.ElectionSpecification es,
                 BallotGeometry geom)
          throws java.io.IOException,
                 com.lowagie.text.DocumentException
creates the javascript to put in the pdf from the ElectionSpec and from jsFunctions.js . This file must be next to this class (the path is relative)

Parameters:
es - - the Election Specification
geom - - the geometry of the ballot (coresponding to the Election Spec)
Throws:
java.lang.Exception - - no Exception is caugth and no Exception is Explicitly thrown
java.io.IOException
com.lowagie.text.DocumentException
Method Detail

make

public void make(java.lang.String background,
                 java.lang.String outFile)
          throws com.lowagie.text.DocumentException,
                 java.io.IOException
creates a pdf from representing a ballot, with the only thing missing being the letters. All the fonts are embeded, the pdf is compressed. Version 1.3 of the pdf is used. To properly view the pdf Adobe Reader or Adobe Acrobat must be used. Other viewers will not display it properly (do not imperpret javascript correctly)

Parameters:
background - - the background to be used. If null or there is an error reading the background, a white background is used
outFile - - where the form is produced
Throws:
java.lang.Exception - - no Exception is caugth and no Exception is Explicitly thrown
com.lowagie.text.DocumentException
java.io.IOException

makeText

public com.lowagie.text.pdf.PdfFormField makeText(com.lowagie.text.Rectangle possition,
                                                  java.lang.String name,
                                                  com.lowagie.text.pdf.BaseFont font,
                                                  int fontSize)
Parameters:
possition - - the possition for the created pdf field
name - - the name of the field (used when filling it in)
font - - the font used when filling in the form
fontSize - - the size of the font
Returns:
- a PdfFormField of type text, read-only, centered, and printable

makeButtonOrangeTop

public com.lowagie.text.pdf.PdfFormField makeButtonOrangeTop(com.lowagie.text.Rectangle possition,
                                                             java.lang.String name)
Parameters:
possition - - where the pdf field should be placed
name - - the name of the pdf field
Returns:
- a pdf button with a black donut on it (as it would appear when a voter choses the top page) The donut is as big as the given rectangle and the hole as half the diameter

makeButtonOrangeBottom

public com.lowagie.text.pdf.PdfFormField makeButtonOrangeBottom(com.lowagie.text.Rectangle possition,
                                                                java.lang.String name)
Parameters:
possition - - where the pdf filed should be placed
name - - the name of the pdf field
Returns:
- a pdf button with a black bullet on it (as it would appear when a voter choses the bottom page) The bullet is as big as the side of the given rectangle

makeButtonHighlightCandidate

public com.lowagie.text.pdf.PdfFormField makeButtonHighlightCandidate(com.lowagie.text.Rectangle possition,
                                                                      java.lang.String name)
Parameters:
possition - - where the pdf filed should be placed
name - - the name of the pdf field
Returns:
- a pdf button that gets highlighed when rolled over

makeButtonOrangeBoth

public com.lowagie.text.pdf.PdfFormField makeButtonOrangeBoth(com.lowagie.text.Rectangle possition,
                                                              java.lang.String name)
Parameters:
possition - - where the pdf filed should be placed
name - - the name of the pdf field
Returns:
- a pdf button with a black bullet on it (as it would appear when a voter marks) The button is black and 0.75 transparent.

makeButtonTopHoles

public com.lowagie.text.pdf.PdfFormField makeButtonTopHoles(com.lowagie.text.Rectangle possition,
                                                            java.lang.String name)
Parameters:
possition - - where the pdf filed should be placed
name - - the name of the pdf field
Returns:
- a pdf form with a dashed circle, to mark where the holes are on the top page

makeButtonAlignmentMark

public com.lowagie.text.pdf.PdfFormField makeButtonAlignmentMark(com.lowagie.text.Rectangle possition,
                                                                 java.lang.String name)
Parameters:
possition - - where the pdf filed should be placed
name - - the name of the pdf field
Returns:
- a pdf button with a black circle on it (used for alignment)

makeButtonFinishVoting

public com.lowagie.text.pdf.PdfFormField makeButtonFinishVoting(com.lowagie.text.Rectangle possition,
                                                                java.lang.String name,
                                                                java.lang.String text)
Parameters:
possition - - where the pdf filed should be placed
name - - the name of the pdf field
text - - the text that appears on the button
Returns:
- a pdf button pressed when the voter finished his selection

makeButtonVoteTop

public com.lowagie.text.pdf.PdfFormField makeButtonVoteTop(com.lowagie.text.Rectangle possition,
                                                           java.lang.String name)
Parameters:
possition - - where the pdf filed should be placed
name - - the name of the pdf field
Returns:
- a pdf button coresponding to where the candidate name and symbol should be When pressed, the coresponding letter on the bottom gets selected

makeButtonVoteBottom

public com.lowagie.text.pdf.PdfFormField makeButtonVoteBottom(com.lowagie.text.Rectangle possition,
                                                              java.lang.String name)
Parameters:
possition - - where the pdf filed should be placed
name - - the name of the pdf field
Returns:
- a pdf button coresponding to where the letter on the bottom page is When pressed, the a black circle covers the letter on the bottom page

getJsFunctions

public java.lang.String getJsFunctions()
Returns:
the js code from jsFunctions.js (same for all elections)

getJsInitValues

public java.lang.String getJsInitValues()
Returns:
the js code particular to an election (from the Election Spec)

getQs

public org.gwu.voting.standardFormat.basic.Question[] getQs()
Returns:
- the ordered questions from the Election Spec

getFontSize

public static int getFontSize(com.lowagie.text.Rectangle rect,
                              com.lowagie.text.pdf.BaseFont font)
Returns:
getFontSize(rect, "0", font)

getFontSize

public static int getFontSize(com.lowagie.text.Rectangle rect,
                              java.lang.String zero,
                              com.lowagie.text.pdf.BaseFont font)
increases the size from 0 to until the string does not fit in the rectangle It returns three quarters from this maximum size.

Parameters:
rect - - the bounding rectangle
zero - - the caracter that has to fit in the rectangle
font - - the font the character is in
Returns:
- a int representing the three quarters of the size the string has to be in such that when writen in font "font" it fits in the bounding rectangle

getFontSize

public static int getFontSize(float w,
                              float h,
                              java.lang.String zero,
                              com.lowagie.text.pdf.BaseFont font)
increases the size from 0 to until the string does not fit in a rectangle (width,heigth). It returns three quarters from this maximum size.

Parameters:
w - - the width of thebounding rectangle
h - - the heigth of the bounding rectangle
zero - - the caracter that has to fit in the rectangle
font - - the font the character is in
Returns:
- a int representing the three quarters of the size the string has to be in such that when writen in font "font" it fits in the bounding rectangle

main

public static void main(java.lang.String[] args)
                 throws org.gwu.voting.standardFormat.electionSpecification.exceptions.ESException,
                        org.xml.sax.SAXException,
                        java.io.IOException,
                        com.lowagie.text.DocumentException
debug method

Parameters:
args -
Throws:
org.gwu.voting.standardFormat.electionSpecification.exceptions.ESException
org.xml.sax.SAXException
java.io.IOException
com.lowagie.text.DocumentException