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.scene.Parent
|
||||
import javafx.scene.Scene
|
||||
import io.sarl.demos.sierpinski.gui.FXMLViewerController
|
||||
|
||||
class FractalesFXApplications extends Application {
|
||||
private var loader: FXMLLoader
|
||||
@ -31,6 +32,7 @@ class FractalesFXApplications extends Application {
|
||||
@Override
|
||||
public def stop() throws Exception {
|
||||
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.core.Logging
|
||||
import io.sarl.util.OpenEventSpace
|
||||
import io.sarl.demos.sierpinski.events.Exit
|
||||
|
||||
agent Fractal {
|
||||
uses InnerContextAccess, Lifecycle, DefaultContextInteractions, Behaviors
|
||||
@ -83,6 +84,12 @@ agent Fractal {
|
||||
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]{
|
||||
this.multiplication
|
||||
}
|
||||
@ -99,12 +106,24 @@ agent Fractal {
|
||||
this.emitMultiply
|
||||
}
|
||||
|
||||
on Exit[guiSpace !== null && occurrence.source.spaceId == guiSpace.spaceID && !hasMemberAgent]{
|
||||
killMe;
|
||||
}
|
||||
|
||||
// on Multiply[hasMemberAgent && memberAgentCount >= 3 && (occurrence.emmiter == parentID || guiSpace !== null)]{
|
||||
// innerContext.defaultSpace.emit(new Multiply(ID))
|
||||
// }
|
||||
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 MemberLeft [!isFromMe(occurrence) && !hasMemberAgent] {
|
||||
// killMe
|
||||
// }
|
||||
}
|
@ -1,14 +1,4 @@
|
||||
package io.sarl.demos.sierpinski.events
|
||||
|
||||
import java.util.UUID
|
||||
|
||||
event Multiply {
|
||||
var emmiter: UUID
|
||||
new (emmiter: UUID){
|
||||
this.emmiter = emmiter
|
||||
}
|
||||
new (){
|
||||
emmiter = null
|
||||
}
|
||||
}
|
||||
event Multiply
|
||||
event Exit
|
@ -19,6 +19,7 @@ import javafx.util.Duration
|
||||
import javafx.scene.paint.Color
|
||||
import io.sarl.demos.sierpinski.objects.Vector2D
|
||||
import io.sarl.lang.core.Address
|
||||
import io.sarl.demos.sierpinski.events.Exit
|
||||
|
||||
class FXMLViewerController implements EventListener {
|
||||
|
||||
@ -40,8 +41,11 @@ class FXMLViewerController implements EventListener {
|
||||
@FXML private var drawZone: Canvas
|
||||
@FXML private var multiplyButton: Button
|
||||
|
||||
@FXML public def exitApplication(ievent: ActionEvent){
|
||||
// ispace.emit(new Exit())
|
||||
@FXML public def exitApplication(){
|
||||
var e = new Exit()
|
||||
this.multiplyButton.setDisable(true)
|
||||
e.source = new Address(ispace.spaceID, id)
|
||||
this.ispace.emit(e)
|
||||
// Platform.ext()
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user