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());
|
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
|
* Subtracts the given vector
|
||||||
*
|
*
|
||||||
@ -161,4 +172,5 @@ public class VectorFloat implements VectorInterface {
|
|||||||
public VectorFloat getOrthogonal() {
|
public VectorFloat getOrthogonal() {
|
||||||
return new VectorFloat(y, -x);
|
return new VectorFloat(y, -x);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -173,21 +173,30 @@ public class Transition extends Movable<Transition> {
|
|||||||
.add(end.add(dir).sub(lot)), arrowStyle);
|
.add(end.add(dir).sub(lot)), arrowStyle);
|
||||||
|
|
||||||
// text
|
// text
|
||||||
VectorFloat textPos = getPos();
|
ArrayList<String> strings = new ArrayList<>();
|
||||||
final int fontSize = Style.NORMAL.getFontSize();
|
if (condition != null && !condition.isEmpty())
|
||||||
if (fromState.getPos().getYFloat() < getPos().getYFloat()
|
strings.add(condition);
|
||||||
&& toState.getPos().getYFloat() < getPos().getYFloat())
|
if (getValues() != null && !getValues().isEmpty())
|
||||||
textPos = textPos.add(new VectorFloat(0, fontSize / 2f));
|
strings.add(Lang.get("fsm_set_N", getValues()));
|
||||||
if (fromState.getPos().getYFloat() > getPos().getYFloat()
|
|
||||||
&& toState.getPos().getYFloat() > getPos().getYFloat())
|
|
||||||
textPos = textPos.add(new VectorFloat(0, -fontSize / 2f));
|
|
||||||
|
|
||||||
if (condition != null && condition.length() > 0) {
|
if (!strings.isEmpty()) {
|
||||||
gr.drawText(textPos, textPos.add(new Vector(1, 0)), condition, Orientation.CENTERCENTER, Style.INOUT);
|
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);
|
||||||
}
|
}
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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">Zustandsnummer</string>
|
||||||
<string name="key_stateNum_tt">Die Nummer welche diesen Zustand representiert.</string>
|
<string name="key_stateNum_tt">Die Nummer welche diesen Zustand representiert.</string>
|
||||||
<string name="key_stateValues">Ausgänge</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 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>
|
||||||
<string name="key_transCond">Bedingung</string>
|
<string name="key_transCond">Bedingung</string>
|
||||||
<string name="key_transCond_tt">Ein boolscher Ausdruck.</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">State Number</string>
|
||||||
<string name="key_stateNum_tt">The number which represents this state.</string>
|
<string name="key_stateNum_tt">The number which represents this state.</string>
|
||||||
<string name="key_stateValues">Outputs</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.
|
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">Condition</string>
|
||||||
<string name="key_transCond_tt">A boolean expression.</string>
|
<string name="key_transCond_tt">A boolean expression.</string>
|
||||||
<string name="key_transRad">Radius</string>
|
<string name="key_transRad">Radius</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user