use of org.intellij.images.editor.ImageZoomModel in project intellij-community by JetBrains.
the class ActualSizeAction method actionPerformed.
public void actionPerformed(AnActionEvent e) {
ImageComponentDecorator decorator = ImageEditorActionUtil.getImageComponentDecorator(e);
if (decorator != null) {
ImageZoomModel zoomModel = decorator.getZoomModel();
zoomModel.setZoomFactor(1.0d);
}
}
use of org.intellij.images.editor.ImageZoomModel in project intellij-community by JetBrains.
the class ZoomInAction 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.canZoomIn());
}
}
use of org.intellij.images.editor.ImageZoomModel in project intellij-community by JetBrains.
the class ZoomInAction method actionPerformed.
public void actionPerformed(AnActionEvent e) {
ImageComponentDecorator decorator = ImageEditorActionUtil.getImageComponentDecorator(e);
if (decorator != null) {
ImageZoomModel zoomModel = decorator.getZoomModel();
zoomModel.zoomIn();
}
}
use of org.intellij.images.editor.ImageZoomModel in project intellij-community by JetBrains.
the class ZoomOutAction method actionPerformed.
public void actionPerformed(AnActionEvent e) {
ImageComponentDecorator decorator = ImageEditorActionUtil.getImageComponentDecorator(e);
if (decorator != null) {
ImageZoomModel zoomModel = decorator.getZoomModel();
zoomModel.zoomOut();
}
}
use of org.intellij.images.editor.ImageZoomModel in project intellij-community by JetBrains.
the class ImageEditorUI method setImage.
public void setImage(BufferedImage image, String format) {
ImageDocument document = imageComponent.getDocument();
BufferedImage previousImage = document.getValue();
document.setValue(image);
if (image == null)
return;
document.setFormat(format);
ImageZoomModel zoomModel = getZoomModel();
if (previousImage == null || !zoomModel.isZoomLevelChanged()) {
// Set smart zooming behaviour on open
Options options = OptionsManager.getInstance().getOptions();
ZoomOptions zoomOptions = options.getEditorOptions().getZoomOptions();
// Open as actual size
zoomModel.setZoomFactor(1.0d);
if (zoomOptions.isSmartZooming()) {
Dimension prefferedSize = zoomOptions.getPrefferedSize();
if (prefferedSize.width > image.getWidth() && prefferedSize.height > image.getHeight()) {
// Resize to preffered size
// Calculate zoom factor
double factor = (prefferedSize.getWidth() / (double) image.getWidth() + prefferedSize.getHeight() / (double) image.getHeight()) / 2.0d;
zoomModel.setZoomFactor(Math.ceil(factor));
}
}
}
}
Aggregations