public class UserDefinedColours extends GUserDefinedColours implements
ChangeListener
{
- private static final Font VERDANA_BOLD_10 = new Font("Verdana", Font.BOLD, 10);
++ private static final Font VERDANA_BOLD_10 = new Font("Verdana",
++ Font.BOLD, 10);
+
+ public static final String USER_DEFINED_COLOURS = "USER_DEFINED_COLOURS";
+
+ private static final String LAST_DIRECTORY = "LAST_DIRECTORY";
+
private static final int MY_FRAME_HEIGHT = 420;
private static final int MY_FRAME_WIDTH = 810;
if (oldColourScheme instanceof UserColourScheme)
{
- schemeName.setText(((UserColourScheme) oldColourScheme).getSchemeName());
- schemeName.setText(((UserColourScheme) oldColourScheme).getName());
++ schemeName.setText(((UserColourScheme) oldColourScheme)
++ .getSchemeName());
}
resetButtonPanel(false);
}
/**
- * DOCUMENT ME!
+ * A helper method to update or make a colour button, whose background colour
+ * is the associated colour, and text colour a darker shade of the same. If
+ * the button is already in the list, then its text and margins are updated,
+ * if not then it is created and added. This method supports toggling between
+ * case-sensitive and case-insensitive button panels. The case-sensitive
+ * version has abbreviated button text in order to fit in more buttons.
*
* @param label
- * DOCUMENT ME!
- * @param aa
- * DOCUMENT ME!
+ * @param residue
+ * @param the
+ * list of buttons
+ * @param buttonIndex
+ * the button's position in the list
*/
- JButton makeButton(String label, String residue,
- List<JButton> buttons, int buttonIndex)
- JButton makeButton(String label, String aa,
- ArrayList<JButton> caseSensitiveButtons, int buttonIndex)
++ JButton makeButton(String label, String residue, List<JButton> buttons,
++ int buttonIndex)
{
final JButton button;
Color col;
int value = chooser.showOpenDialog(this);
- if (value == JalviewFileChooser.APPROVE_OPTION)
+ if (value != JalviewFileChooser.APPROVE_OPTION)
{
- File choice = chooser.getSelectedFile();
- jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice.getParent());
- String defaultColours = jalview.bin.Cache.getDefault(
- "USER_DEFINED_COLOURS", choice.getPath());
- if (defaultColours.indexOf(choice.getPath()) == -1)
- {
- defaultColours = defaultColours.concat("|")
- .concat(choice.getPath());
- }
-
- jalview.bin.Cache.setProperty("USER_DEFINED_COLOURS", defaultColours);
-
- UserColourScheme ucs = loadColours(choice.getAbsolutePath());
- Color[] colors = ucs.getColours();
- schemeName.setText(ucs.getName());
+ return;
+ }
+ File choice = chooser.getSelectedFile();
+ Cache.setProperty(LAST_DIRECTORY, choice.getParent());
- UserColourScheme ucs = ColourSchemes.loadColourScheme(choice.getAbsolutePath());
- if (ucs.getLowerCaseColours() != null)
- {
- caseSensitive.setSelected(true);
- lcaseColour.setEnabled(true);
- resetButtonPanel(true);
- for (int i = 0; i < lowerCaseButtons.size(); i++)
- {
- JButton button = lowerCaseButtons.get(i);
- button.setBackground(ucs.getLowerCaseColours()[i]);
- }
++ UserColourScheme ucs = ColourSchemes.loadColourScheme(choice
++ .getAbsolutePath());
+ Color[] colors = ucs.getColours();
+ schemeName.setText(ucs.getSchemeName());
- }
- else
+ if (ucs.getLowerCaseColours() != null)
+ {
+ caseSensitive.setSelected(true);
+ lcaseColour.setEnabled(true);
+ resetButtonPanel(true);
+ for (int i = 0; i < lowerCaseButtons.size(); i++)
{
- caseSensitive.setSelected(false);
- lcaseColour.setEnabled(false);
- resetButtonPanel(false);
- }
-
- for (int i = 0; i < upperCaseButtons.size(); i++)
- {
- JButton button = upperCaseButtons.get(i);
- button.setBackground(colors[i]);
+ JButton button = lowerCaseButtons.get(i);
+ button.setBackground(ucs.getLowerCaseColours()[i]);
}
+ }
+ else
+ {
+ caseSensitive.setSelected(false);
+ lcaseColour.setEnabled(false);
+ resetButtonPanel(false);
+ }
+ for (int i = 0; i < upperCaseButtons.size(); i++)
+ {
+ JButton button = upperCaseButtons.get(i);
+ button.setBackground(colors[i]);
}
+
+ addNewColourScheme(choice.getPath());
}
/**
{
return;
}
-
- userColourSchemes.remove(schemeName.getText());
+ ColourSchemes.getInstance().removeColourScheme(name);
}
- JalviewFileChooser chooser = new JalviewFileChooser(
- Cache.getProperty(LAST_DIRECTORY), "jc",
+ JalviewFileChooser chooser = new JalviewFileChooser("jc",
"Jalview User Colours");
- chooser.setFileView(new JalviewFileView());
+ JalviewFileView fileView = new JalviewFileView();
+ chooser.setFileView(fileView);
chooser.setDialogTitle(MessageManager
.getString("label.save_colour_scheme"));
chooser.setToolTipText(MessageManager.getString("action.save"));