Created Succesefully whole config object
parent
ef1ff8dea1
commit
fe5a4d7be1
|
@ -23,7 +23,7 @@ message Question {
|
|||
|
||||
// Message object which contains the question and its type
|
||||
message UIQuestion{
|
||||
int32 Type = 1;
|
||||
int32 QuestionType = 1;
|
||||
|
||||
Question question = 2;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,16 @@
|
|||
package meerkat.voting.gui;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import javafx.application.Application;
|
||||
import javafx.stage.Stage;
|
||||
import meerkat.protobuf.BallotQuestionUIElementOuterClass;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBufferByte;
|
||||
import java.awt.image.WritableRaster;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -10,46 +19,64 @@ import javafx.stage.Stage;
|
|||
* Main calls to ChainBuilder which initilizes all the TwoWayNode's
|
||||
*/
|
||||
public class Main extends Application {
|
||||
public VotingBoothConfiguration GetConfig(){
|
||||
/** VotingBoothConfiguration config = new VotingBoothConfiguration();
|
||||
|
||||
/**
|
||||
* Converts the image from given path to bytes array
|
||||
* @param filepath the path to the wanted picture
|
||||
* @return byte array of the image
|
||||
* @throws IOException
|
||||
*/
|
||||
private byte[] GetData(String filepath) throws IOException {
|
||||
File imgPath = new File(filepath);
|
||||
BufferedImage bufferedImage = ImageIO.read(imgPath);
|
||||
|
||||
WritableRaster raster = bufferedImage .getRaster();
|
||||
DataBufferByte data = (DataBufferByte) raster.getDataBuffer();
|
||||
|
||||
return ( data.getData() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates configuration for example
|
||||
* @return VotingBoothConfiguration object
|
||||
* @throws IOException
|
||||
*/
|
||||
private VotingBoothConfiguration GetConfig() throws IOException {
|
||||
VotingBoothConfiguration config = new VotingBoothConfiguration();
|
||||
|
||||
config.NameSelectionQuestion = BallotQuestionUIElementOuterClass.BallotQuestionUIElement.newBuilder()
|
||||
.setQuestion(BallotQuestionUIElementOuterClass.UIQuestion.newBuilder()
|
||||
.setType(0)
|
||||
.setQuestionType(0)
|
||||
.setQuestion(BallotQuestionUIElementOuterClass.Question.newBuilder()
|
||||
.setQuestion(ByteString.copyFromUtf8("Who you vote for?"))
|
||||
.setType(0))
|
||||
.setAnswers(BallotQuestionUIElementOuterClass.UIAnswers.newBuilder()
|
||||
.setQuestion(ByteString.copyFromUtf8("Who you vote for?"))))
|
||||
.setAnswers(BallotQuestionUIElementOuterClass.UIAnswers.newBuilder()
|
||||
.setAnswersType(0)
|
||||
.setAnswers(BallotQuestionUIElementOuterClass.ListOfAnswers.newBuilder()
|
||||
.setAnswers(0, ByteString.copyFromUtf8("George Boosh"))
|
||||
.setAnswers(1, ByteString.copyFromUtf8("Antonio Banderas"))
|
||||
.setAnswers(2, ByteString.copyFromUtf8("Michal Jakson"))))
|
||||
.addAnswers(ByteString.copyFromUtf8("George Boosh"))
|
||||
.addAnswers(ByteString.copyFromUtf8("Antonio Banderas"))
|
||||
.addAnswers(ByteString.copyFromUtf8("Michal Jakson"))))
|
||||
.setRandomizeListOrder(true).build();
|
||||
|
||||
config.NameSelectionByPictureQuestion = BallotQuestionUIElementOuterClass.BallotQuestionUIElement.newBuilder()
|
||||
.setQuestion(BallotQuestionUIElementOuterClass.UIQuestion.newBuilder()
|
||||
.setType(2)
|
||||
.setQuestionType(0)
|
||||
.setQuestion(BallotQuestionUIElementOuterClass.Question.newBuilder()
|
||||
.mergeFrom()
|
||||
.setQuestion(ByteString.copyFromUtf8("Who you vote for?"))))
|
||||
.setAnswers(BallotQuestionUIElementOuterClass.UIAnswers.newBuilder()
|
||||
.setAnswersType(0)
|
||||
.setAnswersType(2)
|
||||
.setAnswers(BallotQuestionUIElementOuterClass.ListOfAnswers.newBuilder()
|
||||
.setAnswers(0, ByteString.copyFromUtf8("George Boosh"))
|
||||
.setAnswers(1, ByteString.copyFromUtf8("Antonio Banderas"))
|
||||
.setAnswers(2, ByteString.copyFromUtf8("Michal Jakson"))))
|
||||
.addAnswers(ByteString.copyFrom(GetData("F:\\vova\\meerkat\\meerkat-java\\voting-booth-gui\\src\\main\\resources\\images\\GeorgeBush.png")))
|
||||
.addAnswers(ByteString.copyFrom(GetData("F:\\vova\\meerkat\\meerkat-java\\voting-booth-gui\\src\\main\\resources\\images\\MichaelJackson.png")))
|
||||
.addAnswers(ByteString.copyFrom(GetData("F:\\vova\\meerkat\\meerkat-java\\voting-booth-gui\\src\\main\\resources\\images\\AntonioBanderass.jpg")))))
|
||||
.setRandomizeListOrder(true).build();
|
||||
.
|
||||
|
||||
**/
|
||||
return null;
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception
|
||||
{
|
||||
VotingBoothConfiguration config = GetConfig();
|
||||
ChainBuilder.Build(primaryStage, config);
|
||||
ChainBuilder.Build(primaryStage, GetConfig());
|
||||
primaryStage.setTitle("Meerkat Polling Station");
|
||||
primaryStage.show();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue