Skip to content

Commit

Permalink
Issue added.
Browse files Browse the repository at this point in the history
  • Loading branch information
guirak committed Dec 14, 2023
1 parent 22906e1 commit 43d2715
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 75 deletions.
92 changes: 54 additions & 38 deletions src/main/java/one/jpro/hellojpro/HelloJProFXMLController.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@

import com.jpro.webapi.JProApplication;
import com.jpro.webapi.WebAPI;
import javafx.animation.Animation;
import javafx.animation.FadeTransition;
import javafx.animation.ParallelTransition;
import javafx.animation.ScaleTransition;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.util.Duration;
import javafx.scene.image.Image;
import javafx.scene.layout.*;

import java.net.URL;
import java.util.ResourceBundle;
Expand All @@ -24,45 +19,66 @@
public class HelloJProFXMLController implements Initializable {

@FXML
public Label platformLabel;
protected VBox root;

protected JProApplication jproApplication;

private static final String PRESIGNED_URL =
"https://mmione-tests.s3.eu-west-3.amazonaws.com/global/mmi_order/rayons/jus.jpg?response-content-disposition=inline&X-Amz-Security-Token=IQoJb3JpZ2luX2VjEOD%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCWV1LXdlc3QtMyJIMEYCIQCDQU2jdpZWG4CfZtckW0FR1h0a%2FBtwrtlTSVL6pGcY0gIhAIkNq73Mxvek8zm%2FLd%2B6CAcsfIIcftClBsUhrq9DWWksKoUDCFkQARoMNzg2NTM3NjE5MjQ4Igwr9Vmz1CzTwg1s5GMq4gKURSwxfeuXnkOfA2RR50g%2BDxa0dVQCqlgW63LneiW7PaXWOdDrGcg4XsMNZ%2Fe2kkDT0nSSgIC68JCgUj03QcndN%2B0CBLpAuX7RXmSwqCzQC0xUG%2FZ1PZacQUL2uHLjkVpDuoRGXfZAqKebSJRVpZX2%2FCteSJSY8hXe2A8v8E4EhDcFIA4UKZmt%2BYpmM%2F2Wli56MTIaTGVJSi5Ek8QQ992MqL6EQwsbE7VVAar%2FWdSiEdHO96sS43BrVVFNDg%2FzI1Y%2FpVQzOiQug0UjPTaLBHWcxuyO4kRnkIXuvflaDkWxStwz8bl11ln%2F14wVjDy3OJon%2F2QjyUfKkyac%2FXFItTm35aqlseWJGzc%2BlNvQKbg31799pb2a6z%2BLovh0qlya9%2B7bjc9tgPsox2Mm4C0Rk%2B62DtE2sq0UsvllHtDBh4G5gfNC%2Fa5DcG0FGkUKWKH3zlwY%2BjBtwRIEXFEdyFwRKTMWO7Ywq9nqqwY6sgKUW6qEIMNd%2BZBKLsY6ROGgMLgq3xua%2F6JJPHNjVO9R41%2BPXhy6OBXBma35eHs43Jk7cfudm26w4unCP1vLKf%2BuDjSCofQigPPyWNRY8Sq4h2%2Fpkw82EKBHkzTJPfp8WlKCpPS0kffiPX6oPZtEMTiiTDtnU6U1ABFtLgUbD0FYRQ8monZpuYS8q4wugHWpWOUHoSYj%2Ffzus1kQXcYEcSkn%2FXJBN%2F6L2hV9kVmmPO%2BMpRDvfzG39buvwaZNquR1EdW9EJ82U57Uyiu6IKlhDfC3J4TmCdH29Xtyx2Hq9wN95wS%2FSCcNJwbEPc15sl3TyWfGrgpTv66IbJTP3tEJYGOav7OUNxhTuRcyFoYs8Fd4nas%2F5%2B0LeL7a5LagwWFIu3%2F0ddXyOfYOb%2FuoDdh7fLrhVKk%3D&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20231214T143715Z&X-Amz-SignedHeaders=host&X-Amz-Expires=43200&X-Amz-Credential=ASIA3OIKLT4YBS3KBUP7%2F20231214%2Feu-west-3%2Fs3%2Faws4_request&X-Amz-Signature=742399e50744ec08061f3b489c52aef2d7e505e6e9f22e31e94e0333f6b14d2e";

@Override
public void initialize(final URL location, final ResourceBundle resources) {
}

protected void init(final JProApplication jproApplication) {
this.jproApplication = jproApplication;

}

@FXML
protected StackPane root;
private void onCreateVirtualImageWorking(@SuppressWarnings("unused") final ActionEvent actionEvent) {
System.out.println("Create virtual image that work");
final Image image = WebAPI.createVirtualImage(PRESIGNED_URL, 400, 179);
setBackgroundImage(image);
}

@FXML
protected Node logo;
private void onCreateVirtualImageNotWorking(@SuppressWarnings("unused") final ActionEvent actionEvent) {
System.out.println("Create virtual image that doesn't work");

protected JProApplication jproApplication;
protected ParallelTransition pt;
final Image image = WebAPI.createVirtualImage(PRESIGNED_URL, 400, 179, false);
setBackgroundImage(image);

@Override
public void initialize(URL location, ResourceBundle resources) {
platformLabel.setText(String.format("Platform: %s", WebAPI.isBrowser() ? "Browser" : "Desktop"));
}

protected void initLogoAnimation(Node logo) {
ScaleTransition st = new ScaleTransition(Duration.millis(1000), logo);
st.setByX(-0.5);
st.setByY(-0.5);
st.setAutoReverse(true);
st.setCycleCount(Animation.INDEFINITE);

FadeTransition ft = new FadeTransition(Duration.millis(1000), logo);
ft.setToValue(0.5);
ft.setAutoReverse(true);
ft.setCycleCount(Animation.INDEFINITE);
logo.setOpacity(1);

pt = new ParallelTransition(st, ft);
pt.play();

if (WebAPI.isBrowser()) {
jproApplication.getWebAPI().addInstanceCloseListener(() -> pt.stop());
}
@FXML
private void onCreateVirtualImageNotWorkingWithProxy(@SuppressWarnings("unused") final ActionEvent actionEvent) {
System.out.println("Create virtual image that doesn't work with proxy");

final Image image = WebAPI.createVirtualImage(PRESIGNED_URL, 400, 179, true);
setBackgroundImage(image);
}

protected void init(JProApplication jproApplication) {
this.jproApplication = jproApplication;
initLogoAnimation(this.logo);
private void setBackgroundImage(final Image image){
// Taille de l'image
final BackgroundSize backgroundSize = new BackgroundSize(
BackgroundSize.AUTO,
BackgroundSize.AUTO,
false,
false,
false,
true);

// Création de l'image background
final BackgroundImage backgroundImage = new BackgroundImage(
image,
BackgroundRepeat.NO_REPEAT,
BackgroundRepeat.NO_REPEAT,
BackgroundPosition.CENTER,
backgroundSize
);

root.setBackground(new Background(backgroundImage));
}

}
23 changes: 2 additions & 21 deletions src/main/resources/one/jpro/hellojpro/css/HelloJPro.css
Original file line number Diff line number Diff line change
@@ -1,24 +1,5 @@
.root {
-fx-background-color: white;
}

.label {
-fx-font-size: 16px;
}

.hello-label {
-fx-translate-y: -80px;
-fx-text-fill: #999;
-fx-font-size: 32px;
}

.platform-label {
-fx-translate-y: -10px;
-fx-text-fill: #BBB;
-fx-font-size: 14px;
}

.progress-indicator {
-fx-max-width: 32px;
-fx-max-height: 32px;
-fx-spacing: 0.5em;
-fx-padding: 0.5em;
}
27 changes: 11 additions & 16 deletions src/main/resources/one/jpro/hellojpro/fxml/HelloJPro.fxml
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Label?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.StackPane?>
<StackPane
xmlns:fx="http://javafx.com/fxml"
stylesheets="@../css/HelloJPro.css"
prefWidth="800" prefHeight="600"
fx:id="root"
fx:controller="one.jpro.hellojpro.HelloJProFXMLController">
<Label text="Hello" styleClass="hello-label"></Label>
<ImageView fx:id="logo" fitWidth="300" preserveRatio="true">
<Image url="@../img/JPRO_logo_rgb.png"></Image>
</ImageView>
<Label fx:id="platformLabel" text="Platform: " styleClass="platform-label" StackPane.alignment="BOTTOM_CENTER"></Label>
</StackPane>
<?import javafx.scene.control.Button?>
<?import javafx.scene.layout.VBox?>


<VBox fx:id="root" alignment="CENTER" stylesheets="@../css/HelloJPro.css" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="one.jpro.hellojpro.HelloJProFXMLController">
<children>
<Button mnemonicParsing="false" onAction="#onCreateVirtualImageWorking" text=" createVirtualImage(String url, int w, int h)" />
<Button mnemonicParsing="false" onAction="#onCreateVirtualImageNotWorking" text="createVirtualImage(String url, int w, int h, false)" />
<Button mnemonicParsing="false" onAction="#onCreateVirtualImageNotWorkingWithProxy" text="createVirtualImage(String url, int w, int h, true)" />
</children>
</VBox>

0 comments on commit 43d2715

Please sign in to comment.