Added the selection of the channel

android-scanner
VladimirEliTokarev 2016-10-03 21:15:44 +03:00
parent 6e47a4df98
commit 80a032d373
3 changed files with 72 additions and 17 deletions

View File

@ -119,7 +119,6 @@ class StringsAnswersUpdater implements javafx.event.EventHandler{
if (target.isSelected()) {
String answer = target.getId().split("-")[0];
this.answer = answer;
System.out.println(answer);
this.uncheckBoxes(target);
}
}

View File

@ -1,14 +1,22 @@
package meerkat.voting.gui.straight_channel_section;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.input.MouseEvent;
import meerkat.voting.gui.TwoWayNode;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Vladimir Eliezer Tokarev on 8/27/2016.
* StraightChannelSectionController handle the behavior of select channel section screen
*/
public class StraightChannelSectionController extends TwoWayNode {
private List<Integer> chanelValue;
private int pointer;
private boolean lock;
@FXML
private void ProceedToNameSelection(MouseEvent boutonPressed) {
@ -19,7 +27,55 @@ public class StraightChannelSectionController extends TwoWayNode {
}
@Override
/**
* Creates the array of the canel value
*/
public void UpdateNode() {
// Does it suppose to show the channel ?
this.pointer = 0;
this.lock = false;
this.chanelValue = new ArrayList<>();
this.chanelValue.add(0);
this.chanelValue.add(0);
this.chanelValue.add(0);
this.chanelValue.add(0);
this.updateVisualChanel();
}
/**
* Updates the visual channel value
*/
private void updateVisualChanel(){
for (int i = 0 ; i < 4 ; i ++ ){
String id = "#textarea_"+i;
TextField textField = ((TextField)this.currentStage.getScene().lookup(id));
textField.setText(String.valueOf(this.chanelValue.get(i)));
}
}
@FXML
private void numberPressed(MouseEvent mousePressed){
if (!this.lock) {
String value = ((Button) mousePressed.getSource()).getId().split("_")[1];
this.chanelValue.set(this.pointer, Integer.parseInt(value));
this.pointer++;
this.updateVisualChanel();
if (this.pointer == 4) {
this.lock = true;
}
}
}
@FXML
private void clearLastNumber(MouseEvent mousePressed){
if (this.pointer >= 1) {
int lastValueLocation = this.pointer - 1;
this.chanelValue.set(lastValueLocation, 0);
this.currentStage.show();
this.pointer--;
this.updateVisualChanel();
this.lock = false;
}
}
}

View File

@ -118,7 +118,7 @@
<children>
<BorderPane prefHeight="67.0" prefWidth="46.0">
<center>
<TextField maxHeight="74.0" maxWidth="74.0" minHeight="54.0" minWidth="58.0" prefHeight="69.0" prefWidth="69.0" text="1" BorderPane.alignment="CENTER">
<TextField fx:id="textarea_0" maxHeight="74.0" maxWidth="74.0" minHeight="54.0" minWidth="58.0" prefHeight="69.0" prefWidth="69.0" text="1" BorderPane.alignment="CENTER">
<font>
<Font size="30.0" />
</font>
@ -127,7 +127,7 @@
</BorderPane>
<BorderPane prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1">
<center>
<TextField maxHeight="74.0" maxWidth="74.0" minHeight="54.0" minWidth="58.0" prefHeight="69.0" prefWidth="69.0" text="6" BorderPane.alignment="CENTER">
<TextField fx:id="textarea_1" maxHeight="74.0" maxWidth="74.0" minHeight="54.0" minWidth="58.0" prefHeight="69.0" prefWidth="69.0" text="6" BorderPane.alignment="CENTER">
<font>
<Font size="30.0" />
</font>
@ -136,7 +136,7 @@
</BorderPane>
<BorderPane prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="2">
<center>
<TextField maxHeight="74.0" maxWidth="74.0" minHeight="54.0" minWidth="58.0" prefHeight="54.0" prefWidth="69.0" text="8" BorderPane.alignment="CENTER">
<TextField fx:id="textarea_2" maxHeight="74.0" maxWidth="74.0" minHeight="54.0" minWidth="58.0" prefHeight="54.0" prefWidth="69.0" text="8" BorderPane.alignment="CENTER">
<font>
<Font size="30.0" />
</font>
@ -145,7 +145,7 @@
</BorderPane>
<BorderPane prefHeight="55.0" prefWidth="70.0" GridPane.columnIndex="3">
<center>
<TextField maxHeight="74.0" maxWidth="74.0" minHeight="54.0" minWidth="58.0" prefHeight="54.0" prefWidth="69.0" text="5" BorderPane.alignment="CENTER">
<TextField fx:id="textarea_3" maxHeight="74.0" maxWidth="74.0" minHeight="54.0" minWidth="58.0" prefHeight="54.0" prefWidth="69.0" text="5" BorderPane.alignment="CENTER">
<font>
<Font size="30.0" />
</font>
@ -167,7 +167,7 @@
<children>
<BorderPane prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1">
<center>
<Button mnemonicParsing="false" prefHeight="54.0" prefWidth="69.0" text="2" BorderPane.alignment="CENTER">
<Button fx:id="button_2" mnemonicParsing="false" onMousePressed="#numberPressed" prefHeight="54.0" prefWidth="69.0" text="2" BorderPane.alignment="CENTER">
<font>
<Font size="25.0" />
</font>
@ -177,7 +177,7 @@
<BorderPane prefHeight="200.0" prefWidth="200.0" />
<BorderPane prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="2">
<center>
<Button mnemonicParsing="false" prefHeight="54.0" prefWidth="69.0" text="3" BorderPane.alignment="CENTER">
<Button fx:id="button_3" mnemonicParsing="false" onMousePressed="#numberPressed" prefHeight="54.0" prefWidth="69.0" text="3" BorderPane.alignment="CENTER">
<font>
<Font size="25.0" />
</font>
@ -186,14 +186,14 @@
</BorderPane>
<BorderPane prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="3">
<center>
<Button mnemonicParsing="false" prefHeight="54.0" prefWidth="69.0" text="4" BorderPane.alignment="CENTER">
<Button fx:id="button_4" mnemonicParsing="false" onMousePressed="#numberPressed" prefHeight="54.0" prefWidth="69.0" text="4" BorderPane.alignment="CENTER">
<font>
<Font size="25.0" />
</font>
</Button>
</center>
</BorderPane>
<Button mnemonicParsing="false" prefHeight="54.0" prefWidth="69.0" text="1">
<Button fx:id="button_1" mnemonicParsing="false" onMousePressed="#numberPressed" prefHeight="54.0" prefWidth="69.0" text="1">
<font>
<Font size="25.0" />
</font>
@ -213,7 +213,7 @@
<children>
<BorderPane prefHeight="200.0" prefWidth="200.0">
<center>
<Button mnemonicParsing="false" prefHeight="54.0" prefWidth="69.0" text="5" BorderPane.alignment="CENTER">
<Button fx:id="button_5" mnemonicParsing="false" onMousePressed="#numberPressed" prefHeight="54.0" prefWidth="69.0" text="5" BorderPane.alignment="CENTER">
<font>
<Font size="25.0" />
</font>
@ -222,7 +222,7 @@
</BorderPane>
<BorderPane prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1">
<center>
<Button mnemonicParsing="false" prefHeight="54.0" prefWidth="69.0" text="6" BorderPane.alignment="CENTER">
<Button fx:id="button_6" mnemonicParsing="false" onMousePressed="#numberPressed" prefHeight="54.0" prefWidth="69.0" text="6" BorderPane.alignment="CENTER">
<font>
<Font size="25.0" />
</font>
@ -231,7 +231,7 @@
</BorderPane>
<BorderPane prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="2">
<center>
<Button mnemonicParsing="false" prefHeight="54.0" prefWidth="69.0" text="7" BorderPane.alignment="CENTER">
<Button fx:id="button_7" mnemonicParsing="false" onMousePressed="#numberPressed" prefHeight="54.0" prefWidth="69.0" text="7" BorderPane.alignment="CENTER">
<font>
<Font size="25.0" />
</font>
@ -240,7 +240,7 @@
</BorderPane>
<BorderPane prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="3">
<center>
<Button mnemonicParsing="false" prefHeight="54.0" prefWidth="69.0" text="8" BorderPane.alignment="CENTER">
<Button fx:id="button_8" mnemonicParsing="false" onMousePressed="#numberPressed" prefHeight="54.0" prefWidth="69.0" text="8" BorderPane.alignment="CENTER">
<font>
<Font size="25.0" />
</font>
@ -262,7 +262,7 @@
<BorderPane prefHeight="200.0" prefWidth="200.0" />
<BorderPane prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1">
<center>
<Button mnemonicParsing="false" prefHeight="54.0" prefWidth="69.0" text="0" BorderPane.alignment="CENTER">
<Button fx:id="button_0" mnemonicParsing="false" onMousePressed="#numberPressed" prefHeight="54.0" prefWidth="69.0" text="0" BorderPane.alignment="CENTER">
<font>
<Font size="25.0" />
</font>
@ -271,14 +271,14 @@
</BorderPane>
<BorderPane prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="2">
<right>
<Button mnemonicParsing="false" prefHeight="54.0" prefWidth="138.0" text="Clear Last" BorderPane.alignment="CENTER">
<Button fx:id="button_clear_last" mnemonicParsing="false" onMousePressed="#clearLastNumber" prefHeight="54.0" prefWidth="138.0" text="Clear Last" BorderPane.alignment="CENTER">
<font>
<Font size="24.0" />
</font>
</Button>
</right>
</BorderPane>
<Button mnemonicParsing="false" prefHeight="54.0" prefWidth="69.0" text="9">
<Button fx:id="button_9" mnemonicParsing="false" onMousePressed="#numberPressed" prefHeight="54.0" prefWidth="69.0" text="9">
<font>
<Font size="25.0" />
</font>