diff --git a/voting-booth-gui/build.gradle b/voting-booth-gui/build.gradle index c3ede95..843f9d3 100644 --- a/voting-booth-gui/build.gradle +++ b/voting-booth-gui/build.gradle @@ -59,6 +59,9 @@ dependencies { // Json configuraiton parsing compile name: 'java-json' + // Jar that creates barcodes + compile name: 'barbecue-1.5-beta1' + testCompile 'junit:junit:4.+' runtime 'org.codehaus.groovy:groovy:2.4.+' diff --git a/voting-booth-gui/src/main/java/meerkat/voting/gui/managment/VotersBallot.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/managment/VotersBallot.java index ec5e207..ecc8d44 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/managment/VotersBallot.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/managment/VotersBallot.java @@ -13,7 +13,12 @@ import java.util.List; * 3. the ByteString (that contains bytes of image) of the person the voter selected */ public class VotersBallot { - public List Votershannel; + public List VoterChannel; public String VotersNameSelection; public ByteString VotersImageSelection; + + public String toString(){ + return this.VotersNameSelection +"---"+ this.VoterChannel.get(0) + "" + this.VoterChannel.get(1) + + this.VoterChannel.get(2) + "" + this.VoterChannel.get(3); + } } diff --git a/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/ballot_summary/VotersChoicesAdder.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/ballot_summary/VotersChoicesAdder.java index 05be003..112388a 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/ballot_summary/VotersChoicesAdder.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/ballot_summary/VotersChoicesAdder.java @@ -39,7 +39,7 @@ public class VotersChoicesAdder { */ public void ShowVotersChoices() throws IOException { this.RemoveAllAnswers(); - this.addAnswer(this.getChannelChoice(this.votersBallot.Votershannel)); + this.addAnswer(this.getChannelChoice(this.votersBallot.VoterChannel)); this.addAnswer(this.getNameChoice(this.votersBallot.VotersNameSelection)); this.addAnswer(this.getImageChoice(this.votersBallot.VotersImageSelection)); Label error = new Label(); diff --git a/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/straight_channel_section/StraightChannelSectionController.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/straight_channel_section/StraightChannelSectionController.java index 22bb1eb..143edb8 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/straight_channel_section/StraightChannelSectionController.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/straight_channel_section/StraightChannelSectionController.java @@ -45,7 +45,7 @@ public class StraightChannelSectionController extends TwoWayNode { * Updates the channel in the voters choise */ private void UpdateVotersChoise(){ - this.votersBallot.Votershannel = this.chanelValue; + this.votersBallot.VoterChannel = this.chanelValue; } /** diff --git a/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/vote_have_been_cast/VoteHaveBeenCastController.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/vote_have_been_cast/VoteHaveBeenCastController.java index a01ee73..0c40406 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/vote_have_been_cast/VoteHaveBeenCastController.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/vote_have_been_cast/VoteHaveBeenCastController.java @@ -3,6 +3,16 @@ package meerkat.voting.gui.panels.vote_have_been_cast; import javafx.fxml.FXML; import javafx.scene.input.MouseEvent; import meerkat.voting.gui.managment.TwoWayNode; +import net.sourceforge.barbecue.Barcode; +import net.sourceforge.barbecue.BarcodeException; +import net.sourceforge.barbecue.BarcodeFactory; +import net.sourceforge.barbecue.BarcodeImageHandler; +import net.sourceforge.barbecue.output.OutputException; + +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; /** * Created by Vladimir Eliezer Tokarev on 8/27/2016. @@ -10,8 +20,20 @@ import meerkat.voting.gui.managment.TwoWayNode; */ public class VoteHaveBeenCastController extends TwoWayNode { + /** + * This method prints the whole VotersBalliot into barcode + */ + private void createBarCode() throws BarcodeException, OutputException, IOException { + Barcode barcode = BarcodeFactory.createCode128(this.votersBallot.toString()); + barcode.setFont(null); + BufferedImage image = BarcodeImageHandler.getImage(barcode); + File outputfile = new File("VotersBallot.png"); + ImageIO.write(image, "png", outputfile); + } + @FXML - private void backToWelcomeSplash(MouseEvent mousePress){ + private void backToWelcomeSplash(MouseEvent mousePress) throws BarcodeException, OutputException, IOException { + this.createBarCode(); this.currentStage.close(); this.currentStage.setScene(this.previous.GetCurrentScene()); this.previous.UpdateNode(); diff --git a/voting-booth-gui/src/main/resources/jars/barbecue-1.5-beta1.jar b/voting-booth-gui/src/main/resources/jars/barbecue-1.5-beta1.jar new file mode 100644 index 0000000..a8fe1e3 Binary files /dev/null and b/voting-booth-gui/src/main/resources/jars/barbecue-1.5-beta1.jar differ