From 406f3f0bc69c49fb910a601a2acd20f028eea012 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Fri, 9 Dec 2005 13:35:03 +0000 Subject: [PATCH] Can be used by PDBViewer --- src/jalview/gui/UserDefinedColours.java | 61 ++++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 6 deletions(-) diff --git a/src/jalview/gui/UserDefinedColours.java b/src/jalview/gui/UserDefinedColours.java index ec4ad55..089c8a9 100755 --- a/src/jalview/gui/UserDefinedColours.java +++ b/src/jalview/gui/UserDefinedColours.java @@ -52,6 +52,7 @@ public class UserDefinedColours extends GUserDefinedColours Vector selectedButtons; ColourSchemeI oldColourScheme; JInternalFrame frame; + MCview.PDBCanvas pdbcanvas; /** * Creates a new UserDefinedColours object. @@ -106,6 +107,40 @@ public class UserDefinedColours extends GUserDefinedColours makeButton("Gap", "-"); } + public UserDefinedColours(MCview.PDBCanvas pdb, ColourSchemeI oldcs) + { + super(); + frame = new JInternalFrame(); + frame.setContentPane(this); + Desktop.addInternalFrame(frame, "User Defined Colours", 720, 370, true); + pdbcanvas = pdb; + + if (System.getProperty("os.name").startsWith("Mac")) + { + frame.setSize(760, 370); + } + + colorChooser.getSelectionModel().addChangeListener(this); + + oldColourScheme = oldcs; + + if (oldColourScheme instanceof UserColourScheme) + { + schemeName.setText( ( (UserColourScheme) oldColourScheme).getName()); + } + for (int i = 0; i < 20; i++) + { + makeButton(ResidueProperties.aa2Triplet.get(ResidueProperties.aa[i]) + + "", ResidueProperties.aa[i]); + } + + makeButton("B", "B"); + makeButton("Z", "Z"); + makeButton("X", "X"); + makeButton("Gap", "-"); + } + + /** * DOCUMENT ME! * @@ -269,10 +304,15 @@ public class UserDefinedColours extends GUserDefinedColours seqGroup.cs = ucs; ap.repaint(); } - else + else if(ap!=null) { ap.alignFrame.changeColour(ucs); } + else if(pdbcanvas!=null) + { + pdbcanvas.pdb.setColours(ucs); + pdbcanvas.updateSeqColours(); + } } UserColourScheme getSchemeFromGUI() @@ -286,7 +326,9 @@ public class UserDefinedColours extends GUserDefinedColours } UserColourScheme ucs = new UserColourScheme(newColours); - ucs.setThreshold(0, ap.av.getIgnoreGapsConsensus()); + if(ap!=null) + ucs.setThreshold(0, ap.av.getIgnoreGapsConsensus()); + return ucs; } @@ -494,16 +536,23 @@ public class UserDefinedColours extends GUserDefinedColours */ protected void cancelButton_actionPerformed(ActionEvent e) { + if (ap != null) + { if (seqGroup != null) { - seqGroup.cs = oldColourScheme; + seqGroup.cs = oldColourScheme; } - else + else if (ap != null) { - ap.av.setGlobalColourScheme(oldColourScheme); + ap.av.setGlobalColourScheme(oldColourScheme); } - ap.repaint(); + } + + if(pdbcanvas!=null) + { + pdbcanvas.pdb.setColours(oldColourScheme); + } try { -- 1.7.10.2