X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FUserDefinedColours.java;h=a104ad97cddf25734dcdf912b4a438f9e8d7a555;hb=6fb502e4a8749d1d98f5442c3b8156ab47996b77;hp=ca1ebf48693fc77f03549fb15fce6c812843ec1e;hpb=506d60f0e188723ddc91c26824b41ac7034df3fe;p=jalview.git diff --git a/src/jalview/gui/UserDefinedColours.java b/src/jalview/gui/UserDefinedColours.java index ca1ebf4..a104ad9 100755 --- a/src/jalview/gui/UserDefinedColours.java +++ b/src/jalview/gui/UserDefinedColours.java @@ -1,35 +1,49 @@ /* - * 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.8) + * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, 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. + * + * 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * You should have received a copy of the GNU General Public License along with Jalview. If not, see . */ package jalview.gui; -import java.io.*; -import java.util.*; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.event.*; - -import jalview.datamodel.*; -import jalview.io.*; -import jalview.jbgui.*; -import jalview.schemes.*; +import jalview.datamodel.SequenceGroup; +import jalview.io.JalviewFileChooser; +import jalview.jbgui.GUserDefinedColours; +import jalview.schemes.ColourSchemeI; +import jalview.schemes.ResidueProperties; +import jalview.schemes.UserColourScheme; +import jalview.util.MessageManager; + +import java.awt.Color; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.MouseEvent; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.util.Hashtable; +import java.util.StringTokenizer; +import java.util.Vector; + +import javax.swing.JButton; +import javax.swing.JInternalFrame; +import javax.swing.JOptionPane; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; /** * DOCUMENT ME! @@ -60,9 +74,9 @@ public class UserDefinedColours extends GUserDefinedColours implements * Creates a new UserDefinedColours object. * * @param ap - * DOCUMENT ME! + * DOCUMENT ME! * @param sg - * DOCUMENT ME! + * DOCUMENT ME! */ public UserDefinedColours(AlignmentPanel ap, SequenceGroup sg) { @@ -218,7 +232,7 @@ public class UserDefinedColours extends GUserDefinedColours implements * DOCUMENT ME! * * @param evt - * DOCUMENT ME! + * DOCUMENT ME! */ public void stateChanged(ChangeEvent evt) { @@ -249,7 +263,7 @@ public class UserDefinedColours extends GUserDefinedColours implements * DOCUMENT ME! * * @param e - * DOCUMENT ME! + * DOCUMENT ME! */ public void colourButtonPressed(MouseEvent e) { @@ -298,9 +312,7 @@ public class UserDefinedColours extends GUserDefinedColours implements JButton button = (JButton) buttonPanel.getComponent(b); if (!selectedButtons.contains(button)) { - button - .setForeground(button.getBackground().brighter() - .brighter()); + button.setForeground(button.getBackground().brighter().brighter()); selectedButtons.add(button); } } @@ -326,9 +338,7 @@ public class UserDefinedColours extends GUserDefinedColours implements } else { - pressed - .setForeground(pressed.getBackground().brighter() - .brighter()); + pressed.setForeground(pressed.getBackground().brighter().brighter()); selectedButtons.addElement(pressed); } } @@ -344,9 +354,9 @@ public class UserDefinedColours extends GUserDefinedColours implements * DOCUMENT ME! * * @param label - * DOCUMENT ME! + * DOCUMENT ME! * @param aa - * DOCUMENT ME! + * DOCUMENT ME! */ JButton makeButton(String label, String aa, Vector caseSensitiveButtons, int buttonIndex) @@ -373,12 +383,14 @@ public class UserDefinedColours extends GUserDefinedColours implements caseSensitiveButtons.addElement(button); 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, null); + } catch (Exception ex) + { + } } } @@ -403,7 +415,7 @@ public class UserDefinedColours extends GUserDefinedColours implements * DOCUMENT ME! * * @param e - * DOCUMENT ME! + * DOCUMENT ME! */ protected void okButton_actionPerformed(ActionEvent e) { @@ -421,7 +433,7 @@ public class UserDefinedColours extends GUserDefinedColours implements * DOCUMENT ME! * * @param e - * DOCUMENT ME! + * DOCUMENT ME! */ protected void applyButton_actionPerformed(ActionEvent e) { @@ -479,17 +491,17 @@ public class UserDefinedColours extends GUserDefinedColours implements * DOCUMENT ME! * * @param e - * DOCUMENT ME! + * DOCUMENT ME! */ protected void loadbutton_actionPerformed(ActionEvent e) { upperCaseButtons = new Vector(); lowerCaseButtons = new Vector(); - JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache - .getProperty("LAST_DIRECTORY"), new String[] - { "jc" }, new String[] - { "Jalview User Colours" }, "Jalview User Colours"); + JalviewFileChooser chooser = new JalviewFileChooser( + jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] + { "jc" }, new String[] + { "Jalview User Colours" }, "Jalview User Colours"); chooser.setFileView(new jalview.io.JalviewFileView()); chooser.setDialogTitle("Load colour scheme"); chooser.setToolTipText("Load"); @@ -579,7 +591,7 @@ public class UserDefinedColours extends GUserDefinedColours implements * DOCUMENT ME! * * @param file - * DOCUMENT ME! + * DOCUMENT ME! * * @return DOCUMENT ME! */ @@ -692,26 +704,25 @@ public class UserDefinedColours extends GUserDefinedColours implements * DOCUMENT ME! * * @param e - * DOCUMENT ME! + * DOCUMENT ME! */ protected void savebutton_actionPerformed(ActionEvent e) { if (schemeName.getText().trim().length() < 1) { JOptionPane.showInternalMessageDialog(Desktop.desktop, - "User colour scheme must have a name!", - "No name for colour scheme", JOptionPane.WARNING_MESSAGE); + MessageManager.getString("label.user_colour_scheme_must_have_name"), + MessageManager.getString("label.no_name_colour_scheme"), JOptionPane.WARNING_MESSAGE); return; } if (userColourSchemes != null && userColourSchemes.containsKey(schemeName.getText())) { - int reply = JOptionPane.showInternalConfirmDialog(Desktop.desktop, - "Colour scheme " + schemeName.getText() + " exists." - + "\nContinue saving colour scheme as " - + schemeName.getText() + "?", - "Duplicate scheme name", JOptionPane.YES_NO_OPTION); + int reply = JOptionPane.showInternalConfirmDialog( + Desktop.desktop, + MessageManager.formatMessage("label.colour_scheme_exists_overwrite", new String[]{schemeName.getText(),schemeName.getText()}), + MessageManager.getString("label.duplicate_scheme_name"), JOptionPane.YES_NO_OPTION); if (reply != JOptionPane.YES_OPTION) { return; @@ -719,10 +730,10 @@ public class UserDefinedColours extends GUserDefinedColours implements userColourSchemes.remove(schemeName.getText()); } - JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache - .getProperty("LAST_DIRECTORY"), new String[] - { "jc" }, new String[] - { "Jalview User Colours" }, "Jalview User Colours"); + JalviewFileChooser chooser = new JalviewFileChooser( + jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] + { "jc" }, new String[] + { "Jalview User Colours" }, "Jalview User Colours"); chooser.setFileView(new jalview.io.JalviewFileView()); chooser.setDialogTitle("Save colour scheme"); @@ -781,7 +792,7 @@ public class UserDefinedColours extends GUserDefinedColours implements * DOCUMENT ME! * * @param e - * DOCUMENT ME! + * DOCUMENT ME! */ protected void cancelButton_actionPerformed(ActionEvent e) { @@ -855,8 +866,8 @@ public class UserDefinedColours extends GUserDefinedColours implements { if (coloursFound.toString().length() > 1) { - jalview.bin.Cache.setProperty("USER_DEFINED_COLOURS", coloursFound - .toString()); + jalview.bin.Cache.setProperty("USER_DEFINED_COLOURS", + coloursFound.toString()); } else { @@ -875,8 +886,8 @@ public class UserDefinedColours extends GUserDefinedColours implements userColourSchemes = new Hashtable(); StringBuffer coloursFound = new StringBuffer(); - StringTokenizer st = new StringTokenizer(jalview.bin.Cache - .getProperty("USER_DEFINED_COLOURS"), "|"); + StringTokenizer st = new StringTokenizer( + jalview.bin.Cache.getProperty("USER_DEFINED_COLOURS"), "|"); while (st.hasMoreElements()) { @@ -901,8 +912,8 @@ public class UserDefinedColours extends GUserDefinedColours implements if (coloursFound.toString().length() > 1) { - jalview.bin.Cache.setProperty("USER_DEFINED_COLOURS", coloursFound - .toString()); + jalview.bin.Cache.setProperty("USER_DEFINED_COLOURS", + coloursFound.toString()); } else {