Java Code Examples for javafx.scene.image.ImageView#getImage()

The following examples show how to use javafx.scene.image.ImageView#getImage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImageManufactureController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@FXML
@Override
public void statisticAction() {
    ImageView view = null;
    File file = null;
    if (currentImageTab.isSelected()) {
        view = currentImageController.imageView;
        file = sourceFile;

    } else if (refImageTab.isSelected()) {
        view = refImageController.imageView;
        sourceFile = refFile;

    } else if (hisImageTab.isSelected()) {
        view = hisImageController.imageView;

    }
    if (view == null || view.getImage() == null) {
        return;
    }
    ImageAnalyseController controller
            = (ImageAnalyseController) FxmlStage.openStage(CommonValues.ImageAnalyseFxml);
    controller.init(file, view.getImage());
    controller.setParentView(view);
    controller.loadData();
}
 
Example 2
Source File: ImagesBrowserController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
public void paneSize(int index) {
    ImageView iView = imageViewList.get(index);
    ScrollPane sPane = imageScrollList.get(index);
    if (iView == null || iView.getImage() == null
            || sPane == null) {
        return;
    }
    FxmlControl.paneSize(sPane, iView);
}
 
Example 3
Source File: ImagesBrowserController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
public void imageSize(int index) {
    ImageView iView = imageViewList.get(index);
    ScrollPane sPane = imageScrollList.get(index);
    if (iView == null || iView.getImage() == null) {
        return;
    }
    FxmlControl.imageSize(sPane, iView);
}
 
Example 4
Source File: ImagesBrowserController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
public void zoomIn(int index) {
    ImageView iView = imageViewList.get(index);
    ScrollPane sPane = imageScrollList.get(index);
    if (iView == null || iView.getImage() == null) {
        return;
    }
    FxmlControl.zoomIn(sPane, iView, xZoomStep, yZoomStep);
}
 
Example 5
Source File: ImagesBrowserController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
public void zoomOut(int index) {
    ImageView iView = imageViewList.get(index);
    ScrollPane sPane = imageScrollList.get(index);
    if (iView == null || iView.getImage() == null) {
        return;
    }
    FxmlControl.zoomOut(sPane, iView, xZoomStep, yZoomStep);
}
 
Example 6
Source File: ImageMaskController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
public DoublePoint getImageXY(MouseEvent event, ImageView view) {
    if (view.getImage() == null) {
        return null;
    }
    double offsetX = event.getX() - view.getLayoutX() - view.getX();
    double offsetY = event.getY() - view.getLayoutY() - view.getY();
    if (offsetX < 0 || offsetX >= view.getBoundsInParent().getWidth()
            || offsetY < 0 || offsetY >= view.getBoundsInParent().getHeight()) {
        return null;
    }
    double x = offsetX * getImageWidth() / view.getBoundsInParent().getWidth();
    double y = offsetY * getImageHeight() / view.getBoundsInParent().getHeight();
    return new DoublePoint(x, y);
}
 
Example 7
Source File: FxmlControl.java    From MyBox with Apache License 2.0 5 votes vote down vote up
public static void paneSize(ScrollPane sPane, ImageView iView) {
        try {
            if (iView == null || iView.getImage() == null
                    || sPane == null) {
                return;
            }
            iView.setFitWidth(sPane.getWidth() - 20);
            iView.setFitHeight(sPane.getHeight() - 20);
            FxmlControl.moveXCenter(sPane, iView);
            iView.setLayoutY(10);
        } catch (Exception e) {
//            logger.error(e.toString());
        }
    }
 
Example 8
Source File: FxmlControl.java    From MyBox with Apache License 2.0 5 votes vote down vote up
public static void imageSize(ScrollPane sPane, ImageView iView) {
        try {
            if (iView == null || iView.getImage() == null
                    || sPane == null) {
                return;
            }
            iView.setFitWidth(iView.getImage().getWidth());
            iView.setFitHeight(iView.getImage().getHeight());
            FxmlControl.moveXCenter(sPane, iView);
            iView.setLayoutY(10);
        } catch (Exception e) {
//            logger.error(e.toString());
        }
    }
 
Example 9
Source File: ImagePreview.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
@Override
@FxThread
protected void show() {

    final ImageView imageView = getImageView();
    if (imageView.getImage() == null) {
        showImage(path);
    }

    super.show();
}
 
Example 10
Source File: DynamicIconSupport.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
/**
 * Adds support changing icons by selection.
 *
 * @param button the button.
 */
