Skip to content

Commit

Permalink
#213 generate already scaled image
Browse files Browse the repository at this point in the history
  • Loading branch information
krasa committed Mar 29, 2019
1 parent 8ca95f2 commit c4f01f6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<idea-plugin version="2">
<name>PlantUML integration</name>
<version>2.13.0</version>
<version>2.13.1</version>
<vendor url="https://github.com/esteinberg/plantuml4idea/">Eugene Steinberg</vendor>
<!-- IJ 12+ -->
<idea-version since-build="182"/>
Expand Down
9 changes: 7 additions & 2 deletions src/org/plantuml/idea/rendering/PlantUmlRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Pair;
import com.intellij.util.ui.JBUI;
import net.sourceforge.plantuml.*;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.cucadiagram.Display;
Expand Down Expand Up @@ -103,7 +104,7 @@ private static void zoomDiagram(Diagram diagram, int zoom) {
UmlDiagram umlDiagram = (UmlDiagram) diagram;
Scale scale = umlDiagram.getScale();
if (scale == null) {
umlDiagram.setScale(new ScaleSimple(zoom / 100f));
umlDiagram.setScale(new ScaleSimple(getSystemScale() * zoom / 100f));
}
} else if (diagram instanceof NewpagedDiagram) {
NewpagedDiagram newpagedDiagram = (NewpagedDiagram) diagram;
Expand All @@ -112,13 +113,17 @@ private static void zoomDiagram(Diagram diagram, int zoom) {
DescriptionDiagram descriptionDiagram = (DescriptionDiagram) page;
Scale scale = descriptionDiagram.getScale();
if (scale == null) {
descriptionDiagram.setScale(new ScaleSimple(zoom / 100f));
descriptionDiagram.setScale(new ScaleSimple(getSystemScale() * zoom / 100f));
}
}
}
}
}

private static double getSystemScale() {
return JBUI.ScaleContext.create().getScale(JBUI.ScaleType.SYS_SCALE);
}

@NotNull
protected static Titles getTitles(int totalPages, List<BlockUml> blocks) {
List<String> titles = new ArrayList<String>(totalPages);
Expand Down
3 changes: 1 addition & 2 deletions src/org/plantuml/idea/toolwindow/PlantUmlImageLabel.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.ui.JBColor;
import com.intellij.ui.PopupHandler;
import com.intellij.util.ImageLoader;
import com.intellij.util.ui.ImageUtil;
import com.intellij.util.ui.JBImageIcon;
import com.intellij.util.ui.JBUI;
Expand Down Expand Up @@ -90,7 +89,7 @@ private static void setDiagram(@NotNull final ImageItem imageItem, final JLabel

JBUI.ScaleContext ctx = JBUI.ScaleContext.create(label);
scaledImage = ImageUtil.ensureHiDPI(image, ctx);
scaledImage = ImageLoader.scaleImage(scaledImage, ctx.getScale(JBUI.ScaleType.SYS_SCALE));
// scaledImage = ImageLoader.scaleImage(scaledImage, ctx.getScale(JBUI.ScaleType.SYS_SCALE));

label.setIcon(new JBImageIcon(scaledImage));
label.addMouseListener(new PopupHandler() {
Expand Down

0 comments on commit c4f01f6

Please sign in to comment.