+/*\r
+ * Jalview - A Sequence Alignment Editor and Viewer\r
+ * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\r
+ */\r
+\r
package jalview.appletgui;\r
\r
-import jalview.jbappletgui.GUserDefinedColours;\r
-import jalview.datamodel.*;\r
-import jalview.schemes.*;\r
-import jalview.io.*;\r
-import java.io.*;\r
+import java.util.*;\r
+\r
import java.awt.*;\r
import java.awt.event.*;\r
-import java.util.*;\r
\r
+import jalview.datamodel.*;\r
+import jalview.jbappletgui.*;\r
+import jalview.schemes.*;\r
\r
-public class UserDefinedColours extends GUserDefinedColours\r
+public class UserDefinedColours\r
+ extends GUserDefinedColours\r
{\r
\r
AlignmentPanel ap;\r
super();\r
frame = new Frame();\r
frame.add(this);\r
- jalview.bin.JalviewLite.addFrame(frame, "User defined colours", 420,345 );\r
-\r
- if(sg!=null)\r
- frame.setTitle( frame.getTitle()+ " ("+sg.getName()+")");\r
+ jalview.bin.JalviewLite.addFrame(frame, "User defined colours", 420, 345);\r
\r
+ if (sg != null)\r
+ {\r
+ frame.setTitle(frame.getTitle() + " (" + sg.getName() + ")");\r
+ }\r
\r
this.ap = ap;\r
seqGroup = sg;\r
\r
+ if (seqGroup != null)\r
+ {\r
+ oldColourScheme = seqGroup.cs;\r
+ }\r
+ else\r
+ {\r
+ oldColourScheme = ap.av.getGlobalColourScheme();\r
+ }\r
\r
- if (seqGroup != null)\r
- oldColourScheme = seqGroup.cs;\r
- else\r
- oldColourScheme = ap.av.getGlobalColourScheme();\r
+ for (int i = 0; i < 20; i++)\r
+ {\r
+ makeButton(ResidueProperties.aa2Triplet.get(ResidueProperties.aa[i]) +\r
+ "", ResidueProperties.aa[i]);\r
+ }\r
\r
- for (int i = 0; i < 20; i++)\r
- makeButton(ResidueProperties.aa2Triplet.get(ResidueProperties.aa[i]) +\r
- "", ResidueProperties.aa[i]);\r
+ makeButton("B", "B");\r
+ makeButton("Z", "Z");\r
+ makeButton("X", "X");\r
+ makeButton("Gap", "'.','-',' '");\r
\r
- makeButton("B", "B");\r
- makeButton("Z", "Z");\r
- makeButton("X", "X");\r
- makeButton("Gap", "'.','-',' '");\r
+ validate();\r
\r
}\r
\r
- protected void rText_actionPerformed(ActionEvent e) {\r
- try{\r
+ protected void rText_actionPerformed(ActionEvent e)\r
+ {\r
+ try\r
+ {\r
int i = Integer.parseInt(rText.getText());\r
rScroller.setValue(i);\r
- }catch(NumberFormatException ex){}\r
+ rScroller_adjustmentValueChanged(null);\r
+ }\r
+ catch (NumberFormatException ex)\r
+ {}\r
}\r
\r
- protected void gText_actionPerformed(ActionEvent e) {\r
- try{\r
+ protected void gText_actionPerformed(ActionEvent e)\r
+ {\r
+ try\r
+ {\r
int i = Integer.parseInt(gText.getText());\r
gScroller.setValue(i);\r
- }catch(NumberFormatException ex){}\r
+ gScroller_adjustmentValueChanged(null);\r
+ }\r
+ catch (NumberFormatException ex)\r
+ {}\r
\r
}\r
\r
- protected void bText_actionPerformed(ActionEvent e) {\r
- try{\r
+ protected void bText_actionPerformed(ActionEvent e)\r
+ {\r
+ try\r
+ {\r
int i = Integer.parseInt(bText.getText());\r
bScroller.setValue(i);\r
- }catch(NumberFormatException ex){}\r
+ bScroller_adjustmentValueChanged(null);\r
+ }\r
+ catch (NumberFormatException ex)\r
+ {}\r
\r
}\r
\r
-\r
- protected void rScroller_adjustmentValueChanged(AdjustmentEvent e) {\r
+ protected void rScroller_adjustmentValueChanged(AdjustmentEvent e)\r
+ {\r
R = rScroller.getValue();\r
- rText.setText(R+"");\r
+ rText.setText(R + "");\r
colourChanged();\r
}\r
\r
- protected void gScroller_adjustmentValueChanged(AdjustmentEvent e) {\r
+ protected void gScroller_adjustmentValueChanged(AdjustmentEvent e)\r
+ {\r
G = gScroller.getValue();\r
- gText.setText(G+"");\r
+ gText.setText(G + "");\r
colourChanged();\r
}\r
\r
- protected void bScroller_adjustmentValueChanged(AdjustmentEvent e) {\r
+ protected void bScroller_adjustmentValueChanged(AdjustmentEvent e)\r
+ {\r
B = bScroller.getValue();\r
- bText.setText(B+"");\r
+ bText.setText(B + "");\r
colourChanged();\r
}\r
\r
- public void colourChanged()\r
- {\r
- Color col = new Color(R,G,B);\r
- target.setBackground( col );\r
+ public void colourChanged()\r
+ {\r
+ Color col = new Color(R, G, B);\r
+ target.setBackground(col);\r
+ target.repaint();\r
\r
- if(selectedButton!=null)\r
- selectedButton.setBackground( col );\r
- }\r
+ if (selectedButton != null)\r
+ {\r
+ selectedButton.setBackground(col);\r
+ selectedButton.repaint();\r
+ }\r
+ }\r
\r
public void colourButtonPressed(MouseEvent e)\r
{\r
- selectedButton = (Button)e.getSource();\r
- Color col = selectedButton.getBackground();\r
- R = col.getRed();\r
- G = col.getGreen();\r
- B = col.getBlue();\r
- rScroller.setValue(R);\r
- gScroller.setValue(G);\r
- bScroller.setValue(B);\r
- rText.setText(R+"");\r
- gText.setText(G+"");\r
- bText.setText(B+"");\r
-\r
- colourChanged();\r
+ selectedButton = (Button) e.getSource();\r
+ Color col = selectedButton.getBackground();\r
+ R = col.getRed();\r
+ G = col.getGreen();\r
+ B = col.getBlue();\r
+ rScroller.setValue(R);\r
+ gScroller.setValue(G);\r
+ bScroller.setValue(B);\r
+ rText.setText(R + "");\r
+ gText.setText(G + "");\r
+ bText.setText(B + "");\r
+\r
+ colourChanged();\r
}\r
\r
void makeButton(String label, String aa)\r
final Button button = new Button();\r
Color col = Color.white;\r
\r
-\r
- try{\r
+ try\r
+ {\r
col = oldColourScheme.findColour(aa, -1);\r
- }catch(Exception ex){}\r
+ }\r
+ catch (Exception ex)\r
+ {}\r
\r
- button.setBackground( col );\r
- oldColours.addElement( col );\r
- button.setLabel( label );\r
- button.setForeground( col.darker().darker().darker() );\r
+ button.setBackground(col);\r
+ oldColours.addElement(col);\r
+ button.setLabel(label);\r
+ button.setForeground(col.darker().darker().darker());\r
button.setFont(new java.awt.Font("Verdana", 1, 10));\r
button.addMouseListener(new java.awt.event.MouseAdapter()\r
{\r
- public void mouseClicked(MouseEvent e)\r
+ public void mousePressed(MouseEvent e)\r
{\r
colourButtonPressed(e);\r
}\r
buttonPanel.add(button, null);\r
}\r
\r
-\r
protected void okButton_actionPerformed(ActionEvent e)\r
{\r
applyButton_actionPerformed(null);\r
- frame.setVisible(false);\r
+ frame.setVisible(false);\r
}\r
\r
protected void applyButton_actionPerformed(ActionEvent e)\r
{\r
\r
- Color [] newColours = new Color[24];\r
- for(int i=0; i<24; i++)\r
+ Color[] newColours = new Color[24];\r
+ for (int i = 0; i < 24; i++)\r
{\r
- Button button = (Button)buttonPanel.getComponent(i);\r
- newColours[i] = button.getBackground();\r
+ Button button = (Button) buttonPanel.getComponent(i);\r
+ newColours[i] = button.getBackground();\r
}\r
\r
- UserColourScheme ucs = new UserColourScheme( newColours );\r
- ucs.setThreshold(0);\r
+ UserColourScheme ucs = new UserColourScheme(newColours);\r
+ ucs.setThreshold(0, ap.av.getIgnoreGapsConsensus());\r
\r
- if(seqGroup!=null)\r
+ if (seqGroup != null)\r
+ {\r
seqGroup.cs = ucs;\r
+ }\r
else\r
- ap.av.setGlobalColourScheme(ucs);\r
-\r
- ap.repaint();\r
- }\r
-\r
-\r
- public static UserColourScheme loadDefaultColours(String file)\r
- {\r
- UserColourScheme ucs = null;\r
- try\r
{\r
- BufferedReader in = new BufferedReader(new FileReader(file));\r
- Color [] newColours = new Color[24];\r
- for (int i = 0; i < 24; i++)\r
- {\r
- newColours[i] = new Color(Integer.parseInt(in.readLine()));\r
- }\r
-\r
- ucs = new UserColourScheme(newColours);\r
- ucs.setThreshold(0);\r
-\r
+ ap.av.setGlobalColourScheme(ucs);\r
}\r
- catch (Exception ex)\r
- {}\r
\r
- return ucs;\r
+ ap.seqPanel.seqCanvas.img = null;\r
+ ap.repaint();\r
}\r
\r
\r
protected void cancelButton_actionPerformed(ActionEvent e)\r
{\r
\r
- Color [] newColours = new Color[24];\r
- for(int i=0; i<24; i++)\r
+ Color[] newColours = new Color[24];\r
+ for (int i = 0; i < 24; i++)\r
{\r
- newColours[i] = (Color)oldColours.elementAt(i);\r
- buttonPanel.getComponent(i).setBackground(newColours[i]);\r
+ newColours[i] = (Color) oldColours.elementAt(i);\r
+ buttonPanel.getComponent(i).setBackground(newColours[i]);\r
}\r
\r
- UserColourScheme ucs = new UserColourScheme( newColours );\r
+ UserColourScheme ucs = new UserColourScheme(newColours);\r
\r
if (seqGroup != null)\r
+ {\r
seqGroup.cs = ucs;\r
+ }\r
else\r
+ {\r
ap.av.setGlobalColourScheme(ucs);\r
+ }\r
\r
ap.repaint();\r
\r
frame.setVisible(false);\r
}\r
\r
-\r
}\r