Einheiten hinzugefügt + Weitere Übersetzungen + Fileinput .json bugfix + exporter " " hinzugefügt
This commit is contained in:
		
							
								
								
									
										50
									
								
								src/tourplaner/business/EinheitenAdder.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								src/tourplaner/business/EinheitenAdder.java
									
									
									
									
									
										Normal 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;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -34,8 +34,9 @@ public class Exporter {
 | 
			
		||||
        ProgressBar progressBar = new ProgressBar("Export...");
 | 
			
		||||
        int step = progressBar.getProgressSize(4, 100);
 | 
			
		||||
        ArrayList<Tour> data = new DbConnect().getAllTouren();
 | 
			
		||||
 | 
			
		||||
        progressBar.addProgress(step);
 | 
			
		||||
        FileWriter fileWriter = new FileWriter(path + ".json");
 | 
			
		||||
        FileWriter fileWriter = new FileWriter(EinheitenAdder.addJson(this.path));
 | 
			
		||||
        progressBar.addProgress(step);
 | 
			
		||||
        JsonHelper.getJsonFromObj(data, fileWriter);
 | 
			
		||||
        progressBar.addProgress(step);
 | 
			
		||||
@@ -51,7 +52,7 @@ public class Exporter {
 | 
			
		||||
    public void doImport() {
 | 
			
		||||
        ProgressBar progressBar = new ProgressBar("Import...");
 | 
			
		||||
        try {
 | 
			
		||||
            this.touren = JsonHelper.getTourenFromJson(new FileReader(this.path));
 | 
			
		||||
            this.touren = JsonHelper.getTourenFromJson(new FileReader(EinheitenAdder.addJson(this.path)));
 | 
			
		||||
            DbConnect dbConnect = new DbConnect();
 | 
			
		||||
            dbConnect.delAllData();
 | 
			
		||||
            progressBar.addProgress(5);
 | 
			
		||||
 
 | 
			
		||||
@@ -3,12 +3,9 @@ package tourplaner.business;
 | 
			
		||||
import com.itextpdf.text.*;
 | 
			
		||||
import com.itextpdf.text.Font;
 | 
			
		||||
import com.itextpdf.text.Image;
 | 
			
		||||
import tourplaner.data.DbConnect;
 | 
			
		||||
import tourplaner.object.Log;
 | 
			
		||||
import tourplaner.object.Tour;
 | 
			
		||||
 | 
			
		||||
import com.itextpdf.text.pdf.PdfPCell;
 | 
			
		||||
import com.itextpdf.text.pdf.PdfPTable;
 | 
			
		||||
import com.itextpdf.text.pdf.PdfWriter;
 | 
			
		||||
 | 
			
		||||
import java.awt.*;
 | 
			
		||||
@@ -78,17 +75,17 @@ public class Reporter {
 | 
			
		||||
                strecke += log.getStrecke();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        Anchor anchor = new Anchor("Zusammengefasster Report", catFont);
 | 
			
		||||
        anchor.setName("Zusammengefasster Report");
 | 
			
		||||
        Anchor anchor = new Anchor(ConfigHelper.getLangIniString("rsummrepo"), catFont);
 | 
			
		||||
        anchor.setName(ConfigHelper.getLangIniString("rsummrepo"));
 | 
			
		||||
        // Second parameter is the number of the chapter
 | 
			
		||||
        Chapter catPart = new Chapter(new Paragraph(anchor), 1);
 | 
			
		||||
        Paragraph subPara = new Paragraph("Daten", subFont);
 | 
			
		||||
        Paragraph subPara = new Paragraph(ConfigHelper.getLangIniString("rdaten"), subFont);
 | 
			
		||||
        Section subCatPart = catPart.addSection(subPara);
 | 
			
		||||
        subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("reportvon") + System.getProperty("user.name") + ", " + new Date()));
 | 
			
		||||
        subCatPart.add(new Paragraph("Gesammte Zeit aller Logs: " + dauer));
 | 
			
		||||
        subCatPart.add(new Paragraph("gesammte Strecke aller Logs: " + strecke));
 | 
			
		||||
        subCatPart.add(new Paragraph("Berechnete Zeit aller Logs: " + calDauer));
 | 
			
		||||
        subCatPart.add(new Paragraph("Berechnete Strecke aller Touren: " + calStecke));
 | 
			
		||||
        subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("reportvon") + " " + System.getProperty("user.name") + ", " + new Date()));
 | 
			
		||||
        subCatPart.add(new Paragraph(EinheitenAdder.addMinuten(ConfigHelper.getLangIniString("rzeitallerlogs") + " " + dauer)));
 | 
			
		||||
        subCatPart.add(new Paragraph(EinheitenAdder.addKm(ConfigHelper.getLangIniString("rstreckeallerlogs") + " " + strecke)));
 | 
			
		||||
        subCatPart.add(new Paragraph(EinheitenAdder.addMinuten(ConfigHelper.getLangIniString("rcalzeitallerlogs") + " " + calDauer)));
 | 
			
		||||
        subCatPart.add(new Paragraph(EinheitenAdder.addKm(ConfigHelper.getLangIniString("calstreckeallerloggs") + " " + calStecke)));
 | 
			
		||||
        document.add(catPart);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -120,7 +117,7 @@ public class Reporter {
 | 
			
		||||
    // Reader
 | 
			
		||||
    // under File -> Properties
 | 
			
		||||
    private static void addMetaData(Document document, Tour tour) {
 | 
			
		||||
        document.addTitle(ConfigHelper.getLangIniString("tourreportvon") + tour.getName());
 | 
			
		||||
        document.addTitle(ConfigHelper.getLangIniString("tourreportvon") + " " + tour.getName());
 | 
			
		||||
        document.addSubject(ConfigHelper.getLangIniString("tourplanervon"));
 | 
			
		||||
        document.addKeywords(ConfigHelper.getLangIniString("reportkeywords"));
 | 
			
		||||
        document.addAuthor(ConfigHelper.getLangIniString("tourplaner"));
 | 
			
		||||
@@ -142,11 +139,11 @@ public class Reporter {
 | 
			
		||||
 | 
			
		||||
        Paragraph subPara = new Paragraph(ConfigHelper.getLangIniString("tour"), subFont);
 | 
			
		||||
        Section subCatPart = catPart.addSection(subPara);
 | 
			
		||||
        subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("reportvon") + System.getProperty("user.name") + ", " + new Date()));
 | 
			
		||||
        subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("reportstart") + tour.getStart()));
 | 
			
		||||
        subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("reportziel") + tour.getZiel()));
 | 
			
		||||
        subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("reportdauercal") + tour.getDauer()));
 | 
			
		||||
        subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("reportstreckecal") + tour.getStrecke()));
 | 
			
		||||
        subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("reportvon") + " " + System.getProperty("user.name") + ", " + new Date()));
 | 
			
		||||
        subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("reportstart") + " " + tour.getStart()));
 | 
			
		||||
        subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("reportziel") + " " + tour.getZiel()));
 | 
			
		||||
        subCatPart.add(new Paragraph(EinheitenAdder.addMinuten(ConfigHelper.getLangIniString("reportdauercal") + " " + tour.getDauer())));
 | 
			
		||||
        subCatPart.add(new Paragraph(EinheitenAdder.addKm(ConfigHelper.getLangIniString("reportstreckecal") + " " + tour.getStrecke())));
 | 
			
		||||
        Paragraph emptyLine = new Paragraph();
 | 
			
		||||
        addEmptyLine(emptyLine, 5);
 | 
			
		||||
        subCatPart.add(emptyLine);
 | 
			
		||||
