diff --git a/src/main/dig/sequential/Counter-JK.dig b/src/main/dig/sequential/Counter-JK.dig index 3337e16d9..ab3bcb33a 100644 --- a/src/main/dig/sequential/Counter-JK.dig +++ b/src/main/dig/sequential/Counter-JK.dig @@ -1,351 +1,362 @@ - 1 - - - Out - - - rotation - - - - - 3 - - - JK_FF - - - valueIsProbe - true - - - Label - q_0n - - - - 0 - - - JK_FF - - - valueIsProbe - true - - - Label - q_1n - - - Default - 1 - - - - 0 - - - JK_FF - - - valueIsProbe - true - - - Label - q_2n - - - Default - 1 - - - - 0 - - - JK_FF - - - valueIsProbe - true - - - Label - q_3n - - - Default - 1 - - - - 0 - - - And - - - 0 - - - And - - - 0 - - - Const - - - 0 - - - Clock - - - Label - C - - - - 0 - - - Out - - - rotation - - - - - 3 - - - Out - - - rotation - - - - - 3 - - - Out - - - rotation - - - - - 3 - - - Data - - - microStep - true - - - Label - Data - - - - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - C - Q_0 - Q_1 - Q_2 - Q_3 - + 1 + + + Out + + + rotation + + + + + 3 + + + JK_FF + + + valueIsProbe + true + + + Label + q_0n + + + + 0 + + + JK_FF + + + valueIsProbe + true + + + Label + q_1n + + + Default + 1 + + + + 0 + + + JK_FF + + + valueIsProbe + true + + + Label + q_2n + + + Default + 1 + + + + 0 + + + JK_FF + + + valueIsProbe + true + + + Label + q_3n + + + Default + 1 + + + + 0 + + + And + + + 0 + + + And + + + 0 + + + Const + + + 0 + + + Clock + + + Label + C + + + + 0 + + + Out + + + rotation + + + + + 3 + + + Out + + + rotation + + + + + 3 + + + Out + + + rotation + + + + + 3 + + + Data + + + microStep + true + + + Label + Data + + + + 0 + + + Text + + + Label + Synchroner Zähler aus JK-Flipflops + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + C + Q_0 + Q_1 + Q_2 + Q_3 + \ No newline at end of file diff --git a/src/main/dig/sequential/Counter-T.dig b/src/main/dig/sequential/Counter-T.dig index 8b6b2e43d..74322fbce 100644 --- a/src/main/dig/sequential/Counter-T.dig +++ b/src/main/dig/sequential/Counter-T.dig @@ -1,214 +1,225 @@ - 1 - - - Out - - - rotation - - - - - 3 - - - Clock - - - Label - C - - - Frequency - 2 - - - - 0 - - - Out - - - rotation - - - - - 3 - - - Out - - - rotation - - - - - 3 - - - Out - - - rotation - - - - - 3 - - - T_FF - - - valueIsProbe - true - - - Label - Q_0 - - - - 0 - - - T_FF - - - valueIsProbe - true - - - Label - Q_1 - - - - 0 - - - T_FF - - - valueIsProbe - true - - - Label - Q_2 - - - - 0 - - - T_FF - - - valueIsProbe - true - - - Label - Q_3 - - - - 0 - - - Data - - - microStep - true - - - Label - Data - - - - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 1 + + + Out + + + rotation + + + + + 3 + + + Clock + + + Label + C + + + Frequency + 2 + + + + 0 + + + Out + + + rotation + + + + + 3 + + + Out + + + rotation + + + + + 3 + + + Out + + + rotation + + + + + 3 + + + T_FF + + + valueIsProbe + true + + + Label + Q_0 + + + + 0 + + + T_FF + + + valueIsProbe + true + + + Label + Q_1 + + + + 0 + + + T_FF + + + valueIsProbe + true + + + Label + Q_2 + + + + 0 + + + T_FF + + + valueIsProbe + true + + + Label + Q_3 + + + + 0 + + + Data + + + microStep + true + + + Label + Data + + + + 0 + + + Text + + + Label + Asynchroner Zähler aus T-Flipflops + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file 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 5dc4e916c..125cbc42d 100644 --- a/src/main/java/de/neemann/digital/draw/graphics/GraphicSVG.java +++ b/src/main/java/de/neemann/digital/draw/graphics/GraphicSVG.java @@ -79,36 +79,38 @@ public class GraphicSVG implements Graphic, Closeable { @Override public void drawLine(Vector p1, Vector p2, Style style) { - try { - w.write("\n"); - } catch (IOException e) { - throw new RuntimeException(e); - } + w.write(" />\n"); + } catch (IOException e) { + throw new RuntimeException(e); + } } @Override public void drawPolygon(Polygon p, Style style) { - try { - w.write("\n"); - else - w.write(" stroke=\"" + getColor(style) + "\" stroke-width=\"" + getStrokeWidth(style) + "\" fill=\"none\"/>\n"); - } catch (IOException e) { - throw new RuntimeException(e); - } + if (style.isFilled() && p.isClosed()) + w.write(" stroke=\"" + getColor(style) + "\" stroke-width=\"" + getStrokeWidth(style) + "\" fill=\"" + getColor(style) + "\"/>\n"); + else + w.write(" stroke=\"" + getColor(style) + "\" stroke-width=\"" + getStrokeWidth(style) + "\" fill=\"none\"/>\n"); + } catch (IOException e) { + throw new RuntimeException(e); + } } private static double getStrokeWidth(Style style) { @@ -117,20 +119,21 @@ public class GraphicSVG implements Graphic, Closeable { @Override public void drawCircle(Vector p1, Vector p2, Style style) { - try { - Vector c = p1.add(p2).div(2); - double r = Math.abs(p2.sub(p1).x) / 2.0; - if (style.isFilled()) - w.write("\n"); - else { - w.write("\n"); + else { + w.write("\n"); + w.write(" />\n"); + } + } catch (IOException e) { + throw new RuntimeException(e); } - } catch (IOException e) { - throw new RuntimeException(e); - } } @Override diff --git a/src/main/java/de/neemann/digital/draw/graphics/GraphicSwing.java b/src/main/java/de/neemann/digital/draw/graphics/GraphicSwing.java index 857822381..96a08c3a9 100644 --- a/src/main/java/de/neemann/digital/draw/graphics/GraphicSwing.java +++ b/src/main/java/de/neemann/digital/draw/graphics/GraphicSwing.java @@ -27,28 +27,32 @@ public class GraphicSwing implements Graphic { @Override public void drawLine(Vector p1, Vector p2, Style style) { - applyStyle(style); - gr.drawLine(p1.x, p1.y, p2.x, p2.y); + if (style != Style.INVISIBLE) { + applyStyle(style); + gr.drawLine(p1.x, p1.y, p2.x, p2.y); + } } @Override public void drawPolygon(Polygon p, Style style) { - applyStyle(style); - Path2D path = new GeneralPath(); - boolean first = true; - for (Vector v : p) - if (first) { - first = false; - path.moveTo(v.x, v.y); - } else - path.lineTo(v.x, v.y); + if (style != Style.INVISIBLE) { + applyStyle(style); + Path2D path = new GeneralPath(); + boolean first = true; + for (Vector v : p) + if (first) { + first = false; + path.moveTo(v.x, v.y); + } else + path.lineTo(v.x, v.y); - if (p.isClosed()) - path.closePath(); + if (p.isClosed()) + path.closePath(); - if (style.isFilled()) - gr.fill(path); - gr.draw(path); + if (style.isFilled()) + gr.fill(path); + gr.draw(path); + } } @Override 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 ca294db89..6aa3e571c 100644 --- a/src/main/java/de/neemann/digital/draw/graphics/Style.java +++ b/src/main/java/de/neemann/digital/draw/graphics/Style.java @@ -19,6 +19,7 @@ public class Style { public static final Style DASH = new Style(1, false, Color.BLACK, new float[]{4, 4}); public static final Style SHAPE_PIN = new Style(4, false, Color.GRAY, 18, null); public static final Style HIGHLIGHT = new Style(4, false, Color.CYAN); + public static final Style INVISIBLE = new Style(0, false, Color.WHITE); private final int thickness; private final boolean filled; diff --git a/src/main/java/de/neemann/digital/draw/library/ElementLibrary.java b/src/main/java/de/neemann/digital/draw/library/ElementLibrary.java index 9c0aabdf1..5392c476d 100644 --- a/src/main/java/de/neemann/digital/draw/library/ElementLibrary.java +++ b/src/main/java/de/neemann/digital/draw/library/ElementLibrary.java @@ -51,6 +51,7 @@ public class ElementLibrary implements Iterable add(Out.SEVENHEXDESCRIPTION, menu); add(Terminal.DESCRIPTION, menu); add(DummyElement.DATADESCRIPTION, menu); + add(DummyElement.TEXTDESCRIPTION, menu); menu = Lang.get("lib_mux"); add(Multiplexer.DESCRIPTION, menu); diff --git a/src/main/java/de/neemann/digital/draw/shapes/OutputPinInfo.java b/src/main/java/de/neemann/digital/draw/shapes/OutputPinInfo.java deleted file mode 100644 index 84950b7d1..000000000 --- a/src/main/java/de/neemann/digital/draw/shapes/OutputPinInfo.java +++ /dev/null @@ -1,24 +0,0 @@ -package de.neemann.digital.draw.shapes; - -import de.neemann.digital.draw.elements.Pin; - -/** - * @author hneemann - */ -public class OutputPinInfo { - private final String name; - private final Pin.Direction direction; - - public OutputPinInfo(String name, boolean bidirectional) { - this.name = name; - this.direction = bidirectional ? Pin.Direction.both : Pin.Direction.output; - } - - public String getName() { - return name; - } - - public Pin.Direction getDirection() { - return direction; - } -} diff --git a/src/main/java/de/neemann/digital/draw/shapes/ShapeFactory.java b/src/main/java/de/neemann/digital/draw/shapes/ShapeFactory.java index f1a28bbb8..ea5c1e2e1 100644 --- a/src/main/java/de/neemann/digital/draw/shapes/ShapeFactory.java +++ b/src/main/java/de/neemann/digital/draw/shapes/ShapeFactory.java @@ -60,6 +60,8 @@ public final class ShapeFactory { map.put(Splitter.DESCRIPTION.getName(), SplitterShape::new); map.put(Driver.DESCRIPTION.getName(), DriverShape::new); + + map.put(DummyElement.TEXTDESCRIPTION.getName(), TextShape::new); } private PinDescription[] outputInfos(ElementTypeDescription description, ElementAttributes attributes) { diff --git a/src/main/java/de/neemann/digital/draw/shapes/TextShape.java b/src/main/java/de/neemann/digital/draw/shapes/TextShape.java new file mode 100644 index 000000000..7304bcc5c --- /dev/null +++ b/src/main/java/de/neemann/digital/draw/shapes/TextShape.java @@ -0,0 +1,52 @@ +package de.neemann.digital.draw.shapes; + +import de.neemann.digital.core.Observer; +import de.neemann.digital.core.element.ElementAttributes; +import de.neemann.digital.draw.elements.IOState; +import de.neemann.digital.draw.elements.Pins; +import de.neemann.digital.draw.graphics.*; +import de.neemann.digital.lang.Lang; + +/** + * Simple text + * + * @author hneemann + */ +public class TextShape implements Shape { + private final String label; + + /** + * Create a new instance + * + * @param attr attributes + */ + public TextShape(ElementAttributes attr) { + String text = attr.getLabel(); + if (text.length() == 0) + text = Lang.get("elem_Text"); + this.label = text; + + } + + @Override + public Pins getPins() { + return new Pins(); + } + + @Override + public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) { + return null; + } + + @Override + public void drawTo(Graphic graphic, boolean highLight) { + int size = Style.NORMAL.getFontSize(); + graphic.drawPolygon( + new Polygon(true) + .add(0, 0) + .add(size * 2, 0) + .add(size * 2, size) + .add(0, size), Style.INVISIBLE); + graphic.drawText(new Vector(0, 0), new Vector(1, 0), label, Orientation.LEFTTOP, Style.NORMAL); + } +} diff --git a/src/main/java/de/neemann/digital/gui/components/data/DummyElement.java b/src/main/java/de/neemann/digital/gui/components/data/DummyElement.java index a0fb3e0dc..082d1e536 100644 --- a/src/main/java/de/neemann/digital/gui/components/data/DummyElement.java +++ b/src/main/java/de/neemann/digital/gui/components/data/DummyElement.java @@ -22,6 +22,12 @@ public class DummyElement implements Element { public static final ElementTypeDescription DATADESCRIPTION = new ElementTypeDescription("Data", DummyElement.class) .addAttribute(AttributeKey.MicroStep); + /** + * The TextElement description + */ + public static final ElementTypeDescription TEXTDESCRIPTION = new ElementTypeDescription("Text", DummyElement.class) + .addAttribute(AttributeKey.Label); + /** * Creates a new dummy element * diff --git a/src/main/resources/lang/lang_de.properties b/src/main/resources/lang/lang_de.properties index f2b48e13d..f2066f001 100644 --- a/src/main/resources/lang/lang_de.properties +++ b/src/main/resources/lang/lang_de.properties @@ -96,6 +96,7 @@ elem_Reset_tt=Der Ausgang dieses Elements ist Null, solange sich das Model nach elem_Break_tt=Wenn der Eingang dieses Elementes zu Eins wird, wird der schnelle Simulationslauf beendet.\nDieses Element kann verwendet werden, um einen Assemblerbefehl BRK zu implementieren.\nEs kann dann ein Programm bis zum n\u00E4chsten BRK-Befehl ausgef\u00FChrt werden. elem_RAMDualPort_tt=Ein RAM Modul mit getrennten Anschl\u00FCssen f\u00FCr Lesen und Schreiben.\nEin gibt einen Eingang f\u00FCr das Beschreiben und einen Ausgang f\u00FCr das Auslesen der gespeicherten Daten. elem_RAMSinglePort_tt=Ein RAM Module mit einem bidirektionellem Anschluss f\u00FCr das Lesen und Schreiben von Daten. +elem_Text=Text rot_0=0\u00B0 rot_90=90\u00B0 diff --git a/src/main/resources/lang/lang_en.properties b/src/main/resources/lang/lang_en.properties index 10230b16f..e0759ccea 100644 --- a/src/main/resources/lang/lang_en.properties +++ b/src/main/resources/lang/lang_en.properties @@ -96,6 +96,7 @@ elem_Add=Add elem_Sub=Sub elem_Mul=Mul elem_Comparator=Comparator +elem_Text=Text rot_0=0\u00B0 rot_90=90\u00B0