1
0
mirror of https://github.com/klmp200/sarl-fireworks.git synced 2024-11-25 02:24:28 +00:00

Rewriting anonymous class and ambiguous variable names

This commit is contained in:
ngaud 2017-05-02 17:22:16 +02:00
parent 73f349ae0b
commit 9890daffc8

View File

@ -1,32 +1,29 @@
package io.sarl.demos.fireworks.gui;
import java.util.UUID;
import io.sarl.demos.fireworks.Firework;
import io.sarl.demos.fireworks.Positions;
import io.sarl.demos.fireworks.events.CreateArea;
import io.sarl.demos.fireworks.events.Exit;
import io.sarl.demos.fireworks.events.Freeze;
import io.sarl.demos.fireworks.events.SetupSettings;
import io.sarl.lang.core.Event;
import io.sarl.lang.core.EventListener;
import io.sarl.util.OpenEventSpace;
import javafx.animation.PauseTransition;
import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.^event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollBar;
import javafx.util.Duration;
import io.sarl.demos.fireworks.Firework
import io.sarl.demos.fireworks.Positions
import io.sarl.demos.fireworks.events.CreateArea
import io.sarl.demos.fireworks.events.Exit
import io.sarl.demos.fireworks.events.Freeze
import io.sarl.demos.fireworks.events.SetupSettings
import io.sarl.lang.core.Event
import io.sarl.lang.core.EventListener
import io.sarl.util.OpenEventSpace
import java.util.UUID
import javafx.animation.PauseTransition
import javafx.application.Platform
import javafx.^event.ActionEvent
import javafx.fxml.FXML
import javafx.scene.canvas.Canvas
import javafx.scene.canvas.GraphicsContext
import javafx.scene.control.Button
import javafx.scene.control.Label
import javafx.scene.control.ScrollBar
import javafx.util.Duration
class FXMLViewerController implements EventListener {
private var ^space : OpenEventSpace;
private var ispace : OpenEventSpace;
private val id : UUID = UUID.randomUUID();
private var launched : boolean = false;
@ -57,13 +54,13 @@ class FXMLViewerController implements EventListener {
private var stop_button : Button;
public def cleanExit() {
if (this.^space !== null)
this.^space.emit(new Exit());
if (this.ispace !== null)
this.ispace.emit(new Exit());
}
public def setGUISpace(ispace : OpenEventSpace) {
this.^space = ispace;
this.^space.register(this);
this.ispace = ispace;
this.ispace.register(this);
}
public def getGravity() : double {
@ -108,12 +105,12 @@ class FXMLViewerController implements EventListener {
@FXML
public def exitApplication(ievent : ActionEvent) {
^space.emit(new Exit());
ispace.emit(new Exit());
Platform.exit();
}
@FXML protected def actionSetup() {
var ^event : SetupSettings = new SetupSettings(this.getRocketQuantity(), this.getFireQuantity(),
var ievent : SetupSettings = new SetupSettings(this.getRocketQuantity(), this.getFireQuantity(),
this.getGravity(), this.draw_zone.getWidth());
if (!launched) {
launch_button.setDisable(false);
@ -121,7 +118,7 @@ class FXMLViewerController implements EventListener {
launched = true;
areaCreated = false;
}
this.^space.emit(^event);
this.ispace.emit(ievent);
}
@FXML
@ -130,10 +127,10 @@ class FXMLViewerController implements EventListener {
stop_button.setDisable(false);
setup_button.setDisable(true);
if (!areaCreated) {
this.^space.emit(new CreateArea());
this.ispace.emit(new CreateArea());
this.areaCreated = true;
} else {
this.^space.emit(new Freeze(false));
this.ispace.emit(new Freeze(false));
}
}
@ -142,46 +139,37 @@ class FXMLViewerController implements EventListener {
stop_button.setDisable(true);
launch_button.setDisable(false);
setup_button.setDisable(false);
this.^space.emit(new Freeze(true));
this.ispace.emit(new Freeze(true));
}
@FXML
protected def actionGravityDisplay() {
gravity_input.valueProperty().addListener(new ChangeListener<Number>() {
public def changed(ov : ObservableValue<? extends Number>, old_val : Number, new_val : Number) {
gravity_display.setText(String.format("%.1f", gravity_input.getValue()));
}
});
gravity_input.valueProperty().addListener [
gravity_display.setText(String.format("%.1f", gravity_input.getValue()));
]
}
@FXML
protected def actionRocketQuantityDisplay() {
rocket_quantity_input.valueProperty().addListener(new ChangeListener<Number>() {
public def changed(ov : ObservableValue<? extends Number>, old_val : Number, new_val : Number) {
rocket_quantity_display.setText(String.format("%.0f", rocket_quantity_input.getValue()));
}
});
rocket_quantity_input.valueProperty().addListener [
rocket_quantity_display.setText(String.format("%.0f", rocket_quantity_input.getValue()));
];
}
@FXML
protected def actionFireQuantityDisplay() {
fire_quantity_input.valueProperty().addListener(new ChangeListener<Number>() {
public def changed(ov : ObservableValue<? extends Number>, old_val : Number, new_val : Number) {
fire_quantity_display.setText(String.format("%.0f", fire_quantity_input.getValue()));
}
});
fire_quantity_input.valueProperty().addListener [
fire_quantity_display.setText(String.format("%.0f", fire_quantity_input.getValue()));
]
}
@Override
public def getID() : UUID {
// TODO Auto-generated method stub
return this.id;
}
@Override
public def receiveEvent(^event : Event) {
public def receiveEvent(ievent : Event) {
/*
* if (event instanceof TestEvent){
* System.out.println("Guy recieved an event " + ((TestEvent) event).message);