Einheiten hinzugefügt + Weitere Übersetzungen + Fileinput .json bugfix + exporter " " hinzugefügt

This commit is contained in:
Georg Reisinger 2021-04-17 23:55:25 +02:00
parent 9d010d452c
commit d872a39394
11 changed files with 122 additions and 47 deletions

View File

@ -10,6 +10,12 @@ lang = langde
openpdf = 1 openpdf = 1
openmap = 0 openmap = 0
[einheiten]
zeit = min
strecke = km
meter = m
speed = km/h
[db] [db]
dbname = tourplaner dbname = tourplaner
url = url =

View File

@ -94,3 +94,11 @@ fhilfe = Hilfe
freposum = Erstelle Report über alle Touren freposum = Erstelle Report über alle Touren
frepotour = Erstelle Report über aktuelle Tour frepotour = Erstelle Report über aktuelle Tour
fbeenden = Beenden 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

View File

@ -95,3 +95,11 @@ fhilfe = Help
freposum = Generate summarize-report freposum = Generate summarize-report
frepotour = Generate tour-report frepotour = Generate tour-report
fbeenden = Quit 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

View File

@ -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;
}
}

View File

@ -34,8 +34,9 @@ public class Exporter {
ProgressBar progressBar = new ProgressBar("Export..."); ProgressBar progressBar = new ProgressBar("Export...");
int step = progressBar.getProgressSize(4, 100); int step = progressBar.getProgressSize(4, 100);
ArrayList<Tour> data = new DbConnect().getAllTouren(); ArrayList<Tour> data = new DbConnect().getAllTouren();
progressBar.addProgress(step); progressBar.addProgress(step);
FileWriter fileWriter = new FileWriter(path + ".json"); FileWriter fileWriter = new FileWriter(EinheitenAdder.addJson(this.path));
progressBar.addProgress(step); progressBar.addProgress(step);
JsonHelper.getJsonFromObj(data, fileWriter); JsonHelper.getJsonFromObj(data, fileWriter);
progressBar.addProgress(step); progressBar.addProgress(step);
@ -51,7 +52,7 @@ public class Exporter {
public void doImport() { public void doImport() {
ProgressBar progressBar = new ProgressBar("Import..."); ProgressBar progressBar = new ProgressBar("Import...");
try { try {
this.touren = JsonHelper.getTourenFromJson(new FileReader(this.path)); this.touren = JsonHelper.getTourenFromJson(new FileReader(EinheitenAdder.addJson(this.path)));
DbConnect dbConnect = new DbConnect(); DbConnect dbConnect = new DbConnect();
dbConnect.delAllData(); dbConnect.delAllData();
progressBar.addProgress(5); progressBar.addProgress(5);

View File

@ -3,12 +3,9 @@ package tourplaner.business;
import com.itextpdf.text.*; import com.itextpdf.text.*;
import com.itextpdf.text.Font; import com.itextpdf.text.Font;
import com.itextpdf.text.Image; import com.itextpdf.text.Image;
import tourplaner.data.DbConnect;
import tourplaner.object.Log; import tourplaner.object.Log;
import tourplaner.object.Tour; import tourplaner.object.Tour;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter; import com.itextpdf.text.pdf.PdfWriter;
import java.awt.*; import java.awt.*;
@ -78,17 +75,17 @@ public class Reporter {
strecke += log.getStrecke(); strecke += log.getStrecke();
} }
} }
Anchor anchor = new Anchor("Zusammengefasster Report", catFont); Anchor anchor = new Anchor(ConfigHelper.getLangIniString("rsummrepo"), catFont);
anchor.setName("Zusammengefasster Report"); anchor.setName(ConfigHelper.getLangIniString("rsummrepo"));
// Second parameter is the number of the chapter // Second parameter is the number of the chapter
Chapter catPart = new Chapter(new Paragraph(anchor), 1); 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); Section subCatPart = catPart.addSection(subPara);
subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("reportvon") + System.getProperty("user.name") + ", " + new Date())); 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(EinheitenAdder.addMinuten(ConfigHelper.getLangIniString("rzeitallerlogs") + " " + dauer)));
subCatPart.add(new Paragraph("gesammte Strecke aller Logs: " + strecke)); subCatPart.add(new Paragraph(EinheitenAdder.addKm(ConfigHelper.getLangIniString("rstreckeallerlogs") + " " + strecke)));
subCatPart.add(new Paragraph("Berechnete Zeit aller Logs: " + calDauer)); subCatPart.add(new Paragraph(EinheitenAdder.addMinuten(ConfigHelper.getLangIniString("rcalzeitallerlogs") + " " + calDauer)));
subCatPart.add(new Paragraph("Berechnete Strecke aller Touren: " + calStecke)); subCatPart.add(new Paragraph(EinheitenAdder.addKm(ConfigHelper.getLangIniString("calstreckeallerloggs") + " " + calStecke)));
document.add(catPart); document.add(catPart);
} }
@ -120,7 +117,7 @@ public class Reporter {
// Reader // Reader
// under File -> Properties // under File -> Properties
private static void addMetaData(Document document, Tour tour) { 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.addSubject(ConfigHelper.getLangIniString("tourplanervon"));
document.addKeywords(ConfigHelper.getLangIniString("reportkeywords")); document.addKeywords(ConfigHelper.getLangIniString("reportkeywords"));
document.addAuthor(ConfigHelper.getLangIniString("tourplaner")); document.addAuthor(ConfigHelper.getLangIniString("tourplaner"));
@ -142,11 +139,11 @@ public class Reporter {
Paragraph subPara = new Paragraph(ConfigHelper.getLangIniString("tour"), subFont); Paragraph subPara = new Paragraph(ConfigHelper.getLangIniString("tour"), subFont);
Section subCatPart = catPart.addSection(subPara); Section subCatPart = catPart.addSection(subPara);
subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("reportvon") + System.getProperty("user.name") + ", " + new Date())); 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("reportstart") + " " + tour.getStart()));
subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("reportziel") + tour.getZiel())); subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("reportziel") + " " + tour.getZiel()));
subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("reportdauercal") + tour.getDauer())); subCatPart.add(new Paragraph(EinheitenAdder.addMinuten(ConfigHelper.getLangIniString("reportdauercal") + " " + tour.getDauer())));
subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("reportstreckecal") + tour.getStrecke())); subCatPart.add(new Paragraph(EinheitenAdder.addKm(ConfigHelper.getLangIniString("reportstreckecal") + " " + tour.getStrecke())));
Paragraph emptyLine = new Paragraph(); Paragraph emptyLine = new Paragraph();
addEmptyLine(emptyLine, 5); addEmptyLine(emptyLine, 5);
subCatPart.add(emptyLine); subCatPart.add(emptyLine);
@ -168,18 +165,18 @@ public class Reporter {
anchor = new Anchor(ConfigHelper.getLangIniString("logs"), catFont); anchor = new Anchor(ConfigHelper.getLangIniString("logs"), catFont);
anchor.setName(ConfigHelper.getLangIniString("logs")); anchor.setName(ConfigHelper.getLangIniString("logs"));
catPart = new Chapter(new Paragraph(anchor), 2); 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) { 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 = catPart.addSection(subPara);
subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("logdauer") + log.getDauer())); subCatPart.add(new Paragraph(EinheitenAdder.addMinuten(ConfigHelper.getLangIniString("logdauer") + " " + log.getDauer())));
subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("logpause") + log.getPause())); subCatPart.add(new Paragraph(EinheitenAdder.addMinuten(ConfigHelper.getLangIniString("logpause") + " " + log.getPause())));
subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("loggegangen") + log.getGegangen())); subCatPart.add(new Paragraph(EinheitenAdder.addMinuten(ConfigHelper.getLangIniString("loggegangen") + " " + log.getGegangen())));
subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("logavg")+ log.getAvgspeed())); subCatPart.add(new Paragraph(EinheitenAdder.addSpeed(ConfigHelper.getLangIniString("logavg") + " " + log.getAvgspeed())));
subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("logstrecke") + log.getStrecke())); subCatPart.add(new Paragraph(EinheitenAdder.addKm(ConfigHelper.getLangIniString("logstrecke") + " " + log.getStrecke())));
subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("loghight") + log.getHightmeter())); subCatPart.add(new Paragraph(EinheitenAdder.addMeter(ConfigHelper.getLangIniString("loghight") + " " + log.getHightmeter())));
subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("logbemerkung") + log.getBemerkung())); subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("logbemerkung") + " " + log.getBemerkung()));
} }
// now add all this to the document // now add all this to the document
document.add(catPart); document.add(catPart);

