From 0e9ffd63118314d7277356f0c548670b19760850 Mon Sep 17 00:00:00 2001 From: vitawrap <thevitawrap@gmail.com> Date: Wed, 10 May 2023 11:12:04 +0200 Subject: [PATCH] Java: JNI + FXML --- Makefile | 2 +- include/Scheduling.h | 21 ++++++++++++++ java/application/App.java | 19 ++++++++---- java/application/Scheduling.java | 5 ++++ java/bin/App.class | Bin 964 -> 1484 bytes java/bin/Scheduling.class | Bin 0 -> 322 bytes java/resources/ProjetView.fxml | 48 +++++++++++++++++++++++++++++++ src/Scheduling.c | 9 ++++++ src/application_Scheduling.c | 4 --- 9 files changed, 98 insertions(+), 10 deletions(-) create mode 100644 include/Scheduling.h create mode 100644 java/application/Scheduling.java create mode 100644 java/bin/Scheduling.class create mode 100644 java/resources/ProjetView.fxml create mode 100644 src/Scheduling.c delete mode 100644 src/application_Scheduling.c diff --git a/Makefile b/Makefile index 300e4db..003e6a6 100644 --- a/Makefile +++ b/Makefile @@ -61,7 +61,7 @@ testmemorycheck : $(TEST) $(ODIR)/%.o : $(SDIR)/%.c $(DEP) $(CC) $(FLAGS) -o $@ $< -$(ODIR)/application_Scheduling.o : $(SDIR)/application_Scheduling.c $(DEP) +$(ODIR)/Scheduling.o : $(SDIR)/Scheduling.c $(DEP) $(CC) $(FLAGS) $(JINCLUDES) -o $@ $< $(PROG) : $(OBJ) $(ODIR)/main.o diff --git a/include/Scheduling.h b/include/Scheduling.h new file mode 100644 index 0000000..8809de0 --- /dev/null +++ b/include/Scheduling.h @@ -0,0 +1,21 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include <jni.h> +/* Header for class Scheduling */ + +#ifndef _Included_Scheduling +#define _Included_Scheduling +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: Scheduling + * Method: runSchedule + * Signature: (Ljava/lang/String;Ljava/lang/String;III)V + */ +JNIEXPORT void JNICALL Java_Scheduling_runSchedule + (JNIEnv *, jclass, jstring, jstring, jint, jint, jint); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/java/application/App.java b/java/application/App.java index 6aebc1d..044fede 100644 --- a/java/application/App.java +++ b/java/application/App.java @@ -1,6 +1,9 @@ +import java.io.IOException; + import javafx.application.Application; +import javafx.fxml.FXMLLoader; import javafx.scene.Scene; -import javafx.scene.layout.StackPane; +import javafx.scene.control.SplitPane; import javafx.stage.Stage; public class App extends Application { @@ -10,9 +13,15 @@ public class App extends Application { @Override public void start(Stage primaryStage) throws Exception { - StackPane root = new StackPane(); - primaryStage.setTitle("Hello World"); - primaryStage.setScene(new Scene(root, 800, 600)); - primaryStage.show(); + try { + SplitPane root = FXMLLoader.load(getClass().getResource("resources/ProjetView.fxml")); + primaryStage.setTitle("Hello World"); + primaryStage.setScene(new Scene(root, 800, 600)); + primaryStage.show(); + } + catch (IOException e) + { + System.err.println("FXML indisponible."); + } } } diff --git a/java/application/Scheduling.java b/java/application/Scheduling.java new file mode 100644 index 0000000..b92b4d1 --- /dev/null +++ b/java/application/Scheduling.java @@ -0,0 +1,5 @@ +public class Scheduling { + + public static native void runSchedule(String instanceInFile, String scheduleOutFile, int m, int preemption, int balanced); + +} diff --git a/java/bin/App.class b/java/bin/App.class index 8a8f1bb7264cf9255ed4fd5f89b037f3a2818016..85d39015b0d6e7806c05b76d73db4e8db4f6fbb0 100644 GIT binary patch delta 871 zcmX@YeukUt)W2Q(7#J9A84@;fNi)`SF-SAWvNOmqG6-ZPmL=-vB<7{-`zK|kCYSIq z$T7$>GH|4)mN@4m78f%z2y1BiAXI?`tvMJJ85tytQj7CTi;`1|^#h9Xvr<dKGE>X- z(kgOuxEPcfRM{C+7#aA{bn-B$F{sxwGH|D-mIOhyGcqV?AlVRHQk0pOZVk0GFSSHJ zG|0!Ai$Rk?o1H<6kwFY(WLkwj$Rd5W2wxwc{KS;hA|3`E23<x5mYn>=6oiQ|?NHMo z9*qV2)S8_^pOHZhYFcq}YF?^-a(-S(QGSkoa6wLHNkC#=DhGohBLlZbYEDkRLU?{r zP6`);F@q^Pg9#&p5KL!DVtT56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000..9e872064c688ae13b0f7e44c3aaa7677c80a8ead GIT binary patch literal 322 zcmX^0Z`VEs1_oOOA$A5PMh33n<c!pm(wxk^ban<7Mh1bb#Ii*FoW#6zegCAa)Z`LI z1~!|_yv!0iMh0dL%`ip=7U%qwR4xW)22LIZRt7dk27aH+yi~u^+@#c^ki?{%R7M6N zpZw&+oUp{AOb{O`$WoG#S<J}5<Abo#nvsFKs5B2MkjluQrQw6HKe(hQGcVm5Q^eEL z6XX!C;QZ2}<W#pzkd^#ULo)Ny^*}~2C^9fIFf)Jv69Xg2p$v=+><kPH`V5Q=j0_A6 ztXkU{I5sjcFfcK2F)%Q&fdv^ExEUB2c))B{1|9}p1_nk>20jLU1_lO31_7{YK>(-t BMU?;m literal 0 HcmV?d00001 diff --git a/java/resources/ProjetView.fxml b/java/resources/ProjetView.fxml new file mode 100644 index 0000000..46ba8d1 --- /dev/null +++ b/java/resources/ProjetView.fxml @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.geometry.Insets?> +<?import javafx.scene.canvas.Canvas?> +<?import javafx.scene.control.Button?> +<?import javafx.scene.control.CheckBox?> +<?import javafx.scene.control.Separator?> +<?import javafx.scene.control.Spinner?> +<?import javafx.scene.control.SplitPane?> +<?import javafx.scene.control.TextField?> +<?import javafx.scene.layout.AnchorPane?> +<?import javafx.scene.layout.BorderPane?> +<?import javafx.scene.layout.Pane?> +<?import javafx.scene.layout.VBox?> +<?import javafx.scene.text.Text?> + +<SplitPane dividerPositions="0.29797979797979796" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/19"> + <items> + <AnchorPane maxWidth="-Infinity" minHeight="0.0" minWidth="172.0" prefHeight="160.0" prefWidth="172.0"> + <children> + <VBox prefHeight="398.4" prefWidth="175.2" spacing="10.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> + <padding> + <Insets bottom="10.0" left="10.0" right="10.0" top="10.0" /> + </padding> + <children> + <Text strokeType="OUTSIDE" strokeWidth="0.0" text="File path:" /> + <TextField fx:id="_filename" promptText="Scheduling instance file" /> + <Separator prefWidth="200.0" /> + <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Machine count:" /> + <Spinner fx:id="_machineCount" editable="true" /> + <Separator prefWidth="200.0" /> + <CheckBox fx:id="_balanced" mnemonicParsing="false" selected="true" text="Use balanced trees" /> + <CheckBox fx:id="_preemptive" mnemonicParsing="false" text="Use SRPT over SPT" /> + <Pane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="0.0" prefWidth="0.0" VBox.vgrow="ALWAYS" /> + <Button alignment="BOTTOM_CENTER" defaultButton="true" mnemonicParsing="false" onAction="#submitToDiagram" text="Display and Save" /> + </children> + </VBox> + </children></AnchorPane> + <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0"> + <children> + <BorderPane prefHeight="398.4" prefWidth="417.6" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> + <center> + <Canvas fx:id="_canvas" height="380.0" width="400.0" BorderPane.alignment="CENTER" /> + </center> + </BorderPane> + </children></AnchorPane> + </items> +</SplitPane> diff --git a/src/Scheduling.c b/src/Scheduling.c new file mode 100644 index 0000000..8767d77 --- /dev/null +++ b/src/Scheduling.c @@ -0,0 +1,9 @@ +#include <jni.h> +#include "schedule.h" +#include "Scheduling.h" + +JNIEXPORT void JNICALL Java_Scheduling_runSchedule + (JNIEnv * env, jclass , jstring, jstring, jint, jint, jint) +{ + //const char * mystring = (* env )->GetStringUTFChars(env, s, NULL); +} diff --git a/src/application_Scheduling.c b/src/application_Scheduling.c deleted file mode 100644 index 43f1e5b..0000000 --- a/src/application_Scheduling.c +++ /dev/null @@ -1,4 +0,0 @@ -#include <jni.h> -#include "schedule.h" - - -- GitLab