@FxThread
public static void addSupport(@NotNull final ToggleButton button) {

    final EditorConfig editorConfig = EditorConfig.getInstance();
    final CssColorTheme theme = editorConfig.getEnum(PREF_UI_THEME, PREF_DEFAULT_THEME);

    if (!theme.needRepaintIcons()) {
        return;
    }

    final ImageView graphic = (ImageView) button.getGraphic();
    final Image image = graphic.getImage();
    final Image original = FILE_ICON_MANAGER.getOriginal(image);

    final ObservableMap<Object, Object> properties = button.getProperties();
    properties.put(NOT_SELECTED_IMAGE, image);
    properties.put(SELECTED_IMAGE, original);

    button.selectedProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue) {
            graphic.setImage((Image) properties.get(SELECTED_IMAGE));
        } else {
            graphic.setImage((Image) properties.get(NOT_SELECTED_IMAGE));
        }
    });

    if (button.isSelected()) {
        graphic.setImage(original);
    } else {
        graphic.setImage(image);
    }
}
 
Example 11
Source File: DynamicIconSupport.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
/**
 * Adds support changing icons by pressed.
 *
 * @param button the button.
 */
@FxThread
public static void addSupport(@NotNull final ButtonBase button) {

    final EditorConfig editorConfig = EditorConfig.getInstance();
    final CssColorTheme theme = editorConfig.getEnum(PREF_UI_THEME, PREF_DEFAULT_THEME);

    if (!theme.needRepaintIcons()) {
        return;
    }

    final ImageView graphic = (ImageView) button.getGraphic();
    final Image image = graphic.getImage();
    final Image original = FILE_ICON_MANAGER.getOriginal(image);

    final ObservableMap<Object, Object> properties = button.getProperties();
    properties.put(NOT_PRESSED_IMAGE, image);
    properties.put(PRESSED_IMAGE, original);

    button.pressedProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue) {
            graphic.setImage((Image) properties.get(PRESSED_IMAGE));
        } else {
            graphic.setImage((Image) properties.get(NOT_PRESSED_IMAGE));
        }
    });

    if (button.isPressed()) {
        graphic.setImage(original);
    } else {
        graphic.setImage(image);
    }
}
 
Example 12
Source File: DigitFactory.java    From metastone with GNU General Public License v2.0 5 votes vote down vote up
private static void applyFontColor(ImageView image, Color color) {
	ColorAdjust monochrome = new ColorAdjust();
	monochrome.setSaturation(-1.0);
	Effect colorInput = new ColorInput(0, 0, image.getImage().getWidth(), image.getImage().getHeight(), color);
	Blend blend = new Blend(BlendMode.MULTIPLY, new ImageInput(image.getImage()), colorInput);
	image.setClip(new ImageView(image.getImage()));
	image.setEffect(blend);
	image.setCache(true);
}
 
Example 13
Source File: TestLoadImageUsingClass.java    From javafxsvg with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void imageShouldBeVisible() {
	ImageView imageView = find("#TestImage");
	Image image = imageView.getImage();

	assertNotNull(image);
	assertFalse(image.errorProperty().get());
}
 
Example 14
Source File: TestLoadImageUsingFxml.java    From javafxsvg with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void imageShouldBeVisible() {
	ImageView imageView = find("#TestImage");
	Image image = imageView.getImage();

	assertNotNull(image);
	assertFalse(image.errorProperty().get());
}
 
Example 15
Source File: DynamicIconSupport.java    From jmonkeybuilder with Apache License 2.0 4 votes vote down vote up
@FxThread
private static void updateListener(@NotNull final Node node, @NotNull final ImageView imageView,
                                   @NotNull final ReadOnlyBooleanProperty condition,
                                   @NotNull final Object listenerKey, @NotNull final Object notSelectedKey,
                                   @NotNull final Object selectedKey) {

    final EditorConfig editorConfig = EditorConfig.getInstance();
    final CssColorTheme theme = editorConfig.getEnum(PREF_UI_THEME, PREF_DEFAULT_THEME);

    if (!theme.needRepaintIcons()) {
        return;
    }

    final ObservableMap<Object, Object> properties = node.getProperties();
    final Image newImage = imageView.getImage();

    if (newImage == null) {
        properties.remove(listenerKey);
        return;
    }

    final Image original = FILE_ICON_MANAGER.getOriginal(newImage);

    properties.put(notSelectedKey, newImage);
    properties.put(selectedKey, original);

    final ChangeListener<Boolean> listener = (observable, oldValue, newValue) -> {
        if (newValue) {
            imageView.setImage((Image) properties.get(selectedKey));
        } else {
            imageView.setImage((Image) properties.get(notSelectedKey));
        }
    };

    condition.addListener(listener);

    properties.put(listenerKey, listener);

    if (condition.get()) {
        imageView.setImage(original);
    } else {
        imageView.setImage(newImage);
    }
}