X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FUserDefinedColours.java;h=60c45c5ca50ae6a42c59ee6bdb0d7b38c13ee014;hb=02e9934037787599aefda03a6af9b7501e867dc3;hp=83f9d0ce8d590bd037beb7fb0d2c8e47a38287d5;hpb=3825c0853b33c036d396bb9e3f8b4d7b4966e5ad;p=jalview.git diff --git a/src/jalview/gui/UserDefinedColours.java b/src/jalview/gui/UserDefinedColours.java index 83f9d0c..60c45c5 100755 --- a/src/jalview/gui/UserDefinedColours.java +++ b/src/jalview/gui/UserDefinedColours.java @@ -1,35 +1,48 @@ /* - * 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 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 +73,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 +231,7 @@ public class UserDefinedColours extends GUserDefinedColours implements * DOCUMENT ME! * * @param evt - * DOCUMENT ME! + * DOCUMENT ME! */ public void stateChanged(ChangeEvent evt) { @@ -249,7 +262,7 @@ public class UserDefinedColours extends GUserDefinedColours implements * DOCUMENT ME! * * @param e - * DOCUMENT ME! + * DOCUMENT ME! */ public void colourButtonPressed(MouseEvent e) { @@ -298,9 +311,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 +337,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 +353,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,11 +382,11 @@ public class UserDefinedColours extends GUserDefinedColours implements caseSensitiveButtons.addElement(button); col = Color.white; - if (oldColourScheme!=null) + if (oldColourScheme != null) { try { - col = oldColourScheme.findColour(aa.charAt(0), -1); + col = oldColourScheme.findColour(aa.charAt(0), -1, null); } catch (Exception ex) { } @@ -405,7 +414,7 @@ public class UserDefinedColours extends GUserDefinedColours implements * DOCUMENT ME! * * @param e - * DOCUMENT ME! + * DOCUMENT ME! */ protected void okButton_actionPerformed(ActionEvent e) { @@ -423,7 +432,7 @@ public class UserDefinedColours extends GUserDefinedColours implements * DOCUMENT ME! * * @param e - * DOCUMENT ME! + * DOCUMENT ME! */ protected void applyButton_actionPerformed(ActionEvent e) { @@ -481,17 +490,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"); @@ -581,7 +590,7 @@ public class UserDefinedColours extends GUserDefinedColours implements * DOCUMENT ME! * * @param file - * DOCUMENT ME! + * DOCUMENT ME! * * @return DOCUMENT ME! */ @@ -694,7 +703,7 @@ public class UserDefinedColours extends GUserDefinedColours implements * DOCUMENT ME! * * @param e - * DOCUMENT ME! + * DOCUMENT ME! */ protected void savebutton_actionPerformed(ActionEvent e) { @@ -709,7 +718,8 @@ public class UserDefinedColours extends GUserDefinedColours implements if (userColourSchemes != null && userColourSchemes.containsKey(schemeName.getText())) { - int reply = JOptionPane.showInternalConfirmDialog(Desktop.desktop, + int reply = JOptionPane.showInternalConfirmDialog( + Desktop.desktop, "Colour scheme " + schemeName.getText() + " exists." + "\nContinue saving colour scheme as " + schemeName.getText() + "?", @@ -721,10 +731,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"); @@ -783,7 +793,7 @@ public class UserDefinedColours extends GUserDefinedColours implements * DOCUMENT ME! * * @param e - * DOCUMENT ME! + * DOCUMENT ME! */ protected void cancelButton_actionPerformed(ActionEvent e) { @@ -857,8 +867,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 { @@ -877,8 +887,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()) { @@ -903,8 +913,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 {