commit 82a06985653e2aa3cf55c162451243d4258f1f46
Author: Daniel Stuš <stusd@students.zcu.cz>
Date:   Tue May 14 01:04:32 2019 +0200

    Úpravy metod a dat tříd BitmapBuilder, Bitmap, DataLoader. QoL improvements třídy Window (Re #7485)

diff --git a/JDF/SeznamLinek.txt b/JDF/SeznamLinek.txt
index 7abb706..eb9d51e 100644
--- a/JDF/SeznamLinek.txt
+++ b/JDF/SeznamLinek.txt
@@ -1,4 +1,4 @@
-143440
+000004
 440055
 440070
 440380
\ No newline at end of file
diff --git a/src/data/Bitmap.java b/src/data/Bitmap.java
index 1cabdc8..5524280 100644
--- a/src/data/Bitmap.java
+++ b/src/data/Bitmap.java
@@ -165,6 +165,20 @@ public class Bitmap {
         }
     }
 
+    public void setWeeks(int value, int remainder, int dayNumber) {
+        value = validateValue(value);
+        Calendar currentDay = (Calendar) this.dateFrom.clone();
+
+        for (int i = 0; i < this.bitmap.length; i++) {
+            if ((currentDay.get(Calendar.WEEK_OF_YEAR)%2) == remainder && currentDay.get((Calendar.DAY_OF_WEEK)) == dayNumber) {
+                this.bitmap[i] = value;
+            }
+
+            currentDay.add(Calendar.DATE, 1);
+
+        }
+    }
+
 
     public void setWeeksRange(Calendar from, Calendar to, int value, int remainder) {
 
@@ -185,6 +199,25 @@ public class Bitmap {
 
     }
 
+    public void setWeeksRange(Calendar from, Calendar to, int value, int remainder, int dayNumber) {
+
+        value = validateValue(value);
+        Calendar currentDay = (Calendar) this.dateFrom.clone();
+        to.add(Calendar.DATE, 1);
+        from.add(Calendar.DATE, -1);
+
+        for (int i = 0; i < this.bitmap.length; i++) {
+            if (currentDay.after(from) && currentDay.before(to)) {
+                if ((currentDay.get(Calendar.WEEK_OF_YEAR)%2)==remainder && currentDay.get((Calendar.DAY_OF_WEEK)) == dayNumber) {
+                    this.bitmap[i] = value;
+                }
+            }
+
+            currentDay.add(Calendar.DATE, 1);
+        }
+
+    }
+
     public void unsetHolidays() {
         Calendar currentDay = (Calendar) this.dateFrom.clone();
 
diff --git a/src/data/BitmapBuilder.java b/src/data/BitmapBuilder.java
index 44b6109..9e8c7d5 100644
--- a/src/data/BitmapBuilder.java
+++ b/src/data/BitmapBuilder.java
@@ -11,15 +11,15 @@ import java.nio.file.Path;
 import java.nio.file.StandardOpenOption;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Calendar;
+import java.util.List;
 
 public class BitmapBuilder {
 
     ArrayList<JDFPevnykodRecord> pevnykod = new ArrayList<>();
     ArrayList<JDFCaskodyRecord> caskody = new ArrayList<>();
     ArrayList<JDFSpojeRecord> spoje = new ArrayList<>();
-    String[] lineList;
+    List<String> lineList;
     Path outputFile;
     
     private Window window;
@@ -79,8 +79,10 @@ public class BitmapBuilder {
     public void getPevnyKod(ArrayList<String[]> loadedData){
         JDFPevnykodRecord pevnykodRecord;
         for(String[] record : loadedData){
-            pevnykodRecord = new JDFPevnykodRecord(record);
-            pevnykod.add(pevnykodRecord);
+            if (lineList.contains(record[0])) {
+                pevnykodRecord = new JDFPevnykodRecord(record);
+                pevnykod.add(pevnykodRecord);
+            }
         }
         window.printMessage("Načten soubor Pevnykod.txt");
     }
@@ -88,25 +90,30 @@ public class BitmapBuilder {
     public void getCaskody(ArrayList<String[]> loadedData){
         JDFCaskodyRecord caskodyRecord;
         for(String[] record : loadedData){
-            caskodyRecord = new JDFCaskodyRecord(record);
-            caskody.add(caskodyRecord);
+            if (lineList.contains(record[0]) && record[4].matches("\\d+")) {
+                caskodyRecord = new JDFCaskodyRecord(record);
+                caskody.add(caskodyRecord);
+            }
         }
-        window.printMessage("Načten soubor Caskody.txt");
+        window.printMessage("Načteny požadované linky ze souboru Caskody.txt");
     }
 
     public void getSpoje(ArrayList<String[]> loadedData){
         JDFSpojeRecord spojeRecord;
         for(String[] record : loadedData){
-            spojeRecord = new JDFSpojeRecord(record);
-            spoje.add(spojeRecord);
+            if (lineList.contains(record[0])) {
+                spojeRecord = new JDFSpojeRecord(record);
+                spoje.add(spojeRecord);
+            }
         }
-        window.printMessage("Načten soubor Spoje.txt");
+        window.printMessage("Načteny požadované linky ze souboru Spoje.txt");
     }
 
-    public void getLineList(String[] lines){
+    public void getLineList(List<String> lines){
         this.lineList = lines;
         window.printMessage("Načten uživatelský seznam linek");
-        window.printMessage("Nalezené linky: "+ Arrays.toString(lineList));
+        window.printMessage("Nalezené linky: "+lineList);
+
     }
 
     public void writeBitmaps(Calendar dateFrom, Calendar dateTo) {
@@ -116,28 +123,43 @@ public class BitmapBuilder {
             String formatedDateFrom = format.format(dateFrom.getTime());
             String formatedDateTo = format.format(dateTo.getTime());
             writer.write("Období;" + formatedDateFrom + ";" + formatedDateTo + "\n\n");
-            window.printMessage("Zapisuji bitmapy..");
-            for (int i = 0; i < lineList.length ; i++) {
-
+            String currentTimeCode = caskody.get(0).getTimeCode();
+            String currentLine =  caskody.get(0).getNumberLine();
+            int numberOfBitmaps = 0;
 
-                Bitmap generatedBitmap = new Bitmap(dateFrom, dateTo, lineList[i]);
+            window.printMessage("Zpracovávám bitmapy...");
 
-                // TODO: 10.05.2019 Logika procházení seznamu CASKODY | SPOJE | PEVNYKOD -> generování správných bitmap
 
+            Bitmap generatedBitmap = new Bitmap(dateFrom, dateTo, currentLine);
+            numberOfBitmaps++;
+            window.printMessage("Zpracovávám linku: "+currentLine);
 
-               for (JDFCaskodyRecord caskod : caskody) {
-                    if(caskod.getNumberLine().equals(lineList[i])) {
-                        writer.write(generatedBitmap.getLineNumber()+caskod.getNumberLineVersion()+"-"+caskod.getTimeCode());
-                        writer.write("-X;;"+generatedBitmap.getBitmapString()+"\n");
+                for (JDFCaskodyRecord caskod : caskody) {
+                    if (currentLine.equals(caskod.getNumberLine()) && currentTimeCode.equals(caskod.getTimeCode())) {
+                        writer.write(generatedBitmap.getLineNumber()+caskod.getNumberLineVersion()+"-"+currentTimeCode+"-X;;"+generatedBitmap.getBitmapString()+"\n");
+                    }
+                    else if (currentLine.equals(caskod.getNumberLine()) && !currentTimeCode.equals(caskod.getTimeCode())){
+                        currentTimeCode = caskod.getTimeCode();
+                        generatedBitmap = new Bitmap(dateFrom, dateTo, currentLine);
+                        numberOfBitmaps++;
+                        writer.write(generatedBitmap.getLineNumber()+caskod.getNumberLineVersion()+"-"+currentTimeCode+"-X;;"+generatedBitmap.getBitmapString()+"\n");
                     }
-                }
 
+                    else {
+                        currentLine = caskod.getNumberLine();
+                        currentTimeCode = caskod.getTimeCode();
+                        window.printMessage("Zpracovávám linku: "+currentLine);
 
-            }
+                        generatedBitmap = new Bitmap(dateFrom, dateTo, currentLine);
+                        numberOfBitmaps++;
+                        writer.write(generatedBitmap.getLineNumber()+caskod.getNumberLineVersion()+"-"+currentTimeCode+"-X;;"+generatedBitmap.getBitmapString()+"\n");
+                    }
+                }
+                window.printMessage("Celkem vygenerováno: "+numberOfBitmaps+" Bitmap");
 
         } catch (IOException e) {
             e.printStackTrace();
-            window.printMessage("Nečekaná chyba při zapisování bitmapy");
+            window.printMessage("Neočekávaná chyba při zapisování bitmapy");
         }
         window.printMessage("Bitmapy úspěšně zapsány");
     }
diff --git a/src/data/DataLoader.java b/src/data/DataLoader.java
index 923961d..657646b 100644
--- a/src/data/DataLoader.java
+++ b/src/data/DataLoader.java
@@ -123,9 +123,9 @@ public class DataLoader {
      *
      * @param lineFile cesta k uživatelskému souboru se seznamem linek
      */
-    public String[] loadLines(File lineFile) {
+    public List<String> loadLines(File lineFile) {
 
-        List<String> linkList = null;
+        List<String> lineList = null;
         Charset charset = Charset.defaultCharset();
 
         //soubor
@@ -140,12 +140,12 @@ public class DataLoader {
 
 
         try {
-            linkList = Files.readAllLines(file.toPath(), charset);
+            lineList = Files.readAllLines(file.toPath(), charset);
         } catch (IOException e) {
             e.printStackTrace();
         }
 
-      return linkList.toArray(new String[]{});
+      return lineList;
     }
 
     /**,
diff --git a/src/gui/Window.java b/src/gui/Window.java
index 347f267..7b1f0d0 100644
--- a/src/gui/Window.java
+++ b/src/gui/Window.java
@@ -7,6 +7,7 @@ import java.awt.GridLayout;
 import java.awt.event.*;
 
 import java.io.File;
+import java.io.IOException;
 import java.text.DateFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
@@ -329,7 +330,7 @@ public class Window extends JFrame{
 	        DataLoader loader = new DataLoader(jdfDir);
 
 	        //načítání konkrétních dat
-			String[] lineList = loader.loadLines(linkyFile);
+			List<String> lineList= loader.loadLines(linkyFile);
 			bitmapBuilder.getLineList(lineList);
 
 	        loadedData = loader.loadData(PEVNY_KOD);
@@ -345,7 +346,15 @@ public class Window extends JFrame{
 
 	        bitmapBuilder.writeBitmaps(dateFrom, dateTo);
 
-	        printMessage("Ukončuji program..");
+
+	        // Otevře explorer a zvýrazní výstupní soubor
+			try {
+				Runtime.getRuntime().exec("explorer.exe /select," + outputFile);
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+
+			printMessage("Ukončuji program..");
 			
 		}
 		
