X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FUserDefinedColours.java;h=af08b7529b6ac4bf1ef49123d03a88603992e25e;hb=7bc226b58110fa26d9dbd3f0c78095d06909ffc3;hp=6544993bf8a858f982289f7536651bace4ecad76;hpb=a4c90a2c3a3b977a542250e2cfdfb0d8b247d4aa;p=jalview.git diff --git a/src/jalview/appletgui/UserDefinedColours.java b/src/jalview/appletgui/UserDefinedColours.java index 6544993..af08b75 100755 --- a/src/jalview/appletgui/UserDefinedColours.java +++ b/src/jalview/appletgui/UserDefinedColours.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -38,9 +38,10 @@ public class UserDefinedColours ColourSchemeI oldColourScheme; Frame frame; MCview.AppletPDBCanvas pdbcanvas; - FeatureSettings featureSettings; - String feature; - Color originalFeatureCol; + + Component caller; + String originalLabel; + Color originalColour; int R = 0, G = 0, B = 0; @@ -73,47 +74,66 @@ public class UserDefinedColours init(); } - public UserDefinedColours(FeatureSettings featureSettings, - String feature, - Color col) + public UserDefinedColours(Component caller, + String label, + Color colour) { - this.featureSettings = featureSettings; - this.feature = feature; + this.caller = caller; + originalColour = colour; + originalLabel = label; init(); remove(buttonPanel); - originalFeatureCol = col; - setTargetColour(col); + + setTargetColour(colour); okcancelPanel.setBounds(new Rectangle(0, 113, 400, 35)); - frame.setTitle("User Defined Colours - "+feature); + frame.setTitle("User Defined Colours - " + label); frame.setSize(420, 200); } public void actionPerformed(ActionEvent evt) { - if(evt.getSource()==okButton) - okButton_actionPerformed(); - else if(evt.getSource()==applyButton) + if (evt.getSource() == okButton) + { + okButton_actionPerformed(); + } + else if (evt.getSource() == applyButton) + { applyButton_actionPerformed(); - else if(evt.getSource()==cancelButton) - cancelButton_actionPerformed(); - else if(evt.getSource()==rText) - rText_actionPerformed(); - else if (evt.getSource() == gText) - gText_actionPerformed(); - else if (evt.getSource() == bText) - bText_actionPerformed(); -} + } + else if (evt.getSource() == cancelButton) + { + cancelButton_actionPerformed(); + } + else if (evt.getSource() == rText) + { + rText_actionPerformed(); + } + else if (evt.getSource() == gText) + { + gText_actionPerformed(); + } + else if (evt.getSource() == bText) + { + bText_actionPerformed(); + } + } public void adjustmentValueChanged(AdjustmentEvent evt) { - if(evt.getSource()==rScroller) - rScroller_adjustmentValueChanged(); - else if(evt.getSource()==gScroller) - gScroller_adjustmentValueChanged(); - else if(evt.getSource()==bScroller) - bScroller_adjustmentValueChanged(); -} + if (evt.getSource() == rScroller) + { + rScroller_adjustmentValueChanged(); + } + else if (evt.getSource() == gScroller) + { + gScroller_adjustmentValueChanged(); + } + else if (evt.getSource() == bScroller) + { + bScroller_adjustmentValueChanged(); + } + } void init() { @@ -147,6 +167,7 @@ public class UserDefinedColours validate(); } + protected void rText_actionPerformed() { try @@ -246,7 +267,7 @@ public class UserDefinedColours try { - col = oldColourScheme.findColour(aa, -1); + col = oldColourScheme.findColour(aa.charAt(0), -1); } catch (Exception ex) {} @@ -275,9 +296,26 @@ public class UserDefinedColours protected void applyButton_actionPerformed() { - if (featureSettings != null) + if (caller != null) { - featureSettings.setUserColour(feature, new Color(R,G,B)); + if (caller instanceof FeatureSettings) + { + ( (FeatureSettings) caller).setUserColour + (originalLabel, new Color(R, G, B)); + } + else if (caller instanceof AnnotationColourChooser) + { + if (originalLabel.equals("Min Colour")) + { + ( (AnnotationColourChooser) caller).minColour_actionPerformed + (new Color(R, G, B)); + } + else + { + ( (AnnotationColourChooser) caller).maxColour_actionPerformed + (new Color(R, G, B)); + } + } return; } @@ -289,10 +327,12 @@ public class UserDefinedColours } UserColourScheme ucs = new UserColourScheme(newColours); - if(ap!=null) + if (ap != null) + { ucs.setThreshold(0, ap.av.getIgnoreGapsConsensus()); + } - if(ap!=null) + if (ap != null) { if (seqGroup != null) { @@ -305,19 +345,35 @@ public class UserDefinedColours ap.seqPanel.seqCanvas.img = null; ap.repaint(); } - else if(pdbcanvas!=null) + else if (pdbcanvas != null) { pdbcanvas.pdb.setColours(ucs); pdbcanvas.updateSeqColours(); } } - protected void cancelButton_actionPerformed() { - if(featureSettings!=null) + if (caller != null) { - featureSettings.setUserColour(feature, originalFeatureCol); + if (caller instanceof FeatureSettings) + { + ( (FeatureSettings) caller).setUserColour + (originalLabel, originalColour); + } + else if (caller instanceof AnnotationColourChooser) + { + if (originalLabel.equals("Min Colour")) + { + ( (AnnotationColourChooser) caller).minColour_actionPerformed + (originalColour); + } + else + { + ( (AnnotationColourChooser) caller).maxColour_actionPerformed + (originalColour); + } + } frame.setVisible(false); return; } @@ -331,7 +387,7 @@ public class UserDefinedColours UserColourScheme ucs = new UserColourScheme(newColours); - if(ap!=null) + if (ap != null) { if (seqGroup != null) { @@ -343,7 +399,7 @@ public class UserDefinedColours } ap.repaint(); } - else if(pdbcanvas!=null) + else if (pdbcanvas != null) { pdbcanvas.pdb.setColours(ucs); } @@ -351,7 +407,6 @@ public class UserDefinedColours frame.setVisible(false); } - protected Panel buttonPanel = new Panel(); protected GridLayout gridLayout = new GridLayout(); Panel okcancelPanel = new Panel(); @@ -369,82 +424,84 @@ public class UserDefinedColours protected TextField bText = new TextField(); protected Panel target = new Panel(); - private void jbInit() throws Exception { - this.setLayout(null); - buttonPanel.setLayout(gridLayout); - gridLayout.setColumns(6); - gridLayout.setRows(4); - okButton.setFont(new java.awt.Font("Verdana", 0, 11)); - okButton.setLabel("OK"); - okButton.addActionListener(this); - applyButton.setFont(new java.awt.Font("Verdana", 0, 11)); - applyButton.setLabel("Apply"); - applyButton.addActionListener(this); - cancelButton.setFont(new java.awt.Font("Verdana", 0, 11)); - cancelButton.setLabel("Cancel"); - cancelButton.addActionListener(this); - this.setBackground(new Color(212, 208, 223)); - okcancelPanel.setBounds(new Rectangle(0, 265, 400, 35)); - buttonPanel.setBounds(new Rectangle(0, 123, 400, 142)); - rScroller.setMaximum(256); - rScroller.setMinimum(0); - rScroller.setOrientation(0); - rScroller.setUnitIncrement(1); - rScroller.setVisibleAmount(1); - rScroller.setBounds(new Rectangle(36, 27, 119, 19)); - rScroller.addAdjustmentListener(this); - label1.setAlignment(Label.RIGHT); - label1.setText("R"); - label1.setBounds(new Rectangle(19, 30, 16, 15)); - rText.setFont(new java.awt.Font("Dialog", Font.PLAIN, 10)); - rText.setText("0 "); - rText.setBounds(new Rectangle(156, 27, 53, 19)); - rText.addActionListener(this); - label4.setAlignment(Label.RIGHT); - label4.setText("G"); - label4.setBounds(new Rectangle(15, 56, 20, 15)); - gScroller.setMaximum(256); - gScroller.setMinimum(0); - gScroller.setOrientation(0); - gScroller.setUnitIncrement(1); - gScroller.setVisibleAmount(1); - gScroller.setBounds(new Rectangle(35, 52, 120, 20)); - gScroller.addAdjustmentListener(this); - gText.setFont(new java.awt.Font("Dialog", Font.PLAIN, 10)); - gText.setText("0 "); - gText.setBounds(new Rectangle(156, 52, 53, 20)); - gText.addActionListener(this); - label5.setAlignment(Label.RIGHT); - label5.setText("B"); - label5.setBounds(new Rectangle(14, 82, 20, 15)); - bScroller.setMaximum(256); - bScroller.setMinimum(0); - bScroller.setOrientation(0); - bScroller.setUnitIncrement(1); - bScroller.setVisibleAmount(1); - bScroller.setBounds(new Rectangle(35, 78, 120, 20)); - bScroller.addAdjustmentListener(this); - bText.setFont(new java.awt.Font("Dialog", Font.PLAIN, 10)); - bText.setText("0 "); - bText.setBounds(new Rectangle(157, 78, 52, 20)); - bText.addActionListener(this); - target.setBackground(Color.black); - target.setBounds(new Rectangle(229, 26, 134, 79)); - this.add(okcancelPanel, null); - okcancelPanel.add(okButton, null); - okcancelPanel.add(applyButton, null); - okcancelPanel.add(cancelButton, null); - this.add(buttonPanel, null); - this.add(target, null); - this.add(gScroller); - this.add(rScroller); - this.add(bScroller); - this.add(label5); - this.add(label4); - this.add(label1); - this.add(gText); - this.add(rText); - this.add(bText); -} + private void jbInit() + throws Exception + { + this.setLayout(null); + buttonPanel.setLayout(gridLayout); + gridLayout.setColumns(6); + gridLayout.setRows(4); + okButton.setFont(new java.awt.Font("Verdana", 0, 11)); + okButton.setLabel("OK"); + okButton.addActionListener(this); + applyButton.setFont(new java.awt.Font("Verdana", 0, 11)); + applyButton.setLabel("Apply"); + applyButton.addActionListener(this); + cancelButton.setFont(new java.awt.Font("Verdana", 0, 11)); + cancelButton.setLabel("Cancel"); + cancelButton.addActionListener(this); + this.setBackground(new Color(212, 208, 223)); + okcancelPanel.setBounds(new Rectangle(0, 265, 400, 35)); + buttonPanel.setBounds(new Rectangle(0, 123, 400, 142)); + rScroller.setMaximum(256); + rScroller.setMinimum(0); + rScroller.setOrientation(0); + rScroller.setUnitIncrement(1); + rScroller.setVisibleAmount(1); + rScroller.setBounds(new Rectangle(36, 27, 119, 19)); + rScroller.addAdjustmentListener(this); + label1.setAlignment(Label.RIGHT); + label1.setText("R"); + label1.setBounds(new Rectangle(19, 30, 16, 15)); + rText.setFont(new java.awt.Font("Dialog", Font.PLAIN, 10)); + rText.setText("0 "); + rText.setBounds(new Rectangle(156, 27, 53, 19)); + rText.addActionListener(this); + label4.setAlignment(Label.RIGHT); + label4.setText("G"); + label4.setBounds(new Rectangle(15, 56, 20, 15)); + gScroller.setMaximum(256); + gScroller.setMinimum(0); + gScroller.setOrientation(0); + gScroller.setUnitIncrement(1); + gScroller.setVisibleAmount(1); + gScroller.setBounds(new Rectangle(35, 52, 120, 20)); + gScroller.addAdjustmentListener(this); + gText.setFont(new java.awt.Font("Dialog", Font.PLAIN, 10)); + gText.setText("0 "); + gText.setBounds(new Rectangle(156, 52, 53, 20)); + gText.addActionListener(this); + label5.setAlignment(Label.RIGHT); + label5.setText("B"); + label5.setBounds(new Rectangle(14, 82, 20, 15)); + bScroller.setMaximum(256); + bScroller.setMinimum(0); + bScroller.setOrientation(0); + bScroller.setUnitIncrement(1); + bScroller.setVisibleAmount(1); + bScroller.setBounds(new Rectangle(35, 78, 120, 20)); + bScroller.addAdjustmentListener(this); + bText.setFont(new java.awt.Font("Dialog", Font.PLAIN, 10)); + bText.setText("0 "); + bText.setBounds(new Rectangle(157, 78, 52, 20)); + bText.addActionListener(this); + target.setBackground(Color.black); + target.setBounds(new Rectangle(229, 26, 134, 79)); + this.add(okcancelPanel, null); + okcancelPanel.add(okButton, null); + okcancelPanel.add(applyButton, null); + okcancelPanel.add(cancelButton, null); + this.add(buttonPanel, null); + this.add(target, null); + this.add(gScroller); + this.add(rScroller); + this.add(bScroller); + this.add(label5); + this.add(label4); + this.add(label1); + this.add(gText); + this.add(rText); + this.add(bText); + } }