[follow-up] Fix JBHiDPIScaledImage used for drawing.

Create a delegate BufferedImage for JBHiDPIScaledImage used for drawing to meet the logic of UIUtil.drawImage(JBHiDPIScaledImage).
This commit is contained in:
Anton Tarasov
2016-09-06 16:50:03 +03:00
parent c9521d024f
commit b1af9cb9ef
@@ -37,10 +37,7 @@ public class JBHiDPIScaledImage extends BufferedImage {
* @param type type of the created image
*/
public JBHiDPIScaledImage(int width, int height, int type) {
super(2 * width, 2 * height, type);
myImage = null;
myWidth = width;
myHeight = height;
this(new BufferedImage(width * 2, height * 2, type), width, height, type);
}
/**
@@ -84,11 +81,10 @@ public class JBHiDPIScaledImage extends BufferedImage {
@Override
public Graphics2D createGraphics() {
assert myImage == null : "graphics should only be created for the image used for drawing";
Graphics2D g = super.createGraphics();
if (myImage == null) {
return new HiDPIScaledGraphics(g);
assert myImage instanceof BufferedImage : "graphics should only be created for the image used for drawing";
if (myImage instanceof BufferedImage) {
return new HiDPIScaledGraphics(((BufferedImage)myImage).createGraphics());
}
return g;
return super.createGraphics();
}
}