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());
}
}
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));
}
}
}
}
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());
}
}
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);
}
}
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);
}
Aggregations