From 3647f2e6c679ed5ef3e673f10a8d1afb2882014e Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Mon, 21 Feb 2005 17:01:41 +0000 Subject: [PATCH] Sets USER_DEFINED_COLOUR as property --- src/jalview/gui/UserDefinedColours.java | 63 +++++++++++++++++++------------ 1 file changed, 39 insertions(+), 24 deletions(-) diff --git a/src/jalview/gui/UserDefinedColours.java b/src/jalview/gui/UserDefinedColours.java index 642f473..a409549 100755 --- a/src/jalview/gui/UserDefinedColours.java +++ b/src/jalview/gui/UserDefinedColours.java @@ -18,23 +18,38 @@ public class UserDefinedColours extends GUserDefinedColours implements ChangeLis SequenceGroup seqGroup; JButton selectedButton; Vector oldColours = new Vector(); + ColourSchemeI oldColourScheme; JInternalFrame frame; + public UserDefinedColours(JInternalFrame f, AlignmentPanel ap, SequenceGroup sg) { super(); colorChooser.getSelectionModel().addChangeListener(this); this.ap = ap; frame = f; - seqGroup = sg; + seqGroup = sg; + + + if (seqGroup != null) + oldColourScheme = seqGroup.cs; + else + oldColourScheme = ap.av.getGlobalColourScheme(); + + for (int i = 0; i < 20; i++) + makeButton(ResidueProperties.aa2Triplet.get(ResidueProperties.aa[i]) + + "", ResidueProperties.aa[i]); + + makeButton("B", "B"); + makeButton("Z", "Z"); + makeButton("X", "X"); + makeButton("'.','-',' '", "-"); - for(int i=0; i<20; i++) - makeButton(ResidueProperties.aa2Triplet.get( ResidueProperties.aa[i] )+"", ResidueProperties.aa[i]); + if(jalview.bin.Cache.getProperty("USER_DEFINED_COLOUR")!=null) + { + loadColour(jalview.bin.Cache.getProperty("USER_DEFINED_COLOUR")); + } - makeButton("B","B"); - makeButton("Z","Z"); - makeButton("X","X"); - makeButton("'.','-',' '", "-"); } @@ -54,15 +69,10 @@ public class UserDefinedColours extends GUserDefinedColours implements ChangeLis { final JButton button = new JButton(); Color col = Color.white; - ColourSchemeI cs = null; - if(seqGroup!=null) - cs = seqGroup.cs; - else - cs = ap.av.getGlobalColourScheme(); try{ - col = cs.findColour(aa, -1, null); + col = oldColourScheme.findColour(aa, -1, null); }catch(Exception ex){} button.setBackground( col ); @@ -121,20 +131,25 @@ public class UserDefinedColours extends GUserDefinedColours implements ChangeLis { String choice = chooser.getSelectedFile().getPath(); jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice); + loadColour(choice); + } - try{ - BufferedReader in = new BufferedReader(new FileReader(choice)); - for(int i=0; i<24; i++) - { - JButton button = (JButton)buttonPanel.getComponent(i); - Color c = new Color(Integer.parseInt(in.readLine())); - button.setBackground(c); - } + } + void loadColour(String file) + { + try + { + BufferedReader in = new BufferedReader(new FileReader(file)); + for (int i = 0; i < 24; i++) + { + JButton button = (JButton) buttonPanel.getComponent(i); + Color c = new Color(Integer.parseInt(in.readLine())); + button.setBackground(c); } - catch(Exception ex) - {} } + catch (Exception ex) + {} } @@ -147,7 +162,7 @@ public class UserDefinedColours extends GUserDefinedColours implements ChangeLis if (value == JFileChooser.APPROVE_OPTION) { String choice = chooser.getSelectedFile().getPath(); - jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice); + jalview.bin.Cache.setProperty("USER_DEFINED_COLOUR", choice); try{ PrintWriter out = new PrintWriter(new FileWriter(choice)); -- 1.7.10.2