diff --git a/platform/platform-api/src/com/intellij/ui/SizedIcon.java b/platform/platform-api/src/com/intellij/ui/SizedIcon.java index f4ca493ff209..ef4bb0d5b186 100644 --- a/platform/platform-api/src/com/intellij/ui/SizedIcon.java +++ b/platform/platform-api/src/com/intellij/ui/SizedIcon.java @@ -32,50 +32,40 @@ public class SizedIcon extends JBUI.JBAbstractIcon implements Icon, ScalableIcon private float myScale = 1f; public SizedIcon(Icon delegate, int width, int height) { - myDelegate = delegate; + myScaledDelegate = myDelegate = delegate; myWidth = width; myHeight = height; } @Override public void paintIcon(Component c, Graphics g, int x, int y) { - int dx = scaleVal(myWidth) - delegate().getIconWidth(); - int dy = scaleVal(myHeight) - delegate().getIconHeight(); + int dx = scaleVal(myWidth) - myScaledDelegate.getIconWidth(); + int dy = scaleVal(myHeight) - myScaledDelegate.getIconHeight(); if (dx > 0 || dy > 0) { - delegate().paintIcon(c, g, x + dx/2, y + dy/2); + myScaledDelegate.paintIcon(c, g, x + dx/2, y + dy/2); } else { - delegate().paintIcon(c, g, x, y); + myScaledDelegate.paintIcon(c, g, x, y); } } - public Icon delegate() { - return myScaledDelegate != null ? myScaledDelegate : myDelegate; - } - @Override public int scaleVal(int n) { return super.scaleVal(myScale == 1f ? n : (int) (n * myScale)); } public int getIconWidth() { - if (delegate() instanceof ScalableIcon) { - return delegate().getIconWidth(); - } return scaleVal(myWidth); } public int getIconHeight() { - if (delegate() instanceof ScalableIcon) { - return delegate().getIconHeight(); - } return scaleVal(myHeight); } @Override public Icon scale(float scaleFactor) { if (scaleFactor == 1f) { - myScaledDelegate = null; + myScaledDelegate = myDelegate; } else if (myDelegate instanceof ScalableIcon) { myScaledDelegate = ((ScalableIcon)myDelegate).scale(scaleFactor); }