This commit is contained in:
Debucquoy
2023-09-20 15:18:20 +02:00
parent 00d0cdfaf3
commit 4fd7542f03
228 changed files with 351 additions and 12 deletions

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="bin/main" path="src/main/java">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/main" path="src/main/resources">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/test" path="src/test/java">
<attributes>
<attribute name="gradle_scope" value="test"/>
<attribute name="gradle_used_by_scope" value="test"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/test" path="src/test/resources">
<attributes>
<attribute name="gradle_scope" value="test"/>
<attribute name="gradle_used_by_scope" value="test"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-19/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>app</name>
<comment>Project app created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,13 @@
arguments=
auto.sync=false
build.scans.enabled=false
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
connection.project.dir=
eclipse.preferences.version=1
gradle.user.home=
java.home=
jvm.arguments=
offline.mode=false
override.workspace.settings=false
show.console.view=false
show.executions.view=false

View File

@ -0,0 +1,4 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=19
org.eclipse.jdt.core.compiler.compliance=19
org.eclipse.jdt.core.compiler.source=19

View File

@ -0,0 +1,41 @@
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java application project to get you started.
* For more details take a look at the 'Building Java & JVM projects' chapter in the Gradle
* User Manual available at https://docs.gradle.org/8.0.2/userguide/building_java_projects.html
*/
plugins {
// Apply the application plugin to add support for building a CLI application in Java.
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.13'
}
repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}
dependencies {
// Use JUnit Jupiter for testing.
testImplementation 'org.junit.jupiter:junit-jupiter:5.9.1'
// This dependency is used by the application.
implementation 'com.google.guava:guava:31.1-jre'
}
application {
// Define the main class for the application.
mainClass = 'spirale.App'
}
javafx {
version = "20"
modules = [ 'javafx.controls' ]
}
tasks.named('test') {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
}

View File

@ -0,0 +1,77 @@
package spirale;
import javafx.application.Application;
import javafx.scene.*;
import javafx.scene.layout.*;
import javafx.scene.paint.*;
import javafx.scene.control.*;
import javafx.scene.canvas.*;
import javafx.stage.Stage;
import javafx.geometry.Pos;
public class App extends Application {
private BorderPane root;
private Button next;
private HBox top;
private Generator gen;
private Canvas can;
@Override
public void start(Stage primaryStage){
final int[] last_pos_x = {400};
final int[] last_pos_y = { 400 };
final int[] last_pos_state = { 0 };
gen = new Fibonacci();
can = new Canvas(800,800);
GraphicsContext con = can.getGraphicsContext2D();
con.setFill(Color.BLUE);
root = new BorderPane();
top = new HBox();
next = new Button("Next");
next.setOnAction((x) -> {
int curr = gen.next();
System.out.println(curr);
int next_pos_x = last_pos_x[0], next_pos_y = last_pos_y[0];
switch (last_pos_state[0]) {
case 0:
next_pos_x = last_pos_x[0];
next_pos_y = last_pos_y[0] + curr;
break;
case 1:
next_pos_x = last_pos_x[0] + curr;
next_pos_y = last_pos_y[0];
break;
case 2:
next_pos_x = last_pos_x[0];
next_pos_y = last_pos_y[0] - curr;
break;
case 3:
next_pos_x = last_pos_x[0] - curr;
next_pos_y = last_pos_y[0];
break;
}
last_pos_state[0]++;
last_pos_state[0] = last_pos_state[0] % 4;
con.strokeLine(last_pos_x[0], last_pos_y[0], next_pos_x, next_pos_y);
last_pos_x[0] = next_pos_x;
last_pos_y[0] = next_pos_y;
});
top.getChildren().add(next);
top.setAlignment(Pos.CENTER);
root.setTop(top);
root.setCenter(can);
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.setTitle("Mon paneau");
primaryStage.show();
}
public static void main(String[] args) {
launch();
}
}

View File

@ -0,0 +1,15 @@
package spirale;
public class Fibonacci implements Generator{
private int last1 = 0, last2 = 0;
public int next(){
int tmp = last1 + last2;
if(tmp == 0){
tmp = 1;
}
last2 = last1;
last1 = tmp;
return tmp;
}
}

View File

@ -0,0 +1,5 @@
package spirale;
public interface Generator {
int next();
}

View File

@ -0,0 +1,14 @@
/*
* This Java source file was generated by the Gradle 'init' task.
*/
package spirale;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class AppTest {
@Test void appHasAGreeting() {
App classUnderTest = new App();
assertNotNull(classUnderTest.getGreeting(), "app should have a greeting");
}
}