fixed a repaint bug

This commit is contained in:
hneemann 2018-11-24 18:48:55 +01:00
parent cbf66868b3
commit 37ddaf01f6
4 changed files with 13 additions and 25 deletions

View File

@ -20,7 +20,7 @@ public class State extends Movable {
private static final float REACH = 2000;
private int number = -1;
private String name = "";
private String name;
private int radius;
private String values = "";

View File

@ -31,7 +31,7 @@ public class TransitionTableCreator {
*
* @param fsm the fsm
*/
public TransitionTableCreator(FSM fsm) {
TransitionTableCreator(FSM fsm) {
this.states = fsm.getStates();
this.transitions = fsm.getTransitions();
}

View File

@ -49,7 +49,7 @@ public class FSMComponent extends JComponent {
/**
* Creates a new component
*/
public FSMComponent() {
FSMComponent() {
addMouseWheelListener(e -> {
Vector pos = getPosVector(e);
double f = Math.pow(0.9, e.getWheelRotation());
@ -70,7 +70,7 @@ public class FSMComponent extends JComponent {
public void mousePressed(MouseEvent e) {
pos = new Vector(e.getX(), e.getY());
final Vector posVector = getPosVector(e);
screenDrag=false;
screenDrag = false;
if (mouse.isPrimaryClick(e)) {
elementMoved = fsm.getMovable(posVector);
if (elementMoved != null)
@ -82,7 +82,7 @@ public class FSMComponent extends JComponent {
newTransitionFromState = (State) st;
repaint();
}
screenDrag=true;
screenDrag = true;
}
}
@ -151,10 +151,13 @@ public class FSMComponent extends JComponent {
@Override
public void actionPerformed(ActionEvent actionEvent) {
Movable element = fsm.getMovable(lastMousePos);
if (element instanceof State)
if (element instanceof State) {
fsm.remove((State) element);
else if (element instanceof Transition)
repaint();
} else if (element instanceof Transition) {
fsm.remove((Transition) element);
repaint();
}
}
}.setToolTip(Lang.get("menu_delete_tt"));
@ -240,7 +243,7 @@ public class FSMComponent extends JComponent {
/**
* Fits the FSM to the window
*/
public void fitFSM() {
void fitFSM() {
if (fsm != null) {
GraphicMinMax gr = new GraphicMinMax();
fsm.drawTo(gr);
@ -276,7 +279,7 @@ public class FSMComponent extends JComponent {
*
* @param f factor to scale
*/
public void scaleCircuit(double f) {
void scaleCircuit(double f) {
Vector dif = getPosVector(getWidth() / 2, getHeight() / 2);
transform.translate(dif.x, dif.y);
transform.scale(f, f);
@ -288,7 +291,7 @@ public class FSMComponent extends JComponent {
/**
* @return the element picked by the mouse
*/
public Movable getElementMoved() {
Movable getElementMoved() {
return elementMoved;
}

View File

@ -50,21 +50,6 @@ public class FSMFrame extends JFrame implements ClosingWindowListener.ConfirmSav
private File filename;
private boolean lastModified;
/**
* Use only for tests!
*
* @param givenFsm the fsm to visualize
*/
public FSMFrame(FSM givenFsm) {
this(null, givenFsm, createLibrary());
}
private static ElementLibrary createLibrary() {
ElementLibrary library = new ElementLibrary();
new ShapeFactory(library);
return library;
}
/**
* Creates a new instance
*