// Path: src/main/java/me/xwang1024/sifResExplorer/presentation/builder/SIFStage.java
// public class SIFStage {
// 	private boolean isBuild = false;
// 	private Stage stage;
// 	private AbsStageBuilder builder;
// 
// 	public Stage getStage() {
// 		return stage;
// 	}
// 
// 	public void setStage(Stage stage) {
// 		this.stage = stage;
// 	}
// 
// 	public AbsStageBuilder getBuilder() {
// 		return builder;
// 	}
// 
// 	public void setBuilder(AbsStageBuilder builder) {
// 		this.builder = builder;
// 	}
// 
// 	public void show() throws Exception {
// 		if (builder != null && !isBuild) {
// 			builder.build();
// 		}
// 		stage.show();
// 	}
// 
// 	public void hide() {
// 		stage.hide();
// 	}
// 
// 	public void close() {
// 		stage.close();
// 	}
// 
// 	public SIFStage() {
// 		// TODO Auto-generated constructor stub
// 	}
// 
// 	public SIFStage(Stage stage, AbsStageBuilder builder) {
// 		super();
// 		this.stage = stage;
// 		this.builder = builder;
// 	}
// }
// 
// Path: src/main/java/me/xwang1024/sifResExplorer/presentation/builder/impl/AssetPreviewStageBuilder.java
// public class AssetPreviewStageBuilder extends AbsStageBuilder {
// 	private ImageService imageService = new ImageService();
// 	private ScrollPane scrollPane;
// 	private StackPane nodeContainer;
// 	private ImageView imageView;
// 
// 	private String imagPath;
// 
// 	public AssetPreviewStageBuilder(FXMLLoader root) throws Exception {
// 		super(root);
// 	}
// 
// 	public String getImagPath() {
// 		return imagPath;
// 	}
// 
// 	public void setImagPath(String imagPath) {
// 		this.imagPath = imagPath;
// 	}
// 	
// 	private ImageView getImageView() throws IOException {
// 		BufferedImage bufImage = imageService.getImage(imagPath);
// 		WritableImage image = SwingFXUtils.toFXImage(bufImage, null);
// 		ImageView view = new ImageView(image);
// 		view.setFitWidth(bufImage.getWidth());
// 		view.setFitHeight(bufImage.getHeight());
// 		return view;
// 	}
// 	
// 	private void setNewImageView(ImageView newNode) {
// 		Pane parent = this.imageView != null ? (Pane) this.imageView.getParent() : null;
// 		if (parent != null) {
// 			parent.getChildren().remove(this.imageView);
// 			parent.getChildren().add(newNode);
// 		}
// 		this.imageView = newNode;
// 
// 		imageView.boundsInParentProperty().addListener(new ChangeListener<Bounds>() {
// 			@Override
// 			public void changed(ObservableValue<? extends Bounds> observableValue,
// 					Bounds oldBounds, Bounds newBounds) {
// 				nodeContainer.setPrefSize(
// 						Math.max(newBounds.getMaxX(), scrollPane.getViewportBounds().getWidth()),
// 						Math.max(newBounds.getMaxY(), scrollPane.getViewportBounds().getHeight()));
// 			}
// 		});
// 	}
// 
// 	private void initElements() throws IOException {
// 		scrollPane = (ScrollPane) ((Parent)loader.getRoot()).lookup("#scrollPane");
// 		nodeContainer = new StackPane();
// 		imageView = getImageView();
// 		
// 	}
// 	
// 	private void initScrollPane() throws IOException {
// 		nodeContainer.setStyle("-fx-background-color: #333;");
// 		nodeContainer.getChildren().add(imageView);
// 		scrollPane.setContent(nodeContainer);
// 		scrollPane.viewportBoundsProperty().addListener(new ChangeListener<Bounds>() {
// 			@Override
// 			public void changed(ObservableValue<? extends Bounds> observableValue,
// 					Bounds oldBounds, Bounds newBounds) {
// 				nodeContainer.setPrefSize(
// 						Math.max(imageView.getBoundsInParent().getMaxX(), newBounds.getWidth()),
// 						Math.max(imageView.getBoundsInParent().getMaxY(), newBounds.getHeight()));
// 			}
// 		});
// 		setNewImageView(getImageView());
// 	}
// 
// 	
// 
// 	@Override
// 	public void build() throws IOException {
// 		initElements();
// 		initScrollPane();
// 	}
// 
// 	
// }


import java.io.File;
import java.io.IOException;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Modality;
import javafx.stage.Stage;
import me.xwang1024.sifResExplorer.presentation.builder.SIFStage;
import me.xwang1024.sifResExplorer.presentation.builder.impl.AssetPreviewStageBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

package me.xwang1024.sifResExplorer.presentation;




public class AssetPreviewStage {
	private static final Logger logger = LoggerFactory.getLogger(MainStage.class);

