From 98c18dee792356c23995aecf96fd3467a9c1164c Mon Sep 17 00:00:00 2001 From: hneemann Date: Mon, 3 Jul 2017 16:34:02 +0200 Subject: [PATCH] added failed/passed colors to measurement graph --- .../de/neemann/digital/data/DataPlotter.java | 32 ++++- .../neemann/digital/draw/graphics/Style.java | 8 ++ .../components/testing/TestResultDialog.java | 8 +- src/main/resources/measurement-graph.png | Bin 0 -> 1275 bytes src/main/resources/measurement-graph_hi.png | Bin 0 -> 2598 bytes src/main/svg/exp.sh | 1 + src/main/svg/measurement-graph.svg | 134 ++++++++++++++++++ 7 files changed, 177 insertions(+), 6 deletions(-) create mode 100644 src/main/resources/measurement-graph.png create mode 100644 src/main/resources/measurement-graph_hi.png create mode 100644 src/main/svg/measurement-graph.svg diff --git a/src/main/java/de/neemann/digital/data/DataPlotter.java b/src/main/java/de/neemann/digital/data/DataPlotter.java index a4504f06f..3e80dd403 100644 --- a/src/main/java/de/neemann/digital/data/DataPlotter.java +++ b/src/main/java/de/neemann/digital/data/DataPlotter.java @@ -89,13 +89,35 @@ public class DataPlotter implements Drawable { g.drawLine(new Vector(xx, BORDER - SEP2), new Vector(xx, (SIZE + SEP) * signals + BORDER - SEP2), Style.DASH); y = BORDER; for (int i = 0; i < signals; i++) { + Style style; + switch (s[i].getState()) { + case FAIL: + style=Style.FAILED; + break; + case PASS: + style=Style.PASS; + break; + default: + style=Style.NORMAL; + } long width = data.getMax(i); if (width == 0) width = 1; - int ry = (int) (SIZE - (SIZE * s[i].getValue()) / width); - g.drawLine(new Vector(xx, y + ry), new Vector((int) (xx + size), y + ry), Style.NORMAL); - if (!first && ry != lastRy[i]) - g.drawLine(new Vector(xx, y + lastRy[i]), new Vector(xx, y + ry), Style.NORMAL); + int ry; + if (s[i].getType() == Value.Type.CLOCK) { + ry = 0; + g.drawLine(new Vector(xx, y + ry), new Vector((int) (xx + size / 2), y + ry), style); + if (!first && ry != lastRy[i]) + g.drawLine(new Vector(xx, y + lastRy[i]), new Vector(xx, y + ry), style); + ry = SIZE; + g.drawLine(new Vector((int) (xx + size / 2), y + ry), new Vector((int) (xx + size), y + ry), style); + g.drawLine(new Vector((int) (xx + size / 2), y), new Vector((int) (xx + size / 2), y + SIZE), style); + } else { + ry = (int) (SIZE - (SIZE * s[i].getValue()) / width); + g.drawLine(new Vector(xx, y + ry), new Vector((int) (xx + size), y + ry), style); + if (!first && ry != lastRy[i]) + g.drawLine(new Vector(xx, y + lastRy[i]), new Vector(xx, y + ry), style); + } lastRy[i] = ry; y += SIZE + SEP; @@ -103,7 +125,7 @@ public class DataPlotter implements Drawable { first = false; pos += size; } - g.drawLine(new Vector(x, BORDER - SEP2), new Vector(x, (SIZE + SEP) * signals + BORDER - SEP2), Style.DASH); + g.drawLine(new Vector((int) (pos + x), BORDER - SEP2), new Vector((int) (pos + x), (SIZE + SEP) * signals + BORDER - SEP2), Style.DASH); }); } diff --git a/src/main/java/de/neemann/digital/draw/graphics/Style.java b/src/main/java/de/neemann/digital/draw/graphics/Style.java index a2c7c162a..5b52d6995 100644 --- a/src/main/java/de/neemann/digital/draw/graphics/Style.java +++ b/src/main/java/de/neemann/digital/draw/graphics/Style.java @@ -25,6 +25,14 @@ public class Style { * used for all lines to draw the shapes itself */ public static final Style NORMAL = new Style(LINETHICK, false, Color.BLACK); + /** + * used for all lines to draw the failed state + */ + public static final Style FAILED = new Style(LINETHICK, false, Color.RED); + /** + * used for all lines to draw the passed state + */ + public static final Style PASS = new Style(LINETHICK, false, Color.GREEN); /** * Used for text which is integral part of the shape. * Text which uses this style is always included in sizing! diff --git a/src/main/java/de/neemann/digital/gui/components/testing/TestResultDialog.java b/src/main/java/de/neemann/digital/gui/components/testing/TestResultDialog.java index a6852e7f0..71b94d037 100644 --- a/src/main/java/de/neemann/digital/gui/components/testing/TestResultDialog.java +++ b/src/main/java/de/neemann/digital/gui/components/testing/TestResultDialog.java @@ -35,6 +35,8 @@ public class TestResultDialog extends JDialog { private static final Color PASSED_COLOR = new Color(200, 255, 200); private static final Icon ICON_FAILED = IconCreator.create("testFailed.png"); private static final Icon ICON_PASSED = IconCreator.create("testPassed.png"); + private static final Icon ICON_GRAPH = IconCreator.create("measurement-graph.png"); + private final ArrayList resultTableData; @@ -101,7 +103,7 @@ public class TestResultDialog extends JDialog { JMenuBar bar = new JMenuBar(); JMenu view = new JMenu(Lang.get("menu_view")); - ToolTipAction asGraph = new ToolTipAction(Lang.get("menu_showDataAsGraph")) { + ToolTipAction asGraph = new ToolTipAction(Lang.get("menu_showDataAsGraph"), ICON_GRAPH) { @Override public void actionPerformed(ActionEvent actionEvent) { int tab = tp.getSelectedIndex(); @@ -113,6 +115,10 @@ public class TestResultDialog extends JDialog { bar.add(view); setJMenuBar(bar); + JToolBar toolBar = new JToolBar(); + toolBar.add(asGraph.createJButtonNoText()); + getContentPane().add(toolBar, BorderLayout.NORTH); + getContentPane().add(tp); pack(); setLocationRelativeTo(owner); diff --git a/src/main/resources/measurement-graph.png b/src/main/resources/measurement-graph.png new file mode 100644 index 0000000000000000000000000000000000000000..605724d3a44d965eec65f3d73832de7f5810dd3b GIT binary patch literal 1275 zcmVX1^@s6BEU{300004b3#c}2nYxW zdl}bfjigXnxR~K~=1i?YX%|(nRixOIr8ci-St+}bamFBNK-;mGJ+jIQj zdm+n@hvz-#-1j*r9wCI_-x5NQ$z2wf65RFD@Hk)`n9&}yjQ(yt``KPU ze*EC%$&=i=b<4$DtrohjqiLFp-??*#FJHc}d-rY^cN_=eR##WW z&U*j;y_lVym3XmO6prIaJef?2#l=O5udlBQtUQ#zfFQfwH8#6qDEy}i8>4+euuk3yk#;K74RAwa2AVsUZN z#cbOq5C}-8QZAR39;Ruc|7ix@Emx~mNf?jE@%#NedGf@?|2CzONQ6Cm_DDY8zI{XA z2^SU?IC}IbmSvGhB(`!lIXTIZBS)}p8^bVYG#WULgJBp5AutSMD|a70e8BJblg(zg zG8>IX0o*y<*x2C8l`HssK4~Wt6BAs!cFo0~KYz}nM~|dQU0GS-@#Dt~4-dO|KA%T_ z`SK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v`WMp7Ao6$6l?(S|>RYg%0G)-f4bQD!p85tQNDJhBn031=y;bMX2$N&HU07*qo IM6N<$f&_INEC2ui literal 0 HcmV?d00001 diff --git a/src/main/svg/exp.sh b/src/main/svg/exp.sh index adae63d02..64386ba7e 100755 --- a/src/main/svg/exp.sh +++ b/src/main/svg/exp.sh @@ -18,6 +18,7 @@ ./expicon.sh View-zoom-out ./expicon.sh edit-redo ./expicon.sh edit-undo +./expicon.sh measurement-graph ./exptest.sh testFailed ./exptest.sh testPassed diff --git a/src/main/svg/measurement-graph.svg b/src/main/svg/measurement-graph.svg new file mode 100644 index 000000000..22d1bb2d8 --- /dev/null +++ b/src/main/svg/measurement-graph.svg @@ -0,0 +1,134 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + A + B + C + +