diff --git a/conf.ini.sample b/conf.ini.sample index 44d0e68..1440243 100644 --- a/conf.ini.sample +++ b/conf.ini.sample @@ -10,6 +10,12 @@ lang = langde openpdf = 1 openmap = 0 +[einheiten] +zeit = min +strecke = km +meter = m +speed = km/h + [db] dbname = tourplaner url = diff --git a/langde.ini b/langde.ini index 67e1ca1..04a6c05 100644 --- a/langde.ini +++ b/langde.ini @@ -93,4 +93,12 @@ fsprache = Sprache auswählen fhilfe = Hilfe freposum = Erstelle Report über alle Touren frepotour = Erstelle Report über aktuelle Tour -fbeenden = Beenden \ No newline at end of file +fbeenden = Beenden +fpunkte = ... + +rzeitallerlogs = Gesammte Zeit aller Logs: +rstreckeallerlogs = gesammte Strecke aller Logs: +rcalzeitallerlogs = Berechnete Zeit aller Logs: +calstreckeallerloggs = Berechnete Strecke aller Touren: +rdaten = Daten +rsummrepo = Zusammengefasster Report \ No newline at end of file diff --git a/langen.ini b/langen.ini index 072aef9..8571698 100644 --- a/langen.ini +++ b/langen.ini @@ -94,4 +94,12 @@ fsprache = Choose Language fhilfe = Help freposum = Generate summarize-report frepotour = Generate tour-report -fbeenden = Quit \ No newline at end of file +fbeenden = Quit +fpunkte = ... + +rzeitallerlogs = Time of all logs: +rstreckeallerlogs = Distance of all logs: +rcalzeitallerlogs = Calculated time of all logs: +calstreckeallerloggs = Calculated distance of all logs: +rdaten = Data +rsummrepo = Summary Report \ No newline at end of file diff --git a/src/tourplaner/business/EinheitenAdder.java b/src/tourplaner/business/EinheitenAdder.java new file mode 100644 index 0000000..80bf31c --- /dev/null +++ b/src/tourplaner/business/EinheitenAdder.java @@ -0,0 +1,50 @@ +package tourplaner.business; + +/** + * Fügt am ende eines Strings die einheiten an + */ +public class EinheitenAdder { + + /** + * Fügt meter hinzu + * @param meter Meter als String + * @return Meter mit einheit + */ + public static String addMeter(String meter){ + return meter + " " +ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "einheiten", "meter"); + } + + public static String addSpeed(String speed){ + return speed + " " + ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "einheiten", "speed"); + } + + /** + * Fügt km hinzu + * @param km km als String + * @return km mit einheit + */ + public static String addKm(String km){ + return km + " " +ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "einheiten", "strecke"); + } + + /** + * Fügt minuten hinzu + * @param min minuten als String + * @return minuten mit einheit + */ + public static String addMinuten(String min){ + return min + " " +ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "einheiten", "zeit"); + } + + /** + * Fügt am ende .json hinzu. Sofern es nicht schon dort ist + * @param filename Filename ohne .json am ende + * @return Der Filename mit .json am ende- + */ + public static String addJson(String filename){ + if(!filename.contains(".json")){ + filename += ".json"; + } + return filename; + } +} diff --git a/src/tourplaner/business/Exporter.java b/src/tourplaner/business/Exporter.java index c5b9059..4a3888c 100644 --- a/src/tourplaner/business/Exporter.java +++ b/src/tourplaner/business/Exporter.java @@ -34,8 +34,9 @@ public class Exporter { ProgressBar progressBar = new ProgressBar("Export..."); int step = progressBar.getProgressSize(4, 100); ArrayList data = new DbConnect().getAllTouren(); + progressBar.addProgress(step); - FileWriter fileWriter = new FileWriter(path + ".json"); + FileWriter fileWriter = new FileWriter(EinheitenAdder.addJson(this.path)); progressBar.addProgress(step); JsonHelper.getJsonFromObj(data, fileWriter); progressBar.addProgress(step); @@ -51,7 +52,7 @@ public class Exporter { public void doImport() { ProgressBar progressBar = new ProgressBar("Import..."); try { - this.touren = JsonHelper.getTourenFromJson(new FileReader(this.path)); + this.touren = JsonHelper.getTourenFromJson(new FileReader(EinheitenAdder.addJson(this.path))); DbConnect dbConnect = new DbConnect(); dbConnect.delAllData(); progressBar.addProgress(5); diff --git a/src/tourplaner/business/Reporter.java b/src/tourplaner/business/Reporter.java index 8f55552..8091604 100644 --- a/src/tourplaner/business/Reporter.java +++ b/src/tourplaner/business/Reporter.java @@ -3,12 +3,9 @@ package tourplaner.business; import com.itextpdf.text.*; import com.itextpdf.text.Font; import com.itextpdf.text.Image; -import tourplaner.data.DbConnect; import tourplaner.object.Log; import tourplaner.object.Tour; -import com.itextpdf.text.pdf.PdfPCell; -import com.itextpdf.text.pdf.PdfPTable; import com.itextpdf.text.pdf.PdfWriter; import java.awt.*; @@ -78,17 +75,17 @@ public class Reporter { strecke += log.getStrecke(); } } - Anchor anchor = new Anchor("Zusammengefasster Report", catFont); - anchor.setName("Zusammengefasster Report"); + Anchor anchor = new Anchor(ConfigHelper.getLangIniString("rsummrepo"), catFont); + anchor.setName(ConfigHelper.getLangIniString("rsummrepo")); // Second parameter is the number of the chapter Chapter catPart = new Chapter(new Paragraph(anchor), 1); - Paragraph subPara = new Paragraph("Daten", subFont); + Paragraph subPara = new Paragraph(ConfigHelper.getLangIniString("rdaten"), subFont); Section subCatPart = catPart.addSection(subPara); - subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("reportvon") + System.getProperty("user.name") + ", " + new Date())); - subCatPart.add(new Paragraph("Gesammte Zeit aller Logs: " + dauer)); - subCatPart.add(new Paragraph("gesammte Strecke aller Logs: " + strecke)); - subCatPart.add(new Paragraph("Berechnete Zeit aller Logs: " + calDauer)); - subCatPart.add(new Paragraph("Berechnete Strecke aller Touren: " + calStecke)); + subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("reportvon") + " " + System.getProperty("user.name") + ", " + new Date())); + subCatPart.add(new Paragraph(EinheitenAdder.addMinuten(ConfigHelper.getLangIniString("rzeitallerlogs") + " " + dauer))); + subCatPart.add(new Paragraph(EinheitenAdder.addKm(ConfigHelper.getLangIniString("rstreckeallerlogs") + " " + strecke))); + subCatPart.add(new Paragraph(EinheitenAdder.addMinuten(ConfigHelper.getLangIniString("rcalzeitallerlogs") + " " + calDauer))); + subCatPart.add(new Paragraph(EinheitenAdder.addKm(ConfigHelper.getLangIniString("calstreckeallerloggs") + " " + calStecke))); document.add(catPart); } @@ -120,7 +117,7 @@ public class Reporter { // Reader // under File -> Properties private static void addMetaData(Document document, Tour tour) { - document.addTitle(ConfigHelper.getLangIniString("tourreportvon") + tour.getName()); + document.addTitle(ConfigHelper.getLangIniString("tourreportvon") + " " + tour.getName()); document.addSubject(ConfigHelper.getLangIniString("tourplanervon")); document.addKeywords(ConfigHelper.getLangIniString("reportkeywords")); document.addAuthor(ConfigHelper.getLangIniString("tourplaner")); @@ -142,11 +139,11 @@ public class Reporter { Paragraph subPara = new Paragraph(ConfigHelper.getLangIniString("tour"), subFont); Section subCatPart = catPart.addSection(subPara); - subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("reportvon") + System.getProperty("user.name") + ", " + new Date())); - subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("reportstart") + tour.getStart())); - subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("reportziel") + tour.getZiel())); - subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("reportdauercal") + tour.getDauer())); - subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("reportstreckecal") + tour.getStrecke())); + subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("reportvon") + " " + System.getProperty("user.name") + ", " + new Date())); + subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("reportstart") + " " + tour.getStart())); + subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("reportziel") + " " + tour.getZiel())); + subCatPart.add(new Paragraph(EinheitenAdder.addMinuten(ConfigHelper.getLangIniString("reportdauercal") + " " + tour.getDauer()))); + subCatPart.add(new Paragraph(EinheitenAdder.addKm(ConfigHelper.getLangIniString("reportstreckecal") + " " + tour.getStrecke()))); Paragraph emptyLine = new Paragraph(); addEmptyLine(emptyLine, 5); subCatPart.add(emptyLine); @@ -168,18 +165,18 @@ public class Reporter { anchor = new Anchor(ConfigHelper.getLangIniString("logs"), catFont); anchor.setName(ConfigHelper.getLangIniString("logs")); catPart = new Chapter(new Paragraph(anchor), 2); - catPart.add(new Paragraph(ConfigHelper.getLangIniString("countlog") + logs.size())); + catPart.add(new Paragraph(ConfigHelper.getLangIniString("countlog") + " " + logs.size())); for (Log log: logs) { - subPara = new Paragraph(ConfigHelper.getLangIniString("logvom") + log.getDatum() , subFont); + subPara = new Paragraph(ConfigHelper.getLangIniString("logvom") + " " + log.getDatum() , subFont); subCatPart = catPart.addSection(subPara); - subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("logdauer") + log.getDauer())); - subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("logpause") + log.getPause())); - subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("loggegangen") + log.getGegangen())); - subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("logavg")+ log.getAvgspeed())); - subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("logstrecke") + log.getStrecke())); - subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("loghight") + log.getHightmeter())); - subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("logbemerkung") + log.getBemerkung())); + subCatPart.add(new Paragraph(EinheitenAdder.addMinuten(ConfigHelper.getLangIniString("logdauer") + " " + log.getDauer()))); + subCatPart.add(new Paragraph(EinheitenAdder.addMinuten(ConfigHelper.getLangIniString("logpause") + " " + log.getPause()))); + subCatPart.add(new Paragraph(EinheitenAdder.addMinuten(ConfigHelper.getLangIniString("loggegangen") + " " + log.getGegangen()))); + subCatPart.add(new Paragraph(EinheitenAdder.addSpeed(ConfigHelper.getLangIniString("logavg") + " " + log.getAvgspeed()))); + subCatPart.add(new Paragraph(EinheitenAdder.addKm(ConfigHelper.getLangIniString("logstrecke") + " " + log.getStrecke()))); + subCatPart.add(new Paragraph(EinheitenAdder.addMeter(ConfigHelper.getLangIniString("loghight") + " " + log.getHightmeter()))); + subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("logbemerkung") + " " + log.getBemerkung())); } // now add all this to the document document.add(catPart); diff --git a/src/tourplaner/object/Log.java b/src/tourplaner/object/Log.java index f9e1b70..d499822 100644 --- a/src/tourplaner/object/Log.java +++ b/src/tourplaner/object/Log.java @@ -20,6 +20,9 @@ public class Log { this.pause = pause; this.gegangen = this.dauer - this.pause; this.avgspeed = this.strecke / (this.gegangen); + if(Double.isInfinite(this.avgspeed)){ + this.avgspeed = -1; + } } public String getBemerkung() { diff --git a/src/tourplaner/tourplaner.fxml b/src/tourplaner/tourplaner.fxml index 7ec6177..c10f043 100644 --- a/src/tourplaner/tourplaner.fxml +++ b/src/tourplaner/tourplaner.fxml @@ -133,9 +133,9 @@ - - - + + + @@ -185,14 +185,14 @@ - - - - - - - - + + + + + + + + @@ -210,7 +210,7 @@ - diff --git a/src/tourplaner/ui/AlertHelper.java b/src/tourplaner/ui/AlertHelper.java index 5282239..34b8ca6 100644 --- a/src/tourplaner/ui/AlertHelper.java +++ b/src/tourplaner/ui/AlertHelper.java @@ -10,6 +10,7 @@ import javafx.scene.layout.*; import javafx.stage.Stage; import javafx.stage.WindowEvent; import tourplaner.business.ConfigHelper; +import tourplaner.business.EinheitenAdder; import javax.swing.*; import javax.swing.border.TitledBorder; diff --git a/src/tourplaner/ui/TourplanerController.java b/src/tourplaner/ui/TourplanerController.java index a49a401..28b4c5c 100644 --- a/src/tourplaner/ui/TourplanerController.java +++ b/src/tourplaner/ui/TourplanerController.java @@ -160,10 +160,10 @@ public class TourplanerController implements Initializable { this.viewModel.setSucheAktiv(false); progressBar.addProgress(10); syncTourNamen(); - progressBar.addProgress(40); + progressBar.setProgress(100); this.sucheInput.setText(""); } - progressBar.addProgress(50); + progressBar.setProgress(100); } /** @@ -302,6 +302,7 @@ public class TourplanerController implements Initializable { this.reportsummary.setText(ConfigHelper.getLangIniString("freposum")); this.tourreport.setText(ConfigHelper.getLangIniString("frepotour")); this.beendenButton.setText(ConfigHelper.getLangIniString("fbeenden")); + this.sucheInput.setPromptText(ConfigHelper.getLangIniString("fsuche")+ConfigHelper.getLangIniString("fpunkte")); } @FXML diff --git a/src/tourplaner/viewmodels/ViewModel.java b/src/tourplaner/viewmodels/ViewModel.java index fbbe993..0c09b77 100644 --- a/src/tourplaner/viewmodels/ViewModel.java +++ b/src/tourplaner/viewmodels/ViewModel.java @@ -417,8 +417,8 @@ public class ViewModel { } public ObservableList getLogData() { - logData.removeAll(); - if(this.selectedLog != null) logData.addAll(TourPlaner.getLogs(this.selectedTour.getName())); + logData.removeIf(s -> true); + if(this.selectedTour != null) logData.addAll(TourPlaner.getLogs(this.selectedTour.getName())); return logData; }