	public AssetPreviewStage(final Stage father, final String imagPath) throws Exception {
		final Stage stage = new Stage();
		stage.initModality(Modality.NONE);
		stage.initOwner(father);
		stage.setTitle("Asset Preview: " + new File(imagPath).getName());
		FXMLLoader fxmlLoader = new FXMLLoader(this.getClass().getClassLoader()
				.getResource("assetPreview.fxml"));
		Parent root = fxmlLoader.load();
		Scene scene = new Scene(root);
		stage.setScene(scene);

// Path: src/main/java/me/xwang1024/sifResExplorer/presentation/builder/SIFStage.java
// public class SIFStage {
// 	private boolean isBuild = false;
// 	private Stage stage;
// 	private AbsStageBuilder builder;
// 
// 	public Stage getStage() {
// 		return stage;
// 	}
// 
// 	public void setStage(Stage stage) {
// 		this.stage = stage;
// 	}
// 
// 	public AbsStageBuilder getBuilder() {
// 		return builder;
// 	}
// 
// 	public void setBuilder(AbsStageBuilder builder) {
// 		this.builder = builder;
// 	}
// 
// 	public void show() throws Exception {
// 		if (builder != null && !isBuild) {
// 			builder.build();
// 		}
// 		stage.show();
// 	}
// 
// 	public void hide() {
// 		stage.hide();
// 	}
// 
// 	public void close() {
// 		stage.close();
// 	}
// 
// 	public SIFStage() {
// 		// TODO Auto-generated constructor stub
// 	}
// 
// 	public SIFStage(Stage stage, AbsStageBuilder builder) {
// 		super();
// 		this.stage = stage;
// 		this.builder = builder;
// 	}
// }
// 
// Path: src/main/java/me/xwang1024/sifResExplorer/presentation/builder/impl/AssetPreviewStageBuilder.java
// public class AssetPreviewStageBuilder extends AbsStageBuilder {
// 	private ImageService imageService = new ImageService();
// 	private ScrollPane scrollPane;
// 	private StackPane nodeContainer;
// 	private ImageView imageView;
// 
// 	private String imagPath;
// 
// 	public AssetPreviewStageBuilder(FXMLLoader root) throws Exception {
// 		super(root);
// 	}
// 
// 	public String getImagPath() {
// 		return imagPath;
// 	}
// 
// 	public void setImagPath(String imagPath) {
// 		this.imagPath = imagPath;
// 	}
// 	
// 	private ImageView getImageView() throws IOException {
// 		BufferedImage bufImage = imageService.getImage(imagPath);
// 		WritableImage image = SwingFXUtils.toFXImage(bufImage, null);
// 		ImageView view = new ImageView(image);
// 		view.setFitWidth(bufImage.getWidth());
// 		view.setFitHeight(bufImage.getHeight());
// 		return view;
// 	}
// 	
// 	private void setNewImageView(ImageView newNode) {
// 		Pane parent = this.imageView != null ? (Pane) this.imageView.getParent() : null;
// 		if (parent != null) {
// 			parent.getChildren().remove(this.imageView);
// 			parent.getChildren().add(newNode);
// 		}
// 		this.imageView = newNode;
// 
// 		imageView.boundsInParentProperty().addListener(new ChangeListener<Bounds>() {
// 			@Override
// 			public void changed(ObservableValue<? extends Bounds> observableValue,
// 					Bounds oldBounds, Bounds newBounds) {
// 				nodeContainer.setPrefSize(
// 						Math.max(newBounds.getMaxX(), scrollPane.getViewportBounds().getWidth()),
// 						Math.max(newBounds.getMaxY(), scrollPane.getViewportBounds().getHeight()));
// 			}
// 		});
// 	}
// 
// 	private void initElements() throws IOException {
// 		scrollPane = (ScrollPane) ((Parent)loader.getRoot()).lookup("#scrollPane");
// 		nodeContainer = new StackPane();
// 		imageView = getImageView();
// 		
// 	}
// 	
// 	private void initScrollPane() throws IOException {
// 		nodeContainer.setStyle("-fx-background-color: #333;");
// 		nodeContainer.getChildren().add(imageView);
// 		scrollPane.setContent(nodeContainer);
// 		scrollPane.viewportBoundsProperty().addListener(new ChangeListener<Bounds>() {
// 			@Override
// 			public void changed(ObservableValue<? extends Bounds> observableValue,
// 					Bounds oldBounds, Bounds newBounds) {
// 				nodeContainer.setPrefSize(
// 						Math.max(imageView.getBoundsInParent().getMaxX(), newBounds.getWidth()),
// 						Math.max(imageView.getBoundsInParent().getMaxY(), newBounds.getHeight()));
// 			}
// 		});
// 		setNewImageView(getImageView());
// 	}
// 
// 	
// 
// 	@Override
// 	public void build() throws IOException {
// 		initElements();
// 		initScrollPane();
// 	}
// 
// 	
// }


// Path: src/main/java/me/xwang1024/sifResExplorer/presentation/AssetPreviewStage.java
import java.io.File;
import java.io.IOException;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Modality;
import javafx.stage.Stage;
import me.xwang1024.sifResExplorer.presentation.builder.SIFStage;
import me.xwang1024.sifResExplorer.presentation.builder.impl.AssetPreviewStageBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

package me.xwang1024.sifResExplorer.presentation;




public class AssetPreviewStage {
	private static final Logger logger = LoggerFactory.getLogger(MainStage.class);

	public AssetPreviewStage(final Stage father, final String imagPath) throws Exception {
		final Stage stage = new Stage();
		stage.initModality(Modality.NONE);
		stage.initOwner(father);
		stage.setTitle("Asset Preview: " + new File(imagPath).getName());
		FXMLLoader fxmlLoader = new FXMLLoader(this.getClass().getClassLoader()
				.getResource("assetPreview.fxml"));
		Parent root = fxmlLoader.load();
		Scene scene = new Scene(root);
		stage.setScene(scene);

		AssetPreviewStageBuilder builder = new AssetPreviewStageBuilder(fxmlLoader);