View File

@ -20,6 +20,9 @@ public class Log {
this.pause = pause; this.pause = pause;
this.gegangen = this.dauer - this.pause; this.gegangen = this.dauer - this.pause;
this.avgspeed = this.strecke / (this.gegangen); this.avgspeed = this.strecke / (this.gegangen);
if(Double.isInfinite(this.avgspeed)){
this.avgspeed = -1;
}
} }
public String getBemerkung() { public String getBemerkung() {

View File

@ -133,9 +133,9 @@
<children> <children>
<TableView fx:id="beschreibungTableView" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <TableView fx:id="beschreibungTableView" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<columns> <columns>
<TableColumn fx:id="nameCol" maxWidth="1.7976931348623157E308" minWidth="70.0" prefWidth="-1.0" text="Tourname" /> <TableColumn fx:id="nameCol" minWidth="100.0" prefWidth="-1.0" text="Tourname" />
<TableColumn fx:id="dauerCol" maxWidth="1.7976931348623157E308" minWidth="40.0" prefWidth="-1.0" text="Dauer" /> <TableColumn fx:id="dauerCol" maxWidth="1.7976931348623157E308" minWidth="100.0" prefWidth="-1.0" text="Dauer" />
<TableColumn fx:id="streckeCol" maxWidth="1.7976931348623157E308" minWidth="50.0" prefWidth="-1.0" text="Strecke" /> <TableColumn fx:id="streckeCol" maxWidth="1.7976931348623157E308" minWidth="100.0" prefWidth="-1.0" text="Strecke" />
<TableColumn fx:id="startCol" maxWidth="1.7976931348623157E308" minWidth="100.0" prefWidth="-1.0" text="Startpunk" /> <TableColumn fx:id="startCol" maxWidth="1.7976931348623157E308" minWidth="100.0" prefWidth="-1.0" text="Startpunk" />
<TableColumn fx:id="zielCol" maxWidth="1.7976931348623157E308" minWidth="100.0" prefWidth="-1.0" text="Zielpunkt" /> <TableColumn fx:id="zielCol" maxWidth="1.7976931348623157E308" minWidth="100.0" prefWidth="-1.0" text="Zielpunkt" />
</columns> </columns>
@ -185,14 +185,14 @@
<children> <children>
<TableView fx:id="logTableView" onMouseClicked="#logItemSelected" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <TableView fx:id="logTableView" onMouseClicked="#logItemSelected" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<columns> <columns>
<TableColumn fx:id="logDatumCol" prefWidth="49.0" text="Datum" /> <TableColumn fx:id="logDatumCol" minWidth="-1.0" prefWidth="-1.0" text="Datum" />
<TableColumn fx:id="logDauerCol" prefWidth="126.0" text="Dauer" /> <TableColumn fx:id="logDauerCol" minWidth="-1.0" prefWidth="-1.0" text="Dauer" />
<TableColumn fx:id="logStreckeCol" prefWidth="240.0" text="Entfernung" /> <TableColumn fx:id="logStreckeCol" minWidth="-1.0" prefWidth="-1.0" text="Entfernung" />
<TableColumn fx:id="logAvgCol" prefWidth="75.0" text="AVG Geschwindigkeit" /> <TableColumn fx:id="logAvgCol" minWidth="-1.0" prefWidth="-1.0" text="AVG Geschwindigkeit" />
<TableColumn fx:id="logHightCol" prefWidth="75.0" text="Höhenmeter" /> <TableColumn fx:id="logHightCol" minWidth="-1.0" prefWidth="75.0" text="Höhenmeter" />
<TableColumn fx:id="logPauseCol" prefWidth="75.0" text="Davon Pause" /> <TableColumn fx:id="logPauseCol" minWidth="-1.0" prefWidth="-1.0" text="Davon Pause" />
<TableColumn fx:id="logGegangenCol" prefWidth="75.0" text="Davon Unterwegs" /> <TableColumn fx:id="logGegangenCol" minWidth="-1.0" prefWidth="-1.0" text="Davon Unterwegs" />
<TableColumn fx:id="logBemerkungCol" prefWidth="75.0" text="Bemerkung" /> <TableColumn fx:id="logBemerkungCol" minWidth="-1.0" prefWidth="-1.0" text="Bemerkung" />
</columns> </columns>
<columnResizePolicy> <columnResizePolicy>
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY" /> <TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
@ -210,7 +210,7 @@
</SplitPane> </SplitPane>
<HBox id="HBox" alignment="CENTER_LEFT" spacing="5.0" VBox.vgrow="NEVER"> <HBox id="HBox" alignment="CENTER_LEFT" spacing="5.0" VBox.vgrow="NEVER">
<children> <children>
<Label maxHeight="1.7976931348623157E308" maxWidth="-1.0" text="Left status" HBox.hgrow="ALWAYS"> <Label maxHeight="1.7976931348623157E308" maxWidth="-1.0" text="Tourplaner" HBox.hgrow="ALWAYS">
<font> <font>
<Font size="11.0" fx:id="x3" /> <Font size="11.0" fx:id="x3" />
</font> </font>
@ -219,7 +219,7 @@
</textFill> </textFill>
</Label> </Label>
<AnchorPane prefHeight="-1.0" prefWidth="-1.0" HBox.hgrow="ALWAYS" /> <AnchorPane prefHeight="-1.0" prefWidth="-1.0" HBox.hgrow="ALWAYS" />
<Label font="$x3" maxWidth="-1.0" text="Right status" textFill="$x4" HBox.hgrow="NEVER" /> <Label font="$x3" maxWidth="-1.0" text="Georg Reisinger" textFill="$x4" HBox.hgrow="NEVER" />
</children> </children>
<padding> <padding>
<Insets bottom="3.0" left="3.0" right="3.0" top="3.0" /> <Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />

View File

@ -10,6 +10,7 @@ import javafx.scene.layout.*;
import javafx.stage.Stage; import javafx.stage.Stage;
import javafx.stage.WindowEvent; import javafx.stage.WindowEvent;
import tourplaner.business.ConfigHelper; import tourplaner.business.ConfigHelper;
import tourplaner.business.EinheitenAdder;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.TitledBorder; import javax.swing.border.TitledBorder;

View File

@ -160,10 +160,10 @@ public class TourplanerController implements Initializable {
this.viewModel.setSucheAktiv(false); this.viewModel.setSucheAktiv(false);
progressBar.addProgress(10); progressBar.addProgress(10);
syncTourNamen(); syncTourNamen();
progressBar.addProgress(40); progressBar.setProgress(100);
this.sucheInput.setText(""); 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.reportsummary.setText(ConfigHelper.getLangIniString("freposum"));
this.tourreport.setText(ConfigHelper.getLangIniString("frepotour")); this.tourreport.setText(ConfigHelper.getLangIniString("frepotour"));
this.beendenButton.setText(ConfigHelper.getLangIniString("fbeenden")); this.beendenButton.setText(ConfigHelper.getLangIniString("fbeenden"));
this.sucheInput.setPromptText(ConfigHelper.getLangIniString("fsuche")+ConfigHelper.getLangIniString("fpunkte"));
} }
@FXML @FXML

View File

@ -417,8 +417,8 @@ public class ViewModel {
} }
public ObservableList<Log> getLogData() { public ObservableList<Log> getLogData() {
logData.removeAll(); logData.removeIf(s -> true);
if(this.selectedLog != null) logData.addAll(TourPlaner.getLogs(this.selectedTour.getName())); if(this.selectedTour != null) logData.addAll(TourPlaner.getLogs(this.selectedTour.getName()));
return logData; return logData;
} }