*/
package jalview.gui;
-import jalview.api.structures.JalviewStructureDisplayI;
import jalview.bin.Cache;
import jalview.datamodel.SequenceGroup;
import jalview.io.JalviewFileChooser;
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;
SequenceGroup seqGroup;
- List<JButton> selectedButtons;
-
ColourSchemeI oldColourScheme;
JInternalFrame frame;
- JalviewStructureDisplayI structureViewer;
-
List<JButton> upperCaseButtons;
List<JButton> lowerCaseButtons;
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<JButton>();
}
/**
- * 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()
{
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()
{
}
/**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
+ * Action on clicking Load scheme button.
+ * <ul>
+ * <li>Open a file chooser to browse for files with extension .jc</li>
+ * <li>Load in the colour scheme and transfer it to this panel's buttons</li>
+ * <li>Register the loaded colour scheme</li>
+ * </ul>
*/
@Override
- protected void loadbutton_actionPerformed(ActionEvent e)
+ protected void loadbutton_actionPerformed()
{
upperCaseButtons = new ArrayList<JButton>();
lowerCaseButtons = new ArrayList<JButton>();
}
/**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
+ * Action on pressing the Save button.
+ * <ul>
+ * <li>Check a name has been entered</li>
+ * <li>Warn if the name already exists, remove any existing scheme of the same
+ * name if overwriting</li>
+ * <li>Do the standard file chooser thing to write with extension .jc</li>
+ * <li>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</li>
+ * <li>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</li>
+ * </ul>
*/
@Override
- protected void savebutton_actionPerformed(ActionEvent e)
+ protected void savebutton_actionPerformed()
{
String name = schemeName.getText().trim();
if (name.length() < 1)
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();
+ }
}
}
* 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(
}
/**
- * 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)
{
ap.paintAlignment(true);
}
- if (structureViewer != null)
- {
- structureViewer.setJalviewColourScheme(oldColourScheme);
- }
-
try
{
frame.setClosed(true);
}
}
+ /**
+ * 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);
gridLayout.setRows(5);
okButton.setFont(new java.awt.Font("Verdana", 0, 11));
okButton.setText(MessageManager.getString("action.ok"));
- okButton.addActionListener(new java.awt.event.ActionListener()
+ okButton.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
});
loadbutton.setFont(new java.awt.Font("Verdana", 0, 11));
loadbutton.setText(MessageManager.getString("action.load_scheme"));
- loadbutton.addActionListener(new java.awt.event.ActionListener()
+ loadbutton.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
- loadbutton_actionPerformed(e);
+ loadbutton_actionPerformed();
}
});
savebutton.setFont(new java.awt.Font("Verdana", 0, 11));
savebutton.setText(MessageManager.getString("action.save_scheme"));
- savebutton.addActionListener(new java.awt.event.ActionListener()
+ savebutton.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
- savebutton_actionPerformed(e);
+ savebutton_actionPerformed();
}
});
cancelButton.setFont(JvSwingUtils.getLabelFont());
cancelButton.setText(MessageManager.getString("action.cancel"));
- cancelButton.addActionListener(new java.awt.event.ActionListener()
+ cancelButton.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
- cancelButton_actionPerformed(e);
+ cancelButton_actionPerformed();
}
});
this.setBackground(new Color(212, 208, 223));
@Override
public void actionPerformed(ActionEvent e)
{
- caseSensitive_actionPerformed(e);
+ caseSensitive_actionPerformed();
}
});
lcaseColour
* @param e
* DOCUMENT ME!
*/
- protected void loadbutton_actionPerformed(ActionEvent e)
+ protected void loadbutton_actionPerformed()
{
}
- /**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
- */
- protected void savebutton_actionPerformed(ActionEvent e)
+ protected void savebutton_actionPerformed()
{
}
* @param e
* DOCUMENT ME!
*/
- protected void cancelButton_actionPerformed(ActionEvent e)
+ protected void cancelButton_actionPerformed()
{
}
- public void caseSensitive_actionPerformed(ActionEvent e)
+ public void caseSensitive_actionPerformed()
{
}
- public void lcaseColour_actionPerformed(ActionEvent e)
+ public void lcaseColour_actionPerformed()
{
}