mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
Refactor ComponentSkin.skins to compSkins in FSkin
This commit is contained in:
@@ -78,14 +78,6 @@ public enum FSkin {
|
||||
|
||||
|
||||
public static class ComponentSkin<T extends Component> {
|
||||
private static final HashMap<Component, ComponentSkin<?>> skins = new HashMap<Component, ComponentSkin<?>>();
|
||||
|
||||
private static void reapplyAll() {
|
||||
for (ComponentSkin<?> compSkin : skins.values()) {
|
||||
compSkin.reapply();
|
||||
}
|
||||
}
|
||||
|
||||
protected T comp;
|
||||
private SkinColor foreground, background;
|
||||
private SkinFont font;
|
||||
@@ -458,75 +450,77 @@ public enum FSkin {
|
||||
}
|
||||
}
|
||||
|
||||
private static final HashMap<Component, ComponentSkin<?>> compSkins = new HashMap<Component, ComponentSkin<?>>();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends Component> ComponentSkin<T> get(T comp) {
|
||||
ComponentSkin<T> compSkin = (ComponentSkin<T>) ComponentSkin.skins.get(comp);
|
||||
ComponentSkin<T> compSkin = (ComponentSkin<T>) compSkins.get(comp);
|
||||
if (compSkin == null) {
|
||||
compSkin = new ComponentSkin<T>(comp);
|
||||
ComponentSkin.skins.put(comp, compSkin);
|
||||
compSkins.put(comp, compSkin);
|
||||
}
|
||||
return compSkin;
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends Window> WindowSkin<T> get(T comp) {
|
||||
WindowSkin<T> compSkin = (WindowSkin<T>) ComponentSkin.skins.get(comp);
|
||||
WindowSkin<T> compSkin = (WindowSkin<T>) compSkins.get(comp);
|
||||
if (compSkin == null) {
|
||||
compSkin = new WindowSkin<T>(comp);
|
||||
ComponentSkin.skins.put(comp, compSkin);
|
||||
compSkins.put(comp, compSkin);
|
||||
}
|
||||
return compSkin;
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends JComponent> JComponentSkin<T> get(T comp) {
|
||||
JComponentSkin<T> compSkin = (JComponentSkin<T>) ComponentSkin.skins.get(comp);
|
||||
JComponentSkin<T> compSkin = (JComponentSkin<T>) compSkins.get(comp);
|
||||
if (compSkin == null) {
|
||||
compSkin = new JComponentSkin<T>(comp);
|
||||
ComponentSkin.skins.put(comp, compSkin);
|
||||
compSkins.put(comp, compSkin);
|
||||
}
|
||||
return compSkin;
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends JLabel> JLabelSkin<T> get(T comp) {
|
||||
JLabelSkin<T> compSkin = (JLabelSkin<T>) ComponentSkin.skins.get(comp);
|
||||
JLabelSkin<T> compSkin = (JLabelSkin<T>) compSkins.get(comp);
|
||||
if (compSkin == null) {
|
||||
compSkin = new JLabelSkin<T>(comp);
|
||||
ComponentSkin.skins.put(comp, compSkin);
|
||||
compSkins.put(comp, compSkin);
|
||||
}
|
||||
return compSkin;
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends AbstractButton> AbstractButtonSkin<T> get(T comp) {
|
||||
AbstractButtonSkin<T> compSkin = (AbstractButtonSkin<T>) ComponentSkin.skins.get(comp);
|
||||
AbstractButtonSkin<T> compSkin = (AbstractButtonSkin<T>) compSkins.get(comp);
|
||||
if (compSkin == null) {
|
||||
compSkin = new AbstractButtonSkin<T>(comp);
|
||||
ComponentSkin.skins.put(comp, compSkin);
|
||||
compSkins.put(comp, compSkin);
|
||||
}
|
||||
return compSkin;
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends JTextComponent> JTextComponentSkin<T> get(T comp) {
|
||||
JTextComponentSkin<T> compSkin = (JTextComponentSkin<T>) ComponentSkin.skins.get(comp);
|
||||
JTextComponentSkin<T> compSkin = (JTextComponentSkin<T>) compSkins.get(comp);
|
||||
if (compSkin == null) {
|
||||
compSkin = new JTextComponentSkin<T>(comp);
|
||||
ComponentSkin.skins.put(comp, compSkin);
|
||||
compSkins.put(comp, compSkin);
|
||||
}
|
||||
return compSkin;
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends JTable> JTableSkin<T> get(T comp) {
|
||||
JTableSkin<T> compSkin = (JTableSkin<T>) ComponentSkin.skins.get(comp);
|
||||
JTableSkin<T> compSkin = (JTableSkin<T>) compSkins.get(comp);
|
||||
if (compSkin == null) {
|
||||
compSkin = new JTableSkin<T>(comp);
|
||||
ComponentSkin.skins.put(comp, compSkin);
|
||||
compSkins.put(comp, compSkin);
|
||||
}
|
||||
return compSkin;
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends FPanel> FPanelSkin<T> get(T comp) {
|
||||
FPanelSkin<T> compSkin = (FPanelSkin<T>) ComponentSkin.skins.get(comp);
|
||||
FPanelSkin<T> compSkin = (FPanelSkin<T>) compSkins.get(comp);
|
||||
if (compSkin == null) {
|
||||
compSkin = new FPanelSkin<T>(comp);
|
||||
ComponentSkin.skins.put(comp, compSkin);
|
||||
compSkins.put(comp, compSkin);
|
||||
}
|
||||
return compSkin;
|
||||
}
|
||||
@@ -535,10 +529,10 @@ public enum FSkin {
|
||||
if (comp instanceof IDisposable) { //dispose component itself if possible
|
||||
((IDisposable)comp).dispose();
|
||||
}
|
||||
ComponentSkin<?> compSkin = ComponentSkin.skins.get(comp);
|
||||
ComponentSkin<?> compSkin = compSkins.get(comp);
|
||||
if (compSkin != null) {
|
||||
compSkin.comp = null;
|
||||
ComponentSkin.skins.remove(comp);
|
||||
compSkins.remove(comp);
|
||||
}
|
||||
if (comp instanceof Container) {
|
||||
//dispose skins for child components
|
||||
@@ -1741,7 +1735,9 @@ public enum FSkin {
|
||||
loadFull(false);
|
||||
|
||||
//reapply skin to all skinned components
|
||||
ComponentSkin.reapplyAll();
|
||||
for (ComponentSkin<?> compSkin : compSkins.values()) {
|
||||
compSkin.reapply();
|
||||
}
|
||||
|
||||
//refresh certain components skinned via look and feel
|
||||
Singletons.getControl().getForgeMenu().refresh();
|
||||
|
||||
Reference in New Issue
Block a user