Kleine Map für Report
This commit is contained in:
parent
3f60d618ff
commit
9fe6f34ba3
@ -24,5 +24,6 @@ javadoc = https://git.dergeorg.at/dergeorg/tourplaner
|
||||
[map]
|
||||
key =
|
||||
size = 1500,400
|
||||
sizePdf = 600,400
|
||||
path = D:\\TourplanerImages\\
|
||||
file_pre = file:///
|
@ -10,8 +10,8 @@ import java.io.IOException;
|
||||
public class DirectionMap {
|
||||
|
||||
private double dauer, strecke;
|
||||
private String start, end, tourname, file;
|
||||
private Image map;
|
||||
private String start, end, tourname, file, filepdf;
|
||||
private Image map, mappdf;
|
||||
|
||||
/**
|
||||
* Holt die Map als image und alle Daten zur berechneten Route
|
||||
@ -22,12 +22,15 @@ public class DirectionMap {
|
||||
* @throws IOException Fehler beim Image der Map
|
||||
*/
|
||||
public DirectionMap (String start, String ende, String tourname) throws IOException {
|
||||
this.map = getMap(start, ende);
|
||||
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";
|
||||
FileHelper.saveImage(this.map, "jpg", new File(file));
|
||||
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);
|
||||
}
|
||||
|
||||
@ -38,8 +41,8 @@ public class DirectionMap {
|
||||
* @return Image von der Map
|
||||
* @throws IOException Fehler beim Get der Map
|
||||
*/
|
||||
private Image getMap(String start, String ende) throws IOException {
|
||||
return HttpHelper.httpGetImage("https://www.mapquestapi.com/staticmap/v5/map?start="+start+"&end="+ende+"&size="+ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "map", "size")+"&key="+ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "map", "key"));
|
||||
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,21 +1,13 @@
|
||||
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.Anchor;
|
||||
import com.itextpdf.text.BadElementException;
|
||||
import com.itextpdf.text.Chapter;
|
||||
import com.itextpdf.text.Document;
|
||||
import com.itextpdf.text.DocumentException;
|
||||
import com.itextpdf.text.Element;
|
||||
import com.itextpdf.text.Font;
|
||||
import com.itextpdf.text.List;
|
||||
import com.itextpdf.text.ListItem;
|
||||
import com.itextpdf.text.Paragraph;
|
||||
import com.itextpdf.text.Phrase;
|
||||
import com.itextpdf.text.Section;
|
||||
import com.itextpdf.text.pdf.PdfPCell;
|
||||
import com.itextpdf.text.pdf.PdfPTable;
|
||||
import com.itextpdf.text.pdf.PdfWriter;
|
||||
@ -28,6 +20,9 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* https://github.com/ymasory/iText-4.2.0
|
||||
*/
|
||||
public class Reporter {
|
||||
|
||||
private static Font catFont = new Font(Font.TIMES_ROMAN, 18,
|
||||
@ -82,15 +77,24 @@ public class Reporter {
|
||||
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);
|
||||
|
@ -39,12 +39,14 @@ public class TourPlaner{
|
||||
*/
|
||||
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);
|
||||
}
|
||||
/**
|
||||
@ -53,7 +55,7 @@ public class TourPlaner{
|
||||
* @return false bei error
|
||||
*/
|
||||
public static boolean addTour(Tour newTour) throws IOException {
|
||||
DirectionMap directionMap = new DirectionMap(newTour.getStart(), newTour.getZiel(), newTour.getName());
|
||||
new DirectionMap(newTour.getStart(), newTour.getZiel(), newTour.getName());
|
||||
return new DbConnect().addTour(newTour);
|
||||
}
|
||||
|
||||
@ -64,6 +66,9 @@ public class TourPlaner{
|
||||
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));
|
||||
|
@ -115,7 +115,7 @@
|
||||
<tabs>
|
||||
<Tab fx:id="kartenTab" text="Karte">
|
||||
<AnchorPane>
|
||||
<ImageView fx:id="mapImageView" pickOnBounds="true" preserveRatio="true" AnchorPane.bottomAnchor="80.0" AnchorPane.leftAnchor="13.0" AnchorPane.rightAnchor="825.0" AnchorPane.topAnchor="0.0" />
|
||||
<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>
|
||||
</Tab>
|
||||
<Tab fx:id="beschreibungTab" text="Beschreibung">
|
||||
|
Loading…
x
Reference in New Issue
Block a user