From 9fe2470b6400c06457392d608763cbf65b535f4c Mon Sep 17 00:00:00 2001 From: jprocter Date: Mon, 25 Jul 2011 17:05:57 +0100 Subject: [PATCH] use proper encoding for storing colour as user preference (JAL-234) --- src/jalview/bin/Cache.java | 11 +++++++++++ src/jalview/gui/Preferences.java | 4 ++-- src/jalview/jbgui/GPreferences.java | 20 ++++++++++++++------ 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index 09ebadd..f67377b 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -754,4 +754,15 @@ public class Cache } return (col==null) ? defcolour: col; } + + /** + * store a colour as a Jalview user default property + * @param property + * @param colour + */ + public static void setColourProperty(String property, Color colour) + { + setProperty(property, jalview.util.Format + .getHexString(colour)); + } } diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java index b92f9da..fac25e9 100755 --- a/src/jalview/gui/Preferences.java +++ b/src/jalview/gui/Preferences.java @@ -335,8 +335,8 @@ public class Preferences extends GPreferences Cache.applicationProperties.setProperty("SORT_ALIGNMENT", sortby .getSelectedItem().toString()); - Cache.applicationProperties.setProperty("ANNOTATIONCOLOUR_MIN", minColour.getBackground().toString()); - Cache.applicationProperties.setProperty("ANNOTATIONCOLOUR_MAX", maxColour.getBackground().toString()); + Cache.setColourProperty("ANNOTATIONCOLOUR_MIN", minColour.getBackground()); + Cache.setColourProperty("ANNOTATIONCOLOUR_MAX", maxColour.getBackground()); if (epsRendering.getSelectedItem().equals("Prompt each time")) { diff --git a/src/jalview/jbgui/GPreferences.java b/src/jalview/jbgui/GPreferences.java index 42ffa5d..9448065 100755 --- a/src/jalview/jbgui/GPreferences.java +++ b/src/jalview/jbgui/GPreferences.java @@ -242,18 +242,22 @@ public class GPreferences extends JPanel public void addtoLayout(JPanel panel, String tooltip, JComponent label, JComponent valBox) { JPanel laypanel = new JPanel(),labPanel=new JPanel(), valPanel=new JPanel(); - laypanel.setSize(panel.getWidth(),33); + // laypanel.setSize(panel.getPreferredSize()); + // laypanel.setLayout(null); labPanel.setBounds(new Rectangle(7, 7, 158, 23)); valPanel.setBounds(new Rectangle(172, 7, 270,23)); - labPanel.setLayout(new GridLayout()); - valPanel.setLayout(new GridLayout()); + //labPanel.setLayout(new GridLayout(1,1)); + //valPanel.setLayout(new GridLayout(1,1)); labPanel.add(label); valPanel.add(valBox); laypanel.add(labPanel); laypanel.add(valPanel); - panel.add(laypanel); valPanel.setToolTipText(tooltip); labPanel.setToolTipText(tooltip); + valBox.setToolTipText(tooltip); + panel.add(laypanel); + panel.validate(); + } /** * Creates a new GPreferences object. @@ -724,8 +728,12 @@ public class GPreferences extends JPanel visualTab.add(tooltipSettings); visualTab.add(jPanel2); addtoLayout(visual2Tab, "Default Colourscheme for alignment", colourLabel, colour); - addtoLayout(visual2Tab, "Default Minimum Colour for annotation shading", mincolourLabel,minColour); - addtoLayout(visual2Tab,"Default Maximum Colour for annotation shading", maxcolourLabel, maxColour); + JPanel annotationShding=new JPanel(); + annotationShding.setBorder(new TitledBorder("Annotation Shading Default")); + annotationShding.setLayout(new GridLayout(1,2)); + addtoLayout(annotationShding, "Default Minimum Colour for annotation shading", mincolourLabel,minColour); + addtoLayout(annotationShding,"Default Maximum Colour for annotation shading", maxcolourLabel, maxColour); + visual2Tab.add(annotationShding); // , FlowLayout.LEFT); // visual2panel.add(minColour); // visual2panel.add(maxColour); -- 1.7.10.2