diff --git a/src/main/java/de/neemann/digital/draw/graphics/VectorFloat.java b/src/main/java/de/neemann/digital/draw/graphics/VectorFloat.java index d6467a7d7..cd583a770 100644 --- a/src/main/java/de/neemann/digital/draw/graphics/VectorFloat.java +++ b/src/main/java/de/neemann/digital/draw/graphics/VectorFloat.java @@ -71,6 +71,17 @@ public class VectorFloat implements VectorInterface { return new VectorFloat(x + a.getXFloat(), y + a.getYFloat()); } + /** + * Creates a new vector which has the value this+(dx,dy) + * + * @param dx dx + * @param dy dy + * @return this+(dx,dy) + */ + public VectorFloat add(float dx, float dy) { + return new VectorFloat(x + dx, y + dy); + } + /** * Subtracts the given vector * @@ -161,4 +172,5 @@ public class VectorFloat implements VectorInterface { public VectorFloat getOrthogonal() { return new VectorFloat(y, -x); } + } diff --git a/src/main/java/de/neemann/digital/fsm/Transition.java b/src/main/java/de/neemann/digital/fsm/Transition.java index b4c5277c1..ec02d5f2e 100644 --- a/src/main/java/de/neemann/digital/fsm/Transition.java +++ b/src/main/java/de/neemann/digital/fsm/Transition.java @@ -173,21 +173,30 @@ public class Transition extends Movable { .add(end.add(dir).sub(lot)), arrowStyle); // text - VectorFloat textPos = getPos(); - final int fontSize = Style.NORMAL.getFontSize(); - if (fromState.getPos().getYFloat() < getPos().getYFloat() - && toState.getPos().getYFloat() < getPos().getYFloat()) - textPos = textPos.add(new VectorFloat(0, fontSize / 2f)); - if (fromState.getPos().getYFloat() > getPos().getYFloat() - && toState.getPos().getYFloat() > getPos().getYFloat()) - textPos = textPos.add(new VectorFloat(0, -fontSize / 2f)); + ArrayList strings = new ArrayList<>(); + if (condition != null && !condition.isEmpty()) + strings.add(condition); + if (getValues() != null && !getValues().isEmpty()) + strings.add(Lang.get("fsm_set_N", getValues())); - if (condition != null && condition.length() > 0) { - gr.drawText(textPos, textPos.add(new Vector(1, 0)), condition, Orientation.CENTERCENTER, Style.INOUT); - } - if (getValues() != null && getValues().length() > 0) { - textPos = textPos.add(new VectorFloat(0, fontSize)); - gr.drawText(textPos, textPos.add(new Vector(1, 0)), Lang.get("fsm_set_N", getValues()), Orientation.CENTERCENTER, Style.INOUT); + if (!strings.isEmpty()) { + final int fontSize = Style.NORMAL.getFontSize(); + VectorFloat textPos = getPos().add(0, -fontSize * (strings.size() - 1) / 2f); + + if (fromState.getPos().getYFloat() < getPos().getYFloat() + && toState.getPos().getYFloat() < getPos().getYFloat()) { + textPos = textPos.add(new VectorFloat(0, fontSize * strings.size() / 2f)); + } + + if (fromState.getPos().getYFloat() > getPos().getYFloat() + && toState.getPos().getYFloat() > getPos().getYFloat()) { + textPos = textPos.add(new VectorFloat(0, -fontSize * strings.size() / 2f)); + } + + for (String s : strings) { + gr.drawText(textPos, textPos.add(new Vector(1, 0)), s, Orientation.CENTERCENTER, Style.INOUT); + textPos = textPos.add(0, fontSize); + } } } diff --git a/src/main/resources/lang/lang_de.xml b/src/main/resources/lang/lang_de.xml index d50f91e34..eacb7f2d6 100644 --- a/src/main/resources/lang/lang_de.xml +++ b/src/main/resources/lang/lang_de.xml @@ -1778,8 +1778,11 @@ Daher steht auch das Signal 'D_out' zur Verfügung, um in diesem Fall den Wert z Zustandsnummer Die Nummer welche diesen Zustand representiert. Ausgänge - Legt Ausgangswerte fest. Wird nichts angegeben, werden alle Werte auf Null gesetzt. + Legt Ausgangswerte fest. Mit einfachen Zuweisungen wie "A=1, B=0" können Ausgänge gesetzt werden. + Mit Anweisungen wie "A=101" können mehrbittige Ausgänge gesetzt werden. + Ausgänge die hier nicht definiert werden, werden bei Zuständen auf Null gesetzt. + Bei Übergängen bleiben nicht angegebene Ausgänge unverändert. Bedingung Ein boolscher Ausdruck. diff --git a/src/main/resources/lang/lang_en.xml b/src/main/resources/lang/lang_en.xml index 45326f173..96a06425a 100644 --- a/src/main/resources/lang/lang_en.xml +++ b/src/main/resources/lang/lang_en.xml @@ -1763,9 +1763,11 @@ Therefore, the signal 'D_out' is also available to check the value in this case. State Number The number which represents this state. Outputs - Defines the output values. If nothing is specified, all values are set to zero. + Defines the output values. With simple assignments like "A=1, B=0" outputs can be set. - + With instructions like "A=101", multi-bit outputs can be set. + Outputs that are not defined here are set to zero in states. + For transitions, unspecified outputs remain unchanged. Condition A boolean expression. Radius