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 000000000..605724d3a Binary files /dev/null and b/src/main/resources/measurement-graph.png differ diff --git a/src/main/resources/measurement-graph_hi.png b/src/main/resources/measurement-graph_hi.png new file mode 100644 index 000000000..8e69216d5 Binary files /dev/null and b/src/main/resources/measurement-graph_hi.png differ 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 + +