Просмотр исходного кода

Added testing with different topCount (only saves res if 2)

Axel Nordh 5 лет назад
Родитель
Сommit
ef8bfc9401
2 измененных файлов с 25 добавлено и 10 удалено
  1. 6 4
      ATG/src/controllers/TestingTabController.java
  2. 19 6
      ATG/src/fxml/TestingTab.fxml

+ 6 - 4
ATG/src/controllers/TestingTabController.java

@@ -56,6 +56,8 @@ public class TestingTabController implements Initializable {
 	@FXML TextField divisorValueCustom;
 	@FXML TextField divisorValueCombined;
 
+	@FXML TextField topCountTextField;
+
 	@FXML TextField combineHorseWeight;
 	@FXML TextField combineDriverWeight;
 
@@ -133,7 +135,7 @@ public class TestingTabController implements Initializable {
 	@FXML
 	public void CalculateAction() {
 		ReadTestData();
-		getPercentagesOrderedBy(2);
+		getPercentagesOrderedBy(Integer.valueOf(topCountTextField.getText()));
 	}
 
 	private void ReadTestData() {
@@ -330,10 +332,10 @@ public class TestingTabController implements Initializable {
 
 		final DatabaseContoller database = DatabaseContoller.getInstance();
 		final String oldSetting = database.getSetting(settingTextField.getId() + "Value");
-		if (!Strings.isNullOrEmpty(oldSetting) && Float.valueOf(oldSetting) < newValue) {
+		if (!Strings.isNullOrEmpty(oldSetting) && Float.valueOf(oldSetting) < newValue && Integer.valueOf(topCountTextField.getText()) == 2) {
 			database.setSetting(settingTextField.getId() + "Value", String.valueOf(newValue));
 			database.setSetting(settingTextField.getId(), settingTextField.getText());
-		} else if (Strings.isNullOrEmpty(oldSetting)) {
+		} else if (Strings.isNullOrEmpty(oldSetting) && Integer.valueOf(topCountTextField.getText()) == 2) {
 			database.setSetting(settingTextField.getId() + "Value", String.valueOf(newValue));
 			database.setSetting(settingTextField.getId(), settingTextField.getText());
 		}
@@ -357,7 +359,7 @@ public class TestingTabController implements Initializable {
 		currentRaces.sort(sorter);
 
 		for (int p = 0; p < topCount; p++) {
-			if (currentRaces.get(p).getResult() == 1) {
+			if (currentRaces.size() > p && currentRaces.get(p).getResult() == 1) {
 				correct++;
 				break;
 			}

+ 19 - 6
ATG/src/fxml/TestingTab.fxml

@@ -24,6 +24,8 @@
                     </columnConstraints>
                     <rowConstraints>
                         <RowConstraints maxHeight="50.0" minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES" />
+                        <RowConstraints maxHeight="50.0" minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES" />
+                        <RowConstraints maxHeight="50.0" minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES" />
                       <RowConstraints maxHeight="131.0" minHeight="30.0" prefHeight="120.0" vgrow="SOMETIMES" />
                         <RowConstraints maxHeight="49.0" minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                       <RowConstraints maxHeight="49.0" minHeight="0.0" prefHeight="30.0" vgrow="SOMETIMES" />
@@ -31,7 +33,7 @@
                         <RowConstraints maxHeight="45.0" minHeight="30.0" prefHeight="37.0" vgrow="SOMETIMES" />
                     </rowConstraints>
                      <children>
-                        <FlowPane orientation="VERTICAL" GridPane.rowIndex="1">
+                        <FlowPane orientation="VERTICAL" GridPane.rowIndex="3">
                            <children>
                               <Label prefHeight="20.0" text="Lanewin Divisor Horse Avg" />
                               <Label prefHeight="20.0" text="Lanewin Divisor Horse Distance" />
@@ -41,7 +43,7 @@
                               <Label prefHeight="20.0" text="Lanewin Divisor Combined" />
                            </children>
                         </FlowPane>
-                        <FlowPane orientation="VERTICAL" GridPane.columnIndex="1" GridPane.rowIndex="1">
+                        <FlowPane orientation="VERTICAL" GridPane.columnIndex="1" GridPane.rowIndex="3">
                            <children>
                               <TextField fx:id="divisorValueHorse" minHeight="20.0" prefHeight="20.0" prefWidth="103.0" promptText="1" text="1" />
                               <TextField fx:id="divisorValueHorseDistance" minHeight="20.0" prefHeight="20.0" prefWidth="103.0" promptText="1" text="1" />
@@ -51,28 +53,35 @@
                               <TextField fx:id="divisorValueCombined" minHeight="20.0" prefHeight="20.0" prefWidth="103.0" promptText="1" text="1" />
                            </children>
                         </FlowPane>
-                        <FlowPane orientation="VERTICAL" prefHeight="200.0" prefWidth="200.0" GridPane.rowIndex="3">
+                        <FlowPane orientation="VERTICAL" prefHeight="200.0" prefWidth="200.0" GridPane.rowIndex="5">
                            <children>
                               <Label text="Combine Horse Weight" />
                               <Label text="Combine Driver Weight" />
                            </children>
                         </FlowPane>
-                        <FlowPane orientation="VERTICAL" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.rowIndex="3">
+                        <FlowPane orientation="VERTICAL" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.rowIndex="5">
                            <children>
                               <TextField fx:id="combineHorseWeight" minHeight="20.0" prefHeight="20.0" prefWidth="103.0" promptText="1" text="1" />
                               <TextField fx:id="combineDriverWeight" minHeight="20.0" prefHeight="20.0" prefWidth="103.0" promptText="1" text="1" />
                            </children>
                         </FlowPane>
-                        <Label alignment="CENTER" prefHeight="45.0" prefWidth="466.0" text="Combine sorter" GridPane.columnSpan="2147483647" GridPane.rowIndex="2" GridPane.vgrow="ALWAYS">
+                        <Label alignment="CENTER" prefHeight="45.0" prefWidth="466.0" text="Combine sorter" GridPane.columnSpan="2147483647" GridPane.rowIndex="4" GridPane.vgrow="ALWAYS">
                            <font>
                               <Font size="26.0" />
                            </font>
                         </Label>
-                        <Label alignment="CENTER" text="Lane divisor settings" GridPane.columnSpan="2" GridPane.halignment="CENTER" GridPane.hgrow="ALWAYS" GridPane.valignment="CENTER" GridPane.vgrow="ALWAYS">
+                        <Label alignment="CENTER" text="Lane divisor settings" GridPane.columnSpan="2" GridPane.halignment="CENTER" GridPane.hgrow="ALWAYS" GridPane.rowIndex="2" GridPane.valignment="CENTER" GridPane.vgrow="ALWAYS">
+                           <font>
+                              <Font size="27.0" />
+                           </font>
+                        </Label>
+                        <Label alignment="CENTER" text="General Settings" GridPane.columnSpan="2">
                            <font>
                               <Font size="27.0" />
                            </font>
                         </Label>
+                        <Label prefHeight="20.0" text="Top to Count" GridPane.rowIndex="1" />
+                        <TextField fx:id="topCountTextField" minHeight="20.0" prefHeight="20.0" prefWidth="103.0" promptText="2" text="2" GridPane.columnIndex="1" GridPane.rowIndex="1" />
                      </children>
                   </GridPane>
                </center>
@@ -99,6 +108,10 @@
                   <RowConstraints minHeight="10.0" prefHeight="30.0" valignment="CENTER" vgrow="SOMETIMES" />
                   <RowConstraints minHeight="10.0" prefHeight="30.0" valignment="CENTER" vgrow="SOMETIMES" />
                   <RowConstraints minHeight="10.0" prefHeight="30.0" valignment="CENTER" vgrow="SOMETIMES" />
+                  <RowConstraints minHeight="10.0" prefHeight="30.0" valignment="CENTER" vgrow="SOMETIMES" />
+                  <RowConstraints minHeight="10.0" prefHeight="30.0" valignment="CENTER" vgrow="SOMETIMES" />
+                  <RowConstraints minHeight="10.0" prefHeight="30.0" valignment="CENTER" vgrow="SOMETIMES" />
+                  <RowConstraints minHeight="10.0" prefHeight="30.0" valignment="CENTER" vgrow="SOMETIMES" />
               </rowConstraints>
                <children>
                   <Label fx:id="horseAvgTimePercentText" alignment="CENTER" style="-fx-text-fill: BLACK;" text="HorseAvgTime" GridPane.halignment="CENTER" GridPane.valignment="CENTER" />