package de.siphalor.was.visual.jfx.component;

import javafx.beans.property.ObjectProperty;
import javafx.scene.control.ScrollPane;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;

public class ScalingImagePane extends ScrollPane {
	private final ImageView imageView;

	public ScalingImagePane() {
		setHbarPolicy(ScrollBarPolicy.NEVER);
		setVbarPolicy(ScrollBarPolicy.NEVER);
		setFocusTraversable(false);
		getStyleClass().add("edge-to-edge");

		imageView = new ImageView();
		imageView.setPreserveRatio(true);
		imageView.setSmooth(true);
		imageView.fitWidthProperty().bind(widthProperty());
		imageView.fitHeightProperty().bind(heightProperty());

		setContent(imageView);
	}

	public Image getImage() {
		return imageView.getImage();
	}
	public void setImage(Image image) {
		imageView.setImage(image);
	}

	public ObjectProperty<Image> imageProperty() {
		return imageView.imageProperty();
	}
}
