X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FUserDefinedColours.java;h=282e757e04e3bd48236afd4783404cf3d4ee008c;hb=6366cf9dcc083ef36aa9fe822bf49fbc18100dca;hp=ecb32651c28e1684363d27e9b7aab4341f33fd4a;hpb=5486259bcccbe21aebd36e70a6695e710679fb7f;p=jalview.git diff --git a/src/jalview/appletgui/UserDefinedColours.java b/src/jalview/appletgui/UserDefinedColours.java index ecb3265..282e757 100755 --- a/src/jalview/appletgui/UserDefinedColours.java +++ b/src/jalview/appletgui/UserDefinedColours.java @@ -40,6 +40,7 @@ public class UserDefinedColours MCview.AppletPDBCanvas pdbcanvas; AppletJmol jmol; + Dialog dialog; Object caller; String originalLabel; Color originalColour; @@ -81,6 +82,29 @@ public class UserDefinedColours init(); } + public UserDefinedColours(FeatureRenderer fr, Frame alignframe) + { + caller = fr; + originalColour = fr.colourPanel.getBackground(); + originalLabel = "Feature Colour"; + setForDialog("Select Feature Colour", alignframe); + setTargetColour(fr.colourPanel.getBackground()); + dialog.show(); + } + + public UserDefinedColours(Component caller, + Color col1, + Frame alignframe) + { + this.caller = caller; + originalColour = col1; + originalLabel = "Select Colour"; + setForDialog("Select Colour", alignframe); + setTargetColour(col1); + dialog.show(); + } + + public UserDefinedColours(Object caller, String label, Color colour) @@ -98,6 +122,27 @@ public class UserDefinedColours frame.setSize(420, 200); } + void setForDialog(String title, Frame alignframe) + { + init(); + frame.setVisible(false); + remove(buttonPanel); + dialog = new Dialog(alignframe, title, true); + + dialog.add(this); + this.setSize(400,123); + okcancelPanel.setBounds(new Rectangle(0, 123, 400, 35)); + int height = 160 + alignframe.getInsets().top + getInsets().bottom; + int width = 400; + + dialog.setBounds(alignframe.getBounds().x + + (alignframe.getSize().width - width) / 2, + alignframe.getBounds().y + + (alignframe.getSize().height - height) / 2, + width, height); + + } + public void actionPerformed(ActionEvent evt) { if (evt.getSource() == okButton) @@ -252,6 +297,7 @@ public class UserDefinedColours R = col.getRed(); G = col.getGreen(); B = col.getBlue(); + rScroller.setValue(R); gScroller.setValue(G); bScroller.setValue(B); @@ -298,9 +344,17 @@ public class UserDefinedColours protected void okButton_actionPerformed() { applyButton_actionPerformed(); + if (dialog != null) + dialog.setVisible(false); + frame.setVisible(false); } + public Color getColor() + { + return new Color(R, G, B); + } + protected void applyButton_actionPerformed() { if (caller != null) @@ -308,21 +362,26 @@ public class UserDefinedColours if (caller instanceof FeatureSettings) { ( (FeatureSettings) caller).setUserColour - (originalLabel, new Color(R, G, B)); + (originalLabel, getColor()); } else if (caller instanceof AnnotationColourChooser) { if (originalLabel.equals("Min Colour")) { ( (AnnotationColourChooser) caller).minColour_actionPerformed - (new Color(R, G, B)); + (getColor()); } else { ( (AnnotationColourChooser) caller).maxColour_actionPerformed - (new Color(R, G, B)); + (getColor()); } } + else if(caller instanceof FeatureRenderer) + { + ((FeatureRenderer)caller).colourPanel.setBackground(getColor()); + } + return; } @@ -384,6 +443,15 @@ public class UserDefinedColours (originalColour); } } + else if (caller instanceof FeatureRenderer) + { + ( (FeatureRenderer) caller).colourPanel.setBackground(originalColour); + + } + + if(dialog!=null) + dialog.setVisible(false); + frame.setVisible(false); return; }