From: amwaterhouse Date: Tue, 14 Dec 2004 14:49:55 +0000 (+0000) Subject: Userdefinedcolours works for groups as well X-Git-Tag: Release_2_0~831 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=aff701283dbb15ac97dad993addc312636fa06bf;p=jalview.git Userdefinedcolours works for groups as well --- diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 9d0f60c..a50164a 100755 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -543,7 +543,7 @@ public class AlignFrame extends GAlignFrame public void userDefinedColour_actionPerformed(ActionEvent e) { JInternalFrame frame = new JInternalFrame(); - UserDefinedColours chooser = new UserDefinedColours( frame, viewport ); + UserDefinedColours chooser = new UserDefinedColours( frame, alignPanel, null); frame.setContentPane(chooser); Desktop.addInternalFrame(frame,"User defined colours", 450,540 ); frame.setResizable(false); diff --git a/src/jalview/gui/UserDefinedColours.java b/src/jalview/gui/UserDefinedColours.java index a12672e..1fcc923 100755 --- a/src/jalview/gui/UserDefinedColours.java +++ b/src/jalview/gui/UserDefinedColours.java @@ -1,6 +1,7 @@ package jalview.gui; import jalview.jbgui.GUserDefinedColours; +import jalview.datamodel.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; @@ -13,19 +14,19 @@ import java.util.*; public class UserDefinedColours extends GUserDefinedColours implements ChangeListener { - AlignViewport av; - ColourSchemeI colourScheme; + AlignmentPanel ap; + SequenceGroup seqGroup; JButton selectedButton; Vector oldColours = new Vector(); JInternalFrame frame; - public UserDefinedColours(JInternalFrame f, AlignViewport av) + public UserDefinedColours(JInternalFrame f, AlignmentPanel ap, SequenceGroup sg) { super(); colorChooser.getSelectionModel().addChangeListener(this); - this.av = av; + this.ap = ap; frame = f; - colourScheme = av.getGlobalColourScheme(); + seqGroup = sg; for(int i=0; i<20; i++) makeButton(ResidueProperties.aa2Triplet.get( ResidueProperties.aa[i] )+"", ResidueProperties.aa[i]); @@ -52,8 +53,18 @@ public class UserDefinedColours extends GUserDefinedColours implements ChangeLis void makeButton(String label, String aa) { final JButton button = new JButton(); - button.setBackground( colourScheme.findColour(null,aa,-1,null) ); - oldColours.addElement( colourScheme.findColour(null,aa,-1,null) ); + Color col = Color.white; + ColourSchemeI cs = null; + if(seqGroup!=null) + cs = seqGroup.cs; + else + cs = ap.av.getGlobalColourScheme(); + + if(cs!=null) + col = cs.findColour(null, aa, -1, null); + + button.setBackground( col ); + oldColours.addElement( col ); button.setText( label ); button.setFont(new java.awt.Font("Verdana", 1, 10)); button.addMouseListener(new java.awt.event.MouseAdapter() @@ -88,7 +99,13 @@ public class UserDefinedColours extends GUserDefinedColours implements ChangeLis ucs.setThreshold(0); ucs.setColourScheme( newColours ); - av.setGlobalColourScheme( ucs ); + + if(seqGroup!=null) + seqGroup.cs = ucs; + else + ap.av.setGlobalColourScheme(ucs); + + ap.RefreshPanels(); } protected void loadbutton_actionPerformed(ActionEvent e) @@ -156,7 +173,12 @@ public class UserDefinedColours extends GUserDefinedColours implements ChangeLis } ucs.setColourScheme( newColours ); - av.setGlobalColourScheme( ucs ); + if (seqGroup != null) + seqGroup.cs = ucs; + else + ap.av.setGlobalColourScheme(ucs); + + ap.RefreshPanels(); }