X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FUserDefinedColours.java;h=eb454d7de9ed550ff3d033e2ed4fc7975f544765;hb=c42fcf7bf5cfcf51e67dd0f683edb9ab6683d157;hp=b092601faeca0aa79747215bd249dcd321de3414;hpb=de468b0bf50850a89c6a8a7acfa4ff5b689ffed1;p=jalview.git diff --git a/src/jalview/appletgui/UserDefinedColours.java b/src/jalview/appletgui/UserDefinedColours.java index b092601..eb454d7 100755 --- a/src/jalview/appletgui/UserDefinedColours.java +++ b/src/jalview/appletgui/UserDefinedColours.java @@ -39,6 +39,10 @@ public class UserDefinedColours Frame frame; MCview.AppletPDBCanvas pdbcanvas; + Component caller; + String originalLabel; + Color originalColour; + int R = 0, G = 0, B = 0; public ColourSchemeI loadDefaultColours() @@ -70,6 +74,23 @@ public class UserDefinedColours init(); } + public UserDefinedColours(Component caller, + String label, + Color colour) + { + this.caller = caller; + originalColour = colour; + originalLabel = label; + init(); + remove(buttonPanel); + + setTargetColour(colour); + + okcancelPanel.setBounds(new Rectangle(0, 113, 400, 35)); + frame.setTitle("User Defined Colours - "+label); + frame.setSize(420, 200); + } + public void actionPerformed(ActionEvent evt) { if(evt.getSource()==okButton) @@ -200,10 +221,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 +232,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 +277,24 @@ public class UserDefinedColours protected void applyButton_actionPerformed() { + if (caller != null) + { + 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; + } + + Color[] newColours = new Color[24]; for (int i = 0; i < 24; i++) { @@ -287,6 +329,23 @@ public class UserDefinedColours protected void cancelButton_actionPerformed() { + if (caller != null) + { + 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; + } Color[] newColours = new Color[24]; for (int i = 0; i < 24; i++) @@ -320,7 +379,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 +409,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 +455,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);