diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index 4c3925f745cd..0ab45169f951 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -115,8 +115,6 @@ ide.javafx.tips.description=(Experimental) Use JavaFX Browser for 'Tips of the D ide.index.image.max.size=10 ide.index.image.max.size.description=Max size of an image to index, in megabytes -ide.cached.image.max.size=1.5 -ide.cached.image.max.size.description=Max size of an image to cache, in megabytes no.window.actions.in.editor=false no.window.actions.in.editor.description=Disables window actions "Stretch to.." within focused editor as before. diff --git a/platform/util/src/com/intellij/util/SystemProperties.java b/platform/util/src/com/intellij/util/SystemProperties.java index 85ba853c02ad..776ff41318fd 100644 --- a/platform/util/src/com/intellij/util/SystemProperties.java +++ b/platform/util/src/com/intellij/util/SystemProperties.java @@ -73,6 +73,18 @@ public class SystemProperties { return defaultValue; } + public static float getFloatProperty(@NotNull String key, float defaultValue) { + String value = System.getProperty(key); + if (value != null) { + try { + return Float.parseFloat(value); + } + catch (NumberFormatException ignored) { + } + } + return defaultValue; + } + /** * Returns the value of given property as a boolean, or {@code defaultValue} if the property is not specified or malformed. */ diff --git a/platform/util/ui/src/com/intellij/util/ImageLoader.java b/platform/util/ui/src/com/intellij/util/ImageLoader.java index 080306a3d0e3..de3bdd146eb7 100644 --- a/platform/util/ui/src/com/intellij/util/ImageLoader.java +++ b/platform/util/ui/src/com/intellij/util/ImageLoader.java @@ -7,7 +7,6 @@ import com.intellij.openapi.util.io.BufferExposingByteArrayInputStream; import com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.io.FileUtilRt; -import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.util.text.StringUtilRt; import com.intellij.util.containers.ContainerUtil; @@ -42,9 +41,12 @@ import static com.intellij.util.ui.JBUIScale.DerivedScaleType.PIX_SCALE; import static com.intellij.util.ui.JBUIScale.ScaleType.OBJ_SCALE; public class ImageLoader implements Serializable { - private static final Logger LOG = Logger.getInstance("#com.intellij.util.ImageLoader"); + @NotNull + private static Logger getLogger() { + return Logger.getInstance("#com.intellij.util.ImageLoader"); + } - public static final long CACHED_IMAGE_MAX_SIZE = (long)(Registry.doubleValue("ide.cached.image.max.size") * 1024 * 1024); + public static final long CACHED_IMAGE_MAX_SIZE = (long)(SystemProperties.getFloatProperty("ide.cached.image.max.size", 1.5f) * 1024 * 1024); private static final ConcurrentMap> ourCache = ContainerUtil.createConcurrentSoftValueMap(); public static void clearCache() { @@ -106,7 +108,7 @@ public class ImageLoader implements Serializable { // Either {inputStream} or {path} should be defined if (stream == null) { if (StringUtil.isEmpty(path)) { - LOG.warn("empty image path", new Throwable()); + getLogger().warn("empty image path", new Throwable()); return null; } @@ -201,7 +203,7 @@ public class ImageLoader implements Serializable { return image; } catch (Exception ex) { - LOG.error(ex); + getLogger().error(ex); } return null; } @@ -274,8 +276,11 @@ public class ImageLoader implements Serializable { for (ImageDesc desc : this) { try { Image image = desc.load(useCache); - if (image == null) continue; - LOG.debug("Loaded image: " + desc); + if (image == null) { + continue; + } + + getLogger().debug("Loaded image: " + desc); return converters.convert(image, desc); } catch (IOException ignore) { @@ -391,7 +396,7 @@ public class ImageLoader implements Serializable { mediatracker.waitForID(1, 5000); } catch (InterruptedException ex) { - LOG.info(ex); + getLogger().info(ex); } return !mediatracker.isErrorID(1); } @@ -530,7 +535,7 @@ public class ImageLoader implements Serializable { return ImageConverterChain.create().withFilter(filter).withHiDPI(ctx).convert(image, desc); } catch (IOException ex) { - LOG.error(ex); + getLogger().error(ex); } return null; } @@ -544,7 +549,7 @@ public class ImageLoader implements Serializable { final int h = icon.getHeight(null); if (w <= 0 || h <= 0) { - LOG.error("negative image size: w=" + w + ", h=" + h + ", path=" + f.getPath()); + getLogger().error("negative image size: w=" + w + ", h=" + h + ", path=" + f.getPath()); return null; } diff --git a/platform/util/ui/src/com/intellij/util/ui/JBUI.java b/platform/util/ui/src/com/intellij/util/ui/JBUI.java index 39f615b51297..051e0be7af92 100644 --- a/platform/util/ui/src/com/intellij/util/ui/JBUI.java +++ b/platform/util/ui/src/com/intellij/util/ui/JBUI.java @@ -12,7 +12,6 @@ import com.intellij.ui.JBColor; import com.intellij.ui.border.CustomLineBorder; import com.intellij.util.LazyInitializer.MutableNotNullValue; import com.intellij.util.LazyInitializer.NullableValue; -import com.intellij.util.ObjectUtils; import com.intellij.util.SystemProperties; import com.intellij.util.ui.JBUIScale.DerivedScaleType; import com.intellij.util.ui.JBUIScale.Scale; @@ -122,7 +121,9 @@ public class JBUI { @Override protected void onInitialized(@Nullable Float scale) { - if (isNotNull()) setUserScaleFactor(ObjectUtils.notNull(scale)); + if (isNotNull()) { + setUserScaleFactor(scale); + } } };