diff --git a/icon/color_wheel_dock_icon_by_andybaumgar-d3ezjgc.png b/icon/color_wheel_dock_icon_by_andybaumgar-d3ezjgc.png new file mode 100644 index 0000000..ef7e92b Binary files /dev/null and b/icon/color_wheel_dock_icon_by_andybaumgar-d3ezjgc.png differ diff --git a/icon/wh.png b/icon/wh.png new file mode 100644 index 0000000..4dd873b Binary files /dev/null and b/icon/wh.png differ diff --git a/icon/wh24.png b/icon/wh24.png new file mode 100644 index 0000000..5a2268d Binary files /dev/null and b/icon/wh24.png differ diff --git a/icon/wheel.png b/icon/wheel.png new file mode 100644 index 0000000..03fbb27 Binary files /dev/null and b/icon/wheel.png differ diff --git a/manifest.mf b/manifest.mf index fb38ca1..768b844 100644 --- a/manifest.mf +++ b/manifest.mf @@ -4,4 +4,4 @@ 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 +OpenIDE-Module-Requires: org.openide.windows.WindowManager diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties index 163940c..4b4b73d 100644 --- a/nbproject/genfiles.properties +++ b/nbproject/genfiles.properties @@ -1,8 +1,8 @@ -build.xml.data.CRC32=59e91121 +build.xml.data.CRC32=22fb9f16 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=59e91121 +nbproject/build-impl.xml.data.CRC32=22fb9f16 nbproject/build-impl.xml.script.CRC32=e0c60086 nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.67.1 diff --git a/nbproject/project.xml b/nbproject/project.xml index d20bb34..154e67c 100644 --- a/nbproject/project.xml +++ b/nbproject/project.xml @@ -31,6 +31,14 @@ 1.51.1 + + org.openide.awt + + + + 7.62.1 + + org.openide.explorer diff --git a/src/org/idp/laf/settings/Color.java b/src/org/idp/laf/Color.java similarity index 84% rename from src/org/idp/laf/settings/Color.java rename to src/org/idp/laf/Color.java index cae7550..656c867 100644 --- a/src/org/idp/laf/settings/Color.java +++ b/src/org/idp/laf/Color.java @@ -1,20 +1,19 @@ -/* - * 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. +/* Copyright (C) Edward M. Kagan - All Rights Reserved + * Unauthorized copying of this file, via any medium is strictly prohibited + * Proprietary and confidential + * Written by Edward M. Kagan , 2015 */ -package org.idp.laf.settings; +package org.idp.laf; 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 static org.idp.laf.Color.ColorClass.AT; +import static org.idp.laf.Color.ColorClass.SF; +import static org.idp.laf.Color.ColorClass.SS; import sun.swing.PrintColorUIResource; /** - * - * @author Edward M. Kagan + * @author Edward M. Kagan */ public class Color implements Serializable{ @@ -54,7 +53,7 @@ public class Color implements Serializable{ this.cls = SF; } - public Color(String pname, ColorClass cls, int red, int green, int blue, int alpha) { + public Color(String pname, ColorClass cls, int red, int green, int blue, int alpha) { this.A = alpha; this.B = blue; this.G = green; diff --git a/src/org/idp/laf/Installer.java b/src/org/idp/laf/Installer.java index 985ae07..15cdeec 100644 --- a/src/org/idp/laf/Installer.java +++ b/src/org/idp/laf/Installer.java @@ -1,7 +1,7 @@ -/* - * 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. +/* Copyright (C) Edward M. Kagan - All Rights Reserved + * Unauthorized copying of this file, via any medium is strictly prohibited + * Proprietary and confidential + * Written by Edward M. Kagan , 2015 */ package org.idp.laf; @@ -9,8 +9,7 @@ import javax.swing.SwingUtilities; import org.openide.modules.ModuleInstall; /** - * - * @author Edward M. Kagan + * @author Edward M. Kagan */ public class Installer extends ModuleInstall { @@ -22,11 +21,9 @@ public class Installer extends ModuleInstall @Override public void run() { - LAF_killer.load_ui(); + Kernel.load_kernel(); } }); } - - - + } diff --git a/src/org/idp/laf/Kernel.java b/src/org/idp/laf/Kernel.java new file mode 100644 index 0000000..1842cd9 --- /dev/null +++ b/src/org/idp/laf/Kernel.java @@ -0,0 +1,259 @@ +/* Copyright (C) Edward M. Kagan - All Rights Reserved + * Unauthorized copying of this file, via any medium is strictly prohibited + * Proprietary and confidential + * Written by Edward M. Kagan , 2015 + */ +package org.idp.laf; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.io.UnsupportedEncodingException; +import java.nio.charset.Charset; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; +import javax.swing.plaf.ColorUIResource; +import javax.swing.plaf.metal.DefaultMetalTheme; +import javax.swing.plaf.metal.MetalLookAndFeel; +import org.openide.util.Exceptions; +import org.openide.windows.WindowManager; + +/** + * @author Edward M. Kagan + */ +public class Kernel { + + public static void load_kernel () + { + if (prepare_metal_laf ()) + { + String nb_etc = retrieve_netbeans_etc_dir(); + setup_font_antialiaing_hints(nb_etc); + load_setup (nb_etc); + } + else + { + System.err.println("Unable to set Metall Look And Feel - no " + + "modifications done. Follow your ugly way of live."); + } + + } + + private static boolean prepare_metal_laf () + { + try { + UIManager.getDefaults().clear(); + MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme()); + UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); + return true; + } catch (ClassNotFoundException ex) { + Exceptions.printStackTrace(ex); + return false; + } catch (InstantiationException ex) { + Exceptions.printStackTrace(ex); + return false; + } catch (IllegalAccessException ex) { + Exceptions.printStackTrace(ex); + return false; + } catch (UnsupportedLookAndFeelException ex) { + Exceptions.printStackTrace(ex); + return false; + } + } + + + private static String retrieve_netbeans_etc_dir () + { + String nb_home = System.getProperty("netbeans.home"); + String nb_conf = nb_home.substring(0, nb_home.length() - "platform".length()) + "etc" + File.separator; + return nb_conf; + } + + + private static boolean setup_font_antialiaing_hints (String nb_etc) + { + try + { + System.setProperty("awt.useSystemAAFontSettings","lcd"); + System.setProperty("swing.aatext", "true"); + System.setProperty("nb.useSwingHtmlRendering", "true"); + + Path path = FileSystems.getDefault().getPath(nb_etc, "netbeans.conf"); + List linesL = Files.readAllLines(path); + String [] lines = new String[linesL.size()]; + + int i = 0; + for (String str : linesL) + { + lines[i] = str; + i++; + } + + for (i =0; i < lines.length; i ++) + { + if (lines[i].contains("netbeans_default_options=")) + { + if (!lines[i].contains("-J-Dawt.useSystemAAFontSettings")) + { + System.err.println("No rendering hints defined - fixing..."); + String [] parts = lines[i].split("\""); + String new_line = parts[0] + "\"" + parts[1] + " -J-Dswing.aatext=true -J-Dawt.useSystemAAFontSettings=lcd" + "\""; + lines[i] = new_line; + write_scheme(nb_etc + "netbeans.conf", lines); + System.out.println("Reload Netbeans to update hints!"); + } + } + } + return true; + } + catch (IOException ex) + { + Exceptions.printStackTrace(ex); + System.err.println("Unable to apply rendering hints :( Sorry..."); + return false; + } + } + + private static boolean load_setup (String nb_etc) + { + File scheme_file = new File(nb_etc + File.separator + ".idp_scheme"); + String path = scheme_file.getAbsolutePath(); + + if (!scheme_file.exists()) + { + + if (save_scheme(path)) + { + return read_scheme (path); + } + else + { + return false; + } + } + else + { + return read_scheme (path); + } + + + } + + private static boolean save_scheme(String scheme_file) { + + ArrayList color_map = new ArrayList(); + for (int i = 0; i < Keys.color_keys.length; i ++) + { + + Object o = UIManager.get(Keys.color_keys[i]); + if (o != null) + { + if (o.getClass().equals(javax.swing.plaf.ColorUIResource.class)) + { + ColorUIResource oo = (ColorUIResource) o; + Color c = new Color(Keys.color_keys[i], Color.ColorClass.SF, oo.getRed(), oo.getGreen(), oo.getBlue(), oo.getAlpha()); + color_map.add(c); + //System.out.println( "\"" + Keys.color_keys[i] + "\","); + } + else if (o.getClass().equals(java.awt.Color.class)) + { + java.awt.Color oo = (java.awt.Color) o; + Color c = new Color(Keys.color_keys[i], Color.ColorClass.AT, oo.getRed(), oo.getGreen(), oo.getBlue(), oo.getAlpha()); + color_map.add(c); + //System.out.println( "\"" + Keys.color_keys[i] + "\","); + } + } +// else +// { +// System.out.println( " \"" + Keys.color_keys[i] + "\","); +// } + } + + try + { + PrintWriter writer = new PrintWriter(scheme_file , "UTF-8"); + for (int i = 0; i < color_map.size(); i ++) + { + writer.println(color_map.get(i)); + } + writer.close(); + return true; + } + catch (FileNotFoundException ex) + { + Exceptions.printStackTrace(ex); + return false; + } + catch (UnsupportedEncodingException ex) + { + Exceptions.printStackTrace(ex); + return false; + } + + } + + private static boolean read_scheme(String scheme_file) { + + try + { + ArrayList color_map = new ArrayList(); + List C = Files.readAllLines(Paths.get(scheme_file), Charset.forName("UTF-8")); + + for (String s : C) + { + color_map.add(new Color (s)); + } + + for (int i = 0; i < color_map.size(); i ++) + { + UIManager.put(color_map.get(i).getName(), color_map.get(i).getObject()); + } + + repaintUI(); + + return true; + } + catch (IOException ex) + { + Exceptions.printStackTrace(ex); + return false; + } + } + + + public static void repaintUI() + { + SwingUtilities.updateComponentTreeUI(WindowManager.getDefault().getMainWindow()); + WindowManager.getDefault().getMainWindow().pack(); + WindowManager.getDefault().getMainWindow().repaint(); + } + + private static void write_scheme(String path, String [] data) throws IOException + { + + File fout = new File(path); + FileOutputStream fos = new FileOutputStream(fout); + + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos)); + + for (int i = 0; i < data.length; i ++) + { + bw.write(data[i]); + bw.newLine(); + } + + bw.close(); + } + +} diff --git a/src/org/idp/laf/Keys.java b/src/org/idp/laf/Keys.java index ab9f81d..fb9a852 100644 --- a/src/org/idp/laf/Keys.java +++ b/src/org/idp/laf/Keys.java @@ -1,16 +1,302 @@ -/* - * 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. +/* Copyright (C) Edward M. Kagan - All Rights Reserved + * Unauthorized copying of this file, via any medium is strictly prohibited + * Proprietary and confidential + * Written by Edward M. Kagan , 2015 */ package org.idp.laf; /** - * - * @author pagan + * @author Edward M. Kagan */ public class Keys { - public static String [] keys = { "AbstractButton.clickText", + + public static String [] color_keys = + { + "Button.background", + "Button.darkShadow", + "Button.disabledText", + "Button.foreground", + "Button.highlight", + "Button.light", + "Button.select", + "Button.shadow", + "CheckBox.background", + "CheckBox.disabledText", + "CheckBox.foreground", + "CheckBoxMenuItem.acceleratorForeground", + "CheckBoxMenuItem.acceleratorSelectionForeground", + "CheckBoxMenuItem.background", + "CheckBoxMenuItem.disabledForeground", + "CheckBoxMenuItem.foreground", + "CheckBoxMenuItem.selectionBackground", + "CheckBoxMenuItem.selectionForeground", + "ColorChooser.background", + "ColorChooser.foreground", + "ColorChooser.swatchesDefaultRecentColor", + "ComboBox.background", + "ComboBox.buttonBackground", + "ComboBox.buttonDarkShadow", + "ComboBox.buttonHighlight", + "ComboBox.buttonShadow", + "ComboBox.disabledBackground", + "ComboBox.disabledForeground", + "ComboBox.foreground", + "ComboBox.selectionBackground", + "ComboBox.selectionForeground", + "Desktop.background", + "EditorPane.background", + "EditorPane.caretForeground", + "EditorPane.foreground", + "EditorPane.inactiveForeground", + "EditorPane.selectionBackground", + "EditorPane.selectionForeground", + "FormattedTextField.background", + "FormattedTextField.caretForeground", + "FormattedTextField.foreground", + "FormattedTextField.inactiveBackground", + "FormattedTextField.inactiveForeground", + "FormattedTextField.selectionBackground", + "FormattedTextField.selectionForeground", + "InternalFrame.activeTitleBackground", + "InternalFrame.activeTitleForeground", + "InternalFrame.borderColor", + "InternalFrame.borderDarkShadow", + "InternalFrame.borderHighlight", + "InternalFrame.borderLight", + "InternalFrame.borderShadow", + "InternalFrame.inactiveTitleBackground", + "InternalFrame.inactiveTitleForeground", + "Label.background", + "Label.disabledForeground", + "Label.disabledShadow", + "Label.foreground", + "List.background", + "List.dropLineColor", + "List.foreground", + "List.selectionBackground", + "List.selectionForeground", + "Menu.acceleratorForeground", + "Menu.acceleratorSelectionForeground", + "Menu.background", + "Menu.disabledForeground", + "Menu.foreground", + "Menu.selectionBackground", + "Menu.selectionForeground", + "MenuBar.background", + "MenuBar.foreground", + "MenuBar.highlight", + "MenuBar.shadow", + "MenuItem.acceleratorForeground", + "MenuItem.acceleratorSelectionForeground", + "MenuItem.background", + "MenuItem.disabledForeground", + "MenuItem.foreground", + "MenuItem.selectionBackground", + "MenuItem.selectionForeground", + "OptionPane.background", + "OptionPane.foreground", + "OptionPane.messageForeground", + "Panel.background", + "Panel.foreground", + "PasswordField.background", + "PasswordField.caretForeground", + "PasswordField.foreground", + "PasswordField.inactiveBackground", + "PasswordField.inactiveForeground", + "PasswordField.selectionBackground", + "PasswordField.selectionForeground", + "PopupMenu.background", + "PopupMenu.foreground", + "ProgressBar.background", + "ProgressBar.foreground", + "ProgressBar.selectionBackground", + "ProgressBar.selectionForeground", + "RadioButton.background", + "RadioButton.darkShadow", + "RadioButton.disabledText", + "RadioButton.foreground", + "RadioButton.highlight", + "RadioButton.light", + "RadioButton.select", + "RadioButton.shadow", + "RadioButtonMenuItem.acceleratorForeground", + "RadioButtonMenuItem.acceleratorSelectionForeground", + "RadioButtonMenuItem.background", + "RadioButtonMenuItem.disabledForeground", + "RadioButtonMenuItem.foreground", + "RadioButtonMenuItem.selectionBackground", + "RadioButtonMenuItem.selectionForeground", + "ScrollBar.background", + "ScrollBar.foreground", + "ScrollBar.thumb", + "ScrollBar.thumbDarkShadow", + "ScrollBar.thumbHighlight", + "ScrollBar.thumbShadow", + "ScrollBar.track", + "ScrollBar.trackHighlight", + "ScrollPane.background", + "ScrollPane.foreground", + "Separator.foreground", + "Separator.highlight", + "Separator.shadow", + "Slider.background", + "Slider.focus", + "Slider.foreground", + "Slider.highlight", + "Slider.shadow", + "Slider.tickColor", + "Spinner.background", + "Spinner.foreground", + "SplitPane.background", + "SplitPane.darkShadow", + "SplitPane.highlight", + "SplitPane.shadow", + "SplitPaneDivider.draggingColor", + "TabbedPane.background", + "TabbedPane.darkShadow", + "TabbedPane.focus", + "TabbedPane.foreground", + "TabbedPane.highlight", + "TabbedPane.light", + "TabbedPane.shadow", + "Table.background", + "Table.dropLineColor", + "Table.dropLineShortColor", + "Table.focusCellBackground", + "Table.focusCellForeground", + "Table.gridColor", + "Table.selectionBackground", + "Table.selectionForeground", + "Table.sortIconColor", + "TableHeader.background", + "TableHeader.focusCellBackground", + "TableHeader.foreground", + "TextArea.background", + "TextArea.caretForeground", + "TextArea.foreground", + "TextArea.inactiveForeground", + "TextArea.selectionBackground", + "TextArea.selectionForeground", + "TextField.background", + "TextField.caretForeground", + "TextField.darkShadow", + "TextField.foreground", + "TextField.highlight", + "TextField.inactiveBackground", + "TextField.inactiveForeground", + "TextField.light", + "TextField.selectionBackground", + "TextField.selectionForeground", + "TextField.shadow", + "TextPane.background", + "TextPane.caretForeground", + "TextPane.foreground", + "TextPane.inactiveForeground", + "TextPane.selectionBackground", + "TextPane.selectionForeground", + "TitledBorder.titleColor", + "ToggleButton.background", + "ToggleButton.darkShadow", + "ToggleButton.disabledText", + "ToggleButton.foreground", + "ToggleButton.highlight", + "ToggleButton.light", + "ToggleButton.shadow", + "ToolBar.background", + "ToolBar.darkShadow", + "ToolBar.dockingBackground", + "ToolBar.dockingForeground", + "ToolBar.floatingBackground", + "ToolBar.floatingForeground", + "ToolBar.foreground", + "ToolBar.highlight", + "ToolBar.light", + "ToolBar.shadow", + "ToolTip.background", + "ToolTip.foreground", + "Tree.background", + "Tree.dropLineColor", + "Tree.foreground", + "Tree.hash", + "Tree.line", + "Tree.selectionBackground", + "Tree.selectionBorderColor", + "Tree.selectionForeground", + "Tree.textBackground", + "Tree.textForeground", + "Viewport.background", + "Viewport.foreground", + "activeCaption", + "activeCaptionBorder", + "activeCaptionText", + "control", + "controlDkShadow", + "controlHighlight", + "controlLtHighlight", + "controlShadow", + "controlText", + "desktop", + "inactiveCaption", + "inactiveCaptionBorder", + "inactiveCaptionText", + "info", + "infoText", + "menu", + "menuText", + "scrollbar", + "text", + "textHighlight", + "textHighlightText", + "textInactiveText", + "textText", + "window", + "windowBorder", + "windowText", + "PropSheet.setBackground", + "PropSheet.selectedSetBackground", + "PropSheet.setForeground", + "PropSheet.selectedSetForeground", + "PropSheet.disabledForeground", + "PropSheet.selectionBackground", + "PropSheet.selectionForeground", + "CheckBoxMenuItem.disabledBackground", + "EditorPane.inactiveBackground", + "Focus.color", + "InternalFrame.background", + "InternalFrame.optionDialogBackground", + "InternalFrame.paletteBackground", + "Menu.disabledBackground", + "MenuBar.disabledBackground", + "MenuBar.disabledForeground", + "MenuBar.selectionBackground", + "MenuBar.selectionForeground", + "MenuItem.disabledBackground", + "PopupMenu.selectionBackground", + "PopupMenu.selectionForeground", + "RadioButtonMenuItem.disabledBackground", + "TextArea.inactiveBackground", + "TextComponent.selectionBackgroundInactive", + "TextPane.inactiveBackground", + "nb_workplace_fill", + "Nb.Desktop.background", + "nb.output.selectionBackground", + "nb.hyperlink.foreground", + "nb.output.background", + "nb.output.foreground", + "Tree.altbackground", + "PropSheet.customButtonForeground", + "netbeans.ps.buttonColor", + "netbeans.ps.background", + "nb.errorForeground", + "nb.warningForeground", + "TabRenderer.selectedActivatedBackground", + "TabRenderer.selectedActivatedForeground", + "TabRenderer.selectedForeground", + "TabRenderer.selectedBackground" +}; + + + private static String [] keys = { "AbstractButton.clickText", "AbstractDocument.additionText", "AbstractDocument.deletionText", "AbstractDocument.redoText", @@ -713,6 +999,71 @@ public class Keys { "textText", "window", "windowBorder", -"windowText"}; +"windowText", + +"nb_workplace_fill", +"customFontSize", +"nbDefaultFontSize", +"Nb.Editor.Status.leftBorder", +"Nb.Editor.Status.innerBorder", +"Nb.Editor.Status.rightBorder", +"Nb.Editor.Status.onlyOneBorder", +"Nb.Editor.Toolbar.border", +"Nb.Editor.ErrorStripe.ScrollBar.Insets", +"Nb.Explorer.Status.border", +"Nb.Explorer.Folder.icon", +"Nb.Explorer.Folder.openedIcon", +"Nb.Desktop.border", +"Nb.Toolbar.ui", +"Nb.Desktop.background", +"nb.output.selectionBackground", +"nb.hyperlink.foreground", +"nb.output.background", +"nb.output.foreground", +"Tree.altbackground", +"PropSheet.setBackground", +"PropSheet.selectedSetBackground", +"PropSheet.setForeground", +"PropSheet.selectedSetForeground", +"PropSheet.disabledForeground", +"PropSheet.selectionBackground", +"PropSheet.selectionForeground", +"PropSheet.customButtonForeground", +"netbeans.ps.buttonColor", +"netbeans.ps.background", +"netbeans.ps.iconmargin", +"netbeans.ps.rowheight", +"nb.errorForeground", +"nb.warningForeground", +"TabbedContainerUI", +"EditorTabDisplayerUI", +"ViewTabDisplayerUI", +"SlidingTabDisplayerUI", +"IndexButtonUI", +"SlidingButtonUI", +"TabbedContainer.editor.contentBorder", +"TabbedContainer.editor.tabsBorder", +"TabbedContainer.editor.outerBorder", +"TabbedContainer.view.contentBorder", +"TabbedContainer.view.tabsBorder", +"TabbedContainer.view.outerBorder", +"TabbedContainer.sliding.contentBorder", +"TabbedContainer.sliding.tabsBorder", +"TabbedContainer.sliding.outerBorder", +"TabRenderer.selectedActivatedBackground", +"TabRenderer.selectedActivatedForeground", +"TabRenderer.selectedForeground", +"TabRenderer.selectedBackground", +"nb.explorer.ministatusbar.border", +"nb.desktop.splitpane.border", +"nb.propertysheet", +"Nb.SplitPane.dividerSize.vertical", +"Nb.SplitPane.dividerSize.horizontal" + }; + +} + + + + -} \ No newline at end of file diff --git a/src/org/idp/laf/LAF_killer.java b/src/org/idp/laf/LAF_killer.java deleted file mode 100644 index d07b52d..0000000 --- a/src/org/idp/laf/LAF_killer.java +++ /dev/null @@ -1,575 +0,0 @@ -/* - * 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.awt.Insets; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.nio.charset.Charset; -import java.nio.file.FileSystems; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.List; -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.border.Border; -import javax.swing.plaf.ColorUIResource; -import javax.swing.plaf.metal.DefaultMetalTheme; -import javax.swing.plaf.metal.MetalLookAndFeel; -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; -import org.openide.windows.WindowManager; - -/** - * - * @author Edward M. Kagan - */ -public class LAF_killer { - - private static void printColor (ColorUIResource cc) - { - System.out.println(cc.getRed() + " : " + cc.getGreen() + " : " + cc.getBlue()); - } - - - 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()); - - - - - printColor(MetalLookAndFeel.getAcceleratorForeground()); - printColor(MetalLookAndFeel.getAcceleratorSelectedForeground()); - printColor(MetalLookAndFeel.getBlack()); - printColor(MetalLookAndFeel.getControl()); - printColor(MetalLookAndFeel.getControlDarkShadow()); - printColor(MetalLookAndFeel.getControlDisabled()); - printColor(MetalLookAndFeel.getControlHighlight()); - printColor(MetalLookAndFeel.getControlInfo()); - printColor(MetalLookAndFeel.getControlShadow()); - printColor(MetalLookAndFeel.getControlTextColor()); - printColor(MetalLookAndFeel.getDesktopColor()); - printColor(MetalLookAndFeel.getFocusColor()); - printColor(MetalLookAndFeel.getHighlightedTextColor()); - printColor(MetalLookAndFeel.getInactiveControlTextColor()); - printColor(MetalLookAndFeel.getInactiveControlTextColor()); - printColor(MetalLookAndFeel.getInactiveSystemTextColor()); - printColor(MetalLookAndFeel.getMenuBackground()); - printColor(MetalLookAndFeel.getMenuDisabledForeground()); - printColor(MetalLookAndFeel.getMenuForeground()); - printColor(MetalLookAndFeel.getMenuSelectedBackground()); - printColor(MetalLookAndFeel.getMenuSelectedForeground()); - printColor(MetalLookAndFeel.getPrimaryControl()); - printColor(MetalLookAndFeel.getPrimaryControlDarkShadow()); - printColor(MetalLookAndFeel.getPrimaryControlHighlight()); - printColor(MetalLookAndFeel.getPrimaryControlInfo()); - printColor(MetalLookAndFeel.getSeparatorBackground()); - printColor(MetalLookAndFeel.getSeparatorForeground()); - printColor(MetalLookAndFeel.getSystemTextColor()); - printColor(MetalLookAndFeel.getTextHighlightColor()); - printColor(MetalLookAndFeel.getUserTextColor()); - printColor(MetalLookAndFeel.getWhite()); - printColor(MetalLookAndFeel.getWindowBackground()); - printColor(MetalLookAndFeel.getWindowTitleBackground()); - printColor(MetalLookAndFeel.getWindowTitleForeground()); - printColor(MetalLookAndFeel.getWindowTitleInactiveBackground()); - printColor(MetalLookAndFeel.getWindowTitleInactiveForeground()); - - - - - - - - - - - - - //} - - 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)); - } - - -// CheckBox.border CLASS: -//javax.swing.plaf.BorderUIResource$CompoundBorderUIResource -// -//VALUE: -//javax.swing.plaf.BorderUIResource$CompoundBorderUIResource@60e359e2 - - Object borderGP = UIManager.get("Button.border"); - System.err.println("bgp = " + borderGP); - System.err.println("bgp2 = " + borderGP.getClass()); - System.err.println("bgp3 = " + borderGP.getClass().getSuperclass()); - - Border inner_border = new javax.swing.border.LineBorder(new java.awt.Color(48, 48, 48), 1); - Border outter_border = new javax.swing.border.LineBorder(new java.awt.Color(16, 16, 16), 2); - - javax.swing.border.AbstractBorder brd = new javax.swing.border.CompoundBorder(outter_border,inner_border); - - UIManager.put("Button.border", brd); - - Object [] keys = new Object[UIManager.getLookAndFeelDefaults().keySet().size()]; - // UIManager.put("Tree.textForeground", new javax.swing.plaf.ColorUIResource(0,255,0)); - // This is F*CKIN VOODOO MAGIC... aaaaaaaaa, I'm just as black cat in a night - - //System.setProperty("awt.useSystemAAFontSettings", "on"); - - System.setProperty("awt.useSystemAAFontSettings","lcd"); - System.setProperty("swing.aatext", "true"); - System.setProperty("nb.useSwingHtmlRendering", "true"); - - String nb_home = System.getProperty("netbeans.home"); - String nb_conf = nb_home.substring(0, nb_home.length() - "platform".length()) + "etc" + File.separator; - - File conf = new File (nb_conf); - Path path = FileSystems.getDefault().getPath(nb_conf, "netbeans.conf"); - List linesL = Files.readAllLines(path); - String [] lines = new String[linesL.size()]; - - int i = 0; - for (String str : linesL) - { - lines[i] = str; - i++; - } - - for (i =0; i < lines.length; i ++) - { - if (lines[i].contains("netbeans_default_options=")) - { - System.out.println("Fond default settings line!"); - if (!lines[i].contains("-J-Dawt.useSystemAAFontSettings")) - { - System.out.println("No rendering hints defined - fixing..."); - String [] parts = lines[i].split("\""); - String new_line = parts[0] + "\"" + parts[1] + " -J-Dswing.aatext=true -J-Dawt.useSystemAAFontSettings=lcd" + "\""; - lines[i] = new_line; - System.out.println(">>> " + lines[i]); - - writeFile1(nb_conf + "netbeans.conf", lines); - - } - else - { - System.out.println("Font redering hints already set - OK"); - } - } - } - - - -// Properties properties = System.getProperties(); -// for (Object o : properties.keySet()) -// { -// System.out.println( o + " : " + properties.getProperty((String) o)); -// } - // NodeRenderer nr = NodeRenderer.sharedInstance(); -// Field[] fields = nr.getClass().getFields(); -// for (int i = 0; i < fields.length; i ++) -// { -// System.out.println(">>> " + fields[i]); -// } - //public static NodeRenderer sharedInstance() - // - - -UIManager.put("TabbedPane.borderColor", java.awt.Color.RED); -UIManager.put("TabbedPane.darkShadow", ColorUIResource.RED); -UIManager.put("TabbedPane.light", ColorUIResource.RED); -UIManager.put("TabbedPane.highlight", ColorUIResource.RED); -UIManager.put("TabbedPane.focus", ColorUIResource.RED); -UIManager.put("TabbedPane.unselectedBackground", ColorUIResource.RED); -UIManager.put("TabbedPane.selectHighlight", ColorUIResource.RED); -UIManager.put("TabbedPane.tabAreaBackground", ColorUIResource.RED); -UIManager.put("TabbedPane.borderHightlightColor", ColorUIResource.RED); - -UIManager.put("Focus.color", ColorUIResource.RED); - - -UIManager.put("TabbedPane.contentBorderInsets", new Insets(0, 0, 0, 0)); - - -//"window" theme.getWindowBackground() -//"windowBorder" theme.getControl() -//"windowText" theme.getUserTextColor() -//"menu" theme.getMenuBackground() -//"menuText" theme.getMenuForeground() -//"text" theme.getWindowBackground() -//"textText" theme.getUserTextColor() -//"textHighlight" theme.getTextHighlightColor() -//"textHighlightText" theme.getHighlightedTextColor() -//"textInactiveText" theme.getInactiveSystemTextColor() -//"control" theme.getControl() -//"controlText" theme.getControlTextColor() -//"controlHighlight" theme.getControlHighlight() -//"controlLtHighlight" theme.getControlHighlight() -//"controlShadow" theme.getControlShadow() -//"controlDkShadow" theme.getControlDarkShadow() -//"scrollbar" theme.getControl() -//"info" theme.getPrimaryControl() -//"infoText" theme.getPrimaryControlInfo() -//The value theme corresponds to the current MetalTheme. - -// UIManager.put("desktop", new ColorUIResource(java.awt.Color.red)); -// UIManager.put("activeCaption", new ColorUIResource(java.awt.Color.red)); -// UIManager.put("activeCaptionText", new ColorUIResource(java.awt.Color.red)); -// UIManager.put("activeCaptionBorder", new ColorUIResource(java.awt.Color.red)); -// UIManager.put("inactiveCaption", new ColorUIResource(java.awt.Color.red)); -// UIManager.put("inactiveCaptionText", new ColorUIResource(java.awt.Color.red)); -// UIManager.put("inactiveCaptionBorder", new ColorUIResource(java.awt.Color.red)); -// UIManager.put("window", new ColorUIResource(java.awt.Color.red)); -// UIManager.put("windowBorder", new ColorUIResource(java.awt.Color.red)); -// UIManager.put("windowText", new ColorUIResource(java.awt.Color.red)); -// UIManager.put("menu", new ColorUIResource(java.awt.Color.red)); -// UIManager.put("menuText", new ColorUIResource(java.awt.Color.red)); -// UIManager.put("text", new ColorUIResource(java.awt.Color.red)); -// UIManager.put("textText", new ColorUIResource(java.awt.Color.red)); -// UIManager.put("textHighlight", new ColorUIResource(java.awt.Color.red)); -// UIManager.put("textHighlightText", new ColorUIResource(java.awt.Color.red)); -// UIManager.put("textInactiveText", new ColorUIResource(java.awt.Color.red)); -// UIManager.put("control", new ColorUIResource(java.awt.Color.red)); -// UIManager.put("controlText", new ColorUIResource(java.awt.Color.red)); -// UIManager.put("controlHighlight", new ColorUIResource(java.awt.Color.red)); -// UIManager.put("controlLtHighlight", new ColorUIResource(java.awt.Color.red)); -// UIManager.put("controlShadow", new ColorUIResource(java.awt.Color.red)); -// UIManager.put("controlDkShadow", new ColorUIResource(java.awt.Color.red)); -// UIManager.put("scrollbar", new ColorUIResource(java.awt.Color.red)); -// UIManager.put("info", new ColorUIResource(java.awt.Color.red)); -// UIManager.put("infoText", new ColorUIResource(java.awt.Color.red)); - - - System.out.println("==================================="); - System.out.println("==================================="); - System.out.println("==================================="); - - for (int k = 0; k < Keys.keys.length; k ++) - { - - Object o = UIManager.get(Keys.keys[k]); - if (o != null) - { -// if (o.getClass() == javax.swing.plaf.ColorUIResource.class) -// { -// -// } -// else -// { - System.out.println(Keys.keys[k] + " : " + o.getClass() + " >> " + o ); - //} - } - else - { - System.err.println(Keys.keys[k] + " >> NULL"); - } - } - - System.out.println("^^^^^^^^^^^^^^^^^^^^^^^^^^"); - - repaintUI(); - - } - - } catch (IOException ex) { - Exceptions.printStackTrace(ex); - } - - } - - public static void writeFile1(String path, String [] data) throws IOException { - - File fout = new File(path); - FileOutputStream fos = new FileOutputStream(fout); - - BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos)); - - for (int i = 0; i < data.length; i ++) { - bw.write(data[i]); - bw.newLine(); - } - - bw.close(); -} - - private static void repaintUI() -{ -SwingUtilities.updateComponentTreeUI(WindowManager.getDefault().getMainWindow()); -WindowManager.getDefault().getMainWindow().pack(); -WindowManager.getDefault().getMainWindow().repaint(); -} - -} diff --git a/src/org/idp/laf/gui/Bundle.properties b/src/org/idp/laf/gui/Bundle.properties new file mode 100644 index 0000000..03671be --- /dev/null +++ b/src/org/idp/laf/gui/Bundle.properties @@ -0,0 +1,5 @@ +# 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. + +Editor.title=[idp!] Color Editor diff --git a/src/org/idp/laf/gui/ColorEditorActionListener.java b/src/org/idp/laf/gui/ColorEditorActionListener.java new file mode 100644 index 0000000..c4eeb85 --- /dev/null +++ b/src/org/idp/laf/gui/ColorEditorActionListener.java @@ -0,0 +1,44 @@ +/* Copyright (C) Edward M. Kagan - All Rights Reserved + * Unauthorized copying of this file, via any medium is strictly prohibited + * Proprietary and confidential + * Written by Edward M. Kagan , 2015 + */ +package org.idp.laf.gui; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import org.openide.awt.ActionID; +import org.openide.awt.ActionReference; +import org.openide.awt.ActionRegistration; +import org.openide.util.NbBundle.Messages; +import org.openide.windows.WindowManager; + +/** + * @author Edward M. Kagan + */ + +@ActionID( + category = "File", + id = "org.idp.laf.ColorEditorActionListener" +) +@ActionRegistration( + iconBase = "org/idp/laf/gui/wh.png", + displayName = "#CTL_ColorEditorActionListener" +) +@ActionReference(path = "Toolbars/File", position = -100) +@Messages("CTL_ColorEditorActionListener=[idp!] Color Editor") +public final class ColorEditorActionListener implements ActionListener { + + @Override + public void actionPerformed(ActionEvent e) { + ColorEditorTopComponent editor = (ColorEditorTopComponent) WindowManager.getDefault().findTopComponent("ColorEditorTopComponent"); + if (editor.isOpened()) + { + editor.close(); + } + else + { + editor.open(); + } + } +} diff --git a/src/org/idp/laf/gui/ColorEditorTopComponent.form b/src/org/idp/laf/gui/ColorEditorTopComponent.form new file mode 100644 index 0000000..5f3eab1 --- /dev/null +++ b/src/org/idp/laf/gui/ColorEditorTopComponent.form @@ -0,0 +1,28 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/org/idp/laf/gui/ColorEditorTopComponent.java b/src/org/idp/laf/gui/ColorEditorTopComponent.java new file mode 100644 index 0000000..4ad1b49 --- /dev/null +++ b/src/org/idp/laf/gui/ColorEditorTopComponent.java @@ -0,0 +1,97 @@ +/* Copyright (C) Edward M. Kagan - All Rights Reserved + * Unauthorized copying of this file, via any medium is strictly prohibited + * Proprietary and confidential + * Written by Edward M. Kagan , 2015 + */ +package org.idp.laf.gui; + +import org.netbeans.api.settings.ConvertAsProperties; +import org.openide.awt.ActionID; +import org.openide.awt.ActionReference; +import org.openide.windows.TopComponent; +import org.openide.util.NbBundle.Messages; + +/** + * @author Edward M. Kagan + */ + +/** + * Top component which displays something. + */ +@ConvertAsProperties( + dtd = "-//org.idp.laf.gui//ColorEditor//EN", + autostore = false +) +@TopComponent.Description( + preferredID = "ColorEditorTopComponent", + iconBase = "org/idp/laf/gui/wh.png", + persistenceType = TopComponent.PERSISTENCE_ALWAYS +) +@TopComponent.Registration(mode = "editor", openAtStartup = false) +@ActionID(category = "Window", id = "org.idp.laf.gui.ColorEditorTopComponent") +@ActionReference(path = "Menu/Window" /*, position = 333 */) +@TopComponent.OpenActionRegistration( + displayName = "#CTL_ColorEditorAction", + preferredID = "ColorEditorTopComponent" +) +@Messages({ + "CTL_ColorEditorAction=ColorEditor", + "CTL_ColorEditorTopComponent=ColorEditor Window", + "HINT_ColorEditorTopComponent=This is a ColorEditor window" +}) +public final class ColorEditorTopComponent extends TopComponent { + + public ColorEditorTopComponent() { + initComponents(); + setName(Bundle.CTL_ColorEditorTopComponent()); + setToolTipText(Bundle.HINT_ColorEditorTopComponent()); + putClientProperty(TopComponent.PROP_CLOSING_DISABLED, Boolean.TRUE); + putClientProperty(TopComponent.PROP_DRAGGING_DISABLED, Boolean.TRUE); + putClientProperty(TopComponent.PROP_MAXIMIZATION_DISABLED, Boolean.TRUE); + putClientProperty(TopComponent.PROP_UNDOCKING_DISABLED, Boolean.TRUE); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 400, Short.MAX_VALUE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 300, Short.MAX_VALUE) + ); + }// //GEN-END:initComponents + + // Variables declaration - do not modify//GEN-BEGIN:variables + // End of variables declaration//GEN-END:variables + @Override + public void componentOpened() { + // TODO add custom code on component opening + } + + @Override + public void componentClosed() { + // TODO add custom code on component closing + } + + void writeProperties(java.util.Properties p) { + // better to version settings since initial version as advocated at + // http://wiki.apidesign.org/wiki/PropertyFiles + p.setProperty("version", "1.0"); + // TODO store your settings + } + + void readProperties(java.util.Properties p) { + String version = p.getProperty("version"); + // TODO read your settings according to their version + } +} diff --git a/src/org/idp/laf/gui/wh.png b/src/org/idp/laf/gui/wh.png new file mode 100644 index 0000000..4dd873b Binary files /dev/null and b/src/org/idp/laf/gui/wh.png differ diff --git a/src/org/idp/laf/gui/wh24.png b/src/org/idp/laf/gui/wh24.png new file mode 100644 index 0000000..5a2268d Binary files /dev/null and b/src/org/idp/laf/gui/wh24.png differ diff --git a/src/org/idp/laf/settings/Font.java b/src/org/idp/laf/settings/Font.java deleted file mode 100644 index c41d2f2..0000000 --- a/src/org/idp/laf/settings/Font.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * 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 deleted file mode 100644 index 112d6a0..0000000 --- a/src/org/idp/laf/settings/Gradient.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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"); - } - - - } - -}