SequenceGroup seqGroup;\r
JButton selectedButton;\r
Vector oldColours = new Vector();\r
+ ColourSchemeI oldColourScheme;\r
JInternalFrame frame;\r
\r
+\r
public UserDefinedColours(JInternalFrame f, AlignmentPanel ap, SequenceGroup sg)\r
{\r
super();\r
colorChooser.getSelectionModel().addChangeListener(this);\r
this.ap = ap;\r
frame = f;\r
- seqGroup = sg;\r
+ seqGroup = sg;\r
+\r
+\r
+ if (seqGroup != null)\r
+ oldColourScheme = seqGroup.cs;\r
+ else\r
+ oldColourScheme = ap.av.getGlobalColourScheme();\r
+\r
+ for (int i = 0; i < 20; i++)\r
+ makeButton(ResidueProperties.aa2Triplet.get(ResidueProperties.aa[i]) +\r
+ "", ResidueProperties.aa[i]);\r
+\r
+ makeButton("B", "B");\r
+ makeButton("Z", "Z");\r
+ makeButton("X", "X");\r
+ makeButton("'.','-',' '", "-");\r
\r
- for(int i=0; i<20; i++)\r
- makeButton(ResidueProperties.aa2Triplet.get( ResidueProperties.aa[i] )+"", ResidueProperties.aa[i]);\r
+ if(jalview.bin.Cache.getProperty("USER_DEFINED_COLOUR")!=null)\r
+ {\r
+ loadColour(jalview.bin.Cache.getProperty("USER_DEFINED_COLOUR"));\r
+ }\r
\r
- makeButton("B","B");\r
- makeButton("Z","Z");\r
- makeButton("X","X");\r
- makeButton("'.','-',' '", "-");\r
\r
}\r
\r
{\r
final JButton button = new JButton();\r
Color col = Color.white;\r
- ColourSchemeI cs = null;\r
- if(seqGroup!=null)\r
- cs = seqGroup.cs;\r
- else\r
- cs = ap.av.getGlobalColourScheme();\r
\r
\r
try{\r
- col = cs.findColour(aa, -1, null);\r
+ col = oldColourScheme.findColour(aa, -1, null);\r
}catch(Exception ex){}\r
\r
button.setBackground( col );\r
{\r
String choice = chooser.getSelectedFile().getPath();\r
jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);\r
+ loadColour(choice);\r
+ }\r
\r
- try{\r
- BufferedReader in = new BufferedReader(new FileReader(choice));\r
- for(int i=0; i<24; i++)\r
- {\r
- JButton button = (JButton)buttonPanel.getComponent(i);\r
- Color c = new Color(Integer.parseInt(in.readLine()));\r
- button.setBackground(c);\r
- }\r
+ }\r
\r
+ void loadColour(String file)\r
+ {\r
+ try\r
+ {\r
+ BufferedReader in = new BufferedReader(new FileReader(file));\r
+ for (int i = 0; i < 24; i++)\r
+ {\r
+ JButton button = (JButton) buttonPanel.getComponent(i);\r
+ Color c = new Color(Integer.parseInt(in.readLine()));\r
+ button.setBackground(c);\r
}\r
- catch(Exception ex)\r
- {}\r
}\r
+ catch (Exception ex)\r
+ {}\r
\r
}\r
\r
if (value == JFileChooser.APPROVE_OPTION)\r
{\r
String choice = chooser.getSelectedFile().getPath();\r
- jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);\r
+ jalview.bin.Cache.setProperty("USER_DEFINED_COLOUR", choice);\r
\r
try{\r
PrintWriter out = new PrintWriter(new FileWriter(choice));\r