/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jpeg.load.performance.test;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ScrollPane;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

/**
 *
 * @author jp202575
 */
public class JPEGLoadPerformanceTest extends Application {
    
    @Override
    public void start(Stage primaryStage) {
        Image[] images = new Image[6];
        {
            long start = System.currentTimeMillis();
            images[0] = new Image(getClass().getResource("IMG_4626.jpg").toExternalForm());
            long end = System.currentTimeMillis();
            System.out.println("LOAD at 100% took = "+(end-start)+"ms");
        }
        {
            long start = System.currentTimeMillis();
            images[1] = new Image(
                    getClass().getResource("IMG_4626.jpg").toExternalForm(),
                    4368/2d,2912/2d,true, true);
            long end = System.currentTimeMillis();
            System.out.println("LOAD at 50% took = "+(end-start)+"ms");
        }
        {
            long start = System.currentTimeMillis();
            images[2] = new Image(
                    getClass().getResource("IMG_4626.jpg").toExternalForm(),
                    4368/4d,2912/4d,true, true);
            long end = System.currentTimeMillis();
            System.out.println("LOAD at 25% took = "+(end-start)+"ms");
        }
        {
            long start = System.currentTimeMillis();
            images[2] = new Image(
                    getClass().getResource("IMG_4626.jpg").toExternalForm(),
                    4368/8d,2912/8d,true, true);
            long end = System.currentTimeMillis();
            System.out.println("LOAD at 12.5% took = "+(end-start)+"ms");
        }
        {
            long start = System.currentTimeMillis();
            images[3] = new Image(
                    getClass().getResource("IMG_4626.jpg").toExternalForm(),
                    4368/16d,2912/16d,true, true);
            long end = System.currentTimeMillis();
            System.out.println("LOAD at 6.25% took = "+(end-start)+"ms");
        }
        {
            long start = System.currentTimeMillis();
            images[4] = new Image(
                    getClass().getResource("IMG_4626.jpg").toExternalForm(),
                    60,60,true, true);
            long end = System.currentTimeMillis();
            System.out.println("LOAD at 60x60 THUMBNAIL took = "+(end-start)+"ms");
        }
        
        VBox box = new VBox(10);
        ScrollPane root = new ScrollPane();
        root.setContent(box);
        for(int i=images.length-1; i>=0 ; i--) {
            box.getChildren().add(new ImageView(images[i]));
        }
        Scene scene = new Scene(root,1024,600);
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    /**
     * The main() method is ignored in correctly deployed JavaFX application.
     * main() serves only as fallback in case the application can not be
     * launched through deployment artifacts, e.g., in IDEs with limited FX
     * support. NetBeans ignores main().
     *
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        launch(args);
    }
}
