mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-15 07:48:29 -04:00
improved formatting of fsm transitions
This commit is contained in:
parent
466e7809b8
commit
d098f15d6c
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -173,21 +173,30 @@ public class Transition extends Movable<Transition> {
|
||||
.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<String> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1778,8 +1778,11 @@ Daher steht auch das Signal 'D_out' zur Verfügung, um in diesem Fall den Wert z
|
||||
<string name="key_stateNum">Zustandsnummer</string>
|
||||
<string name="key_stateNum_tt">Die Nummer welche diesen Zustand representiert.</string>
|
||||
<string name="key_stateValues">Ausgänge</string>
|
||||
<string name="key_stateValues_tt">Legt Ausgangswerte fest. Wird nichts angegeben, werden alle Werte auf Null gesetzt.
|
||||
<string name="key_stateValues_tt">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.
|
||||
</string>
|
||||
<string name="key_transCond">Bedingung</string>
|
||||
<string name="key_transCond_tt">Ein boolscher Ausdruck.</string>
|
||||
|
@ -1763,9 +1763,11 @@ Therefore, the signal 'D_out' is also available to check the value in this case.
|
||||
<string name="key_stateNum">State Number</string>
|
||||
<string name="key_stateNum_tt">The number which represents this state.</string>
|
||||
<string name="key_stateValues">Outputs</string>
|
||||
<string name="key_stateValues_tt">Defines the output values. If nothing is specified, all values are set to zero.
|
||||
<string name="key_stateValues_tt">Defines the output values.
|
||||
With simple assignments like "A=1, B=0" outputs can be set.
|
||||
</string>
|
||||
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.</string>
|
||||
<string name="key_transCond">Condition</string>
|
||||
<string name="key_transCond_tt">A boolean expression.</string>
|
||||
<string name="key_transRad">Radius</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user