Jupyter: improve image panel

This commit is contained in:
Ekaterina Tuzova
2017-05-29 14:42:20 +03:00
parent 9085c10a19
commit 5b20d8a1ff
@@ -49,7 +49,13 @@ public class IpnbImagePanel extends IpnbCodeOutputPanel<IpnbImageOutputCell> {
public void paintComponent(Graphics g) {
final Icon icon = getIcon();
if (icon instanceof ImageIcon) {
g.drawImage(((ImageIcon)icon).getImage(), 0, 0, getWidth(), getHeight(), this);
final Image image = ((ImageIcon)icon).getImage();
if (getWidth() < image.getWidth(null)) {
g.drawImage(image, 0, 0, getWidth(), getHeight(), this);
}
else {
super.paintComponent(g);
}
}
else {
super.paintComponent(g);