@@ -168,18 +165,18 @@ public class Reporter {
 | 
			
		||||
        anchor = new Anchor(ConfigHelper.getLangIniString("logs"), catFont);
 | 
			
		||||
        anchor.setName(ConfigHelper.getLangIniString("logs"));
 | 
			
		||||
        catPart = new Chapter(new Paragraph(anchor), 2);
 | 
			
		||||
        catPart.add(new Paragraph(ConfigHelper.getLangIniString("countlog") + logs.size()));
 | 
			
		||||
        catPart.add(new Paragraph(ConfigHelper.getLangIniString("countlog") + " " + logs.size()));
 | 
			
		||||
 | 
			
		||||
        for (Log log: logs) {
 | 
			
		||||
            subPara = new Paragraph(ConfigHelper.getLangIniString("logvom") + log.getDatum() , subFont);
 | 
			
		||||
            subPara = new Paragraph(ConfigHelper.getLangIniString("logvom") + " " + log.getDatum() , subFont);
 | 
			
		||||
            subCatPart = catPart.addSection(subPara);
 | 
			
		||||
            subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("logdauer") + log.getDauer()));
 | 
			
		||||
            subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("logpause") + log.getPause()));
 | 
			
		||||
            subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("loggegangen") + log.getGegangen()));
 | 
			
		||||
            subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("logavg")+ log.getAvgspeed()));
 | 
			
		||||
            subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("logstrecke") + log.getStrecke()));
 | 
			
		||||
            subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("loghight") + log.getHightmeter()));
 | 
			
		||||
            subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("logbemerkung") + log.getBemerkung()));
 | 
			
		||||
            subCatPart.add(new Paragraph(EinheitenAdder.addMinuten(ConfigHelper.getLangIniString("logdauer") + " " + log.getDauer())));
 | 
			
		||||
            subCatPart.add(new Paragraph(EinheitenAdder.addMinuten(ConfigHelper.getLangIniString("logpause") + " " + log.getPause())));
 | 
			
		||||
            subCatPart.add(new Paragraph(EinheitenAdder.addMinuten(ConfigHelper.getLangIniString("loggegangen") + " " + log.getGegangen())));
 | 
			
		||||
            subCatPart.add(new Paragraph(EinheitenAdder.addSpeed(ConfigHelper.getLangIniString("logavg") + " " + log.getAvgspeed())));
 | 
			
		||||
            subCatPart.add(new Paragraph(EinheitenAdder.addKm(ConfigHelper.getLangIniString("logstrecke") + " " + log.getStrecke())));
 | 
			
		||||
            subCatPart.add(new Paragraph(EinheitenAdder.addMeter(ConfigHelper.getLangIniString("loghight") + " " + log.getHightmeter())));
 | 
			
		||||
            subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("logbemerkung") + " " + log.getBemerkung()));
 | 
			
		||||
        }
 | 
			
		||||
        // now add all this to the document
 | 
			
		||||
        document.add(catPart);
 | 
			
		||||
 
 | 
			
		||||
