Revize 82a06985
Přidáno uživatelem Daniel Stuš před téměř 6 roky(ů)
JDF/SeznamLinek.txt | ||
---|---|---|
1 |
143440
|
|
1 |
000004
|
|
2 | 2 |
440055 |
3 | 3 |
440070 |
4 | 4 |
440380 |
src/data/Bitmap.java | ||
---|---|---|
165 | 165 |
} |
166 | 166 |
} |
167 | 167 |
|
168 |
public void setWeeks(int value, int remainder, int dayNumber) { |
|
169 |
value = validateValue(value); |
|
170 |
Calendar currentDay = (Calendar) this.dateFrom.clone(); |
|
171 |
|
|
172 |
for (int i = 0; i < this.bitmap.length; i++) { |
|
173 |
if ((currentDay.get(Calendar.WEEK_OF_YEAR)%2) == remainder && currentDay.get((Calendar.DAY_OF_WEEK)) == dayNumber) { |
|
174 |
this.bitmap[i] = value; |
|
175 |
} |
|
176 |
|
|
177 |
currentDay.add(Calendar.DATE, 1); |
|
178 |
|
|
179 |
} |
|
180 |
} |
|
181 |
|
|
168 | 182 |
|
169 | 183 |
public void setWeeksRange(Calendar from, Calendar to, int value, int remainder) { |
170 | 184 |
|
... | ... | |
185 | 199 |
|
186 | 200 |
} |
187 | 201 |
|
202 |
public void setWeeksRange(Calendar from, Calendar to, int value, int remainder, int dayNumber) { |
|
203 |
|
|
204 |
value = validateValue(value); |
|
205 |
Calendar currentDay = (Calendar) this.dateFrom.clone(); |
|
206 |
to.add(Calendar.DATE, 1); |
|
207 |
from.add(Calendar.DATE, -1); |
|
208 |
|
|
209 |
for (int i = 0; i < this.bitmap.length; i++) { |
|
210 |
if (currentDay.after(from) && currentDay.before(to)) { |
|
211 |
if ((currentDay.get(Calendar.WEEK_OF_YEAR)%2)==remainder && currentDay.get((Calendar.DAY_OF_WEEK)) == dayNumber) { |
|
212 |
this.bitmap[i] = value; |
|
213 |
} |
|
214 |
} |
|
215 |
|
|
216 |
currentDay.add(Calendar.DATE, 1); |
|
217 |
} |
|
218 |
|
|
219 |
} |
|
220 |
|
|
188 | 221 |
public void unsetHolidays() { |
189 | 222 |
Calendar currentDay = (Calendar) this.dateFrom.clone(); |
190 | 223 |
|
src/data/BitmapBuilder.java | ||
---|---|---|
11 | 11 |
import java.nio.file.StandardOpenOption; |
12 | 12 |
import java.text.SimpleDateFormat; |
13 | 13 |
import java.util.ArrayList; |
14 |
import java.util.Arrays; |
|
15 | 14 |
import java.util.Calendar; |
15 |
import java.util.List; |
|
16 | 16 |
|
17 | 17 |
public class BitmapBuilder { |
18 | 18 |
|
19 | 19 |
ArrayList<JDFPevnykodRecord> pevnykod = new ArrayList<>(); |
20 | 20 |
ArrayList<JDFCaskodyRecord> caskody = new ArrayList<>(); |
21 | 21 |
ArrayList<JDFSpojeRecord> spoje = new ArrayList<>(); |
22 |
String[] lineList;
|
|
22 |
List<String> lineList;
|
|
23 | 23 |
Path outputFile; |
24 | 24 |
|
25 | 25 |
private Window window; |
... | ... | |
79 | 79 |
public void getPevnyKod(ArrayList<String[]> loadedData){ |
80 | 80 |
JDFPevnykodRecord pevnykodRecord; |
81 | 81 |
for(String[] record : loadedData){ |
82 |
pevnykodRecord = new JDFPevnykodRecord(record); |
|
83 |
pevnykod.add(pevnykodRecord); |
|
82 |
if (lineList.contains(record[0])) { |
|
83 |
pevnykodRecord = new JDFPevnykodRecord(record); |
|
84 |
pevnykod.add(pevnykodRecord); |
|
85 |
} |
|
84 | 86 |
} |
85 | 87 |
window.printMessage("Načten soubor Pevnykod.txt"); |
86 | 88 |
} |
... | ... | |
88 | 90 |
public void getCaskody(ArrayList<String[]> loadedData){ |
89 | 91 |
JDFCaskodyRecord caskodyRecord; |
90 | 92 |
for(String[] record : loadedData){ |
91 |
caskodyRecord = new JDFCaskodyRecord(record); |
|
92 |
caskody.add(caskodyRecord); |
|
93 |
if (lineList.contains(record[0]) && record[4].matches("\\d+")) { |
|
94 |
caskodyRecord = new JDFCaskodyRecord(record); |
|
95 |
caskody.add(caskodyRecord); |
|
96 |
} |
|
93 | 97 |
} |
94 |
window.printMessage("Načten soubor Caskody.txt");
|
|
98 |
window.printMessage("Načteny požadované linky ze souboru Caskody.txt");
|
|
95 | 99 |
} |
96 | 100 |
|
97 | 101 |
public void getSpoje(ArrayList<String[]> loadedData){ |
98 | 102 |
JDFSpojeRecord spojeRecord; |
99 | 103 |
for(String[] record : loadedData){ |
100 |
spojeRecord = new JDFSpojeRecord(record); |
|
101 |
spoje.add(spojeRecord); |
|
104 |
if (lineList.contains(record[0])) { |
|
105 |
spojeRecord = new JDFSpojeRecord(record); |
|
106 |
spoje.add(spojeRecord); |
|
107 |
} |
|
102 | 108 |
} |
103 |
window.printMessage("Načten soubor Spoje.txt");
|
|
109 |
window.printMessage("Načteny požadované linky ze souboru Spoje.txt");
|
|
104 | 110 |
} |
105 | 111 |
|
106 |
public void getLineList(String[] lines){
|
|
112 |
public void getLineList(List<String> lines){
|
|
107 | 113 |
this.lineList = lines; |
108 | 114 |
window.printMessage("Načten uživatelský seznam linek"); |
109 |
window.printMessage("Nalezené linky: "+ Arrays.toString(lineList)); |
|
115 |
window.printMessage("Nalezené linky: "+lineList); |
|
116 |
|
|
110 | 117 |
} |
111 | 118 |
|
112 | 119 |
public void writeBitmaps(Calendar dateFrom, Calendar dateTo) { |
... | ... | |
116 | 123 |
String formatedDateFrom = format.format(dateFrom.getTime()); |
117 | 124 |
String formatedDateTo = format.format(dateTo.getTime()); |
118 | 125 |
writer.write("Období;" + formatedDateFrom + ";" + formatedDateTo + "\n\n"); |
119 |
window.printMessage("Zapisuji bitmapy..");
|
|
120 |
for (int i = 0; i < lineList.length ; i++) {
|
|
121 |
|
|
126 |
String currentTimeCode = caskody.get(0).getTimeCode();
|
|
127 |
String currentLine = caskody.get(0).getNumberLine();
|
|
128 |
int numberOfBitmaps = 0; |
|
122 | 129 |
|
123 |
Bitmap generatedBitmap = new Bitmap(dateFrom, dateTo, lineList[i]);
|
|
130 |
window.printMessage("Zpracovávám bitmapy...");
|
|
124 | 131 |
|
125 |
// TODO: 10.05.2019 Logika procházení seznamu CASKODY | SPOJE | PEVNYKOD -> generování správných bitmap |
|
126 | 132 |
|
133 |
Bitmap generatedBitmap = new Bitmap(dateFrom, dateTo, currentLine); |
|
134 |
numberOfBitmaps++; |
|
135 |
window.printMessage("Zpracovávám linku: "+currentLine); |
|
127 | 136 |
|
128 |
for (JDFCaskodyRecord caskod : caskody) { |
|
129 |
if(caskod.getNumberLine().equals(lineList[i])) { |
|
130 |
writer.write(generatedBitmap.getLineNumber()+caskod.getNumberLineVersion()+"-"+caskod.getTimeCode()); |
|
131 |
writer.write("-X;;"+generatedBitmap.getBitmapString()+"\n"); |
|
137 |
for (JDFCaskodyRecord caskod : caskody) { |
|
138 |
if (currentLine.equals(caskod.getNumberLine()) && currentTimeCode.equals(caskod.getTimeCode())) { |
|
139 |
writer.write(generatedBitmap.getLineNumber()+caskod.getNumberLineVersion()+"-"+currentTimeCode+"-X;;"+generatedBitmap.getBitmapString()+"\n"); |
|
140 |
} |
|
141 |
else if (currentLine.equals(caskod.getNumberLine()) && !currentTimeCode.equals(caskod.getTimeCode())){ |
|
142 |
currentTimeCode = caskod.getTimeCode(); |
|
143 |
generatedBitmap = new Bitmap(dateFrom, dateTo, currentLine); |
|
144 |
numberOfBitmaps++; |
|
145 |
writer.write(generatedBitmap.getLineNumber()+caskod.getNumberLineVersion()+"-"+currentTimeCode+"-X;;"+generatedBitmap.getBitmapString()+"\n"); |
|
132 | 146 |
} |
133 |
} |
|
134 | 147 |
|
148 |
else { |
|
149 |
currentLine = caskod.getNumberLine(); |
|
150 |
currentTimeCode = caskod.getTimeCode(); |
|
151 |
window.printMessage("Zpracovávám linku: "+currentLine); |
|
135 | 152 |
|
136 |
} |
|
153 |
generatedBitmap = new Bitmap(dateFrom, dateTo, currentLine); |
|
154 |
numberOfBitmaps++; |
|
155 |
writer.write(generatedBitmap.getLineNumber()+caskod.getNumberLineVersion()+"-"+currentTimeCode+"-X;;"+generatedBitmap.getBitmapString()+"\n"); |
|
156 |
} |
|
157 |
} |
|
158 |
window.printMessage("Celkem vygenerováno: "+numberOfBitmaps+" Bitmap"); |
|
137 | 159 |
|
138 | 160 |
} catch (IOException e) { |
139 | 161 |
e.printStackTrace(); |
140 |
window.printMessage("Nečekaná chyba při zapisování bitmapy");
|
|
162 |
window.printMessage("Neočekávaná chyba při zapisování bitmapy");
|
|
141 | 163 |
} |
142 | 164 |
window.printMessage("Bitmapy úspěšně zapsány"); |
143 | 165 |
} |
src/data/DataLoader.java | ||
---|---|---|
123 | 123 |
* |
124 | 124 |
* @param lineFile cesta k uživatelskému souboru se seznamem linek |
125 | 125 |
*/ |
126 |
public String[] loadLines(File lineFile) {
|
|
126 |
public List<String> loadLines(File lineFile) {
|
|
127 | 127 |
|
128 |
List<String> linkList = null;
|
|
128 |
List<String> lineList = null;
|
|
129 | 129 |
Charset charset = Charset.defaultCharset(); |
130 | 130 |
|
131 | 131 |
//soubor |
... | ... | |
140 | 140 |
|
141 | 141 |
|
142 | 142 |
try { |
143 |
linkList = Files.readAllLines(file.toPath(), charset);
|
|
143 |
lineList = Files.readAllLines(file.toPath(), charset);
|
|
144 | 144 |
} catch (IOException e) { |
145 | 145 |
e.printStackTrace(); |
146 | 146 |
} |
147 | 147 |
|
148 |
return linkList.toArray(new String[]{});
|
|
148 |
return lineList;
|
|
149 | 149 |
} |
150 | 150 |
|
151 | 151 |
/**, |
src/gui/Window.java | ||
---|---|---|
7 | 7 |
import java.awt.event.*; |
8 | 8 |
|
9 | 9 |
import java.io.File; |
10 |
import java.io.IOException; |
|
10 | 11 |
import java.text.DateFormat; |
11 | 12 |
import java.text.ParseException; |
12 | 13 |
import java.text.SimpleDateFormat; |
... | ... | |
329 | 330 |
DataLoader loader = new DataLoader(jdfDir); |
330 | 331 |
|
331 | 332 |
//načítání konkrétních dat |
332 |
String[] lineList = loader.loadLines(linkyFile);
|
|
333 |
List<String> lineList= loader.loadLines(linkyFile);
|
|
333 | 334 |
bitmapBuilder.getLineList(lineList); |
334 | 335 |
|
335 | 336 |
loadedData = loader.loadData(PEVNY_KOD); |
... | ... | |
345 | 346 |
|
346 | 347 |
bitmapBuilder.writeBitmaps(dateFrom, dateTo); |
347 | 348 |
|
348 |
printMessage("Ukončuji program.."); |
|
349 |
|
|
350 |
// Otevře explorer a zvýrazní výstupní soubor |
|
351 |
try { |
|
352 |
Runtime.getRuntime().exec("explorer.exe /select," + outputFile); |
|
353 |
} catch (IOException e) { |
|
354 |
e.printStackTrace(); |
|
355 |
} |
|
356 |
|
|
357 |
printMessage("Ukončuji program.."); |
|
349 | 358 |
|
350 | 359 |
} |
351 | 360 |
|
Také k dispozici: Unified diff
Úpravy metod a dat tříd BitmapBuilder, Bitmap, DataLoader. QoL improvements třídy Window (Re #7485)