Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • main
  • variant
2 results

Target

Select target project
No results found
Select Git revision
  • main
  • variant
2 results
Show changes

Commits on Source 5

26 files
+ 130
194
Compare changes
  • Side-by-side
  • Inline

Files

.gitignore

0 → 100644
+3 −0
Original line number Diff line number Diff line
/.gradle/
/build/
/.idea/

.idea/.gitignore

deleted100644 → 0
+0 −8
Original line number Diff line number Diff line
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

.idea/compiler.xml

deleted100644 → 0
+0 −6
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="CompilerConfiguration">
    <bytecodeTargetLevel target="16" />
  </component>
</project>
 No newline at end of file

.idea/gradle.xml

deleted100644 → 0
+0 −16
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="GradleSettings">
    <option name="linkedExternalProjectsSettings">
      <GradleProjectSettings>
        <option name="distributionType" value="DEFAULT_WRAPPED" />
        <option name="externalProjectPath" value="$PROJECT_DIR$" />
        <option name="modules">
          <set>
            <option value="$PROJECT_DIR$" />
          </set>
        </option>
      </GradleProjectSettings>
    </option>
  </component>
</project>
 No newline at end of file

.idea/jarRepositories.xml

deleted100644 → 0
+0 −20
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="RemoteRepositoriesConfiguration">
    <remote-repository>
      <option name="id" value="central" />
      <option name="name" value="Maven Central repository" />
      <option name="url" value="https://repo1.maven.org/maven2" />
    </remote-repository>
    <remote-repository>
      <option name="id" value="jboss.community" />
      <option name="name" value="JBoss Community repository" />
      <option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
    </remote-repository>
    <remote-repository>
      <option name="id" value="MavenRepo" />
      <option name="name" value="MavenRepo" />
      <option name="url" value="https://repo.maven.apache.org/maven2/" />
    </remote-repository>
  </component>
</project>
 No newline at end of file

.idea/misc.xml

deleted100644 → 0
+0 −10
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="ExternalStorageConfigurationManager" enabled="true" />
  <component name="FrameworkDetectionExcludesConfiguration">
    <file type="web" url="file://$PROJECT_DIR$" />
  </component>
  <component name="ProjectRootManager" version="2" languageLevel="JDK_16" default="true" project-jdk-name="corretto-16" project-jdk-type="JavaSDK">
    <output url="file://$PROJECT_DIR$/out" />
  </component>
</project>
 No newline at end of file

.idea/vcs.xml

deleted100644 → 0
+0 −6
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="VcsDirectoryMappings">
    <mapping directory="$PROJECT_DIR$" vcs="Git" />
  </component>
</project>
 No newline at end of file
+9 −6
Original line number Diff line number Diff line

plugins {
    id 'application'
    id "org.openjfx.javafxplugin" version "0.0.10"
    id "org.openjfx.javafxplugin" version "0.0.13"
}

javafx {
    version = "17"
    version = "19"
    modules = [ 'javafx.controls', 'javafx.fxml' ]
}

@@ -13,13 +13,16 @@ javafx {
repositories {
    mavenCentral()
}

dependencies {
    testImplementation group: 'junit', name: 'junit', version: '4.12'
    testImplementation 'org.hamcrest:hamcrest-library:1.3'
    testImplementation('org.junit.jupiter:junit-jupiter-api:5.9.0',
            'org.assertj:assertj-core:3.23.1')
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.0'
}

application {
    mainClassName = "App"

}

test {
    useJUnitPlatform()
Original line number Diff line number Diff line
@@ -6,19 +6,23 @@ import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

import static java.lang.Thread.sleep;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;


public class App extends Application {

    boolean isInPause = true;

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws InterruptedException {
    public void start(Stage primaryStage) {
        Group root = new Group();
        Button restart = new Button("Restart");
        Button switchPause = new Button("Pause");
        VBox buttons = new VBox();
        HBox total = new HBox();
        Grid grid = new Grid(1000,1000,20,20);
@@ -27,25 +31,20 @@ public class App extends Application {
        total.getChildren().add(buttons);
        total.getChildren().add(grid);
        buttons.getChildren().add(restart);
        buttons.getChildren().add(switchPause);
        restart.setOnMouseClicked(grid::restart);
        switchPause.setOnMouseClicked((value)->isInPause = !isInPause);
        primaryStage.setScene(new Scene(root));
        primaryStage.show();
        grid.repaint();
        new Thread(new Runnable() {
            @Override
            public void run() {
                while(true){
                    try {
                        sleep(50);

        ScheduledThreadPoolExecutor threadPoolExecutor = new ScheduledThreadPoolExecutor(1);
        threadPoolExecutor.scheduleAtFixedRate(() -> {
            if(!isInPause) {
                grid.model.activation();
                grid.repaint();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }

            }
        }).start();
        }, 0, 50 , TimeUnit.MILLISECONDS);
    }
}
Original line number Diff line number Diff line
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.input.MouseEvent;
import javafx.scene.paint.Color;

public class Grid extends Canvas{
    int width, height, colCount, rowCount;
    double width;
    double height;
    double colCount;
    double rowCount;
    Model model;


@@ -29,9 +31,6 @@ public class Grid extends Canvas{
    private void mousePressed(MouseEvent mouseEvent) {
        model.activation();
        repaint();
            /*double x = mouseEvent.getX();
            double y = mouseEvent.getY();
            model.click((int)x*rowCount/height,(int)y*colCount/width);*/
    }

    void repaint(){
@@ -49,7 +48,7 @@ public class Grid extends Canvas{

    public void paintFF(int row, int col) {
        getGraphicsContext2D().setFill(Color.BLUE);
        getGraphicsContext2D().fillRect(row*height/rowCount,col*width/colCount,height/rowCount,width/colCount);
        getGraphicsContext2D().fillOval(row*height/rowCount,col*width/colCount,height/rowCount,width/colCount);
    }

    public void paintFire(int row, int col) {
Original line number Diff line number Diff line
@@ -3,7 +3,8 @@ import java.util.*;

public class Model {
  Grid grid;
    int colCount, rowCount;
  double colCount;
  double rowCount;
  List<Position> firefighters = new ArrayList<>();
  Set<Position> fires = new HashSet<>();
  List<Position> ffNewPositions;
@@ -44,8 +45,8 @@ public class Model {
      }
      for (Position newFire : newFires)
        grid.paintFire(newFire.row, newFire.col);

            fires.addAll(newFires);}
      fires.addAll(newFires);
    }
    step++;

  }
@@ -55,10 +56,8 @@ public class Model {
  }



  private Position activateFirefighter(Position position) {
    Position randomPosition = aStepTowardFire(position);
                //next(position).get((int) (Math.random()*next(position).size()));
    List<Position> nextFires = next(randomPosition).stream().filter(fires::contains).toList();
    extinguish(randomPosition);
    for (Position fire : nextFires)
@@ -101,5 +100,6 @@ public class Model {
    return position;
  }

    public record Position(int row, int col){}
  public record Position(int row, int col) {
  }
}
 No newline at end of file