@@ -20,6 +20,9 @@ public class Log {
 | 
			
		||||
        this.pause = pause;
 | 
			
		||||
        this.gegangen = this.dauer - this.pause;
 | 
			
		||||
        this.avgspeed = this.strecke / (this.gegangen);
 | 
			
		||||
        if(Double.isInfinite(this.avgspeed)){
 | 
			
		||||
            this.avgspeed = -1;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getBemerkung() {
 | 
			
		||||
 
 | 
			
		||||
@@ -133,9 +133,9 @@
 | 
			
		||||
                                             <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">
 | 
			
		||||
                                                  <columns>
 | 
			
		||||
                                                    <TableColumn fx:id="nameCol" maxWidth="1.7976931348623157E308" minWidth="70.0" prefWidth="-1.0" text="Tourname" />
 | 
			
		||||
                                                    <TableColumn fx:id="dauerCol" maxWidth="1.7976931348623157E308" minWidth="40.0" prefWidth="-1.0" text="Dauer" />
 | 
			
		||||
                                                      <TableColumn fx:id="streckeCol" maxWidth="1.7976931348623157E308" minWidth="50.0" prefWidth="-1.0" text="Strecke" />
 | 
			
		||||
                                                    <TableColumn fx:id="nameCol" minWidth="100.0" prefWidth="-1.0" text="Tourname" />
 | 
			
		||||
                                                    <TableColumn fx:id="dauerCol" maxWidth="1.7976931348623157E308" minWidth="100.0" prefWidth="-1.0" text="Dauer" />
 | 
			
		||||
                                                      <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="zielCol" maxWidth="1.7976931348623157E308" minWidth="100.0" prefWidth="-1.0" text="Zielpunkt" />
 | 
			
		||||
                                                  </columns>
 | 
			
		||||
@@ -185,14 +185,14 @@
 | 
			
		||||
                                 <children>
 | 
			
		||||
                                    <TableView fx:id="logTableView" onMouseClicked="#logItemSelected" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
 | 
			
		||||
                                      <columns>
 | 
			
		||||
                                        <TableColumn fx:id="logDatumCol" prefWidth="49.0" text="Datum" />
 | 
			
		||||
                                        <TableColumn fx:id="logDauerCol" prefWidth="126.0" text="Dauer" />
 | 
			
		||||
                                          <TableColumn fx:id="logStreckeCol" prefWidth="240.0" text="Entfernung" />
 | 
			
		||||
                                          <TableColumn fx:id="logAvgCol" prefWidth="75.0" text="AVG Geschwindigkeit" />
 | 
			
		||||
                                          <TableColumn fx:id="logHightCol" prefWidth="75.0" text="Höhenmeter" />
 | 
			
		||||
                                          <TableColumn fx:id="logPauseCol" prefWidth="75.0" text="Davon Pause" />
 | 
			
		||||
                                          <TableColumn fx:id="logGegangenCol" prefWidth="75.0" text="Davon Unterwegs" />
 | 
			
		||||
                                          <TableColumn fx:id="logBemerkungCol" prefWidth="75.0" text="Bemerkung" />
 | 
			
		||||
                                        <TableColumn fx:id="logDatumCol" minWidth="-1.0" prefWidth="-1.0" text="Datum" />
 | 
			
		||||
                                        <TableColumn fx:id="logDauerCol" minWidth="-1.0" prefWidth="-1.0" text="Dauer" />
 | 
			
		||||
                                          <TableColumn fx:id="logStreckeCol" minWidth="-1.0" prefWidth="-1.0" text="Entfernung" />
 | 
			
		||||
                                          <TableColumn fx:id="logAvgCol" minWidth="-1.0" prefWidth="-1.0" text="AVG Geschwindigkeit" />
 | 
			
		||||
                                          <TableColumn fx:id="logHightCol" minWidth="-1.0" prefWidth="75.0" text="Höhenmeter" />
 | 
			
		||||
                                          <TableColumn fx:id="logPauseCol" minWidth="-1.0" prefWidth="-1.0" text="Davon Pause" />
 | 
			
		||||
                                          <TableColumn fx:id="logGegangenCol" minWidth="-1.0" prefWidth="-1.0" text="Davon Unterwegs" />
 | 
			
		||||
                                          <TableColumn fx:id="logBemerkungCol" minWidth="-1.0" prefWidth="-1.0" text="Bemerkung" />
 | 
			
		||||
                                      </columns>
 | 
			
		||||
                                       <columnResizePolicy>
 | 
			
		||||
                                          <TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
 | 
			
		||||
@@ -210,7 +210,7 @@
 | 
			
		||||
    </SplitPane>
 | 
			
		||||
    <HBox id="HBox" alignment="CENTER_LEFT" spacing="5.0" VBox.vgrow="NEVER">
 | 
			
		||||
      <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 size="11.0" fx:id="x3" />
 | 
			
		||||
          </font>
 | 
			
		||||
@@ -219,7 +219,7 @@
 | 
			
		||||
          </textFill>
 | 
			
		||||
        </Label>
 | 
			
		||||
        <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>
 | 
			
		||||
      <padding>
 | 
			
		||||
        <Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
 | 
			
		||||
 
 | 
			
		||||
@@ -10,6 +10,7 @@ import javafx.scene.layout.*;
 | 
			
		||||
import javafx.stage.Stage;
 | 
			
		||||
import javafx.stage.WindowEvent;
 | 
			
		||||
import tourplaner.business.ConfigHelper;
 | 
			
		||||
import tourplaner.business.EinheitenAdder;
 | 
			
		||||
 | 
			
		||||
import javax.swing.*;
 | 
			
		||||
import javax.swing.border.TitledBorder;
 | 
			
		||||
 
 | 
			
		||||
@@ -160,10 +160,10 @@ public class TourplanerController implements Initializable {
 | 
			
		||||
            this.viewModel.setSucheAktiv(false);
 | 
			
		||||
            progressBar.addProgress(10);
 | 
			
		||||
            syncTourNamen();
 | 
			
		||||
            progressBar.addProgress(40);
 | 
			
		||||
            progressBar.setProgress(100);
 | 
			
		||||
            this.sucheInput.setText("");
 | 
			
		||||
        }
 | 
			
		||||
        progressBar.addProgress(50);
 | 
			
		||||
        progressBar.setProgress(100);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -302,6 +302,7 @@ public class TourplanerController implements Initializable {
 | 
			
		||||
        this.reportsummary.setText(ConfigHelper.getLangIniString("freposum"));
 | 
			
		||||
        this.tourreport.setText(ConfigHelper.getLangIniString("frepotour"));
 | 
			
		||||
        this.beendenButton.setText(ConfigHelper.getLangIniString("fbeenden"));
 | 
			
		||||
        this.sucheInput.setPromptText(ConfigHelper.getLangIniString("fsuche")+ConfigHelper.getLangIniString("fpunkte"));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @FXML
 | 
			
		||||
 
 | 
			
		||||
@@ -417,8 +417,8 @@ public class ViewModel {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public ObservableList<Log> getLogData() {
 | 
			
		||||
        logData.removeAll();
 | 
			
		||||
        if(this.selectedLog != null) logData.addAll(TourPlaner.getLogs(this.selectedTour.getName()));
 | 
			
		||||
        logData.removeIf(s -> true);
 | 
			
		||||
        if(this.selectedTour != null) logData.addAll(TourPlaner.getLogs(this.selectedTour.getName()));
 | 
			
		||||
        return logData;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user