changeset 9119:36c80c7fd02f

missing files Veg'Zone, FontMapper
author gernotbelger
date Tue, 05 Jun 2018 10:25:48 +0200
parents 431f1c269be5
children 2fb72a0aa313
files artifacts/src/main/java/org/dive4elements/river/exports/ChartExportFontMapper.java artifacts/src/main/java/org/dive4elements/river/exports/ChartExportHelper.java gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/AbstractVegZonesTablePanel.java gwt-client/src/main/java/org/dive4elements/river/client/shared/model/VegetationZone.java
diffstat 4 files changed, 167 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/ChartExportFontMapper.java	Tue Jun 05 10:25:48 2018 +0200
@@ -0,0 +1,52 @@
+/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
+ * Software engineering by
+ *  Björnsen Beratende Ingenieure GmbH
+ *  Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
+ *
+ * This file is Free Software under the GNU AGPL (>=v3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out the
+ * documentation coming with Dive4Elements River for details.
+ */
+package org.dive4elements.river.exports;
+
+import java.awt.Font;
+import java.io.IOException;
+
+import com.lowagie.text.DocumentException;
+import com.lowagie.text.ExceptionConverter;
+import com.lowagie.text.pdf.BaseFont;
+import com.lowagie.text.pdf.FontMapper;
+
+/**
+ * @author Domenico Nardi Tironi
+ *
+ */
+public class ChartExportFontMapper implements FontMapper {
+
+    @Override
+    public Font pdfToAwt(final BaseFont font, final int size) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public BaseFont awtToPdf(final Font font) {
+        try {
+
+            if (font.isItalic()) {
+                if (font.isBold())
+                    return BaseFont.createFont("fonts/Roboto/Roboto-BoldItalic.ttf", BaseFont.IDENTITY_H, false);
+                else
+                    return BaseFont.createFont("fonts/Roboto/Roboto-Italic.ttf", BaseFont.IDENTITY_H, false);
+            } else {
+                if (font.isBold())
+                    return BaseFont.createFont("fonts/Roboto/Roboto-Bold.ttf", BaseFont.IDENTITY_H, false);
+                else
+                    return BaseFont.createFont("fonts/Roboto/Roboto-Regular.ttf", BaseFont.IDENTITY_H, false);
+            }
+        }
+        catch (DocumentException | IOException e) {
+            e.printStackTrace();
+            throw new ExceptionConverter(e);
+        }
+    }
+}
\ No newline at end of file
--- a/artifacts/src/main/java/org/dive4elements/river/exports/ChartExportHelper.java	Mon Jun 04 19:38:59 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/ChartExportHelper.java	Tue Jun 05 10:25:48 2018 +0200
@@ -272,7 +272,7 @@
 
                 PdfTemplate template = content.createTemplate(width, height);
 
-                final FontMapper mapper = new ChartExportfontMapper();
+                final FontMapper mapper = new ChartExportFontMapper();
                 
                 final Graphics2D  graphics = template.createGraphics(width, height );
 
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/AbstractVegZonesTablePanel.java	Mon Jun 04 19:38:59 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/AbstractVegZonesTablePanel.java	Tue Jun 05 10:25:48 2018 +0200
@@ -104,7 +104,7 @@
             @Override
             public Object normalize(final ListGridRecord record, final String fieldName) {
                 final String number = record.getAttribute(fieldName);
-                // String.format("%03d", number);// format.format(Integer.valueOf(number)); funktioniert hier leider nicht
+                // String.format("%03d", number); funktioniert hier leider nicht
                 final String numberFormat = "000" + number;
                 return numberFormat.substring(numberFormat.length() - 3);
             }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/shared/model/VegetationZone.java	Tue Jun 05 10:25:48 2018 +0200
@@ -0,0 +1,113 @@
+/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
+ * Software engineering by
+ *  Björnsen Beratende Ingenieure GmbH
+ *  Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
+ *
+ * This file is Free Software under the GNU AGPL (>=v3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out the
+ * documentation coming with Dive4Elements River for details.
+ */
+
+package org.dive4elements.river.client.shared.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Domenico Nardi Tironi
+ *
+ */
+public class VegetationZone implements Comparable<VegetationZone> {
+
+    // IMMER ABGLEICHEN MIT VegetationZone.class IM SERVER
+    private static final String TABLE_CELL_SEPARATOR = "TABLE_CELL_SEPARATOR";
+    private static final String TABLE_ROW_SEPARATOR = "TABLE_ROW_SEPARATOR";
+    private final String zoneName;
+    private final int min_day_overflow;
+    private final int max_day_overflow;
+
+    public static List<VegetationZone> parse(final String zonesRaw) {
+        final List<VegetationZone> resultList = new ArrayList<VegetationZone>();
+
+        final List<String[]> results = new ArrayList<String[]>();
+        if (zonesRaw.contains(TABLE_ROW_SEPARATOR)) {
+            final String[] rows = zonesRaw.split(TABLE_ROW_SEPARATOR);
+            for (final String row : rows) {
+                if (row.contains(TABLE_CELL_SEPARATOR)) {
+                    final String[] result = row.split(TABLE_CELL_SEPARATOR);
+                    results.add(result);
+                }
+            }
+        }
+        for (final String[] zone : results) {
+
+            final VegetationZone helper = new VegetationZone(zone[0], Integer.valueOf(zone[1]), Integer.valueOf(zone[2]));
+            resultList.add(helper);
+        }
+
+        return resultList;
+    }
+
+    public static VegetationZone createFromTableEntry(final String zone, final String min_day_overflow, final String max_day_overflow) {
+        return new VegetationZone(zone, Integer.valueOf(min_day_overflow), Integer.valueOf(max_day_overflow)); // Error-Handling?
+    }
+
+    private VegetationZone(final String zone, final Integer min_day_overflow, final Integer max_day_overflow) {
+        this.zoneName = zone;
+        this.min_day_overflow = min_day_overflow;
+        this.max_day_overflow = max_day_overflow;
+    }
+
+    public int getMax_day_overflow() {
+        return this.max_day_overflow;
+    }
+
+    public String getZoneName() {
+        return this.zoneName;
+    }
+
+    public int getMin_day_overflow() {
+        return this.min_day_overflow;
+    }
+
+    public static final List<VegetationZone> getStandardList() {
+
+        final List<VegetationZone> list = new ArrayList<VegetationZone>();
+        list.add(new VegetationZone("Zonaler Wald", 0, 5));
+        list.add(new VegetationZone("Hartholzaue, trocken", 5, 40));
+        list.add(new VegetationZone("Hartholzaue, feucht", 40, 80));
+        list.add(new VegetationZone("Silberweidenwald", 80, 140));
+        list.add(new VegetationZone("Weidengebüsch", 140, 200));
+        list.add(new VegetationZone("Uferröhricht", 200, 260));
+        list.add(new VegetationZone("Uferpioniere", 260, 320));
+        list.add(new VegetationZone("Vegetationslos", 320, 365));
+        list.add(new VegetationZone("Wasserfläche", 365, 365));
+
+        return list;
+    }
+
+    public static final String parseListToDataString(final List<VegetationZone> list) {
+
+        java.util.Collections.sort(list);
+        final StringBuilder builder = new StringBuilder();
+        for (final VegetationZone zone : list) {
+            builder.append(zone.getZoneName());
+            builder.append(TABLE_CELL_SEPARATOR);
+            builder.append(zone.getMin_day_overflow());
+            builder.append(TABLE_CELL_SEPARATOR);
+            builder.append(zone.getMax_day_overflow());
+            builder.append(TABLE_ROW_SEPARATOR);
+        }
+        return builder.toString();
+
+    }
+
+    @Override
+    public int compareTo(final VegetationZone o) {
+        final int basicCompare = Integer.valueOf(this.getMin_day_overflow()).compareTo(o.getMin_day_overflow());
+        if (basicCompare == 0)
+            return Integer.valueOf(this.getMax_day_overflow()).compareTo(o.getMax_day_overflow()); // wenn min==min && max==max, alphabetisch sortieren?
+        return basicCompare;
+    }
+
+}

http://dive4elements.wald.intevation.org