Kaynağa Gözat

Uppdaterings push

Axel Nordh 4 yıl önce
ebeveyn
işleme
369c75dd26

+ 2 - 2
ATG/pom.xml

@@ -38,13 +38,13 @@
 	<dependency>
     	<groupId>mysql</groupId>
     	<artifactId>mysql-connector-java</artifactId>
-    	<version>8.0.23</version>
+    	<version>8.0.28</version>
 	</dependency>
 
 	<dependency>
     	<groupId>org.apache.commons</groupId>
     	<artifactId>commons-csv</artifactId>
-    	<version>1.8</version>
+    	<version>1.9.0</version>
 	</dependency>
 	
 	

+ 168 - 182
ATG/src/controllers/DatabaseController.java

@@ -40,7 +40,8 @@ public class DatabaseController {
     private static final String password = "CvWKY34DqtlVgjt_9";
     private static final String database = "atg";
     private static final String url = "jdbc:mysql://nordh.xyz:3306/";
-    private static final String timezoneFix = "?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC";
+    private static final String timezoneFix
+            = "?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC";
 
     private Connection conn;
 
@@ -63,9 +64,9 @@ public class DatabaseController {
         return conn;
     }
 
-    public void insertResult(String trackShortCode, String date, int raceNumber, int lane, int distance, int result,
-            float time, String timeModifier, int shoes, int sulky, String driver, String trainer, String horseName,
-            int travsportIdHorse, int travsportIdTrainer, int travsportIdDriver, String raceType, int raceId) {
+    public void insertResult(String trackShortCode, String date, int raceNumber, int lane, int distance, int result, float time,
+            String timeModifier, int shoes, int sulky, String driver, String trainer, String horseName, int travsportIdHorse,
+            int travsportIdTrainer, int travsportIdDriver, String raceType, int raceId) {
         final String sql;
         final boolean raceToday = date.equals(MainController.DATE_FORMAT.format(new Date()));
         horseName = horseName.replaceAll("[^a-zåäöA-ZÅÄÖ0-9 ()\\.']", "");
@@ -110,7 +111,7 @@ public class DatabaseController {
                 stat.setInt(12, trainerId);
             }
             stat.setInt(13, horseId);
-            stat.setInt(14, result < 0?raceId:-1);
+            stat.setInt(14, result < 0 ? raceId : -1);
 
             if (raceToday) {
                 stat.setString(15, raceType);
@@ -127,8 +128,9 @@ public class DatabaseController {
             stat.executeUpdate();
 
         } catch (final SQLException e) {
-            System.out.println("Failing sql " + sql + "[ " + trackId + ", " + date + ", " + raceNumber + ", " + lane + ", " + distance + ", " + result
-                    + ", " + time + ", " + timeModifier + ", " + shoes + "," + sulky + ", " + driverId + ", " + trainerId + ", " + horseId + ", " + raceId +"]");
+            System.out.println("Failing sql " + sql + "[ " + trackId + ", " + date + ", " + raceNumber + ", " + lane + ", "
+                    + distance + ", " + result + ", " + time + ", " + timeModifier + ", " + shoes + "," + sulky + ", " + driverId
+                    + ", " + trainerId + ", " + horseId + ", " + raceId + "]");
             throw new RuntimeException(e.getMessage(), e);
         }
     }
@@ -138,8 +140,7 @@ public class DatabaseController {
         final String sql = "INSERT INTO " + table + " (name, travsportId) VALUES (?, ?)";
         int last_id = -1;
         try {
-            final PreparedStatement stat = getConnection().prepareStatement(sql,
-                    PreparedStatement.RETURN_GENERATED_KEYS);
+            final PreparedStatement stat = getConnection().prepareStatement(sql, PreparedStatement.RETURN_GENERATED_KEYS);
             stat.setString(1, name);
             stat.setInt(2, travsportId);
 
@@ -285,7 +286,8 @@ public class DatabaseController {
 
     public List<LaneWinObject> getAutostartWinPercents(ArrayList<String> distance) {
         final List<LaneWinObject> resultList = Lists.newArrayList();
-        final String sql = "SELECT Lane, (Count(*) / SUM(COUNT(*)) OVER()) * 100 AS Percent, distance FROM `Results` WHERE Result = 1 AND TimeModifier like '%a%' AND Lane > 0 AND Distance IN (?) GROUP BY Lane, Distance ORDER BY `Results`.`Lane` ASC";
+        final String sql
+                = "SELECT Lane, (Count(*) / SUM(COUNT(*)) OVER()) * 100 AS Percent, distance FROM `Results` WHERE Result = 1 AND TimeModifier like '%a%' AND Lane > 0 AND Distance IN (?) GROUP BY Lane, Distance ORDER BY `Results`.`Lane` ASC";
         try {
             final PreparedStatement stat = getConnection().prepareStatement(sql);
             stat.setString(1, String.join(",", distance));
@@ -301,14 +303,16 @@ public class DatabaseController {
 
         return resultList;
     }
+
     public List<LaneWinObject> getAutostartWinPercents(List<Integer> distances) {
-        return getAutostartWinPercents(Lists.newArrayList(distances.stream().map(d -> d.toString()).collect(Collectors.toList())));
+        return getAutostartWinPercents(
+                Lists.newArrayList(distances.stream().map(d -> d.toString()).collect(Collectors.toList())));
     }
 
-
     public List<LaneWinObject> getVoltstartWinPercents(ArrayList<String> distance) {
         final List<LaneWinObject> resultList = Lists.newArrayList();
-        String sql = "SELECT Lane, (Count(*) / SUM(COUNT(*)) OVER()) * 100 AS Percent, distance FROM `Results` WHERE Result = 1 AND TimeModifier NOT like '%a%' AND Lane > 0 AND Distance IN (?) GROUP BY Lane, Distance ORDER BY `Results`.`Lane` ASC";
+        String sql
+                = "SELECT Lane, (Count(*) / SUM(COUNT(*)) OVER()) * 100 AS Percent, distance FROM `Results` WHERE Result = 1 AND TimeModifier NOT like '%a%' AND Lane > 0 AND Distance IN (?) GROUP BY Lane, Distance ORDER BY `Results`.`Lane` ASC";
         try {
             final String in = distance.stream().collect(Collectors.joining(",", "(", ")"));
             sql = sql.replace("(?)", in);
@@ -334,10 +338,8 @@ public class DatabaseController {
         final List<HorseRaceData> results = new ArrayList<>();
 
         final String sql = "SELECT r1.*, driver.name as DriverName, horse.name as HorseName, track.name as TrackName "
-                + "FROM Results r1 "
-                + "INNER JOIN Driver as driver ON driverId = driver.id "
-                + "INNER JOIN Horse as horse ON HorseId = horse.id "
-                + "INNER JOIN Track as track ON TrackId = track.id "
+                + "FROM Results r1 " + "INNER JOIN Driver as driver ON driverId = driver.id "
+                + "INNER JOIN Horse as horse ON HorseId = horse.id " + "INNER JOIN Track as track ON TrackId = track.id "
                 + "WHERE r1.RaceDate = ? " + " GROUP BY r1.horseId "
                 + "ORDER BY r1.TrackId DESC, r1.RaceDate DESC, `r1`.`RaceNumber` ASC";
 
@@ -367,19 +369,22 @@ public class DatabaseController {
 
                 if (shouldUpdate) {
                     if (rd.getAvgDriverTimeCount() < 20) {
-                        System.out.println("Uppdating driver " + rd.getDriverName() + "(" + rd.getDriverId()
-                        + ") travsport id: " + getDriverTravsportId(rd.getDriverName()) + "because race count was "
-                        + rd.getAvgDriverTimeCount());
+                        System.out.println("Uppdating driver " + rd.getDriverName() + "(" + rd.getDriverId() + ") travsport id: "
+                                + getDriverTravsportId(rd.getDriverName()) + "because race count was "
+                                + rd.getAvgDriverTimeCount());
                         TravsportParser.getInstance().getDriverStatById(getDriverTravsportId(rd.getDriverName()),
-                                rd.getDriverName(), rs.getInt("raceId"));
+                                rd.getDriverName(),
+                                rs.getInt("raceId"));
                     }
 
                     if (rd.getAvgHorseTimeCount() < 5) {
-                        System.out.println("Uppdating horse " + rd.getHorseName() + "( " + rd.getHorseId()
-                        + ") travsport id: " + getHorseTravsportId(rd.getHorseName()) + " because race count was "
-                        + rd.getAvgHorseTimeCount());
+                        System.out.println("Uppdating horse " + rd.getHorseName() + "( " + rd.getHorseId() + ") travsport id: "
+                                + getHorseTravsportId(rd.getHorseName()) + " because race count was "
+                                + rd.getAvgHorseTimeCount());
                         TravsportParser.getInstance().getHorseStatByIdJson(getHorseTravsportId(rd.getHorseName()),
-                                rd.getHorseName(), "", rs.getInt("raceId"));
+                                rd.getHorseName(),
+                                "",
+                                rs.getInt("raceId"));
                     }
                 }
 
@@ -406,19 +411,17 @@ public class DatabaseController {
         c.add(Calendar.YEAR, -2);
 
         if (Strings.isNullOrEmpty(type)) {
-            sql = "SELECT r1.*, driver.name as DriverName, horse.name as HorseName, track.name as TrackName "
-                    + "FROM Results r1 " + "				INNER JOIN Driver as driver ON driverId = driver.id "
+            sql = "SELECT r1.*, driver.name as DriverName, horse.name as HorseName, track.name as TrackName " + "FROM Results r1 "
+                    + "				INNER JOIN Driver as driver ON driverId = driver.id "
                     + "				INNER JOIN Horse as horse ON HorseId = horse.id "
-                    + "				INNER JOIN Track as track ON TrackId = track.id "
-                    + " WHERE r1.RaceDate = ? " + " GROUP BY r1.horseId "
-                    + "ORDER BY r1.TrackId DESC, r1.RaceDate DESC, `r1`.`RaceNumber` ASC";
+                    + "				INNER JOIN Track as track ON TrackId = track.id " + " WHERE r1.RaceDate = ? "
+                    + " GROUP BY r1.horseId " + "ORDER BY r1.TrackId DESC, r1.RaceDate DESC, `r1`.`RaceNumber` ASC";
         } else {
-            sql = "SELECT r1.*, driver.name as DriverName, horse.name as HorseName, track.name as TrackName "
-                    + "FROM Results r1 " + "				INNER JOIN Driver as driver ON driverId = driver.id "
+            sql = "SELECT r1.*, driver.name as DriverName, horse.name as HorseName, track.name as TrackName " + "FROM Results r1 "
+                    + "				INNER JOIN Driver as driver ON driverId = driver.id "
                     + "				INNER JOIN Horse as horse ON HorseId = horse.id "
-                    + "				INNER JOIN Track as track ON TrackId = track.id "
-                    + " WHERE r1.RaceDate = ? " + " AND r1.RaceType LIKE ? " + " GROUP BY r1.horseId "
-                    + "ORDER BY r1.TrackId DESC, `r1`.`RaceNumber` ASC";
+                    + "				INNER JOIN Track as track ON TrackId = track.id " + " WHERE r1.RaceDate = ? "
+                    + " AND r1.RaceType LIKE ? " + " GROUP BY r1.horseId " + "ORDER BY r1.TrackId DESC, `r1`.`RaceNumber` ASC";
         }
 
         final List<HorseRaceData> results = new ArrayList<>();
@@ -461,19 +464,22 @@ public class DatabaseController {
 
                 if (shouldUpdate) {
                     if (rd.getAvgDriverTimeCount() < 20) {
-                        System.out.println("Uppdating driver " + rd.getDriverName() + "(" + rd.getDriverId()
-                        + ") travsport id: " + getDriverTravsportId(rd.getDriverName()) + "because race count was "
-                        + rd.getAvgDriverTimeCount());
+                        System.out.println("Uppdating driver " + rd.getDriverName() + "(" + rd.getDriverId() + ") travsport id: "
+                                + getDriverTravsportId(rd.getDriverName()) + "because race count was "
+                                + rd.getAvgDriverTimeCount());
                         TravsportParser.getInstance().getDriverStatById(getDriverTravsportId(rd.getDriverName()),
-                                rd.getDriverName(), rs.getInt("raceId"));
+                                rd.getDriverName(),
+                                rs.getInt("raceId"));
                     }
 
                     if (rd.getAvgHorseTimeCount() < 5) {
-                        System.out.println("Uppdating horse " + rd.getHorseName() + "( " + rd.getHorseId()
-                        + ") travsport id: " + getHorseTravsportId(rd.getHorseName()) + " because race count was "
-                        + rd.getAvgHorseTimeCount());
+                        System.out.println("Uppdating horse " + rd.getHorseName() + "( " + rd.getHorseId() + ") travsport id: "
+                                + getHorseTravsportId(rd.getHorseName()) + " because race count was "
+                                + rd.getAvgHorseTimeCount());
                         TravsportParser.getInstance().getHorseStatByIdJson(getHorseTravsportId(rd.getHorseName()),
-                                rd.getHorseName(), "", rs.getInt("raceId"));
+                                rd.getHorseName(),
+                                "",
+                                rs.getInt("raceId"));
                     }
                 }
 
@@ -609,7 +615,8 @@ public class DatabaseController {
 
     // Hämta statistik för häst, förare, kombinationen av dessa två, distans....
     public SimpleEntry<Integer, Integer> getNumHorseGallop(int horseId) {
-        final String sql = "SELECT COUNT(*) as total, SUM(IF(TimeModifier LIKE '%g%', 1, 0)) as gallop FROM `Results` WHERE HorseId = ?";
+        final String sql
+                = "SELECT COUNT(*) as total, SUM(IF(TimeModifier LIKE '%g%', 1, 0)) as gallop FROM `Results` WHERE HorseId = ?";
         SimpleEntry<Integer, Integer> returnValue = null;
 
         try {
@@ -629,7 +636,8 @@ public class DatabaseController {
 
     // Hämta statistik för häst, förare, kombinationen av dessa två, distans....
     public SimpleEntry<Integer, Integer> getNumDriverGallop(int driverId) {
-        final String sql = "SELECT COUNT(*) as total, SUM(IF(TimeModifier LIKE '%g%', 1, 0)) as gallop FROM `Results` WHERE DriverId = ?";
+        final String sql
+                = "SELECT COUNT(*) as total, SUM(IF(TimeModifier LIKE '%g%', 1, 0)) as gallop FROM `Results` WHERE DriverId = ?";
         SimpleEntry<Integer, Integer> returnValue = null;
 
         try {
@@ -697,9 +705,12 @@ public class DatabaseController {
     }
 
     public float getTrendLast5(HorseRaceData horseRaceData) {
-        final String combinedTrendSql = "SELECT Time, (SELECT AVG(Time) FROM Results WHERE HorseId = ? AND DriverId = ? AND Distance = ?) as avgTime FROM Results WHERE HorseId = ? AND DriverId = ? AND Distance = ? AND Time > -1 ORDER BY RaceDate ASC limit 5";
-        final String DriverTrendSql = "SELECT Time, (SELECT AVG(Time) FROM Results WHERE DriverId = ? AND Distance = ?) as avgTime FROM Results WHERE DriverId = ? AND Distance = ? AND Time > -1 ORDER BY RaceDate ASC limit 5";
-        final String horseTrendSql = "SELECT Time, (SELECT AVG(Time) FROM Results WHERE HorseId = ? AND Distance = ?) as avgTime FROM Results WHERE HorseId = ? AND Distance = ? AND Time > -1  ORDER BY RaceDate ASC limit 5";
+        final String combinedTrendSql
+                = "SELECT Time, (SELECT AVG(Time) FROM Results WHERE HorseId = ? AND DriverId = ? AND Distance = ?) as avgTime FROM Results WHERE HorseId = ? AND DriverId = ? AND Distance = ? AND Time > -1 ORDER BY RaceDate ASC limit 5";
+        final String DriverTrendSql
+                = "SELECT Time, (SELECT AVG(Time) FROM Results WHERE DriverId = ? AND Distance = ?) as avgTime FROM Results WHERE DriverId = ? AND Distance = ? AND Time > -1 ORDER BY RaceDate ASC limit 5";
+        final String horseTrendSql
+                = "SELECT Time, (SELECT AVG(Time) FROM Results WHERE HorseId = ? AND Distance = ?) as avgTime FROM Results WHERE HorseId = ? AND Distance = ? AND Time > -1  ORDER BY RaceDate ASC limit 5";
 
         final int horseId = horseRaceData.getHorseId();
         final int driverId = horseRaceData.getDriverId();
@@ -712,8 +723,8 @@ public class DatabaseController {
         float startDriverAvgTime = -1;
         float startCombinedAvgTime = -1;
         try {
-            final PreparedStatement horseStat = getConnection().prepareStatement(horseTrendSql,
-                    ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
+            final PreparedStatement horseStat = getConnection()
+                    .prepareStatement(horseTrendSql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
             horseStat.setInt(1, horseId);
             horseStat.setInt(2, distance);
             horseStat.setInt(3, horseId);
@@ -734,8 +745,8 @@ public class DatabaseController {
             horseRs.close();
             horseStat.close();
 
-            final PreparedStatement driverStat = conn.prepareStatement(DriverTrendSql,
-                    ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
+            final PreparedStatement driverStat
+                    = conn.prepareStatement(DriverTrendSql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
             driverStat.setInt(1, driverId);
             driverStat.setInt(2, distance);
             driverStat.setInt(3, driverId);
@@ -752,8 +763,8 @@ public class DatabaseController {
                 System.out.println("No driver trend found");
             }
 
-            final PreparedStatement combinedStat = conn.prepareStatement(combinedTrendSql,
-                    ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
+            final PreparedStatement combinedStat
+                    = conn.prepareStatement(combinedTrendSql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
 
             combinedStat.setInt(1, horseId);
             combinedStat.setInt(2, driverId);
@@ -802,11 +813,11 @@ public class DatabaseController {
         return returnValue;
     }
 
-    public void updateResult(String horseName, String driverName, int result, String timeModifier, float timeValue,
-            String date, String type) {
+    public void updateResult(String horseName, String driverName, int result, String timeModifier, float timeValue, String date,
+            String type) {
         final String sql = "UPDATE Results " + "SET " + "Result = ?, Time = ?, TimeModifier = ?" + "WHERE "
-                + "HorseId = (SELECT id FROM Horse WHERE name = ?) AND "
-                + "DriverId = (SELECT id FROM Driver WHERE name = ?) AND" + "RaceDate = ?";
+                + "HorseId = (SELECT id FROM Horse WHERE name = ?) AND " + "DriverId = (SELECT id FROM Driver WHERE name = ?) AND"
+                + "RaceDate = ?";
         try {
             final PreparedStatement stat = getConnection().prepareStatement(sql);
             stat.setInt(1, result);
@@ -819,8 +830,8 @@ public class DatabaseController {
             final int res = stat.executeUpdate();
 
             if (res != 1) {
-                System.out.println("Updated " + res + " results for horse " + horseName + " and driver " + driverName
-                        + " at date " + date);
+                System.out.println(
+                        "Updated " + res + " results for horse " + horseName + " and driver " + driverName + " at date " + date);
             }
 
         } catch (final SQLException e) {
@@ -875,7 +886,8 @@ public class DatabaseController {
     }
 
     public int getRaceId() {
-        final String sql = "SELECT raceId FROM Results where raceId > -1 AND RaceDate < DATE(NOW()) ORDER BY RaceDate ASC LIMIT 1";
+        final String sql
+                = "SELECT raceId FROM Results where raceId > -1 AND RaceDate < DATE(NOW()) ORDER BY RaceDate ASC LIMIT 1";
         int returnValue = -1;
         try {
             final PreparedStatement stat = getConnection().prepareStatement(sql);
@@ -893,7 +905,8 @@ public class DatabaseController {
 
     public List<UpdateRaceRow> getRacesToUpdate(String date) {
         final List<UpdateRaceRow> racesToUpdate = Lists.newArrayList();
-        final String sql = "SELECT r.*, t.name as TrackName, t.id as TrackId FROM Results r INNER JOIN Track t ON r.trackId = t.id WHERE r.RaceDate = ? GROUP BY r.RaceDate, t.name, r.RaceNumber";
+        final String sql
+                = "SELECT r.*, t.name as TrackName, t.id as TrackId FROM Results r INNER JOIN Track t ON r.trackId = t.id WHERE r.RaceDate = ? GROUP BY r.RaceDate, t.name, r.RaceNumber";
 
         try {
             final PreparedStatement stat = getConnection().prepareStatement(sql);
@@ -902,9 +915,9 @@ public class DatabaseController {
             final ResultSet rs = stat.executeQuery();
 
             while (rs.next()) {
-                racesToUpdate
-                .add(new UpdateRaceRow(rs.getInt("id"), rs.getString("RaceDate"), rs.getString("RaceType"),
-                        rs.getString("TimeModifier").contains("a"), rs.getInt("RaceNumber"), rs.getString("TrackName"), rs.getInt("TrackId")));
+                racesToUpdate.add(new UpdateRaceRow(rs.getInt("id"), rs.getString("RaceDate"), rs.getString("RaceType"),
+                        rs.getString("TimeModifier").contains("a"), rs.getInt("RaceNumber"), rs.getString("TrackName"),
+                        rs.getInt("TrackId")));
             }
         } catch (final SQLException e) {
             throw new RuntimeException(e.getMessage(), e);
@@ -918,14 +931,10 @@ public class DatabaseController {
         final String sql = "UPDATE Results SET RaceType = ? WHERE raceId = ? AND RaceNumber = ? AND trackId = ? AND RaceDate = ?";
         final String updateTimeModifier;
         if (isAutostart) {
-            updateTimeModifier = "UPDATE `Results` SET TimeModifier = "
-                    + "IF(TimeModifier LIKE '%a%', "
-                    + "TimeModifier, "
-                    + "CONCAT(TimeModifier, 'a')) "
-                    + "WHERE RaceDate = ? AND RaceNumber = ? AND TrackId = ?";
+            updateTimeModifier = "UPDATE `Results` SET TimeModifier = " + "IF(TimeModifier LIKE '%a%', " + "TimeModifier, "
+                    + "CONCAT(TimeModifier, 'a')) " + "WHERE RaceDate = ? AND RaceNumber = ? AND TrackId = ?";
         } else {
-            updateTimeModifier = "UPDATE `Results` SET TimeModifier = "
-                    + "REPLACE(TimeModifier, 'a', '') "
+            updateTimeModifier = "UPDATE `Results` SET TimeModifier = " + "REPLACE(TimeModifier, 'a', '') "
                     + "WHERE RaceDate = ? AND RaceNumber = ? AND TrackId = ?";
         }
 
@@ -956,7 +965,8 @@ public class DatabaseController {
             int horseTravsportId, int driverTravsportId, String raceDate, int raceNumber) {
         final int horseId = getHorseId("", horseTravsportId);
         final int driverId = getDriverId("", driverTravsportId);
-        final String sql = "UPDATE Results SET Result = ?, Time = ?, TimeModifier = ?, DriverId = ?, raceId = -1 WHERE RaceDate = ? AND RaceId = ? AND RaceNumber = ? AND HorseId = ?";
+        final String sql
+                = "UPDATE Results SET Result = ?, Time = ?, TimeModifier = ?, DriverId = ?, raceId = -1 WHERE RaceDate = ? AND RaceId = ? AND RaceNumber = ? AND HorseId = ?";
         if (horseId == -1 || driverId == -1) {
             System.out.println("NOT UPDATING horseId " + horseId + " driver Id: " + driverId);
             return;
@@ -972,12 +982,11 @@ public class DatabaseController {
             stat.setInt(6, raceId);
             stat.setInt(7, raceNumber);
             stat.setInt(8, horseId);
-            //			stat.setInt(7, lane);
-            //			stat.setInt(8, distance);
+            // stat.setInt(7, lane);
+            // stat.setInt(8, distance);
 
             stat.executeUpdate();
 
-
         } catch (final SQLException e) {
             throw new RuntimeException(e.getMessage(), e);
         }
@@ -1031,7 +1040,8 @@ public class DatabaseController {
     }
 
     public String getDriverLastRace(int driverId, int raceNumber) {
-        final String sql = "SELECT RaceDate FROM Results WHERE (RaceDate < ? || (RaceDate = ? AND RaceNumber < ?)) AND DriverId = ? ORDER BY RaceDate DESC limit 1";
+        final String sql
+                = "SELECT RaceDate FROM Results WHERE (RaceDate < ? || (RaceDate = ? AND RaceNumber < ?)) AND DriverId = ? ORDER BY RaceDate DESC limit 1";
         String lastRaceDate = "";
         try {
             final PreparedStatement stat = getConnection().prepareStatement(sql);
@@ -1063,18 +1073,19 @@ public class DatabaseController {
 
         final Long days = Duration.between(lastDate.atStartOfDay(), parsedDate.atStartOfDay()).toDays();
 
-        final String sql = "SELECT currentDate.RaceDate as date, prevDate.RaceDate AS prev_date, DATEDIFF(currentDate.RaceDate, prevDate.RaceDate) as diff, "
-                + "ROUND(AVG(currentDate.Time),2) as avgTime, COUNT(*), ROUND(AVG(currentDate.adjTime),2) as adjAvgTime "
-                + "FROM " + "(SELECT (@row_number:=@row_number + 1) as RID, "
-                + "IF (Time = -1, (SELECT MIN(Time) FROM (SELECT Time FROM Results WHERE TimeModifier NOT LIKE '%g%' ORDER BY Time DESC limit 5) abc), time) as adjTime, "
-                + "Results.* FROM Results, "
-                + "(SELECT @row_number:=0) as t WHERE DriverId = ? AND distance = ? AND RaceDate <= ? "
-                + "ORDER BY RaceDate DESC ) AS currentDate "
-                + "INNER JOIN (SELECT (@row_number2 := @row_number2 + 1) AS RID, RaceDate "
-                + "FROM Results, (SELECT @row_number2:=0) AS t "
-                + "WHERE DriverId = ? AND distance = ? AND RaceDate <= ? "
-                + "ORDER BY RaceDate DESC LIMIT 99999 OFFSET 1) AS prevDate ON currentDate.RID = prevDate.RID "
-                + "GROUP BY diff ORDER BY DIFF";
+        final String sql
+                = "SELECT currentDate.RaceDate as date, prevDate.RaceDate AS prev_date, DATEDIFF(currentDate.RaceDate, prevDate.RaceDate) as diff, "
+                        + "ROUND(AVG(currentDate.Time),2) as avgTime, COUNT(*), ROUND(AVG(currentDate.adjTime),2) as adjAvgTime "
+                        + "FROM " + "(SELECT (@row_number:=@row_number + 1) as RID, "
+                        + "IF (Time = -1, (SELECT MIN(Time) FROM (SELECT Time FROM Results WHERE TimeModifier NOT LIKE '%g%' ORDER BY Time DESC limit 5) abc), time) as adjTime, "
+                        + "Results.* FROM Results, "
+                        + "(SELECT @row_number:=0) as t WHERE DriverId = ? AND distance = ? AND RaceDate <= ? "
+                        + "ORDER BY RaceDate DESC ) AS currentDate "
+                        + "INNER JOIN (SELECT (@row_number2 := @row_number2 + 1) AS RID, RaceDate "
+                        + "FROM Results, (SELECT @row_number2:=0) AS t "
+                        + "WHERE DriverId = ? AND distance = ? AND RaceDate <= ? "
+                        + "ORDER BY RaceDate DESC LIMIT 99999 OFFSET 1) AS prevDate ON currentDate.RID = prevDate.RID "
+                        + "GROUP BY diff ORDER BY DIFF";
 
         try {
             final PreparedStatement stat = getConnection().prepareStatement(sql);
@@ -1110,8 +1121,8 @@ public class DatabaseController {
 
         final File file = new File(System.getProperty("user.dir") + File.separator + "src/test/testFiles.csv");
         try (final BufferedWriter writer = new BufferedWriter(new FileWriter(file))) {
-            final PreparedStatement stat = getConnection().prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE,
-                    ResultSet.CONCUR_READ_ONLY);
+            final PreparedStatement stat
+                    = getConnection().prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
             stat.setString(1, currentDate);
             stat.setString(2, "2015-01-01");
 
@@ -1123,19 +1134,19 @@ public class DatabaseController {
 
             int i = 1;
             while (rs.next()) {
-                final Result result = new Result(rs.getInt(1), rs.getInt(2), rs.getString(3), rs.getString(4),
-                        rs.getInt(5), rs.getInt(6), rs.getInt(7), rs.getInt(8), rs.getFloat(9), rs.getString(10),
-                        rs.getInt(11), rs.getInt(12), rs.getInt(13), rs.getInt(14), rs.getInt(15), rs.getInt(16));
+                final Result result = new Result(rs.getInt(1), rs.getInt(2), rs.getString(3), rs.getString(4), rs.getInt(5),
+                        rs.getInt(6), rs.getInt(7), rs.getInt(8), rs.getFloat(9), rs.getString(10), rs.getInt(11), rs.getInt(12),
+                        rs.getInt(13), rs.getInt(14), rs.getInt(15), rs.getInt(16));
 
                 final float avgHorseTime = getAvgTime(result.getHorseId(), result.getRaceDate(), -1, false);
-                final float avgHorseTimeDistance = getAvgTime(result.getHorseId(), result.getRaceDate(),
-                        result.getDistance(), false);
+                final float avgHorseTimeDistance
+                        = getAvgTime(result.getHorseId(), result.getRaceDate(), result.getDistance(), false);
                 final float avgDriverTime = getAvgTime(result.getDriverId(), result.getRaceDate(), -1, true);
-                final float avgDriverTimeDistance = getAvgTime(result.getDriverId(), result.getRaceDate(),
-                        result.getDistance(), true);
+                final float avgDriverTimeDistance
+                        = getAvgTime(result.getDriverId(), result.getRaceDate(), result.getDistance(), true);
 
-                writer.append(result.resultToFileString() + ";" + avgHorseTime + ";" + avgHorseTimeDistance + ";"
-                        + avgDriverTime + ";" + avgDriverTimeDistance + System.lineSeparator());
+                writer.append(result.resultToFileString() + ";" + avgHorseTime + ";" + avgHorseTimeDistance + ";" + avgDriverTime
+                        + ";" + avgDriverTimeDistance + System.lineSeparator());
 
                 if (i % 1000 == 0) {
                     System.out.println(LocalTime.now() + " Done with " + i++ + " of " + lastRow);
@@ -1150,16 +1161,14 @@ public class DatabaseController {
 
     public int getLastRaceDaysHorse(int horseId, String raceDate, int raceNumber) {
         int returnValue = 999;
-        final String sql = "SELECT DATEDIFF(?, startDate.RaceDate) as days, startDate.RaceDate, nextDate.RaceDate, RaceNumber " +
-                "FROM (SELECT (@row_number := @row_number + 1) AS orderNum, RaceDate, RaceNumber " +
-                "FROM Results, (SELECT @row_number:=0) AS t WHERE RaceDate <= ? AND HorseId = ? " +
-                "ORDER BY RaceDate DESC, RaceNumber DESC) AS startDate " +
-                "INNER JOIN " +
-                "(SELECT (@row_number2 := @row_number2 + 1) AS orderNum, RaceDate " +
-                "FROM Results, (SELECT @row_number2 := 0) AS t WHERE RaceDate <= ? AND HorseId = ? " +
-                "ORDER BY RaceDate DESC, RaceNumber DESC " +
-                "LIMIT 11 " +
-                "OFFSET 1) AS nextDate ON nextDate.orderNum = startDate.orderNum";
+        final String sql = "SELECT DATEDIFF(?, startDate.RaceDate) as days, startDate.RaceDate, nextDate.RaceDate, RaceNumber "
+                + "FROM (SELECT (@row_number := @row_number + 1) AS orderNum, RaceDate, RaceNumber "
+                + "FROM Results, (SELECT @row_number:=0) AS t WHERE RaceDate <= ? AND HorseId = ? "
+                + "ORDER BY RaceDate DESC, RaceNumber DESC) AS startDate " + "INNER JOIN "
+                + "(SELECT (@row_number2 := @row_number2 + 1) AS orderNum, RaceDate "
+                + "FROM Results, (SELECT @row_number2 := 0) AS t WHERE RaceDate <= ? AND HorseId = ? "
+                + "ORDER BY RaceDate DESC, RaceNumber DESC " + "LIMIT 11 "
+                + "OFFSET 1) AS nextDate ON nextDate.orderNum = startDate.orderNum";
         try {
             final PreparedStatement stat = getConnection().prepareStatement(sql);
 
@@ -1190,16 +1199,14 @@ public class DatabaseController {
     public int getLastRaceDaysDriver(int driverId, String raceDate, int raceNumber) {
         int returnValue = 999;
 
-        final String sql = "SELECT DATEDIFF(?, startDate.RaceDate) as days, startDate.RaceDate, nextDate.RaceDate, RaceNumber " +
-                "FROM (SELECT (@row_number := @row_number + 1) AS orderNum, RaceDate, RaceNumber " +
-                "FROM Results, (SELECT @row_number:=0) AS t WHERE RaceDate <= ? AND DriverId = ? " +
-                "ORDER BY RaceDate DESC, RaceNumber DESC) AS startDate " +
-                "INNER JOIN " +
-                "(SELECT (@row_number2 := @row_number2 + 1) AS orderNum, RaceDate " +
-                "FROM Results, (SELECT @row_number2 := 0) AS t WHERE RaceDate <= ? AND DriverId = ? " +
-                "ORDER BY RaceDate DESC, RaceNumber DESC " +
-                "LIMIT 11 " +
-                "OFFSET 1) AS nextDate ON nextDate.orderNum = startDate.orderNum";
+        final String sql = "SELECT DATEDIFF(?, startDate.RaceDate) as days, startDate.RaceDate, nextDate.RaceDate, RaceNumber "
+                + "FROM (SELECT (@row_number := @row_number + 1) AS orderNum, RaceDate, RaceNumber "
+                + "FROM Results, (SELECT @row_number:=0) AS t WHERE RaceDate <= ? AND DriverId = ? "
+                + "ORDER BY RaceDate DESC, RaceNumber DESC) AS startDate " + "INNER JOIN "
+                + "(SELECT (@row_number2 := @row_number2 + 1) AS orderNum, RaceDate "
+                + "FROM Results, (SELECT @row_number2 := 0) AS t WHERE RaceDate <= ? AND DriverId = ? "
+                + "ORDER BY RaceDate DESC, RaceNumber DESC " + "LIMIT 11 "
+                + "OFFSET 1) AS nextDate ON nextDate.orderNum = startDate.orderNum";
 
         try {
             final CallableStatement stat = getConnection().prepareCall(sql);
@@ -1228,19 +1235,18 @@ public class DatabaseController {
         }
         return returnValue;
     }
+
     public int getLastRaceDaysBoth(int horseId, int driverId, String raceDate, int raceNumber) {
         int returnValue = 999;
 
-        final String sql = "SELECT DATEDIFF(?, startDate.RaceDate) as days, startDate.RaceDate, nextDate.RaceDate, RaceNumber " +
-                "FROM (SELECT (@row_number := @row_number + 1) AS orderNum, RaceDate, RaceNumber " +
-                "FROM Results, (SELECT @row_number:=0) AS t WHERE RaceDate <= ? AND DriverId = ? AND HorseId = ? " +
-                "ORDER BY RaceDate DESC, RaceNumber DESC) AS startDate " +
-                "INNER JOIN " +
-                "(SELECT (@row_number2 := @row_number2 + 1) AS orderNum, RaceDate " +
-                "FROM Results, (SELECT @row_number2 := 0) AS t WHERE RaceDate <= ? AND DriverId = ? AND HorseId = ? " +
-                "ORDER BY RaceDate DESC, RaceNumber DESC " +
-                "LIMIT 11 " +
-                "OFFSET 1) AS nextDate ON nextDate.orderNum = startDate.orderNum";
+        final String sql = "SELECT DATEDIFF(?, startDate.RaceDate) as days, startDate.RaceDate, nextDate.RaceDate, RaceNumber "
+                + "FROM (SELECT (@row_number := @row_number + 1) AS orderNum, RaceDate, RaceNumber "
+                + "FROM Results, (SELECT @row_number:=0) AS t WHERE RaceDate <= ? AND DriverId = ? AND HorseId = ? "
+                + "ORDER BY RaceDate DESC, RaceNumber DESC) AS startDate " + "INNER JOIN "
+                + "(SELECT (@row_number2 := @row_number2 + 1) AS orderNum, RaceDate "
+                + "FROM Results, (SELECT @row_number2 := 0) AS t WHERE RaceDate <= ? AND DriverId = ? AND HorseId = ? "
+                + "ORDER BY RaceDate DESC, RaceNumber DESC " + "LIMIT 11 "
+                + "OFFSET 1) AS nextDate ON nextDate.orderNum = startDate.orderNum";
 
         try {
             final PreparedStatement stat = getConnection().prepareStatement(sql);
@@ -1253,7 +1259,6 @@ public class DatabaseController {
             stat.setInt(6, driverId);
             stat.setInt(7, horseId);
 
-
             final ResultSet rs = stat.executeQuery();
 
             boolean getNext = false;
@@ -1275,18 +1280,15 @@ public class DatabaseController {
 
     public ArrayList<DaysSinceLastRace> getDriverDaysSinceLastRaceStats(int driverId) {
         final ArrayList<DaysSinceLastRace> daysStats = Lists.newArrayList();
-        final String sql = "SELECT DATEDIFF(startDate.RaceDate, prevDate.RaceDate) as days, count(*) as count, SUM(if (startDate.result = 1,1,0)) as wins, SUM(if (startDate.result = 1,1,0)) / count(*) as percent " +
-                "FROM (SELECT (@row_number := @row_number + 1) AS orderNum, RaceDate, Result, RaceNumber " +
-                "FROM Results, (SELECT @row_number:=0) AS t " +
-                "WHERE DriverId = ? " +
-                "ORDER BY RaceDate DESC, RaceNumber ASC) as startDate " +
-                "INNER JOIN " +
-                "(SELECT (@row_number2 := @row_number2 + 1) AS orderNum, RaceDate " +
-                "FROM Results, (SELECT @row_number2 := 0) AS t  " +
-                "WHERE DriverId = ? " +
-                "ORDER BY RaceDate DESC, RaceNumber ASC " +
-                "LIMIT 100000 " +
-                "OFFSET 1) AS prevDate ON startDate.orderNum = prevDate.orderNum GROUP BY days HAVING days <= 100 ORDER BY days ASC";
+        final String sql
+                = "SELECT DATEDIFF(startDate.RaceDate, prevDate.RaceDate) as days, count(*) as count, SUM(if (startDate.result = 1,1,0)) as wins, SUM(if (startDate.result = 1,1,0)) / count(*) as percent "
+                        + "FROM (SELECT (@row_number := @row_number + 1) AS orderNum, RaceDate, Result, RaceNumber "
+                        + "FROM Results, (SELECT @row_number:=0) AS t " + "WHERE DriverId = ? "
+                        + "ORDER BY RaceDate DESC, RaceNumber ASC) as startDate " + "INNER JOIN "
+                        + "(SELECT (@row_number2 := @row_number2 + 1) AS orderNum, RaceDate "
+                        + "FROM Results, (SELECT @row_number2 := 0) AS t  " + "WHERE DriverId = ? "
+                        + "ORDER BY RaceDate DESC, RaceNumber ASC " + "LIMIT 100000 "
+                        + "OFFSET 1) AS prevDate ON startDate.orderNum = prevDate.orderNum GROUP BY days HAVING days <= 100 ORDER BY days ASC";
 
         try {
             final PreparedStatement stat = getConnection().prepareStatement(sql);
@@ -1297,7 +1299,8 @@ public class DatabaseController {
             final ResultSet rs = stat.executeQuery();
 
             while (rs.next()) {
-                daysStats.add(new DaysSinceLastRace(rs.getInt("days"), rs.getInt("count"), rs.getInt("wins"), rs.getFloat("percent")));
+                daysStats.add(
+                        new DaysSinceLastRace(rs.getInt("days"), rs.getInt("count"), rs.getInt("wins"), rs.getFloat("percent")));
             }
 
         } catch (final SQLException e) {
@@ -1310,18 +1313,15 @@ public class DatabaseController {
 
     public DaysSinceLastRace getDriverDaysSinceLastRaceStat(int driverId, int daysSinceLast) {
         DaysSinceLastRace dayStat = null;
-        final String sql = "SELECT DATEDIFF(startDate.RaceDate, prevDate.RaceDate) as days, count(*) as count, SUM(if (startDate.result = 1,1,0)) as wins, SUM(if (startDate.result = 1,1,0)) / count(*) as percent " +
-                "FROM (SELECT (@row_number := @row_number + 1) AS orderNum, RaceDate, Result, RaceNumber " +
-                "FROM Results, (SELECT @row_number:=0) AS t " +
-                "WHERE DriverId = ? " +
-                "ORDER BY RaceDate DESC, RaceNumber ASC) as startDate " +
-                "INNER JOIN " +
-                "(SELECT (@row_number2 := @row_number2 + 1) AS orderNum, RaceDate " +
-                "FROM Results, (SELECT @row_number2 := 0) AS t  " +
-                "WHERE DriverId = ? " +
-                "ORDER BY RaceDate DESC, RaceNumber ASC " +
-                "LIMIT 100000 " +
-                "OFFSET 1) AS prevDate ON startDate.orderNum = prevDate.orderNum WHERE DATEDIFF(startDate.RaceDate, prevDate.RaceDate) = ?";
+        final String sql
+                = "SELECT DATEDIFF(startDate.RaceDate, prevDate.RaceDate) as days, count(*) as count, SUM(if (startDate.result = 1,1,0)) as wins, SUM(if (startDate.result = 1,1,0)) / count(*) as percent "
+                        + "FROM (SELECT (@row_number := @row_number + 1) AS orderNum, RaceDate, Result, RaceNumber "
+                        + "FROM Results, (SELECT @row_number:=0) AS t " + "WHERE DriverId = ? "
+                        + "ORDER BY RaceDate DESC, RaceNumber ASC) as startDate " + "INNER JOIN "
+                        + "(SELECT (@row_number2 := @row_number2 + 1) AS orderNum, RaceDate "
+                        + "FROM Results, (SELECT @row_number2 := 0) AS t  " + "WHERE DriverId = ? "
+                        + "ORDER BY RaceDate DESC, RaceNumber ASC " + "LIMIT 100000 "
+                        + "OFFSET 1) AS prevDate ON startDate.orderNum = prevDate.orderNum WHERE DATEDIFF(startDate.RaceDate, prevDate.RaceDate) = ?";
 
         try {
             final PreparedStatement stat = getConnection().prepareStatement(sql);
@@ -1375,13 +1375,8 @@ public class DatabaseController {
             typeString = "";
         }
         final String sql = "SELECT AVG(IF (Result <= 0, 8, result)) as avg, GROUP_CONCAT(Result) as list FROM "
-                + "(SELECT result FROM Results "
-                + "WHERE "
-                + typeString
-                + "RaceDate < ? "
-                + "AND RaceDate < DATE(NOW()) "
-                + "ORDER BY RaceDate DESC, RaceNumber DESC "
-                + "LIMIT ?) as t";
+                + "(SELECT result FROM Results " + "WHERE " + typeString + "RaceDate < ? " + "AND RaceDate < DATE(NOW()) "
+                + "ORDER BY RaceDate DESC, RaceNumber DESC " + "LIMIT ?) as t";
 
         try {
             final PreparedStatement stat = getConnection().prepareStatement(sql);
@@ -1401,7 +1396,7 @@ public class DatabaseController {
                 final String dbList = rs.getString("list");
                 final ArrayList<String> list;
                 if (dbList == null) {
-                    list = new ArrayList<String>();
+                    list = new ArrayList<>();
                 } else {
                     list = Lists.newArrayList(dbList.split(","));
                 }
@@ -1417,7 +1412,7 @@ public class DatabaseController {
                     for (int i = list.size(); i < limit; i++) {
                         newAvg += 8;
                     }
-                    avg = newAvg / (float)limit;
+                    avg = newAvg / (float) limit;
                 }
                 returnValue = String.valueOf(avg) + " (" + dbList + ")";
             }
@@ -1429,7 +1424,8 @@ public class DatabaseController {
         return returnValue;
     }
 
-    public List<SimpleEntry<Integer, Float>> getTrackAvarages(String trackName, ArrayList<Integer> distances, String date, int id, boolean isDriver) {
+    public List<SimpleEntry<Integer, Float>> getTrackAvarages(String trackName, ArrayList<Integer> distances, String date, int id,
+            boolean isDriver) {
         final List<SimpleEntry<Integer, Float>> res = Lists.newArrayList();
         String typeString;
         if (id > 0) {
@@ -1449,13 +1445,8 @@ public class DatabaseController {
             trackFilter = "AND TrackId = (SELECT id FROM Track WHERE name = ?) ";
         }
 
-        final String sql = "SELECT Lane, AVG(IF(Time <= 0,30,time)) as avg FROM Results "
-                + "WHERE distance IN (?) "
-                + trackFilter
-                + typeString
-                + "AND RaceDate < ? "
-                + "GROUP BY Lane "
-                + "ORDER BY Lane ASC";
+        final String sql = "SELECT Lane, AVG(IF(Time <= 0,30,time)) as avg FROM Results " + "WHERE distance IN (?) " + trackFilter
+                + typeString + "AND RaceDate < ? " + "GROUP BY Lane " + "ORDER BY Lane ASC";
 
         try {
             final PreparedStatement stat = getConnection().prepareStatement(sql);
@@ -1518,12 +1509,8 @@ public class DatabaseController {
             trackFilter = " TrackId = (SELECT id FROM Track WHERE name = ?) AND ";
         }
 
-        final String sql = "SELECT AVG(IF(Time <= 0,30,time)) as avg FROM Results "
-                + "WHERE "
-                + typeString
-                + distanceFilter
-                + trackFilter
-                + "RaceDate < ?";
+        final String sql = "SELECT AVG(IF(Time <= 0,30,time)) as avg FROM Results " + "WHERE " + typeString + distanceFilter
+                + trackFilter + "RaceDate < ?";
 
         try {
             final PreparedStatement stat = getConnection().prepareStatement(sql);
@@ -1537,7 +1524,7 @@ public class DatabaseController {
                         stat.setString(2, in);
                         stat.setString(3, date);
 
-                    }  else {
+                    } else {
                         stat.setString(1, in);
                         stat.setString(2, date);
                     }
@@ -1558,7 +1545,7 @@ public class DatabaseController {
                     if (id > 0) {
                         stat.setInt(1, id);
                         stat.setString(2, date);
-                    }  else {
+                    } else {
                         stat.setString(1, date);
                     }
                 } else {
@@ -1591,5 +1578,4 @@ public class DatabaseController {
         return res;
     }
 
-
 }

+ 179 - 288
ATG/src/controllers/NewTab/DriverController.java

@@ -8,11 +8,22 @@ import javafx.fxml.Initializable;
 import javafx.scene.control.Label;
 import objects.ResultsDTO;
 
-public class DriverController implements Initializable {
+public class DriverController extends MainContent implements Initializable {
 
     @FXML Label driverNameLabel;
     @FXML Label avgTimeLabel;
     @FXML Label avgTimeLabelTotal;
+
+    @FXML Label avgTimeLimit5Label;
+    @FXML Label avgTimeLimit5LabelTotal;
+    @FXML Label avgTimeLimit5LabelCompare;
+    @FXML Label avgTimeLimit10Label;
+    @FXML Label avgTimeLimit10LabelTotal;
+    @FXML Label avgTimeLimit10LabelCompare;
+    @FXML Label avgTimeLimit15Label;
+    @FXML Label avgTimeLimit15LabelTotal;
+    @FXML Label avgTimeLimit15LabelCompare;
+
     @FXML Label avgTimeLabelCompare;
     @FXML Label avgTimeDistanceLabel;
     @FXML Label avgTimeDistanceLabelTotal;
@@ -62,382 +73,262 @@ public class DriverController implements Initializable {
     }
 
     public void setDriverName(String name) {
-        this.driverNameLabel.setText(name);
+        driverNameLabel.setText(name);
     }
 
     public void setAvgTimeLabel(String value) {
-        this.avgTimeLabel.setText(value);
+        avgTimeLabel.setText(value);
 
-        this.avgTimeLabelCompare.setDisable(true);
-        this.avgTimeLabelCompare.setOpacity(0);
+        avgTimeLabelCompare.setDisable(true);
+        avgTimeLabelCompare.setOpacity(0);
 
-        this.avgTimeLabelTotal.setDisable(true);
-        this.avgTimeLabelTotal.setOpacity(0);
+        avgTimeLabelTotal.setDisable(true);
+        avgTimeLabelTotal.setOpacity(0);
     }
 
     public void setAvgTimeLabel(ResultsDTO firstValue, Float globalAvg, ResultsDTO compareValue) {
-        this.avgTimeLabel.setText(firstValue.toString());
-        this.avgTimeLabelTotal.setText(" (" + globalAvg.toString() + ") ");
-        this.avgTimeLabelCompare.setText(compareValue.toString());
-
-        this.avgTimeLabelCompare.setDisable(false);
-        this.avgTimeLabelCompare.setOpacity(1);
-
-        this.avgTimeLabelTotal.setDisable(false);
-        this.avgTimeLabelTotal.setOpacity(1);
-        if (firstValue.getRes() < compareValue.getRes()) {
-            this.avgTimeLabel.setStyle("-fx-text-fill: green;");
-            this.avgTimeLabelCompare.setStyle("-fx-text-fill: red;");
-        } else if (firstValue.getRes() > compareValue.getRes()) {
-            this.avgTimeLabel.setStyle("-fx-text-fill: red;");
-            this.avgTimeLabelCompare.setStyle("-fx-text-fill: green;");
-        } else {
-            this.avgTimeLabel.setStyle("-fx-text-fill: black;");
-            this.avgTimeLabelCompare.setStyle("-fx-text-fill: black;");
-        }
+        super.setAvgTimeLabel(avgTimeLabel, avgTimeLabelCompare, avgTimeLabelTotal, firstValue, globalAvg, compareValue);
+    }
+
+    public void setAvgTimeLimit5Label(ResultsDTO firstValue, Float globalAvg, ResultsDTO compareValue) {
+        super.setAvgTimeLimit5Label(avgTimeLimit5Label,
+                avgTimeLimit5LabelCompare,
+                avgTimeLimit5LabelTotal,
+                firstValue,
+                globalAvg,
+                compareValue);
+    }
+
+    public void setAvgTimeLimit10Label(ResultsDTO firstValue, Float globalAvg, ResultsDTO compareValue) {
+        super.setAvgTimeLimit10Label(avgTimeLimit10Label,
+                avgTimeLimit10LabelCompare,
+                avgTimeLimit10LabelTotal,
+                firstValue,
+                globalAvg,
+                compareValue);
+    }
+
+    public void setAvgTimeLimit15Label(ResultsDTO firstValue, Float globalAvg, ResultsDTO compareValue) {
+        super.setAvgTimeLimit15Label(avgTimeLimit15Label,
+                avgTimeLimit15LabelCompare,
+                avgTimeLimit15LabelTotal,
+                firstValue,
+                globalAvg,
+                compareValue);
+    }
+
+    public void setAvgTimeLimit5Label(ResultsDTO value) {
+        avgTimeLimit5Label.setText(value.getRes() + "(" + value.getCount() + ")");
+
+        avgTimeLimit5LabelCompare.setDisable(true);
+        avgTimeLimit5LabelCompare.setOpacity(0);
+
+        avgTimeLimit5LabelTotal.setDisable(true);
+        avgTimeLimit5LabelTotal.setOpacity(0);
+    }
+
+    public void setAvgTimeLimit10Label(ResultsDTO value) {
+        avgTimeLimit10Label.setText(value.getRes() + "(" + value.getCount() + ")");
+
+        avgTimeLimit10LabelCompare.setDisable(true);
+        avgTimeLimit10LabelCompare.setOpacity(0);
+
+        avgTimeLimit10LabelTotal.setDisable(true);
+        avgTimeLimit10LabelTotal.setOpacity(0);
+    }
+
+    public void setAvgTimeLimit15Label(ResultsDTO value) {
+        avgTimeLimit15Label.setText(value.getRes() + "(" + value.getCount() + ")");
+
+        avgTimeLimit15LabelCompare.setDisable(true);
+        avgTimeLimit15LabelCompare.setOpacity(0);
+
+        avgTimeLimit15LabelTotal.setDisable(true);
+        avgTimeLimit15LabelTotal.setOpacity(0);
     }
 
     public void setAvgTimeDistanceLimit5Label(String value) {
-        this.avgTimeDistanceLimit5Label.setText(value);
+        avgTimeDistanceLimit5Label.setText(value);
 
-        this.avgTimeDistanceLimit5LabelCompare.setDisable(true);
-        this.avgTimeDistanceLimit5LabelCompare.setOpacity(0);
+        avgTimeDistanceLimit5LabelCompare.setDisable(true);
+        avgTimeDistanceLimit5LabelCompare.setOpacity(0);
 
-        this.avgTimeDistanceLimit5LabelTotal.setDisable(true);
-        this.avgTimeDistanceLimit5LabelTotal.setOpacity(0);
+        avgTimeDistanceLimit5LabelTotal.setDisable(true);
+        avgTimeDistanceLimit5LabelTotal.setOpacity(0);
     }
 
     public void setAvgTimeDistance5LabelWithCompare(ResultsDTO firstValue, Float globalAvg, ResultsDTO compareValue) {
-        this.avgTimeDistanceLimit5Label.setText(firstValue.toString());
-        this.avgTimeDistanceLimit5LabelTotal.setText(" (" + globalAvg.toString() + ") ");
-        this.avgTimeDistanceLimit5LabelCompare.setText(compareValue.toString());
-
-        this.avgTimeDistanceLimit5LabelCompare.setDisable(false);
-        this.avgTimeDistanceLimit5LabelCompare.setOpacity(1);
-
-        this.avgTimeDistanceLimit5LabelTotal.setDisable(false);
-        this.avgTimeDistanceLimit5LabelTotal.setOpacity(1);
-        if (firstValue.getRes() < compareValue.getRes()) {
-            this.avgTimeDistanceLimit5Label.setStyle("-fx-text-fill: green;");
-            this.avgTimeDistanceLimit5LabelCompare.setStyle("-fx-text-fill: red;");
-        } else if (firstValue.getRes() > compareValue.getRes()) {
-            this.avgTimeDistanceLimit5Label.setStyle("-fx-text-fill: red;");
-            this.avgTimeDistanceLimit5LabelCompare.setStyle("-fx-text-fill: green;");
-        } else {
-            this.avgTimeDistanceLimit5Label.setStyle("-fx-text-fill: black;");
-            this.avgTimeDistanceLimit5LabelCompare.setStyle("-fx-text-fill: black;");
-        }
+        super.setAvgTimeDistance5LabelWithCompare(avgTimeDistanceLimit5Label,
+                avgTimeDistanceLimit5LabelCompare,
+                avgTimeDistanceLimit5LabelTotal,
+                firstValue,
+                globalAvg,
+                compareValue);
     }
 
     public void setAvgTimeDistanceLabel(String value) {
-        this.avgTimeDistanceLabel.setText(value);
-        this.avgTimeDistanceLabelCompare.setDisable(true);
-        this.avgTimeDistanceLabelCompare.setOpacity(0);
+        avgTimeDistanceLabel.setText(value);
+        avgTimeDistanceLabelCompare.setDisable(true);
+        avgTimeDistanceLabelCompare.setOpacity(0);
 
-        this.avgTimeDistanceLabelTotal.setDisable(true);
-        this.avgTimeDistanceLabelTotal.setOpacity(0);
+        avgTimeDistanceLabelTotal.setDisable(true);
+        avgTimeDistanceLabelTotal.setOpacity(0);
     }
 
     public void setAvgTimeDistanceLabel(ResultsDTO firstValue, Float globalAvg, ResultsDTO compareValue) {
-        this.avgTimeDistanceLabel.setText(firstValue.toString());
-        this.avgTimeDistanceLabelTotal.setText(" (" + globalAvg.toString() + ") ");
-        this.avgTimeDistanceLabelCompare.setText(compareValue.toString());
-
-        this.avgTimeDistanceLabelCompare.setDisable(false);
-        this.avgTimeDistanceLabelCompare.setOpacity(1);
-
-        this.avgTimeDistanceLabelTotal.setDisable(false);
-        this.avgTimeDistanceLabelTotal.setOpacity(1);
-        if (firstValue.getRes() < compareValue.getRes()) {
-            this.avgTimeDistanceLabel.setStyle("-fx-text-fill: green;");
-            this.avgTimeDistanceLabelCompare.setStyle("-fx-text-fill: red;");
-        } else if (firstValue.getRes() > compareValue.getRes()) {
-            this.avgTimeDistanceLabel.setStyle("-fx-text-fill: red;");
-            this.avgTimeDistanceLabelCompare.setStyle("-fx-text-fill: green;");
-        } else {
-            this.avgTimeDistanceLabel.setStyle("-fx-text-fill: black;");
-            this.avgTimeDistanceLabelCompare.setStyle("-fx-text-fill: black;");
-        }
+        super.setAvgTimeDistanceLabel(avgTimeDistanceLabel,
+                avgTimeDistanceLabelCompare,
+                avgTimeDistanceLabelTotal,
+                firstValue,
+                globalAvg,
+                compareValue);
     }
 
     public void setAvgTimeDistanceLimit10Label(String value) {
-        this.avgTimeDistanceLimit10Label.setText(value);
+        avgTimeDistanceLimit10Label.setText(value);
 
-        this.avgTimeDistanceLimit10LabelCompare.setDisable(true);
-        this.avgTimeDistanceLimit10LabelCompare.setOpacity(0);
+        avgTimeDistanceLimit10LabelCompare.setDisable(true);
+        avgTimeDistanceLimit10LabelCompare.setOpacity(0);
 
-        this.avgTimeDistanceLimit10LabelTotal.setDisable(true);
-        this.avgTimeDistanceLimit10LabelTotal.setOpacity(0);
+        avgTimeDistanceLimit10LabelTotal.setDisable(true);
+        avgTimeDistanceLimit10LabelTotal.setOpacity(0);
     }
 
     public void setAvgTimeDistanceLimit10Label(ResultsDTO firstValue, Float globalAvg, ResultsDTO compareValue) {
-        this.avgTimeDistanceLimit10Label.setText(firstValue.toString());
-        this.avgTimeDistanceLimit10LabelTotal.setText(" (" + globalAvg.toString() + ") ");
-        this.avgTimeDistanceLimit10LabelCompare.setText(compareValue.toString());
-
-        this.avgTimeDistanceLimit10LabelCompare.setDisable(false);
-        this.avgTimeDistanceLimit10LabelCompare.setOpacity(1);
-
-        this.avgTimeDistanceLimit10LabelTotal.setDisable(false);
-        this.avgTimeDistanceLimit10LabelTotal.setOpacity(1);
-        if (firstValue.getRes() < compareValue.getRes()) {
-            this.avgTimeDistanceLimit10Label.setStyle("-fx-text-fill: green;");
-            this.avgTimeDistanceLimit10LabelCompare.setStyle("-fx-text-fill: red;");
-        } else if (firstValue.getRes() > compareValue.getRes()) {
-            this.avgTimeDistanceLimit10Label.setStyle("-fx-text-fill: red;");
-            this.avgTimeDistanceLimit10LabelCompare.setStyle("-fx-text-fill: green;");
-        } else {
-            this.avgTimeDistanceLimit10Label.setStyle("-fx-text-fill: black;");
-            this.avgTimeDistanceLimit10LabelCompare.setStyle("-fx-text-fill: black;");
-        }
+        super.setAvgTimeDistanceLimit10Label(avgTimeDistanceLimit10Label,
+                avgTimeDistanceLimit10LabelCompare,
+                avgTimeDistanceLimit10LabelTotal,
+                firstValue,
+                globalAvg,
+                compareValue);
     }
 
     public void setAvgTimeDistanceLimit15Label(String value) {
-        this.avgTimeDistanceLimit15Label.setText(value);
+        avgTimeDistanceLimit15Label.setText(value);
 
-        this.avgTimeDistanceLimit15LabelCompare.setDisable(true);
-        this.avgTimeDistanceLimit15LabelCompare.setOpacity(0);
+        avgTimeDistanceLimit15LabelCompare.setDisable(true);
+        avgTimeDistanceLimit15LabelCompare.setOpacity(0);
 
-        this.avgTimeDistanceLimit15LabelTotal.setDisable(true);
-        this.avgTimeDistanceLimit15LabelTotal.setOpacity(0);
+        avgTimeDistanceLimit15LabelTotal.setDisable(true);
+        avgTimeDistanceLimit15LabelTotal.setOpacity(0);
     }
 
     public void setAvgTimeDistanceLimit15Label(ResultsDTO firstValue, Float globalAvg, ResultsDTO compareValue) {
-        this.avgTimeDistanceLimit15Label.setText(firstValue.toString());
-        this.avgTimeDistanceLimit15LabelTotal.setText(" (" + globalAvg.toString() + ") ");
-        this.avgTimeDistanceLimit15LabelCompare.setText(compareValue.toString());
-
-        this.avgTimeDistanceLimit15LabelCompare.setDisable(false);
-        this.avgTimeDistanceLimit15LabelCompare.setOpacity(1);
-
-        this.avgTimeDistanceLimit15LabelTotal.setDisable(false);
-        this.avgTimeDistanceLimit15LabelTotal.setOpacity(1);
-        if (firstValue.getRes() < compareValue.getRes()) {
-            this.avgTimeDistanceLimit15Label.setStyle("-fx-text-fill: green;");
-            this.avgTimeDistanceLimit15LabelCompare.setStyle("-fx-text-fill: red;");
-        } else if (firstValue.getRes() > compareValue.getRes()) {
-            this.avgTimeDistanceLimit15Label.setStyle("-fx-text-fill: red;");
-            this.avgTimeDistanceLimit15LabelCompare.setStyle("-fx-text-fill: green;");
-        } else {
-            this.avgTimeDistanceLimit15Label.setStyle("-fx-text-fill: black;");
-            this.avgTimeDistanceLimit15LabelCompare.setStyle("-fx-text-fill: black;");
-        }
+        super.setAvgTimeDistanceLimit15Label(avgTimeDistanceLimit15Label,
+                avgTimeDistanceLimit15LabelCompare,
+                avgTimeDistanceLimit15LabelTotal,
+                firstValue,
+                globalAvg,
+                compareValue);
     }
 
     public void setAvgPosition(String value) {
-        this.avgPosition.setText(value);
+        avgPosition.setText(value);
 
-        this.avgPositionCompare.setDisable(true);
-        this.avgPositionCompare.setOpacity(0);
+        avgPositionCompare.setDisable(true);
+        avgPositionCompare.setOpacity(0);
 
-        this.avgPositionVS.setDisable(true);
-        this.avgPositionVS.setOpacity(0);
+        avgPositionVS.setDisable(true);
+        avgPositionVS.setOpacity(0);
     }
 
     public void setAvgPosition(ResultsDTO firstValue, ResultsDTO compareValue) {
-        this.avgPosition.setText(firstValue.toString());
-        this.avgPositionCompare.setText(compareValue.toString());
-
-        this.avgPositionCompare.setDisable(false);
-        this.avgPositionCompare.setOpacity(1);
-
-        this.avgPositionVS.setDisable(false);
-        this.avgPositionVS.setOpacity(1);
-        if (firstValue.getRes() < compareValue.getRes()) {
-            this.avgPosition.setStyle("-fx-text-fill: green;");
-            this.avgPositionCompare.setStyle("-fx-text-fill: red;");
-        } else if (firstValue.getRes() > compareValue.getRes()) {
-            this.avgPosition.setStyle("-fx-text-fill: red;");
-            this.avgPositionCompare.setStyle("-fx-text-fill: green;");
-        } else {
-            this.avgPosition.setStyle("-fx-text-fill: black;");
-            this.avgPositionCompare.setStyle("-fx-text-fill: black;");
-        }
+        super.setAvgPosition(avgPosition, avgPositionCompare, avgPositionVS, firstValue, compareValue);
     }
 
     public void setAvgPositionLast5(String value) {
-        this.avgPositionLast5.setText(value);
+        avgPositionLast5.setText(value);
 
-        this.avgPositionLast5Compare.setDisable(true);
-        this.avgPositionLast5Compare.setOpacity(0);
+        avgPositionLast5Compare.setDisable(true);
+        avgPositionLast5Compare.setOpacity(0);
 
-        this.avgPositionLast5VS.setDisable(true);
-        this.avgPositionLast5VS.setOpacity(0);
+        avgPositionLast5VS.setDisable(true);
+        avgPositionLast5VS.setOpacity(0);
     }
 
     public void setAvgPositionLast5(ResultsDTO firstValue, ResultsDTO compareValue) {
-        this.avgPositionLast5.setText(firstValue.toString());
-        this.avgPositionLast5Compare.setText(compareValue.toString());
-
-        this.avgPositionLast5Compare.setDisable(false);
-        this.avgPositionLast5Compare.setOpacity(1);
-
-        this.avgPositionLast5VS.setDisable(false);
-        this.avgPositionLast5VS.setOpacity(1);
-        if (firstValue.getRes() < compareValue.getRes()) {
-            this.avgPositionLast5.setStyle("-fx-text-fill: green;");
-            this.avgPositionLast5Compare.setStyle("-fx-text-fill: red;");
-        } else if (firstValue.getRes() > compareValue.getRes()) {
-            this.avgPositionLast5.setStyle("-fx-text-fill: red;");
-            this.avgPositionLast5Compare.setStyle("-fx-text-fill: green;");
-        } else {
-            this.avgPositionLast5.setStyle("-fx-text-fill: black;");
-            this.avgPositionLast5Compare.setStyle("-fx-text-fill: black;");
-        }
+        super.setAvgPositionLast5(avgPositionLast5, avgPositionLast5Compare, avgPositionLast5VS, firstValue, compareValue);
     }
 
     public void setAvgPositionLast10(String value) {
-        this.avgPositionLast10.setText(value);
+        avgPositionLast10.setText(value);
 
-        this.avgPositionLast10Compare.setDisable(true);
-        this.avgPositionLast10Compare.setOpacity(0);
+        avgPositionLast10Compare.setDisable(true);
+        avgPositionLast10Compare.setOpacity(0);
 
-        this.avgPositionLast10VS.setDisable(true);
-        this.avgPositionLast10VS.setOpacity(0);
+        avgPositionLast10VS.setDisable(true);
+        avgPositionLast10VS.setOpacity(0);
     }
 
     public void setAvgPositionLast10(ResultsDTO firstValue, ResultsDTO compareValue) {
-        this.avgPositionLast10.setText(firstValue.toString());
-        this.avgPositionLast10Compare.setText(compareValue.toString());
-
-        this.avgPositionLast10Compare.setDisable(false);
-        this.avgPositionLast10Compare.setOpacity(1);
-
-        this.avgPositionLast10VS.setDisable(false);
-        this.avgPositionLast10VS.setOpacity(1);
-        if (firstValue.getRes() < compareValue.getRes()) {
-            this.avgPositionLast10.setStyle("-fx-text-fill: green;");
-            this.avgPositionLast10Compare.setStyle("-fx-text-fill: red;");
-        } else if (firstValue.getRes() > compareValue.getRes()) {
-            this.avgPositionLast10.setStyle("-fx-text-fill: red;");
-            this.avgPositionLast10Compare.setStyle("-fx-text-fill: green;");
-        } else {
-            this.avgPositionLast10.setStyle("-fx-text-fill: black;");
-            this.avgPositionLast10Compare.setStyle("-fx-text-fill: black;");
-        }
+        super.setAvgPositionLast10(avgPositionLast10, avgPositionLast10Compare, avgPositionLast10VS, firstValue, compareValue);
     }
 
     public void setAvgPositionLast15(String value) {
-        this.avgPositionLast15.setText(value);
+        avgPositionLast15.setText(value);
 
-        this.avgPositionLast15Compare.setDisable(true);
-        this.avgPositionLast15Compare.setOpacity(0);
+        avgPositionLast15Compare.setDisable(true);
+        avgPositionLast15Compare.setOpacity(0);
 
-        this.avgPositionLast15VS.setDisable(true);
-        this.avgPositionLast15VS.setOpacity(0);
+        avgPositionLast15VS.setDisable(true);
+        avgPositionLast15VS.setOpacity(0);
     }
 
     public void setAvgPositionLast15(ResultsDTO firstValue, ResultsDTO compareValue) {
-        this.avgPositionLast15.setText(firstValue.toString());
-        this.avgPositionLast15Compare.setText(compareValue.toString());
-
-        this.avgPositionLast15Compare.setDisable(false);
-        this.avgPositionLast15Compare.setOpacity(1);
-
-        this.avgPositionLast15VS.setDisable(false);
-        this.avgPositionLast15VS.setOpacity(1);
-        if (firstValue.getRes() < compareValue.getRes()) {
-            this.avgPositionLast15.setStyle("-fx-text-fill: green;");
-            this.avgPositionLast15Compare.setStyle("-fx-text-fill: red;");
-        } else if (firstValue.getRes() > compareValue.getRes()) {
-            this.avgPositionLast15.setStyle("-fx-text-fill: red;");
-            this.avgPositionLast15Compare.setStyle("-fx-text-fill: green;");
-        } else {
-            this.avgPositionLast15.setStyle("-fx-text-fill: black;");
-            this.avgPositionLast15Compare.setStyle("-fx-text-fill: black;");
-        }
+        super.setAvgPositionLast15(avgPositionLast15, avgPositionLast15Compare, avgPositionLast15VS, firstValue, compareValue);
     }
 
     public void setAvgPositionDistanceLast5(String value) {
-        this.avgPositionDistanceLast5.setText(value);
+        avgPositionDistanceLast5.setText(value);
 
-        this.avgPositionDistanceLast5Compare.setDisable(true);
-        this.avgPositionDistanceLast5Compare.setOpacity(0);
+        avgPositionDistanceLast5Compare.setDisable(true);
+        avgPositionDistanceLast5Compare.setOpacity(0);
 
-        this.avgPositionDistanceLast5VS.setDisable(true);
-        this.avgPositionDistanceLast5VS.setOpacity(0);
+        avgPositionDistanceLast5VS.setDisable(true);
+        avgPositionDistanceLast5VS.setOpacity(0);
     }
 
     public void setAvgPositionDistanceLast5(ResultsDTO firstValue, ResultsDTO compareValue) {
-        this.avgPositionDistanceLast5.setText(firstValue.toString());
-        this.avgPositionDistanceLast5Compare.setText(compareValue.toString());
-
-        this.avgPositionDistanceLast5Compare.setDisable(false);
-        this.avgPositionDistanceLast5Compare.setOpacity(1);
-
-        this.avgPositionDistanceLast5VS.setDisable(false);
-        this.avgPositionDistanceLast5VS.setOpacity(1);
-        if (firstValue.getRes() < compareValue.getRes()) {
-            this.avgPositionDistanceLast5.setStyle("-fx-text-fill: green;");
-            this.avgPositionDistanceLast5Compare.setStyle("-fx-text-fill: red;");
-        } else if (firstValue.getRes() > compareValue.getRes()) {
-            this.avgPositionDistanceLast5.setStyle("-fx-text-fill: red;");
-            this.avgPositionDistanceLast5Compare.setStyle("-fx-text-fill: green;");
-        } else {
-            this.avgPositionDistanceLast5.setStyle("-fx-text-fill: black;");
-            this.avgPositionDistanceLast5Compare.setStyle("-fx-text-fill: black;");
-        }
+        super.setAvgPositionDistanceLast5(avgPositionDistanceLast5,
+                avgPositionDistanceLast5Compare,
+                avgPositionDistanceLast5VS,
+                firstValue,
+                compareValue);
     }
 
     public void setAvgPositionDistanceLast10(String value) {
-        this.avgPositionDistanceLast10.setText(value);
+        avgPositionDistanceLast10.setText(value);
 
-        this.avgPositionDistanceLast10Compare.setDisable(true);
-        this.avgPositionDistanceLast10Compare.setOpacity(0);
+        avgPositionDistanceLast10Compare.setDisable(true);
+        avgPositionDistanceLast10Compare.setOpacity(0);
 
-        this.avgPositionDistanceLast10VS.setDisable(true);
-        this.avgPositionDistanceLast10VS.setOpacity(0);
+        avgPositionDistanceLast10VS.setDisable(true);
+        avgPositionDistanceLast10VS.setOpacity(0);
     }
 
     public void setAvgPositionDistanceLast10(ResultsDTO firstValue, ResultsDTO compareValue) {
-        this.avgPositionDistanceLast10.setText(firstValue.toString());
-        this.avgPositionDistanceLast10Compare.setText(compareValue.toString());
-
-        this.avgPositionDistanceLast10Compare.setDisable(false);
-        this.avgPositionDistanceLast10Compare.setOpacity(1);
-
-        this.avgPositionDistanceLast10VS.setDisable(false);
-        this.avgPositionDistanceLast10VS.setOpacity(1);
-        if (firstValue.getRes() < compareValue.getRes()) {
-            this.avgPositionDistanceLast10.setStyle("-fx-text-fill: green;");
-            this.avgPositionDistanceLast10Compare.setStyle("-fx-text-fill: red;");
-        } else if (firstValue.getRes() > compareValue.getRes()) {
-            this.avgPositionDistanceLast10.setStyle("-fx-text-fill: red;");
-            this.avgPositionDistanceLast10Compare.setStyle("-fx-text-fill: green;");
-        } else {
-            this.avgPositionDistanceLast10.setStyle("-fx-text-fill: black;");
-            this.avgPositionDistanceLast10Compare.setStyle("-fx-text-fill: black;");
-        }
+        super.setAvgPositionDistanceLast10(avgPositionDistanceLast10,
+                avgPositionDistanceLast10Compare,
+                avgPositionDistanceLast10VS,
+                firstValue,
+                compareValue);
     }
 
     public void setAvgPositionDistanceLast15(String value) {
-        this.avgPositionDistanceLast15.setText(value);
-
-        this.avgPositionDistanceLast15Compare.setDisable(true);
-        this.avgPositionDistanceLast15Compare.setOpacity(0);
-
-        this.avgPositionDistanceLast15VS.setDisable(true);
-        this.avgPositionDistanceLast15VS.setOpacity(0);
-    }
-
-    public void setAvgPositionDistanceLast15(ResultsDTO firstValue, ResultsDTO compareValue) {
-        this.avgPositionDistanceLast15.setText(firstValue.toString());
-        this.avgPositionDistanceLast15Compare.setText(compareValue.toString());
-
-        this.avgPositionDistanceLast15Compare.setDisable(false);
-        this.avgPositionDistanceLast15Compare.setOpacity(1);
-
-        this.avgPositionDistanceLast15VS.setDisable(false);
-        this.avgPositionDistanceLast15VS.setOpacity(1);
-        if (firstValue.getRes() < compareValue.getRes()) {
-            this.avgPositionDistanceLast15.setStyle("-fx-text-fill: green;");
-            this.avgPositionDistanceLast15Compare.setStyle("-fx-text-fill: red;");
-        } else if (firstValue.getRes() > compareValue.getRes()) {
-            this.avgPositionDistanceLast15.setStyle("-fx-text-fill: red;");
-            this.avgPositionDistanceLast15Compare.setStyle("-fx-text-fill: green;");
-        } else {
-            this.avgPositionDistanceLast15.setStyle("-fx-text-fill: black;");
-            this.avgPositionDistanceLast15Compare.setStyle("-fx-text-fill: black;");
-        }
+        avgPositionDistanceLast15.setText(value);
+
+        avgPositionDistanceLast15Compare.setDisable(true);
+        avgPositionDistanceLast15Compare.setOpacity(0);
+
+        avgPositionDistanceLast15VS.setDisable(true);
+        avgPositionDistanceLast15VS.setOpacity(0);
+    }
+
+    public void setAvgPositionDistanceLast15(ResultsDTO firstValue, ResultsDTO secondValue) {
+        super.setAvgPositionDistanceLast15(avgPositionDistanceLast15,
+                avgPositionDistanceLast15Compare,
+                avgPositionDistanceLast15VS,
+                firstValue,
+                secondValue);
     }
 }

+ 181 - 290
ATG/src/controllers/NewTab/EkipageController.java

@@ -8,12 +8,23 @@ import javafx.fxml.Initializable;
 import javafx.scene.control.Label;
 import objects.ResultsDTO;
 
-public class EkipageController implements Initializable {
+public class EkipageController extends MainContent implements Initializable {
 
     @FXML Label ekipageNameLabel;
     @FXML Label avgTimeLabel;
     @FXML Label avgTimeLabelTotal;
     @FXML Label avgTimeLabelCompare;
+
+    @FXML Label avgTimeLimit5Label;
+    @FXML Label avgTimeLimit5LabelTotal;
+    @FXML Label avgTimeLimit5LabelCompare;
+    @FXML Label avgTimeLimit10Label;
+    @FXML Label avgTimeLimit10LabelTotal;
+    @FXML Label avgTimeLimit10LabelCompare;
+    @FXML Label avgTimeLimit15Label;
+    @FXML Label avgTimeLimit15LabelTotal;
+    @FXML Label avgTimeLimit15LabelCompare;
+
     @FXML Label avgTimeDistanceLabel;
     @FXML Label avgTimeDistanceLabelTotal;
     @FXML Label avgTimeDistanceLabelCompare;
@@ -62,382 +73,262 @@ public class EkipageController implements Initializable {
     }
 
     public void setEkipageName(String name) {
-        this.ekipageNameLabel.setText(name);
+        ekipageNameLabel.setText(name);
     }
 
     public void setAvgTimeLabel(String value) {
-        this.avgTimeLabel.setText(value);
+        avgTimeLabel.setText(value);
 
-        this.avgTimeLabelCompare.setDisable(true);
-        this.avgTimeLabelCompare.setOpacity(0);
+        avgTimeLabelCompare.setDisable(true);
+        avgTimeLabelCompare.setOpacity(0);
 
-        this.avgTimeLabelTotal.setDisable(true);
-        this.avgTimeLabelTotal.setOpacity(0);
+        avgTimeLabelTotal.setDisable(true);
+        avgTimeLabelTotal.setOpacity(0);
     }
 
     public void setAvgTimeLabel(ResultsDTO firstValue, Float globalAvg, ResultsDTO compareValue) {
-        this.avgTimeLabel.setText(firstValue.toString());
-        this.avgTimeLabelTotal.setText(" (" + globalAvg.toString() + ") ");
-        this.avgTimeLabelCompare.setText(compareValue.toString());
-
-        this.avgTimeLabelCompare.setDisable(false);
-        this.avgTimeLabelCompare.setOpacity(1);
-
-        this.avgTimeLabelTotal.setDisable(false);
-        this.avgTimeLabelTotal.setOpacity(1);
-        if (firstValue.getRes() < compareValue.getRes()) {
-            this.avgTimeLabel.setStyle("-fx-text-fill: green;");
-            this.avgTimeLabelCompare.setStyle("-fx-text-fill: red;");
-        } else if (firstValue.getRes() > compareValue.getRes()) {
-            this.avgTimeLabel.setStyle("-fx-text-fill: red;");
-            this.avgTimeLabelCompare.setStyle("-fx-text-fill: green;");
-        } else {
-            this.avgTimeLabel.setStyle("-fx-text-fill: black;");
-            this.avgTimeLabelCompare.setStyle("-fx-text-fill: black;");
-        }
+        super.setAvgTimeLabel(avgTimeLabel, avgTimeLabelCompare, avgTimeLabelTotal, firstValue, globalAvg, compareValue);
     }
 
-    public void setAvgTimeDistanceLimit5Label(String value) {
-        this.avgTimeDistanceLimit5Label.setText(value);
+    public void setAvgTimeLimit5Label(ResultsDTO firstValue, Float globalAvg, ResultsDTO compareValue) {
+        super.setAvgTimeLimit5Label(avgTimeLimit5Label,
+                avgTimeLimit5LabelCompare,
+                avgTimeLimit5LabelTotal,
+                firstValue,
+                globalAvg,
+                compareValue);
+    }
 
-        this.avgTimeDistanceLimit5LabelCompare.setDisable(true);
-        this.avgTimeDistanceLimit5LabelCompare.setOpacity(0);
+    public void setAvgTimeLimit10Label(ResultsDTO firstValue, Float globalAvg, ResultsDTO compareValue) {
+        super.setAvgTimeLimit10Label(avgTimeLimit10Label,
+                avgTimeLimit10LabelCompare,
+                avgTimeLimit10LabelTotal,
+                firstValue,
+                globalAvg,
+                compareValue);
+    }
 
-        this.avgTimeDistanceLimit5LabelTotal.setDisable(true);
-        this.avgTimeDistanceLimit5LabelTotal.setOpacity(0);
+    public void setAvgTimeLimit15Label(ResultsDTO firstValue, Float globalAvg, ResultsDTO compareValue) {
+        super.setAvgTimeLimit15Label(avgTimeLimit15Label,
+                avgTimeLimit15LabelCompare,
+                avgTimeLimit15LabelTotal,
+                firstValue,
+                globalAvg,
+                compareValue);
     }
 
-    public void setAvgTimeDistance5LabelWithCompare(ResultsDTO firstValue, Float globalAvg, ResultsDTO compareValue) {
-        this.avgTimeDistanceLimit5Label.setText(firstValue.toString());
-        this.avgTimeDistanceLimit5LabelTotal.setText(" (" + globalAvg.toString() + ") ");
-        this.avgTimeDistanceLimit5LabelCompare.setText(compareValue.toString());
-
-        this.avgTimeDistanceLimit5LabelCompare.setDisable(false);
-        this.avgTimeDistanceLimit5LabelCompare.setOpacity(1);
-
-        this.avgTimeDistanceLimit5LabelTotal.setDisable(false);
-        this.avgTimeDistanceLimit5LabelTotal.setOpacity(1);
-        if (firstValue.getRes() < compareValue.getRes()) {
-            this.avgTimeDistanceLimit5Label.setStyle("-fx-text-fill: green;");
-            this.avgTimeDistanceLimit5LabelCompare.setStyle("-fx-text-fill: red;");
-        } else if (firstValue.getRes() > compareValue.getRes()) {
-            this.avgTimeDistanceLimit5Label.setStyle("-fx-text-fill: red;");
-            this.avgTimeDistanceLimit5LabelCompare.setStyle("-fx-text-fill: green;");
-        } else {
-            this.avgTimeDistanceLimit5Label.setStyle("-fx-text-fill: black;");
-            this.avgTimeDistanceLimit5LabelCompare.setStyle("-fx-text-fill: black;");
-        }
+    public void setAvgTimeLimit5Label(ResultsDTO value) {
+        avgTimeLimit5Label.setText(value.getRes() + "(" + value.getCount() + ")");
+
+        avgTimeLimit5LabelCompare.setDisable(true);
+        avgTimeLimit5LabelCompare.setOpacity(0);
+
+        avgTimeLimit5LabelTotal.setDisable(true);
+        avgTimeLimit5LabelTotal.setOpacity(0);
+    }
+
+    public void setAvgTimeLimit10Label(ResultsDTO value) {
+        avgTimeLimit10Label.setText(value.getRes() + "(" + value.getCount() + ")");
+
+        avgTimeLimit10LabelCompare.setDisable(true);
+        avgTimeLimit10LabelCompare.setOpacity(0);
+
+        avgTimeLimit10LabelTotal.setDisable(true);
+        avgTimeLimit10LabelTotal.setOpacity(0);
+    }
+
+    public void setAvgTimeLimit15Label(ResultsDTO value) {
+        avgTimeLimit15Label.setText(value.getRes() + "(" + value.getCount() + ")");
+
+        avgTimeLimit15LabelCompare.setDisable(true);
+        avgTimeLimit15LabelCompare.setOpacity(0);
+
+        avgTimeLimit15LabelTotal.setDisable(true);
+        avgTimeLimit15LabelTotal.setOpacity(0);
+    }
+
+    public void setAvgTimeDistanceLimit5Label(String value) {
+        avgTimeDistanceLimit5Label.setText(value);
+
+        avgTimeDistanceLimit5LabelCompare.setDisable(true);
+        avgTimeDistanceLimit5LabelCompare.setOpacity(0);
+
+        avgTimeDistanceLimit5LabelTotal.setDisable(true);
+        avgTimeDistanceLimit5LabelTotal.setOpacity(0);
     }
 
     public void setAvgTimeDistanceLabel(String value) {
-        this.avgTimeDistanceLabel.setText(value);
-        this.avgTimeDistanceLabelCompare.setDisable(true);
-        this.avgTimeDistanceLabelCompare.setOpacity(0);
+        avgTimeDistanceLabel.setText(value);
+        avgTimeDistanceLabelCompare.setDisable(true);
+        avgTimeDistanceLabelCompare.setOpacity(0);
 
-        this.avgTimeDistanceLabelTotal.setDisable(true);
-        this.avgTimeDistanceLabelTotal.setOpacity(0);
+        avgTimeDistanceLabelTotal.setDisable(true);
+        avgTimeDistanceLabelTotal.setOpacity(0);
+    }
+
+    public void setAvgTimeDistance5LabelWithCompare(ResultsDTO firstValue, Float globalAvg, ResultsDTO compareValue) {
+        super.setAvgTimeDistance5LabelWithCompare(avgTimeDistanceLimit5Label,
+                avgTimeDistanceLimit5LabelCompare,
+                avgTimeDistanceLimit5LabelTotal,
+                firstValue,
+                globalAvg,
+                compareValue);
     }
 
     public void setAvgTimeDistanceLabel(ResultsDTO firstValue, Float globalAvg, ResultsDTO compareValue) {
-        this.avgTimeDistanceLabel.setText(firstValue.toString());
-        this.avgTimeDistanceLabelTotal.setText(" (" + globalAvg.toString() + ") ");
-        this.avgTimeDistanceLabelCompare.setText(compareValue.toString());
-
-        this.avgTimeDistanceLabelCompare.setDisable(false);
-        this.avgTimeDistanceLabelCompare.setOpacity(1);
-
-        this.avgTimeDistanceLabelTotal.setDisable(false);
-        this.avgTimeDistanceLabelTotal.setOpacity(1);
-        if (firstValue.getRes() < compareValue.getRes()) {
-            this.avgTimeDistanceLabel.setStyle("-fx-text-fill: green;");
-            this.avgTimeDistanceLabelCompare.setStyle("-fx-text-fill: red;");
-        } else if (firstValue.getRes() > compareValue.getRes()) {
-            this.avgTimeDistanceLabel.setStyle("-fx-text-fill: red;");
-            this.avgTimeDistanceLabelCompare.setStyle("-fx-text-fill: green;");
-        } else {
-            this.avgTimeDistanceLabel.setStyle("-fx-text-fill: black;");
-            this.avgTimeDistanceLabelCompare.setStyle("-fx-text-fill: black;");
-        }
+        super.setAvgTimeDistanceLabel(avgTimeDistanceLabel,
+                avgTimeDistanceLabelCompare,
+                avgTimeDistanceLabelTotal,
+                firstValue,
+                globalAvg,
+                compareValue);
     }
 
     public void setAvgTimeDistanceLimit10Label(String value) {
-        this.avgTimeDistanceLimit10Label.setText(value);
+        avgTimeDistanceLimit10Label.setText(value);
 
-        this.avgTimeDistanceLimit10LabelCompare.setDisable(true);
-        this.avgTimeDistanceLimit10LabelCompare.setOpacity(0);
+        avgTimeDistanceLimit10LabelCompare.setDisable(true);
+        avgTimeDistanceLimit10LabelCompare.setOpacity(0);
 
-        this.avgTimeDistanceLimit10LabelTotal.setDisable(true);
-        this.avgTimeDistanceLimit10LabelTotal.setOpacity(0);
+        avgTimeDistanceLimit10LabelTotal.setDisable(true);
+        avgTimeDistanceLimit10LabelTotal.setOpacity(0);
     }
 
     public void setAvgTimeDistanceLimit10Label(ResultsDTO firstValue, Float globalAvg, ResultsDTO compareValue) {
-        this.avgTimeDistanceLimit10Label.setText(firstValue.toString());
-        this.avgTimeDistanceLimit10LabelTotal.setText(" (" + globalAvg.toString() + ") ");
-        this.avgTimeDistanceLimit10LabelCompare.setText(compareValue.toString());
-
-        this.avgTimeDistanceLimit10LabelCompare.setDisable(false);
-        this.avgTimeDistanceLimit10LabelCompare.setOpacity(1);
-
-        this.avgTimeDistanceLimit10LabelTotal.setDisable(false);
-        this.avgTimeDistanceLimit10LabelTotal.setOpacity(1);
-        if (firstValue.getRes() < compareValue.getRes()) {
-            this.avgTimeDistanceLimit10Label.setStyle("-fx-text-fill: green;");
-            this.avgTimeDistanceLimit10LabelCompare.setStyle("-fx-text-fill: red;");
-        } else if (firstValue.getRes() > compareValue.getRes()) {
-            this.avgTimeDistanceLimit10Label.setStyle("-fx-text-fill: red;");
-            this.avgTimeDistanceLimit10LabelCompare.setStyle("-fx-text-fill: green;");
-        } else {
-            this.avgTimeDistanceLimit10Label.setStyle("-fx-text-fill: black;");
-            this.avgTimeDistanceLimit10LabelCompare.setStyle("-fx-text-fill: black;");
-        }
+        super.setAvgTimeDistanceLimit10Label(avgTimeDistanceLimit10Label,
+                avgTimeDistanceLimit10LabelCompare,
+                avgTimeDistanceLimit10LabelTotal,
+                firstValue,
+                globalAvg,
+                compareValue);
     }
 
     public void setAvgTimeDistanceLimit15Label(String value) {
-        this.avgTimeDistanceLimit15Label.setText(value);
+        avgTimeDistanceLimit15Label.setText(value);
 
-        this.avgTimeDistanceLimit15LabelCompare.setDisable(true);
-        this.avgTimeDistanceLimit15LabelCompare.setOpacity(0);
+        avgTimeDistanceLimit15LabelCompare.setDisable(true);
+        avgTimeDistanceLimit15LabelCompare.setOpacity(0);
 
-        this.avgTimeDistanceLimit15LabelTotal.setDisable(true);
-        this.avgTimeDistanceLimit15LabelTotal.setOpacity(0);
+        avgTimeDistanceLimit15LabelTotal.setDisable(true);
+        avgTimeDistanceLimit15LabelTotal.setOpacity(0);
     }
 
     public void setAvgTimeDistanceLimit15Label(ResultsDTO firstValue, Float globalAvg, ResultsDTO compareValue) {
-        this.avgTimeDistanceLimit15Label.setText(firstValue.toString());
-        this.avgTimeDistanceLimit15LabelTotal.setText(" (" + globalAvg.toString() + ") ");
-        this.avgTimeDistanceLimit15LabelCompare.setText(compareValue.toString());
-
-        this.avgTimeDistanceLimit15LabelCompare.setDisable(false);
-        this.avgTimeDistanceLimit15LabelCompare.setOpacity(1);
-
-        this.avgTimeDistanceLimit15LabelTotal.setDisable(false);
-        this.avgTimeDistanceLimit15LabelTotal.setOpacity(1);
-        if (firstValue.getRes() < compareValue.getRes()) {
-            this.avgTimeDistanceLimit15Label.setStyle("-fx-text-fill: green;");
-            this.avgTimeDistanceLimit15LabelCompare.setStyle("-fx-text-fill: red;");
-        } else if (firstValue.getRes() > compareValue.getRes()) {
-            this.avgTimeDistanceLimit15Label.setStyle("-fx-text-fill: red;");
-            this.avgTimeDistanceLimit15LabelCompare.setStyle("-fx-text-fill: green;");
-        } else {
-            this.avgTimeDistanceLimit15Label.setStyle("-fx-text-fill: black;");
-            this.avgTimeDistanceLimit15LabelCompare.setStyle("-fx-text-fill: black;");
-        }
+        super.setAvgTimeDistanceLimit15Label(avgTimeDistanceLimit15Label,
+                avgTimeDistanceLimit15LabelCompare,
+                avgTimeDistanceLimit15LabelTotal,
+                firstValue,
+                globalAvg,
+                compareValue);
     }
 
     public void setAvgPosition(String value) {
-        this.avgPosition.setText(value);
+        avgPosition.setText(value);
 
-        this.avgPositionCompare.setDisable(true);
-        this.avgPositionCompare.setOpacity(0);
+        avgPositionCompare.setDisable(true);
+        avgPositionCompare.setOpacity(0);
 
-        this.avgPositionVS.setDisable(true);
-        this.avgPositionVS.setOpacity(0);
+        avgPositionVS.setDisable(true);
+        avgPositionVS.setOpacity(0);
     }
 
     public void setAvgPosition(ResultsDTO firstValue, ResultsDTO compareValue) {
-        this.avgPosition.setText(firstValue.toString());
-        this.avgPositionCompare.setText(compareValue.toString());
-
-        this.avgPositionCompare.setDisable(false);
-        this.avgPositionCompare.setOpacity(1);
-
-        this.avgPositionVS.setDisable(false);
-        this.avgPositionVS.setOpacity(1);
-        if (firstValue.getRes() < compareValue.getRes()) {
-            this.avgPosition.setStyle("-fx-text-fill: green;");
-            this.avgPositionCompare.setStyle("-fx-text-fill: red;");
-        } else if (firstValue.getRes() > compareValue.getRes()) {
-            this.avgPosition.setStyle("-fx-text-fill: red;");
-            this.avgPositionCompare.setStyle("-fx-text-fill: green;");
-        } else {
-            this.avgPosition.setStyle("-fx-text-fill: black;");
-            this.avgPositionCompare.setStyle("-fx-text-fill: black;");
-        }
+        super.setAvgPosition(avgPosition, avgPositionCompare, avgPositionVS, firstValue, compareValue);
     }
 
     public void setAvgPositionLast5(String value) {
-        this.avgPositionLast5.setText(value);
+        avgPositionLast5.setText(value);
 
-        this.avgPositionLast5Compare.setDisable(true);
-        this.avgPositionLast5Compare.setOpacity(0);
+        avgPositionLast5Compare.setDisable(true);
+        avgPositionLast5Compare.setOpacity(0);
 
-        this.avgPositionLast5VS.setDisable(true);
-        this.avgPositionLast5VS.setOpacity(0);
+        avgPositionLast5VS.setDisable(true);
+        avgPositionLast5VS.setOpacity(0);
     }
 
     public void setAvgPositionLast5(ResultsDTO firstValue, ResultsDTO compareValue) {
-        this.avgPositionLast5.setText(firstValue.toString());
-        this.avgPositionLast5Compare.setText(compareValue.toString());
-
-        this.avgPositionLast5Compare.setDisable(false);
-        this.avgPositionLast5Compare.setOpacity(1);
-
-        this.avgPositionLast5VS.setDisable(false);
-        this.avgPositionLast5VS.setOpacity(1);
-        if (firstValue.getRes() < compareValue.getRes()) {
-            this.avgPositionLast5.setStyle("-fx-text-fill: green;");
-            this.avgPositionLast5Compare.setStyle("-fx-text-fill: red;");
-        } else if (firstValue.getRes() > compareValue.getRes()) {
-            this.avgPositionLast5.setStyle("-fx-text-fill: red;");
-            this.avgPositionLast5Compare.setStyle("-fx-text-fill: green;");
-        } else {
-            this.avgPositionLast5.setStyle("-fx-text-fill: black;");
-            this.avgPositionLast5Compare.setStyle("-fx-text-fill: black;");
-        }
+        super.setAvgPositionLast5(avgPositionLast5, avgPositionLast5Compare, avgPositionLast5VS, firstValue, compareValue);
     }
 
     public void setAvgPositionLast10(String value) {
-        this.avgPositionLast10.setText(value);
+        avgPositionLast10.setText(value);
 
-        this.avgPositionLast10Compare.setDisable(true);
-        this.avgPositionLast10Compare.setOpacity(0);
+        avgPositionLast10Compare.setDisable(true);
+        avgPositionLast10Compare.setOpacity(0);
 
-        this.avgPositionLast10VS.setDisable(true);
-        this.avgPositionLast10VS.setOpacity(0);
+        avgPositionLast10VS.setDisable(true);
+        avgPositionLast10VS.setOpacity(0);
     }
 
     public void setAvgPositionLast10(ResultsDTO firstValue, ResultsDTO compareValue) {
-        this.avgPositionLast10.setText(firstValue.toString());
-        this.avgPositionLast10Compare.setText(compareValue.toString());
-
-        this.avgPositionLast10Compare.setDisable(false);
-        this.avgPositionLast10Compare.setOpacity(1);
-
-        this.avgPositionLast10VS.setDisable(false);
-        this.avgPositionLast10VS.setOpacity(1);
-        if (firstValue.getRes() < compareValue.getRes()) {
-            this.avgPositionLast10.setStyle("-fx-text-fill: green;");
-            this.avgPositionLast10Compare.setStyle("-fx-text-fill: red;");
-        } else if (firstValue.getRes() > compareValue.getRes()) {
-            this.avgPositionLast10.setStyle("-fx-text-fill: red;");
-            this.avgPositionLast10Compare.setStyle("-fx-text-fill: green;");
-        } else {
-            this.avgPositionLast10.setStyle("-fx-text-fill: black;");
-            this.avgPositionLast10Compare.setStyle("-fx-text-fill: black;");
-        }
+        super.setAvgPositionLast10(avgPositionLast10, avgPositionLast10Compare, avgPositionLast10VS, firstValue, compareValue);
     }
 
     public void setAvgPositionLast15(String value) {
-        this.avgPositionLast15.setText(value);
+        avgPositionLast15.setText(value);
 
-        this.avgPositionLast15Compare.setDisable(true);
-        this.avgPositionLast15Compare.setOpacity(0);
+        avgPositionLast15Compare.setDisable(true);
+        avgPositionLast15Compare.setOpacity(0);
 
-        this.avgPositionLast15VS.setDisable(true);
-        this.avgPositionLast15VS.setOpacity(0);
+        avgPositionLast15VS.setDisable(true);
+        avgPositionLast15VS.setOpacity(0);
     }
 
     public void setAvgPositionLast15(ResultsDTO firstValue, ResultsDTO compareValue) {
-        this.avgPositionLast15.setText(firstValue.toString());
-        this.avgPositionLast15Compare.setText(compareValue.toString());
-
-        this.avgPositionLast15Compare.setDisable(false);
-        this.avgPositionLast15Compare.setOpacity(1);
-
-        this.avgPositionLast15VS.setDisable(false);
-        this.avgPositionLast15VS.setOpacity(1);
-        if (firstValue.getRes() < compareValue.getRes()) {
-            this.avgPositionLast15.setStyle("-fx-text-fill: green;");
-            this.avgPositionLast15Compare.setStyle("-fx-text-fill: red;");
-        } else if (firstValue.getRes() > compareValue.getRes()) {
-            this.avgPositionLast15.setStyle("-fx-text-fill: red;");
-            this.avgPositionLast15Compare.setStyle("-fx-text-fill: green;");
-        } else {
-            this.avgPositionLast15.setStyle("-fx-text-fill: black;");
-            this.avgPositionLast15Compare.setStyle("-fx-text-fill: black;");
-        }
+        super.setAvgPositionLast15(avgPositionLast15, avgPositionLast15Compare, avgPositionLast15VS, firstValue, compareValue);
     }
 
     public void setAvgPositionDistanceLast5(String value) {
-        this.avgPositionDistanceLast5.setText(value);
+        avgPositionDistanceLast5.setText(value);
 
-        this.avgPositionDistanceLast5Compare.setDisable(true);
-        this.avgPositionDistanceLast5Compare.setOpacity(0);
+        avgPositionDistanceLast5Compare.setDisable(true);
+        avgPositionDistanceLast5Compare.setOpacity(0);
 
-        this.avgPositionDistanceLast5VS.setDisable(true);
-        this.avgPositionDistanceLast5VS.setOpacity(0);
+        avgPositionDistanceLast5VS.setDisable(true);
+        avgPositionDistanceLast5VS.setOpacity(0);
     }
 
     public void setAvgPositionDistanceLast5(ResultsDTO firstValue, ResultsDTO compareValue) {
-        this.avgPositionDistanceLast5.setText(firstValue.toString());
-        this.avgPositionDistanceLast5Compare.setText(compareValue.toString());
-
-        this.avgPositionDistanceLast5Compare.setDisable(false);
-        this.avgPositionDistanceLast5Compare.setOpacity(1);
-
-        this.avgPositionDistanceLast5VS.setDisable(false);
-        this.avgPositionDistanceLast5VS.setOpacity(1);
-        if (firstValue.getRes() < compareValue.getRes()) {
-            this.avgPositionDistanceLast5.setStyle("-fx-text-fill: green;");
-            this.avgPositionDistanceLast5Compare.setStyle("-fx-text-fill: red;");
-        } else if (firstValue.getRes() > compareValue.getRes()) {
-            this.avgPositionDistanceLast5.setStyle("-fx-text-fill: red;");
-            this.avgPositionDistanceLast5Compare.setStyle("-fx-text-fill: green;");
-        } else {
-            this.avgPositionDistanceLast5.setStyle("-fx-text-fill: black;");
-            this.avgPositionDistanceLast5Compare.setStyle("-fx-text-fill: black;");
-        }
+        super.setAvgPositionDistanceLast5(avgPositionDistanceLast5,
+                avgPositionDistanceLast5Compare,
+                avgPositionDistanceLast5VS,
+                firstValue,
+                compareValue);
     }
 
     public void setAvgPositionDistanceLast10(String value) {
-        this.avgPositionDistanceLast10.setText(value);
+        avgPositionDistanceLast10.setText(value);
 
-        this.avgPositionDistanceLast10Compare.setDisable(true);
-        this.avgPositionDistanceLast10Compare.setOpacity(0);
+        avgPositionDistanceLast10Compare.setDisable(true);
+        avgPositionDistanceLast10Compare.setOpacity(0);
 
-        this.avgPositionDistanceLast10VS.setDisable(true);
-        this.avgPositionDistanceLast10VS.setOpacity(0);
+        avgPositionDistanceLast10VS.setDisable(true);
+        avgPositionDistanceLast10VS.setOpacity(0);
     }
 
     public void setAvgPositionDistanceLast10(ResultsDTO firstValue, ResultsDTO compareValue) {
-        this.avgPositionDistanceLast10.setText(firstValue.toString());
-        this.avgPositionDistanceLast10Compare.setText(compareValue.toString());
-
-        this.avgPositionDistanceLast10Compare.setDisable(false);
-        this.avgPositionDistanceLast10Compare.setOpacity(1);
-
-        this.avgPositionDistanceLast10VS.setDisable(false);
-        this.avgPositionDistanceLast10VS.setOpacity(1);
-        if (firstValue.getRes() < compareValue.getRes()) {
-            this.avgPositionDistanceLast10.setStyle("-fx-text-fill: green;");
-            this.avgPositionDistanceLast10Compare.setStyle("-fx-text-fill: red;");
-        } else if (firstValue.getRes() > compareValue.getRes()) {
-            this.avgPositionDistanceLast10.setStyle("-fx-text-fill: red;");
-            this.avgPositionDistanceLast10Compare.setStyle("-fx-text-fill: green;");
-        } else {
-            this.avgPositionDistanceLast10.setStyle("-fx-text-fill: black;");
-            this.avgPositionDistanceLast10Compare.setStyle("-fx-text-fill: black;");
-        }
+        super.setAvgPositionDistanceLast10(avgPositionDistanceLast10,
+                avgPositionDistanceLast10Compare,
+                avgPositionDistanceLast10VS,
+                firstValue,
+                compareValue);
     }
 
     public void setAvgPositionDistanceLast15(String value) {
-        this.avgPositionDistanceLast15.setText(value);
-
-        this.avgPositionDistanceLast15Compare.setDisable(true);
-        this.avgPositionDistanceLast15Compare.setOpacity(0);
-
-        this.avgPositionDistanceLast15VS.setDisable(true);
-        this.avgPositionDistanceLast15VS.setOpacity(0);
-    }
-
-    public void setAvgPositionDistanceLast15(ResultsDTO firstValue, ResultsDTO compareValue) {
-        this.avgPositionDistanceLast15.setText(firstValue.toString());
-        this.avgPositionDistanceLast15Compare.setText(compareValue.toString());
-
-        this.avgPositionDistanceLast15Compare.setDisable(false);
-        this.avgPositionDistanceLast15Compare.setOpacity(1);
-
-        this.avgPositionDistanceLast15VS.setDisable(false);
-        this.avgPositionDistanceLast15VS.setOpacity(1);
-        if (firstValue.getRes() < compareValue.getRes()) {
-            this.avgPositionDistanceLast15.setStyle("-fx-text-fill: green;");
-            this.avgPositionDistanceLast15Compare.setStyle("-fx-text-fill: red;");
-        } else if (firstValue.getRes() > compareValue.getRes()) {
-            this.avgPositionDistanceLast15.setStyle("-fx-text-fill: red;");
-            this.avgPositionDistanceLast15Compare.setStyle("-fx-text-fill: green;");
-        } else {
-            this.avgPositionDistanceLast15.setStyle("-fx-text-fill: black;");
-            this.avgPositionDistanceLast15Compare.setStyle("-fx-text-fill: black;");
-        }
+        avgPositionDistanceLast15.setText(value);
+
+        avgPositionDistanceLast15Compare.setDisable(true);
+        avgPositionDistanceLast15Compare.setOpacity(0);
+
+        avgPositionDistanceLast15VS.setDisable(true);
+        avgPositionDistanceLast15VS.setOpacity(0);
+    }
+
+    public void setAvgPositionDistanceLast15(ResultsDTO firstValue, ResultsDTO secondValue) {
+        super.setAvgPositionDistanceLast15(avgPositionDistanceLast15,
+                avgPositionDistanceLast15Compare,
+                avgPositionDistanceLast15VS,
+                firstValue,
+                secondValue);
     }
 }

+ 179 - 288
ATG/src/controllers/NewTab/HorseController.java

@@ -8,12 +8,23 @@ import javafx.fxml.Initializable;
 import javafx.scene.control.Label;
 import objects.ResultsDTO;
 
-public class HorseController implements Initializable {
+public class HorseController extends MainContent implements Initializable {
 
     @FXML Label horseNameLabel;
     @FXML Label avgTimeLabel;
     @FXML Label avgTimeLabelTotal;
     @FXML Label avgTimeLabelCompare;
+
+    @FXML Label avgTimeLimit5Label;
+    @FXML Label avgTimeLimit5LabelTotal;
+    @FXML Label avgTimeLimit5LabelCompare;
+    @FXML Label avgTimeLimit10Label;
+    @FXML Label avgTimeLimit10LabelTotal;
+    @FXML Label avgTimeLimit10LabelCompare;
+    @FXML Label avgTimeLimit15Label;
+    @FXML Label avgTimeLimit15LabelTotal;
+    @FXML Label avgTimeLimit15LabelCompare;
+
     @FXML Label avgTimeDistanceLabel;
     @FXML Label avgTimeDistanceLabelTotal;
     @FXML Label avgTimeDistanceLabelCompare;
@@ -62,382 +73,262 @@ public class HorseController implements Initializable {
     }
 
     public void setHorseName(String name) {
-        this.horseNameLabel.setText(name);
+        horseNameLabel.setText(name);
     }
 
     public void setAvgTimeLabel(String value) {
-        this.avgTimeLabel.setText(value);
+        avgTimeLabel.setText(value);
 
-        this.avgTimeLabelCompare.setDisable(true);
-        this.avgTimeLabelCompare.setOpacity(0);
+        avgTimeLabelCompare.setDisable(true);
+        avgTimeLabelCompare.setOpacity(0);
 
-        this.avgTimeLabelTotal.setDisable(true);
-        this.avgTimeLabelTotal.setOpacity(0);
+        avgTimeLabelTotal.setDisable(true);
+        avgTimeLabelTotal.setOpacity(0);
     }
 
     public void setAvgTimeLabel(ResultsDTO firstValue, Float globalAvg, ResultsDTO compareValue) {
-        this.avgTimeLabel.setText(firstValue.toString());
-        this.avgTimeLabelTotal.setText(" (" + globalAvg.toString() + ") ");
-        this.avgTimeLabelCompare.setText(compareValue.toString());
-
-        this.avgTimeLabelCompare.setDisable(false);
-        this.avgTimeLabelCompare.setOpacity(1);
-
-        this.avgTimeLabelTotal.setDisable(false);
-        this.avgTimeLabelTotal.setOpacity(1);
-        if (firstValue.getRes() < compareValue.getRes()) {
-            this.avgTimeLabel.setStyle("-fx-text-fill: green;");
-            this.avgTimeLabelCompare.setStyle("-fx-text-fill: red;");
-        } else if (firstValue.getRes() > compareValue.getRes()) {
-            this.avgTimeLabel.setStyle("-fx-text-fill: red;");
-            this.avgTimeLabelCompare.setStyle("-fx-text-fill: green;");
-        } else {
-            this.avgTimeLabel.setStyle("-fx-text-fill: black;");
-            this.avgTimeLabelCompare.setStyle("-fx-text-fill: black;");
-        }
+        super.setAvgTimeLabel(avgTimeLabel, avgTimeLabelCompare, avgTimeLabelTotal, firstValue, globalAvg, compareValue);
+    }
+
+    public void setAvgTimeLimit5Label(ResultsDTO value) {
+        avgTimeLimit5Label.setText(value.getRes() + "(" + value.getCount() + ")");
+
+        avgTimeLimit5LabelCompare.setDisable(true);
+        avgTimeLimit5LabelCompare.setOpacity(0);
+
+        avgTimeLimit5LabelTotal.setDisable(true);
+        avgTimeLimit5LabelTotal.setOpacity(0);
+    }
+
+    public void setAvgTimeLimit10Label(ResultsDTO value) {
+        avgTimeLimit10Label.setText(value.getRes() + "(" + value.getCount() + ")");
+
+        avgTimeLimit10LabelCompare.setDisable(true);
+        avgTimeLimit10LabelCompare.setOpacity(0);
+
+        avgTimeLimit10LabelTotal.setDisable(true);
+        avgTimeLimit10LabelTotal.setOpacity(0);
+    }
+
+    public void setAvgTimeLimit15Label(ResultsDTO value) {
+        avgTimeLimit15Label.setText(value.getRes() + "(" + value.getCount() + ")");
+
+        avgTimeLimit15LabelCompare.setDisable(true);
+        avgTimeLimit15LabelCompare.setOpacity(0);
+
+        avgTimeLimit15LabelTotal.setDisable(true);
+        avgTimeLimit15LabelTotal.setOpacity(0);
+    }
+
+    public void setAvgTimeLimit5Label(ResultsDTO firstValue, Float globalAvg, ResultsDTO compareValue) {
+        super.setAvgTimeLimit5Label(avgTimeLimit5Label,
+                avgTimeLimit5LabelCompare,
+                avgTimeLimit5LabelTotal,
+                firstValue,
+                globalAvg,
+                compareValue);
+    }
+
+    public void setAvgTimeLimit10Label(ResultsDTO firstValue, Float globalAvg, ResultsDTO compareValue) {
+        super.setAvgTimeLimit10Label(avgTimeLimit10Label,
+                avgTimeLimit10LabelCompare,
+                avgTimeLimit10LabelTotal,
+                firstValue,
+                globalAvg,
+                compareValue);
+    }
+
+    public void setAvgTimeLimit15Label(ResultsDTO firstValue, Float globalAvg, ResultsDTO compareValue) {
+        super.setAvgTimeLimit15Label(avgTimeLimit15Label,
+                avgTimeLimit15LabelCompare,
+                avgTimeLimit15LabelTotal,
+                firstValue,
+                globalAvg,
+                compareValue);
     }
 
     public void setAvgTimeDistanceLimit5Label(String value) {
-        this.avgTimeDistanceLimit5Label.setText(value);
+        avgTimeDistanceLimit5Label.setText(value);
 
-        this.avgTimeDistanceLimit5LabelCompare.setDisable(true);
-        this.avgTimeDistanceLimit5LabelCompare.setOpacity(0);
+        avgTimeDistanceLimit5LabelCompare.setDisable(true);
+        avgTimeDistanceLimit5LabelCompare.setOpacity(0);
 
-        this.avgTimeDistanceLimit5LabelTotal.setDisable(true);
-        this.avgTimeDistanceLimit5LabelTotal.setOpacity(0);
+        avgTimeDistanceLimit5LabelTotal.setDisable(true);
+        avgTimeDistanceLimit5LabelTotal.setOpacity(0);
     }
 
     public void setAvgTimeDistance5LabelWithCompare(ResultsDTO firstValue, Float globalAvg, ResultsDTO compareValue) {
-        this.avgTimeDistanceLimit5Label.setText(firstValue.toString());
-        this.avgTimeDistanceLimit5LabelTotal.setText(" (" + globalAvg.toString() + ") ");
-        this.avgTimeDistanceLimit5LabelCompare.setText(compareValue.toString());
-
-        this.avgTimeDistanceLimit5LabelCompare.setDisable(false);
-        this.avgTimeDistanceLimit5LabelCompare.setOpacity(1);
-
-        this.avgTimeDistanceLimit5LabelTotal.setDisable(false);
-        this.avgTimeDistanceLimit5LabelTotal.setOpacity(1);
-        if (firstValue.getRes() < compareValue.getRes()) {
-            this.avgTimeDistanceLimit5Label.setStyle("-fx-text-fill: green;");
-            this.avgTimeDistanceLimit5LabelCompare.setStyle("-fx-text-fill: red;");
-        } else if (firstValue.getRes() > compareValue.getRes()) {
-            this.avgTimeDistanceLimit5Label.setStyle("-fx-text-fill: red;");
-            this.avgTimeDistanceLimit5LabelCompare.setStyle("-fx-text-fill: green;");
-        } else {
-            this.avgTimeDistanceLimit5Label.setStyle("-fx-text-fill: black;");
-            this.avgTimeDistanceLimit5LabelCompare.setStyle("-fx-text-fill: black;");
-        }
+        super.setAvgTimeDistance5LabelWithCompare(avgTimeDistanceLimit5Label,
+                avgTimeDistanceLimit5LabelCompare,
+                avgTimeDistanceLimit5LabelTotal,
+                firstValue,
+                globalAvg,
+                compareValue);
     }
 
     public void setAvgTimeDistanceLabel(String value) {
-        this.avgTimeDistanceLabel.setText(value);
-        this.avgTimeDistanceLabelCompare.setDisable(true);
-        this.avgTimeDistanceLabelCompare.setOpacity(0);
+        avgTimeDistanceLabel.setText(value);
+        avgTimeDistanceLabelCompare.setDisable(true);
+        avgTimeDistanceLabelCompare.setOpacity(0);
 
-        this.avgTimeDistanceLabelTotal.setDisable(true);
-        this.avgTimeDistanceLabelTotal.setOpacity(0);
+        avgTimeDistanceLabelTotal.setDisable(true);
+        avgTimeDistanceLabelTotal.setOpacity(0);
     }
 
     public void setAvgTimeDistanceLabel(ResultsDTO firstValue, Float globalAvg, ResultsDTO compareValue) {
-        this.avgTimeDistanceLabel.setText(firstValue.toString());
-        this.avgTimeDistanceLabelTotal.setText(" (" + globalAvg.toString() + ") ");
-        this.avgTimeDistanceLabelCompare.setText(compareValue.toString());
-
-        this.avgTimeDistanceLabelCompare.setDisable(false);
-        this.avgTimeDistanceLabelCompare.setOpacity(1);
-
-        this.avgTimeDistanceLabelTotal.setDisable(false);
-        this.avgTimeDistanceLabelTotal.setOpacity(1);
-        if (firstValue.getRes() < compareValue.getRes()) {
-            this.avgTimeDistanceLabel.setStyle("-fx-text-fill: green;");
-            this.avgTimeDistanceLabelCompare.setStyle("-fx-text-fill: red;");
-        } else if (firstValue.getRes() > compareValue.getRes()) {
-            this.avgTimeDistanceLabel.setStyle("-fx-text-fill: red;");
-            this.avgTimeDistanceLabelCompare.setStyle("-fx-text-fill: green;");
-        } else {
-            this.avgTimeDistanceLabel.setStyle("-fx-text-fill: black;");
-            this.avgTimeDistanceLabelCompare.setStyle("-fx-text-fill: black;");
-        }
+        super.setAvgTimeDistanceLabel(avgTimeDistanceLabel,
+                avgTimeDistanceLabelCompare,
+                avgTimeDistanceLabelTotal,
+                firstValue,
+                globalAvg,
+                compareValue);
     }
 
     public void setAvgTimeDistanceLimit10Label(String value) {
-        this.avgTimeDistanceLimit10Label.setText(value);
+        avgTimeDistanceLimit10Label.setText(value);
 
-        this.avgTimeDistanceLimit10LabelCompare.setDisable(true);
-        this.avgTimeDistanceLimit10LabelCompare.setOpacity(0);
+        avgTimeDistanceLimit10LabelCompare.setDisable(true);
+        avgTimeDistanceLimit10LabelCompare.setOpacity(0);
 
-        this.avgTimeDistanceLimit10LabelTotal.setDisable(true);
-        this.avgTimeDistanceLimit10LabelTotal.setOpacity(0);
+        avgTimeDistanceLimit10LabelTotal.setDisable(true);
+        avgTimeDistanceLimit10LabelTotal.setOpacity(0);
     }
 
     public void setAvgTimeDistanceLimit10Label(ResultsDTO firstValue, Float globalAvg, ResultsDTO compareValue) {
-        this.avgTimeDistanceLimit10Label.setText(firstValue.toString());
-        this.avgTimeDistanceLimit10LabelTotal.setText(" (" + globalAvg.toString() + ") ");
-        this.avgTimeDistanceLimit10LabelCompare.setText(compareValue.toString());
-
-        this.avgTimeDistanceLimit10LabelCompare.setDisable(false);
-        this.avgTimeDistanceLimit10LabelCompare.setOpacity(1);
-
-        this.avgTimeDistanceLimit10LabelTotal.setDisable(false);
-        this.avgTimeDistanceLimit10LabelTotal.setOpacity(1);
-        if (firstValue.getRes() < compareValue.getRes()) {
-            this.avgTimeDistanceLimit10Label.setStyle("-fx-text-fill: green;");
-            this.avgTimeDistanceLimit10LabelCompare.setStyle("-fx-text-fill: red;");
-        } else if (firstValue.getRes() > compareValue.getRes()) {
-            this.avgTimeDistanceLimit10Label.setStyle("-fx-text-fill: red;");
-            this.avgTimeDistanceLimit10LabelCompare.setStyle("-fx-text-fill: green;");
-        } else {
-            this.avgTimeDistanceLimit10Label.setStyle("-fx-text-fill: black;");
-            this.avgTimeDistanceLimit10LabelCompare.setStyle("-fx-text-fill: black;");
-        }
+        super.setAvgTimeDistanceLimit10Label(avgTimeDistanceLimit10Label,
+                avgTimeDistanceLimit10LabelCompare,
+                avgTimeDistanceLimit10LabelTotal,
+                firstValue,
+                globalAvg,
+                compareValue);
     }
 
     public void setAvgTimeDistanceLimit15Label(String value) {
-        this.avgTimeDistanceLimit15Label.setText(value);
+        avgTimeDistanceLimit15Label.setText(value);
 
-        this.avgTimeDistanceLimit15LabelCompare.setDisable(true);
-        this.avgTimeDistanceLimit15LabelCompare.setOpacity(0);
+        avgTimeDistanceLimit15LabelCompare.setDisable(true);
+        avgTimeDistanceLimit15LabelCompare.setOpacity(0);
 
-        this.avgTimeDistanceLimit15LabelTotal.setDisable(true);
-        this.avgTimeDistanceLimit15LabelTotal.setOpacity(0);
+        avgTimeDistanceLimit15LabelTotal.setDisable(true);
+        avgTimeDistanceLimit15LabelTotal.setOpacity(0);
     }
 
     public void setAvgTimeDistanceLimit15Label(ResultsDTO firstValue, Float globalAvg, ResultsDTO compareValue) {
-        this.avgTimeDistanceLimit15Label.setText(firstValue.toString());
-        this.avgTimeDistanceLimit15LabelTotal.setText(" (" + globalAvg.toString() + ") ");
-        this.avgTimeDistanceLimit15LabelCompare.setText(compareValue.toString());
-
-        this.avgTimeDistanceLimit15LabelCompare.setDisable(false);
-        this.avgTimeDistanceLimit15LabelCompare.setOpacity(1);
-
-        this.avgTimeDistanceLimit15LabelTotal.setDisable(false);
-        this.avgTimeDistanceLimit15LabelTotal.setOpacity(1);
-        if (firstValue.getRes() < compareValue.getRes()) {
-            this.avgTimeDistanceLimit15Label.setStyle("-fx-text-fill: green;");
-            this.avgTimeDistanceLimit15LabelCompare.setStyle("-fx-text-fill: red;");
-        } else if (firstValue.getRes() > compareValue.getRes()) {
-            this.avgTimeDistanceLimit15Label.setStyle("-fx-text-fill: red;");
-            this.avgTimeDistanceLimit15LabelCompare.setStyle("-fx-text-fill: green;");
-        } else {
-            this.avgTimeDistanceLimit15Label.setStyle("-fx-text-fill: black;");
-            this.avgTimeDistanceLimit15LabelCompare.setStyle("-fx-text-fill: black;");
-        }
+        super.setAvgTimeDistanceLimit15Label(avgTimeDistanceLimit15Label,
+                avgTimeDistanceLimit15LabelCompare,
+                avgTimeDistanceLimit15LabelTotal,
+                firstValue,
+                globalAvg,
+                compareValue);
     }
 
     public void setAvgPosition(String value) {
-        this.avgPosition.setText(value);
+        avgPosition.setText(value);
 
-        this.avgPositionCompare.setDisable(true);
-        this.avgPositionCompare.setOpacity(0);
+        avgPositionCompare.setDisable(true);
+        avgPositionCompare.setOpacity(0);
 
-        this.avgPositionVS.setDisable(true);
-        this.avgPositionVS.setOpacity(0);
+        avgPositionVS.setDisable(true);
+        avgPositionVS.setOpacity(0);
     }
 
     public void setAvgPosition(ResultsDTO firstValue, ResultsDTO compareValue) {
-        this.avgPosition.setText(firstValue.toString());
-        this.avgPositionCompare.setText(compareValue.toString());
-
-        this.avgPositionCompare.setDisable(false);
-        this.avgPositionCompare.setOpacity(1);
-
-        this.avgPositionVS.setDisable(false);
-        this.avgPositionVS.setOpacity(1);
-        if (firstValue.getRes() < compareValue.getRes()) {
-            this.avgPosition.setStyle("-fx-text-fill: green;");
-            this.avgPositionCompare.setStyle("-fx-text-fill: red;");
-        } else if (firstValue.getRes() > compareValue.getRes()) {
-            this.avgPosition.setStyle("-fx-text-fill: red;");
-            this.avgPositionCompare.setStyle("-fx-text-fill: green;");
-        } else {
-            this.avgPosition.setStyle("-fx-text-fill: black;");
-            this.avgPositionCompare.setStyle("-fx-text-fill: black;");
-        }
+        super.setAvgPosition(avgPosition, avgPositionCompare, avgPositionVS, firstValue, compareValue);
     }
 
     public void setAvgPositionLast5(String value) {
-        this.avgPositionLast5.setText(value);
+        avgPositionLast5.setText(value);
 
-        this.avgPositionLast5Compare.setDisable(true);
-        this.avgPositionLast5Compare.setOpacity(0);
+        avgPositionLast5Compare.setDisable(true);
+        avgPositionLast5Compare.setOpacity(0);
 
-        this.avgPositionLast5VS.setDisable(true);
-        this.avgPositionLast5VS.setOpacity(0);
+        avgPositionLast5VS.setDisable(true);
+        avgPositionLast5VS.setOpacity(0);
     }
 
     public void setAvgPositionLast5(ResultsDTO firstValue, ResultsDTO compareValue) {
-        this.avgPositionLast5.setText(firstValue.toString());
-        this.avgPositionLast5Compare.setText(compareValue.toString());
-
-        this.avgPositionLast5Compare.setDisable(false);
-        this.avgPositionLast5Compare.setOpacity(1);
-
-        this.avgPositionLast5VS.setDisable(false);
-        this.avgPositionLast5VS.setOpacity(1);
-        if (firstValue.getRes() < compareValue.getRes()) {
-            this.avgPositionLast5.setStyle("-fx-text-fill: green;");
-            this.avgPositionLast5Compare.setStyle("-fx-text-fill: red;");
-        } else if (firstValue.getRes() > compareValue.getRes()) {
-            this.avgPositionLast5.setStyle("-fx-text-fill: red;");
-            this.avgPositionLast5Compare.setStyle("-fx-text-fill: green;");
-        } else {
-            this.avgPositionLast5.setStyle("-fx-text-fill: black;");
-            this.avgPositionLast5Compare.setStyle("-fx-text-fill: black;");
-        }
+        super.setAvgPositionLast5(avgPositionLast5, avgPositionLast5Compare, avgPositionLast5VS, firstValue, compareValue);
     }
 
     public void setAvgPositionLast10(String value) {
-        this.avgPositionLast10.setText(value);
+        avgPositionLast10.setText(value);
 
-        this.avgPositionLast10Compare.setDisable(true);
-        this.avgPositionLast10Compare.setOpacity(0);
+        avgPositionLast10Compare.setDisable(true);
+        avgPositionLast10Compare.setOpacity(0);
 
-        this.avgPositionLast10VS.setDisable(true);
-        this.avgPositionLast10VS.setOpacity(0);
+        avgPositionLast10VS.setDisable(true);
+        avgPositionLast10VS.setOpacity(0);
     }
 
     public void setAvgPositionLast10(ResultsDTO firstValue, ResultsDTO compareValue) {
-        this.avgPositionLast10.setText(firstValue.toString());
-        this.avgPositionLast10Compare.setText(compareValue.toString());
-
-        this.avgPositionLast10Compare.setDisable(false);
-        this.avgPositionLast10Compare.setOpacity(1);
-
-        this.avgPositionLast10VS.setDisable(false);
-        this.avgPositionLast10VS.setOpacity(1);
-        if (firstValue.getRes() < compareValue.getRes()) {
-            this.avgPositionLast10.setStyle("-fx-text-fill: green;");
-            this.avgPositionLast10Compare.setStyle("-fx-text-fill: red;");
-        } else if (firstValue.getRes() > compareValue.getRes()) {
-            this.avgPositionLast10.setStyle("-fx-text-fill: red;");
-            this.avgPositionLast10Compare.setStyle("-fx-text-fill: green;");
-        } else {
-            this.avgPositionLast10.setStyle("-fx-text-fill: black;");
-            this.avgPositionLast10Compare.setStyle("-fx-text-fill: black;");
-        }
+        super.setAvgPositionLast10(avgPositionLast10, avgPositionLast10Compare, avgPositionLast10VS, firstValue, compareValue);
     }
 
     public void setAvgPositionLast15(String value) {
-        this.avgPositionLast15.setText(value);
+        avgPositionLast15.setText(value);
 
-        this.avgPositionLast15Compare.setDisable(true);
-        this.avgPositionLast15Compare.setOpacity(0);
+        avgPositionLast15Compare.setDisable(true);
+        avgPositionLast15Compare.setOpacity(0);
 
-        this.avgPositionLast15VS.setDisable(true);
-        this.avgPositionLast15VS.setOpacity(0);
+        avgPositionLast15VS.setDisable(true);
+        avgPositionLast15VS.setOpacity(0);
     }
 
     public void setAvgPositionLast15(ResultsDTO firstValue, ResultsDTO compareValue) {
-        this.avgPositionLast15.setText(firstValue.toString());
-        this.avgPositionLast15Compare.setText(compareValue.toString());
-
-        this.avgPositionLast15Compare.setDisable(false);
-        this.avgPositionLast15Compare.setOpacity(1);
-
-        this.avgPositionLast15VS.setDisable(false);
-        this.avgPositionLast15VS.setOpacity(1);
-        if (firstValue.getRes() < compareValue.getRes()) {
-            this.avgPositionLast15.setStyle("-fx-text-fill: green;");
-            this.avgPositionLast15Compare.setStyle("-fx-text-fill: red;");
-        } else if (firstValue.getRes() > compareValue.getRes()) {
-            this.avgPositionLast15.setStyle("-fx-text-fill: red;");
-            this.avgPositionLast15Compare.setStyle("-fx-text-fill: green;");
-        } else {
-            this.avgPositionLast15.setStyle("-fx-text-fill: black;");
-            this.avgPositionLast15Compare.setStyle("-fx-text-fill: black;");
-        }
+        super.setAvgPositionLast15(avgPositionLast15, avgPositionLast15Compare, avgPositionLast15VS, firstValue, compareValue);
     }
 
     public void setAvgPositionDistanceLast5(String value) {
-        this.avgPositionDistanceLast5.setText(value);
+        avgPositionDistanceLast5.setText(value);
 
-        this.avgPositionDistanceLast5Compare.setDisable(true);
-        this.avgPositionDistanceLast5Compare.setOpacity(0);
+        avgPositionDistanceLast5Compare.setDisable(true);
+        avgPositionDistanceLast5Compare.setOpacity(0);
 
-        this.avgPositionDistanceLast5VS.setDisable(true);
-        this.avgPositionDistanceLast5VS.setOpacity(0);
+        avgPositionDistanceLast5VS.setDisable(true);
+        avgPositionDistanceLast5VS.setOpacity(0);
     }
 
     public void setAvgPositionDistanceLast5(ResultsDTO firstValue, ResultsDTO compareValue) {
-        this.avgPositionDistanceLast5.setText(firstValue.toString());
-        this.avgPositionDistanceLast5Compare.setText(compareValue.toString());
-
-        this.avgPositionDistanceLast5Compare.setDisable(false);
-        this.avgPositionDistanceLast5Compare.setOpacity(1);
-
-        this.avgPositionDistanceLast5VS.setDisable(false);
-        this.avgPositionDistanceLast5VS.setOpacity(1);
-        if (firstValue.getRes() < compareValue.getRes()) {
-            this.avgPositionDistanceLast5.setStyle("-fx-text-fill: green;");
-            this.avgPositionDistanceLast5Compare.setStyle("-fx-text-fill: red;");
-        } else if (firstValue.getRes() > compareValue.getRes()) {
-            this.avgPositionDistanceLast5.setStyle("-fx-text-fill: red;");
-            this.avgPositionDistanceLast5Compare.setStyle("-fx-text-fill: green;");
-        } else {
-            this.avgPositionDistanceLast5.setStyle("-fx-text-fill: black;");
-            this.avgPositionDistanceLast5Compare.setStyle("-fx-text-fill: black;");
-        }
+        super.setAvgPositionDistanceLast5(avgPositionDistanceLast5,
+                avgPositionDistanceLast5Compare,
+                avgPositionDistanceLast5VS,
+                firstValue,
+                compareValue);
     }
 
     public void setAvgPositionDistanceLast10(String value) {
-        this.avgPositionDistanceLast10.setText(value);
+        avgPositionDistanceLast10.setText(value);
 
-        this.avgPositionDistanceLast10Compare.setDisable(true);
-        this.avgPositionDistanceLast10Compare.setOpacity(0);
+        avgPositionDistanceLast10Compare.setDisable(true);
+        avgPositionDistanceLast10Compare.setOpacity(0);
 
-        this.avgPositionDistanceLast10VS.setDisable(true);
-        this.avgPositionDistanceLast10VS.setOpacity(0);
+        avgPositionDistanceLast10VS.setDisable(true);
+        avgPositionDistanceLast10VS.setOpacity(0);
     }
 
     public void setAvgPositionDistanceLast10(ResultsDTO firstValue, ResultsDTO compareValue) {
-        this.avgPositionDistanceLast10.setText(firstValue.toString());
-        this.avgPositionDistanceLast10Compare.setText(compareValue.toString());
-
-        this.avgPositionDistanceLast10Compare.setDisable(false);
-        this.avgPositionDistanceLast10Compare.setOpacity(1);
-
-        this.avgPositionDistanceLast10VS.setDisable(false);
-        this.avgPositionDistanceLast10VS.setOpacity(1);
-        if (firstValue.getRes() < compareValue.getRes()) {
-            this.avgPositionDistanceLast10.setStyle("-fx-text-fill: green;");
-            this.avgPositionDistanceLast10Compare.setStyle("-fx-text-fill: red;");
-        } else if (firstValue.getRes() > compareValue.getRes()) {
-            this.avgPositionDistanceLast10.setStyle("-fx-text-fill: red;");
-            this.avgPositionDistanceLast10Compare.setStyle("-fx-text-fill: green;");
-        } else {
-            this.avgPositionDistanceLast10.setStyle("-fx-text-fill: black;");
-            this.avgPositionDistanceLast10Compare.setStyle("-fx-text-fill: black;");
-        }
+        super.setAvgPositionDistanceLast10(avgPositionDistanceLast10,
+                avgPositionDistanceLast10Compare,
+                avgPositionDistanceLast10VS,
+                firstValue,
+                compareValue);
     }
 
     public void setAvgPositionDistanceLast15(String value) {
-        this.avgPositionDistanceLast15.setText(value);
-
-        this.avgPositionDistanceLast15Compare.setDisable(true);
-        this.avgPositionDistanceLast15Compare.setOpacity(0);
-
-        this.avgPositionDistanceLast15VS.setDisable(true);
-        this.avgPositionDistanceLast15VS.setOpacity(0);
-    }
-
-    public void setAvgPositionDistanceLast15(ResultsDTO firstValue, ResultsDTO compareValue) {
-        this.avgPositionDistanceLast15.setText(firstValue.toString());
-        this.avgPositionDistanceLast15Compare.setText(compareValue.toString());
-
-        this.avgPositionDistanceLast15Compare.setDisable(false);
-        this.avgPositionDistanceLast15Compare.setOpacity(1);
-
-        this.avgPositionDistanceLast15VS.setDisable(false);
-        this.avgPositionDistanceLast15VS.setOpacity(1);
-        if (firstValue.getRes() < compareValue.getRes()) {
-            this.avgPositionDistanceLast15.setStyle("-fx-text-fill: green;");
-            this.avgPositionDistanceLast15Compare.setStyle("-fx-text-fill: red;");
-        } else if (firstValue.getRes() > compareValue.getRes()) {
-            this.avgPositionDistanceLast15.setStyle("-fx-text-fill: red;");
-            this.avgPositionDistanceLast15Compare.setStyle("-fx-text-fill: green;");
-        } else {
-            this.avgPositionDistanceLast15.setStyle("-fx-text-fill: black;");
-            this.avgPositionDistanceLast15Compare.setStyle("-fx-text-fill: black;");
-        }
+        avgPositionDistanceLast15.setText(value);
+
+        avgPositionDistanceLast15Compare.setDisable(true);
+        avgPositionDistanceLast15Compare.setOpacity(0);
+
+        avgPositionDistanceLast15VS.setDisable(true);
+        avgPositionDistanceLast15VS.setOpacity(0);
+    }
+
+    public void setAvgPositionDistanceLast15(ResultsDTO firstValue, ResultsDTO secondValue) {
+        super.setAvgPositionDistanceLast15(avgPositionDistanceLast15,
+                avgPositionDistanceLast15Compare,
+                avgPositionDistanceLast15VS,
+                firstValue,
+                secondValue);
     }
 }

+ 444 - 3
ATG/src/controllers/NewTab/MainContent.java

@@ -10,14 +10,20 @@ import com.google.common.collect.Lists;
 
 import javafx.fxml.FXML;
 import javafx.fxml.Initializable;
+import javafx.scene.control.Button;
+import javafx.scene.control.Label;
 import javafx.scene.control.TabPane;
 import javafx.scene.layout.Pane;
+import javafx.scene.layout.VBox;
 import objects.HorseRaceData;
 import objects.NewTabRaceTableView;
+import objects.ResultsDTO;
 
 public class MainContent implements Initializable {
 
     @FXML TabPane mainNewTabTableView;
+    @FXML VBox BetOnContent;
+    @FXML Button SubmitBongButton;
 
     @FXML Pane kuskPanel;
     @FXML Pane horsePanel;
@@ -36,14 +42,449 @@ public class MainContent implements Initializable {
         final List<String> tracks = data.stream().map(m -> m.getTrackName()).distinct().collect(Collectors.toList());
         mainNewTabTableView.getTabs().clear();
         for (final String t : tracks) {
-            final SimpleEntry<String, List<HorseRaceData>> trackRaces = new SimpleEntry<String,List<HorseRaceData>>(t,
-                    data.stream().filter(p -> p.getTrackName().equals(t)).collect(Collectors.toList()));
+            final SimpleEntry<String, List<HorseRaceData>> trackRaces
+                    = new SimpleEntry<>(t, data.stream().filter(p -> p.getTrackName().equals(t)).collect(Collectors.toList()));
             racesByTrack.add(trackRaces);
-            mainNewTabTableView.getTabs().add(new NewTabRaceTableView(trackRaces));
+            final NewTabRaceTableView newTabRaceTableView = new NewTabRaceTableView(trackRaces);
+            newTabRaceTableView.setBongObject(BetOnContent);
+            mainNewTabTableView.getTabs().add(newTabRaceTableView);
         }
     }
 
     public static MainContent getThis() {
         return mainContent;
     }
+
+    @FXML
+    void SubmitBongAction() {
+
+    }
+
+    public void setAvgTimeLabel(Label firstLabel, Label secondLabel, Label middleText, ResultsDTO firstValue, Float globalAvg,
+            ResultsDTO compareValue) {
+        firstLabel.setText(firstValue.toString());
+        middleText.setText(" (" + globalAvg.toString() + ") ");
+        secondLabel.setText(compareValue.toString());
+
+        secondLabel.setDisable(false);
+        secondLabel.setOpacity(1);
+
+        middleText.setDisable(false);
+        middleText.setOpacity(1);
+        if (firstValue.getRes() < compareValue.getRes() && firstValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: green;");
+            secondLabel.setStyle("-fx-text-fill: red;");
+        } else if (firstValue.getRes() > compareValue.getRes() && compareValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: red;");
+            secondLabel.setStyle("-fx-text-fill: green;");
+        } else if (firstValue.getRes() == 0f && compareValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: black;");
+            secondLabel.setStyle("-fx-text-fill: green;");
+        } else if (firstValue.getRes() > 0f && compareValue.getRes() == 0f) {
+            firstLabel.setStyle("-fx-text-fill: green;");
+            secondLabel.setStyle("-fx-text-fill: black;");
+        } else {
+            firstLabel.setStyle("-fx-text-fill: black;");
+            secondLabel.setStyle("-fx-text-fill: black;");
+        }
+    }
+
+    public void setAvgTimeLimit5Label(Label firstLabel, Label secondLabel, Label middleText, ResultsDTO firstValue,
+            Float globalAvg, ResultsDTO compareValue) {
+        firstLabel.setText(firstValue.toString());
+        middleText.setText(" (" + globalAvg.toString() + ") ");
+        secondLabel.setText(compareValue.toString());
+
+        secondLabel.setDisable(false);
+        secondLabel.setOpacity(1);
+
+        middleText.setDisable(false);
+        middleText.setOpacity(1);
+        if (firstValue.getRes() < compareValue.getRes() && firstValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: green;");
+            secondLabel.setStyle("-fx-text-fill: red;");
+        } else if (firstValue.getRes() > compareValue.getRes() && compareValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: red;");
+            secondLabel.setStyle("-fx-text-fill: green;");
+        } else if (firstValue.getRes() == 0f && compareValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: black;");
+            secondLabel.setStyle("-fx-text-fill: green;");
+        } else if (firstValue.getRes() > 0f && compareValue.getRes() == 0f) {
+            firstLabel.setStyle("-fx-text-fill: green;");
+            secondLabel.setStyle("-fx-text-fill: black;");
+        } else {
+            firstLabel.setStyle("-fx-text-fill: black;");
+            secondLabel.setStyle("-fx-text-fill: black;");
+        }
+    }
+
+    public void setAvgTimeLimit10Label(Label firstLabel, Label secondLabel, Label middleText, ResultsDTO firstValue,
+            Float globalAvg, ResultsDTO compareValue) {
+        firstLabel.setText(firstValue.toString());
+        middleText.setText(" (" + globalAvg.toString() + ") ");
+        secondLabel.setText(compareValue.toString());
+
+        secondLabel.setDisable(false);
+        secondLabel.setOpacity(1);
+
+        middleText.setDisable(false);
+        middleText.setOpacity(1);
+        if (firstValue.getRes() < compareValue.getRes() && firstValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: green;");
+            secondLabel.setStyle("-fx-text-fill: red;");
+        } else if (firstValue.getRes() > compareValue.getRes() && compareValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: red;");
+            secondLabel.setStyle("-fx-text-fill: green;");
+        } else if (firstValue.getRes() == 0f && compareValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: black;");
+            secondLabel.setStyle("-fx-text-fill: green;");
+        } else if (firstValue.getRes() > 0f && compareValue.getRes() == 0f) {
+            firstLabel.setStyle("-fx-text-fill: green;");
+            secondLabel.setStyle("-fx-text-fill: black;");
+        } else {
+            firstLabel.setStyle("-fx-text-fill: black;");
+            secondLabel.setStyle("-fx-text-fill: black;");
+        }
+    }
+
+    public void setAvgTimeLimit15Label(Label firstLabel, Label secondLabel, Label middleText, ResultsDTO firstValue,
+            Float globalAvg, ResultsDTO compareValue) {
+        firstLabel.setText(firstValue.toString());
+        middleText.setText(" (" + globalAvg.toString() + ") ");
+        secondLabel.setText(compareValue.toString());
+
+        secondLabel.setDisable(false);
+        secondLabel.setOpacity(1);
+
+        middleText.setDisable(false);
+        middleText.setOpacity(1);
+        if (firstValue.getRes() < compareValue.getRes() && firstValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: green;");
+            secondLabel.setStyle("-fx-text-fill: red;");
+        } else if (firstValue.getRes() > compareValue.getRes() && compareValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: red;");
+            secondLabel.setStyle("-fx-text-fill: green;");
+        } else if (firstValue.getRes() == 0f && compareValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: black;");
+            secondLabel.setStyle("-fx-text-fill: green;");
+        } else if (firstValue.getRes() > 0f && compareValue.getRes() == 0f) {
+            firstLabel.setStyle("-fx-text-fill: green;");
+            secondLabel.setStyle("-fx-text-fill: black;");
+        } else {
+            firstLabel.setStyle("-fx-text-fill: black;");
+            secondLabel.setStyle("-fx-text-fill: black;");
+        }
+    }
+
+    public void setAvgTimeDistanceLabel(Label firstLabel, Label secondLabel, Label middleText, ResultsDTO firstValue,
+            Float globalAvg, ResultsDTO compareValue) {
+        firstLabel.setText(firstValue.toString());
+        middleText.setText(" (" + globalAvg.toString() + ") ");
+        secondLabel.setText(compareValue.toString());
+
+        secondLabel.setDisable(false);
+        secondLabel.setOpacity(1);
+
+        middleText.setDisable(false);
+        middleText.setOpacity(1);
+        if (firstValue.getRes() < compareValue.getRes() && firstValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: green;");
+            secondLabel.setStyle("-fx-text-fill: red;");
+        } else if (firstValue.getRes() > compareValue.getRes() && compareValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: red;");
+            secondLabel.setStyle("-fx-text-fill: green;");
+        } else if (firstValue.getRes() == 0f && compareValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: black;");
+            secondLabel.setStyle("-fx-text-fill: green;");
+        } else if (firstValue.getRes() > 0f && compareValue.getRes() == 0f) {
+            firstLabel.setStyle("-fx-text-fill: green;");
+            secondLabel.setStyle("-fx-text-fill: black;");
+        } else {
+            firstLabel.setStyle("-fx-text-fill: black;");
+            secondLabel.setStyle("-fx-text-fill: black;");
+        }
+    }
+
+    public void setAvgTimeDistance5LabelWithCompare(Label firstLabel, Label secondLabel, Label middleText, ResultsDTO firstValue,
+            Float globalAvg, ResultsDTO compareValue) {
+        firstLabel.setText(firstValue.toString());
+        middleText.setText(" (" + globalAvg.toString() + ") ");
+        secondLabel.setText(compareValue.toString());
+
+        secondLabel.setDisable(false);
+        secondLabel.setOpacity(1);
+
+        middleText.setDisable(false);
+        middleText.setOpacity(1);
+        if (firstValue.getRes() < compareValue.getRes() && firstValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: green;");
+            secondLabel.setStyle("-fx-text-fill: red;");
+        } else if (firstValue.getRes() > compareValue.getRes() && compareValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: red;");
+            secondLabel.setStyle("-fx-text-fill: green;");
+        } else if (firstValue.getRes() == 0f && compareValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: black;");
+            secondLabel.setStyle("-fx-text-fill: green;");
+        } else if (firstValue.getRes() > 0f && compareValue.getRes() == 0f) {
+            firstLabel.setStyle("-fx-text-fill: green;");
+            secondLabel.setStyle("-fx-text-fill: black;");
+        } else {
+            firstLabel.setStyle("-fx-text-fill: black;");
+            secondLabel.setStyle("-fx-text-fill: black;");
+        }
+    }
+
+    public void setAvgTimeDistanceLimit10Label(Label firstLabel, Label secondLabel, Label middleText, ResultsDTO firstValue,
+            Float globalAvg, ResultsDTO compareValue) {
+        firstLabel.setText(firstValue.toString());
+        middleText.setText(" (" + globalAvg.toString() + ") ");
+        secondLabel.setText(compareValue.toString());
+
+        secondLabel.setDisable(false);
+        secondLabel.setOpacity(1);
+
+        middleText.setDisable(false);
+        middleText.setOpacity(1);
+        if (firstValue.getRes() < compareValue.getRes() && firstValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: green;");
+            secondLabel.setStyle("-fx-text-fill: red;");
+        } else if (firstValue.getRes() > compareValue.getRes() && compareValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: red;");
+            secondLabel.setStyle("-fx-text-fill: green;");
+        } else if (firstValue.getRes() == 0f && compareValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: black;");
+            secondLabel.setStyle("-fx-text-fill: green;");
+        } else if (firstValue.getRes() > 0f && compareValue.getRes() == 0f) {
+            firstLabel.setStyle("-fx-text-fill: green;");
+            secondLabel.setStyle("-fx-text-fill: black;");
+        } else {
+            firstLabel.setStyle("-fx-text-fill: black;");
+            secondLabel.setStyle("-fx-text-fill: black;");
+        }
+    }
+
+    public void setAvgTimeDistanceLimit15Label(Label firstLabel, Label secondLabel, Label middleText, ResultsDTO firstValue,
+            Float globalAvg, ResultsDTO compareValue) {
+        firstLabel.setText(firstValue.toString());
+        middleText.setText(" (" + globalAvg.toString() + ") ");
+        secondLabel.setText(compareValue.toString());
+
+        secondLabel.setDisable(false);
+        secondLabel.setOpacity(1);
+
+        middleText.setDisable(false);
+        middleText.setOpacity(1);
+        if (firstValue.getRes() < compareValue.getRes() && firstValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: green;");
+            secondLabel.setStyle("-fx-text-fill: red;");
+        } else if (firstValue.getRes() > compareValue.getRes() && compareValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: red;");
+            secondLabel.setStyle("-fx-text-fill: green;");
+        } else if (firstValue.getRes() == 0f && compareValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: black;");
+            secondLabel.setStyle("-fx-text-fill: green;");
+        } else if (firstValue.getRes() > 0f && compareValue.getRes() == 0f) {
+            firstLabel.setStyle("-fx-text-fill: green;");
+            secondLabel.setStyle("-fx-text-fill: black;");
+        } else {
+            firstLabel.setStyle("-fx-text-fill: black;");
+            secondLabel.setStyle("-fx-text-fill: black;");
+        }
+    }
+
+    public void setAvgPosition(Label firstLabel, Label secondLabel, Label middleText, ResultsDTO firstValue,
+            ResultsDTO compareValue) {
+        firstLabel.setText(firstValue.toString());
+        secondLabel.setText(compareValue.toString());
+
+        secondLabel.setDisable(false);
+        secondLabel.setOpacity(1);
+
+        middleText.setDisable(false);
+        middleText.setOpacity(1);
+        if (firstValue.getRes() < compareValue.getRes() && firstValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: green;");
+            secondLabel.setStyle("-fx-text-fill: red;");
+        } else if (firstValue.getRes() > compareValue.getRes() && compareValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: red;");
+            secondLabel.setStyle("-fx-text-fill: green;");
+        } else if (firstValue.getRes() == 0f && compareValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: black;");
+            secondLabel.setStyle("-fx-text-fill: green;");
+        } else if (firstValue.getRes() > 0f && compareValue.getRes() == 0f) {
+            firstLabel.setStyle("-fx-text-fill: green;");
+            secondLabel.setStyle("-fx-text-fill: black;");
+        } else {
+            firstLabel.setStyle("-fx-text-fill: black;");
+            secondLabel.setStyle("-fx-text-fill: black;");
+        }
+    }
+
+    public void setAvgPositionLast5(Label firstLabel, Label secondLabel, Label middleText, ResultsDTO firstValue,
+            ResultsDTO compareValue) {
+        firstLabel.setText(firstValue.toString());
+        secondLabel.setText(compareValue.toString());
+
+        secondLabel.setDisable(false);
+        secondLabel.setOpacity(1);
+
+        middleText.setDisable(false);
+        middleText.setOpacity(1);
+        if (firstValue.getRes() < compareValue.getRes() && firstValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: green;");
+            secondLabel.setStyle("-fx-text-fill: red;");
+        } else if (firstValue.getRes() > compareValue.getRes() && compareValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: red;");
+            secondLabel.setStyle("-fx-text-fill: green;");
+        } else if (firstValue.getRes() == 0f && compareValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: black;");
+            secondLabel.setStyle("-fx-text-fill: green;");
+        } else if (firstValue.getRes() > 0f && compareValue.getRes() == 0f) {
+            firstLabel.setStyle("-fx-text-fill: green;");
+            secondLabel.setStyle("-fx-text-fill: black;");
+        } else {
+            firstLabel.setStyle("-fx-text-fill: black;");
+            secondLabel.setStyle("-fx-text-fill: black;");
+        }
+    }
+
+    public void setAvgPositionLast10(Label firstLabel, Label secondLabel, Label middleText, ResultsDTO firstValue,
+            ResultsDTO compareValue) {
+        firstLabel.setText(firstValue.toString());
+        secondLabel.setText(compareValue.toString());
+
+        secondLabel.setDisable(false);
+        secondLabel.setOpacity(1);
+
+        middleText.setDisable(false);
+        middleText.setOpacity(1);
+        if (firstValue.getRes() < compareValue.getRes() && firstValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: green;");
+            secondLabel.setStyle("-fx-text-fill: red;");
+        } else if (firstValue.getRes() > compareValue.getRes() && compareValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: red;");
+            secondLabel.setStyle("-fx-text-fill: green;");
+        } else if (firstValue.getRes() == 0f && compareValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: black;");
+            secondLabel.setStyle("-fx-text-fill: green;");
+        } else if (firstValue.getRes() > 0f && compareValue.getRes() == 0f) {
+            firstLabel.setStyle("-fx-text-fill: green;");
+            secondLabel.setStyle("-fx-text-fill: black;");
+        } else {
+            firstLabel.setStyle("-fx-text-fill: black;");
+            secondLabel.setStyle("-fx-text-fill: black;");
+        }
+    }
+
+    public void setAvgPositionLast15(Label firstLabel, Label secondLabel, Label middleText, ResultsDTO firstValue,
+            ResultsDTO compareValue) {
+        firstLabel.setText(firstValue.toString());
+        secondLabel.setText(compareValue.toString());
+
+        secondLabel.setDisable(false);
+        secondLabel.setOpacity(1);
+
+        middleText.setDisable(false);
+        middleText.setOpacity(1);
+        if (firstValue.getRes() < compareValue.getRes() && firstValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: green;");
+            secondLabel.setStyle("-fx-text-fill: red;");
+        } else if (firstValue.getRes() > compareValue.getRes() && compareValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: red;");
+            secondLabel.setStyle("-fx-text-fill: green;");
+        } else if (firstValue.getRes() == 0f && compareValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: black;");
+            secondLabel.setStyle("-fx-text-fill: green;");
+        } else if (firstValue.getRes() > 0f && compareValue.getRes() == 0f) {
+            firstLabel.setStyle("-fx-text-fill: green;");
+            secondLabel.setStyle("-fx-text-fill: black;");
+        } else {
+            firstLabel.setStyle("-fx-text-fill: black;");
+            secondLabel.setStyle("-fx-text-fill: black;");
+        }
+    }
+
+    public void setAvgPositionDistanceLast5(Label firstLabel, Label secondLabel, Label middleText, ResultsDTO firstValue,
+            ResultsDTO compareValue) {
+        firstLabel.setText(firstValue.toString());
+        secondLabel.setText(compareValue.toString());
+
+        secondLabel.setDisable(false);
+        secondLabel.setOpacity(1);
+
+        middleText.setDisable(false);
+        middleText.setOpacity(1);
+        if (firstValue.getRes() < compareValue.getRes() && firstValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: green;");
+            secondLabel.setStyle("-fx-text-fill: red;");
+        } else if (firstValue.getRes() > compareValue.getRes() && compareValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: red;");
+            secondLabel.setStyle("-fx-text-fill: green;");
+        } else if (firstValue.getRes() == 0f && compareValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: black;");
+            secondLabel.setStyle("-fx-text-fill: green;");
+        } else if (firstValue.getRes() > 0f && compareValue.getRes() == 0f) {
+            firstLabel.setStyle("-fx-text-fill: green;");
+            secondLabel.setStyle("-fx-text-fill: black;");
+        } else {
+            firstLabel.setStyle("-fx-text-fill: black;");
+            secondLabel.setStyle("-fx-text-fill: black;");
+        }
+    }
+
+    public void setAvgPositionDistanceLast10(Label firstLabel, Label secondLabel, Label middleText, ResultsDTO firstValue,
+            ResultsDTO compareValue) {
+        firstLabel.setText(firstValue.toString());
+        secondLabel.setText(compareValue.toString());
+
+        secondLabel.setDisable(false);
+        secondLabel.setOpacity(1);
+
+        middleText.setDisable(false);
+        middleText.setOpacity(1);
+        if (firstValue.getRes() < compareValue.getRes() && firstValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: green;");
+            secondLabel.setStyle("-fx-text-fill: red;");
+        } else if (firstValue.getRes() > compareValue.getRes() && compareValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: red;");
+            secondLabel.setStyle("-fx-text-fill: green;");
+        } else if (firstValue.getRes() == 0f && compareValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: black;");
+            secondLabel.setStyle("-fx-text-fill: green;");
+        } else if (firstValue.getRes() > 0f && compareValue.getRes() == 0f) {
+            firstLabel.setStyle("-fx-text-fill: green;");
+            secondLabel.setStyle("-fx-text-fill: black;");
+        } else {
+            firstLabel.setStyle("-fx-text-fill: black;");
+            secondLabel.setStyle("-fx-text-fill: black;");
+        }
+    }
+
+    public void setAvgPositionDistanceLast15(Label firstLabel, Label secondLabel, Label middleText, ResultsDTO firstValue,
+            ResultsDTO compareValue) {
+        firstLabel.setText(firstValue.toString());
+        secondLabel.setText(compareValue.toString());
+
+        secondLabel.setDisable(false);
+        secondLabel.setOpacity(1);
+
+        middleText.setDisable(false);
+        middleText.setOpacity(1);
+        if (firstValue.getRes() < compareValue.getRes() && firstValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: green;");
+            secondLabel.setStyle("-fx-text-fill: red;");
+        } else if (firstValue.getRes() > compareValue.getRes() && compareValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: red;");
+            secondLabel.setStyle("-fx-text-fill: green;");
+        } else if (firstValue.getRes() == 0f && compareValue.getRes() > 0f) {
+            firstLabel.setStyle("-fx-text-fill: black;");
+            secondLabel.setStyle("-fx-text-fill: green;");
+        } else if (firstValue.getRes() > 0f && compareValue.getRes() == 0f) {
+            firstLabel.setStyle("-fx-text-fill: green;");
+            secondLabel.setStyle("-fx-text-fill: black;");
+        } else {
+            firstLabel.setStyle("-fx-text-fill: black;");
+            secondLabel.setStyle("-fx-text-fill: black;");
+        }
+    }
 }

+ 1 - 1
ATG/src/database/DriverDB.java

@@ -73,7 +73,7 @@ public class DriverDB extends Database {
     }
 
     public ResultsDTO avarageTimeWithLimit(int driverId, int raceLimit, String date) {
-        return avaragePlacementByDistance(driverId, 0, raceLimit, date);
+        return avarageTimeByDistance(driverId, 0, raceLimit, date);
     }
 
     public ResultsDTO avarageTimeByDistance(int driverId, int distance, int raceLimit, String date) {

+ 47 - 22
ATG/src/fxml/NewTab/Driver.fxml

@@ -46,93 +46,118 @@
                <Label fx:id="avgTimeLabelCompare" text="Label" />
             </children>
          </FlowPane>
-         <Label text="avgTimeDistance (all)" GridPane.rowIndex="3" />
+
+         <Label text="avgTimeLimit5 (all)" GridPane.rowIndex="3" />
          <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="3">
+            <children>
+               <Label fx:id="avgTimeLimit5Label" text="&lt;Avg Time Distance limit 5&gt;" />
+               <Label fx:id="avgTimeLimit5LabelTotal" text="Label" />
+               <Label fx:id="avgTimeLimit5LabelCompare" text="Label" />
+            </children>
+         </FlowPane>
+                  <Label text="avgTimeLimit10 (all)" GridPane.rowIndex="4" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="4">
+            <children>
+               <Label fx:id="avgTimeLimit10Label" text="&lt;Avg Time Distance limit 10&gt;" />
+               <Label fx:id="avgTimeLimit10LabelTotal" text="Label" />
+               <Label fx:id="avgTimeLimit10LabelCompare" text="Label" />
+            </children>
+         </FlowPane>
+                  <Label text="avgTimeLimit15 (all)" GridPane.rowIndex="5" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="5">
+            <children>
+               <Label fx:id="avgTimeLimit15Label" text="&lt;Avg Time Distance limit 15&gt;" />
+               <Label fx:id="avgTimeLimit15LabelTotal" text="Label" />
+               <Label fx:id="avgTimeLimit15LabelCompare" text="Label" />
+            </children>
+         </FlowPane>
+                  <Label text="avgTimeDistance (all)" GridPane.rowIndex="6" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="6">
             <children>
                <Label fx:id="avgTimeDistanceLabel" text="&lt;Avg Time Distance&gt;" />
                <Label fx:id="avgTimeDistanceLabelTotal" text="Label" />
                <Label fx:id="avgTimeDistanceLabelCompare" text="Label" />
             </children>
          </FlowPane>
-         <Label text="avgTimeDistanceLimit5 (all)" GridPane.rowIndex="4" />
-         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="4">
+         <Label text="avgTimeDistanceLimit5 (all)" GridPane.rowIndex="7" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="7">
             <children>
                <Label fx:id="avgTimeDistanceLimit5Label" text="&lt;Avg Time Distance limit 5&gt;" />
                <Label fx:id="avgTimeDistanceLimit5LabelTotal" text="Label" />
                <Label fx:id="avgTimeDistanceLimit5LabelCompare" text="Label" />
             </children>
          </FlowPane>
-         <Label text="avgTimeDistanceLimit10 (all)" GridPane.rowIndex="5" />
-         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="5">
+         <Label text="avgTimeDistanceLimit10 (all)" GridPane.rowIndex="8" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="8">
             <children>
                <Label fx:id="avgTimeDistanceLimit10Label" text="&lt;Avg Time Distance limit 10&gt;" />
                <Label fx:id="avgTimeDistanceLimit10LabelTotal" text="Label" />
                <Label fx:id="avgTimeDistanceLimit10LabelCompare" text="Label" />
             </children>
          </FlowPane>
-         <Label text="avgTimeDistanceLimit15 (all)" GridPane.rowIndex="6" />
-         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="6">
+         <Label text="avgTimeDistanceLimit15 (all)" GridPane.rowIndex="9" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="9">
             <children>
                <Label fx:id="avgTimeDistanceLimit15Label" text="&lt;Avg Time Distance limit 15&gt;" />
                <Label fx:id="avgTimeDistanceLimit15LabelTotal" text="Label" />
                <Label fx:id="avgTimeDistanceLimit15LabelCompare" text="Label" />
             </children>
          </FlowPane>
-         <Label alignment="CENTER" text="POSITION" textAlignment="CENTER" GridPane.columnSpan="2" GridPane.halignment="CENTER" GridPane.rowIndex="7" GridPane.valignment="CENTER">
+         <Label alignment="CENTER" text="POSITION" textAlignment="CENTER" GridPane.columnSpan="2" GridPane.halignment="CENTER" GridPane.rowIndex="10" GridPane.valignment="CENTER">
             <font>
                <Font name="System Bold" size="14.0" />
             </font>
          </Label>
-         <Label text="Avarage position" GridPane.rowIndex="8" />
-         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="8">
+         <Label text="Avarage position" GridPane.rowIndex="11" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="11">
             <children>
                <Label fx:id="avgPosition" text="&lt;Avg Position&gt;" />
                <Label fx:id="avgPositionVS" text=" VS " />
                <Label fx:id="avgPositionCompare" text="Label" />
             </children>
          </FlowPane>
-         <Label text="Avg Position Last 5" GridPane.rowIndex="9" />
-         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="9">
+         <Label text="Avg Position Last 5" GridPane.rowIndex="12" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="12">
             <children>
                <Label fx:id="avgPositionLast5" text="&lt;Avg Position Last 5&gt;" />
                <Label fx:id="avgPositionLast5VS" text=" VS " />
                <Label fx:id="avgPositionLast5Compare" text="Label" />
             </children>
          </FlowPane>
-         <Label text="Avg Position Last 10" GridPane.rowIndex="10" />
-         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="10">
+         <Label text="Avg Position Last 10" GridPane.rowIndex="13" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="13">
             <children>
                <Label fx:id="avgPositionLast10" text="&lt;Avg Position Last 10&gt;" />
                <Label fx:id="avgPositionLast10VS" text=" VS " />
                <Label fx:id="avgPositionLast10Compare" text="Label" />
             </children>
          </FlowPane>
-         <Label text="Avg Position Last 15" GridPane.rowIndex="11" />
-         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="11">
+         <Label text="Avg Position Last 15" GridPane.rowIndex="14" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="14">
             <children>
                <Label fx:id="avgPositionLast15" text="&lt;Avg Position Last 15&gt;" />
                <Label fx:id="avgPositionLast15VS" text=" VS " />
                <Label fx:id="avgPositionLast15Compare" text="Label" />
             </children>
          </FlowPane>
-         <Label text="Avg Position Distance Last 5" GridPane.rowIndex="12" />
-         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="12">
+         <Label text="Avg Position Distance Last 5" GridPane.rowIndex="15" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="15">
             <children>
                <Label fx:id="avgPositionDistanceLast5" text="&lt;Avg Position Distance Last 5&gt;" />
                <Label fx:id="avgPositionDistanceLast5VS" text=" VS " />
                <Label fx:id="avgPositionDistanceLast5Compare" text="Label" />
             </children>
          </FlowPane>
-         <Label text="Avg Position Distance Last 10" GridPane.rowIndex="13" />
-         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="13">
+         <Label text="Avg Position Distance Last 10" GridPane.rowIndex="16" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="16">
             <children>
                <Label fx:id="avgPositionDistanceLast10" text="&lt;Avg Position Distance Last 10&gt;" />
                <Label fx:id="avgPositionDistanceLast10VS" text=" VS " />
                <Label fx:id="avgPositionDistanceLast10Compare" text="Label" />
             </children>
          </FlowPane>
-         <Label text="Avg Position Distance Last 15" GridPane.rowIndex="14" />
-         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="14">
+         <Label text="Avg Position Distance Last 15" GridPane.rowIndex="17" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="17">
             <children>
                <Label fx:id="avgPositionDistanceLast15" text="&lt;Avg Position Distance Last 15&gt;" />
                <Label fx:id="avgPositionDistanceLast15VS" text=" VS " />

+ 47 - 23
ATG/src/fxml/NewTab/Ekipage.fxml

@@ -38,7 +38,7 @@
                <Font name="System Bold" size="14.0" />
             </font></Label>
          <Label fx:id="ekipageNameLabel" text="&lt;EkipageName&gt;" />
-                  <Label text="Avg Time (all)" GridPane.rowIndex="2" />
+         <Label text="Avg Time (all)" GridPane.rowIndex="2" />
          <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="2">
             <children>
                <Label fx:id="avgTimeLabel" text="&lt;Avg Time&gt;" />
@@ -46,93 +46,117 @@
                <Label fx:id="avgTimeLabelCompare" text="Label" />
             </children>
          </FlowPane>
-         <Label text="avgTimeDistance (all)" GridPane.rowIndex="3" />
+         <Label text="avgTimeLimit5 (all)" GridPane.rowIndex="3" />
          <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="3">
+            <children>
+               <Label fx:id="avgTimeLimit5Label" text="&lt;Avg Time Distance limit 5&gt;" />
+               <Label fx:id="avgTimeLimit5LabelTotal" text="Label" />
+               <Label fx:id="avgTimeLimit5LabelCompare" text="Label" />
+            </children>
+         </FlowPane>
+                  <Label text="avgTimeLimit10 (all)" GridPane.rowIndex="4" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="4">
+            <children>
+               <Label fx:id="avgTimeLimit10Label" text="&lt;Avg Time Distance limit 10&gt;" />
+               <Label fx:id="avgTimeLimit10LabelTotal" text="Label" />
+               <Label fx:id="avgTimeLimit10LabelCompare" text="Label" />
+            </children>
+         </FlowPane>
+                  <Label text="avgTimeLimit15 (all)" GridPane.rowIndex="5" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="5">
+            <children>
+               <Label fx:id="avgTimeLimit15Label" text="&lt;Avg Time Distance limit 15&gt;" />
+               <Label fx:id="avgTimeLimit15LabelTotal" text="Label" />
+               <Label fx:id="avgTimeLimit15LabelCompare" text="Label" />
+            </children>
+         </FlowPane>
+         <Label text="avgTimeDistance (all)" GridPane.rowIndex="6" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="6">
             <children>
                <Label fx:id="avgTimeDistanceLabel" text="&lt;Avg Time Distance&gt;" />
                <Label fx:id="avgTimeDistanceLabelTotal" text="Label" />
                <Label fx:id="avgTimeDistanceLabelCompare" text="Label" />
             </children>
          </FlowPane>
-         <Label text="avgTimeDistanceLimit5 (all)" GridPane.rowIndex="4" />
-         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="4">
+         <Label text="avgTimeDistanceLimit5 (all)" GridPane.rowIndex="7" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="7">
             <children>
                <Label fx:id="avgTimeDistanceLimit5Label" text="&lt;Avg Time Distance limit 5&gt;" />
                <Label fx:id="avgTimeDistanceLimit5LabelTotal" text="Label" />
                <Label fx:id="avgTimeDistanceLimit5LabelCompare" text="Label" />
             </children>
          </FlowPane>
-         <Label text="avgTimeDistanceLimit10 (all)" GridPane.rowIndex="5" />
-         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="5">
+         <Label text="avgTimeDistanceLimit10 (all)" GridPane.rowIndex="8" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="8">
             <children>
                <Label fx:id="avgTimeDistanceLimit10Label" text="&lt;Avg Time Distance limit 10&gt;" />
                <Label fx:id="avgTimeDistanceLimit10LabelTotal" text="Label" />
                <Label fx:id="avgTimeDistanceLimit10LabelCompare" text="Label" />
             </children>
          </FlowPane>
-         <Label text="avgTimeDistanceLimit15 (all)" GridPane.rowIndex="6" />
-         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="6">
+         <Label text="avgTimeDistanceLimit15 (all)" GridPane.rowIndex="9" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="9">
             <children>
                <Label fx:id="avgTimeDistanceLimit15Label" text="&lt;Avg Time Distance limit 15&gt;" />
                <Label fx:id="avgTimeDistanceLimit15LabelTotal" text="Label" />
                <Label fx:id="avgTimeDistanceLimit15LabelCompare" text="Label" />
             </children>
          </FlowPane>
-         <Label alignment="CENTER" text="POSITION" textAlignment="CENTER" GridPane.columnSpan="2" GridPane.halignment="CENTER" GridPane.rowIndex="7" GridPane.valignment="CENTER">
+         <Label alignment="CENTER" text="POSITION" textAlignment="CENTER" GridPane.columnSpan="2" GridPane.halignment="CENTER" GridPane.rowIndex="10" GridPane.valignment="CENTER">
             <font>
                <Font name="System Bold" size="14.0" />
             </font>
          </Label>
-         <Label text="Avarage position" GridPane.rowIndex="8" />
-         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="8">
+         <Label text="Avarage position" GridPane.rowIndex="11" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="11">
             <children>
                <Label fx:id="avgPosition" text="&lt;Avg Position&gt;" />
                <Label fx:id="avgPositionVS" text=" VS " />
                <Label fx:id="avgPositionCompare" text="Label" />
             </children>
          </FlowPane>
-         <Label text="Avg Position Last 5" GridPane.rowIndex="9" />
-         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="9">
+         <Label text="Avg Position Last 5" GridPane.rowIndex="12" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="12">
             <children>
                <Label fx:id="avgPositionLast5" text="&lt;Avg Position Last 5&gt;" />
                <Label fx:id="avgPositionLast5VS" text=" VS " />
                <Label fx:id="avgPositionLast5Compare" text="Label" />
             </children>
          </FlowPane>
-         <Label text="Avg Position Last 10" GridPane.rowIndex="10" />
-         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="10">
+         <Label text="Avg Position Last 10" GridPane.rowIndex="13" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="13">
             <children>
                <Label fx:id="avgPositionLast10" text="&lt;Avg Position Last 10&gt;" />
                <Label fx:id="avgPositionLast10VS" text=" VS " />
                <Label fx:id="avgPositionLast10Compare" text="Label" />
             </children>
          </FlowPane>
-         <Label text="Avg Position Last 15" GridPane.rowIndex="11" />
-         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="11">
+         <Label text="Avg Position Last 15" GridPane.rowIndex="14" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="14">
             <children>
                <Label fx:id="avgPositionLast15" text="&lt;Avg Position Last 15&gt;" />
                <Label fx:id="avgPositionLast15VS" text=" VS " />
                <Label fx:id="avgPositionLast15Compare" text="Label" />
             </children>
          </FlowPane>
-         <Label text="Avg Position Distance Last 5" GridPane.rowIndex="12" />
-         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="12">
+         <Label text="Avg Position Distance Last 5" GridPane.rowIndex="15" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="15">
             <children>
                <Label fx:id="avgPositionDistanceLast5" text="&lt;Avg Position Distance Last 5&gt;" />
                <Label fx:id="avgPositionDistanceLast5VS" text=" VS " />
                <Label fx:id="avgPositionDistanceLast5Compare" text="Label" />
             </children>
          </FlowPane>
-         <Label text="Avg Position Distance Last 10" GridPane.rowIndex="13" />
-         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="13">
+         <Label text="Avg Position Distance Last 10" GridPane.rowIndex="16" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="16">
             <children>
                <Label fx:id="avgPositionDistanceLast10" text="&lt;Avg Position Distance Last 10&gt;" />
                <Label fx:id="avgPositionDistanceLast10VS" text=" VS " />
                <Label fx:id="avgPositionDistanceLast10Compare" text="Label" />
             </children>
          </FlowPane>
-         <Label text="Avg Position Distance Last 15" GridPane.rowIndex="14" />
-         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="14">
+         <Label text="Avg Position Distance Last 15" GridPane.rowIndex="17" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="17">
             <children>
                <Label fx:id="avgPositionDistanceLast15" text="&lt;Avg Position Distance Last 15&gt;" />
                <Label fx:id="avgPositionDistanceLast15VS" text=" VS " />

+ 46 - 22
ATG/src/fxml/NewTab/Horse.fxml

@@ -46,93 +46,117 @@
                <Label fx:id="avgTimeLabelCompare" text="Label" />
             </children>
          </FlowPane>
-         <Label text="avgTimeDistance (all)" GridPane.rowIndex="3" />
+         <Label text="avgTimeLimit5 (all)" GridPane.rowIndex="3" />
          <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="3">
+            <children>
+               <Label fx:id="avgTimeLimit5Label" text="&lt;Avg Time Distance limit 5&gt;" />
+               <Label fx:id="avgTimeLimit5LabelTotal" text="Label" />
+               <Label fx:id="avgTimeLimit5LabelCompare" text="Label" />
+            </children>
+         </FlowPane>
+                  <Label text="avgTimeLimit10 (all)" GridPane.rowIndex="4" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="4">
+            <children>
+               <Label fx:id="avgTimeLimit10Label" text="&lt;Avg Time Distance limit 10&gt;" />
+               <Label fx:id="avgTimeLimit10LabelTotal" text="Label" />
+               <Label fx:id="avgTimeLimit10LabelCompare" text="Label" />
+            </children>
+         </FlowPane>
+                  <Label text="avgTimeLimit15 (all)" GridPane.rowIndex="5" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="5">
+            <children>
+               <Label fx:id="avgTimeLimit15Label" text="&lt;Avg Time Distance limit 15&gt;" />
+               <Label fx:id="avgTimeLimit15LabelTotal" text="Label" />
+               <Label fx:id="avgTimeLimit15LabelCompare" text="Label" />
+            </children>
+         </FlowPane>
+         <Label text="avgTimeDistance (all)" GridPane.rowIndex="6" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="6">
             <children>
                <Label fx:id="avgTimeDistanceLabel" text="&lt;Avg Time Distance&gt;" />
                <Label fx:id="avgTimeDistanceLabelTotal" text="Label" />
                <Label fx:id="avgTimeDistanceLabelCompare" text="Label" />
             </children>
          </FlowPane>
-         <Label text="avgTimeDistanceLimit5 (all)" GridPane.rowIndex="4" />
-         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="4">
+         <Label text="avgTimeDistanceLimit5 (all)" GridPane.rowIndex="7" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="7">
             <children>
                <Label fx:id="avgTimeDistanceLimit5Label" text="&lt;Avg Time Distance limit 5&gt;" />
                <Label fx:id="avgTimeDistanceLimit5LabelTotal" text="Label" />
                <Label fx:id="avgTimeDistanceLimit5LabelCompare" text="Label" />
             </children>
          </FlowPane>
-         <Label text="avgTimeDistanceLimit10 (all)" GridPane.rowIndex="5" />
-         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="5">
+         <Label text="avgTimeDistanceLimit10 (all)" GridPane.rowIndex="8" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="8">
             <children>
                <Label fx:id="avgTimeDistanceLimit10Label" text="&lt;Avg Time Distance limit 10&gt;" />
                <Label fx:id="avgTimeDistanceLimit10LabelTotal" text="Label" />
                <Label fx:id="avgTimeDistanceLimit10LabelCompare" text="Label" />
             </children>
          </FlowPane>
-         <Label text="avgTimeDistanceLimit15 (all)" GridPane.rowIndex="6" />
-         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="6">
+         <Label text="avgTimeDistanceLimit15 (all)" GridPane.rowIndex="9" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="9">
             <children>
                <Label fx:id="avgTimeDistanceLimit15Label" text="&lt;Avg Time Distance limit 15&gt;" />
                <Label fx:id="avgTimeDistanceLimit15LabelTotal" text="Label" />
                <Label fx:id="avgTimeDistanceLimit15LabelCompare" text="Label" />
             </children>
          </FlowPane>
-         <Label alignment="CENTER" text="POSITION" textAlignment="CENTER" GridPane.columnSpan="2" GridPane.halignment="CENTER" GridPane.rowIndex="7" GridPane.valignment="CENTER">
+         <Label alignment="CENTER" text="POSITION" textAlignment="CENTER" GridPane.columnSpan="2" GridPane.halignment="CENTER" GridPane.rowIndex="10" GridPane.valignment="CENTER">
             <font>
                <Font name="System Bold" size="14.0" />
             </font>
          </Label>
-         <Label text="Avarage position" GridPane.rowIndex="8" />
-         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="8">
+         <Label text="Avarage position" GridPane.rowIndex="11" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="11">
             <children>
                <Label fx:id="avgPosition" text="&lt;Avg Position&gt;" />
                <Label fx:id="avgPositionVS" text=" VS " />
                <Label fx:id="avgPositionCompare" text="Label" />
             </children>
          </FlowPane>
-         <Label text="Avg Position Last 5" GridPane.rowIndex="9" />
-         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="9">
+         <Label text="Avg Position Last 5" GridPane.rowIndex="12" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="12">
             <children>
                <Label fx:id="avgPositionLast5" text="&lt;Avg Position Last 5&gt;" />
                <Label fx:id="avgPositionLast5VS" text=" VS " />
                <Label fx:id="avgPositionLast5Compare" text="Label" />
             </children>
          </FlowPane>
-         <Label text="Avg Position Last 10" GridPane.rowIndex="10" />
-         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="10">
+         <Label text="Avg Position Last 10" GridPane.rowIndex="13" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="13">
             <children>
                <Label fx:id="avgPositionLast10" text="&lt;Avg Position Last 10&gt;" />
                <Label fx:id="avgPositionLast10VS" text=" VS " />
                <Label fx:id="avgPositionLast10Compare" text="Label" />
             </children>
          </FlowPane>
-         <Label text="Avg Position Last 15" GridPane.rowIndex="11" />
-         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="11">
+         <Label text="Avg Position Last 15" GridPane.rowIndex="14" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="14">
             <children>
                <Label fx:id="avgPositionLast15" text="&lt;Avg Position Last 15&gt;" />
                <Label fx:id="avgPositionLast15VS" text=" VS " />
                <Label fx:id="avgPositionLast15Compare" text="Label" />
             </children>
          </FlowPane>
-         <Label text="Avg Position Distance Last 5" GridPane.rowIndex="12" />
-         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="12">
+         <Label text="Avg Position Distance Last 5" GridPane.rowIndex="15" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="15">
             <children>
                <Label fx:id="avgPositionDistanceLast5" text="&lt;Avg Position Distance Last 5&gt;" />
                <Label fx:id="avgPositionDistanceLast5VS" text=" VS " />
                <Label fx:id="avgPositionDistanceLast5Compare" text="Label" />
             </children>
          </FlowPane>
-         <Label text="Avg Position Distance Last 10" GridPane.rowIndex="13" />
-         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="13">
+         <Label text="Avg Position Distance Last 10" GridPane.rowIndex="17" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="17">
             <children>
                <Label fx:id="avgPositionDistanceLast10" text="&lt;Avg Position Distance Last 10&gt;" />
                <Label fx:id="avgPositionDistanceLast10VS" text=" VS " />
                <Label fx:id="avgPositionDistanceLast10Compare" text="Label" />
             </children>
          </FlowPane>
-         <Label text="Avg Position Distance Last 15" GridPane.rowIndex="14" />
-         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="14">
+         <Label text="Avg Position Distance Last 15" GridPane.rowIndex="18" />
+         <FlowPane GridPane.columnIndex="1" GridPane.rowIndex="18">
             <children>
                <Label fx:id="avgPositionDistanceLast15" text="&lt;Avg Position Distance Last 15&gt;" />
                <Label fx:id="avgPositionDistanceLast15VS" text=" VS " />

+ 10 - 3
ATG/src/fxml/NewTab/MainContent.fxml

@@ -1,18 +1,19 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
-<?import javafx.scene.control.Label?>
+<?import javafx.scene.control.Button?>
 <?import javafx.scene.control.TabPane?>
 <?import javafx.scene.layout.AnchorPane?>
 <?import javafx.scene.layout.ColumnConstraints?>
 <?import javafx.scene.layout.GridPane?>
-<?import javafx.scene.layout.Pane?>
 <?import javafx.scene.layout.RowConstraints?>
+<?import javafx.scene.layout.VBox?>
 
 <AnchorPane prefHeight="1000.0" prefWidth="1600.0" xmlns="http://javafx.com/javafx/15.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="controllers.NewTab.MainContent">
    <children>
       <GridPane prefHeight="1000.0" prefWidth="1600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
         <columnConstraints>
           <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
+            <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
         </columnConstraints>
         <rowConstraints>
           <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
@@ -20,7 +21,13 @@
         </rowConstraints>
          <children>
       	<TabPane fx:id="mainNewTabTableView" tabClosingPolicy="UNAVAILABLE" />
-      	  <GridPane GridPane.rowIndex="1">
+            <VBox alignment="TOP_CENTER" prefHeight="200.0" prefWidth="100.0" GridPane.columnIndex="1">
+               <children>
+                  <VBox fx:id="BetOnContent" prefHeight="474.0" prefWidth="783.0" style="-fx-background-color: cyan;" />
+                  <Button fx:id="SubmitBongButton" alignment="BOTTOM_CENTER" contentDisplay="CENTER" disable="true" mnemonicParsing="false" onAction="#SubmitBongAction" text="Submit" />
+               </children>
+            </VBox>
+      	  <GridPane GridPane.columnSpan="2" GridPane.rowIndex="1">
       	      <columnConstraints>
       	         <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
       	         <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />

+ 103 - 0
ATG/src/objects/BongObject.java

@@ -0,0 +1,103 @@
+package objects;
+
+import javafx.collections.ObservableList;
+import javafx.scene.Node;
+import javafx.scene.control.TextField;
+import javafx.scene.layout.HBox;
+import javafx.scene.layout.Pane;
+
+public class BongObject extends HBox {
+
+    int lane;
+    String horse;
+    String driver;
+    int raceNumber;
+
+    HBox content;
+    private final Pane raceNumberPane;
+    private final Pane horsePane;
+    private final Pane driverPane;
+    private final Pane lanePane;
+
+    BongObject() {
+        content = new HBox();
+
+        raceNumberPane = new Pane();
+        driverPane = new Pane();
+        horsePane = new Pane();
+        lanePane = new Pane();
+
+        raceNumberPane.getChildren().add(new TextField());
+        horsePane.getChildren().add(new TextField());
+        driverPane.getChildren().add(new TextField());
+        lanePane.getChildren().add(new TextField());
+
+        final ObservableList<Node> children = content.getChildren();
+        children.add(raceNumberPane);
+        children.add(horsePane);
+        children.add(driverPane);
+        children.add(lanePane);
+    }
+
+    public HBox getContent() {
+        return content;
+    }
+
+    public int getLane() {
+        return lane;
+    }
+
+    public String getHorse() {
+        return horse;
+    }
+
+    public String getDriver() {
+        return driver;
+    }
+
+    public void addLane(int lane) {
+        this.lane = lane;
+        final TextField laneText = (TextField) lanePane.getChildren().get(0);
+        String text = laneText.getText();
+        if (text.length() > 0) {
+            text += ", " + lane;
+        } else {
+            text = String.valueOf(lane);
+        }
+        laneText.setText(text);
+    }
+
+    public void addHorse(String horse) {
+        this.horse = horse;
+        final TextField horseText = (TextField) horsePane.getChildren().get(0);
+        String text = horseText.getText();
+        if (text.length() > 0) {
+            text += ", " + horse;
+        } else {
+            text = horse;
+        }
+        horseText.setText(text);
+    }
+
+    public void addDriver(String driver) {
+        this.driver = driver;
+        final TextField driverText = (TextField) driverPane.getChildren().get(0);
+        String text = driverText.getText();
+        if (text.length() > 0) {
+            text += ", " + driver;
+        } else {
+            text = driver;
+        }
+        driverText.setText(text);
+    }
+
+    public int getRaceNumber() {
+        return raceNumber;
+    }
+
+    public void setRaceNumber(int raceNumber) {
+        this.raceNumber = raceNumber;
+        ((TextField) raceNumberPane.getChildren().get(0)).setText(String.valueOf(raceNumber));
+    }
+
+}

+ 346 - 309
ATG/src/objects/ComparingResultsData.java

@@ -5,313 +5,350 @@ import java.util.List;
 
 public class ComparingResultsData {
 
-	private int horseId;
-	private int driverId;
-	private int trainerId;
-	private final int raceNumber;
-	private final String raceDate;
-
-	private String trackName;
-
-	private String horseName;
-	private int lane;
-	private int distance;
-	private int result;
-	private float time;
-	private String timeModifier;
-	private String trainerName;
-	private String driverName;
-	private float laneWin;
-
-	private String lastRacesDriver;
-	private String lastRacesHorse;
-	private String lastRacesBoth;
-	private float combinedLastRaces = 0f;
-
-	private Float avgTimeHorseChange;
-	private Float avgTimeDriverChange;
-
-	private Float avgTimeHorse;
-	private Float avgTimeDriver;
-
-	private float sumHorse;
-	private float sumDriver;
-
-	private int ratingSumHorse;
-	private int ratingSumDriver;
-	private int ratingLastResultsTotal;
-	private int sumRatings;
-
-	public ComparingResultsData(HorseRaceData data) {
-		horseName = data.getHorseName();
-		lane = data.getLane();
-		distance = data.getDistance();
-		result = data.getResult();
-		time = data.getTime();
-		timeModifier = data.getTimeModifier();
-		trainerName = data.getTrainerName();
-		driverName = data.getDriverName();
-		laneWin = data.getLaneWin();
-		horseId = data.getHorseId();
-		driverId = data.getDriverId();
-		trainerId = data.getTrainerId();
-		raceNumber = data.getRaceNumber();
-		raceDate = data.getRaceDate();
-		trackName = data.getTrackName();
-	}
-
-	public int getLane() {
-		return lane;
-	}
-	public int getDistance() {
-		return distance;
-	}
-	public int getResult() {
-		return result;
-	}
-	public float getTime() {
-		return time;
-	}
-	public String getTimeModifier() {
-		return timeModifier;
-	}
-
-	public String getTrainerName() {
-		return trainerName;
-	}
-	public String getDriverName() {
-		return driverName;
-	}
-
-	public void setLane(int lane) {
-		this.lane = lane;
-	}
-	public void setDistance(int distance) {
-		this.distance = distance;
-	}
-	public void setResult(int result) {
-		this.result = result;
-	}
-	public void setTime(float time) {
-		this.time = time;
-	}
-	public void setTimeModifier(String timeModifier) {
-		this.timeModifier = timeModifier;
-	}
-
-	public void setTrainerName(String trainerName) {
-		this.trainerName = trainerName;
-	}
-	public void setDriverName(String driverName) {
-		this.driverName = driverName;
-	}
-	public String getHorseName() {
-		return horseName;
-	}
-	public void setHorseName(String horseName) {
-		this.horseName = horseName;
-	}
-
-	public float getLaneWin() {
-		return laneWin;
-	}
-	public void setLaneWin(float laneWin) {
-		this.laneWin = laneWin;
-	}
-
-	public static ArrayList<ComparingResultsData> convertHorseRaceDataList(List<HorseRaceData> races) {
-		final ArrayList<ComparingResultsData> returnArray = new ArrayList<ComparingResultsData>();
-
-		for (final HorseRaceData data : races) {
-			returnArray.add(new ComparingResultsData(data));
-		}
-
-		return returnArray;
-	}
-
-	public int getHorseId() {
-		return horseId;
-	}
-
-	public int getDriverId() {
-		return driverId;
-	}
-
-	public int getTrainerId() {
-		return trainerId;
-	}
-
-	public void setHorseId(int horseId) {
-		this.horseId = horseId;
-	}
-
-	public void setDriverId(int driverId) {
-		this.driverId = driverId;
-	}
-
-	public void setTrainerId(int trainerId) {
-		this.trainerId = trainerId;
-	}
-
-	public int getRaceNumber() {
-		return raceNumber;
-	}
-
-	public String getRaceDate() {
-		return raceDate;
-	}
-
-	public String getLastRacesDriver() {
-		return lastRacesDriver;
-	}
-
-	public String getLastRacesHorse() {
-		return lastRacesHorse;
-	}
-
-	public String getLastRacesBoth() {
-		return lastRacesBoth;
-	}
-
-	public void setLastRacesDriver(String lastRacesDriver) {
-		final float val = Float.valueOf(lastRacesDriver.substring(0, lastRacesDriver.indexOf("(") - 1));
-		if (val <= 0) {
-			combinedLastRaces += 8f;
-		} else {
-			combinedLastRaces += val;
-		}
-		this.lastRacesDriver = lastRacesDriver;
-	}
-
-	public void setLastRacesHorse(String lastRacesHorse) {
-		final float val = Float.valueOf(lastRacesHorse.substring(0, lastRacesHorse.indexOf("(") - 1));
-		if (val <= 0) {
-			combinedLastRaces += 8f;
-		} else {
-			combinedLastRaces += val;
-		}
-		this.lastRacesHorse = lastRacesHorse;
-	}
-
-	public void setLastRacesBoth(String lastRacesBoth) {
-		final float val = Float.valueOf(lastRacesBoth.substring(0, lastRacesBoth.indexOf("(") - 1));
-		if (val <= 0) {
-			combinedLastRaces += 8f;
-		} else {
-			combinedLastRaces += val;
-		}
-		this.lastRacesBoth = lastRacesBoth;
-	}
-
-	public float getCombinedLastRaces() {
-		return combinedLastRaces;
-	}
-
-	public String getTrackName() {
-		return trackName;
-	}
-
-	public void setTrackName(String trackName) {
-		this.trackName = trackName;
-	}
-
-	public Float getAvgTimeHorseChange() {
-		return avgTimeHorseChange;
-	}
-
-	public void setAvgTimeHorseChange(float avgHorseTime) {
-		this.avgTimeHorseChange = avgHorseTime;
-	}
-
-	public Float getAvgTimeDriverChange() {
-		return avgTimeDriverChange;
-	}
-
-	public void setAvgTimeDriverChange(Float avgTimeDriver) {
-		this.avgTimeDriverChange = avgTimeDriver;
-	}
-
-	public Float getAvgTimeHorse() {
-		return avgTimeHorse;
-	}
-
-	public Float getAvgTimeDriver() {
-		return avgTimeDriver;
-	}
-
-	public void setCombinedLastRaces(float combinedLastRaces) {
-		this.combinedLastRaces = combinedLastRaces;
-	}
-
-	public void setAvgTimeHorseChange(Float avgTimeHorseChange) {
-		this.avgTimeHorseChange = avgTimeHorseChange;
-	}
-
-	public void setAvgTimeHorse(Float avgTimeHorse) {
-		this.avgTimeHorse = avgTimeHorse;
-	}
-
-	public void setAvgTimeDriver(Float avgTimeDriver) {
-		this.avgTimeDriver = avgTimeDriver;
-	}
-	public float getSumAvgTimeHorse() {
-		return sumHorse;
-	}
-	public float getSumAvgTimeDriver() {
-		return sumDriver;
-	}
-	public void setSumAvgTimeHorse(float sumHorse) {
-		this.sumHorse = sumHorse;
-	}
-	public void setSumAvgTimeDriver(float sumDriver) {
-		this.sumDriver = sumDriver;
-	}
-
-	public float getSumHorse() {
-		return sumHorse;
-	}
-
-	public float getSumDriver() {
-		return sumDriver;
-	}
-
-	public int getRatingSumHorse() {
-		return ratingSumHorse;
-	}
-
-	public int getRatingSumDriver() {
-		return ratingSumDriver;
-	}
-
-	public int getRatingLastResultsTotal() {
-		return ratingLastResultsTotal;
-	}
-
-	public void setSumHorse(float sumHorse) {
-		this.sumHorse = sumHorse;
-	}
-
-	public void setSumDriver(float sumDriver) {
-		this.sumDriver = sumDriver;
-	}
-
-	public void setRatingSumHorse(int ratingSumHorse) {
-		this.ratingSumHorse = ratingSumHorse;
-	}
-
-	public void setRatingSumDriver(int ratingSumDriver) {
-		this.ratingSumDriver = ratingSumDriver;
-	}
-
-	public void setRatingLastResultsTotal(int ratingLastResultsTotal) {
-		this.ratingLastResultsTotal = ratingLastResultsTotal;
-	}
-
-	public int getSumRatings() {
-		return sumRatings;
-	}
-
-	public void setSumRatings(int sumRatings) {
-		this.sumRatings = sumRatings;
-	}
+    private int horseId;
+    private int driverId;
+    private int trainerId;
+    private final int raceNumber;
+    private final String raceDate;
+
+    private String trackName;
+
+    private String horseName;
+    private int lane;
+    private int distance;
+    private int result;
+    private float time;
+    private String timeModifier;
+    private String trainerName;
+    private String driverName;
+    private float laneWin;
+    private boolean betOn;
+
+    private String lastRacesDriver;
+    private String lastRacesHorse;
+    private String lastRacesBoth;
+    private float combinedLastRaces = 0f;
+
+    private Float avgTimeHorseChange;
+    private Float avgTimeDriverChange;
+
+    private Float avgTimeHorse;
+    private Float avgTimeDriver;
+
+    private float sumHorse;
+    private float sumDriver;
+
+    private int ratingSumHorse;
+    private int ratingSumDriver;
+    private int ratingLastResultsTotal;
+    private int sumRatings;
+
+    private boolean selected = false;
+
+    public ComparingResultsData(HorseRaceData data) {
+        horseName = data.getHorseName();
+        lane = data.getLane();
+        distance = data.getDistance();
+        result = data.getResult();
+        time = data.getTime();
+        timeModifier = data.getTimeModifier();
+        trainerName = data.getTrainerName();
+        driverName = data.getDriverName();
+        laneWin = data.getLaneWin();
+        horseId = data.getHorseId();
+        driverId = data.getDriverId();
+        trainerId = data.getTrainerId();
+        raceNumber = data.getRaceNumber();
+        raceDate = data.getRaceDate();
+        trackName = data.getTrackName();
+        betOn = false;
+    }
+
+    public int getLane() {
+        return lane;
+    }
+
+    public int getDistance() {
+        return distance;
+    }
+
+    public int getResult() {
+        return result;
+    }
+
+    public float getTime() {
+        return time;
+    }
+
+    public String getTimeModifier() {
+        return timeModifier;
+    }
+
+    public String getTrainerName() {
+        return trainerName;
+    }
+
+    public String getDriverName() {
+        return driverName;
+    }
+
+    public void setLane(int lane) {
+        this.lane = lane;
+    }
+
+    public void setDistance(int distance) {
+        this.distance = distance;
+    }
+
+    public void setResult(int result) {
+        this.result = result;
+    }
+
+    public void setTime(float time) {
+        this.time = time;
+    }
+
+    public void setTimeModifier(String timeModifier) {
+        this.timeModifier = timeModifier;
+    }
+
+    public void setTrainerName(String trainerName) {
+        this.trainerName = trainerName;
+    }
+
+    public void setDriverName(String driverName) {
+        this.driverName = driverName;
+    }
+
+    public String getHorseName() {
+        return horseName;
+    }
+
+    public void setHorseName(String horseName) {
+        this.horseName = horseName;
+    }
+
+    public float getLaneWin() {
+        return laneWin;
+    }
+
+    public void setLaneWin(float laneWin) {
+        this.laneWin = laneWin;
+    }
+
+    public static ArrayList<ComparingResultsData> convertHorseRaceDataList(List<HorseRaceData> races) {
+        final ArrayList<ComparingResultsData> returnArray = new ArrayList<>();
+
+        for (final HorseRaceData data : races) {
+            returnArray.add(new ComparingResultsData(data));
+        }
+
+        return returnArray;
+    }
+
+    public int getHorseId() {
+        return horseId;
+    }
+
+    public int getDriverId() {
+        return driverId;
+    }
+
+    public int getTrainerId() {
+        return trainerId;
+    }
+
+    public void setHorseId(int horseId) {
+        this.horseId = horseId;
+    }
+
+    public void setDriverId(int driverId) {
+        this.driverId = driverId;
+    }
+
+    public void setTrainerId(int trainerId) {
+        this.trainerId = trainerId;
+    }
+
+    public int getRaceNumber() {
+        return raceNumber;
+    }
+
+    public String getRaceDate() {
+        return raceDate;
+    }
+
+    public String getLastRacesDriver() {
+        return lastRacesDriver;
+    }
+
+    public String getLastRacesHorse() {
+        return lastRacesHorse;
+    }
+
+    public String getLastRacesBoth() {
+        return lastRacesBoth;
+    }
+
+    public void setLastRacesDriver(String lastRacesDriver) {
+        final float val = Float.valueOf(lastRacesDriver.substring(0, lastRacesDriver.indexOf("(") - 1));
+        if (val <= 0) {
+            combinedLastRaces += 8f;
+        } else {
+            combinedLastRaces += val;
+        }
+        this.lastRacesDriver = lastRacesDriver;
+    }
+
+    public void setLastRacesHorse(String lastRacesHorse) {
+        final float val = Float.valueOf(lastRacesHorse.substring(0, lastRacesHorse.indexOf("(") - 1));
+        if (val <= 0) {
+            combinedLastRaces += 8f;
+        } else {
+            combinedLastRaces += val;
+        }
+        this.lastRacesHorse = lastRacesHorse;
+    }
+
+    public void setLastRacesBoth(String lastRacesBoth) {
+        final float val = Float.valueOf(lastRacesBoth.substring(0, lastRacesBoth.indexOf("(") - 1));
+        if (val <= 0) {
+            combinedLastRaces += 8f;
+        } else {
+            combinedLastRaces += val;
+        }
+        this.lastRacesBoth = lastRacesBoth;
+    }
+
+    public float getCombinedLastRaces() {
+        return combinedLastRaces;
+    }
+
+    public String getTrackName() {
+        return trackName;
+    }
+
+    public void setTrackName(String trackName) {
+        this.trackName = trackName;
+    }
+
+    public Float getAvgTimeHorseChange() {
+        return avgTimeHorseChange;
+    }
+
+    public void setAvgTimeHorseChange(float avgHorseTime) {
+        this.avgTimeHorseChange = avgHorseTime;
+    }
+
+    public Float getAvgTimeDriverChange() {
+        return avgTimeDriverChange;
+    }
+
+    public void setAvgTimeDriverChange(Float avgTimeDriver) {
+        this.avgTimeDriverChange = avgTimeDriver;
+    }
+
+    public Float getAvgTimeHorse() {
+        return avgTimeHorse;
+    }
+
+    public Float getAvgTimeDriver() {
+        return avgTimeDriver;
+    }
+
+    public void setCombinedLastRaces(float combinedLastRaces) {
+        this.combinedLastRaces = combinedLastRaces;
+    }
+
+    public void setAvgTimeHorseChange(Float avgTimeHorseChange) {
+        this.avgTimeHorseChange = avgTimeHorseChange;
+    }
+
+    public void setAvgTimeHorse(Float avgTimeHorse) {
+        this.avgTimeHorse = avgTimeHorse;
+    }
+
+    public void setAvgTimeDriver(Float avgTimeDriver) {
+        this.avgTimeDriver = avgTimeDriver;
+    }
+
+    public float getSumAvgTimeHorse() {
+        return sumHorse;
+    }
+
+    public float getSumAvgTimeDriver() {
+        return sumDriver;
+    }
+
+    public void setSumAvgTimeHorse(float sumHorse) {
+        this.sumHorse = sumHorse;
+    }
+
+    public void setSumAvgTimeDriver(float sumDriver) {
+        this.sumDriver = sumDriver;
+    }
+
+    public float getSumHorse() {
+        return sumHorse;
+    }
+
+    public float getSumDriver() {
+        return sumDriver;
+    }
+
+    public int getRatingSumHorse() {
+        return ratingSumHorse;
+    }
+
+    public int getRatingSumDriver() {
+        return ratingSumDriver;
+    }
+
+    public int getRatingLastResultsTotal() {
+        return ratingLastResultsTotal;
+    }
+
+    public void setSumHorse(float sumHorse) {
+        this.sumHorse = sumHorse;
+    }
+
+    public void setSumDriver(float sumDriver) {
+        this.sumDriver = sumDriver;
+    }
+
+    public void setRatingSumHorse(int ratingSumHorse) {
+        this.ratingSumHorse = ratingSumHorse;
+    }
+
+    public void setRatingSumDriver(int ratingSumDriver) {
+        this.ratingSumDriver = ratingSumDriver;
+    }
+
+    public void setRatingLastResultsTotal(int ratingLastResultsTotal) {
+        this.ratingLastResultsTotal = ratingLastResultsTotal;
+    }
+
+    public int getSumRatings() {
+        return sumRatings;
+    }
+
+    public void setSumRatings(int sumRatings) {
+        this.sumRatings = sumRatings;
+    }
+
+    public void setBetOn(boolean value) {
+        betOn = value;
+    }
+
+    public boolean getBetOn() {
+        return betOn;
+    }
+
+    public boolean isSelected() {
+        return selected;
+    }
+
+    public void setSelected(boolean selected) {
+        this.selected = selected;
+    }
 }

+ 409 - 147
ATG/src/objects/NewTabRaceTableView.java

@@ -1,6 +1,7 @@
 package objects;
 
 import java.util.AbstractMap.SimpleEntry;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Optional;
 import java.util.stream.Collectors;
@@ -13,14 +14,26 @@ import database.Database;
 import database.DriverDB;
 import database.Ekipage;
 import database.Horse;
+import javafx.beans.value.ChangeListener;
+import javafx.beans.value.ObservableValue;
 import javafx.collections.ObservableList;
+import javafx.scene.Node;
+import javafx.scene.control.CheckBox;
+import javafx.scene.control.ContentDisplay;
 import javafx.scene.control.SelectionMode;
 import javafx.scene.control.Tab;
 import javafx.scene.control.TabPane;
+import javafx.scene.control.TableCell;
 import javafx.scene.control.TableColumn;
+import javafx.scene.control.TableRow;
 import javafx.scene.control.TableView;
 import javafx.scene.control.TableView.TableViewSelectionModel;
+import javafx.scene.control.TextField;
 import javafx.scene.control.cell.PropertyValueFactory;
+import javafx.scene.layout.HBox;
+import javafx.scene.layout.Pane;
+import javafx.scene.layout.VBox;
+import javafx.util.Callback;
 
 public class NewTabRaceTableView extends Tab {
 
@@ -36,6 +49,8 @@ public class NewTabRaceTableView extends Tab {
 
     private ComparingResultsData lastSelected;
 
+    private VBox betSlip;
+
     public NewTabRaceTableView(SimpleEntry<String, List<HorseRaceData>> trackRaces) {
 
         setText(trackRaces.getKey());
@@ -47,8 +62,9 @@ public class NewTabRaceTableView extends Tab {
         this.setContent(racesTabs);
 
         for (final Integer rn : raceNumbers) {
-            addRaceNumberTab(rn, ComparingResultsData.convertHorseRaceDataList(
-                    this.trackRaces.stream().filter(p -> p.getRaceNumber() == rn).collect(Collectors.toList())));
+            addRaceNumberTab(rn,
+                    ComparingResultsData.convertHorseRaceDataList(
+                            this.trackRaces.stream().filter(p -> p.getRaceNumber() == rn).collect(Collectors.toList())));
         }
     }
 
@@ -104,27 +120,55 @@ public class NewTabRaceTableView extends Tab {
             if (selectedItems.size() == 2) {
                 final ComparingResultsData firstSel
                         = selectedItems.stream().filter(p -> !p.equals(newSelection)).collect(Collectors.toList()).get(0);
+
                 horseController.setAvgTimeLabel(horseDb.avarageTime(firstSel.getHorseId(), firstSel.getRaceDate()),
-                        databaseb.getAvgTime(), horseDb.avarageTime(newSelection.getHorseId(), newSelection.getRaceDate()));
+                        databaseb.getAvgTime(),
+                        horseDb.avarageTime(newSelection.getHorseId(), newSelection.getRaceDate()));
+
+                horseController.setAvgTimeLimit5Label(
+                        horseDb.avarageTimeWithLimit(firstSel.getHorseId(), 5, firstSel.getRaceDate()),
+                        horseDb.getAvgTimeWithLimit(5),
+                        horseDb.avarageTimeWithLimit(newSelection.getHorseId(), 5, newSelection.getRaceDate()));
+
+                horseController.setAvgTimeLimit10Label(
+                        horseDb.avarageTimeWithLimit(firstSel.getHorseId(), 10, firstSel.getRaceDate()),
+                        horseDb.getAvgTimeWithLimit(10),
+                        horseDb.avarageTimeWithLimit(newSelection.getHorseId(), 10, newSelection.getRaceDate()));
+
+                horseController.setAvgTimeLimit15Label(
+                        horseDb.avarageTimeWithLimit(firstSel.getHorseId(), 15, firstSel.getRaceDate()),
+                        horseDb.getAvgTimeWithLimit(15),
+                        horseDb.avarageTimeWithLimit(newSelection.getHorseId(), 15, newSelection.getRaceDate()));
 
                 horseController.setAvgTimeDistanceLabel(
                         horseDb.avarageTimeByDistance(firstSel.getHorseId(), firstSel.getDistance(), firstSel.getRaceDate()),
-                        databaseb.getAvgTimeByDistance(newSelection.getDistance()), horseDb.avarageTimeByDistance(
-                                newSelection.getHorseId(), newSelection.getDistance(), newSelection.getRaceDate()));
+                        databaseb.getAvgTimeByDistance(newSelection.getDistance()),
+                        horseDb.avarageTimeByDistance(newSelection.getHorseId(),
+                                newSelection.getDistance(),
+                                newSelection.getRaceDate()));
 
                 horseController.setAvgTimeDistance5LabelWithCompare(
                         horseDb.avarageTimeByDistance(firstSel.getHorseId(), firstSel.getDistance(), 5, firstSel.getRaceDate()),
-                        databaseb.getAvgTimeByDistanceLimit(newSelection.getDistance(), 5), horseDb.avarageTimeByDistance(
-                                newSelection.getHorseId(), newSelection.getDistance(), 5, newSelection.getRaceDate()));
+                        databaseb.getAvgTimeByDistanceLimit(newSelection.getDistance(), 5),
+                        horseDb.avarageTimeByDistance(newSelection.getHorseId(),
+                                newSelection.getDistance(),
+                                5,
+                                newSelection.getRaceDate()));
 
                 horseController.setAvgTimeDistanceLimit10Label(
                         horseDb.avarageTimeByDistance(firstSel.getHorseId(), firstSel.getDistance(), 10, firstSel.getRaceDate()),
-                        databaseb.getAvgTimeByDistanceLimit(newSelection.getDistance(), 10), horseDb.avarageTimeByDistance(
-                                newSelection.getHorseId(), newSelection.getDistance(), 10, newSelection.getRaceDate()));
+                        databaseb.getAvgTimeByDistanceLimit(newSelection.getDistance(), 10),
+                        horseDb.avarageTimeByDistance(newSelection.getHorseId(),
+                                newSelection.getDistance(),
+                                10,
+                                newSelection.getRaceDate()));
                 horseController.setAvgTimeDistanceLimit15Label(
                         horseDb.avarageTimeByDistance(firstSel.getHorseId(), firstSel.getDistance(), 15, firstSel.getRaceDate()),
-                        databaseb.getAvgTimeByDistanceLimit(newSelection.getDistance(), 15), horseDb.avarageTimeByDistance(
-                                newSelection.getHorseId(), newSelection.getDistance(), 15, newSelection.getRaceDate()));
+                        databaseb.getAvgTimeByDistanceLimit(newSelection.getDistance(), 15),
+                        horseDb.avarageTimeByDistance(newSelection.getHorseId(),
+                                newSelection.getDistance(),
+                                15,
+                                newSelection.getRaceDate()));
 
                 horseController.setAvgPosition(horseDb.avaragePlacement(firstSel.getHorseId(), firstSel.getRaceDate()),
                         horseDb.avaragePlacement(newSelection.getHorseId(), newSelection.getRaceDate()));
@@ -139,49 +183,77 @@ public class NewTabRaceTableView extends Tab {
                         horseDb.avaragePlacementWithLimit(firstSel.getHorseId(), 15, firstSel.getRaceDate()),
                         horseDb.avaragePlacementWithLimit(newSelection.getHorseId(), 15, newSelection.getRaceDate()));
 
-                horseController.setAvgPositionDistanceLast5(
-                        horseDb.avaragePlacementByDistance(firstSel.getHorseId(), firstSel.getDistance(), 5,
-                                firstSel.getRaceDate()),
-                        horseDb.avaragePlacementByDistance(newSelection.getHorseId(), newSelection.getDistance(), 5,
+                horseController.setAvgPositionDistanceLast5(horseDb
+                        .avaragePlacementByDistance(firstSel.getHorseId(), firstSel.getDistance(), 5, firstSel.getRaceDate()),
+                        horseDb.avaragePlacementByDistance(newSelection.getHorseId(),
+                                newSelection.getDistance(),
+                                5,
                                 newSelection.getRaceDate()));
 
-                horseController.setAvgPositionDistanceLast10(
-                        horseDb.avaragePlacementByDistance(firstSel.getHorseId(), firstSel.getDistance(), 10,
-                                firstSel.getRaceDate()),
-                        horseDb.avaragePlacementByDistance(newSelection.getHorseId(), newSelection.getDistance(), 10,
+                horseController.setAvgPositionDistanceLast10(horseDb
+                        .avaragePlacementByDistance(firstSel.getHorseId(), firstSel.getDistance(), 10, firstSel.getRaceDate()),
+                        horseDb.avaragePlacementByDistance(newSelection.getHorseId(),
+                                newSelection.getDistance(),
+                                10,
                                 newSelection.getRaceDate()));
 
-                horseController.setAvgPositionDistanceLast15(
-                        horseDb.avaragePlacementByDistance(firstSel.getHorseId(), firstSel.getDistance(), 15,
-                                firstSel.getRaceDate()),
-                        horseDb.avaragePlacementByDistance(newSelection.getHorseId(), newSelection.getDistance(), 15,
+                horseController.setAvgPositionDistanceLast15(horseDb
+                        .avaragePlacementByDistance(firstSel.getHorseId(), firstSel.getDistance(), 15, firstSel.getRaceDate()),
+                        horseDb.avaragePlacementByDistance(newSelection.getHorseId(),
+                                newSelection.getDistance(),
+                                15,
                                 newSelection.getRaceDate()));
 
                 // Driver
 
                 driverController.setAvgTimeLabel(driverDb.avarageTime(firstSel.getDriverId(), firstSel.getRaceDate()),
-                        databaseb.getAvgTime(), driverDb.avarageTime(newSelection.getDriverId(), newSelection.getRaceDate()));
+                        databaseb.getAvgTime(),
+                        driverDb.avarageTime(newSelection.getDriverId(), newSelection.getRaceDate()));
+
+                driverController.setAvgTimeLimit5Label(
+                        driverDb.avarageTimeWithLimit(firstSel.getDriverId(), 5, firstSel.getRaceDate()),
+                        driverDb.getAvgTimeWithLimit(5),
+                        driverDb.avarageTimeWithLimit(newSelection.getDriverId(), 5, newSelection.getRaceDate()));
+
+                driverController.setAvgTimeLimit10Label(
+                        driverDb.avarageTimeWithLimit(firstSel.getDriverId(), 10, firstSel.getRaceDate()),
+                        driverDb.getAvgTimeWithLimit(10),
+                        driverDb.avarageTimeWithLimit(newSelection.getDriverId(), 10, newSelection.getRaceDate()));
+
+                driverController.setAvgTimeLimit15Label(
+                        driverDb.avarageTimeWithLimit(firstSel.getDriverId(), 15, firstSel.getRaceDate()),
+                        driverDb.getAvgTimeWithLimit(15),
+                        driverDb.avarageTimeWithLimit(newSelection.getDriverId(), 15, newSelection.getRaceDate()));
 
                 driverController.setAvgTimeDistanceLabel(
                         driverDb.avarageTimeByDistance(firstSel.getDriverId(), firstSel.getDistance(), firstSel.getRaceDate()),
-                        databaseb.getAvgTimeByDistance(newSelection.getDistance()), driverDb.avarageTimeByDistance(
-                                newSelection.getDriverId(), newSelection.getDistance(), newSelection.getRaceDate()));
+                        databaseb.getAvgTimeByDistance(newSelection.getDistance()),
+                        driverDb.avarageTimeByDistance(newSelection.getDriverId(),
+                                newSelection.getDistance(),
+                                newSelection.getRaceDate()));
 
                 driverController.setAvgTimeDistance5LabelWithCompare(
                         driverDb.avarageTimeByDistance(firstSel.getDriverId(), firstSel.getDistance(), 5, firstSel.getRaceDate()),
-                        databaseb.getAvgTimeByDistanceLimit(newSelection.getDistance(), 5), driverDb.avarageTimeByDistance(
-                                newSelection.getDriverId(), newSelection.getDistance(), 5, newSelection.getRaceDate()));
+                        databaseb.getAvgTimeByDistanceLimit(newSelection.getDistance(), 5),
+                        driverDb.avarageTimeByDistance(newSelection.getDriverId(),
+                                newSelection.getDistance(),
+                                5,
+                                newSelection.getRaceDate()));
 
-                driverController.setAvgTimeDistanceLimit10Label(
-                        driverDb.avarageTimeByDistance(firstSel.getDriverId(), firstSel.getDistance(), 10,
-                                firstSel.getRaceDate()),
-                        databaseb.getAvgTimeByDistanceLimit(newSelection.getDistance(), 10), driverDb.avarageTimeByDistance(
-                                newSelection.getDriverId(), newSelection.getDistance(), 10, newSelection.getRaceDate()));
-                driverController.setAvgTimeDistanceLimit15Label(
-                        driverDb.avarageTimeByDistance(firstSel.getDriverId(), firstSel.getDistance(), 15,
-                                firstSel.getRaceDate()),
-                        databaseb.getAvgTimeByDistanceLimit(newSelection.getDistance(), 15), driverDb.avarageTimeByDistance(
-                                newSelection.getDriverId(), newSelection.getDistance(), 15, newSelection.getRaceDate()));
+                driverController.setAvgTimeDistanceLimit10Label(driverDb
+                        .avarageTimeByDistance(firstSel.getDriverId(), firstSel.getDistance(), 10, firstSel.getRaceDate()),
+                        databaseb.getAvgTimeByDistanceLimit(newSelection.getDistance(), 10),
+                        driverDb.avarageTimeByDistance(newSelection.getDriverId(),
+                                newSelection.getDistance(),
+                                10,
+                                newSelection.getRaceDate()));
+                driverController.setAvgTimeDistanceLimit15Label(driverDb
+                        .avarageTimeByDistance(firstSel.getDriverId(), firstSel.getDistance(), 15, firstSel.getRaceDate()),
+                        databaseb.getAvgTimeByDistanceLimit(newSelection.getDistance(), 15),
+                        driverDb.avarageTimeByDistance(newSelection.getDriverId(),
+                                newSelection.getDistance(),
+                                15,
+                                newSelection.getRaceDate()));
 
                 driverController.setAvgPosition(driverDb.avaragePlacement(firstSel.getDriverId(), firstSel.getRaceDate()),
                         driverDb.avaragePlacement(newSelection.getDriverId(), newSelection.getRaceDate()));
@@ -195,22 +267,25 @@ public class NewTabRaceTableView extends Tab {
                         driverDb.avaragePlacementWithLimit(firstSel.getDriverId(), 15, firstSel.getRaceDate()),
                         driverDb.avaragePlacementWithLimit(newSelection.getDriverId(), 15, newSelection.getRaceDate()));
 
-                driverController.setAvgPositionDistanceLast5(
-                        driverDb.avaragePlacementByDistance(firstSel.getDriverId(), firstSel.getDistance(), 5,
-                                firstSel.getRaceDate()),
-                        driverDb.avaragePlacementByDistance(newSelection.getDriverId(), newSelection.getDistance(), 5,
+                driverController.setAvgPositionDistanceLast5(driverDb
+                        .avaragePlacementByDistance(firstSel.getDriverId(), firstSel.getDistance(), 5, firstSel.getRaceDate()),
+                        driverDb.avaragePlacementByDistance(newSelection.getDriverId(),
+                                newSelection.getDistance(),
+                                5,
                                 newSelection.getRaceDate()));
 
-                driverController.setAvgPositionDistanceLast10(
-                        driverDb.avaragePlacementByDistance(firstSel.getDriverId(), firstSel.getDistance(), 10,
-                                firstSel.getRaceDate()),
-                        driverDb.avaragePlacementByDistance(newSelection.getDriverId(), newSelection.getDistance(), 10,
+                driverController.setAvgPositionDistanceLast10(driverDb
+                        .avaragePlacementByDistance(firstSel.getDriverId(), firstSel.getDistance(), 10, firstSel.getRaceDate()),
+                        driverDb.avaragePlacementByDistance(newSelection.getDriverId(),
+                                newSelection.getDistance(),
+                                10,
                                 newSelection.getRaceDate()));
 
-                driverController.setAvgPositionDistanceLast15(
-                        driverDb.avaragePlacementByDistance(firstSel.getDriverId(), firstSel.getDistance(), 15,
-                                firstSel.getRaceDate()),
-                        driverDb.avaragePlacementByDistance(newSelection.getDriverId(), newSelection.getDistance(), 15,
+                driverController.setAvgPositionDistanceLast15(driverDb
+                        .avaragePlacementByDistance(firstSel.getDriverId(), firstSel.getDistance(), 15, firstSel.getRaceDate()),
+                        driverDb.avaragePlacementByDistance(newSelection.getDriverId(),
+                                newSelection.getDistance(),
+                                15,
                                 newSelection.getRaceDate()));
 
                 // Ekipage
@@ -220,88 +295,151 @@ public class NewTabRaceTableView extends Tab {
                         databaseb.getAvgTime(),
                         ekipageDb.avarageTime(newSelection.getDriverId(), newSelection.getHorseId(), newSelection.getRaceDate()));
 
+                ekipageController.setAvgTimeLimit5Label(
+                        ekipageDb.avarageTimeWithLimit(firstSel.getDriverId(), firstSel.getHorseId(), 5, firstSel.getRaceDate()),
+                        databaseb.getAvgTimeWithLimit(5),
+                        ekipageDb.avarageTimeWithLimit(newSelection.getDriverId(),
+                                newSelection.getHorseId(),
+                                5,
+                                newSelection.getRaceDate()));
+
+                ekipageController.setAvgTimeLimit10Label(
+                        ekipageDb.avarageTimeWithLimit(firstSel.getDriverId(), firstSel.getHorseId(), 10, firstSel.getRaceDate()),
+                        databaseb.getAvgTimeWithLimit(10),
+                        ekipageDb.avarageTimeWithLimit(newSelection.getDriverId(),
+                                newSelection.getHorseId(),
+                                10,
+                                newSelection.getRaceDate()));
+
+                ekipageController.setAvgTimeLimit15Label(
+                        ekipageDb.avarageTimeWithLimit(firstSel.getDriverId(), firstSel.getHorseId(), 15, firstSel.getRaceDate()),
+                        databaseb.getAvgTimeWithLimit(15),
+                        ekipageDb.avarageTimeWithLimit(newSelection.getDriverId(),
+                                newSelection.getHorseId(),
+                                15,
+                                newSelection.getRaceDate()));
+
                 ekipageController.setAvgTimeDistanceLabel(
-                        ekipageDb.avarageTimeByDistance(firstSel.getHorseId(), firstSel.getDriverId(), firstSel.getDistance(),
-                                newSelection.getRaceDate()),
+                        ekipageDb.avarageTimeByDistance(firstSel.getDriverId(),
+                                firstSel.getHorseId(),
+                                firstSel.getDistance(),
+                                firstSel.getRaceDate()),
                         databaseb.getAvgTimeByDistance(newSelection.getDistance()),
-                        ekipageDb.avarageTimeByDistance(newSelection.getDriverId(), newSelection.getHorseId(),
-                                newSelection.getDistance(), firstSel.getRaceDate()));
+                        ekipageDb.avarageTimeByDistance(newSelection.getDriverId(),
+                                newSelection.getHorseId(),
+                                newSelection.getDistance(),
+                                newSelection.getRaceDate()));
 
                 ekipageController.setAvgTimeDistance5LabelWithCompare(
-                        ekipageDb.avarageTimeByDistance(firstSel.getDriverId(), firstSel.getHorseId(), firstSel.getDistance(), 5,
-                                newSelection.getRaceDate()),
+                        ekipageDb.avarageTimeByDistance(firstSel
+                                .getDriverId(), firstSel.getHorseId(), firstSel.getDistance(), 5, newSelection.getRaceDate()),
                         databaseb.getAvgTimeByDistanceLimit(newSelection.getDistance(), 5),
-                        ekipageDb.avarageTimeByDistance(newSelection.getDriverId(), newSelection.getHorseId(),
-                                newSelection.getDistance(), 5, firstSel.getRaceDate()));
+                        ekipageDb.avarageTimeByDistance(newSelection.getDriverId(),
+                                newSelection.getHorseId(),
+                                newSelection.getDistance(),
+                                5,
+                                firstSel.getRaceDate()));
 
                 ekipageController.setAvgTimeDistanceLimit10Label(
-                        ekipageDb.avarageTimeByDistance(firstSel.getDriverId(), firstSel.getHorseId(), firstSel.getDistance(), 10,
-                                newSelection.getRaceDate()),
+                        ekipageDb.avarageTimeByDistance(firstSel
+                                .getDriverId(), firstSel.getHorseId(), firstSel.getDistance(), 10, newSelection.getRaceDate()),
                         databaseb.getAvgTimeByDistanceLimit(newSelection.getDistance(), 10),
-                        ekipageDb.avarageTimeByDistance(newSelection.getDriverId(), newSelection.getHorseId(),
-                                newSelection.getDistance(), 10, firstSel.getRaceDate()));
+                        ekipageDb.avarageTimeByDistance(newSelection.getDriverId(),
+                                newSelection.getHorseId(),
+                                newSelection.getDistance(),
+                                10,
+                                firstSel.getRaceDate()));
                 ekipageController.setAvgTimeDistanceLimit15Label(
-                        ekipageDb.avarageTimeByDistance(firstSel.getDriverId(), firstSel.getHorseId(), firstSel.getDistance(), 15,
-                                newSelection.getRaceDate()),
+                        ekipageDb.avarageTimeByDistance(firstSel
+                                .getDriverId(), firstSel.getHorseId(), firstSel.getDistance(), 15, newSelection.getRaceDate()),
                         databaseb.getAvgTimeByDistanceLimit(newSelection.getDistance(), 15),
-                        ekipageDb.avarageTimeByDistance(newSelection.getDriverId(), newSelection.getHorseId(),
-                                newSelection.getDistance(), 15, firstSel.getRaceDate()));
+                        ekipageDb.avarageTimeByDistance(newSelection.getDriverId(),
+                                newSelection.getHorseId(),
+                                newSelection.getDistance(),
+                                15,
+                                firstSel.getRaceDate()));
 
                 ekipageController.setAvgPosition(
                         ekipageDb.avaragePlacement(firstSel.getDriverId(), firstSel.getHorseId(), firstSel.getRaceDate()),
-                        ekipageDb.avaragePlacement(newSelection.getDriverId(), newSelection.getHorseId(),
+                        ekipageDb.avaragePlacement(newSelection.getDriverId(),
+                                newSelection.getHorseId(),
                                 newSelection.getRaceDate()));
-                ekipageController.setAvgPositionLast5(
-                        ekipageDb.avaragePlacementWithLimit(firstSel.getDriverId(), firstSel.getHorseId(), 5,
-                                firstSel.getRaceDate()),
-                        ekipageDb.avaragePlacementWithLimit(newSelection.getDriverId(), newSelection.getHorseId(), 5,
+                ekipageController.setAvgPositionLast5(ekipageDb
+                        .avaragePlacementWithLimit(firstSel.getDriverId(), firstSel.getHorseId(), 5, firstSel.getRaceDate()),
+                        ekipageDb.avaragePlacementWithLimit(newSelection.getDriverId(),
+                                newSelection.getHorseId(),
+                                5,
                                 newSelection.getRaceDate()));
-                ekipageController.setAvgPositionLast10(
-                        ekipageDb.avaragePlacementWithLimit(firstSel.getDriverId(), firstSel.getHorseId(), 10,
-                                firstSel.getRaceDate()),
-                        ekipageDb.avaragePlacementWithLimit(newSelection.getDriverId(), newSelection.getHorseId(), 10,
+                ekipageController.setAvgPositionLast10(ekipageDb
+                        .avaragePlacementWithLimit(firstSel.getDriverId(), firstSel.getHorseId(), 10, firstSel.getRaceDate()),
+                        ekipageDb.avaragePlacementWithLimit(newSelection.getDriverId(),
+                                newSelection.getHorseId(),
+                                10,
                                 newSelection.getRaceDate()));
-                ekipageController.setAvgPositionLast15(
-                        ekipageDb.avaragePlacementWithLimit(firstSel.getDriverId(), firstSel.getHorseId(), 15,
-                                firstSel.getRaceDate()),
-                        ekipageDb.avaragePlacementWithLimit(newSelection.getDriverId(), newSelection.getHorseId(), 15,
+                ekipageController.setAvgPositionLast15(ekipageDb
+                        .avaragePlacementWithLimit(firstSel.getDriverId(), firstSel.getHorseId(), 15, firstSel.getRaceDate()),
+                        ekipageDb.avaragePlacementWithLimit(newSelection.getDriverId(),
+                                newSelection.getHorseId(),
+                                15,
                                 newSelection.getRaceDate()));
 
                 ekipageController.setAvgPositionDistanceLast5(
-                        ekipageDb.avaragePlacementByDistance(firstSel.getDriverId(), firstSel.getHorseId(),
-                                firstSel.getDistance(), 5, firstSel.getRaceDate()),
-                        ekipageDb.avaragePlacementByDistance(newSelection.getDriverId(), newSelection.getHorseId(),
-                                newSelection.getDistance(), 5, newSelection.getRaceDate()));
+                        ekipageDb.avaragePlacementByDistance(firstSel
+                                .getDriverId(), firstSel.getHorseId(), firstSel.getDistance(), 5, firstSel.getRaceDate()),
+                        ekipageDb.avaragePlacementByDistance(newSelection.getDriverId(),
+                                newSelection.getHorseId(),
+                                newSelection.getDistance(),
+                                5,
+                                newSelection.getRaceDate()));
 
                 ekipageController.setAvgPositionDistanceLast10(
-                        ekipageDb.avaragePlacementByDistance(firstSel.getDriverId(), firstSel.getHorseId(),
-                                firstSel.getDistance(), 10, firstSel.getRaceDate()),
-                        ekipageDb.avaragePlacementByDistance(newSelection.getDriverId(), newSelection.getHorseId(),
-                                newSelection.getDistance(), 10, newSelection.getRaceDate()));
+                        ekipageDb.avaragePlacementByDistance(firstSel
+                                .getDriverId(), firstSel.getHorseId(), firstSel.getDistance(), 10, firstSel.getRaceDate()),
+                        ekipageDb.avaragePlacementByDistance(newSelection.getDriverId(),
+                                newSelection.getHorseId(),
+                                newSelection.getDistance(),
+                                10,
+                                newSelection.getRaceDate()));
 
                 ekipageController.setAvgPositionDistanceLast15(
-                        ekipageDb.avaragePlacementByDistance(firstSel.getDriverId(), firstSel.getHorseId(),
-                                firstSel.getDistance(), 15, firstSel.getRaceDate()),
-                        ekipageDb.avaragePlacementByDistance(newSelection.getDriverId(), newSelection.getHorseId(),
-                                newSelection.getDistance(), 15, newSelection.getRaceDate()));
+                        ekipageDb.avaragePlacementByDistance(firstSel
+                                .getDriverId(), firstSel.getHorseId(), firstSel.getDistance(), 15, firstSel.getRaceDate()),
+                        ekipageDb.avaragePlacementByDistance(newSelection.getDriverId(),
+                                newSelection.getHorseId(),
+                                newSelection.getDistance(),
+                                15,
+                                newSelection.getRaceDate()));
             } else {
                 horseController.setAvgTimeLabel(
                         String.valueOf(horseDb.avarageTime(newSelection.getHorseId(), newSelection.getRaceDate())) + "("
                                 + String.valueOf(databaseb.getAvgTime()) + ")");
-                horseController.setAvgTimeDistanceLabel(String
-                        .valueOf(horseDb.avarageTimeByDistance(newSelection.getHorseId(), newSelection.getDistance(),
-                                newSelection.getRaceDate()))
+
+                horseController.setAvgTimeLimit5Label(
+                        horseDb.avarageTimeWithLimit(newSelection.getHorseId(), 5, newSelection.getRaceDate()));
+                horseController.setAvgTimeLimit10Label(
+                        horseDb.avarageTimeWithLimit(newSelection.getHorseId(), 10, newSelection.getRaceDate()));
+                horseController.setAvgTimeLimit15Label(
+                        horseDb.avarageTimeWithLimit(newSelection.getHorseId(), 15, newSelection.getRaceDate()));
+
+                horseController.setAvgTimeDistanceLabel(String.valueOf(horseDb
+                        .avarageTimeByDistance(newSelection.getHorseId(), newSelection.getDistance(), newSelection.getRaceDate()))
                         + "(" + String.valueOf(databaseb.getAvgTimeByDistance(newSelection.getDistance())) + ")");
                 horseController.setAvgTimeDistanceLimit5Label(String
-                        .valueOf(horseDb.avarageTimeByDistance(newSelection.getHorseId(), newSelection.getDistance(), 5,
+                        .valueOf(horseDb.avarageTimeByDistance(newSelection.getHorseId(),
+                                newSelection.getDistance(),
+                                5,
                                 newSelection.getRaceDate()))
                         + "(" + String.valueOf(databaseb.getAvgTimeByDistanceLimit(newSelection.getDistance(), 5)) + ")");
                 horseController.setAvgTimeDistanceLimit10Label(String
-                        .valueOf(horseDb.avarageTimeByDistance(newSelection.getHorseId(), newSelection.getDistance(), 10,
+                        .valueOf(horseDb.avarageTimeByDistance(newSelection.getHorseId(),
+                                newSelection.getDistance(),
+                                10,
                                 newSelection.getRaceDate()))
                         + "(" + String.valueOf(databaseb.getAvgTimeByDistanceLimit(newSelection.getDistance(), 10)) + ")");
                 horseController.setAvgTimeDistanceLimit15Label(String
-                        .valueOf(horseDb.avarageTimeByDistance(newSelection.getHorseId(), newSelection.getDistance(), 15,
+                        .valueOf(horseDb.avarageTimeByDistance(newSelection.getHorseId(),
+                                newSelection.getDistance(),
+                                15,
                                 newSelection.getRaceDate()))
                         + "(" + String.valueOf(databaseb.getAvgTimeByDistanceLimit(newSelection.getDistance(), 15)) + ")");
 
@@ -315,33 +453,45 @@ public class NewTabRaceTableView extends Tab {
                 horseController.setAvgPositionLast15(String
                         .valueOf(horseDb.avaragePlacementWithLimit(newSelection.getHorseId(), 15, newSelection.getRaceDate())));
 
-                horseController
-                        .setAvgPositionDistanceLast5(String.valueOf(horseDb.avaragePlacementByDistance(newSelection.getHorseId(),
-                                newSelection.getDistance(), 5, newSelection.getRaceDate())));
-                horseController
-                        .setAvgPositionDistanceLast10(String.valueOf(horseDb.avaragePlacementByDistance(newSelection.getHorseId(),
-                                newSelection.getDistance(), 10, newSelection.getRaceDate())));
-                horseController
-                        .setAvgPositionDistanceLast15(String.valueOf(horseDb.avaragePlacementByDistance(newSelection.getHorseId(),
-                                newSelection.getDistance(), 15, newSelection.getRaceDate())));
+                horseController.setAvgPositionDistanceLast5(String.valueOf(horseDb.avaragePlacementByDistance(newSelection
+                        .getHorseId(), newSelection.getDistance(), 5, newSelection.getRaceDate())));
+                horseController.setAvgPositionDistanceLast10(String.valueOf(horseDb.avaragePlacementByDistance(newSelection
+                        .getHorseId(), newSelection.getDistance(), 10, newSelection.getRaceDate())));
+                horseController.setAvgPositionDistanceLast15(String.valueOf(horseDb.avaragePlacementByDistance(newSelection
+                        .getHorseId(), newSelection.getDistance(), 15, newSelection.getRaceDate())));
 
                 driverController.setAvgTimeLabel(
                         String.valueOf(driverDb.avarageTime(newSelection.getDriverId(), newSelection.getRaceDate())) + "("
                                 + String.valueOf(databaseb.getAvgTime()) + ")");
+
+                driverController.setAvgTimeLimit5Label(
+                        driverDb.avarageTimeWithLimit(newSelection.getDriverId(), 5, newSelection.getRaceDate()));
+                driverController.setAvgTimeLimit10Label(
+                        driverDb.avarageTimeWithLimit(newSelection.getDriverId(), 10, newSelection.getRaceDate()));
+                driverController.setAvgTimeLimit15Label(
+                        driverDb.avarageTimeWithLimit(newSelection.getDriverId(), 15, newSelection.getRaceDate()));
+
                 driverController.setAvgTimeDistanceLabel(String
-                        .valueOf(driverDb.avarageTimeByDistance(newSelection.getDriverId(), newSelection.getDistance(),
+                        .valueOf(driverDb.avarageTimeByDistance(newSelection.getDriverId(),
+                                newSelection.getDistance(),
                                 newSelection.getRaceDate()))
                         + "(" + String.valueOf(databaseb.getAvgTimeByDistance(newSelection.getDistance())) + ")");
                 driverController.setAvgTimeDistanceLimit5Label(String
-                        .valueOf(driverDb.avarageTimeByDistance(newSelection.getDriverId(), newSelection.getDistance(), 5,
+                        .valueOf(driverDb.avarageTimeByDistance(newSelection.getDriverId(),
+                                newSelection.getDistance(),
+                                5,
                                 newSelection.getRaceDate()))
                         + "(" + String.valueOf(databaseb.getAvgTimeByDistanceLimit(newSelection.getDistance(), 5)) + ")");
                 driverController.setAvgTimeDistanceLimit10Label(String
-                        .valueOf(driverDb.avarageTimeByDistance(newSelection.getDriverId(), newSelection.getDistance(), 10,
+                        .valueOf(driverDb.avarageTimeByDistance(newSelection.getDriverId(),
+                                newSelection.getDistance(),
+                                10,
                                 newSelection.getRaceDate()))
                         + "(" + String.valueOf(databaseb.getAvgTimeByDistanceLimit(newSelection.getDistance(), 10)) + ")");
                 driverController.setAvgTimeDistanceLimit15Label(String
-                        .valueOf(driverDb.avarageTimeByDistance(newSelection.getDriverId(), newSelection.getDistance(), 15,
+                        .valueOf(driverDb.avarageTimeByDistance(newSelection.getDriverId(),
+                                newSelection.getDistance(),
+                                15,
                                 newSelection.getRaceDate()))
                         + "(" + String.valueOf(databaseb.getAvgTimeByDistanceLimit(newSelection.getDistance(), 15)) + ")");
 
@@ -355,55 +505,62 @@ public class NewTabRaceTableView extends Tab {
                 driverController.setAvgPositionLast15(String
                         .valueOf(driverDb.avaragePlacementWithLimit(newSelection.getDriverId(), 15, newSelection.getRaceDate())));
 
-                driverController.setAvgPositionDistanceLast5(String.valueOf(driverDb.avaragePlacementByDistance(
-                        newSelection.getDriverId(), newSelection.getDistance(), 5, newSelection.getRaceDate())));
-                driverController.setAvgPositionDistanceLast10(String.valueOf(driverDb.avaragePlacementByDistance(
-                        newSelection.getDriverId(), newSelection.getDistance(), 10, newSelection.getRaceDate())));
-                driverController.setAvgPositionDistanceLast15(String.valueOf(driverDb.avaragePlacementByDistance(
-                        newSelection.getDriverId(), newSelection.getDistance(), 15, newSelection.getRaceDate())));
+                driverController.setAvgPositionDistanceLast5(String.valueOf(driverDb.avaragePlacementByDistance(newSelection
+                        .getDriverId(), newSelection.getDistance(), 5, newSelection.getRaceDate())));
+                driverController.setAvgPositionDistanceLast10(String.valueOf(driverDb.avaragePlacementByDistance(newSelection
+                        .getDriverId(), newSelection.getDistance(), 10, newSelection.getRaceDate())));
+                driverController.setAvgPositionDistanceLast15(String.valueOf(driverDb.avaragePlacementByDistance(newSelection
+                        .getDriverId(), newSelection.getDistance(), 15, newSelection.getRaceDate())));
 
                 ekipageController.setAvgTimeLabel(String.valueOf(
                         ekipageDb.avarageTime(newSelection.getDriverId(), newSelection.getHorseId(), newSelection.getRaceDate()))
                         + "(" + String.valueOf(databaseb.getAvgTime()) + ")");
+
+                ekipageController.setAvgTimeLimit5Label(ekipageDb.avarageTimeWithLimit(newSelection.getDriverId(),
+                        newSelection.getHorseId(),
+                        5,
+                        newSelection.getRaceDate()));
+                ekipageController.setAvgTimeLimit10Label(ekipageDb.avarageTimeWithLimit(newSelection.getDriverId(),
+                        newSelection.getHorseId(),
+                        10,
+                        newSelection.getRaceDate()));
+                ekipageController.setAvgTimeLimit15Label(ekipageDb.avarageTimeWithLimit(newSelection.getDriverId(),
+                        newSelection.getHorseId(),
+                        15,
+                        newSelection.getRaceDate()));
+
                 ekipageController.setAvgTimeDistanceLabel(String
-                        .valueOf(ekipageDb.avarageTimeByDistance(newSelection.getDriverId(), newSelection.getHorseId(),
-                                newSelection.getDistance(), newSelection.getRaceDate()))
+                        .valueOf(ekipageDb.avarageTimeByDistance(newSelection.getDriverId(),
+                                newSelection.getHorseId(),
+                                newSelection.getDistance(),
+                                newSelection.getRaceDate()))
                         + "(" + String.valueOf(databaseb.getAvgTimeByDistance(newSelection.getDistance())) + ")");
-                ekipageController.setAvgTimeDistanceLimit5Label(String
-                        .valueOf(ekipageDb.avarageTimeByDistance(newSelection.getDriverId(), newSelection.getHorseId(),
-                                newSelection.getDistance(), 5, newSelection.getRaceDate()))
+                ekipageController.setAvgTimeDistanceLimit5Label(String.valueOf(ekipageDb.avarageTimeByDistance(newSelection
+                        .getDriverId(), newSelection.getHorseId(), newSelection.getDistance(), 5, newSelection.getRaceDate()))
                         + "(" + String.valueOf(databaseb.getAvgTimeByDistanceLimit(newSelection.getDistance(), 5)) + ")");
-                ekipageController.setAvgTimeDistanceLimit10Label(String
-                        .valueOf(ekipageDb.avarageTimeByDistance(newSelection.getDriverId(), newSelection.getHorseId(),
-                                newSelection.getDistance(), 10, newSelection.getRaceDate()))
+                ekipageController.setAvgTimeDistanceLimit10Label(String.valueOf(ekipageDb.avarageTimeByDistance(newSelection
+                        .getDriverId(), newSelection.getHorseId(), newSelection.getDistance(), 10, newSelection.getRaceDate()))
                         + "(" + String.valueOf(databaseb.getAvgTimeByDistanceLimit(newSelection.getDistance(), 10)) + ")");
-                ekipageController.setAvgTimeDistanceLimit15Label(String
-                        .valueOf(ekipageDb.avarageTimeByDistance(newSelection.getDriverId(), newSelection.getHorseId(),
-                                newSelection.getDistance(), 15, newSelection.getRaceDate()))
+                ekipageController.setAvgTimeDistanceLimit15Label(String.valueOf(ekipageDb.avarageTimeByDistance(newSelection
+                        .getDriverId(), newSelection.getHorseId(), newSelection.getDistance(), 15, newSelection.getRaceDate()))
                         + "(" + String.valueOf(databaseb.getAvgTimeByDistanceLimit(newSelection.getDistance(), 15)) + ")");
 
-                ekipageController.setAvgPosition(String.valueOf(ekipageDb.avaragePlacement(newSelection.getDriverId(),
-                        newSelection.getHorseId(), newSelection.getRaceDate())));
+                ekipageController.setAvgPosition(String.valueOf(ekipageDb
+                        .avaragePlacement(newSelection.getDriverId(), newSelection.getHorseId(), newSelection.getRaceDate())));
 
-                ekipageController
-                        .setAvgPositionLast5(String.valueOf(ekipageDb.avaragePlacementWithLimit(newSelection.getDriverId(),
-                                newSelection.getHorseId(), 5, newSelection.getRaceDate())));
-                ekipageController
-                        .setAvgPositionLast10(String.valueOf(ekipageDb.avaragePlacementWithLimit(newSelection.getDriverId(),
-                                newSelection.getHorseId(), 10, newSelection.getRaceDate())));
-                ekipageController
-                        .setAvgPositionLast15(String.valueOf(ekipageDb.avaragePlacementWithLimit(newSelection.getDriverId(),
-                                newSelection.getHorseId(), 15, newSelection.getRaceDate())));
+                ekipageController.setAvgPositionLast5(String.valueOf(ekipageDb.avaragePlacementWithLimit(newSelection
+                        .getDriverId(), newSelection.getHorseId(), 5, newSelection.getRaceDate())));
+                ekipageController.setAvgPositionLast10(String.valueOf(ekipageDb.avaragePlacementWithLimit(newSelection
+                        .getDriverId(), newSelection.getHorseId(), 10, newSelection.getRaceDate())));
+                ekipageController.setAvgPositionLast15(String.valueOf(ekipageDb.avaragePlacementWithLimit(newSelection
+                        .getDriverId(), newSelection.getHorseId(), 15, newSelection.getRaceDate())));
 
-                ekipageController.setAvgPositionDistanceLast5(
-                        String.valueOf(ekipageDb.avaragePlacementByDistance(newSelection.getDriverId(), newSelection.getHorseId(),
-                                newSelection.getDistance(), 5, newSelection.getRaceDate())));
-                ekipageController.setAvgPositionDistanceLast10(
-                        String.valueOf(ekipageDb.avaragePlacementByDistance(newSelection.getDriverId(), newSelection.getHorseId(),
-                                newSelection.getDistance(), 10, newSelection.getRaceDate())));
-                ekipageController.setAvgPositionDistanceLast15(
-                        String.valueOf(ekipageDb.avaragePlacementByDistance(newSelection.getDriverId(), newSelection.getHorseId(),
-                                newSelection.getDistance(), 15, newSelection.getRaceDate())));
+                ekipageController.setAvgPositionDistanceLast5(String.valueOf(ekipageDb.avaragePlacementByDistance(newSelection
+                        .getDriverId(), newSelection.getHorseId(), newSelection.getDistance(), 5, newSelection.getRaceDate())));
+                ekipageController.setAvgPositionDistanceLast10(String.valueOf(ekipageDb.avaragePlacementByDistance(newSelection
+                        .getDriverId(), newSelection.getHorseId(), newSelection.getDistance(), 10, newSelection.getRaceDate())));
+                ekipageController.setAvgPositionDistanceLast15(String.valueOf(ekipageDb.avaragePlacementByDistance(newSelection
+                        .getDriverId(), newSelection.getHorseId(), newSelection.getDistance(), 15, newSelection.getRaceDate())));
 
             }
 
@@ -413,6 +570,7 @@ public class NewTabRaceTableView extends Tab {
         theTable.getItems().addAll(races);
         raceNumTab.setContent(theTable);
         racesTabs.getTabs().add(raceNumTab);
+
     }
 
     private TableView<ComparingResultsData> createTable() {
@@ -436,6 +594,19 @@ public class NewTabRaceTableView extends Tab {
         laneWinColumn.setCellValueFactory(new PropertyValueFactory<>("laneWin"));
         final TableColumn<ComparingResultsData, Integer> resultColumn = new TableColumn<>("Result");
         resultColumn.setCellValueFactory(new PropertyValueFactory<>("result"));
+        final TableColumn<ComparingResultsData, Boolean> betOnColumn = new TableColumn<>("BetOn");
+        betOnColumn.setCellValueFactory(new PropertyValueFactory<>("betOn"));
+
+        final Callback<TableColumn<ComparingResultsData, Boolean>, TableCell<ComparingResultsData, Boolean>> booleanCellFactory
+                = new Callback<>() {
+                    @Override
+                    public TableCell<ComparingResultsData, Boolean> call(TableColumn<ComparingResultsData, Boolean> p) {
+                        return new BooleanCell();
+                    }
+
+                };
+
+        betOnColumn.setCellFactory(booleanCellFactory);
 
         table.getColumns().add(horseNameColumn);
         table.getColumns().add(driverNameColumn);
@@ -445,8 +616,99 @@ public class NewTabRaceTableView extends Tab {
         table.getColumns().add(timeModifierColumn);
         table.getColumns().add(laneWinColumn);
         table.getColumns().add(resultColumn);
+        table.getColumns().add(betOnColumn);
 
         return table;
     }
 
+    protected <T> void addToBong(TableRow<T> row) {
+        final ComparingResultsData item = (ComparingResultsData) row.getItem();
+
+        final BongObject betOnRaceObject = new BongObject();
+        betOnRaceObject.addDriver(item.getDriverName());
+        betOnRaceObject.addHorse(item.getHorseName());
+        betOnRaceObject.addLane(item.getLane());
+        betOnRaceObject.setRaceNumber(item.getRaceNumber());
+        this.betSlip.getChildren().add(betOnRaceObject.getContent());
+    }
+
+    protected <T> void removeFromBong(TableRow<T> row) {
+        final ComparingResultsData item = (ComparingResultsData) row.getItem();
+        Optional<Node> found = null;
+        for (final Node data : betSlip.getChildren()) {
+            final HBox test = ((HBox) data);
+            found = test.getChildren().stream()
+                    .filter(p -> ((TextField) ((Pane) p).getChildren().get(0)).getText().equals(item.getHorseName())).findFirst();
+
+        }
+
+        if (found != null && found.isPresent()) {
+            final Node node = found.get();
+            final Iterator<Node> iterator = betSlip.getChildren().iterator();
+            while (iterator.hasNext()) {
+                if (iterator.next().equals(node.getParent())) {
+                    iterator.remove();
+                }
+            }
+
+        }
+    }
+
+    class BooleanCell extends TableCell<ComparingResultsData, Boolean> {
+        private final CheckBox checkBox;
+
+        public BooleanCell() {
+            checkBox = new CheckBox();
+
+            checkBox.selectedProperty().addListener(new ChangeListener<Boolean>() {
+                @SuppressWarnings({ "rawtypes", "unchecked" })
+                @Override
+                public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
+                    if (newValue) {
+                        addToBong((TableRow) checkBox.getParent().getParent());
+                    } else {
+                        removeFromBong((TableRow) checkBox.getParent().getParent());
+                    }
+                    if (isEditing()) {
+                        commitEdit(newValue == null ? false : newValue);
+                    }
+                }
+            });
+            this.setGraphic(checkBox);
+            this.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
+            this.setEditable(true);
+        }
+
+        @Override
+        public void startEdit() {
+            super.startEdit();
+            if (isEmpty()) {
+                return;
+            }
+            checkBox.requestFocus();
+        }
+
+        @Override
+        public void cancelEdit() {
+            super.cancelEdit();
+        }
+
+        @Override
+        public void commitEdit(Boolean value) {
+            super.commitEdit(value);
+        }
+
+        @Override
+        public void updateItem(Boolean item, boolean empty) {
+            super.updateItem(item, empty);
+            if (!isEmpty()) {
+                checkBox.setSelected(item);
+            }
+        }
+    }
+
+    public void setBongObject(VBox betOnContent) {
+        betSlip = betOnContent;
+    }
+
 }

+ 747 - 612
ATG/src/parsers/TravsportParser.java

@@ -31,617 +31,752 @@ import controllers.DatabaseController;
 
 public class TravsportParser implements Parser {
 
-	private static final TravsportParser instance = new TravsportParser();
-	private final DatabaseController databaseController;
-
-	private TravsportParser() {
-		databaseController = DatabaseController.getInstance();
-	};
-
-	public static TravsportParser getInstance() {
-		return instance;
-	}
-
-	/**
-	 * Förklaringar
-	 * tid - 'a' betyder "autoStart" vilket get snabbare tid
-	 * tid - 'g' betyder "gallopp" vilker ger långsammare tid
-	 * tid - 'd' betyder "Diskad" två galopper eller gallopp över mållinje eller längre än 150 meter
-	 * tid - 'it' betyder "Ingen tid" kan vara fel på banans tidtagning eller liknande så det finns ingen tid.
-	 * @param horseId
-	 */
-	public void getHorseStats(String raceType, String horseId) {
-		final WebClient webclient = MyWebClient.getInstance().getWebclient();
-		HtmlPage page;
-		try {
-			page = webclient.getPage("https://sportapp.travsport.se/sportinfo/horse/"+horseId+"/results");
-			webclient.waitForBackgroundJavaScript(3000);
-			webclient.waitForBackgroundJavaScriptStartingBefore(3000);
-			// Hitta div med data-testid="sportinfo-horse-details" för häst info
-
-			final HtmlDivision detailsDiv = (HtmlDivision) page.getBody().getByXPath("//div[@data-testid='sportinfo-horse-details']").get(0);
-
-			final HtmlHeading1 nameHeader = (HtmlHeading1)detailsDiv.getByXPath("//h1").get(0);
-			final String horseName = nameHeader.getTextContent().trim();
-			// Hitta div med data-testid="sportinfo-horse-results" för årliga resultat är första tabellen, andra tabellen är lopp resultat
-			final HtmlDivision resultsDiv = (HtmlDivision) page.getBody().getByXPath("//div[@data-testid='sportinfo-horse-results']").get(0);
-			final ArrayList<DomElement> resultsDivs = Lists.newArrayList(resultsDiv.getChildElements());
-
-			final HtmlDivision raceResults = (HtmlDivision) resultsDivs.get(4);
-
-			final HtmlTable raceTable = (HtmlTable) raceResults.getFirstChild();
-
-			final List<HtmlTableCell> tableHeader = raceTable.getRow(0).getCells();
-
-			int trackPos = -1;
-			int datePos = -1;
-			int lanePos = -1;
-			int distancePos = -1;
-			int resultPos = -1;
-			int timePos = -1;
-			int shoePos = -1;
-			int sulkyPos = -1;
-			int driverPos = -1;
-			int trainerPos = -1;
-			int oddsPos = -1;
-			int pos = 0;
-			for (final HtmlTableCell th : tableHeader) {
-				final HtmlSpan span = (HtmlSpan) th.getFirstChild();
-				final String text = span.getTextContent().toLowerCase();
-				if (text.equals("bana")) {
-					trackPos = pos;
-				} else if (text.equals("datum")) {
-					datePos = pos;
-				} else if (text.equals("spår")) {
-					lanePos = pos;
-				} else if (text.equals("dist.")) {
-					distancePos = pos;
-				} else if (text.equals("res.")) {
-					resultPos = pos;
-				} else if (text.equals("tid")) {
-					timePos = pos;
-				} else if (text.equals("skor")) {
-					shoePos = pos;
-				} else if (text.equals("vagn")) {
-					sulkyPos = pos;
-				} else if (text.equals("kusk")) {
-					driverPos = pos;
-				} else if (text.equals("tränare")) {
-					trainerPos = pos;
-				} else if (text.equals("odds")) {
-					oddsPos = pos;
-				} else if (text.equals("kategori")) {
-					//
-				}  else if (text.equals("vinstsumma")) {
-					//
-				}  else {
-					System.err.println("What should I do with " + text);
-				}
-
-				pos++;
-			}
-
-			for (int i = 1; i < raceTable.getRowCount(); i++) {
-				final List<HtmlTableCell> cells = raceTable.getRow(i).getCells();
-				final String timeCell = cells.get(6).getTextContent();
-				final float time;
-				final String timeModifier;
-
-				time = getTimeFromTimeCellValue(timeCell);
-
-				timeModifier = getTimeModifierFromTimeCellValue(timeCell);
-
-				final String trackShortCode = cells.get(trackPos).getTextContent();
-				final String date = cells.get(datePos).getTextContent().split("-")[0];
-				final int raceNumber = Integer.valueOf(cells.get(datePos).getTextContent().split("-")[1]);
-				final int startLine = Strings.isNullOrEmpty(cells.get(lanePos).getTextContent())?-1:Integer.valueOf(cells.get(lanePos).getTextContent());
-				final int distance = Integer.valueOf(cells.get(distancePos).getTextContent().replaceAll("\\D", ""));
-				final int result = Strings.isNullOrEmpty(cells.get(resultPos).getTextContent().replaceAll("\\D", ""))?-1:Integer.valueOf(cells.get(resultPos).getTextContent().replaceAll("\\D", ""));
-				final int shooes;
-				final DomNodeList<HtmlElement> shoeSpans = cells.get(shoePos).getElementsByTagName("span");
-				if (shoeSpans.getLength() == 0) { // NO SHOES
-					shooes = 0;
-				} else {
-					// show title possible values {"Barfota fram", "Skor runt om", "barfota bak", "barfota runt om"}
-					final String shoeTitle = shoeSpans.get(0).getAttribute("title").toLowerCase();
-					if (shoeTitle.equals("barfota fram")) {
-						shooes = 1;
-					} else if (shoeTitle.equals("skor runt om")) {
-						shooes = 2;
-					} else if (shoeTitle.equals("barfota runt om")){
-						shooes = 0;
-					} else if (shoeTitle.equals("barfota bak")) {
-						shooes = 3;
-					} else {
-						shooes = -1;
-						System.err.println("Dont know the value of " + shoeTitle);
-					}
-				}
-
-				final String driverName = cells.get(driverPos).getTextContent();
-				final String trainerName = cells.get(trainerPos).getTextContent();
-
-				DatabaseController.getInstance().insertResult(trackShortCode, date, raceNumber, startLine, distance, result, time, timeModifier, shooes, -1, driverName, trainerName, horseName, 0, 0, 0, raceType, -1);
-			}
-
-		} catch (final ClassCastException e) {
-			System.out.println("Failed to cast " + e.getMessage());
-			throw new RuntimeException(e.getMessage(), e);
-		} catch (FailingHttpStatusCodeException | IOException e) {
-			throw new RuntimeException(e.getMessage(), e);
-		} catch (final Exception e) {
-			System.err.println("Failed with exception " + e.getMessage() + " Horse id " + horseId);
-		}
-		webclient.close();
-	}
-
-	public void getRaceResults(String startOfMonth, String endOfMonth) {
-		final String calendarUrl = "https://api.travsport.se/webapi/raceinfo/organisation/TROT/sourceofdata/BOTH?fromracedate=" + startOfMonth + "&tosubmissiondate=" + endOfMonth + "&toracedate=" + endOfMonth;
-		final String url = "https://api.travsport.se/webapi/raceinfo/results/organisation/TROT/sourceofdata/SPORT/racedayid/";
-
-		final ArrayList<JsonObject> outerJsonObjects = getJsonObjects(calendarUrl);
-
-		final List<JsonObject> withStartlist = outerJsonObjects.stream().filter(j -> j.get("trackProgramExists").getAsBoolean()).collect(Collectors.toList());
-
-		for (final JsonObject outerJo : withStartlist) {
-			final int raceDayId = outerJo.get("raceDayId").getAsInt();
-			final String trackName = outerJo.get("trackName").getAsString();
-			final String trackCode = databaseController.getTrackShortCodeByName(trackName);
-
-			try {
-				final Page page = MyWebClient.getInstance().getJsonWebClient().getPage(url + raceDayId);
-				final String content = new String(page.getWebResponse().getContentAsString()); //.getBytes("ISO-8859-1"), "UTF-8");
-				final Gson gson = new Gson();
-				final JsonObject jo = gson.fromJson(content, JsonObject.class);
-
-				final ArrayList<JsonObject> jsonObjects = Lists.newArrayList();
-				final JsonArray results = jo.get("racesWithReadyResult").getAsJsonArray();
-				results.forEach(j -> jsonObjects.add(j.getAsJsonObject()));
-
-				for (final JsonObject json : jsonObjects) {
-					final JsonObject generalInfo = json.get("generalInfo").getAsJsonObject();
-					final int raceNumber = generalInfo.get("raceNumber").getAsInt();
-
-					final String startTime = generalInfo.get("startTime").getAsString();
-					final Pattern pattern = Pattern.compile("\\d{4}-\\d{2}-\\d{2}");
-					final Matcher matcher = pattern.matcher(startTime);
-					String raceDate;
-					if (matcher.find()) {
-						raceDate = matcher.group();
-					} else {
-						throw new RuntimeException("Could not find date from " + startTime);
-					}
-
-					try {
-						final JsonArray raceResultRows = json.get("raceResultRows").getAsJsonArray();
-						for (int i = 0; i < raceResultRows.size(); i++) {
-							final JsonObject res = raceResultRows.get(i).getAsJsonObject();
-							final int result = res.get("placementNumber").getAsInt();
-							final JsonObject horse = res.get("horse").getAsJsonObject();
-							final int horseTravsportId = horse.get("id").getAsInt();
-							final String horseName = horse.get("name").getAsString();
-
-							final JsonObject driver = res.get("driver").getAsJsonObject();
-							final int driverTravsportId = driver.get("id").getAsInt();
-							final String driverName = driver.get("name").getAsString();
-
-							final JsonObject trainer = res.get("trainer").getAsJsonObject();
-							final int trainerTravsportId = trainer.get("id").getAsInt();
-							final String trainerName = trainer.get("name").getAsString();
-							int shoeInfo = 0;
-							try {
-								shoeInfo = res.get("shoeInfo").getAsJsonObject().get("sortValue").getAsInt();
-							} catch (final NullPointerException e) {
-								// ignore
-							}
-
-							final String timeString = res.get("time").getAsString();
-							final float time = getTimeFromTimeCellValue(timeString);
-							final String timeModifier = getTimeModifierFromTimeCellValue(timeString);
-
-							final String[] startPosAndDistance = res.get("startPositionAndDistance").getAsString().split("/");
-							final int lane = res.get("programNumber").getAsInt();
-							final int distance = Integer.valueOf(startPosAndDistance[1]);
-
-							DatabaseController.getInstance().insertResult(trackCode, raceDate, raceNumber, lane, distance, result, time, timeModifier, shoeInfo, 0, driverName, trainerName, horseName, horseTravsportId, trainerTravsportId, driverTravsportId, "", raceDayId);
-						}
-					} catch (final NullPointerException e) {
-						System.out.println(url + raceDayId);
-						System.out.println("ERROR WITH MESSAGE: " + e.getMessage() + e.getCause());
-						continue;
-					}
-				}
-			} catch (FailingHttpStatusCodeException | IOException e) {
-				throw new RuntimeException(e.getMessage(), e);
-			}
-		}
-	}
-
-	// Get raceDayResultsJSon https://api.travsport.se/webapi/raceinfo/results/organisation/TROT/sourceofdata/SPORT/racedayid/590412
-	public void getRaceCalendar(String date) {
-		// JSON för race dagen https://api.travsport.se/webapi/raceinfo/startlists/organisation/TROT/sourceofdata/SPORT/racedayid/590412
-		// JSON för calendern https://api.travsport.se/webapi/raceinfo/organisation/TROT/sourceofdata/BOTH?fromracedate=2021-02-01&tosubmissiondate=2021-02-28&toracedate=2021-02-28
-		final String calendarUrl;
-		if (date == null) {
-			calendarUrl = "https://api.travsport.se/webapi/raceinfo/organisation/TROT/sourceofdata/BOTH?fromracedate="+getTodaysDate()+"&tosubmissiondate="+getLastDayOfMonth()+"&toracedate=" + getLastDayOfMonth();
-		} else {
-			calendarUrl = "https://api.travsport.se/webapi/raceinfo/organisation/TROT/sourceofdata/BOTH?fromracedate=" + date + "&tosubmissiondate=" + date + "&toracedate=" + date;
-		}
-		final String raceUrl = "https://api.travsport.se/webapi/raceinfo/startlists/organisation/TROT/sourceofdata/SPORT/racedayid/";
-
-		final ArrayList<JsonObject> jsonObjects = getJsonObjects(calendarUrl);
-
-		final List<JsonObject> withStartlist = jsonObjects.stream().filter(j -> j.get("trackProgramExists").getAsBoolean()).collect(Collectors.toList());
-
-		int i = 1;
-		for (final JsonObject jo : withStartlist) {
-			final int raceDayId = jo.get("raceDayId").getAsInt();
-			final String raceDate = jo.get("raceDayDate").getAsString();
-			final String trackName = jo.get("trackName").getAsString();
-			final String trackCode = databaseController.getTrackShortCodeByName(trackName);
-
-			System.out.println("Updating raceCalendar day " + raceDate + " " + i++ + "/" + withStartlist.size());
-
-			final ArrayList<JsonObject> raceJsonObjects = Lists.newArrayList();
-			try {
-				final Page page = MyWebClient.getInstance().getJsonWebClient().getPage(raceUrl + raceDayId);
-				final String content = new String(page.getWebResponse().getContentAsString()); //.getBytes("ISO-8859-1"), "UTF-8");
-				//				final String content = page.getWebResponse().getContentAsString();
-				final Gson gson = new Gson();
-				final JsonObject raceObject = gson.fromJson(content, JsonObject.class);
-				final JsonArray raceListData = raceObject.get("raceList").getAsJsonArray();
-				raceListData.forEach(e -> raceJsonObjects.add(e.getAsJsonObject()));
-
-				for (final JsonObject race : raceJsonObjects) {
-					final int raceNumber = race.get("raceNumber").getAsInt();
-					//					final int raceId = race.get("raceId").getAsInt();
-					final int distance = race.get("distance").getAsInt();
-					final String raceStartType = ""; //race.get("raceType").getAsJsonObject().get("code").getAsString();
-					final JsonArray horses = race.get("horses").getAsJsonArray();
-					final ArrayList<JsonObject> horseData = Lists.newArrayList();
-
-					horses.forEach(h -> horseData.add(h.getAsJsonObject()));
-					for (final JsonObject horse : horseData) {
-						final int horseTravsportId = horse.get("id").getAsInt();
-						final String horseName = horse.get("name").getAsString();
-						final JsonObject driverObject = horse.get("driver").getAsJsonObject();
-						final String driverName = driverObject.get("name").getAsString();
-						final int driverId = driverObject.get("licenseId").getAsInt();
-						final JsonObject trainerObject = horse.get("trainer").getAsJsonObject();
-						final String trainerName = trainerObject.get("name") != null?trainerObject.get("name").getAsString(): "";
-						final int trainerId = trainerObject.get("licenseId") != null?trainerObject.get("licenseId").getAsInt(): -1;
-
-						final JsonObject ownerObject = horse.get("owner").getAsJsonObject();
-						String ownerName;
-						int ownerId;
-						try {
-							ownerName = ownerObject.get("name").getAsString();
-							ownerId = ownerObject.get("licenseId").getAsInt();
-						} catch (final NullPointerException e) {
-							ownerName = "";
-							ownerId = -1;
-						}
-						final int lane = horse.get("startPosition").getAsInt();
-						final int actualDistance = horse.get("actualDistance").getAsInt();
-						final int shoe = horse.get("shoeOption").getAsJsonObject().get("code").getAsInt();
-
-						databaseController.insertResult(trackCode, raceDate, raceNumber, lane, actualDistance, -2, -1, raceStartType, shoe, -1, driverName, trainerName, horseName, horseTravsportId, trainerId, driverId, "", raceDayId);
-						final int horseIdByName = databaseController.getHorseId(horseName, horseTravsportId);
-						final int horseRaceCount = databaseController.getRaceCount("Horse", horseIdByName);
-						if (horseIdByName > -1 && horseRaceCount <= 5) {
-							getHorseStatByIdJson(horseTravsportId, horseName, "", -1);
-						}
-
-						final int driverIdByName = databaseController.getDriverId(driverName, driverId);
-						final int driverRaceCount = databaseController.getRaceCount("Driver", driverIdByName);
-						if (driverIdByName > -1 && driverRaceCount <= 20) {
-							getDriverStatById(driverId, driverName, -1);
-						}
-					}
-				}
-			} catch (final NullPointerException e) {
-				System.out.println("Failed to get results");
-				throw new RuntimeException(e.getMessage(), e);
-			} catch (FailingHttpStatusCodeException | IOException e1 ) {
-				throw new RuntimeException(e1.getMessage(), e1);
-			}
-
-		}
-
-
-		// Xpath data-testid = racecalendar-button-startlist
-
-	}
-
-	public int getHorseIdByName(String horseName) {
-		/*
-		 * Uppdatera med detta anrop, kommer tillbaka en JSON sträng som man kan ta utan css och allt.
-		 * https://api.travsport.se/webapi/horses/results/organisation/TROT/sourceofdata/SPORT/horseid/781845
-		 *
-		 * */
-		/* Search String https://api.travsport.se/webapi/horses/search/organisation/TROT?age=0&gender=BOTH&horseName=molly&trotBreed=ALL&autoSuffixWildcard=true
-
-		Svarar med lista ex.
-		[{"organisation":"TROT","sourceOfData":"SPORT","horseId":58291,"name":"GINA II","yearOfBirth":"1945","horseGender":{"code":"S","text":"sto"},"horseBreed":{"code":"K","text":"kallblodig travare"}},
-		{"organisation":"TROT","sourceOfData":"SPORT","horseId":58264,"name":"GINA","yearOfBirth":"1935","horseGender":{"code":"S","text":"sto"},"horseBreed":{"code":"K","text":"kallblodig travare"}}]
-		 */
-
-		int horseId = DatabaseController.getInstance().getHorseTravsportId(horseName);
-		if (horseId <= 0) {
-			System.out.println("Getting horse id from travsport");
-			final String url = "https://api.travsport.se/webapi/horses/search/organisation/TROT?age=0&gender=BOTH&horseName="+horseName+"&trotBreed=ALL&autoSuffixWildcard=false";
-
-			final WebClient webclient = MyWebClient.getInstance().getWebclient();
-			try {
-
-				final Page page = webclient.getPage(url);
-
-				final String content = page.getWebResponse().getContentAsString();
-				final Gson gson = new Gson();
-				final JsonArray fromJson = gson.fromJson(content, JsonArray.class);
-				final ArrayList<JsonObject> jsonObjects = Lists.newArrayList();
-				fromJson.forEach(e -> jsonObjects.add(e.getAsJsonObject()));
-
-				Collections.sort(jsonObjects, new Comparator<JsonObject>() {
-
-					@Override
-					public int compare(JsonObject o1, JsonObject o2) {
-						return o2.get("horseId").getAsString().compareTo(o1.get("horseId").getAsString());
-					}
-
-				});
-				horseId = jsonObjects.get(0).get("horseId").getAsInt();
-				DatabaseController.getInstance().setHorseTravsportId(Integer.valueOf(horseId), horseName);
-			} catch (FailingHttpStatusCodeException | IOException e) {
-				throw new RuntimeException(e.getMessage(), e);
-			} catch (final IndexOutOfBoundsException e) {
-				System.out.println("Horse with name " + horseName + " not found at travsport");
-			}
-
-		}
-		return horseId;
-	}
-
-	private ArrayList<JsonObject> getJsonObjects(String url) {
-		final ArrayList<JsonObject> jsonObjects = Lists.newArrayList();
-		try (WebClient wc = MyWebClient.getInstance().getJsonWebClient();){
-
-			final Page page = wc.getPage(url);
-			final String content = page.getWebResponse().getContentAsString();
-			final Gson gson = new Gson();
-			final JsonArray fromJson = gson.fromJson(content, JsonArray.class);
-			fromJson.forEach(e -> jsonObjects.add(e.getAsJsonObject()));
-		} catch (FailingHttpStatusCodeException | IOException e) {
-			throw new RuntimeException(e.getMessage(), e);
-		}
-		return jsonObjects;
-	}
-
-	public void getHorseStatByIdJson(int horseTravsportId, String horseName, String raceType, int raceId) {
-		final String url = "https://api.travsport.se/webapi/horses/results/organisation/TROT/sourceofdata/SPORT/horseid/" + horseTravsportId;
-
-		final ArrayList<JsonObject> jsonObjects = getJsonObjects(url);
-		final int i = 0;
-		final int rows = jsonObjects.size();
-		System.out.println("Updating horse " + horseName + " " + rows + " results");
-		for (final JsonObject jo : jsonObjects) {
-			final String trackCode = jo.get("trackCode").getAsString();
-
-			final JsonObject raceInfo = jo.get("raceInformation").getAsJsonObject();
-			final String raceDate = raceInfo.get("date").getAsString();
-			final int raceNumber = raceInfo.get("raceNumber").getAsInt();
-
-			int lane;
-			try {
-				lane = Integer.valueOf(jo.get("startPosition").getAsJsonObject().get("displayValue").getAsString());
-			} catch (final NumberFormatException e) {
-				lane = -1;
-			}
-
-			final int distance = Integer.valueOf(jo.get("distance").getAsJsonObject().get("displayValue").getAsString());
-
-			final String timeValue = jo.get("kilometerTime").getAsJsonObject().get("displayValue").getAsString();
-
-			final float time = getTimeFromTimeCellValue(timeValue);
-			final String timeModifier = getTimeModifierFromTimeCellValue(timeValue);
-
-			if (jo.get("shoeInfo") != null) {
-				final JsonObject shoeInfo = jo.get("shoeInfo").getAsJsonObject();
-				final boolean frontShoe = shoeInfo.get("front").getAsBoolean();
-				final boolean backShoe = shoeInfo.get("back").getAsBoolean();
-				// konvertera till värdet som det ska vara...
-			}
-
-			final JsonObject placementInfo = jo.get("placement").getAsJsonObject();
-			final String resultString = placementInfo.get("displayValue").getAsString();
-			final int result = Strings.isNullOrEmpty(resultString.replaceAll("\\D", ""))?-1:Integer.valueOf(resultString.replaceAll("\\D", ""));
-
-			final JsonObject driverInfo = jo.get("driver").getAsJsonObject();
-			final int driverId = driverInfo.get("id").getAsInt();
-			final String driverName = driverInfo.get("name").getAsString();
-
-			final JsonObject trainerInfo = jo.get("trainer").getAsJsonObject();
-			final int trainerId = trainerInfo.get("id").getAsInt();
-			final String trainerName = trainerInfo.get("name").getAsString();
-
-			//				final String sulkyString = jo.get("suklyOptions").getAsJsonObject().get("description").getAsString();
-
-			DatabaseController.getInstance().insertResult(trackCode, raceDate, raceNumber, lane, distance, result, time, timeModifier, -1, -1, driverName, trainerName, horseName, horseTravsportId, trainerId, driverId, raceType, raceId);
-
-		}
-	}
-
-	public void getDriverStatById(int driverTravsportId, String driverName, int raceId) {
-		// https://api.travsport.se/webapi/licenseholder/drivers/results/organisation/TROT/sourceofdata/SPORT/driverid/70381 JSON resultat
-
-		final String url = "https://api.travsport.se/webapi/licenseholder/drivers/results/organisation/TROT/sourceofdata/SPORT/driverid/" + driverTravsportId;
-		final WebClient wc = MyWebClient.getInstance().getJsonWebClient();
-
-		try {
-			final Page page = wc.getPage(url);
-
-			final String content = page.getWebResponse().getContentAsString();
-			final Gson gson = new Gson();
-			final JsonArray fromJson = gson.fromJson(content, JsonArray.class);
-			final ArrayList<JsonObject> jsonObjects = Lists.newArrayList();
-			fromJson.forEach(e -> jsonObjects.add(e.getAsJsonObject()));
-
-			final int i = 0;
-			final int rows = jsonObjects.size();
-			System.out.println("Updating driver " + driverName + " " + rows + " results");
-			for (final JsonObject jo : jsonObjects) {
-
-				final String trackCode = jo.get("trackCode").getAsString();
-
-				final JsonObject raceInfo = jo.get("raceInformation").getAsJsonObject();
-				final String raceDate = raceInfo.get("date").getAsString();
-				final int raceNumber = raceInfo.get("raceNumber").getAsInt();
-				int lane;
-				try {
-					lane = Integer.valueOf(jo.get("startPosition").getAsJsonObject().get("displayValue").getAsString());
-				} catch (final NumberFormatException e) {
-					lane = -1;
-				}
-				final int distance = Integer.valueOf(jo.get("distance").getAsJsonObject().get("displayValue").getAsString());
-
-				final String timeValue = jo.get("kilometerTime").getAsJsonObject().get("displayValue").getAsString();
-				final float time = getTimeFromTimeCellValue(timeValue);
-				final String timeModifier = getTimeModifierFromTimeCellValue(timeValue);
-
-				final String resultString = jo.get("placement").getAsJsonObject().get("displayValue").getAsString();
-				final int result = Strings.isNullOrEmpty(resultString.replaceAll("\\D", ""))?-1:Integer.valueOf(resultString.replaceAll("\\D", ""));
-
-				final JsonObject horseObject = jo.get("horse").getAsJsonObject();
-				final String horseName = horseObject.get("name").getAsString();
-				final int travsportIdHorse = horseObject.get("id").getAsInt();
-				String trainerName = "";
-				int trainerId = -1;
-				if (jo.get("trainer") != null) {
-					final JsonObject trainerObject = jo.get("trainer").getAsJsonObject();
-					trainerName = trainerObject.get("name").getAsString();
-					trainerId = trainerObject.get("id").getAsInt();
-				}
-
-				DatabaseController.getInstance().insertResult(trackCode, raceDate, raceNumber, lane, distance, result, time, timeModifier, -1, -1, driverName, trainerName, horseName, travsportIdHorse, trainerId, driverTravsportId, "", raceId);
-
-			}
-
-		} catch (FailingHttpStatusCodeException | IOException e) {
-			throw new RuntimeException(e.getMessage(), e);
-		}
-	}
-
-	public int getDriverIdByName(String firstName, String lastName) {
-		System.out.println("Getting driver id from travsport by name " + firstName + " " + lastName);
-		final String url = "https://api.travsport.se/webapi/licenseholder/search/organisation/TROT?firstName="+firstName+"&lastName="+lastName+"&showAll=false";
-		int driverId = 0;
-		final WebClient webclient = MyWebClient.getInstance().getJsonWebClient();
-		try {
-
-			final Page page = webclient.getPage(url);
-
-			final String content = page.getWebResponse().getContentAsString();
-			final Gson gson = new Gson();
-			final JsonArray fromJson = gson.fromJson(content, JsonArray.class);
-			final ArrayList<JsonObject> jsonObjects = Lists.newArrayList();
-			fromJson.forEach(e -> jsonObjects.add(e.getAsJsonObject()));
-
-			Collections.sort(jsonObjects, new Comparator<JsonObject>() {
-
-				@Override
-				public int compare(JsonObject o1, JsonObject o2) {
-					return o2.get("id").getAsString().compareTo(o1.get("id").getAsString());
-				}
-
-			});
-			driverId = jsonObjects.get(0).get("id").getAsInt();
-			DatabaseController.getInstance().setDriverTravsportId(driverId, firstName, lastName);
-
-		} catch (FailingHttpStatusCodeException | IOException e) {
-			throw new RuntimeException(e.getMessage(), e);
-		} catch (final IndexOutOfBoundsException e) {
-			System.out.println("Driver with name " + firstName + " " + lastName + " not found at travsport");
-		}
-		return driverId;
-	}
-
-	public void updateRaceResults(int raceId) {
-		// https://api.travsport.se/webapi/raceinfo/results/organisation/TROT/sourceofdata/SPORT/racedayid/<raceId>
-		final String url = "https://api.travsport.se/webapi/raceinfo/results/organisation/TROT/sourceofdata/SPORT/racedayid/" + raceId;
-
-		try {
-			final Page page = MyWebClient.getInstance().getJsonWebClient().getPage(url);
-			final String content = new String(page.getWebResponse().getContentAsString()); //.getBytes("ISO-8859-1"), "UTF-8");
-			final Gson gson = new Gson();
-			final JsonObject jo = gson.fromJson(content, JsonObject.class);
-
-			final ArrayList<JsonObject> jsonObjects = Lists.newArrayList();
-			final JsonArray results = jo.get("racesWithReadyResult").getAsJsonArray();
-			results.forEach(j -> jsonObjects.add(j.getAsJsonObject()));
-
-			for (final JsonObject json : jsonObjects) {
-				final JsonObject generalInfo = json.get("generalInfo").getAsJsonObject();
-				final int raceNumber = generalInfo.get("raceNumber").getAsInt();
-				Matcher matcher;
-				String startTime;
-				try {
-					startTime = generalInfo.get("startTime").getAsString();
-					final Pattern pattern = Pattern.compile("\\d{4}-\\d{2}-\\d{2}");
-					matcher = pattern.matcher(startTime);
-				} catch (final NullPointerException e) {
-					continue;
-				}
-				String raceDate;
-				if (matcher.find()) {
-					raceDate = matcher.group();
-				} else {
-					throw new RuntimeException("Could not find date from " + startTime);
-				}
-
-				try {
-					final JsonArray raceResultRows = json.get("raceResultRows").getAsJsonArray();
-
-					for (int i = 0; i < raceResultRows.size(); i++) {
-						final JsonObject res = raceResultRows.get(i).getAsJsonObject();
-						final int result = res.get("placementNumber").getAsInt();
-						final JsonObject horse = res.get("horse").getAsJsonObject();
-						final int horseTravsportId = horse.get("id").getAsInt();
-						final String horseName = horse.get("name").getAsString();
-
-						final JsonObject driver = res.get("driver").getAsJsonObject();
-						final int driverTravsportId = driver.get("id").getAsInt();
-						final String driverName = driver.get("name").getAsString();
-
-						final JsonObject trainer = res.get("trainer").getAsJsonObject();
-						final int trainerTravsportId = trainer.get("id").getAsInt();
-						final String trainerName = trainer.get("name").getAsString();
-						int shoeInfo = 0;
-						try {
-							shoeInfo = res.get("shoeInfo").getAsJsonObject().get("sortValue").getAsInt();
-						} catch (final NullPointerException e) {
-							// ignore
-						}
-
-						final String timeString = res.get("time").getAsString();
-						final float time = getTimeFromTimeCellValue(timeString);
-						final String timeModifier = getTimeModifierFromTimeCellValue(timeString);
-
-						final String[] startPosAndDistance = res.get("startPositionAndDistance").getAsString().split("/");
-						//						final int lane = Integer.valueOf(startPosAndDistance[0]);
-						final int lane = res.get("programNumber").getAsInt();
-						final int distance = Integer.valueOf(startPosAndDistance[1]);
-
-						DatabaseController.getInstance().updateFromRaceResults(raceId, result, time, timeModifier, lane, distance, horseTravsportId, driverTravsportId, raceDate, raceNumber);
-						System.out.println("Updated raceId " + raceId + " horse " + horseName + "(" + horseTravsportId + ") driver " + driverName + "(" + driverTravsportId + ") at date " + raceDate + " with result " + result + " time " + time + " time mod " + timeModifier + " race number: " + raceNumber );
-					}
-				} catch (final NullPointerException e) {
-					System.out.println("ERROR WITH MESSAGE: " + e.getMessage());
-					continue;
-				}
-			}
-		} catch (FailingHttpStatusCodeException | IOException e) {
-			throw new RuntimeException(e.getMessage(), e);
-		}
-	}
+    private static final TravsportParser instance = new TravsportParser();
+    private final DatabaseController databaseController;
+
+    private TravsportParser() {
+        databaseController = DatabaseController.getInstance();
+    };
+
+    public static TravsportParser getInstance() {
+        return instance;
+    }
+
+    /**
+     * Förklaringar tid - 'a' betyder "autoStart" vilket get snabbare tid tid - 'g'
+     * betyder "gallopp" vilker ger långsammare tid tid - 'd' betyder "Diskad" två
+     * galopper eller gallopp över mållinje eller längre än 150 meter tid - 'it'
+     * betyder "Ingen tid" kan vara fel på banans tidtagning eller liknande så det
+     * finns ingen tid.
+     *
+     * @param horseId
+     */
+    public void getHorseStats(String raceType, String horseId) {
+        final WebClient webclient = MyWebClient.getInstance().getWebclient();
+        HtmlPage page;
+        try {
+            page = webclient.getPage("https://sportapp.travsport.se/sportinfo/horse/" + horseId + "/results");
+            webclient.waitForBackgroundJavaScript(3000);
+            webclient.waitForBackgroundJavaScriptStartingBefore(3000);
+            // Hitta div med data-testid="sportinfo-horse-details" för häst info
+
+            final HtmlDivision detailsDiv
+                    = (HtmlDivision) page.getBody().getByXPath("//div[@data-testid='sportinfo-horse-details']").get(0);
+
+            final HtmlHeading1 nameHeader = (HtmlHeading1) detailsDiv.getByXPath("//h1").get(0);
+            final String horseName = nameHeader.getTextContent().trim();
+            // Hitta div med data-testid="sportinfo-horse-results" för årliga resultat är
+            // första tabellen, andra tabellen är lopp resultat
+            final HtmlDivision resultsDiv
+                    = (HtmlDivision) page.getBody().getByXPath("//div[@data-testid='sportinfo-horse-results']").get(0);
+            final ArrayList<DomElement> resultsDivs = Lists.newArrayList(resultsDiv.getChildElements());
+
+            final HtmlDivision raceResults = (HtmlDivision) resultsDivs.get(4);
+
+            final HtmlTable raceTable = (HtmlTable) raceResults.getFirstChild();
+
+            final List<HtmlTableCell> tableHeader = raceTable.getRow(0).getCells();
+
+            int trackPos = -1;
+            int datePos = -1;
+            int lanePos = -1;
+            int distancePos = -1;
+            int resultPos = -1;
+            int timePos = -1;
+            int shoePos = -1;
+            int sulkyPos = -1;
+            int driverPos = -1;
+            int trainerPos = -1;
+            int oddsPos = -1;
+            int pos = 0;
+            for (final HtmlTableCell th : tableHeader) {
+                final HtmlSpan span = (HtmlSpan) th.getFirstChild();
+                final String text = span.getTextContent().toLowerCase();
+                if (text.equals("bana")) {
+                    trackPos = pos;
+                } else if (text.equals("datum")) {
+                    datePos = pos;
+                } else if (text.equals("spår")) {
+                    lanePos = pos;
+                } else if (text.equals("dist.")) {
+                    distancePos = pos;
+                } else if (text.equals("res.")) {
+                    resultPos = pos;
+                } else if (text.equals("tid")) {
+                    timePos = pos;
+                } else if (text.equals("skor")) {
+                    shoePos = pos;
+                } else if (text.equals("vagn")) {
+                    sulkyPos = pos;
+                } else if (text.equals("kusk")) {
+                    driverPos = pos;
+                } else if (text.equals("tränare")) {
+                    trainerPos = pos;
+                } else if (text.equals("odds")) {
+                    oddsPos = pos;
+                } else if (text.equals("kategori")) {
+                    //
+                } else if (text.equals("vinstsumma")) {
+                    //
+                } else {
+                    System.err.println("What should I do with " + text);
+                }
+
+                pos++;
+            }
+
+            for (int i = 1; i < raceTable.getRowCount(); i++) {
+                final List<HtmlTableCell> cells = raceTable.getRow(i).getCells();
+                final String timeCell = cells.get(6).getTextContent();
+                final float time;
+                final String timeModifier;
+
+                time = getTimeFromTimeCellValue(timeCell);
+
+                timeModifier = getTimeModifierFromTimeCellValue(timeCell);
+
+                final String trackShortCode = cells.get(trackPos).getTextContent();
+                final String date = cells.get(datePos).getTextContent().split("-")[0];
+                final int raceNumber = Integer.valueOf(cells.get(datePos).getTextContent().split("-")[1]);
+                final int startLine = Strings.isNullOrEmpty(cells.get(lanePos).getTextContent()) ? -1
+                        : Integer.valueOf(cells.get(lanePos).getTextContent());
+                final int distance = Integer.valueOf(cells.get(distancePos).getTextContent().replaceAll("\\D", ""));
+                final int result = Strings.isNullOrEmpty(cells.get(resultPos).getTextContent().replaceAll("\\D", "")) ? -1
+                        : Integer.valueOf(cells.get(resultPos).getTextContent().replaceAll("\\D", ""));
+                final int shooes;
+                final DomNodeList<HtmlElement> shoeSpans = cells.get(shoePos).getElementsByTagName("span");
+                if (shoeSpans.getLength() == 0) { // NO SHOES
+                    shooes = 0;
+                } else {
+                    // show title possible values {"Barfota fram", "Skor runt om", "barfota bak",
+                    // "barfota runt om"}
+                    final String shoeTitle = shoeSpans.get(0).getAttribute("title").toLowerCase();
+                    if (shoeTitle.equals("barfota fram")) {
+                        shooes = 1;
+                    } else if (shoeTitle.equals("skor runt om")) {
+                        shooes = 2;
+                    } else if (shoeTitle.equals("barfota runt om")) {
+                        shooes = 0;
+                    } else if (shoeTitle.equals("barfota bak")) {
+                        shooes = 3;
+                    } else {
+                        shooes = -1;
+                        System.err.println("Dont know the value of " + shoeTitle);
+                    }
+                }
+
+                final String driverName = cells.get(driverPos).getTextContent();
+                final String trainerName = cells.get(trainerPos).getTextContent();
+
+                DatabaseController.getInstance().insertResult(trackShortCode,
+                        date,
+                        raceNumber,
+                        startLine,
+                        distance,
+                        result,
+                        time,
+                        timeModifier,
+                        shooes,
+                        -1,
+                        driverName,
+                        trainerName,
+                        horseName,
+                        0,
+                        0,
+                        0,
+                        raceType,
+                        -1);
+            }
+
+        } catch (final ClassCastException e) {
+            System.out.println("Failed to cast " + e.getMessage());
+            throw new RuntimeException(e.getMessage(), e);
+        } catch (FailingHttpStatusCodeException | IOException e) {
+            throw new RuntimeException(e.getMessage(), e);
+        } catch (final Exception e) {
+            System.err.println("Failed with exception " + e.getMessage() + " Horse id " + horseId);
+        }
+        webclient.close();
+    }
+
+    public void getRaceResults(String startOfMonth, String endOfMonth) {
+        final String calendarUrl = "https://api.travsport.se/webapi/raceinfo/organisation/TROT/sourceofdata/BOTH?fromracedate="
+                + startOfMonth + "&tosubmissiondate=" + endOfMonth + "&toracedate=" + endOfMonth;
+        final String url = "https://api.travsport.se/webapi/raceinfo/results/organisation/TROT/sourceofdata/SPORT/racedayid/";
+
+        final ArrayList<JsonObject> outerJsonObjects = getJsonObjects(calendarUrl);
+
+        final List<JsonObject> withStartlist
+                = outerJsonObjects.stream().filter(j -> j.get("trackProgramExists").getAsBoolean()).collect(Collectors.toList());
+
+        for (final JsonObject outerJo : withStartlist) {
+            final int raceDayId = outerJo.get("raceDayId").getAsInt();
+            final String trackName = outerJo.get("trackName").getAsString();
+            final String trackCode = databaseController.getTrackShortCodeByName(trackName);
+
+            try {
+                final Page page = MyWebClient.getInstance().getJsonWebClient().getPage(url + raceDayId);
+                final String content = new String(page.getWebResponse().getContentAsString()); // .getBytes("ISO-8859-1"),
+                                                                                               // "UTF-8");
+                final Gson gson = new Gson();
+                final JsonObject jo = gson.fromJson(content, JsonObject.class);
+
+                final ArrayList<JsonObject> jsonObjects = Lists.newArrayList();
+                final JsonArray results = jo.get("racesWithReadyResult").getAsJsonArray();
+                results.forEach(j -> jsonObjects.add(j.getAsJsonObject()));
+
+                for (final JsonObject json : jsonObjects) {
+                    final JsonObject generalInfo = json.get("generalInfo").getAsJsonObject();
+                    final int raceNumber = generalInfo.get("raceNumber").getAsInt();
+
+                    final String startTime = generalInfo.get("startTime").getAsString();
+                    final Pattern pattern = Pattern.compile("\\d{4}-\\d{2}-\\d{2}");
+                    final Matcher matcher = pattern.matcher(startTime);
+                    String raceDate;
+                    if (matcher.find()) {
+                        raceDate = matcher.group();
+                    } else {
+                        throw new RuntimeException("Could not find date from " + startTime);
+                    }
+
+                    try {
+                        final JsonArray raceResultRows = json.get("raceResultRows").getAsJsonArray();
+                        for (int i = 0; i < raceResultRows.size(); i++) {
+                            final JsonObject res = raceResultRows.get(i).getAsJsonObject();
+                            final int result = res.get("placementNumber").getAsInt();
+                            final JsonObject horse = res.get("horse").getAsJsonObject();
+                            final int horseTravsportId = horse.get("id").getAsInt();
+                            final String horseName = horse.get("name").getAsString();
+
+                            final JsonObject driver = res.get("driver").getAsJsonObject();
+                            final int driverTravsportId = driver.get("id").getAsInt();
+                            final String driverName = driver.get("name").getAsString();
+
+                            final JsonObject trainer = res.get("trainer").getAsJsonObject();
+                            final int trainerTravsportId = trainer.get("id").getAsInt();
+                            final String trainerName = trainer.get("name").getAsString();
+                            int shoeInfo = 0;
+                            try {
+                                shoeInfo = res.get("shoeInfo").getAsJsonObject().get("sortValue").getAsInt();
+                            } catch (final NullPointerException e) {
+                                // ignore
+                            }
+
+                            final String timeString = res.get("time").getAsString();
+                            final float time = getTimeFromTimeCellValue(timeString);
+                            final String timeModifier = getTimeModifierFromTimeCellValue(timeString);
+
+                            final String[] startPosAndDistance = res.get("startPositionAndDistance").getAsString().split("/");
+                            final int lane = res.get("programNumber").getAsInt();
+                            final int distance = Integer.valueOf(startPosAndDistance[1]);
+
+                            DatabaseController.getInstance().insertResult(trackCode,
+                                    raceDate,
+                                    raceNumber,
+                                    lane,
+                                    distance,
+                                    result,
+                                    time,
+                                    timeModifier,
+                                    shoeInfo,
+                                    0,
+                                    driverName,
+                                    trainerName,
+                                    horseName,
+                                    horseTravsportId,
+                                    trainerTravsportId,
+                                    driverTravsportId,
+                                    "",
+                                    raceDayId);
+                        }
+                    } catch (final NullPointerException e) {
+                        System.out.println(url + raceDayId);
+                        System.out.println("ERROR WITH MESSAGE: " + e.getMessage() + e.getCause());
+                        continue;
+                    }
+                }
+            } catch (FailingHttpStatusCodeException | IOException e) {
+                throw new RuntimeException(e.getMessage(), e);
+            }
+        }
+    }
+
+    // Get raceDayResultsJSon
+    // https://api.travsport.se/webapi/raceinfo/results/organisation/TROT/sourceofdata/SPORT/racedayid/590412
+    public void getRaceCalendar(String date) {
+        // JSON för race dagen
+        // https://api.travsport.se/webapi/raceinfo/startlists/organisation/TROT/sourceofdata/SPORT/racedayid/590412
+        // JSON för calendern
+        // https://api.travsport.se/webapi/raceinfo/organisation/TROT/sourceofdata/BOTH?fromracedate=2021-02-01&tosubmissiondate=2021-02-28&toracedate=2021-02-28
+        final String calendarUrl;
+        if (date == null) {
+            calendarUrl = "https://api.travsport.se/webapi/raceinfo/organisation/TROT/sourceofdata/BOTH?fromracedate="
+                    + getTodaysDate() + "&tosubmissiondate=" + getLastDayOfMonth() + "&toracedate=" + getLastDayOfMonth();
+        } else {
+            calendarUrl = "https://api.travsport.se/webapi/raceinfo/organisation/TROT/sourceofdata/BOTH?fromracedate=" + date
+                    + "&tosubmissiondate=" + date + "&toracedate=" + date;
+        }
+        final String raceUrl
+                = "https://api.travsport.se/webapi/raceinfo/startlists/organisation/TROT/sourceofdata/SPORT/racedayid/";
+
+        final ArrayList<JsonObject> jsonObjects = getJsonObjects(calendarUrl);
+
+        final List<JsonObject> withStartlist
+                = jsonObjects.stream().filter(j -> j.get("trackProgramExists").getAsBoolean()).collect(Collectors.toList());
+
+        int i = 1;
+        for (final JsonObject jo : withStartlist) {
+            final int raceDayId = jo.get("raceDayId").getAsInt();
+            final String raceDate = jo.get("raceDayDate").getAsString();
+            final String trackName = jo.get("trackName").getAsString();
+            final String trackCode = databaseController.getTrackShortCodeByName(trackName);
+
+            System.out.println("Updating raceCalendar day " + raceDate + " " + i++ + "/" + withStartlist.size());
+
+            final ArrayList<JsonObject> raceJsonObjects = Lists.newArrayList();
+            try {
+                final Page page = MyWebClient.getInstance().getJsonWebClient().getPage(raceUrl + raceDayId);
+                final String content = new String(page.getWebResponse().getContentAsString()); // .getBytes("ISO-8859-1"),
+                                                                                               // "UTF-8");
+                // final String content = page.getWebResponse().getContentAsString();
+                final Gson gson = new Gson();
+                final JsonObject raceObject = gson.fromJson(content, JsonObject.class);
+                final JsonArray raceListData = raceObject.get("raceList").getAsJsonArray();
+                raceListData.forEach(e -> raceJsonObjects.add(e.getAsJsonObject()));
+
+                for (final JsonObject race : raceJsonObjects) {
+                    final int raceNumber = race.get("raceNumber").getAsInt();
+                    // final int raceId = race.get("raceId").getAsInt();
+                    final int distance = race.get("distance").getAsInt();
+                    final String raceStartType = ""; // race.get("raceType").getAsJsonObject().get("code").getAsString();
+                    final JsonArray horses = race.get("horses").getAsJsonArray();
+                    final ArrayList<JsonObject> horseData = Lists.newArrayList();
+
+                    horses.forEach(h -> horseData.add(h.getAsJsonObject()));
+                    for (final JsonObject horse : horseData) {
+                        final int horseTravsportId = horse.get("id").getAsInt();
+                        final String horseName = horse.get("name").getAsString();
+                        final JsonObject driverObject = horse.get("driver").getAsJsonObject();
+                        final String driverName = driverObject.get("name").getAsString();
+                        final int driverId = driverObject.get("licenseId").getAsInt();
+                        final JsonObject trainerObject = horse.get("trainer").getAsJsonObject();
+                        final String trainerName
+                                = trainerObject.get("name") != null ? trainerObject.get("name").getAsString() : "";
+                        final int trainerId
+                                = trainerObject.get("licenseId") != null ? trainerObject.get("licenseId").getAsInt() : -1;
+
+                        final JsonObject ownerObject = horse.get("owner").getAsJsonObject();
+                        String ownerName;
+                        int ownerId;
+                        try {
+                            ownerName = ownerObject.get("name").getAsString();
+                            ownerId = ownerObject.get("licenseId").getAsInt();
+                        } catch (final NullPointerException e) {
+                            ownerName = "";
+                            ownerId = -1;
+                        }
+                        final int lane = horse.get("startPosition").getAsInt();
+                        final int actualDistance = horse.get("actualDistance").getAsInt();
+                        final int shoe = horse.get("shoeOption").getAsJsonObject().get("code").getAsInt();
+
+                        databaseController.insertResult(trackCode,
+                                raceDate,
+                                raceNumber,
+                                lane,
+                                actualDistance,
+                                -2,
+                                -1,
+                                raceStartType,
+                                shoe,
+                                -1,
+                                driverName,
+                                trainerName,
+                                horseName,
+                                horseTravsportId,
+                                trainerId,
+                                driverId,
+                                "",
+                                raceDayId);
+                        final int horseIdByName = databaseController.getHorseId(horseName, horseTravsportId);
+                        final int horseRaceCount = databaseController.getRaceCount("Horse", horseIdByName);
+                        if (horseIdByName > -1 && horseRaceCount <= 5) {
+                            getHorseStatByIdJson(horseTravsportId, horseName, "", -1);
+                        }
+
+                        final int driverIdByName = databaseController.getDriverId(driverName, driverId);
+                        final int driverRaceCount = databaseController.getRaceCount("Driver", driverIdByName);
+                        if (driverIdByName > -1 && driverRaceCount <= 20) {
+                            getDriverStatById(driverId, driverName, -1);
+                        }
+                    }
+                }
+            } catch (final NullPointerException e) {
+                System.out.println("Failed to get results");
+                throw new RuntimeException(e.getMessage(), e);
+            } catch (FailingHttpStatusCodeException | IOException e1) {
+                System.out.println("EXCEPTION while getting raceCalendar at date " + date);
+                // throw new RuntimeException(e1.getMessage(), e1);
+            }
+
+        }
+
+        // Xpath data-testid = racecalendar-button-startlist
+
+    }
+
+    public int getHorseIdByName(String horseName) {
+        /*
+         * Uppdatera med detta anrop, kommer tillbaka en JSON sträng som man kan ta utan
+         * css och allt.
+         * https://api.travsport.se/webapi/horses/results/organisation/TROT/sourceofdata
+         * /SPORT/horseid/781845
+         *
+         */
+        /*
+         * Search String
+         * https://api.travsport.se/webapi/horses/search/organisation/TROT?age=0&gender=
+         * BOTH&horseName=molly&trotBreed=ALL&autoSuffixWildcard=true
+         * 
+         * Svarar med lista ex.
+         * [{"organisation":"TROT","sourceOfData":"SPORT","horseId":58291,
+         * "name":"GINA II","yearOfBirth":"1945","horseGender":{"code":"S","text":"sto"}
+         * ,"horseBreed":{"code":"K","text":"kallblodig travare"}},
+         * {"organisation":"TROT","sourceOfData":"SPORT","horseId":58264,"name":"GINA",
+         * "yearOfBirth":"1935","horseGender":{"code":"S","text":"sto"},"horseBreed":{
+         * "code":"K","text":"kallblodig travare"}}]
+         */
+
+        int horseId = DatabaseController.getInstance().getHorseTravsportId(horseName);
+        if (horseId <= 0) {
+            System.out.println("Getting horse id from travsport");
+            final String url = "https://api.travsport.se/webapi/horses/search/organisation/TROT?age=0&gender=BOTH&horseName="
+                    + horseName + "&trotBreed=ALL&autoSuffixWildcard=false";
+
+            final WebClient webclient = MyWebClient.getInstance().getWebclient();
+            try {
+
+                final Page page = webclient.getPage(url);
+
+                final String content = page.getWebResponse().getContentAsString();
+                final Gson gson = new Gson();
+                final JsonArray fromJson = gson.fromJson(content, JsonArray.class);
+                final ArrayList<JsonObject> jsonObjects = Lists.newArrayList();
+                fromJson.forEach(e -> jsonObjects.add(e.getAsJsonObject()));
+
+                Collections.sort(jsonObjects, new Comparator<JsonObject>() {
+
+                    @Override
+                    public int compare(JsonObject o1, JsonObject o2) {
+                        return o2.get("horseId").getAsString().compareTo(o1.get("horseId").getAsString());
+                    }
+
+                });
+                horseId = jsonObjects.get(0).get("horseId").getAsInt();
+                DatabaseController.getInstance().setHorseTravsportId(Integer.valueOf(horseId), horseName);
+            } catch (FailingHttpStatusCodeException | IOException e) {
+                throw new RuntimeException(e.getMessage(), e);
+            } catch (final IndexOutOfBoundsException e) {
+                System.out.println("Horse with name " + horseName + " not found at travsport");
+            }
+
+        }
+        return horseId;
+    }
+
+    private ArrayList<JsonObject> getJsonObjects(String url) {
+        final ArrayList<JsonObject> jsonObjects = Lists.newArrayList();
+        try (WebClient wc = MyWebClient.getInstance().getJsonWebClient();) {
+
+            final Page page = wc.getPage(url);
+            final String content = page.getWebResponse().getContentAsString();
+            final Gson gson = new Gson();
+            final JsonArray fromJson = gson.fromJson(content, JsonArray.class);
+            fromJson.forEach(e -> jsonObjects.add(e.getAsJsonObject()));
+        } catch (FailingHttpStatusCodeException | IOException e) {
+            throw new RuntimeException(e.getMessage(), e);
+        }
+        return jsonObjects;
+    }
+
+    public void getHorseStatByIdJson(int horseTravsportId, String horseName, String raceType, int raceId) {
+        final String url = "https://api.travsport.se/webapi/horses/results/organisation/TROT/sourceofdata/SPORT/horseid/"
+                + horseTravsportId;
+
+        final ArrayList<JsonObject> jsonObjects = getJsonObjects(url);
+        final int i = 0;
+        final int rows = jsonObjects.size();
+        System.out.println("Updating horse " + horseName + " " + rows + " results");
+        for (final JsonObject jo : jsonObjects) {
+            final String trackCode = jo.get("trackCode").getAsString();
+
+            final JsonObject raceInfo = jo.get("raceInformation").getAsJsonObject();
+            final String raceDate = raceInfo.get("date").getAsString();
+            final int raceNumber = raceInfo.get("raceNumber").getAsInt();
+
+            int lane;
+            try {
+                lane = Integer.valueOf(jo.get("startPosition").getAsJsonObject().get("displayValue").getAsString());
+            } catch (final NumberFormatException e) {
+                lane = -1;
+            }
+
+            final int distance = Integer.valueOf(jo.get("distance").getAsJsonObject().get("displayValue").getAsString());
+
+            final String timeValue = jo.get("kilometerTime").getAsJsonObject().get("displayValue").getAsString();
+
+            final float time = getTimeFromTimeCellValue(timeValue);
+            final String timeModifier = getTimeModifierFromTimeCellValue(timeValue);
+
+            if (jo.get("shoeInfo") != null) {
+                final JsonObject shoeInfo = jo.get("shoeInfo").getAsJsonObject();
+                final boolean frontShoe = shoeInfo.get("front").getAsBoolean();
+                final boolean backShoe = shoeInfo.get("back").getAsBoolean();
+                // konvertera till värdet som det ska vara...
+            }
+
+            final JsonObject placementInfo = jo.get("placement").getAsJsonObject();
+            final String resultString = placementInfo.get("displayValue").getAsString();
+            final int result = Strings.isNullOrEmpty(resultString.replaceAll("\\D", "")) ? -1
+                    : Integer.valueOf(resultString.replaceAll("\\D", ""));
+
+            final JsonObject driverInfo = jo.get("driver").getAsJsonObject();
+            final int driverId = driverInfo.get("id").getAsInt();
+            final String driverName = driverInfo.get("name").getAsString();
+
+            final JsonObject trainerInfo = jo.get("trainer").getAsJsonObject();
+            final int trainerId = trainerInfo.get("id").getAsInt();
+            final String trainerName = trainerInfo.get("name").getAsString();
+
+            // final String sulkyString =
+            // jo.get("suklyOptions").getAsJsonObject().get("description").getAsString();
+
+            DatabaseController.getInstance().insertResult(trackCode,
+                    raceDate,
+                    raceNumber,
+                    lane,
+                    distance,
+                    result,
+                    time,
+                    timeModifier,
+                    -1,
+                    -1,
+                    driverName,
+                    trainerName,
+                    horseName,
+                    horseTravsportId,
+                    trainerId,
+                    driverId,
+                    raceType,
+                    raceId);
+
+        }
+    }
+
+    public void getDriverStatById(int driverTravsportId, String driverName, int raceId) {
+        // https://api.travsport.se/webapi/licenseholder/drivers/results/organisation/TROT/sourceofdata/SPORT/driverid/70381
+        // JSON resultat
+
+        final String url
+                = "https://api.travsport.se/webapi/licenseholder/drivers/results/organisation/TROT/sourceofdata/SPORT/driverid/"
+                        + driverTravsportId;
+        final WebClient wc = MyWebClient.getInstance().getJsonWebClient();
+
+        try {
+            final Page page = wc.getPage(url);
+
+            final String content = page.getWebResponse().getContentAsString();
+            final Gson gson = new Gson();
+            final JsonArray fromJson = gson.fromJson(content, JsonArray.class);
+            final ArrayList<JsonObject> jsonObjects = Lists.newArrayList();
+            fromJson.forEach(e -> jsonObjects.add(e.getAsJsonObject()));
+
+            final int i = 0;
+            final int rows = jsonObjects.size();
+            System.out.println("Updating driver " + driverName + " " + rows + " results");
+            for (final JsonObject jo : jsonObjects) {
+
+                final String trackCode = jo.get("trackCode").getAsString();
+
+                final JsonObject raceInfo = jo.get("raceInformation").getAsJsonObject();
+                final String raceDate = raceInfo.get("date").getAsString();
+                final int raceNumber = raceInfo.get("raceNumber").getAsInt();
+                int lane;
+                try {
+                    lane = Integer.valueOf(jo.get("startPosition").getAsJsonObject().get("displayValue").getAsString());
+                } catch (final NumberFormatException e) {
+                    lane = -1;
+                }
+                final int distance = Integer.valueOf(jo.get("distance").getAsJsonObject().get("displayValue").getAsString());
+
+                final String timeValue = jo.get("kilometerTime").getAsJsonObject().get("displayValue").getAsString();
+                final float time = getTimeFromTimeCellValue(timeValue);
+                final String timeModifier = getTimeModifierFromTimeCellValue(timeValue);
+
+                final String resultString = jo.get("placement").getAsJsonObject().get("displayValue").getAsString();
+                final int result = Strings.isNullOrEmpty(resultString.replaceAll("\\D", "")) ? -1
+                        : Integer.valueOf(resultString.replaceAll("\\D", ""));
+
+                final JsonObject horseObject = jo.get("horse").getAsJsonObject();
+                final String horseName = horseObject.get("name").getAsString();
+                final int travsportIdHorse = horseObject.get("id").getAsInt();
+                String trainerName = "";
+                int trainerId = -1;
+                if (jo.get("trainer") != null) {
+                    final JsonObject trainerObject = jo.get("trainer").getAsJsonObject();
+                    trainerName = trainerObject.get("name").getAsString();
+                    trainerId = trainerObject.get("id").getAsInt();
+                }
+
+                DatabaseController.getInstance().insertResult(trackCode,
+                        raceDate,
+                        raceNumber,
+                        lane,
+                        distance,
+                        result,
+                        time,
+                        timeModifier,
+                        -1,
+                        -1,
+                        driverName,
+                        trainerName,
+                        horseName,
+                        travsportIdHorse,
+                        trainerId,
+                        driverTravsportId,
+                        "",
+                        raceId);
+
+            }
+
+        } catch (FailingHttpStatusCodeException | IOException e) {
+            throw new RuntimeException(e.getMessage(), e);
+        }
+    }
+
+    public int getDriverIdByName(String firstName, String lastName) {
+        System.out.println("Getting driver id from travsport by name " + firstName + " " + lastName);
+        final String url = "https://api.travsport.se/webapi/licenseholder/search/organisation/TROT?firstName=" + firstName
+                + "&lastName=" + lastName + "&showAll=false";
+        int driverId = 0;
+        final WebClient webclient = MyWebClient.getInstance().getJsonWebClient();
+        try {
+
+            final Page page = webclient.getPage(url);
+
+            final String content = page.getWebResponse().getContentAsString();
+            final Gson gson = new Gson();
+            final JsonArray fromJson = gson.fromJson(content, JsonArray.class);
+            final ArrayList<JsonObject> jsonObjects = Lists.newArrayList();
+            fromJson.forEach(e -> jsonObjects.add(e.getAsJsonObject()));
+
+            Collections.sort(jsonObjects, new Comparator<JsonObject>() {
+
+                @Override
+                public int compare(JsonObject o1, JsonObject o2) {
+                    return o2.get("id").getAsString().compareTo(o1.get("id").getAsString());
+                }
+
+            });
+            driverId = jsonObjects.get(0).get("id").getAsInt();
+            DatabaseController.getInstance().setDriverTravsportId(driverId, firstName, lastName);
+
+        } catch (FailingHttpStatusCodeException | IOException e) {
+            throw new RuntimeException(e.getMessage(), e);
+        } catch (final IndexOutOfBoundsException e) {
+            System.out.println("Driver with name " + firstName + " " + lastName + " not found at travsport");
+        }
+        return driverId;
+    }
+
+    public void updateRaceResults(int raceId) {
+        // https://api.travsport.se/webapi/raceinfo/results/organisation/TROT/sourceofdata/SPORT/racedayid/<raceId>
+        final String url
+                = "https://api.travsport.se/webapi/raceinfo/results/organisation/TROT/sourceofdata/SPORT/racedayid/" + raceId;
+
+        try {
+            final Page page = MyWebClient.getInstance().getJsonWebClient().getPage(url);
+            final String content = new String(page.getWebResponse().getContentAsString()); // .getBytes("ISO-8859-1"), "UTF-8");
+            final Gson gson = new Gson();
+            final JsonObject jo = gson.fromJson(content, JsonObject.class);
+
+            final ArrayList<JsonObject> jsonObjects = Lists.newArrayList();
+            final JsonArray results = jo.get("racesWithReadyResult").getAsJsonArray();
+            results.forEach(j -> jsonObjects.add(j.getAsJsonObject()));
+
+            for (final JsonObject json : jsonObjects) {
+                final JsonObject generalInfo = json.get("generalInfo").getAsJsonObject();
+                final int raceNumber = generalInfo.get("raceNumber").getAsInt();
+                Matcher matcher;
+                String startTime;
+                try {
+                    startTime = generalInfo.get("startTime").getAsString();
+                    final Pattern pattern = Pattern.compile("\\d{4}-\\d{2}-\\d{2}");
+                    matcher = pattern.matcher(startTime);
+                } catch (final NullPointerException e) {
+                    continue;
+                }
+                String raceDate;
+                if (matcher.find()) {
+                    raceDate = matcher.group();
+                } else {
+                    throw new RuntimeException("Could not find date from " + startTime);
+                }
+
+                try {
+                    final JsonArray raceResultRows = json.get("raceResultRows").getAsJsonArray();
+
+                    for (int i = 0; i < raceResultRows.size(); i++) {
+                        final JsonObject res = raceResultRows.get(i).getAsJsonObject();
+                        final int result = res.get("placementNumber").getAsInt();
+                        final JsonObject horse = res.get("horse").getAsJsonObject();
+                        final int horseTravsportId = horse.get("id").getAsInt();
+                        final String horseName = horse.get("name").getAsString();
+
+                        final JsonObject driver = res.get("driver").getAsJsonObject();
+                        final int driverTravsportId = driver.get("id").getAsInt();
+                        final String driverName = driver.get("name").getAsString();
+
+                        final JsonObject trainer = res.get("trainer").getAsJsonObject();
+                        final int trainerTravsportId = trainer.get("id").getAsInt();
+                        final String trainerName = trainer.get("name").getAsString();
+                        int shoeInfo = 0;
+                        try {
+                            shoeInfo = res.get("shoeInfo").getAsJsonObject().get("sortValue").getAsInt();
+                        } catch (final NullPointerException e) {
+                            // ignore
+                        }
+
+                        final String timeString = res.get("time").getAsString();
+                        final float time = getTimeFromTimeCellValue(timeString);
+                        final String timeModifier = getTimeModifierFromTimeCellValue(timeString);
+
+                        final String[] startPosAndDistance = res.get("startPositionAndDistance").getAsString().split("/");
+                        // final int lane = Integer.valueOf(startPosAndDistance[0]);
+                        final int lane = res.get("programNumber").getAsInt();
+                        final int distance = Integer.valueOf(startPosAndDistance[1]);
+
+                        DatabaseController.getInstance().updateFromRaceResults(raceId,
+                                result,
+                                time,
+                                timeModifier,
+                                lane,
+                                distance,
+                                horseTravsportId,
+                                driverTravsportId,
+                                raceDate,
+                                raceNumber);
+                        System.out.println("Updated raceId " + raceId + " horse " + horseName + "(" + horseTravsportId
+                                + ") driver " + driverName + "(" + driverTravsportId + ") at date " + raceDate + " with result "
+                                + result + " time " + time + " time mod " + timeModifier + " race number: " + raceNumber);
+                    }
+                } catch (final NullPointerException e) {
+                    System.out.println("ERROR WITH MESSAGE: " + e.getMessage());
+                    continue;
+                }
+            }
+        } catch (FailingHttpStatusCodeException | IOException e) {
+            throw new RuntimeException(e.getMessage(), e);
+        }
+    }
 
 }