Compare commits
1 Commits
9fe6f34ba3
...
0.2.5
Author | SHA1 | Date | |
---|---|---|---|
dd1357ec1d |
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,5 +1,4 @@
|
|||||||
out/
|
out/
|
||||||
conf.ini
|
conf.ini
|
||||||
log/
|
log/log4j/log.out/
|
||||||
reports/
|
reports/
|
||||||
.idea/dataSources*
|
|
12
.idea/dataSources.xml
generated
Normal file
12
.idea/dataSources.xml
generated
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||||
|
<data-source source="LOCAL" name="postgres@postgres.dergeorg.at" uuid="304c5f90-6427-4696-beb2-a9a4e6b29a05">
|
||||||
|
<driver-ref>postgresql</driver-ref>
|
||||||
|
<synchronize>true</synchronize>
|
||||||
|
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
|
||||||
|
<jdbc-url>jdbc:postgresql://postgres.dergeorg.at:5432/postgres</jdbc-url>
|
||||||
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
|
</data-source>
|
||||||
|
</component>
|
||||||
|
</project>
|
9
.idea/libraries/iText_4_2_0_com_itextpdf.xml
generated
9
.idea/libraries/iText_4_2_0_com_itextpdf.xml
generated
@ -1,9 +0,0 @@
|
|||||||
<component name="libraryTable">
|
|
||||||
<library name="iText-4.2.0-com.itextpdf">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="jar://$PROJECT_DIR$/lib/iText-4.2.0-com.itextpdf.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES />
|
|
||||||
</library>
|
|
||||||
</component>
|
|
@ -10,7 +10,6 @@
|
|||||||
<orderEntry type="library" name="lib" level="project" />
|
<orderEntry type="library" name="lib" level="project" />
|
||||||
<orderEntry type="library" name="org.ini4j:ini4j:0.5.4" level="project" />
|
<orderEntry type="library" name="org.ini4j:ini4j:0.5.4" level="project" />
|
||||||
<orderEntry type="library" name="log4j:log4j:1.2.17" level="project" />
|
<orderEntry type="library" name="log4j:log4j:1.2.17" level="project" />
|
||||||
<orderEntry type="library" name="org.postgresql:postgresql:42.2.19" level="project" />
|
<orderEntry type="library" name="org.apache.pdfbox:pdfbox:1.8.9" level="project" />
|
||||||
<orderEntry type="library" name="iText-4.2.0-com.itextpdf" level="project" />
|
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
@ -19,11 +19,4 @@ path = ./reports/
|
|||||||
[hilfe]
|
[hilfe]
|
||||||
gitrepo = https://git.dergeorg.at/dergeorg/tourplaner
|
gitrepo = https://git.dergeorg.at/dergeorg/tourplaner
|
||||||
doxygendoc = https://git.dergeorg.at/dergeorg/tourplaner
|
doxygendoc = https://git.dergeorg.at/dergeorg/tourplaner
|
||||||
javadoc = https://git.dergeorg.at/dergeorg/tourplaner
|
javadoc = https://git.dergeorg.at/dergeorg/tourplaner
|
||||||
|
|
||||||
[map]
|
|
||||||
key =
|
|
||||||
size = 1500,400
|
|
||||||
sizePdf = 600,400
|
|
||||||
path = D:\\TourplanerImages\\
|
|
||||||
file_pre = file:///
|
|
Binary file not shown.
@ -8,7 +8,6 @@ import javafx.scene.image.Image;
|
|||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
import tourplaner.business.ConfigHelper;
|
import tourplaner.business.ConfigHelper;
|
||||||
import tourplaner.business.TourPlaner;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@ -24,7 +23,6 @@ public class Main extends Application {
|
|||||||
Parent root = FXMLLoader.load(Main.class.getResource("tourplaner.fxml"));
|
Parent root = FXMLLoader.load(Main.class.getResource("tourplaner.fxml"));
|
||||||
primaryStage.setTitle(ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "start", "apptitle"));
|
primaryStage.setTitle(ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "start", "apptitle"));
|
||||||
primaryStage.getIcons().add(new Image("file:"+ ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "start", "logo")));
|
primaryStage.getIcons().add(new Image("file:"+ ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "start", "logo")));
|
||||||
TourPlaner.init();
|
|
||||||
primaryStage.setScene(new Scene(root, 1500, 1000));
|
primaryStage.setScene(new Scene(root, 1500, 1000));
|
||||||
primaryStage.show();
|
primaryStage.show();
|
||||||
}
|
}
|
||||||
|
@ -1,51 +0,0 @@
|
|||||||
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;
|
|
||||||
|
|
||||||
public class DirectionMap {
|
|
||||||
|
|
||||||
private double dauer, strecke;
|
|
||||||
private String start, end, tourname, file, filepdf;
|
|
||||||
private Image map, mappdf;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Holt die Map als image und alle Daten zur berechneten Route
|
|
||||||
*
|
|
||||||
* @param start Startpunkt
|
|
||||||
* @param ende Endpunkt
|
|
||||||
* @param tourname Name der Aktuellen Tour
|
|
||||||
* @throws IOException Fehler beim Image der Map
|
|
||||||
*/
|
|
||||||
public DirectionMap (String start, String ende, String tourname) throws IOException {
|
|
||||||
this.map = getMap(start, ende, ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "map", "size"));
|
|
||||||
this.mappdf = getMap(start, ende, ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "map", "sizePdf"));
|
|
||||||
this.start = start;
|
|
||||||
this.end = ende;
|
|
||||||
this.tourname = tourname;
|
|
||||||
this.file = ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "map", "path") + this.tourname + ".jpg";
|
|
||||||
this.filepdf = ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "map", "path") + this.tourname + "_pdf.jpg";
|
|
||||||
FileHelper.saveImage(this.map, "jpg", new File(this.file));
|
|
||||||
FileHelper.saveImage(this.mappdf, "jpg", new File(this.filepdf));
|
|
||||||
FileHelper.openDefault(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Downloadet die Map von Mapquest
|
|
||||||
* @param start Startpunkt
|
|
||||||
* @param ende Endpunkt
|
|
||||||
* @return Image von der Map
|
|
||||||
* @throws IOException Fehler beim Get der Map
|
|
||||||
*/
|
|
||||||
private Image getMap(String start, String ende, String size) throws IOException {
|
|
||||||
return HttpHelper.httpGetImage("https://www.mapquestapi.com/staticmap/v5/map?start="+start+"&end="+ende+"&size="+size+"&key="+ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "map", "key"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,62 +0,0 @@
|
|||||||
package tourplaner.business;
|
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class FileHelper {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Öffnet ein File mit dem Standart Program
|
|
||||||
* @param f File Path als string
|
|
||||||
*/
|
|
||||||
public static void openDefault(String f){
|
|
||||||
// A reference to a text file
|
|
||||||
File file = new File(f);
|
|
||||||
|
|
||||||
try {
|
|
||||||
Desktop desktop = Desktop.getDesktop();
|
|
||||||
|
|
||||||
// Open a file using the default program for the file type. In the example
|
|
||||||
// we will launch a default registered program to open a text file. For
|
|
||||||
// example on Windows operating system this call might launch a notepad.exe
|
|
||||||
// to open the file.
|
|
||||||
desktop.open(file);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Speichert ein Image
|
|
||||||
* @param img Das zu speichernde Bild
|
|
||||||
* @param type Dateityp z.b. jpg
|
|
||||||
* @param file Wo die datei zu speichern ist
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
|
||||||
public static void saveImage(Image img, String type, File file) throws IOException {
|
|
||||||
ImageIO.write(ImgHelper.toBufferedImage(img), type, file);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Holt ein image von einem File
|
|
||||||
* @param file File mit dem image
|
|
||||||
* @return Das buffered image
|
|
||||||
* @throws IOException Fehler beim öffnen des bildes
|
|
||||||
*/
|
|
||||||
public static BufferedImage getImage(File file) throws IOException {
|
|
||||||
return ImageIO.read(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Löscht ein File
|
|
||||||
* @param file File das zu löschen ist
|
|
||||||
* @return false bei error
|
|
||||||
*/
|
|
||||||
public static boolean delFile(File file){
|
|
||||||
return file.delete();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
package tourplaner.business;
|
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URL;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Http Hilfsfunktionen
|
|
||||||
*/
|
|
||||||
public class HttpHelper {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Holt ein Image von gegebener URL
|
|
||||||
* @param url Url als Sting
|
|
||||||
* @return Image von der Url
|
|
||||||
* @throws IOException Fehler beim Bild holen
|
|
||||||
*/
|
|
||||||
public static Image httpGetImage(String url) throws IOException {
|
|
||||||
URL urls = new URL(url);
|
|
||||||
return ImageIO.read(urls);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
package tourplaner.business;
|
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Image Hilfsfunktionen
|
|
||||||
*/
|
|
||||||
public class ImgHelper {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a given Image into a BufferedImage
|
|
||||||
*
|
|
||||||
* @param img The Image to be converted
|
|
||||||
* @return The converted BufferedImage
|
|
||||||
*/
|
|
||||||
public static BufferedImage toBufferedImage(Image img)
|
|
||||||
{
|
|
||||||
if (img instanceof BufferedImage)
|
|
||||||
{
|
|
||||||
return (BufferedImage) img;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a buffered image with transparency
|
|
||||||
BufferedImage bimage = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_ARGB);
|
|
||||||
|
|
||||||
// Draw the image on to the buffered image
|
|
||||||
Graphics2D bGr = bimage.createGraphics();
|
|
||||||
bGr.drawImage(img, 0, 0, null);
|
|
||||||
bGr.dispose();
|
|
||||||
|
|
||||||
// Return the buffered image
|
|
||||||
return bimage;
|
|
||||||
}
|
|
||||||
}
|
|
@ -33,14 +33,6 @@ public class LogHelper{
|
|||||||
getLog(name).error(msg);
|
getLog(name).error(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Log info in file und Console
|
|
||||||
* @param e Exception
|
|
||||||
*/
|
|
||||||
public static void error(Exception e){
|
|
||||||
getLog(e.getClass().getName()).error(e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log info in file und Console
|
* Log info in file und Console
|
||||||
* @param msg Nachricht in dem Log
|
* @param msg Nachricht in dem Log
|
||||||
|
@ -1,223 +1,34 @@
|
|||||||
package tourplaner.business;
|
package tourplaner.business;
|
||||||
|
|
||||||
import com.itextpdf.text.*;
|
import org.apache.pdfbox.exceptions.COSVisitorException;
|
||||||
import com.itextpdf.text.Font;
|
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||||
import com.itextpdf.text.Image;
|
import org.apache.pdfbox.pdmodel.PDPage;
|
||||||
import com.sun.scenario.effect.ImageData;
|
import org.apache.pdfbox.pdmodel.edit.PDPageContentStream;
|
||||||
import tourplaner.object.Log;
|
import org.apache.pdfbox.pdmodel.font.PDFont;
|
||||||
import tourplaner.object.Tour;
|
import org.apache.pdfbox.pdmodel.font.PDType1Font;
|
||||||
|
|
||||||
|
|
||||||
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;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* https://github.com/ymasory/iText-4.2.0
|
|
||||||
*/
|
|
||||||
public class Reporter {
|
public class Reporter {
|
||||||
|
|
||||||
private static Font catFont = new Font(Font.TIMES_ROMAN, 18,
|
public static void createTourReport(String tourname) throws IOException, COSVisitorException {
|
||||||
Font.BOLD);
|
PDDocument document = new PDDocument();
|
||||||
private static Font redFont = new Font(Font.TIMES_ROMAN, 12,
|
PDPage page = new PDPage();
|
||||||
Font.NORMAL, Color.RED);
|
document.addPage(page);
|
||||||
private static Font subFont = new Font(Font.TIMES_ROMAN, 16,
|
|
||||||
Font.BOLD);
|
|
||||||
private static Font smallBold = new Font(Font.TIMES_ROMAN, 12,
|
|
||||||
Font.BOLD);
|
|
||||||
|
|
||||||
public static void createTourReport(String tourname) {
|
PDFont font = PDType1Font.HELVETICA;
|
||||||
Tour tour = TourPlaner.getTour(tourname);
|
PDPageContentStream contentStream = new PDPageContentStream(document, page);
|
||||||
tour.setLog(TourPlaner.getLogs(tourname));
|
contentStream.beginText();
|
||||||
String file = ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "report", "path") + tourname+".pdf";
|
contentStream.setFont(font, 12);
|
||||||
try {
|
contentStream.moveTextPositionByAmount(100,700);
|
||||||
Document document = new Document();
|
contentStream.drawString(tourname);
|
||||||
PdfWriter.getInstance(document, new FileOutputStream(file));
|
// contentStream.drawString();
|
||||||
document.open();
|
contentStream.endText();
|
||||||
addMetaData(document, tour);
|
|
||||||
// addTitlePage(document, tour);
|
contentStream.close();
|
||||||
addContent(document, tour);
|
|
||||||
document.close();
|
document.save(ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "report", "path") + "test.pdf");
|
||||||
} catch (DocumentException | FileNotFoundException e) {
|
document.close();
|
||||||
LogHelper.error(e.getMessage(), e.getClass().getName());
|
|
||||||
}
|
|
||||||
FileHelper.openDefault(file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// iText allows to add metadata to the PDF which can be viewed in your Adobe
|
|
||||||
// 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");
|
|
||||||
}
|
|
||||||
|
|
||||||
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());
|
|
||||||
|
|
||||||
// Second parameter is the number of the chapter
|
|
||||||
Chapter catPart = new Chapter(new Paragraph(anchor), 1);
|
|
||||||
|
|
||||||
Paragraph subPara = new Paragraph("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()));
|
|
||||||
Paragraph emptyLine = new Paragraph();
|
|
||||||
addEmptyLine(emptyLine, 5);
|
|
||||||
subCatPart.add(emptyLine);
|
|
||||||
|
|
||||||
|
|
||||||
// now add all this to the document
|
|
||||||
document.add(catPart);
|
|
||||||
|
|
||||||
Image image1 = null;
|
|
||||||
try {
|
|
||||||
image1 = Image.getInstance(TourPlaner.getImagePdfPath(tour.getName()));
|
|
||||||
image1.setAlignment(Element.ALIGN_CENTER);
|
|
||||||
image1.scaleAbsolute(600, 400);
|
|
||||||
|
|
||||||
document.add(image1);
|
|
||||||
} catch (IOException e) {
|
|
||||||
LogHelper.error(e);
|
|
||||||
}
|
|
||||||
ArrayList<Log> logs = tour.getLogs();
|
|
||||||
// Second parameter is the number of the chapter
|
|
||||||
anchor = new Anchor("Logs", catFont);
|
|
||||||
anchor.setName("Logs");
|
|
||||||
catPart = new Chapter(new Paragraph(anchor), 2);
|
|
||||||
catPart.add(new Paragraph("Anzahl der Logeinträge: " + logs.size()));
|
|
||||||
|
|
||||||
for (Log log: logs) {
|
|
||||||
subPara = new Paragraph("Log vom: " + 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()));
|
|
||||||
}
|
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void addEmptyLine(Paragraph paragraph, int number) {
|
|
||||||
for (int i = 0; i < number; i++) {
|
|
||||||
paragraph.add(new Paragraph(" "));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,9 @@ package tourplaner.business;
|
|||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import tourplaner.data.DbConnect;
|
import tourplaner.data.DbConnect;
|
||||||
import tourplaner.object.Log;
|
import tourplaner.data.PostgresHelper;
|
||||||
import tourplaner.object.Tour;
|
import tourplaner.object.Tour;
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -16,94 +13,20 @@ import java.util.ArrayList;
|
|||||||
public class TourPlaner{
|
public class TourPlaner{
|
||||||
private Logger logger;
|
private Logger logger;
|
||||||
|
|
||||||
/**
|
public TourPlaner(){
|
||||||
* Erstellt alle DB Tabellen falls nötig
|
// LogHelper.info(ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "start", "message"),
|
||||||
*/
|
// ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "start", "app"));
|
||||||
public static void init(){
|
|
||||||
new DbConnect().init();
|
new DbConnect().init();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public ArrayList<Tour> getAllTours(){
|
||||||
* Holt alle touren aus der DB
|
DbConnect dbConnect = new DbConnect();
|
||||||
* @return Alle touren als ArrayList
|
ArrayList<Tour> touren = dbConnect.getAllTouren();
|
||||||
*/
|
return touren;
|
||||||
public static ArrayList<Tour> getAllTours(){
|
|
||||||
return new DbConnect().getAllTouren();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public String getMapJson(String start, String ziel){
|
||||||
* Bearbeitet eine Tour
|
|
||||||
* @param oldname Alter Tourname
|
|
||||||
* @param tour Neuer Tourname
|
|
||||||
* @return false bei error
|
|
||||||
*/
|
|
||||||
public static boolean editTour(String oldname, Tour tour) throws IOException {
|
|
||||||
FileHelper.delFile(new File(getImagePath(oldname)));
|
|
||||||
FileHelper.delFile(new File(getImagePdfPath(oldname)));
|
|
||||||
new DirectionMap(tour.getStart(), tour.getZiel(), tour.getName());
|
|
||||||
return new DbConnect().editTour(oldname, tour);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean delTour(String tourname){
|
|
||||||
FileHelper.delFile(new File(getImagePath(tourname)));
|
|
||||||
FileHelper.delFile(new File(getImagePdfPath(tourname)));
|
|
||||||
return new DbConnect().delTour(tourname);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Fügt eine Tour hinzu
|
|
||||||
* @param newTour Neue Tour
|
|
||||||
* @return false bei error
|
|
||||||
*/
|
|
||||||
public static boolean addTour(Tour newTour) throws IOException {
|
|
||||||
new DirectionMap(newTour.getStart(), newTour.getZiel(), newTour.getName());
|
|
||||||
return new DbConnect().addTour(newTour);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Image getImage(String tourname) throws IOException {
|
|
||||||
return FileHelper.getImage(new File(getImagePath(tourname)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getImagePath(String tourname){
|
|
||||||
return ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "map", "path") + tourname + ".jpg";
|
|
||||||
}
|
|
||||||
public static String getImagePdfPath(String tourname){
|
|
||||||
return ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "map", "path") + tourname + "_pdf.jpg";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void openImage(String tourname){
|
|
||||||
FileHelper.openDefault(getImagePath(tourname));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static ArrayList<Log> getLogs(String tourname){
|
|
||||||
return new DbConnect().getLogs(tourname);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void doReport(String tourname){
|
|
||||||
Reporter.createTourReport(tourname);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Tour getTour(String tourname){
|
|
||||||
return new DbConnect().getTour(tourname);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean addLog(String tourname, Log log){
|
|
||||||
if(Double.isInfinite(log.getAvgspeed())) log.setAvgspeed(-1.0);
|
|
||||||
return new DbConnect().addLog(tourname, log);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean delLog(String tourname, String id){
|
|
||||||
return new DbConnect().delLog(tourname, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean editLog(String tourname, Log log){
|
|
||||||
if(Double.isInfinite(log.getAvgspeed())) log.setAvgspeed(-1.0);
|
|
||||||
return new DbConnect().editLog(tourname, log);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static String getMapJson(String start, String ziel){
|
|
||||||
// TODO: 14.04.2021 Map Quest
|
|
||||||
return start + " " + ziel;
|
return start + " " + ziel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,10 @@
|
|||||||
package tourplaner.data;
|
package tourplaner.data;
|
||||||
|
|
||||||
import javafx.geometry.Pos;
|
|
||||||
import tourplaner.object.Log;
|
|
||||||
import tourplaner.object.Tour;
|
import tourplaner.object.Tour;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.Date;
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,108 +38,6 @@ public class DbConnect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Bearbeitet eine Tour
|
|
||||||
* @param oldname Alter Tour name
|
|
||||||
* @param tour Neues Tour Object
|
|
||||||
* @return false bei error
|
|
||||||
*/
|
|
||||||
public boolean editTour(String oldname, Tour tour) {
|
|
||||||
String tourname = tour.getName();
|
|
||||||
ArrayList<Boolean> result = new ArrayList<>();
|
|
||||||
ArrayList<Log> logs = getLogs(oldname);
|
|
||||||
result.add(delLogs(oldname));
|
|
||||||
result.add(PostgresHelper.executeUpdate("UPDATE public.tour SET tourname = '"+tour.getName()+"', dauer = 1, mapjson = '"+tour.getMapJson()+"', start = '"+tour.getStart()+"', ziel = '"+tour.getZiel()+"', strecke = "+tour.getStrecke()+" WHERE tourname ='" + oldname + "';"));
|
|
||||||
logs.forEach(log -> {
|
|
||||||
result.add(addLog(tourname, log));
|
|
||||||
});
|
|
||||||
return !result.contains(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean delLogs(String tourname){
|
|
||||||
return PostgresHelper.executeUpdate("DELETE FROM public.log WHERE tourname = '"+tourname+"'");
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Fügt eine Tour hinzu
|
|
||||||
* @param tour Neue Tour
|
|
||||||
* @return false bei error
|
|
||||||
*/
|
|
||||||
public boolean addTour(Tour tour){
|
|
||||||
return PostgresHelper.executeUpdate("INSERT INTO public.tour (tourname, dauer, mapjson, start, ziel, strecke) VALUES ('"+tour.getName()+"', "+tour.getDauer()+", '"+tour.getMapJson()+"', '"+tour.getStart()+"', '"+tour.getZiel()+"', "+tour.getStrecke()+")");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Löscht eine Tour anhand des Tournamens
|
|
||||||
* @param tourname Tourname der zu löschen ist
|
|
||||||
* @return false bei error
|
|
||||||
*/
|
|
||||||
public boolean delTour(String tourname){
|
|
||||||
ArrayList<Boolean> result = new ArrayList<>();
|
|
||||||
result.add(delLogs(tourname));
|
|
||||||
result.add(PostgresHelper.executeUpdate("DELETE FROM public.tour WHERE tourname = '"+tourname+"'"));
|
|
||||||
return !result.contains(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<Log> getLogs(String tourname){
|
|
||||||
|
|
||||||
this.c = PostgresHelper.con();
|
|
||||||
String id, bemerkung ;
|
|
||||||
double dauer, strecke, pause, gegangen, avg, hightmeter;
|
|
||||||
Date datum;
|
|
||||||
|
|
||||||
ArrayList<Log> logs = new ArrayList<>();
|
|
||||||
try {
|
|
||||||
stmt = this.c.createStatement();
|
|
||||||
ResultSet rs = stmt.executeQuery("SELECT * FROM public.log where tourname = '"+ tourname +"'");
|
|
||||||
while (rs.next()) {
|
|
||||||
id = rs.getString("id");
|
|
||||||
bemerkung = rs.getString("bemerkung");
|
|
||||||
datum = rs.getDate("datum");
|
|
||||||
dauer = rs.getDouble("dauer");
|
|
||||||
// avg = rs.getDouble("avg");
|
|
||||||
hightmeter = rs.getDouble("hightmeter");
|
|
||||||
pause = rs.getDouble("pause");
|
|
||||||
// gegangen = rs.getDouble("gegangen");
|
|
||||||
strecke = rs.getDouble("strecke");
|
|
||||||
if (!tourname.isEmpty()) {
|
|
||||||
logs.add(new Log(id, dauer, datum.toLocalDate(), strecke, bemerkung,hightmeter, pause));
|
|
||||||
}else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rs.close();
|
|
||||||
stmt.close();
|
|
||||||
this.c.close();
|
|
||||||
return logs;
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.err.println(e.getClass().getName() + ": " + e.getMessage());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Füght einen Logeintrag ein
|
|
||||||
* @param tourname Zu welcher Tour der Logeintrag gehört
|
|
||||||
* @param log Der Logeintrag
|
|
||||||
* @return false bei error
|
|
||||||
*/
|
|
||||||
public boolean addLog(String tourname, Log log){
|
|
||||||
if(Double.isInfinite(log.getAvgspeed())) log.setAvgspeed(-1.0);
|
|
||||||
return PostgresHelper.executeUpdate("INSERT INTO public.log (tourname, id, bemerkung, datum, strecke, avg, hightmeter, pause, gegangen, dauer) VALUES ('"+tourname+"', '"+log.getId()+"', '"+log.getBemerkung()+"', '"+log.getDatum()+"', "
|
|
||||||
+log.getStrecke()+", "+log.getAvgspeed()+", "+log.getHightmeter()+", "+log.getPause()+", "+log.getGegangen()+", "+log.getDauer()+")");
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean editLog(String tourname, Log log){
|
|
||||||
return PostgresHelper.executeUpdate("UPDATE public.log SET bemerkung = '"+log.getBemerkung()+"', datum = '"+log.getDatum()+"', strecke = "+log.getStrecke()+", avg = "+log.getAvgspeed()+", hightmeter = "+
|
|
||||||
log.getHightmeter()+", pause = "+log.getPause()+", gegangen = "+log.getGegangen()+", dauer = "+log.getDauer()+" WHERE tourname = '"+tourname+"' and id = '"+log.getId()+"'");
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean delLog(String tourname, String id){
|
|
||||||
System.out.println("DELETE FROM public.log WHERE tourname = '"+tourname+"' and id = '"+id+"'");
|
|
||||||
return PostgresHelper.executeUpdate("DELETE FROM public.log WHERE tourname = '"+tourname+"' and id = '"+id+"'");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holt alle Touren aus der Datenbank
|
* Holt alle Touren aus der Datenbank
|
||||||
* @return Null bei fehler, sonst eine List aus den IDs
|
* @return Null bei fehler, sonst eine List aus den IDs
|
||||||
@ -156,7 +50,7 @@ public class DbConnect {
|
|||||||
ArrayList<Tour> touren = new ArrayList<>();
|
ArrayList<Tour> touren = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
stmt = this.c.createStatement();
|
stmt = this.c.createStatement();
|
||||||
ResultSet rs = stmt.executeQuery("select * from tour;");
|
ResultSet rs = stmt.executeQuery("select tourname, dauer, mapjson, start, ziel, strecke from tour;");
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
tourname = rs.getString("tourname");
|
tourname = rs.getString("tourname");
|
||||||
mapjson = rs.getString("mapjson");
|
mapjson = rs.getString("mapjson");
|
||||||
@ -180,41 +74,4 @@ public class DbConnect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Holt eine Tour aus der Datenbank
|
|
||||||
* @param tn Tourname
|
|
||||||
* @return Null bei fehler, sonst eine List aus den IDs
|
|
||||||
*/
|
|
||||||
public Tour getTour(String tn){
|
|
||||||
this.c = PostgresHelper.con();
|
|
||||||
String tourname, mapjson, start, ziel;
|
|
||||||
double dauer, strecke;
|
|
||||||
|
|
||||||
Tour touren = null;
|
|
||||||
try {
|
|
||||||
stmt = this.c.createStatement();
|
|
||||||
ResultSet rs = stmt.executeQuery("select * from tour where tourname = '"+tn+"';");
|
|
||||||
while (rs.next()) {
|
|
||||||
tourname = rs.getString("tourname");
|
|
||||||
mapjson = rs.getString("mapjson");
|
|
||||||
start = rs.getString("start");
|
|
||||||
ziel = rs.getString("ziel");
|
|
||||||
dauer = rs.getDouble("dauer");
|
|
||||||
strecke = rs.getDouble("strecke");
|
|
||||||
if (!tourname.isEmpty()) {
|
|
||||||
touren = new Tour(tourname, dauer + "", mapjson, strecke, start, ziel);
|
|
||||||
}else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rs.close();
|
|
||||||
stmt.close();
|
|
||||||
this.c.close();
|
|
||||||
return touren;
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.err.println(e.getClass().getName() + ": " + e.getMessage());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,20 +21,6 @@ public class Tour {
|
|||||||
this.log = new ArrayList<>();
|
this.log = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTour(Tour tour){
|
|
||||||
this.dauer = tour.getDauer();
|
|
||||||
this.mapJson = tour.getMapJson();
|
|
||||||
this.strecke = tour.getStrecke();
|
|
||||||
this.name = tour.getName();
|
|
||||||
this.start = tour.getStart();
|
|
||||||
this.ziel = tour.getZiel();
|
|
||||||
this.log = tour.getLogs();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLog(ArrayList<Log> log) {
|
|
||||||
this.log = log;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holt einen einzigen Log Eintrag anhand der Id
|
* Holt einen einzigen Log Eintrag anhand der Id
|
||||||
* @param id Id des Eintrags der zu besorgen ist
|
* @param id Id des Eintrags der zu besorgen ist
|
||||||
|
@ -34,7 +34,6 @@
|
|||||||
|
|
||||||
<?import javafx.geometry.*?>
|
<?import javafx.geometry.*?>
|
||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.image.*?>
|
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
<?import javafx.scene.paint.*?>
|
<?import javafx.scene.paint.*?>
|
||||||
<?import javafx.scene.text.*?>
|
<?import javafx.scene.text.*?>
|
||||||
@ -113,11 +112,10 @@
|
|||||||
<children>
|
<children>
|
||||||
<TabPane fx:id="viewTabPane" layoutX="1.0" layoutY="69.0" prefWidth="702.0" tabClosingPolicy="UNAVAILABLE" AnchorPane.bottomAnchor="-67.0" AnchorPane.leftAnchor="1.0" AnchorPane.rightAnchor="1.0" AnchorPane.topAnchor="0.0">
|
<TabPane fx:id="viewTabPane" layoutX="1.0" layoutY="69.0" prefWidth="702.0" tabClosingPolicy="UNAVAILABLE" AnchorPane.bottomAnchor="-67.0" AnchorPane.leftAnchor="1.0" AnchorPane.rightAnchor="1.0" AnchorPane.topAnchor="0.0">
|
||||||
<tabs>
|
<tabs>
|
||||||
<Tab fx:id="kartenTab" text="Karte">
|
<Tab fx:id="kartenTab" text="Karte">
|
||||||
<AnchorPane>
|
<content>
|
||||||
<ImageView fx:id="mapImageView" pickOnBounds="true" preserveRatio="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
|
<AnchorPane />
|
||||||
</AnchorPane>
|
</content></Tab>
|
||||||
</Tab>
|
|
||||||
<Tab fx:id="beschreibungTab" text="Beschreibung">
|
<Tab fx:id="beschreibungTab" text="Beschreibung">
|
||||||
<content>
|
<content>
|
||||||
<AnchorPane>
|
<AnchorPane>
|
||||||
|
@ -8,11 +8,9 @@ import javafx.scene.control.*;
|
|||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.control.TextField;
|
import javafx.scene.control.TextField;
|
||||||
import javafx.scene.control.cell.PropertyValueFactory;
|
import javafx.scene.control.cell.PropertyValueFactory;
|
||||||
import javafx.scene.image.ImageView;
|
|
||||||
import javafx.scene.input.MouseEvent;
|
import javafx.scene.input.MouseEvent;
|
||||||
import tourplaner.business.ConfigHelper;
|
import tourplaner.business.ConfigHelper;
|
||||||
import tourplaner.business.LogHelper;
|
import tourplaner.business.LogHelper;
|
||||||
import tourplaner.business.TourPlaner;
|
|
||||||
import tourplaner.object.Log;
|
import tourplaner.object.Log;
|
||||||
import tourplaner.object.Tour;
|
import tourplaner.object.Tour;
|
||||||
import tourplaner.viewmodels.ViewModel;
|
import tourplaner.viewmodels.ViewModel;
|
||||||
@ -38,7 +36,6 @@ public class TourplanerController implements Initializable {
|
|||||||
public TableView<Tour> beschreibungTableView;
|
public TableView<Tour> beschreibungTableView;
|
||||||
public TableColumn<Tour, String> startCol, zielCol, dauerCol, streckeCol, nameCol;
|
public TableColumn<Tour, String> startCol, zielCol, dauerCol, streckeCol, nameCol;
|
||||||
public TextField titleTextView, sucheInput;
|
public TextField titleTextView, sucheInput;
|
||||||
public ImageView mapImageView;
|
|
||||||
//Log -> rechts unten
|
//Log -> rechts unten
|
||||||
public TableView<Log> logTableView;
|
public TableView<Log> logTableView;
|
||||||
public TableColumn<Log, String> logDauerCol, logStreckeCol, logDatumCol, logAvgCol, logHightCol, logPauseCol, logGegangenCol, logBemerkungCol;
|
public TableColumn<Log, String> logDauerCol, logStreckeCol, logDatumCol, logAvgCol, logHightCol, logPauseCol, logGegangenCol, logBemerkungCol;
|
||||||
@ -51,18 +48,12 @@ public class TourplanerController implements Initializable {
|
|||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void editTourBtn(){
|
private void editTourBtn(){
|
||||||
try {
|
this.viewModel.editTour();
|
||||||
this.viewModel.editTour();
|
|
||||||
} catch (IOException e) {
|
|
||||||
LogHelper.error(e);
|
|
||||||
}
|
|
||||||
syncTour(this.viewModel.getSelectedTour().getName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void editLogBtn(){
|
private void editLogBtn(){
|
||||||
this.viewModel.editLog();
|
this.viewModel.editLog();
|
||||||
syncLogs();
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Öffnet github im standart browser
|
* Öffnet github im standart browser
|
||||||
@ -91,20 +82,6 @@ public class TourplanerController implements Initializable {
|
|||||||
this.viewModel.doxygenDocBrowser();
|
this.viewModel.doxygenDocBrowser();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void syncTour(String selectedItem){
|
|
||||||
beschreibungTableView.getItems().removeIf(s -> true); //Leert die Table View komplett
|
|
||||||
beschreibungTableView.getItems().add(this.viewModel.getTour(selectedItem));
|
|
||||||
mapImageView.setImage(this.viewModel.getImage(selectedItem));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void syncTourNamen(){
|
|
||||||
TourListView.setItems(this.viewModel.getTourNamen());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void syncLogs(){
|
|
||||||
logTableView.getItems().removeIf(s -> true);
|
|
||||||
logTableView.setItems(this.viewModel.getLogData());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -116,7 +93,8 @@ public class TourplanerController implements Initializable {
|
|||||||
String selectedItem = TourListView.getSelectionModel().getSelectedItem();
|
String selectedItem = TourListView.getSelectionModel().getSelectedItem();
|
||||||
this.viewModel.selectTour(selectedItem);
|
this.viewModel.selectTour(selectedItem);
|
||||||
titleTextView.setText(selectedItem);
|
titleTextView.setText(selectedItem);
|
||||||
syncTour(selectedItem);
|
beschreibungTableView.getItems().removeIf(s -> true); //Leert die Table View komplett
|
||||||
|
beschreibungTableView.getItems().add(this.viewModel.getTour(selectedItem));
|
||||||
startCol.setCellValueFactory(new PropertyValueFactory<Tour, String>("start"));
|
startCol.setCellValueFactory(new PropertyValueFactory<Tour, String>("start"));
|
||||||
zielCol.setCellValueFactory(new PropertyValueFactory<Tour, String>("ziel"));
|
zielCol.setCellValueFactory(new PropertyValueFactory<Tour, String>("ziel"));
|
||||||
dauerCol.setCellValueFactory(new PropertyValueFactory<Tour, String>("dauer"));
|
dauerCol.setCellValueFactory(new PropertyValueFactory<Tour, String>("dauer"));
|
||||||
@ -125,7 +103,6 @@ public class TourplanerController implements Initializable {
|
|||||||
|
|
||||||
//Log anzeigen
|
//Log anzeigen
|
||||||
logTableView.setPlaceholder(new Label( ConfigHelper.getLangIniString("keinelogsvorhanden")));
|
logTableView.setPlaceholder(new Label( ConfigHelper.getLangIniString("keinelogsvorhanden")));
|
||||||
logTableView.getItems().removeIf(s -> true);
|
|
||||||
logTableView.setItems(this.viewModel.getLogData());
|
logTableView.setItems(this.viewModel.getLogData());
|
||||||
logDauerCol.setCellValueFactory(new PropertyValueFactory<Log, String>("dauer"));
|
logDauerCol.setCellValueFactory(new PropertyValueFactory<Log, String>("dauer"));
|
||||||
logStreckeCol.setCellValueFactory(new PropertyValueFactory<Log, String>("strecke"));
|
logStreckeCol.setCellValueFactory(new PropertyValueFactory<Log, String>("strecke"));
|
||||||
@ -136,7 +113,6 @@ public class TourplanerController implements Initializable {
|
|||||||
logGegangenCol.setCellValueFactory(new PropertyValueFactory<Log, String>("gegangen"));
|
logGegangenCol.setCellValueFactory(new PropertyValueFactory<Log, String>("gegangen"));
|
||||||
logBemerkungCol.setCellValueFactory(new PropertyValueFactory<Log, String>("bemerkung"));
|
logBemerkungCol.setCellValueFactory(new PropertyValueFactory<Log, String>("bemerkung"));
|
||||||
|
|
||||||
mapImageView.setImage(this.viewModel.getImage(this.viewModel.getSelectedTour().getName()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -155,7 +131,6 @@ public class TourplanerController implements Initializable {
|
|||||||
@FXML
|
@FXML
|
||||||
private void addTour(){
|
private void addTour(){
|
||||||
this.viewModel.addTour();
|
this.viewModel.addTour();
|
||||||
this.mapImageView.setImage(this.viewModel.getImage(this.viewModel.getSelectedTour().getName()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -168,7 +143,6 @@ public class TourplanerController implements Initializable {
|
|||||||
this.titleTextView.setText(ConfigHelper.getLangIniString("keinetourselected"));
|
this.titleTextView.setText(ConfigHelper.getLangIniString("keinetourselected"));
|
||||||
this.viewModel.delTour();
|
this.viewModel.delTour();
|
||||||
logTableView.setPlaceholder(new Label( ConfigHelper.getLangIniString("keinetourselected")));
|
logTableView.setPlaceholder(new Label( ConfigHelper.getLangIniString("keinetourselected")));
|
||||||
mapImageView.setImage(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -187,13 +161,12 @@ public class TourplanerController implements Initializable {
|
|||||||
@FXML
|
@FXML
|
||||||
private void addLog(){
|
private void addLog(){
|
||||||
this.viewModel.addLog();
|
this.viewModel.addLog();
|
||||||
syncLogs();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void delLog(){
|
private void delLog(){
|
||||||
this.viewModel.delLog();
|
this.viewModel.delLog();
|
||||||
syncLogs();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -215,7 +188,7 @@ public class TourplanerController implements Initializable {
|
|||||||
//Tour list -> links
|
//Tour list -> links
|
||||||
TourListView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
|
TourListView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
|
||||||
TourListView.setOrientation(Orientation.VERTICAL);
|
TourListView.setOrientation(Orientation.VERTICAL);
|
||||||
syncTourNamen();
|
TourListView.setItems(this.viewModel.getTourNamen());
|
||||||
//Tabs zu Tour -> rechts oben
|
//Tabs zu Tour -> rechts oben
|
||||||
beschreibungTableView.setPlaceholder(new Label( ConfigHelper.getLangIniString("keinetourselected")));
|
beschreibungTableView.setPlaceholder(new Label( ConfigHelper.getLangIniString("keinetourselected")));
|
||||||
titleTextView.setText( ConfigHelper.getLangIniString("keinetourselected"));
|
titleTextView.setText( ConfigHelper.getLangIniString("keinetourselected"));
|
||||||
|
@ -2,8 +2,10 @@ package tourplaner.viewmodels;
|
|||||||
|
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.scene.image.Image;
|
import org.apache.pdfbox.exceptions.COSVisitorException;
|
||||||
|
import tourplaner.business.Reporter;
|
||||||
import tourplaner.business.TourPlaner;
|
import tourplaner.business.TourPlaner;
|
||||||
|
import tourplaner.data.DbConnect;
|
||||||
import tourplaner.ui.AlertHelper;
|
import tourplaner.ui.AlertHelper;
|
||||||
import tourplaner.business.ConfigHelper;
|
import tourplaner.business.ConfigHelper;
|
||||||
import tourplaner.business.LogHelper;
|
import tourplaner.business.LogHelper;
|
||||||
@ -32,15 +34,11 @@ public class ViewModel {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Image getImage(String tourname){
|
|
||||||
return new Image( ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "map", "file_pre") + TourPlaner.getImagePath(tourname));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bearbeitet eine bereits bestehende Tour
|
* Bearbeitet eine bereits bestehende Tour
|
||||||
* prüft ob eine tour ausgewählt ist
|
* prüft ob eine tour ausgewählt ist
|
||||||
*/
|
*/
|
||||||
public void editTour() throws IOException {
|
public void editTour(){
|
||||||
if (this.selectedTour == null){
|
if (this.selectedTour == null){
|
||||||
AlertHelper.warn(ConfigHelper.getLangIniString("achtung"),
|
AlertHelper.warn(ConfigHelper.getLangIniString("achtung"),
|
||||||
ConfigHelper.getLangIniString("keinetourselected"),
|
ConfigHelper.getLangIniString("keinetourselected"),
|
||||||
@ -62,11 +60,8 @@ public class ViewModel {
|
|||||||
|
|
||||||
this.tourData.removeIf(tour -> tour.getName().equals(this.selectedTour.getName()));
|
this.tourData.removeIf(tour -> tour.getName().equals(this.selectedTour.getName()));
|
||||||
this.tourNamen.removeIf(tour -> tour.equals(this.selectedTour.getName()));
|
this.tourNamen.removeIf(tour -> tour.equals(this.selectedTour.getName()));
|
||||||
Tour newTour = new Tour(this.neueTourName, "TBD", "TBD", 0, this.neueTourStart, this.neueTourZiel);
|
this.tourData.add(new Tour(this.neueTourName, "TBD", "TBD", 0, this.neueTourStart, this.neueTourZiel));
|
||||||
this.tourData.add(newTour);
|
|
||||||
this.tourNamen.add(this.neueTourName);
|
this.tourNamen.add(this.neueTourName);
|
||||||
LogHelper.info("Edit Tour: " + this.neueTourName + " upload zu Postgres war: " + TourPlaner.editTour(this.selectedTour.getName(), newTour), "ViewModel - EditTour");
|
|
||||||
selectTour(this.neueTourName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -145,7 +140,7 @@ public class ViewModel {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -157,15 +152,8 @@ public class ViewModel {
|
|||||||
tourStartInput("");
|
tourStartInput("");
|
||||||
tourZielInput("");
|
tourZielInput("");
|
||||||
if (getTour(this.neueTourName) == null) {
|
if (getTour(this.neueTourName) == null) {
|
||||||
Tour newTour = new Tour(this.neueTourName, "1", "1", 0, this.neueTourStart, this.neueTourZiel);
|
tourData.add(new Tour(this.neueTourName, "TBD", "TBD", 0, this.neueTourStart, this.neueTourZiel));
|
||||||
tourData.add(newTour);
|
|
||||||
tourNamen.add(this.neueTourName);
|
tourNamen.add(this.neueTourName);
|
||||||
this.selectedTour = newTour;
|
|
||||||
try {
|
|
||||||
TourPlaner.addTour(newTour);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
this.neueTourStart = null;
|
this.neueTourStart = null;
|
||||||
this.neueTourZiel = null;
|
this.neueTourZiel = null;
|
||||||
@ -219,11 +207,10 @@ public class ViewModel {
|
|||||||
Log newLog = new Log(this.selectedLog.getId(), dauer, datum, strecke, this.neueBemerkung, hightmeter, pause);
|
Log newLog = new Log(this.selectedLog.getId(), dauer, datum, strecke, this.neueBemerkung, hightmeter, pause);
|
||||||
this.logData.removeIf(ld -> ld.getId().equals(this.selectedLog.getId()));
|
this.logData.removeIf(ld -> ld.getId().equals(this.selectedLog.getId()));
|
||||||
this.logData.add(newLog);
|
this.logData.add(newLog);
|
||||||
// tourAkt.get().delLog(this.selectedLog.getId());
|
tourAkt.get().delLog(this.selectedLog.getId());
|
||||||
// tourAkt.get().addLog(newLog);
|
tourAkt.get().addLog(newLog);
|
||||||
this.tourData.removeIf(td -> td.getName().equals(this.selectedTour.getName()));
|
this.tourData.removeIf(td -> td.getName().equals(this.selectedTour.getName()));
|
||||||
this.tourData.add(tourAkt.get());
|
this.tourData.add(tourAkt.get());
|
||||||
TourPlaner.editLog(this.selectedTour.getName(), newLog);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -335,7 +322,6 @@ public class ViewModel {
|
|||||||
if (date != null) {
|
if (date != null) {
|
||||||
Log newLog = new Log(newId.get(), dauer, date, strecke, this.neueBemerkung, hightmeter, pause);
|
Log newLog = new Log(newId.get(), dauer, date, strecke, this.neueBemerkung, hightmeter, pause);
|
||||||
this.logData.add(newLog);
|
this.logData.add(newLog);
|
||||||
TourPlaner.addLog(this.selectedTour.getName(), newLog);
|
|
||||||
s.addLog(newLog);
|
s.addLog(newLog);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -357,8 +343,25 @@ public class ViewModel {
|
|||||||
*/
|
*/
|
||||||
public void delLog(){
|
public void delLog(){
|
||||||
if(this.selectedLog != null) {
|
if(this.selectedLog != null) {
|
||||||
TourPlaner.delLog(this.selectedTour.getName(), this.selectedLog.getId());
|
this.logData.removeIf(s -> s.getId().equals(this.selectedLog.getId()));
|
||||||
|
AtomicReference<Tour> tourToEdit = new AtomicReference<>();
|
||||||
|
this.tourData.forEach(s -> {
|
||||||
|
if (s.getLogs() != null) {
|
||||||
|
s.getLogs().forEach(ss -> {
|
||||||
|
if (ss.getId().equals(this.selectedLog.getId())) {
|
||||||
|
tourToEdit.set(s);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (tourToEdit.get() != null){
|
||||||
|
Tour toEdit = tourToEdit.get();
|
||||||
|
toEdit.delLog(this.selectedLog.getId());
|
||||||
|
this.tourData.removeIf(s -> s.getName().equals(toEdit.getName()));
|
||||||
|
this.tourData.add(toEdit);
|
||||||
this.selectedLog = null;
|
this.selectedLog = null;
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
AlertHelper.warn(ConfigHelper.getLangIniString("achtung"),
|
AlertHelper.warn(ConfigHelper.getLangIniString("achtung"),
|
||||||
ConfigHelper.getLangIniString("keinetourselected"),
|
ConfigHelper.getLangIniString("keinetourselected"),
|
||||||
@ -398,8 +401,6 @@ public class ViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ObservableList<Log> getLogData() {
|
public ObservableList<Log> getLogData() {
|
||||||
logData.removeAll();
|
|
||||||
logData.addAll(TourPlaner.getLogs(this.selectedTour.getName()));
|
|
||||||
return logData;
|
return logData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -482,7 +483,7 @@ public class ViewModel {
|
|||||||
public ObservableList<Tour> getTourData() {
|
public ObservableList<Tour> getTourData() {
|
||||||
tourData.removeAll();
|
tourData.removeAll();
|
||||||
// ObservableList<Tour> data = ;
|
// ObservableList<Tour> data = ;
|
||||||
tourData.addAll(TourPlaner.getAllTours());
|
tourData.addAll(new TourPlaner().getAllTours());
|
||||||
return tourData;
|
return tourData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -496,7 +497,6 @@ public class ViewModel {
|
|||||||
tourNamen.removeIf(s -> s.equals(tourname));
|
tourNamen.removeIf(s -> s.equals(tourname));
|
||||||
logData.removeIf(s -> true);
|
logData.removeIf(s -> true);
|
||||||
setSelectedTour(null);
|
setSelectedTour(null);
|
||||||
TourPlaner.delTour(tourname);
|
|
||||||
}catch (NullPointerException e){
|
}catch (NullPointerException e){
|
||||||
LogHelper.error(ConfigHelper.getLangIniString("keinetourselected"),
|
LogHelper.error(ConfigHelper.getLangIniString("keinetourselected"),
|
||||||
ConfigHelper.getLangIniString("deltournoselect"));
|
ConfigHelper.getLangIniString("deltournoselect"));
|
||||||
@ -580,7 +580,14 @@ public class ViewModel {
|
|||||||
ConfigHelper.getLangIniString("keinetourselected"),
|
ConfigHelper.getLangIniString("keinetourselected"),
|
||||||
ConfigHelper.getLangIniString("logtournotselectedmsg"));
|
ConfigHelper.getLangIniString("logtournotselectedmsg"));
|
||||||
}else {
|
}else {
|
||||||
TourPlaner.doReport(this.selectedTour.getName());
|
try {
|
||||||
|
Reporter.createTourReport(this.selectedTour.getName());
|
||||||
|
} catch (IOException e) {
|
||||||
|
LogHelper.error(e.getMessage(), e.getClass().getName());
|
||||||
|
} catch (COSVisitorException e) {
|
||||||
|
LogHelper.error(e.getMessage(), e.getClass().getName());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user