mirror of
				https://github.com/klmp200/sarl-fireworks.git
				synced 2025-10-31 00:53:12 +00:00 
			
		
		
		
	Rewriting anonymous class and ambiguous variable names
This commit is contained in:
		| @@ -1,32 +1,29 @@ | |||||||
| package io.sarl.demos.fireworks.gui; | 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.Firework; | import io.sarl.demos.fireworks.events.CreateArea | ||||||
| import io.sarl.demos.fireworks.Positions; | import io.sarl.demos.fireworks.events.Exit | ||||||
| import io.sarl.demos.fireworks.events.CreateArea; | import io.sarl.demos.fireworks.events.Freeze | ||||||
| import io.sarl.demos.fireworks.events.Exit; | import io.sarl.demos.fireworks.events.SetupSettings | ||||||
| import io.sarl.demos.fireworks.events.Freeze; | import io.sarl.lang.core.Event | ||||||
| import io.sarl.demos.fireworks.events.SetupSettings; | import io.sarl.lang.core.EventListener | ||||||
| import io.sarl.lang.core.Event; | import io.sarl.util.OpenEventSpace | ||||||
| import io.sarl.lang.core.EventListener; | import java.util.UUID | ||||||
| import io.sarl.util.OpenEventSpace; | import javafx.animation.PauseTransition | ||||||
| import javafx.animation.PauseTransition; | import javafx.application.Platform | ||||||
| import javafx.application.Platform; | import javafx.^event.ActionEvent | ||||||
| import javafx.beans.value.ChangeListener; | import javafx.fxml.FXML | ||||||
| import javafx.beans.value.ObservableValue; | import javafx.scene.canvas.Canvas | ||||||
| import javafx.^event.ActionEvent; | import javafx.scene.canvas.GraphicsContext | ||||||
| import javafx.fxml.FXML; | import javafx.scene.control.Button | ||||||
| import javafx.scene.canvas.Canvas; | import javafx.scene.control.Label | ||||||
| import javafx.scene.canvas.GraphicsContext; | import javafx.scene.control.ScrollBar | ||||||
| import javafx.scene.control.Button; | import javafx.util.Duration | ||||||
| import javafx.scene.control.Label; |  | ||||||
| import javafx.scene.control.ScrollBar; |  | ||||||
| import javafx.util.Duration; |  | ||||||
|  |  | ||||||
| class FXMLViewerController implements EventListener { | class FXMLViewerController implements EventListener { | ||||||
|  |  | ||||||
| 	private var ^space : OpenEventSpace; | 	private var ispace : OpenEventSpace; | ||||||
| 	private val id : UUID = UUID.randomUUID(); | 	private val id : UUID = UUID.randomUUID(); | ||||||
|  |  | ||||||
| 	private var launched : boolean = false; | 	private var launched : boolean = false; | ||||||
| @@ -57,13 +54,13 @@ class FXMLViewerController implements EventListener { | |||||||
| 	private var stop_button : Button; | 	private var stop_button : Button; | ||||||
|  |  | ||||||
| 	public def cleanExit() { | 	public def cleanExit() { | ||||||
| 		if (this.^space !== null) | 		if (this.ispace !== null) | ||||||
| 			this.^space.emit(new Exit()); | 			this.ispace.emit(new Exit()); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public def setGUISpace(ispace : OpenEventSpace) { | 	public def setGUISpace(ispace : OpenEventSpace) { | ||||||
| 		this.^space = ispace; | 		this.ispace = ispace; | ||||||
| 		this.^space.register(this); | 		this.ispace.register(this); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public def getGravity() : double { | 	public def getGravity() : double { | ||||||
| @@ -108,12 +105,12 @@ class FXMLViewerController implements EventListener { | |||||||
|  |  | ||||||
| 	@FXML | 	@FXML | ||||||
| 	public def exitApplication(ievent : ActionEvent) { | 	public def exitApplication(ievent : ActionEvent) { | ||||||
| 		^space.emit(new Exit()); | 		ispace.emit(new Exit()); | ||||||
| 		Platform.exit(); | 		Platform.exit(); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	@FXML protected def actionSetup() { | 	@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()); | 			this.getGravity(), this.draw_zone.getWidth()); | ||||||
| 		if (!launched) { | 		if (!launched) { | ||||||
| 			launch_button.setDisable(false); | 			launch_button.setDisable(false); | ||||||
| @@ -121,7 +118,7 @@ class FXMLViewerController implements EventListener { | |||||||
| 			launched = true; | 			launched = true; | ||||||
| 			areaCreated = false; | 			areaCreated = false; | ||||||
| 		} | 		} | ||||||
| 		this.^space.emit(^event); | 		this.ispace.emit(ievent); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	@FXML | 	@FXML | ||||||
| @@ -130,10 +127,10 @@ class FXMLViewerController implements EventListener { | |||||||
| 		stop_button.setDisable(false); | 		stop_button.setDisable(false); | ||||||
| 		setup_button.setDisable(true); | 		setup_button.setDisable(true); | ||||||
| 		if (!areaCreated) { | 		if (!areaCreated) { | ||||||
| 			this.^space.emit(new CreateArea()); | 			this.ispace.emit(new CreateArea()); | ||||||
| 			this.areaCreated = true; | 			this.areaCreated = true; | ||||||
| 		} else { | 		} 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); | 		stop_button.setDisable(true); | ||||||
| 		launch_button.setDisable(false); | 		launch_button.setDisable(false); | ||||||
| 		setup_button.setDisable(false); | 		setup_button.setDisable(false); | ||||||
| 		this.^space.emit(new Freeze(true)); | 		this.ispace.emit(new Freeze(true)); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	@FXML | 	@FXML | ||||||
| 	protected def actionGravityDisplay() { | 	protected def actionGravityDisplay() { | ||||||
| 		gravity_input.valueProperty().addListener(new ChangeListener<Number>() { | 		gravity_input.valueProperty().addListener [ | ||||||
| 			public def changed(ov : ObservableValue<? extends Number>, old_val : Number, new_val : Number) { |  | ||||||
| 			gravity_display.setText(String.format("%.1f", gravity_input.getValue())); | 			gravity_display.setText(String.format("%.1f", gravity_input.getValue())); | ||||||
| 			} | 		] | ||||||
| 		}); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	@FXML | 	@FXML | ||||||
| 	protected def actionRocketQuantityDisplay() { | 	protected def actionRocketQuantityDisplay() { | ||||||
| 		rocket_quantity_input.valueProperty().addListener(new ChangeListener<Number>() { | 		rocket_quantity_input.valueProperty().addListener [ | ||||||
| 			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_display.setText(String.format("%.0f", rocket_quantity_input.getValue())); | ||||||
| 			} | 		]; | ||||||
| 		}); |  | ||||||
|  |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	@FXML | 	@FXML | ||||||
| 	protected def actionFireQuantityDisplay() { | 	protected def actionFireQuantityDisplay() { | ||||||
| 		fire_quantity_input.valueProperty().addListener(new ChangeListener<Number>() { | 		fire_quantity_input.valueProperty().addListener [ | ||||||
| 			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_display.setText(String.format("%.0f", fire_quantity_input.getValue())); | ||||||
| 			} | 		] | ||||||
| 		}); |  | ||||||
|  |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	@Override | 	@Override | ||||||
| 	public def getID() : UUID { | 	public def getID() : UUID { | ||||||
| 		// TODO Auto-generated method stub |  | ||||||
| 		return this.id; | 		return this.id; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	@Override | 	@Override | ||||||
| 	public def receiveEvent(^event : Event) { | 	public def receiveEvent(ievent : Event) { | ||||||
| 		/*  | 		/*  | ||||||
| 		 * if (event instanceof TestEvent){ | 		 * if (event instanceof TestEvent){ | ||||||
| 		 * System.out.println("Guy recieved an event " + ((TestEvent) event).message); | 		 * System.out.println("Guy recieved an event " + ((TestEvent) event).message); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user