Skip to content

Commit

Permalink
Try use apache batik for example rendering #70
Browse files Browse the repository at this point in the history
  • Loading branch information
ivarref committed Mar 3, 2018
1 parent 24cd8db commit 1f4fe7a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions data/brent_monthly_usd.csv
Original file line number Diff line number Diff line change
Expand Up @@ -367,3 +367,4 @@ dato,usd
2017-11,62.71
2017-12,64.37
2018-01,69.08
2018-02,65.15
1 change: 1 addition & 0 deletions data/valuta_monthly.csv
Original file line number Diff line number Diff line change
Expand Up @@ -696,3 +696,4 @@ Date,1 AUD,100 BGN,1 BRL,1 CAD,100 CHF,100 CNY,100 CZK,100 DKK,1 EUR,1 GBP,1 HKD
2017-11,6.2414,491.27,2.5122,6.4149,825.44,123.62,37.624,129.11,9.6082,10.8208,1.0487,127.24,3.0806,106.01,0.060520,2.3274,12.621,7.2574,0.7437,ND,43.25,1.9649,5.6378,16.085,7.772,2.2733,207.31,13.883,97.56,6.0385,24.877,210.20,27.204,114.73,8.1853,11.54594,0.5818,ND,4.1013,9.85,0.5977,ND
2017-12,6.3554,503.18,2.5275,6.5139,841.90,126.05,38.375,132.22,9.8412,11.1497,1.0642,130.53,3.1426,108.34,0.061322,2.3717,12.938,7.3642,0.7668,ND,43.49,2.0402,5.7889,16.512,7.658,2.3414,212.33,14.179,99.04,6.1747,25.470,216.26,27.743,117.31,8.3147,11.77922,0.6323,ND,4.1285,10.05,0.6075,ND
2018-01,6.2886,493.22,2.4628,6.3611,822.87,123.05,37.900,129.56,9.6464,10.9209,1.0115,129.73,3.1191,105.97,0.059130,2.3107,12.425,7.1322,0.7417,ND,41.78,1.9994,5.7422,15.635,7.142,2.3171,207.49,13.958,98.23,5.9838,24.791,209.64,26.882,114.84,7.9092,11.37544,0.6478,ND,3.9746,9.52,0.5867,ND
2018-02,6.1663,494.49,2.4113,6.2291,837.90,123.89,38.196,129.89,9.6712,10.9407,1.0014,129.99,3.1024,105.85,0.057588,2.2403,12.156,7.2571,0.7264,ND,42.00,2.0016,5.7253,15.084,7.072,2.3218,207.72,13.777,97.32,5.9354,24.870,207.05,26.781,114.74,7.8327,11.35306,0.6624,ND,3.9646,9.42,0.5881,ND
Binary file added demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
[cheshire "5.7.1"]
[org.eclipse.jetty/jetty-util "9.4.5.v20170502"]
[clj-time "0.13.0"]
[org.apache.xmlgraphics/batik-rasterizer "1.9.1"]
[org.apache.xmlgraphics/batik-codec "1.9.1"]
[com.vdurmont/emoji-java "3.2.0"]
[hickory/hickory "0.7.1"]]
:aot [clj-simple-chart.jfx]
Expand Down
17 changes: 17 additions & 0 deletions src/clj_simple_chart/demo/batikpng.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
(ns clj-simple-chart.demo.batikpng
(:import [org.apache.batik.transcoder.image PNGTranscoder]
(org.apache.batik.transcoder TranscoderInput TranscoderOutput)
(java.io StringReader BufferedOutputStream FileOutputStream)
(java.awt Color)))

(defn write-png [^String s ^String output-filename]
(let [t (doto (PNGTranscoder.)
(.addTranscodingHint PNGTranscoder/KEY_PIXEL_TO_MM (Float. 0.2645833)) ; 96 dpi
(.addTranscodingHint PNGTranscoder/KEY_BACKGROUND_COLOR Color/white))]
(with-open [input (StringReader. s)
output (BufferedOutputStream. (FileOutputStream. output-filename))]
(.transcode t (TranscoderInput. input) (TranscoderOutput. output)))))

(defn demo []
(write-png (slurp "img/ssb-svg/nettokontantstraum.svg") "demo.png"))
; MD5 (demo.png) = 014a1215aa4c365462bcdcff920c6f4d on OS X

0 comments on commit 1f4fe7a

Please sign in to comment.