From 978659b828d81b2f04db224ea7dae00f9874985b Mon Sep 17 00:00:00 2001 From: hneemann Date: Sun, 18 Dec 2016 18:01:40 +0100 Subject: [PATCH] enabled SVG export stroke dash --- .../digital/draw/graphics/GraphicSVG.java | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/main/java/de/neemann/digital/draw/graphics/GraphicSVG.java b/src/main/java/de/neemann/digital/draw/graphics/GraphicSVG.java index 95a6c0f40..a7ff3a82e 100644 --- a/src/main/java/de/neemann/digital/draw/graphics/GraphicSVG.java +++ b/src/main/java/de/neemann/digital/draw/graphics/GraphicSVG.java @@ -83,8 +83,7 @@ public class GraphicSVG implements Graphic, Closeable { public void drawLine(Vector p1, Vector p2, Style style) { try { w.write("\n"); } catch (IOException e) { throw new RuntimeException(e); @@ -106,10 +105,9 @@ public class GraphicSVG implements Graphic, Closeable { w.write(" Z"); w.write("\""); -// if (style.isDashed()) -// addStrokeDash(w, style.getDashArray()); + addStrokeDash(w, style.getDash()); if (style.isFilled() && p.isClosed()) - w.write(" stroke=\"" + getColor(style) + "\" stroke-width=\"" + getStrokeWidth(style) + "\" fill=\"" + getColor(style) + "\" fill-opacity=\""+getOpacity(style)+"\"/>\n"); + w.write(" stroke=\"" + getColor(style) + "\" stroke-width=\"" + getStrokeWidth(style) + "\" fill=\"" + getColor(style) + "\" fill-opacity=\"" + getOpacity(style) + "\"/>\n"); else w.write(" stroke=\"" + getColor(style) + "\" stroke-width=\"" + getStrokeWidth(style) + "\" fill=\"none\"/>\n"); } catch (IOException e) { @@ -130,8 +128,7 @@ public class GraphicSVG implements Graphic, Closeable { w.write("\n"); else { w.write("\n"); } } catch (IOException e) { @@ -270,13 +267,15 @@ public class GraphicSVG implements Graphic, Closeable { } - private static void addStrokeDash(Writer w, int[] dashArray) throws IOException { - w.write(" stroke-dasharray=\""); - for (int i = 0; i < dashArray.length; i++) { - if (i != 0) w.write(','); - w.write(Integer.toString(dashArray[i])); + private static void addStrokeDash(Writer w, float[] dashArray) throws IOException { + if (dashArray != null) { + w.write(" stroke-dasharray=\""); + for (int i = 0; i < dashArray.length; i++) { + if (i != 0) w.write(','); + w.write(Float.toString(dashArray[i])); + } + w.write('"'); } - w.write('"'); } private String str(Vector p) {