X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FUserDefinedColours.java;fp=src%2Fjalview%2Fgui%2FUserDefinedColours.java;h=5ec95ede83c5edbfdf1d5a6032455ced0c6e34e9;hb=1ddaca03529cd2b02502a1dae10c18582164972d;hp=9ab43278b94218c17552be163ff38bf8190c84a8;hpb=b87940a9a7912d334d0c646c38e658a1a55be769;p=jalview.git diff --git a/src/jalview/gui/UserDefinedColours.java b/src/jalview/gui/UserDefinedColours.java index 9ab4327..5ec95ed 100755 --- a/src/jalview/gui/UserDefinedColours.java +++ b/src/jalview/gui/UserDefinedColours.java @@ -20,7 +20,6 @@ */ package jalview.gui; -import jalview.api.structures.JalviewStructureDisplayI; import jalview.bin.Cache; import jalview.datamodel.SequenceGroup; import jalview.io.JalviewFileChooser; @@ -40,7 +39,6 @@ import jalview.util.MessageManager; import java.awt.Color; import java.awt.Font; import java.awt.Insets; -import java.awt.event.ActionEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.io.File; @@ -82,14 +80,10 @@ public class UserDefinedColours extends GUserDefinedColours implements SequenceGroup seqGroup; - List selectedButtons; - ColourSchemeI oldColourScheme; JInternalFrame frame; - JalviewStructureDisplayI structureViewer; - List upperCaseButtons; List lowerCaseButtons; @@ -140,29 +134,7 @@ public class UserDefinedColours extends GUserDefinedColours implements showFrame(); } - public UserDefinedColours(JalviewStructureDisplayI viewer, - ColourSchemeI oldcs) - { - this(); - this.structureViewer = viewer; - - colorChooser.getSelectionModel().addChangeListener(this); - - oldColourScheme = oldcs; - - if (oldColourScheme instanceof UserColourScheme) - { - schemeName.setText(((UserColourScheme) oldColourScheme) - .getSchemeName()); - } - - resetButtonPanel(false); - - showFrame(); - - } - - public UserDefinedColours() + UserDefinedColours() { super(); selectedButtons = new ArrayList(); @@ -509,8 +481,7 @@ public class UserDefinedColours extends GUserDefinedColours implements } /** - * Applies the current colour scheme to the alignment, sequence group or - * structure view. + * Applies the current colour scheme to the alignment or sequence group */ @Override protected void applyButton_actionPerformed() @@ -534,12 +505,14 @@ public class UserDefinedColours extends GUserDefinedColours implements { ap.alignFrame.changeColour(ucs); } - else if (structureViewer != null) - { - structureViewer.setJalviewColourScheme(ucs); - } } + /** + * Constructs an instance of UserColourScheme with the residue colours + * currently set on the buttons on the panel + * + * @return + */ UserColourScheme getSchemeFromButtons() { @@ -595,13 +568,15 @@ public class UserDefinedColours extends GUserDefinedColours implements } /** - * DOCUMENT ME! - * - * @param e - * DOCUMENT ME! + * Action on clicking Load scheme button. + *
    + *
  • Open a file chooser to browse for files with extension .jc
  • + *
  • Load in the colour scheme and transfer it to this panel's buttons
  • + *
  • Register the loaded colour scheme
  • + *
*/ @Override - protected void loadbutton_actionPerformed(ActionEvent e) + protected void loadbutton_actionPerformed() { upperCaseButtons = new ArrayList(); lowerCaseButtons = new ArrayList(); @@ -683,13 +658,20 @@ public class UserDefinedColours extends GUserDefinedColours implements } /** - * DOCUMENT ME! - * - * @param e - * DOCUMENT ME! + * Action on pressing the Save button. + *
    + *
  • Check a name has been entered
  • + *
  • Warn if the name already exists, remove any existing scheme of the same + * name if overwriting
  • + *
  • Do the standard file chooser thing to write with extension .jc
  • + *
  • If saving changes (possibly not yet applied) to the currently selected + * colour scheme, then apply the changes, as it is too late to back out now
  • + *
  • Don't apply the changes if the currently selected scheme is different, + * to allow a new scheme to be configured and saved but not applied
  • + *
*/ @Override - protected void savebutton_actionPerformed(ActionEvent e) + protected void savebutton_actionPerformed() { String name = schemeName.getText().trim(); if (name.length() < 1) @@ -731,6 +713,16 @@ public class UserDefinedColours extends GUserDefinedColours implements File file = chooser.getSelectedFile(); addNewColourScheme(file.getPath()); saveToFile(file); + + /* + * changes saved - apply to alignment if we are changing + * the currently selected colour scheme + */ + if (oldColourScheme != null + && name.equals(oldColourScheme.getSchemeName())) + { + applyButton_actionPerformed(); + } } } @@ -787,7 +779,8 @@ public class UserDefinedColours extends GUserDefinedColours implements * marshal to file */ JalviewUserColours ucs = new JalviewUserColours(); - ucs.setSchemeName(schemeName.getText()); + String name = schemeName.getText(); + ucs.setSchemeName(name); try { PrintWriter out = new PrintWriter(new OutputStreamWriter( @@ -810,12 +803,11 @@ public class UserDefinedColours extends GUserDefinedColours implements } /** - * On cancel, restores the colour scheme before the dialogue was opened - * - * @param e + * On cancel, restores the colour scheme that was selected before the dialogue + * was opened */ @Override - protected void cancelButton_actionPerformed(ActionEvent e) + protected void cancelButton_actionPerformed() { if (ap != null) { @@ -830,11 +822,6 @@ public class UserDefinedColours extends GUserDefinedColours implements ap.paintAlignment(true); } - if (structureViewer != null) - { - structureViewer.setJalviewColourScheme(oldColourScheme); - } - try { frame.setClosed(true); @@ -843,8 +830,14 @@ public class UserDefinedColours extends GUserDefinedColours implements } } + /** + * Action on selecting or deselecting the Case Sensitive option. When + * selected, separate buttons are shown for lower case residues, and the panel + * is resized to accommodate them. Also, the checkbox for 'apply colour to all + * lower case' is enabled. + */ @Override - public void caseSensitive_actionPerformed(ActionEvent e) + public void caseSensitive_actionPerformed() { boolean selected = caseSensitive.isSelected(); resetButtonPanel(selected);