From a4c90a2c3a3b977a542250e2cfdfb0d8b247d4aa Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Thu, 16 Mar 2006 15:14:09 +0000 Subject: [PATCH] Can be used for user features --- src/jalview/appletgui/UserDefinedColours.java | 54 ++++++++++++++++++++----- 1 file changed, 44 insertions(+), 10 deletions(-) diff --git a/src/jalview/appletgui/UserDefinedColours.java b/src/jalview/appletgui/UserDefinedColours.java index b092601..6544993 100755 --- a/src/jalview/appletgui/UserDefinedColours.java +++ b/src/jalview/appletgui/UserDefinedColours.java @@ -38,6 +38,9 @@ public class UserDefinedColours ColourSchemeI oldColourScheme; Frame frame; MCview.AppletPDBCanvas pdbcanvas; + FeatureSettings featureSettings; + String feature; + Color originalFeatureCol; int R = 0, G = 0, B = 0; @@ -70,6 +73,22 @@ public class UserDefinedColours init(); } + public UserDefinedColours(FeatureSettings featureSettings, + String feature, + Color col) + { + this.featureSettings = featureSettings; + this.feature = feature; + init(); + remove(buttonPanel); + originalFeatureCol = col; + setTargetColour(col); + + okcancelPanel.setBounds(new Rectangle(0, 113, 400, 35)); + frame.setTitle("User Defined Colours - "+feature); + frame.setSize(420, 200); + } + public void actionPerformed(ActionEvent evt) { if(evt.getSource()==okButton) @@ -200,10 +219,8 @@ public class UserDefinedColours } } - public void colourButtonPressed(MouseEvent e) + void setTargetColour(Color col) { - selectedButton = (Button) e.getSource(); - Color col = selectedButton.getBackground(); R = col.getRed(); G = col.getGreen(); B = col.getBlue(); @@ -213,10 +230,15 @@ public class UserDefinedColours rText.setText(R + ""); gText.setText(G + ""); bText.setText(B + ""); - colourChanged(); } + public void colourButtonPressed(MouseEvent e) + { + selectedButton = (Button) e.getSource(); + setTargetColour(selectedButton.getBackground()); + } + void makeButton(String label, String aa) { final Button button = new Button(); @@ -253,6 +275,12 @@ public class UserDefinedColours protected void applyButton_actionPerformed() { + if (featureSettings != null) + { + featureSettings.setUserColour(feature, new Color(R,G,B)); + return; + } + Color[] newColours = new Color[24]; for (int i = 0; i < 24; i++) { @@ -287,6 +315,12 @@ public class UserDefinedColours protected void cancelButton_actionPerformed() { + if(featureSettings!=null) + { + featureSettings.setUserColour(feature, originalFeatureCol); + frame.setVisible(false); + return; + } Color[] newColours = new Color[24]; for (int i = 0; i < 24; i++) @@ -320,7 +354,7 @@ public class UserDefinedColours protected Panel buttonPanel = new Panel(); protected GridLayout gridLayout = new GridLayout(); - Panel jPanel2 = new Panel(); + Panel okcancelPanel = new Panel(); protected Button okButton = new Button(); protected Button applyButton = new Button(); protected Button cancelButton = new Button(); @@ -350,7 +384,7 @@ public class UserDefinedColours cancelButton.setLabel("Cancel"); cancelButton.addActionListener(this); this.setBackground(new Color(212, 208, 223)); - jPanel2.setBounds(new Rectangle(0, 265, 400, 35)); + okcancelPanel.setBounds(new Rectangle(0, 265, 400, 35)); buttonPanel.setBounds(new Rectangle(0, 123, 400, 142)); rScroller.setMaximum(256); rScroller.setMinimum(0); @@ -396,10 +430,10 @@ public class UserDefinedColours bText.addActionListener(this); target.setBackground(Color.black); target.setBounds(new Rectangle(229, 26, 134, 79)); - this.add(jPanel2, null); - jPanel2.add(okButton, null); - jPanel2.add(applyButton, null); - jPanel2.add(cancelButton, null); + 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); -- 1.7.10.2