Search in sources :

Example 6 with ImageZoomModel

use of org.intellij.images.editor.ImageZoomModel in project intellij-community by JetBrains.

the class ImageFileEditorImpl method setState.

public void setState(@NotNull FileEditorState state) {
    if (state instanceof ImageFileEditorState) {
        ImageFileEditorState editorState = (ImageFileEditorState) state;
        ImageZoomModel zoomModel = imageEditor.getZoomModel();
        imageEditor.setTransparencyChessboardVisible(editorState.isBackgroundVisible());
        imageEditor.setGridVisible(editorState.isGridVisible());
        zoomModel.setZoomFactor(editorState.getZoomFactor());
    }
}
Also used : ImageZoomModel(org.intellij.images.editor.ImageZoomModel)

Example 7 with ImageZoomModel

use of org.intellij.images.editor.ImageZoomModel in project android by JetBrains.

the class LayeredImageEditor method setImage.

private void setImage(Image image) throws IOException {
    ImageDocument document = myImageEditor.getDocument();
    BufferedImage previousImage = document.getValue();
    document.setValue(Utilities.getDisplayableImage(image));
    String format = image.getFormat() + "/" + image.getColorMode();
    String description = image.getColorProfileDescription();
    if (!description.isEmpty()) {
        format += ", " + description;
    }
    document.setFormat(format);
    // from ImageEditorUI
    ImageZoomModel zoomModel = myImageEditor.getZoomModel();
    if (previousImage == null || !zoomModel.isZoomLevelChanged()) {
        Options options = OptionsManager.getInstance().getOptions();
        ZoomOptions zoomOptions = options.getEditorOptions().getZoomOptions();
        zoomModel.setZoomFactor(1.0d);
        if (zoomOptions.isSmartZooming()) {
            Dimension preferred = zoomOptions.getPrefferedSize();
            if (preferred.width > image.getWidth() && preferred.height > image.getHeight()) {
                double factor = (preferred.getWidth() / (double) image.getWidth() + preferred.getHeight() / (double) image.getHeight()) / 2.0d;
                zoomModel.setZoomFactor(Math.ceil(factor));
            }
        }
    }
}
Also used : ImageZoomModel(org.intellij.images.editor.ImageZoomModel) ZoomOptions(org.intellij.images.options.ZoomOptions) Options(org.intellij.images.options.Options) ZoomOptions(org.intellij.images.options.ZoomOptions) ImageDocument(org.intellij.images.editor.ImageDocument) BufferedImage(java.awt.image.BufferedImage)

Example 8 with ImageZoomModel

use of org.intellij.images.editor.ImageZoomModel in project intellij-community by JetBrains.

the class ZoomOutAction method update.

public void update(AnActionEvent e) {
    super.update(e);
    if (ImageEditorActionUtil.setEnabled(e)) {
        ImageComponentDecorator decorator = ImageEditorActionUtil.getImageComponentDecorator(e);
        ImageZoomModel zoomModel = decorator.getZoomModel();
        e.getPresentation().setEnabled(zoomModel.canZoomOut());
    }
}
Also used : ImageZoomModel(org.intellij.images.editor.ImageZoomModel) ImageComponentDecorator(org.intellij.images.ui.ImageComponentDecorator)

Example 9 with ImageZoomModel

use of org.intellij.images.editor.ImageZoomModel in project intellij-community by JetBrains.

the class ActualSizeAction method update.

public void update(AnActionEvent e) {
    super.update(e);
    if (ImageEditorActionUtil.setEnabled(e)) {
        ImageComponentDecorator decorator = ImageEditorActionUtil.getImageComponentDecorator(e);
        ImageZoomModel zoomModel = decorator.getZoomModel();
        e.getPresentation().setEnabled(zoomModel.getZoomFactor() != 1.0d);
    }
}
Also used : ImageZoomModel(org.intellij.images.editor.ImageZoomModel) ImageComponentDecorator(org.intellij.images.ui.ImageComponentDecorator)

Example 10 with ImageZoomModel

use of org.intellij.images.editor.ImageZoomModel in project android by JetBrains.

the class ScreenshotViewer method updateEditorImage.

private void updateEditorImage() {
    BufferedImage image = myDisplayedImageRef.get();
    ImageEditor imageEditor = myImageFileEditor.getImageEditor();
    ImageZoomModel zoomModel = imageEditor.getZoomModel();
    double zoom = zoomModel.getZoomFactor();
    imageEditor.getDocument().setValue(image);
    pack();
    zoomModel.setZoomFactor(zoom);
}
Also used : ImageZoomModel(org.intellij.images.editor.ImageZoomModel) ImageEditor(org.intellij.images.editor.ImageEditor) BufferedImage(java.awt.image.BufferedImage)

Aggregations

ImageZoomModel (org.intellij.images.editor.ImageZoomModel)10 ImageComponentDecorator (org.intellij.images.ui.ImageComponentDecorator)6 BufferedImage (java.awt.image.BufferedImage)3 ImageDocument (org.intellij.images.editor.ImageDocument)2 ImageEditor (org.intellij.images.editor.ImageEditor)1 Options (org.intellij.images.options.Options)1 ZoomOptions (org.intellij.images.options.ZoomOptions)1