X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FUserDefinedColours.java;h=af8a15538b9b614ca6eb1fe9796f83e4c54784ec;hb=refs%2Fheads%2Fj2s%2Fdevelop-bh;hp=afa64190ced48a27dba437b2b6e9a630d8eb4478;hpb=aced09c4feeaf3406269442c14e54abeeb4cad81;p=jalview.git diff --git a/src/jalview/appletgui/UserDefinedColours.java b/src/jalview/appletgui/UserDefinedColours.java index afa6419..af8a155 100644 --- a/src/jalview/appletgui/UserDefinedColours.java +++ b/src/jalview/appletgui/UserDefinedColours.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2) - * Copyright (C) 2014 The Jalview Authors + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors * * This file is part of Jalview. * @@ -20,6 +20,7 @@ */ package jalview.appletgui; +import jalview.bin.JalviewLite; import jalview.datamodel.SequenceGroup; import jalview.schemes.ColourSchemeI; import jalview.schemes.GraduatedColor; @@ -27,28 +28,30 @@ import jalview.schemes.ResidueProperties; import jalview.schemes.UserColourScheme; import jalview.util.MessageManager; -import java.awt.Button; +import awt2swing.Button; import java.awt.Color; import java.awt.Component; import java.awt.Container; import java.awt.Dialog; import java.awt.Font; -import java.awt.Frame; +import awt2swing.Frame; import java.awt.GridLayout; -import java.awt.Label; -import java.awt.Panel; +import awt2swing.Label; +import awt2swing.Panel; import java.awt.Rectangle; -import java.awt.Scrollbar; -import java.awt.TextField; +import awt2swing.Scrollbar; +import awt2swing.TextField; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.AdjustmentEvent; import java.awt.event.AdjustmentListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; import java.awt.event.MouseEvent; import java.util.Vector; public class UserDefinedColours extends Panel implements ActionListener, - AdjustmentListener + AdjustmentListener, FocusListener { AlignmentPanel ap; @@ -63,7 +66,7 @@ public class UserDefinedColours extends Panel implements ActionListener, Frame frame; - MCview.AppletPDBCanvas pdbcanvas; +// MCview.AppletPDBCanvas pdbcanvas; AppletJmol jmol; @@ -100,11 +103,11 @@ public class UserDefinedColours extends Panel implements ActionListener, init(); } - public UserDefinedColours(MCview.AppletPDBCanvas pdb) - { - this.pdbcanvas = pdb; - init(); - } +// public UserDefinedColours(MCview.AppletPDBCanvas pdb) +// { +// this.pdbcanvas = pdb; +// init(); +// } public UserDefinedColours(AppletJmol jmol) { @@ -225,27 +228,28 @@ public class UserDefinedColours extends Panel implements ActionListener, public void actionPerformed(ActionEvent evt) { - if (evt.getSource() == okButton) + final Object source = evt.getSource(); + if (source == okButton) { okButton_actionPerformed(); } - else if (evt.getSource() == applyButton) + else if (source == applyButton) { applyButton_actionPerformed(); } - else if (evt.getSource() == cancelButton) + else if (source == cancelButton) { cancelButton_actionPerformed(); } - else if (evt.getSource() == rText) + else if (source == rText) { rText_actionPerformed(); } - else if (evt.getSource() == gText) + else if (source == gText) { gText_actionPerformed(); } - else if (evt.getSource() == bText) + else if (source == bText) { bText_actionPerformed(); } @@ -278,7 +282,7 @@ public class UserDefinedColours extends Panel implements ActionListener, } frame = new Frame(); frame.add(this); - jalview.bin.JalviewLite.addFrame(frame, + JalviewLite.addFrame(frame, MessageManager.getString("label.user_defined_colours"), 420, 345); @@ -427,7 +431,9 @@ public class UserDefinedColours extends Panel implements ActionListener, { applyButton_actionPerformed(); if (dialog != null) + { dialog.setVisible(false); + } frame.setVisible(false); } @@ -489,7 +495,7 @@ public class UserDefinedColours extends Panel implements ActionListener, UserColourScheme ucs = new UserColourScheme(newColours); if (ap != null) { - ucs.setThreshold(0, ap.av.getIgnoreGapsConsensus()); + ucs.setThreshold(0, ap.av.isIgnoreGapsConsensus()); } if (ap != null) @@ -509,10 +515,10 @@ public class UserDefinedColours extends Panel implements ActionListener, { jmol.setJalviewColourScheme(ucs); } - else if (pdbcanvas != null) - { - pdbcanvas.setColours(ucs); - } +// else if (pdbcanvas != null) +// { +// pdbcanvas.setColours(ucs); +// } } protected void cancelButton_actionPerformed() @@ -557,7 +563,9 @@ public class UserDefinedColours extends Panel implements ActionListener, } } if (dialog != null) + { dialog.setVisible(false); + } frame.setVisible(false); return; @@ -588,10 +596,10 @@ public class UserDefinedColours extends Panel implements ActionListener, { jmol.setJalviewColourScheme(ucs); } - else if (pdbcanvas != null) - { - pdbcanvas.pdb.setColours(ucs); - } +// else if (pdbcanvas != null) +// { +// pdbcanvas.pdb.setColours(ucs); +// } frame.setVisible(false); } @@ -660,6 +668,7 @@ public class UserDefinedColours extends Panel implements ActionListener, rText.setText("0 "); rText.setBounds(new Rectangle(156, 27, 53, 19)); rText.addActionListener(this); + rText.addFocusListener(this); label4.setAlignment(Label.RIGHT); label4.setText("G"); label4.setBounds(new Rectangle(15, 56, 20, 15)); @@ -674,6 +683,7 @@ public class UserDefinedColours extends Panel implements ActionListener, gText.setText("0 "); gText.setBounds(new Rectangle(156, 52, 53, 20)); gText.addActionListener(this); + gText.addFocusListener(this); label5.setAlignment(Label.RIGHT); label5.setText("B"); label5.setBounds(new Rectangle(14, 82, 20, 15)); @@ -688,12 +698,16 @@ public class UserDefinedColours extends Panel implements ActionListener, bText.setText("0 "); bText.setBounds(new Rectangle(157, 78, 52, 20)); bText.addActionListener(this); + bText.addFocusListener(this); target.setBackground(Color.black); target.setBounds(new Rectangle(229, 26, 134, 79)); this.add(okcancelPanel, null); okcancelPanel.add(okButton, null); okcancelPanel.add(applyButton, null); okcancelPanel.add(cancelButton, null); + this.add(rText); + this.add(gText); + this.add(bText); this.add(buttonPanel, null); this.add(target, null); this.add(gScroller); @@ -702,9 +716,40 @@ public class UserDefinedColours extends Panel implements ActionListener, this.add(label5); this.add(label4); this.add(label1); - this.add(gText); - this.add(rText); - this.add(bText); + } + + @Override + public void focusGained(FocusEvent e) + { + // noop + } + + /** + * This method applies any change to an RGB value if the user tabs out of the + * field instead of pressing Enter + */ + @Override + public void focusLost(FocusEvent e) + { + Component c = e.getComponent(); + if (c == rText) + { + rText_actionPerformed(); + } + else + { + if (c == gText) + { + gText_actionPerformed(); + } + else + { + if (c == bText) + { + bText_actionPerformed(); + } + } + } } }