|
|
|
@ -27,13 +27,16 @@ import javax.swing.*;
|
|
|
|
|
import javax.swing.border.Border; |
|
|
|
|
import java.awt.*; |
|
|
|
|
import java.lang.ref.WeakReference; |
|
|
|
|
import java.util.Collections; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.WeakHashMap; |
|
|
|
|
|
|
|
|
|
public final class DarkBorders { |
|
|
|
|
|
|
|
|
|
public static Map<WeakLineBorder, WeakReference<WeakLineBorder>> lineBorderMap = new WeakHashMap<>(); |
|
|
|
|
private static Map<WeakLineBorder, WeakReference<WeakLineBorder>> lineWidgetBorderMap = new WeakHashMap<>(); |
|
|
|
|
private static Map<WeakLineBorder, WeakReference<WeakLineBorder>> lineBorderMap = |
|
|
|
|
Collections.synchronizedMap(new WeakHashMap<>()); |
|
|
|
|
private static Map<WeakLineBorder, WeakReference<WeakLineBorder>> lineWidgetBorderMap = |
|
|
|
|
Collections.synchronizedMap(new WeakHashMap<>()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static Border createLineBorder(final int top, final int left, final int bottom, final int right) { |
|
|
|
@ -45,15 +48,17 @@ public final class DarkBorders {
|
|
|
|
|
final Map<WeakLineBorder, WeakReference<WeakLineBorder>> map, final String key) { |
|
|
|
|
WeakLineBorder border = new WeakLineBorder(top, left, bottom, right); |
|
|
|
|
if (map.containsKey(border)) { |
|
|
|
|
return map.get(border).get(); |
|
|
|
|
} else { |
|
|
|
|
border.setColor(UIManager.getColor(key)); |
|
|
|
|
map.put(border, new WeakReference<>(border)); |
|
|
|
|
return border; |
|
|
|
|
WeakReference<WeakLineBorder> ref = map.get(border); |
|
|
|
|
if (ref != null) { |
|
|
|
|
WeakLineBorder b = ref.get(); |
|
|
|
|
if (b != null) return b; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
border.setColor(UIManager.getColor(key)); |
|
|
|
|
map.put(border, new WeakReference<>(border)); |
|
|
|
|
return border; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static Border createWidgetLineBorder(final int top, final int left, final int bottom, final int right) { |
|
|
|
|
return createBorder(top, left, bottom, right, lineWidgetBorderMap, "borderSecondary"); |
|
|
|
|
} |
|
|
|
|