diff artifacts/src/main/java/org/dive4elements/river/exports/ChartExportFontMapper.java @ 9119:36c80c7fd02f

missing files Veg'Zone, FontMapper
author gernotbelger
date Tue, 05 Jun 2018 10:25:48 +0200
parents
children
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

http://dive4elements.wald.intevation.org