Sprachfile erweitert + Exporter begonnen
This commit is contained in:
parent
93cb83e33e
commit
ae93f365d5
22
langde.ini
22
langde.ini
@ -39,4 +39,24 @@ pausemsg = Dauer der Pause
|
||||
hightmeter = Höhenmeter
|
||||
hightmetermsg = Höhenmeter des Abschnitts
|
||||
bemerkung = Bemerkung
|
||||
bemerkungheader = Bitte geben Sie die Bemerkungen zu diesem Log eintrag ein, kann auch leer bleiben.
|
||||
bemerkungheader = Bitte geben Sie die Bemerkungen zu diesem Log eintrag ein, kann auch leer bleiben.
|
||||
tourreportvon = Tour Report von ->
|
||||
tourplanervon = Tourplaner by DerGeorg
|
||||
reportkeywords = Tourplaner, Tour, Report
|
||||
tourplaner = Tourplaner"
|
||||
tour = Tour
|
||||
reportvon = Report erstellt von:
|
||||
reportstart = Startpunkt der Tour:
|
||||
reportziel = Zielpunkt der Tour:
|
||||
reportdauercal = Berechnete Dauer der Tour:
|
||||
reportstreckecal = Berechnete Strecke der Tour:
|
||||
logs = Logs
|
||||
countlog = Anzahl der Logeinträge:
|
||||
logvom = Log vom:
|
||||
logdauer = Dauer:
|
||||
logpause = Davon Pause:
|
||||
loggegangen = Davon gegangen:
|
||||
logavg = Berechnete Durchschnittliche Geschwindigkeit:
|
||||
logstrecke = Entfernung:
|
||||
loghight = Höhenmeter:
|
||||
logbemerkung = Bemerkung:
|
@ -1,14 +1,13 @@
|
||||
package tourplaner.business;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.RenderedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Zuständig für das besorgen der Map für die UI und PDF-Reports und für die Berechneten infos der Tour (Dauer, Strecke)
|
||||
*/
|
||||
public class DirectionMap {
|
||||
|
||||
private double dauer, strecke;
|
||||
private String start, end, tourname, file, filepdf;
|
||||
private Image map, mappdf;
|
||||
@ -35,10 +34,18 @@ public class DirectionMap {
|
||||
FileHelper.openDefault(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get berechnete Dauer in Minuten
|
||||
* @return Berechnete Dauer der Tour
|
||||
*/
|
||||
public double getDauer() {
|
||||
return dauer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get berechnete Strecke
|
||||
* @return Berechnete Strecke der Tour
|
||||
*/
|
||||
public double getStrecke() {
|
||||
return strecke;
|
||||
}
|
||||
@ -54,12 +61,23 @@ public class DirectionMap {
|
||||
return HttpHelper.httpGetImage("https://www.mapquestapi.com/staticmap/v5/map?start="+start+"&end="+ende+"&size="+size+"&key="+ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "map", "key"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Besorgt die Infos der Tour von Mapquest Directions
|
||||
* @param start Start der Tour
|
||||
* @param ende Ende der Tour
|
||||
* @throws IOException Fehler beim besorgen der infos über die Tour
|
||||
*/
|
||||
private void getDirections(String start, String ende) throws IOException {
|
||||
String json = HttpHelper.httpGetJsonString("https://www.mapquestapi.com/directions/v2/route?key="+ ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "map", "key")+"&from="+start+"&to="+ende+"&outFormat=json&ambiguities=ignore&routeType=fastest&doReverseGeocode=false&enhancedNarrative=false&avoidTimedConditions=false");
|
||||
this.strecke = JsonHelper.getDoubleFromJson(json, "distance");
|
||||
this.dauer = formatetTimeToMinutes(JsonHelper.getStingFromJson(json, "formattedTime"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Formatet time HH:MM:SS in Minuten umwandeln
|
||||
* @param formatetTime Formatet time HH:MM:SS
|
||||
* @return Zeit in Minuten
|
||||
*/
|
||||
private double formatetTimeToMinutes(String formatetTime){
|
||||
double minutes = 0;
|
||||
String[] result = formatetTime.split(":");
|
||||
|
2
src/tourplaner/business/Exporter.java
Normal file
2
src/tourplaner/business/Exporter.java
Normal file
@ -0,0 +1,2 @@
|
||||
package tourplaner.business;public class Exporter {
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
package tourplaner.business;
|
||||
|
||||
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
@ -24,37 +22,32 @@ public class HttpHelper {
|
||||
return ImageIO.read(urls);
|
||||
}
|
||||
|
||||
/**
|
||||
* Http GET Json string vom Url string
|
||||
* @param url Url als String
|
||||
* @return Json als String
|
||||
* @throws IOException Fehler beim Json holen
|
||||
*/
|
||||
public static String httpGetJsonString(String url) throws IOException {
|
||||
HttpURLConnection con = null;
|
||||
try {
|
||||
|
||||
var myurl = new URL(url);
|
||||
con = (HttpURLConnection) myurl.openConnection();
|
||||
|
||||
con.setRequestMethod("GET");
|
||||
|
||||
StringBuilder content;
|
||||
|
||||
try (BufferedReader in = new BufferedReader(
|
||||
new InputStreamReader(con.getInputStream()))) {
|
||||
|
||||
String line;
|
||||
content = new StringBuilder();
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
|
||||
content.append(line);
|
||||
content.append(System.lineSeparator());
|
||||
}
|
||||
}
|
||||
|
||||
return content.toString();
|
||||
} finally {
|
||||
|
||||
assert con != null;
|
||||
con.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,19 +1,38 @@
|
||||
package tourplaner.business;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
/**
|
||||
* Hilfsklasse für Json (Gson)
|
||||
*/
|
||||
public class JsonHelper {
|
||||
|
||||
/**
|
||||
* String aus json extrahieren
|
||||
* @param json Json als String
|
||||
* @param gets Eintrag im Json unter "route"
|
||||
* @return Gesammelter String
|
||||
*/
|
||||
public static String getStingFromJson(String json, String gets){
|
||||
return getJObj(json).get("route").getAsJsonObject().get(gets).getAsString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Double aus json extrahieren
|
||||
* @param json Json als String
|
||||
* @param gets Eintrag im Json unter "route"
|
||||
* @return Gesammelter Double Wert
|
||||
*/
|
||||
public static double getDoubleFromJson(String json, String gets){
|
||||
return getJObj(json).get("route").getAsJsonObject().get(gets).getAsDouble();
|
||||
}
|
||||
|
||||
/**
|
||||
* Json String to JsonObject
|
||||
* @param json Json string
|
||||
* @return Neues JsonObject aus String
|
||||
*/
|
||||
private static JsonObject getJObj(String json){
|
||||
return new Gson().fromJson(json, JsonObject.class);
|
||||
}
|
||||
|
@ -3,17 +3,14 @@ package tourplaner.business;
|
||||
import com.itextpdf.text.*;
|
||||
import com.itextpdf.text.Font;
|
||||
import com.itextpdf.text.Image;
|
||||
import com.sun.scenario.effect.ImageData;
|
||||
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.*;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
@ -21,6 +18,11 @@ import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* PDF Report generierung mit iText
|
||||
*
|
||||
* Erstellt Reports über einzelne Touren und fasst alle Touren zusammen
|
||||
*
|
||||
* iText 4 ist gratis verfügbar, siehe:
|
||||
* https://github.com/ymasory/iText-4.2.0
|
||||
*/
|
||||
public class Reporter {
|
||||
@ -34,6 +36,10 @@ public class Reporter {
|
||||
private static Font smallBold = new Font(Font.TIMES_ROMAN, 12,
|
||||
Font.BOLD);
|
||||
|
||||
/**
|
||||
* Erstellt einen Tour Report
|
||||
* @param tourname Name der Tour die Gereportet werden soll
|
||||
*/
|
||||
public static void createTourReport(String tourname) {
|
||||
Tour tour = TourPlaner.getTour(tourname);
|
||||
tour.setLog(TourPlaner.getLogs(tourname));
|
||||
@ -56,32 +62,36 @@ public class Reporter {
|
||||
// Reader
|
||||
// under File -> Properties
|
||||
private static void addMetaData(Document document, Tour tour) {
|
||||
document.addTitle("Tour Report -> " + tour.getName());
|
||||
document.addSubject("Tourplaner by DerGeorg");
|
||||
document.addKeywords("Tourplaner, Tour, Report");
|
||||
document.addAuthor("Tourplaner");
|
||||
document.addCreator("Tourplaner");
|
||||
document.addTitle(ConfigHelper.getLangIniString("tourreportvon") + tour.getName());
|
||||
document.addSubject(ConfigHelper.getLangIniString("tourplanervon"));
|
||||
document.addKeywords(ConfigHelper.getLangIniString("reportkeywords"));
|
||||
document.addAuthor(ConfigHelper.getLangIniString("tourplaner"));
|
||||
document.addCreator(ConfigHelper.getLangIniString("tourplaner"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Erstellt den inhalt des Reports
|
||||
* @param document Aktuelles Dokument
|
||||
* @param tour Aktuelle Tour
|
||||
* @throws DocumentException Fehler beim hinzufügen des Inhaltes
|
||||
*/
|
||||
private static void addContent(Document document, Tour tour) throws DocumentException {
|
||||
Anchor anchor = new Anchor("Tour Report von -> " + tour.getName(), catFont);
|
||||
anchor.setName("Tour Report von -> " + tour.getName());
|
||||
Anchor anchor = new Anchor(ConfigHelper.getLangIniString("tourreportvon") + tour.getName(), catFont);
|
||||
anchor.setName(ConfigHelper.getLangIniString("tourreportvon") + tour.getName());
|
||||
|
||||
// Second parameter is the number of the chapter
|
||||
Chapter catPart = new Chapter(new Paragraph(anchor), 1);
|
||||
|
||||
Paragraph subPara = new Paragraph("Tour", subFont);
|
||||
Paragraph subPara = new Paragraph(ConfigHelper.getLangIniString("tour"), subFont);
|
||||
Section subCatPart = catPart.addSection(subPara);
|
||||
subCatPart.add(new Paragraph("Report erstellt von: " + System.getProperty("user.name") + ", " + new Date()));
|
||||
subCatPart.add(new Paragraph("Startpunkt der Tour: " + tour.getStart()));
|
||||
subCatPart.add(new Paragraph("Zielpunkt der Tour: " + tour.getZiel()));
|
||||
subCatPart.add(new Paragraph("Berechnete Dauer der Tour: " + tour.getDauer()));
|
||||
subCatPart.add(new Paragraph("Berechnete Strecke der Tour: " + 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(ConfigHelper.getLangIniString("reportdauercal") + tour.getDauer()));
|
||||
subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("reportstreckecal") + tour.getStrecke()));
|
||||
Paragraph emptyLine = new Paragraph();
|
||||
addEmptyLine(emptyLine, 5);
|
||||
subCatPart.add(emptyLine);
|
||||
|
||||
|
||||
// now add all this to the document
|
||||
document.add(catPart);
|
||||
|
||||
@ -97,127 +107,83 @@ public class Reporter {
|
||||
}
|
||||
ArrayList<Log> logs = tour.getLogs();
|
||||
// Second parameter is the number of the chapter
|
||||
anchor = new Anchor("Logs", catFont);
|
||||
anchor.setName("Logs");
|
||||
anchor = new Anchor(ConfigHelper.getLangIniString("logs"), catFont);
|
||||
anchor.setName(ConfigHelper.getLangIniString("logs"));
|
||||
catPart = new Chapter(new Paragraph(anchor), 2);
|
||||
catPart.add(new Paragraph("Anzahl der Logeinträge: " + logs.size()));
|
||||
catPart.add(new Paragraph(ConfigHelper.getLangIniString("countlog") + logs.size()));
|
||||
|
||||
for (Log log: logs) {
|
||||
subPara = new Paragraph("Log vom: " + log.getDatum() , subFont);
|
||||
subPara = new Paragraph(ConfigHelper.getLangIniString("logvom") + log.getDatum() , subFont);
|
||||
subCatPart = catPart.addSection(subPara);
|
||||
subCatPart.add(new Paragraph("Dauer: " + log.getDauer()));
|
||||
subCatPart.add(new Paragraph("Davon Pause: " + log.getPause()));
|
||||
subCatPart.add(new Paragraph("Davon gegangen: " + log.getGegangen()));
|
||||
subCatPart.add(new Paragraph("Berechnete Durchschnittliche Geschwindigkeit: " + log.getAvgspeed()));
|
||||
subCatPart.add(new Paragraph("Entfernung: " + log.getStrecke()));
|
||||
subCatPart.add(new Paragraph("Höhenmeter: " + log.getHightmeter()));
|
||||
subCatPart.add(new Paragraph("Bemerkung: " + log.getBemerkung()));
|
||||
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()));
|
||||
}
|
||||
// now add all this to the document
|
||||
document.add(catPart);
|
||||
}
|
||||
|
||||
private static void createTable(Section subCatPart)
|
||||
throws BadElementException {
|
||||
PdfPTable table = new PdfPTable(5);
|
||||
|
||||
// t.setBorderColor(BaseColor.GRAY);
|
||||
// t.setPadding(4);
|
||||
// t.setSpacing(4);
|
||||
// t.setBorderWidth(1);
|
||||
|
||||
PdfPCell c1 = new PdfPCell(new Phrase("NR"));
|
||||
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
|
||||
table.addCell(c1);
|
||||
|
||||
c1 = new PdfPCell(new Phrase("Datum"));
|
||||
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
|
||||
table.addCell(c1);
|
||||
|
||||
c1 = new PdfPCell(new Phrase("Entfernung"));
|
||||
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
|
||||
table.addCell(c1);
|
||||
|
||||
c1 = new PdfPCell(new Phrase("Höhenmeter"));
|
||||
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
|
||||
table.addCell(c1);
|
||||
|
||||
c1 = new PdfPCell(new Phrase("AVG Geschwindigkeit"));
|
||||
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
|
||||
table.addCell(c1);
|
||||
|
||||
|
||||
table.setHeaderRows(1);
|
||||
|
||||
table.addCell("1.0");
|
||||
table.addCell("1.1");
|
||||
table.addCell("1.2");
|
||||
table.addCell("1.3");
|
||||
table.addCell("1.4");
|
||||
table.addCell("1.5");
|
||||
|
||||
table.addCell("2.0");
|
||||
table.addCell("2.1");
|
||||
table.addCell("2.2");
|
||||
table.addCell("2.3");
|
||||
table.addCell("2.4");
|
||||
table.addCell("2.5");
|
||||
|
||||
subCatPart.add(table);
|
||||
|
||||
}
|
||||
private static void createTable2(Section subCatPart)
|
||||
throws BadElementException {
|
||||
PdfPTable table = new PdfPTable(5);
|
||||
|
||||
// t.setBorderColor(BaseColor.GRAY);
|
||||
// t.setPadding(4);
|
||||
// t.setSpacing(4);
|
||||
// t.setBorderWidth(1);
|
||||
|
||||
PdfPCell c1 = new PdfPCell(new Phrase("NR"));
|
||||
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
|
||||
table.addCell(c1);
|
||||
|
||||
c1 = new PdfPCell(new Phrase("Dauer"));
|
||||
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
|
||||
table.addCell(c1);
|
||||
|
||||
c1 = new PdfPCell(new Phrase("Davon Gegangen"));
|
||||
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
|
||||
table.addCell(c1);
|
||||
|
||||
c1 = new PdfPCell(new Phrase("Davon Pause"));
|
||||
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
|
||||
table.addCell(c1);
|
||||
|
||||
c1 = new PdfPCell(new Phrase("Bemerkung"));
|
||||
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
|
||||
table.addCell(c1);
|
||||
|
||||
|
||||
table.setHeaderRows(1);
|
||||
|
||||
table.addCell("1.0");
|
||||
table.addCell("1.1");
|
||||
table.addCell("1.2");
|
||||
table.addCell("1.3");
|
||||
table.addCell("1.4");
|
||||
table.addCell("1.5");
|
||||
|
||||
table.addCell("2.0");
|
||||
table.addCell("2.1");
|
||||
table.addCell("2.2");
|
||||
table.addCell("2.3");
|
||||
table.addCell("2.4");
|
||||
table.addCell("2.5");
|
||||
|
||||
subCatPart.add(table);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fügt eine leere zeile an den Paragraph an
|
||||
* @param paragraph Hier wird hinzugefügt
|
||||
* @param number Um wie viele Leere Zeilen hinzugefügt werden soll
|
||||
*/
|
||||
private static void addEmptyLine(Paragraph paragraph, int number) {
|
||||
for (int i = 0; i < number; i++) {
|
||||
paragraph.add(new Paragraph(" "));
|
||||
}
|
||||
}
|
||||
// private static void createTable(Section subCatPart)
|
||||
// throws BadElementException {
|
||||
// PdfPTable table = new PdfPTable(5);
|
||||
//
|
||||
// // t.setBorderColor(BaseColor.GRAY);
|
||||
// // t.setPadding(4);
|
||||
// // t.setSpacing(4);
|
||||
// // t.setBorderWidth(1);
|
||||
//
|
||||
// PdfPCell c1 = new PdfPCell(new Phrase("NR"));
|
||||
// c1.setHorizontalAlignment(Element.ALIGN_CENTER);
|
||||
// table.addCell(c1);
|
||||
//
|
||||
// c1 = new PdfPCell(new Phrase("Datum"));
|
||||
// c1.setHorizontalAlignment(Element.ALIGN_CENTER);
|
||||
// table.addCell(c1);
|
||||
//
|
||||
// c1 = new PdfPCell(new Phrase("Entfernung"));
|
||||
// c1.setHorizontalAlignment(Element.ALIGN_CENTER);
|
||||
// table.addCell(c1);
|
||||
//
|
||||
// c1 = new PdfPCell(new Phrase("Höhenmeter"));
|
||||
// c1.setHorizontalAlignment(Element.ALIGN_CENTER);
|
||||
// table.addCell(c1);
|
||||
//
|
||||
// c1 = new PdfPCell(new Phrase("AVG Geschwindigkeit"));
|
||||
// c1.setHorizontalAlignment(Element.ALIGN_CENTER);
|
||||
// table.addCell(c1);
|
||||
//
|
||||
//
|
||||
// table.setHeaderRows(1);
|
||||
//
|
||||
// table.addCell("1.0");
|
||||
// table.addCell("1.1");
|
||||
// table.addCell("1.2");
|
||||
// table.addCell("1.3");
|
||||
// table.addCell("1.4");
|
||||
// table.addCell("1.5");
|
||||
//
|
||||
// table.addCell("2.0");
|
||||
// table.addCell("2.1");
|
||||
// table.addCell("2.2");
|
||||
// table.addCell("2.3");
|
||||
// table.addCell("2.4");
|
||||
// table.addCell("2.5");
|
||||
//
|
||||
// subCatPart.add(table);
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
2
src/tourplaner/object/Data.java
Normal file
2
src/tourplaner/object/Data.java
Normal file
@ -0,0 +1,2 @@
|
||||
package tourplaner.object;public class Data {
|
||||
}
|
@ -481,7 +481,6 @@ public class ViewModel {
|
||||
|
||||
public ObservableList<Tour> getTourData() {
|
||||
tourData.removeAll();
|
||||
// ObservableList<Tour> data = ;
|
||||
tourData.addAll(TourPlaner.getAllTours());
|
||||
return tourData;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user