diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..fb74315 --- /dev/null +++ b/build.xml @@ -0,0 +1,8 @@ + + + + + + Builds, tests, and runs the project org.idp.laf. + + diff --git a/manifest.mf b/manifest.mf new file mode 100644 index 0000000..fb38ca1 --- /dev/null +++ b/manifest.mf @@ -0,0 +1,7 @@ +Manifest-Version: 1.0 +AutoUpdate-Show-In-Client: true +OpenIDE-Module: org.idp.laf +OpenIDE-Module-Localizing-Bundle: org/idp/laf/Bundle.properties +OpenIDE-Module-Specification-Version: 1.0 +OpenIDE-Module-Install: org/idp/laf/Installer.class +OpenIDE-Module-Requires: org.openide.windows.WindowManager \ No newline at end of file diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml new file mode 100644 index 0000000..767aa16 --- /dev/null +++ b/nbproject/build-impl.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties new file mode 100644 index 0000000..dc23b16 --- /dev/null +++ b/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=41e2275d +build.xml.script.CRC32=1097797e +build.xml.stylesheet.CRC32=a56c6a5b@2.67.1 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=41e2275d +nbproject/build-impl.xml.script.CRC32=e0c60086 +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.67.1 diff --git a/nbproject/platform.properties b/nbproject/platform.properties new file mode 100644 index 0000000..5de374d --- /dev/null +++ b/nbproject/platform.properties @@ -0,0 +1,15 @@ +cluster.path=\ + ${nbplatform.active.dir}/java:\ + ${nbplatform.active.dir}/apisupport:\ + ${nbplatform.active.dir}/harness:\ + ${nbplatform.active.dir}/cnd:\ + ${nbplatform.active.dir}/ide:\ + ${nbplatform.active.dir}/profiler:\ + ${nbplatform.active.dir}/javafx:\ + ${nbplatform.active.dir}/platform:\ + ${nbplatform.active.dir}/dlight:\ + ${nbplatform.active.dir}/extide:\ + ${nbplatform.active.dir}/politenetbeans:\ + ${nbplatform.active.dir}/websvccommon:\ + ${nbplatform.active.dir}/nb +nbplatform.active=default diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 0000000..42e2a93 --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,3 @@ +javac.source=1.6 +javac.compilerargs=-Xlint -Xlint:-serial +nbm.needs.restart=true diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000..ab50e33 --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,72 @@ + + + org.netbeans.modules.apisupport.project + + + org.idp.laf + + + + org.netbeans.modules.settings + + + + 1 + 1.45.1 + + + + org.netbeans.swing.plaf + + + + 1.37.1 + + + + org.netbeans.swing.tabcontrol + + + + 1.51.1 + + + + org.openide.modules + + + + 7.43.1 + + + + org.openide.util + + + + 8.39.1 + + + + org.openide.util.lookup + + + + 8.25.1 + + + + org.openide.windows + + + + 6.71.1 + + + + + org.idp.laf + + + + diff --git a/src/org/idp/laf/Bundle.properties b/src/org/idp/laf/Bundle.properties new file mode 100644 index 0000000..c2435f6 --- /dev/null +++ b/src/org/idp/laf/Bundle.properties @@ -0,0 +1 @@ +OpenIDE-Module-Name=[idP!] Crew LAF diff --git a/src/org/idp/laf/Installer.java b/src/org/idp/laf/Installer.java new file mode 100644 index 0000000..985ae07 --- /dev/null +++ b/src/org/idp/laf/Installer.java @@ -0,0 +1,32 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.idp.laf; + +import javax.swing.SwingUtilities; +import org.openide.modules.ModuleInstall; + +/** + * + * @author Edward M. Kagan + */ +public class Installer extends ModuleInstall +{ + + @Override + public void restored() { + SwingUtilities.invokeLater(new Runnable() + { + @Override + public void run() + { + LAF_killer.load_ui(); + } + }); + } + + + +} diff --git a/src/org/idp/laf/LAF_killer.java b/src/org/idp/laf/LAF_killer.java new file mode 100644 index 0000000..e394e1c --- /dev/null +++ b/src/org/idp/laf/LAF_killer.java @@ -0,0 +1,315 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.idp.laf; + + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; +import java.io.PrintWriter; +import java.nio.charset.Charset; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; +import javax.swing.plaf.metal.DefaultMetalTheme; +import javax.swing.plaf.metal.MetalLookAndFeel; +import javax.swing.plaf.metal.MetalTheme; +import org.idp.laf.settings.Color; +import static org.idp.laf.settings.Color.ColorClass.AT; +import static org.idp.laf.settings.Color.ColorClass.SS; +import static org.idp.laf.settings.Color.ColorClass.SF; +import org.idp.laf.settings.Font; +import static org.idp.laf.settings.Font.FontClass.FA; +import static org.idp.laf.settings.Font.FontClass.FS; +import org.idp.laf.settings.Gradient; +import org.openide.util.Exceptions; + +/** + * + * @author Edward M. Kagan + */ +public class LAF_killer { + + public static void load_ui(){ + + try { +// if (UIManager.getLookAndFeel().getName().equals("Metal")) +// { +// System.out.println(">>> Hmmm... You smart enought to use Metal theme - OK."); +// MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme()); +// System.out.println(">>>> l&f NAME = " + UIManager.getLookAndFeel().getName() + " / " + javax.swing.plaf.metal.MetalLookAndFeel.getCurrentTheme().getName()); +// } +// else +// { + + System.out.println(">>>> TRYING TO CHANGE L&F"); + MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme()); + UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); + System.out.println(">>>> l&f NAME = " + UIManager.getLookAndFeel().getName() + " / " + javax.swing.plaf.metal.MetalLookAndFeel.getCurrentTheme().getName()); + //} + + Object [] keys = new Object[UIManager.getLookAndFeelDefaults().keySet().size()]; + + String settings = ""; + + UIManager.getLookAndFeelDefaults().keySet().toArray(keys); + +//dump (keys); +load (); + + + + + + } catch (ClassNotFoundException ex) { + Logger.getLogger(LAF_killer.class.getName()).log(Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + Logger.getLogger(LAF_killer.class.getName()).log(Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + Logger.getLogger(LAF_killer.class.getName()).log(Level.SEVERE, null, ex); + } catch (UnsupportedLookAndFeelException ex) { + Logger.getLogger(LAF_killer.class.getName()).log(Level.SEVERE, null, ex); + } + + + } + + + private static void dump(Object [] keys) + { + + ArrayList color_map = new ArrayList(); + ArrayList font_map = new ArrayList(); + ArrayList gradient_map = new ArrayList(); + + for (int i = 0; i < keys.length; i ++) + { + + if (UIManager.getDefaults().get(keys[i]) != null){ + //This check is needed to overcome null_pointer on first run for this shitty icons + // 269 >> Menu.checkIcon : null + // 272 >> MenuItem.checkIcon : null + + + // + if (UIManager.getDefaults().get(keys[i]).getClass().equals(javax.swing.plaf.ColorUIResource.class)) + { + javax.swing.plaf.ColorUIResource color = (javax.swing.plaf.ColorUIResource) UIManager.getDefaults().get(keys[i]); + Color c = new Color (keys[i].toString(), SF, color.getRed(),color.getGreen(),color.getBlue(),color.getAlpha()); + color_map.add(c); + } + else if (UIManager.getDefaults().get(keys[i]).getClass().equals(sun.swing.PrintColorUIResource.class)) + { + sun.swing.PrintColorUIResource color = (sun.swing.PrintColorUIResource) UIManager.getDefaults().get(keys[i]); + Color c = new Color (keys[i].toString(), SS, color.getRed(),color.getGreen(),color.getBlue(),color.getAlpha()); + color_map.add(c); + } + else if (UIManager.getDefaults().get(keys[i]).getClass().equals(java.awt.Color.class)) + { + java.awt.Color color = (java.awt.Color) UIManager.getDefaults().get(keys[i]); + Color c = new Color (keys[i].toString(), AT, color.getRed(),color.getGreen(),color.getBlue(),color.getAlpha()); + color_map.add(c); + } + // + + // + + else if (UIManager.getDefaults().get(keys[i]).getClass().equals(javax.swing.plaf.FontUIResource.class)) + { + javax.swing.plaf.FontUIResource fnt = (javax.swing.plaf.FontUIResource) UIManager.getDefaults().get(keys[i]); + Font f = new Font (keys[i].toString(), FS, fnt.getFamily(), fnt.getName(), fnt.getStyle(), fnt.getSize()); + font_map.add(f); + + // System.out.println(i + " FX>> " + keys[i] + " : " + UIManager.getDefaults().get(keys[i])); + } + else if (UIManager.getDefaults().get(keys[i]).getClass().equals(java.awt.Font.class)) + { + java.awt.Font fnt = (java.awt.Font) UIManager.getDefaults().get(keys[i]); + Font f = new Font (keys[i].toString(), FA, fnt.getFamily(), fnt.getName(), fnt.getStyle(), fnt.getSize()); + font_map.add(f); + //System.out.println(i + " FY>> " + keys[i] + " : " + UIManager.getDefaults().get(keys[i])); + } + + // + + // +// + else if (keys[i].equals("MenuBar.gradient") || + keys[i].equals("ScrollBar.gradient") || + keys[i].equals("ToggleButton.gradient") || + keys[i].equals("CheckBoxMenuItem.gradient") || + keys[i].equals("Slider.gradient") || + keys[i].equals("Button.gradient") || + keys[i].equals("CheckBox.gradient") || + keys[i].equals("RadioButtonMenuItem.gradient") || + keys[i].equals("Slider.focusGradient") || + keys[i].equals("RadioButton.gradient") || + keys[i].equals("InternalFrame.activeTitleGradient") + ) + { + //ArrayList always + //System.out.println(i + " GY>> " + UIManager.getDefaults().get(keys[i])); + List grad = (List) UIManager.getDefaults().get(keys[i]); +// for (int j = 0; j < grad.size(); j ++) +// { +// System.out.println(i + " >> " + grad.get(j).getClass()); +// } + + Gradient g = new Gradient(keys[i].toString(), ((Float)grad.get(0)), ((Float)grad.get(1)), + new Color ((javax.swing.plaf.ColorUIResource) grad.get(2)), + new Color ((javax.swing.plaf.ColorUIResource) grad.get(3)), + new Color ((javax.swing.plaf.ColorUIResource) grad.get(4))); + gradient_map.add(g); + } + + // + + } + else // Shitty test for unknown values - dont bother at all + { + System.out.println(i + " >> " + keys[i] + " : " + UIManager.getDefaults().get(keys[i])); + } + + } +// Looks scientific? Yeah, it's a formal test :) +// +// System.out.println("=============== ==============="); +// for (int i = 0; i < color_map.size(); i ++) +// { +// System.out.println(i + " : " + color_map.get(i)); +// } +// System.out.println("=============== ==============="); +// for (int i = 0; i < font_map.size(); i ++) +// { +// System.out.println(i + " : " + font_map.get(i)); +// } +// System.out.println("=============== ==============="); +// for (int i = 0; i < gradient_map.size(); i ++) +// { +// System.out.println(i + " : " + gradient_map.get(i)); +// } + + if (!new File (System.getProperty("user.home") + File.separator + ".idp_scheme").exists()) + { + new File (System.getProperty("user.home") + File.separator + ".idp_scheme").mkdir(); + } + +// File fileC = new File (); +// File fileF = new File (System.getProperty("user.home") + File.separator + ".idp_scheme/.ui_fonts"); +// File fileG = new File (System.getProperty("user.home") + File.separator + ".idp_scheme/.ui_gradients"); + + + try { + PrintWriter writer = new PrintWriter(System.getProperty("user.home") + File.separator + ".idp_scheme/.ui_colors", "UTF-8"); + for (int i = 0; i < color_map.size(); i ++) + { + writer.println(color_map.get(i)); + } + writer.close(); + + writer = new PrintWriter(System.getProperty("user.home") + File.separator + ".idp_scheme/.ui_fonts", "UTF-8"); + for (int i = 0; i < font_map.size(); i ++) + { + writer.println(font_map.get(i)); + } + writer.close(); + + writer = new PrintWriter(System.getProperty("user.home") + File.separator + ".idp_scheme/.ui_gradients", "UTF-8"); + for (int i = 0; i < gradient_map.size(); i ++) + { + System.out.println(gradient_map.get(i)); + writer.println(gradient_map.get(i)); + } + writer.close(); + + } catch (FileNotFoundException ex) { + Exceptions.printStackTrace(ex); + } catch (IOException ex) { + Exceptions.printStackTrace(ex); + } + + + + + + + + } + + private static void load() + { + + ArrayList color_map = new ArrayList(); + ArrayList font_map = new ArrayList(); + ArrayList gradient_map = new ArrayList(); + + try { + if (!new File (System.getProperty("user.home") + File.separator + ".idp_scheme").exists()) + { + System.err.println("FUCK OFF!"); + } + else + { + List C = Files.readAllLines(Paths.get(System.getProperty("user.home") + File.separator + ".idp_scheme/.ui_colors"), Charset.forName("UTF-8")); + for (String s : C) + { + color_map.add(new Color (s)); + } + + List F = Files.readAllLines(Paths.get(System.getProperty("user.home") + File.separator + ".idp_scheme/.ui_fonts"), Charset.forName("UTF-8")); + for (String s : F) + { + font_map.add(new Font (s)); + } + + List G = Files.readAllLines(Paths.get(System.getProperty("user.home") + File.separator + ".idp_scheme/.ui_gradients"), Charset.forName("UTF-8")); + for (String s : G) + { + gradient_map.add(new Gradient (s)); + } + + + System.out.println("=============== ==============="); + for (int i = 0; i < color_map.size(); i ++) + { + System.out.println(i + " : " + color_map.get(i)); + UIManager.put(color_map.get(i).getName(), color_map.get(i).getObject()); + } + System.out.println("=============== ==============="); + for (int i = 0; i < font_map.size(); i ++) + { + System.out.println(i + " : " + font_map.get(i)); + UIManager.put(font_map.get(i).getName(), font_map.get(i).getObject()); + } + System.out.println("=============== ==============="); + for (int i = 0; i < gradient_map.size(); i ++) + { + System.out.println(i + " : " + gradient_map.get(i)); + } + + + // + + + + } + + } catch (IOException ex) { + Exceptions.printStackTrace(ex); + } + + } + +} diff --git a/src/org/idp/laf/settings/Color.java b/src/org/idp/laf/settings/Color.java new file mode 100644 index 0000000..cae7550 --- /dev/null +++ b/src/org/idp/laf/settings/Color.java @@ -0,0 +1,139 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.idp.laf.settings; + +import java.io.Serializable; +import javax.swing.plaf.ColorUIResource; +import static org.idp.laf.settings.Color.ColorClass.AT; +import static org.idp.laf.settings.Color.ColorClass.SF; +import static org.idp.laf.settings.Color.ColorClass.SS; +import sun.swing.PrintColorUIResource; + +/** + * + * @author Edward M. Kagan + */ +public class Color implements Serializable{ + + + + public enum ColorClass { + SF (javax.swing.plaf.ColorUIResource.class), + SS (sun.swing.PrintColorUIResource.class), + AT (java.awt.Color.class); + + private final Class cls; + + ColorClass(Class cls) { + this.cls = cls; + } + + public Class getClazz() + { + return this.cls; + } + } + + int R; + int G; + int B; + int A; + String pname; + ColorClass cls; + + + public Color(javax.swing.plaf.ColorUIResource color) { + this.A = color.getAlpha(); + this.B = color.getBlue(); + this.G = color.getGreen(); + this.R = color.getRed(); + this.pname = "_"; + this.cls = SF; + } + + public Color(String pname, ColorClass cls, int red, int green, int blue, int alpha) { + this.A = alpha; + this.B = blue; + this.G = green; + this.R = red; + this.pname = pname; + this.cls = cls; + } + + @Override + public String toString() { + return "C[" + this.pname + ":" + this.cls + ":" + R + "," + G + "," + B + "," + A + "]"; + } + + public String toStringC() { + return "[" + this.pname + ":" + this.cls + ":" + R + "," + G + "," + B + "," + A + "]"; + } + + public Color (String str) + { + if (str.startsWith("C")) + { + String real = str.substring(2, str.length() - 1); + String [] vals = real.split(":"); + + this.pname = vals[0]; + if (vals[1].equals("SF")) + { + this.cls = SF; + } + else if (vals[1].equals("SS")) + { + this.cls = SS; + } + else if (vals[1].equals("AT")) + { + this.cls = AT; + } + + vals = vals[2].split(","); + + + this.R = Integer.parseInt(vals[0]); + this.G = Integer.parseInt(vals[1]); + this.B = Integer.parseInt(vals[2]); + this.A = Integer.parseInt(vals[3]); + + } + else + { + System.err.println("FUCK OFF - poor format"); + } + + + } + + public Object getObject () + { + java.awt.Color cc = new java.awt.Color(R, G, B, A); + switch (this.cls) + { + + case SF : { + + javax.swing.plaf.ColorUIResource res = new ColorUIResource(cc); + return res; + } + case SS : { + sun.swing.PrintColorUIResource res = new PrintColorUIResource(cc.getRGB(), cc); + return res; + } + case AT : { + return cc; + } + } + return null; + } + + public Object getName() { + return this.pname; + } + +} diff --git a/src/org/idp/laf/settings/Font.java b/src/org/idp/laf/settings/Font.java new file mode 100644 index 0000000..c41d2f2 --- /dev/null +++ b/src/org/idp/laf/settings/Font.java @@ -0,0 +1,116 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.idp.laf.settings; + +import java.io.Serializable; +import javax.swing.plaf.ColorUIResource; +import javax.swing.plaf.FontUIResource; +import static org.idp.laf.settings.Color.ColorClass.AT; +import static org.idp.laf.settings.Color.ColorClass.SF; +import static org.idp.laf.settings.Color.ColorClass.SS; +import static org.idp.laf.settings.Font.FontClass.FA; +import static org.idp.laf.settings.Font.FontClass.FS; +import sun.swing.PrintColorUIResource; + +/** + * + * @author Edward M. Kagan + */ +public class Font implements Serializable{ + + public enum FontClass { + FS (javax.swing.plaf.FontUIResource.class), + FA (java.awt.Font.class); + + private final Class cls; + + FontClass(Class cls) { + this.cls = cls; + } + + public Class getClazz() + { + return this.cls; + } + } + + String family; + String name; + int style; + int size; + String pname; + FontClass cls; + + + public Font(String pname, FontClass cls, String family, String name, int style, int size) { + this.family = family; + this.name = name; + this.size = size; + this.style = style; + this.pname = pname; + this.cls = cls; + } + + @Override + public String toString() { + return "F[" + this.pname + ":" + this.cls + ":" + family + "," + name + "," + size + "," + style + "]"; + } + + public Font (String str) + { + if (str.startsWith("F")) + { + String real = str.substring(2, str.length() - 1); + String [] vals = real.split(":"); + + this.pname = vals[0]; + if (vals[1].equals("FS")) + { + this.cls = FS; + } + else if (vals[1].equals("FA")) + { + this.cls = FA; + } + + vals = vals[2].split(","); + + + this.family = vals[0]; + this.name = vals[1]; + this.size = Integer.parseInt(vals[2]); + this.style = Integer.parseInt(vals[3]); + + + } + else + { + System.err.println("FUCK OFF - poor format"); + } + } + + public Object getObject () + { + java.awt.Font ff = new java.awt.Font(name, style, size); + + switch (this.cls) + { + case FS : { + javax.swing.plaf.FontUIResource res = new FontUIResource(ff); + return res; + } + case FA : { + return ff; + } + } + return null; + } + + public Object getName() { + return this.pname; + } + +} diff --git a/src/org/idp/laf/settings/Gradient.java b/src/org/idp/laf/settings/Gradient.java new file mode 100644 index 0000000..112d6a0 --- /dev/null +++ b/src/org/idp/laf/settings/Gradient.java @@ -0,0 +1,62 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.idp.laf.settings; + +import java.io.Serializable; +import static org.idp.laf.settings.Font.FontClass.FA; +import static org.idp.laf.settings.Font.FontClass.FS; + +/** + * + * @author Edward M. Kagan + */ +public class Gradient implements Serializable{ + + String pname; + float I; + float J; + Color A; + Color B; + Color C; + + public Gradient(String pname, float I, float J, Color A, Color B, Color C) { + this.pname = pname; + this.I = I; + this.J = J; + this.A = A; + this.B = B; + this.C = C; + } + + @Override + public String toString() { + return "G[" + this.pname + ";" + I + ";" + J + ";" + A.toString() + ";" + B.toString() + ";" + C.toString() + "]"; + } + + public Gradient (String str) + { + if (str.startsWith("G")) + { + String real = str.substring(2, str.length() - 1); + String [] vals = real.split(";"); + + this.pname = vals[0]; + System.out.println(">>" + vals[1]); + this.I = Float.parseFloat(vals[1]); + this.J = Float.parseFloat(vals[2]); + this.A = new Color(vals[3]); + this.B = new Color(vals[4]); + this.C = new Color(vals[5]); + } + else + { + System.err.println("FUCK OFF - poor format"); + } + + + } + +}