Commit ba804d16 authored by Alexey Kudravtsev's avatar Alexey Kudravtsev
Browse files

cleanup

parent 24fc5da5
Branches unavailable Tags unavailable
No related merge requests found
Showing with 20 additions and 30 deletions
+20 -30
......@@ -18,6 +18,7 @@ package com.intellij.ui;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.ScalableIcon;
import com.intellij.util.ArrayUtil;
import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.JBUI.CachingScalableJBIcon;
import org.intellij.lang.annotations.MagicConstant;
import org.jetbrains.annotations.NotNull;
......@@ -26,11 +27,6 @@ import javax.swing.*;
import java.awt.*;
import java.util.Arrays;
import static com.intellij.util.ui.JBUI.ScaleType.OBJ_SCALE;
import static com.intellij.util.ui.JBUI.ScaleType.USR_SCALE;
import static java.lang.Math.ceil;
import static java.lang.Math.floor;
public class LayeredIcon extends CachingScalableJBIcon<LayeredIcon> {
private static final Logger LOG = Logger.getInstance("#com.intellij.ui.LayeredIcon");
private final Icon[] myIcons;
......@@ -46,7 +42,7 @@ public class LayeredIcon extends CachingScalableJBIcon<LayeredIcon> {
private int myHeight;
{
getScaleContext().addUpdateListener(() -> updateSize());
getScaleContext().addUpdateListener(this::updateSize);
setAutoUpdateScaleContext(false);
}
......@@ -233,8 +229,8 @@ public class LayeredIcon extends CachingScalableJBIcon<LayeredIcon> {
for (int i = 0; i < icons.length; i++) {
Icon icon = icons[i];
if (icon == null || myDisabledLayers[i]) continue;
int xOffset = (int)floor(x + scaleVal(myXShift + myHShifts(i), OBJ_SCALE));
int yOffset = (int)floor(y + scaleVal(myYShift + myVShifts(i), OBJ_SCALE));
int xOffset = (int)Math.floor(x + scaleVal(myXShift + myHShifts(i), JBUI.ScaleType.OBJ_SCALE));
int yOffset = (int)Math.floor(y + scaleVal(myYShift + myVShifts(i), JBUI.ScaleType.OBJ_SCALE));
icon.paintIcon(c, g, xOffset, yOffset);
}
}
......@@ -252,7 +248,7 @@ public class LayeredIcon extends CachingScalableJBIcon<LayeredIcon> {
getScaleContext().update();
if (myWidth <= 1) updateSize();
return (int)ceil(scaleVal(myWidth, OBJ_SCALE));
return (int)Math.ceil(scaleVal(myWidth, JBUI.ScaleType.OBJ_SCALE));
}
@Override
......@@ -260,15 +256,15 @@ public class LayeredIcon extends CachingScalableJBIcon<LayeredIcon> {
getScaleContext().update();
if (myHeight <= 1) updateSize();
return (int)ceil(scaleVal(myHeight, OBJ_SCALE));
return (int)Math.ceil(scaleVal(myHeight, JBUI.ScaleType.OBJ_SCALE));
}
private int myHShifts(int i) {
return (int)floor(scaleVal(myHShifts[i], USR_SCALE));
return (int)Math.floor(scaleVal(myHShifts[i], JBUI.ScaleType.USR_SCALE));
}
private int myVShifts(int i) {
return (int)floor(scaleVal(myVShifts[i], USR_SCALE));
return (int)Math.floor(scaleVal(myVShifts[i], JBUI.ScaleType.USR_SCALE));
}
protected void updateSize() {
......@@ -276,11 +272,11 @@ public class LayeredIcon extends CachingScalableJBIcon<LayeredIcon> {
int maxX = Integer.MIN_VALUE;
int minY = Integer.MAX_VALUE;
int maxY = Integer.MIN_VALUE;
boolean hasNotNullIcons = false;
boolean allIconsAreNull = true;
for (int i = 0; i < myIcons.length; i++) {
Icon icon = myIcons[i];
if (icon == null) continue;
hasNotNullIcons = true;
allIconsAreNull = false;
int hShift = myHShifts(i);
int vShift = myVShifts(i);
minX = Math.min(minX, hShift);
......@@ -288,7 +284,7 @@ public class LayeredIcon extends CachingScalableJBIcon<LayeredIcon> {
minY = Math.min(minY, vShift);
maxY = Math.max(maxY, vShift + icon.getIconHeight());
}
if (!hasNotNullIcons) return;
if (allIconsAreNull) return;
myWidth = maxX - minX;
myHeight = maxY - minY;
......
......@@ -36,6 +36,7 @@ public class NonEmptyActionGroup extends DefaultActionGroup implements DumbAware
presentation.setVisible(getChildrenCount() > 0);
}
@Override
public boolean hideIfNoVisibleChildren() {
return true;
}
......
......@@ -32,8 +32,6 @@ import org.jetbrains.annotations.Nullable;
public class BackgroundableProcessIndicator extends ProgressWindow {
protected StatusBarEx myStatusBar;
@SuppressWarnings({"FieldAccessedSynchronizedAndUnsynchronized"})
private PerformInBackgroundOption myOption;
private TaskInfo myInfo;
......@@ -51,10 +49,6 @@ public class BackgroundableProcessIndicator extends ProgressWindow {
public void enteredDumbMode() {
cancel();
}
@Override
public void exitDumbMode() {
}
});
}
}
......
......@@ -78,7 +78,7 @@ public final class IconLoader {
private IconLoader() { }
public static void installPathPatcher(IconPathPatcher patcher) {
public static void installPathPatcher(@NotNull IconPathPatcher patcher) {
ourPatchers.add(patcher);
clearCache();
}
......@@ -346,7 +346,6 @@ public final class IconLoader {
public static Icon getTransparentIcon(@NotNull final Icon icon, final float alpha) {
return new RetrievableIcon() {
@Nullable
@Override
public Icon retrieveIcon() {
return icon;
......@@ -396,7 +395,7 @@ public final class IconLoader {
icon = ((LazyIcon)icon).getOrComputeIcon();
}
if (icon instanceof CachedImageIcon) {
Image img = ((CachedImageIcon)icon).loadFromUrl(ScaleContext.create(USR_SCALE.of(1d), SYS_SCALE.of(1d)));
Image img = ((CachedImageIcon)icon).loadFromUrl(ScaleContext.create(USR_SCALE.of(1), SYS_SCALE.of(1)));
if (img != null) {
icon = new ImageIcon(img);
}
......@@ -412,7 +411,7 @@ public final class IconLoader {
private URL myUrl;
private volatile boolean dark;
private volatile int numberOfPatchers = ourPatchers.size();
private boolean svg;
private final boolean svg;
private boolean useCacheOnLoad = true;
private ImageFilter[] myFilters;
......@@ -436,7 +435,7 @@ public final class IconLoader {
dark = icon.dark;
numberOfPatchers = icon.numberOfPatchers;
myFilters = icon.myFilters;
svg = myOriginalPath != null ? myOriginalPath.toLowerCase().endsWith("svg") : false;
svg = myOriginalPath != null && myOriginalPath.toLowerCase().endsWith("svg");
useCacheOnLoad = icon.useCacheOnLoad;
}
......@@ -575,7 +574,7 @@ public final class IconLoader {
private static final int SCALED_ICONS_CACHE_LIMIT = 5;
// Map {pixel scale -> icon}
private Map<Double, SoftReference<ImageIcon>> scaledIconsCache = Collections.synchronizedMap(new LinkedHashMap<Double, SoftReference<ImageIcon>>(SCALED_ICONS_CACHE_LIMIT) {
private final Map<Double, SoftReference<ImageIcon>> scaledIconsCache = Collections.synchronizedMap(new LinkedHashMap<Double, SoftReference<ImageIcon>>(SCALED_ICONS_CACHE_LIMIT) {
@Override
public boolean removeEldestEntry(Map.Entry<Double, SoftReference<ImageIcon>> entry) {
return size() > SCALED_ICONS_CACHE_LIMIT;
......@@ -585,7 +584,7 @@ public final class IconLoader {
/**
* Retrieves the orig icon scaled by the provided scale.
*/
public ImageIcon getOrScaleIcon(final float scale) {
ImageIcon getOrScaleIcon(final float scale) {
updateScale(OBJ_SCALE.of(scale));
ImageIcon icon = SoftReference.dereference(scaledIconsCache.get(getScale(PIX_SCALE)));
......@@ -606,8 +605,8 @@ public final class IconLoader {
}
icon = checkIcon(image, myUrl);
if (icon != null && (icon.getIconWidth() * icon.getIconHeight() * 4) < ImageLoader.CACHED_IMAGE_MAX_SIZE) {
scaledIconsCache.put(getScale(PIX_SCALE), new SoftReference<ImageIcon>(icon));
if (icon != null && icon.getIconWidth() * icon.getIconHeight() * 4 < ImageLoader.CACHED_IMAGE_MAX_SIZE) {
scaledIconsCache.put((double)getScale(PIX_SCALE), new SoftReference<ImageIcon>(icon));
}
return icon;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment