mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-15 15:58:41 -04:00
improved fsm formatting
This commit is contained in:
parent
eb27f23d7d
commit
3527de0839
@ -106,7 +106,7 @@ public class State extends Movable<State> {
|
||||
|
||||
if (getValues() != null && getValues().length() > 0) {
|
||||
pos = pos.add(delta);
|
||||
gr.drawText(pos, pos.add(new Vector(1, 0)), getValues(), Orientation.CENTERCENTER, Style.NORMAL);
|
||||
gr.drawText(pos, pos.add(new Vector(1, 0)), getValues(), Orientation.CENTERCENTER, Style.INOUT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -139,11 +139,11 @@ public class Transition extends Movable<Transition> {
|
||||
.add(arrowTip)
|
||||
.add(end.add(difTo.sub(lot).mul(0.2f))), arrowStyle);
|
||||
if (condition != null && condition.length() > 0) {
|
||||
gr.drawText(getPos(), getPos().add(new Vector(1, 0)), condition, Orientation.CENTERCENTER, Style.NORMAL);
|
||||
gr.drawText(getPos(), getPos().add(new Vector(1, 0)), condition, Orientation.CENTERCENTER, Style.INOUT);
|
||||
}
|
||||
if (getValues() != null && getValues().length() > 0) {
|
||||
VectorFloat pos = getPos().add(new VectorFloat(0, Style.NORMAL.getFontSize()));
|
||||
gr.drawText(pos, pos.add(new Vector(1, 0)), getValues(), Orientation.CENTERCENTER, Style.NORMAL);
|
||||
gr.drawText(pos, pos.add(new Vector(1, 0)), Lang.get("fsm_set_N", getValues()), Orientation.CENTERCENTER, Style.INOUT);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@ public class FSMComponent extends JComponent {
|
||||
private static final Key<Integer> KEY_RADIUS = new Key.KeyInteger("transRad", 70)
|
||||
.setComboBoxValues(50, 70, 90);
|
||||
private static final String DEL_ACTION = "myDelAction";
|
||||
private static final int MIN_NEW_TRANS_DIST = 10;
|
||||
|
||||
private Mouse mouse = Mouse.getMouse();
|
||||
|
||||
@ -47,6 +48,7 @@ public class FSMComponent extends JComponent {
|
||||
private FSM fsm;
|
||||
private Vector lastMousePos;
|
||||
private State newTransitionFromState;
|
||||
private Vector newTransitionStartPos;
|
||||
|
||||
/**
|
||||
* Creates a new component
|
||||
@ -64,7 +66,6 @@ public class FSMComponent extends JComponent {
|
||||
|
||||
MouseAdapter mouseListener = new MouseAdapter() {
|
||||
private boolean screenDrag;
|
||||
private Vector newTransitionStartPos;
|
||||
private Vector delta;
|
||||
private Vector pos;
|
||||
|
||||
@ -97,7 +98,7 @@ public class FSMComponent extends JComponent {
|
||||
elementMoved = null;
|
||||
if (newTransitionFromState != null) {
|
||||
final Vector posVector = getPosVector(mouseEvent);
|
||||
if (newTransitionStartPos.sub(posVector).len() > 10) {
|
||||
if (newTransitionStartPos.sub(posVector).len() > MIN_NEW_TRANS_DIST) {
|
||||
Movable target = fsm.getMovable(posVector);
|
||||
if (target instanceof State)
|
||||
fsm.add(new Transition(newTransitionFromState, (State) target, ""));
|
||||
@ -316,13 +317,17 @@ public class FSMComponent extends JComponent {
|
||||
fsm.drawTo(gr);
|
||||
|
||||
if (newTransitionFromState != null) {
|
||||
VectorFloat d = lastMousePos.sub(newTransitionFromState.getPos()).norm().mul(16f);
|
||||
VectorFloat a = d.getOrthogonal().norm().mul(8f);
|
||||
gr.drawPolygon(new Polygon(false)
|
||||
.add(lastMousePos.sub(d).add(a))
|
||||
.add(lastMousePos)
|
||||
.add(lastMousePos.sub(d).sub(a)), Style.NORMAL);
|
||||
gr.drawLine(newTransitionFromState.getPos(), lastMousePos.sub(d.mul(0.2f)), Style.NORMAL);
|
||||
final Vector dif = lastMousePos.sub(newTransitionStartPos);
|
||||
int max = Math.max(Math.abs(dif.x), Math.abs(dif.y));
|
||||
if (max > MIN_NEW_TRANS_DIST) {
|
||||
VectorFloat d = lastMousePos.sub(newTransitionFromState.getPos()).norm().mul(16f);
|
||||
VectorFloat a = d.getOrthogonal().norm().mul(8f);
|
||||
gr.drawPolygon(new Polygon(false)
|
||||
.add(lastMousePos.sub(d).add(a))
|
||||
.add(lastMousePos)
|
||||
.add(lastMousePos.sub(d).sub(a)), Style.SHAPE_PIN);
|
||||
gr.drawLine(newTransitionFromState.getPos(), lastMousePos.sub(d.mul(0.2f)), Style.SHAPE_PIN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1759,6 +1759,7 @@ Daher steht auch das Signal 'D_out' zur Verfügung, um in diesem Fall den Wert z
|
||||
<string name="fsm_noMove">keine Bewegung</string>
|
||||
<string name="fsm_moveTrans">Übergänge</string>
|
||||
<string name="fsm_moveStates">Übergänge+Zustände</string>
|
||||
<string name="fsm_set_N">setze {0}</string>
|
||||
<string name="menu_fsm">Endlicher Automat</string>
|
||||
<string name="menu_fsm_tt">Dialog für die Erstellung endlicher Automaten.</string>
|
||||
<string name="menu_fsm_create">Erzeugen</string>
|
||||
|
@ -1738,6 +1738,7 @@ Therefore, the signal 'D_out' is also available to check the value in this case.
|
||||
<string name="fsm_noMove">no movement</string>
|
||||
<string name="fsm_moveTrans">Transitions</string>
|
||||
<string name="fsm_moveStates">Transitions+States</string>
|
||||
<string name="fsm_set_N">set {0}</string>
|
||||
<string name="menu_fsm">Finite State Machine</string>
|
||||
<string name="menu_fsm_tt">Opens a Dialog to Edit a Finite State Machine.</string>
|
||||
<string name="menu_fsm_create">Create</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user