mirror of
https://github.com/klmp200/sierpinski-fractales.git
synced 2025-02-22 15:37:17 +00:00
Clean exit
This commit is contained in:
parent
00bd20ba79
commit
18052c1da3
@ -7,6 +7,7 @@ import java.net.URL
|
|||||||
import javafx.fxml.JavaFXBuilderFactory
|
import javafx.fxml.JavaFXBuilderFactory
|
||||||
import javafx.scene.Parent
|
import javafx.scene.Parent
|
||||||
import javafx.scene.Scene
|
import javafx.scene.Scene
|
||||||
|
import io.sarl.demos.sierpinski.gui.FXMLViewerController
|
||||||
|
|
||||||
class FractalesFXApplications extends Application {
|
class FractalesFXApplications extends Application {
|
||||||
private var loader: FXMLLoader
|
private var loader: FXMLLoader
|
||||||
@ -31,6 +32,7 @@ class FractalesFXApplications extends Application {
|
|||||||
@Override
|
@Override
|
||||||
public def stop() throws Exception {
|
public def stop() throws Exception {
|
||||||
super.stop()
|
super.stop()
|
||||||
|
(loader.controller as FXMLViewerController).exitApplication()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -19,6 +19,7 @@ import io.sarl.demos.sierpinski.objects.Positions
|
|||||||
import io.sarl.demos.sierpinski.objects.Triangle
|
import io.sarl.demos.sierpinski.objects.Triangle
|
||||||
import io.sarl.core.Logging
|
import io.sarl.core.Logging
|
||||||
import io.sarl.util.OpenEventSpace
|
import io.sarl.util.OpenEventSpace
|
||||||
|
import io.sarl.demos.sierpinski.events.Exit
|
||||||
|
|
||||||
agent Fractal {
|
agent Fractal {
|
||||||
uses InnerContextAccess, Lifecycle, DefaultContextInteractions, Behaviors
|
uses InnerContextAccess, Lifecycle, DefaultContextInteractions, Behaviors
|
||||||
@ -83,6 +84,12 @@ agent Fractal {
|
|||||||
innerContext.defaultSpace.emit(m)
|
innerContext.defaultSpace.emit(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def emitExit(){
|
||||||
|
var e = new Exit
|
||||||
|
e.source = innerContext.defaultSpace.getAddress(ID);
|
||||||
|
innerContext.defaultSpace.emit(e)
|
||||||
|
}
|
||||||
|
|
||||||
on Multiply[guiSpace !== null && occurrence.source.spaceId == guiSpace.spaceID && !hasMemberAgent]{
|
on Multiply[guiSpace !== null && occurrence.source.spaceId == guiSpace.spaceID && !hasMemberAgent]{
|
||||||
this.multiplication
|
this.multiplication
|
||||||
}
|
}
|
||||||
@ -99,12 +106,24 @@ agent Fractal {
|
|||||||
this.emitMultiply
|
this.emitMultiply
|
||||||
}
|
}
|
||||||
|
|
||||||
|
on Exit[guiSpace !== null && occurrence.source.spaceId == guiSpace.spaceID && !hasMemberAgent]{
|
||||||
|
killMe;
|
||||||
|
}
|
||||||
|
|
||||||
|
on Exit[guiSpace !== null && occurrence.source.spaceId == guiSpace.spaceID && hasMemberAgent]{
|
||||||
|
this.emitExit
|
||||||
|
}
|
||||||
|
|
||||||
|
on Exit[occurrence.isInDefaultSpace && !hasMemberAgent]{
|
||||||
|
killMe
|
||||||
|
}
|
||||||
|
|
||||||
|
on Exit[occurrence.isInDefaultSpace && hasMemberAgent]{
|
||||||
|
this.emitExit
|
||||||
|
}
|
||||||
|
|
||||||
|
on MemberLeft[!hasMemberAgent]{
|
||||||
|
killMe
|
||||||
|
}
|
||||||
|
|
||||||
// on Multiply[hasMemberAgent && memberAgentCount >= 3 && (occurrence.emmiter == parentID || guiSpace !== null)]{
|
|
||||||
// innerContext.defaultSpace.emit(new Multiply(ID))
|
|
||||||
// }
|
|
||||||
|
|
||||||
// on MemberLeft [!isFromMe(occurrence) && !hasMemberAgent] {
|
|
||||||
// killMe
|
|
||||||
// }
|
|
||||||
}
|
}
|
@ -1,14 +1,4 @@
|
|||||||
package io.sarl.demos.sierpinski.events
|
package io.sarl.demos.sierpinski.events
|
||||||
|
|
||||||
import java.util.UUID
|
event Multiply
|
||||||
|
|
||||||
event Multiply {
|
|
||||||
var emmiter: UUID
|
|
||||||
new (emmiter: UUID){
|
|
||||||
this.emmiter = emmiter
|
|
||||||
}
|
|
||||||
new (){
|
|
||||||
emmiter = null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
event Exit
|
event Exit
|
@ -19,6 +19,7 @@ import javafx.util.Duration
|
|||||||
import javafx.scene.paint.Color
|
import javafx.scene.paint.Color
|
||||||
import io.sarl.demos.sierpinski.objects.Vector2D
|
import io.sarl.demos.sierpinski.objects.Vector2D
|
||||||
import io.sarl.lang.core.Address
|
import io.sarl.lang.core.Address
|
||||||
|
import io.sarl.demos.sierpinski.events.Exit
|
||||||
|
|
||||||
class FXMLViewerController implements EventListener {
|
class FXMLViewerController implements EventListener {
|
||||||
|
|
||||||
@ -40,8 +41,11 @@ class FXMLViewerController implements EventListener {
|
|||||||
@FXML private var drawZone: Canvas
|
@FXML private var drawZone: Canvas
|
||||||
@FXML private var multiplyButton: Button
|
@FXML private var multiplyButton: Button
|
||||||
|
|
||||||
@FXML public def exitApplication(ievent: ActionEvent){
|
@FXML public def exitApplication(){
|
||||||
// ispace.emit(new Exit())
|
var e = new Exit()
|
||||||
|
this.multiplyButton.setDisable(true)
|
||||||
|
e.source = new Address(ispace.spaceID, id)
|
||||||
|
this.ispace.emit(e)
|
||||||
// Platform.ext()
|
// Platform.ext()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user