fix NullPointerException when calling votersBallot.toString and add showBallot (new window)

android-scanner
Laura Radaelli 2016-12-08 12:11:04 +02:00
parent 0509bf6dda
commit 71076f5c7e
3 changed files with 17 additions and 0 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 954 B

After

Width:  |  Height:  |  Size: 973 B

View File

@ -50,6 +50,7 @@ public class StraightChannelSectionController extends TwoWayNode {
this.logger.debug("Created and filled with zeros the channel value.");
this.updateVisualChanel();
this.UpdateVotersChoise();
}
/**

View File

@ -15,6 +15,10 @@ import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import java.awt.image.BufferedImage;
/**
* Created by Vladimir Eliezer Tokarev on 8/27/2016.
@ -33,6 +37,7 @@ public class VoteHaveBeenCastController extends TwoWayNode {
BufferedImage image = BarcodeImageHandler.getImage(barcode);
File outputfile = new File("VotersBallot.png");
ImageIO.write(image, "png", outputfile);
showBallot("VotersBallot.png");
this.logger.debug("Created the bar code with voters choises at VotersBallot.png.");
}
@ -50,4 +55,15 @@ public class VoteHaveBeenCastController extends TwoWayNode {
public void UpdateNode() {
// This panel doesn't have any questions representations that why there is nothing ti show here
}
private void showBallot(String filename) throws IOException {
final JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// bi = ImageIO.read(ImageResourceDemo.class.getResource("../resource/avatar6.jpeg"));
BufferedImage bi = ImageIO.read(new File(filename));
frame.add(new JLabel(new ImageIcon(bi)));
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}