Browse Source

Installation: Reserve needed space for UIDefaults.

spotless
weisj 3 years ago
parent
commit
ff845c4823
No known key found for this signature in database
GPG Key ID: 31124CB75461DA2A
  1. 11
      core/src/main/java/com/github/weisj/darklaf/DarkLaf.java

11
core/src/main/java/com/github/weisj/darklaf/DarkLaf.java

@ -44,6 +44,10 @@ public class DarkLaf extends ThemedLookAndFeel {
public static final String ALLOW_NATIVE_CODE_FLAG = DarkLaf.SYSTEM_PROPERTY_PREFIX + "allowNativeCode"; public static final String ALLOW_NATIVE_CODE_FLAG = DarkLaf.SYSTEM_PROPERTY_PREFIX + "allowNativeCode";
private static final Logger LOGGER = LogUtil.getLogger(DarkLaf.class); private static final Logger LOGGER = LogUtil.getLogger(DarkLaf.class);
private static final float DEFAULTS_LOAD_FACTOR = 0.75f;
// Ensure we don't have to resize during installation.
private static final int DEFAULTS_CAPACITY = (int) Math.ceil(1430 / DEFAULTS_LOAD_FACTOR);
/* /*
* All tasks for initializing the ui defaults in order of execution. * All tasks for initializing the ui defaults in order of execution.
*/ */
@ -59,6 +63,7 @@ public class DarkLaf extends ThemedLookAndFeel {
new PlatformDefaultsInitTask(), new PlatformDefaultsInitTask(),
new UserInitTask(), new UserInitTask(),
new UtilityDefaultsInitTask()}; new UtilityDefaultsInitTask()};
/* /*
* The base look and feel. This may vary to handle different platform support. * The base look and feel. This may vary to handle different platform support.
*/ */
@ -142,7 +147,10 @@ public class DarkLaf extends ThemedLookAndFeel {
@Override @Override
public UIDefaults getDefaults() { public UIDefaults getDefaults() {
final UIDefaults defaults = base.getDefaults(); final UIDefaults baseDefaults = base.getDefaults();
final UIDefaults defaults = new UIDefaults(DEFAULTS_CAPACITY, DEFAULTS_LOAD_FACTOR);
defaults.putAll(baseDefaults);
final Theme currentTheme = getTheme(); final Theme currentTheme = getTheme();
for (DefaultsInitTask task : INIT_TASKS) { for (DefaultsInitTask task : INIT_TASKS) {
if (task.onlyDuringInstallation() && !isInitialized) continue; if (task.onlyDuringInstallation() && !isInitialized) continue;
@ -151,6 +159,7 @@ public class DarkLaf extends ThemedLookAndFeel {
if (isInitialized) { if (isInitialized) {
postInstall(); postInstall();
} }
System.out.println(defaults.size());
return defaults; return defaults;
} }

Loading…
Cancel
Save