X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FUserDefinedColours.java;h=7220321b78c9789d2835cc8b4846ae9529e2640a;hb=b638a305a88456b3bed6a88676c75ddb8b2ecaa0;hp=0f305398a9dacc070b7ad20c26afbb26a34990f3;hpb=506d60f0e188723ddc91c26824b41ac7034df3fe;p=jalview.git diff --git a/src/jalview/appletgui/UserDefinedColours.java b/src/jalview/appletgui/UserDefinedColours.java index 0f30539..7220321 100755 --- a/src/jalview/appletgui/UserDefinedColours.java +++ b/src/jalview/appletgui/UserDefinedColours.java @@ -1,20 +1,19 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) - * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7) + * Copyright (C) 2011 J Procter, AM Waterhouse, 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 - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. + * This file is part of Jalview. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Jalview. If not, see . */ package jalview.appletgui; @@ -52,7 +51,7 @@ public class UserDefinedColours extends Panel implements ActionListener, String originalLabel; - Color originalColour; + Object originalColour; int R = 0, G = 0, B = 0; @@ -103,18 +102,62 @@ public class UserDefinedColours extends Panel implements ActionListener, public UserDefinedColours(Component caller, Color col1, Frame alignframe) { + this(caller, col1, alignframe, "Select Colour"); + } + + /** + * Makes a dialog to choose the colour + * + * @param caller + * - handles events + * @param col1 + * - original colour + * @param alignframe + * - the parent Frame for the dialog + * @param title + * - window title + */ + public UserDefinedColours(Component caller, Color col1, Frame alignframe, + String title) + { this.caller = caller; originalColour = col1; - originalLabel = "Select Colour"; - setForDialog("Select Colour", alignframe); + originalLabel = title; + setForDialog(title, alignframe); setTargetColour(col1); dialog.setVisible(true); } + /** + * feature colour chooser + * + * @param caller + * @param label + * @param colour + */ public UserDefinedColours(Object caller, String label, Color colour) { + this(caller, label, colour, colour); + } + + /** + * feature colour chooser when changing style to single color + * + * @param me + * @param type + * @param graduatedColor + */ + public UserDefinedColours(FeatureSettings me, String type, + GraduatedColor graduatedColor) + { + this(me, type, graduatedColor, graduatedColor.getMaxColor()); + } + + private UserDefinedColours(Object caller, String label, Object ocolour, + Color colour) + { this.caller = caller; - originalColour = colour; + originalColour = ocolour; originalLabel = label; init(); remove(buttonPanel); @@ -126,12 +169,23 @@ public class UserDefinedColours extends Panel implements ActionListener, frame.setSize(420, 200); } - void setForDialog(String title, Frame alignframe) + void setForDialog(String title, Container alignframe) { init(); frame.setVisible(false); remove(buttonPanel); - dialog = new Dialog(alignframe, title, true); + if (alignframe instanceof Frame) + { + dialog = new Dialog((Frame) alignframe, title, true); + } + else + { + // if (alignframe instanceof JVDialog){ + // // not 1.1 compatible! + // dialog = new Dialog(((JVDialog)alignframe), title, true); + // } else { + throw new Error("Unsupported owner for User Colour scheme dialog."); + } dialog.add(this); this.setSize(400, 123); @@ -140,9 +194,10 @@ public class UserDefinedColours extends Panel implements ActionListener, int width = 400; dialog.setBounds(alignframe.getBounds().x - + (alignframe.getSize().width - width) / 2, alignframe - .getBounds().y - + (alignframe.getSize().height - height) / 2, width, height); + + (alignframe.getSize().width - width) / 2, + alignframe.getBounds().y + + (alignframe.getSize().height - height) / 2, width, + height); } @@ -320,14 +375,15 @@ public class UserDefinedColours extends Panel implements ActionListener, { final Button button = new Button(); Color col = Color.white; - - try - { - col = oldColourScheme.findColour(aa.charAt(0), -1); - } catch (Exception ex) + if (oldColourScheme != null) { + try + { + col = oldColourScheme.findColour(aa.charAt(0), -1); + } catch (Exception ex) + { + } } - button.setBackground(col); oldColours.addElement(col); button.setLabel(label); @@ -381,7 +437,20 @@ public class UserDefinedColours extends Panel implements ActionListener, } else if (caller instanceof FeatureRenderer) { - ((FeatureRenderer) caller).colourPanel.setBackground(getColor()); + ((FeatureRenderer) caller).colourPanel.updateColor(getColor()); + } + else if (caller instanceof FeatureColourChooser) + { + if (originalLabel.indexOf("inimum") > -1) + { + ((FeatureColourChooser) caller) + .minColour_actionPerformed(getColor()); + } + else + { + ((FeatureColourChooser) caller) + .maxColour_actionPerformed(getColor()); + } } return; @@ -437,21 +506,33 @@ public class UserDefinedColours extends Panel implements ActionListener, if (originalLabel.equals("Min Colour")) { ((AnnotationColourChooser) caller) - .minColour_actionPerformed(originalColour); + .minColour_actionPerformed((Color) originalColour); } else { ((AnnotationColourChooser) caller) - .maxColour_actionPerformed(originalColour); + .maxColour_actionPerformed((Color) originalColour); } } else if (caller instanceof FeatureRenderer) { - ((FeatureRenderer) caller).colourPanel - .setBackground(originalColour); + ((FeatureRenderer) caller).colourPanel.updateColor(originalColour); } + else if (caller instanceof FeatureColourChooser) + { + if (originalLabel.indexOf("inimum") > -1) + { + ((FeatureColourChooser) caller) + .minColour_actionPerformed((Color) originalColour); + } + else + { + ((FeatureColourChooser) caller) + .maxColour_actionPerformed((Color) originalColour); + } + } if (dialog != null) dialog.setVisible(false);