diff --git a/src/javafx/Controller.java b/src/javafx/Controller.java index b930ae0..898faed 100644 --- a/src/javafx/Controller.java +++ b/src/javafx/Controller.java @@ -78,15 +78,7 @@ public void initialize(URL location, ResourceBundle resources) { redo.setDisable(true); machine_DFA.setDisable(true); - history.setDisable(true); // todo - - open.setAccelerator(KeyCombination.keyCombination("SHORTCUT+O")); - save.setAccelerator(KeyCombination.keyCombination("SHORTCUT+S")); - undo.setAccelerator(KeyCombination.keyCombination("SHORTCUT+Z")); - redo.setAccelerator(KeyCombination.keyCombination("SHORTCUT+Y")); close.setAccelerator(KeyCombination.keyCombination("Esc")); - deleteSelection.setAccelerator(KeyCombination.keyCombination("Del")); - selectAllStates.setAccelerator(KeyCombination.keyCombination("SHORTCUT+A")); colourPicker_state.setValue(PFLAP.stateColour); colourPicker_stateSelected.setValue(PFLAP.stateSelectedColour); @@ -143,6 +135,23 @@ private void open() { File f = fileChooser.showOpenDialog(stage); if (f != null) { HistoryHandler.loadHistory(f.getAbsolutePath()); + machineMenu.getItems().forEach(m -> m.setDisable(false)); + switch (PFLAP.mode) { + case DFA : + machine_DFA.setDisable(true); + break; + case DPA : + machine_DPA.setDisable(true); + break; + case MEALY : + machine_mealy.setDisable(true); + break; + case MOORE : + machine_moore.setDisable(true); + break; + default : + break; + } } } @@ -210,6 +219,11 @@ private void invertSelection() { /* * View Menu */ + + @FXML + private void fullscreen() { + stage.setFullScreen(!stage.isFullScreen()); + } @FXML private void resetZoom() { diff --git a/src/javafx/PFLAP.fxml b/src/javafx/PFLAP.fxml index a707008..b398531 100644 --- a/src/javafx/PFLAP.fxml +++ b/src/javafx/PFLAP.fxml @@ -1,10 +1,12 @@ + + @@ -15,8 +17,14 @@ - - + + + + + + + + @@ -24,24 +32,43 @@ - - + + + + + + + - - + + + + + + + + + + + + + - + + + + diff --git a/src/main/HistoryList.java b/src/main/HistoryList.java index 2c6df99..cbbdee5 100644 --- a/src/main/HistoryList.java +++ b/src/main/HistoryList.java @@ -2,41 +2,33 @@ import static main.Functions.colorToRGB; +import commands.Command; import controlP5.CallbackEvent; import controlP5.CallbackListener; -import controlP5.ControlP5; import controlP5.ListBox; -import main.PFLAP.PApplet; /** * Manages the controlP5 representation of the user's action history. * @author micycle1 - * @deprecated */ public final class HistoryList { - // private static final ControlP5 cP5; - // private static final DropdownList history; - - private PApplet p; - private ControlP5 cp5; private ListBox history; - public HistoryList(PApplet p) { - cp5 = new ControlP5(p); - cp5.hide(); + public HistoryList() { // @formatter:off - history = cp5.addListBox("HistoryList") - .setWidth(160) + history = PFLAP.cp5.addListBox("History") + .setWidth(240) .setColorBackground(colorToRGB(50, 50, 50)) .setColorForeground(colorToRGB(50, 50, 50)) .setBarHeight(30) .setItemHeight(20) .setHeight(200) + .hide() .addCallback(new CallbackListener() { @Override public void controlEvent(CallbackEvent theEvent) { - if (theEvent.getAction() == 100) { // clicked + if (theEvent.getAction() == 100 && PFLAP.allowGUIInterraction) { // clicked HistoryHandler.movetoIndex((int) history.getValue() - 1); } } @@ -51,19 +43,18 @@ public void controlEvent(CallbackEvent theEvent) { protected void update() { history.clear(); history.open(); - // history.addItem("{Init}", null); - // for (Command c : HistoryHandler.export()) { - // history.addItem(c.description(), c); - // } - history.addItem("asds", null); + history.addItem("{Init}", null); + for (Command c : HistoryHandler.export()) { + history.addItem(c.description(), c); + } } protected boolean isMouseOver() { - return cp5.isMouseOver(); + return history.isMouseOver(); } public void toggleVisible() { - cp5.setVisible(!cp5.isVisible()); + history.setVisible(!history.isVisible()); history.open(); } diff --git a/src/main/PFLAP.java b/src/main/PFLAP.java index 0ca0007..1a19eea 100644 --- a/src/main/PFLAP.java +++ b/src/main/PFLAP.java @@ -44,10 +44,7 @@ /** * @author micycle1 - * @version 1.3 - * history list broken - * fix lambda/space functionality - * self-arrows broken w/ big size states + * @version 1.5 */ public final class PFLAP { @@ -90,7 +87,7 @@ public final static class PApplet extends processing.core.PApplet { private static PFont comfortaaRegular, comfortaaBold; private static State mouseOverState, arrowTailState, arrowHeadState, dragState; private static SelectionBox selectionBox; - private static boolean fullScreen = false, newState = false, drawingArrow = false, reset = false; + private static boolean newState = false, drawingArrow = false, reset = false; private static PVector mouseClickXY, mouseReleasedXY, mouseCoords, zoomPanOffsetp; private static ZoomPan zoomPan; private static ArrayList multiMoveCache; @@ -174,7 +171,7 @@ public void setup() { cp5.setFont(PFLAP.cp5Font); mode = modes.DFA; view = new View(this); - historyList = new HistoryList(this); + historyList = new HistoryList(); zoomPanScalep = zoomPan.getZoomScale(); zoomPanOffsetp = zoomPan.getPanOffset(); @@ -282,6 +279,7 @@ public static void reset() { default : break; } + historyList.update(); reset = false; } @@ -312,8 +310,6 @@ public void keyPressed(KeyEvent e) { case RIGHT : Step.stepForward(); break; - case CONTROL : - allowGUIInterraction = false; default : break; } @@ -323,31 +319,10 @@ public void keyPressed(KeyEvent e) { @Override public void keyReleased(KeyEvent key) { - if (keysDown.contains(CONTROL)) { - switch (key.getKey()) { - case 'H' : - historyList.toggleVisible(); - break; - default : - break; - } - } switch (key.getKeyCode()) { case 127 : // 127 == delete key deleteSelection(); break; - case 122 : // F11 - if (fullScreen) { - surface.setSize(Consts.WIDTH, Consts.HEIGHT); - surface.setLocation(displayWidth / 2 - width / 2, displayHeight / 2 - height / 2); - } else { - surface.setSize(displayWidth, displayHeight); - surface.setLocation(0, 0); - } - fullScreen = !fullScreen; - break; - case CONTROL : - allowGUIInterraction = true; default : break; } diff --git a/src/p5/AbstractArrow.java b/src/p5/AbstractArrow.java index 45b6780..bbac566 100644 --- a/src/p5/AbstractArrow.java +++ b/src/p5/AbstractArrow.java @@ -106,6 +106,11 @@ protected final void drawTransitionLabel(PVector pos) { p.fill(0); p.text(transitionInfo, pos.x, pos.y); } + + protected final void drawTransitionLabel(float xPos, float yPos) { + p.fill(0); + p.text(transitionInfo, xPos, yPos); + } protected final void drawArrowTip(PVector translate, float angle) { p.noFill(); diff --git a/src/p5/BezierArrow.java b/src/p5/BezierArrow.java index 2167781..c97b584 100644 --- a/src/p5/BezierArrow.java +++ b/src/p5/BezierArrow.java @@ -18,7 +18,7 @@ public class BezierArrow extends AbstractArrow { private float textSize, arrowTipAngle, theta2; private PVector bezierCPoint, bezierApex, arrowTip, midPoint; - + public BezierArrow(State head, State tail, ArrayList t) { super(head, tail, t); } @@ -36,7 +36,7 @@ public void update() { arrowTipAngle = angleBetween(head.getPosition(), bezierApex); arrowTip = new PVector(head.getPosition().x + (head.getRadius() + 3) * -0.5f * cos(arrowTipAngle), head.getPosition().y + (head.getRadius() + 3) * -0.5f * sin(arrowTipAngle)); -// transitionSymbolEntry.setPosition(bezierApex.x - transitionSymbolEntry.getWidth() / 2, bezierApex.y + 10); + // transitionSymbolEntry.setPosition(bezierApex.x - transitionSymbolEntry.getWidth() / 2, bezierApex.y + 10); stateOptions.setPosition(bezierApex.x, bezierApex.y + 10); } @@ -48,7 +48,7 @@ public void draw() { drawArrowTip(arrowTip, arrowTipAngle); p.textAlign(PConstants.CENTER, PConstants.TOP); p.textSize(textSize); - drawTransitionLabel(bezierApex); + drawTransitionLabel(bezierApex.x, bezierApex.y - textSize / 2); } @Override diff --git a/src/p5/SelfArrow.java b/src/p5/SelfArrow.java index 0693b90..3690977 100644 --- a/src/p5/SelfArrow.java +++ b/src/p5/SelfArrow.java @@ -12,6 +12,7 @@ import java.util.ArrayList; import model.LogicalTransition; +import processing.core.PApplet; import processing.core.PConstants; import processing.core.PVector; @@ -30,12 +31,16 @@ public SelfArrow(State s, ArrayList t) { @Override public void update() { textSize = 24; + int offset = PApplet.max(head.getRadius() - main.Consts.stateRadius, 0); + offset = 0; + selfBezierCP1 = new PVector( + head.getPosition().x + (selfTransitionLength + offset) * sin(selfTransitionAngle), + head.getPosition().y + (selfTransitionLength + offset) * cos(selfTransitionAngle)); - selfBezierCP1 = new PVector(head.getPosition().x + selfTransitionLength * sin(selfTransitionAngle), - head.getPosition().y + selfTransitionLength * cos(selfTransitionAngle)); selfBezierCP2 = new PVector( - head.getPosition().x + selfTransitionLength * sin(selfTransitionAngle + radians(45)), - head.getPosition().y + selfTransitionLength * cos(selfTransitionAngle + radians(45))); + head.getPosition().x + (selfTransitionLength + offset) * sin(selfTransitionAngle + radians(45)), + head.getPosition().y + (selfTransitionLength + offset) * cos(selfTransitionAngle + radians(45))); + selfBezierTranslate = new PVector(head.getPosition().x + head.getRadius() / 2 * sin(selfTransitionAngle), head.getPosition().y + head.getRadius() / 2 * cos(selfTransitionAngle)); selfBezierAngle = angleBetween(head.getPosition(), selfBezierCP1) - 0.3f; @@ -44,8 +49,6 @@ public void update() { + 15 * sin(selfTransitionAngle), p.bezierPoint(head.getPosition().y, selfBezierCP1.y, selfBezierCP2.y, head.getPosition().y, 0.5f) + 15 * cos(selfTransitionAngle)); -// transitionSymbolEntry.setPosition(selfBezierTextLoc.x - transitionSymbolEntry.getWidth() / 2, -// selfBezierTextLoc.y + 10); stateOptions.setPosition(selfBezierTextLoc.x, selfBezierTextLoc.y + 10); } diff --git a/src/p5/State.java b/src/p5/State.java index 24674ee..33ef6be 100644 --- a/src/p5/State.java +++ b/src/p5/State.java @@ -66,6 +66,7 @@ public void controlEvent(CallbackEvent input) { rename.setFocus(false).hide(); rename.clear(); renameState = null; + PFLAP.allowGUIInterraction = true; } } }); @@ -130,6 +131,7 @@ public void controlEvent(ControlEvent optionSelected) { break; case 3 : // Relabel renameState = State.this; + PFLAP.allowGUIInterraction = false; rename.setPosition(position.x - rename.getWidth() / 2, position.y + 30); rename.setFocus(true); rename.show(); diff --git a/src/transitionView/View.java b/src/transitionView/View.java index 480353b..ec9ae6d 100644 --- a/src/transitionView/View.java +++ b/src/transitionView/View.java @@ -35,7 +35,7 @@ /** * Renders the view of the abstract transitions etc. - * handle initial & accepting state here , not in state class + * handle initial & accepting state here, not in state class * @author micycle1 */ public final class View {