X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FUserDefinedColours.java;h=845110e7d4464ed641fd163199f93ea1820fcd22;hb=d065bc916cb63af83cdab7319f5177a855724aba;hp=ccb79320ae64452f6a6da2bd67f2bd5c871b1116;hpb=c19d2a91ca05e052e3408bf5852d88eb5d0608f1;p=jalview.git diff --git a/src/jalview/appletgui/UserDefinedColours.java b/src/jalview/appletgui/UserDefinedColours.java index ccb7932..845110e 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.9.0b2) - * Copyright (C) 2015 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,9 +20,14 @@ */ package jalview.appletgui; +import jalview.analysis.AAFrequency; +import jalview.api.FeatureColourI; import jalview.datamodel.SequenceGroup; +import jalview.renderer.ResidueShader; +import jalview.schemes.Blosum62ColourScheme; import jalview.schemes.ColourSchemeI; -import jalview.schemes.GraduatedColor; +import jalview.schemes.FeatureColour; +import jalview.schemes.PIDColourScheme; import jalview.schemes.ResidueProperties; import jalview.schemes.UserColourScheme; import jalview.util.MessageManager; @@ -59,7 +64,7 @@ public class UserDefinedColours extends Panel implements ActionListener, Button selectedButton; - Vector oldColours = new Vector(); + Vector oldColours = new Vector(); ColourSchemeI oldColourScheme; @@ -75,7 +80,7 @@ public class UserDefinedColours extends Panel implements ActionListener, String originalLabel; - Object originalColour; + FeatureColourI originalColour; int R = 0, G = 0, B = 0; @@ -92,7 +97,7 @@ public class UserDefinedColours extends Panel implements ActionListener, if (seqGroup != null) { - oldColourScheme = seqGroup.cs; + oldColourScheme = seqGroup.getColourScheme(); } else { @@ -117,7 +122,7 @@ public class UserDefinedColours extends Panel implements ActionListener, public UserDefinedColours(FeatureRenderer fr, Frame alignframe) { caller = fr; - originalColour = fr.colourPanel.getBackground(); + originalColour = new FeatureColour(fr.colourPanel.getBackground()); originalLabel = "Feature Colour"; setForDialog("Select Feature Colour", alignframe); setTargetColour(fr.colourPanel.getBackground()); @@ -134,21 +139,21 @@ public class UserDefinedColours extends Panel implements ActionListener, * * @param caller * - handles events - * @param col1 + * @param col * - original colour * @param alignframe * - the parent Frame for the dialog * @param title * - window title */ - public UserDefinedColours(Component caller, Color col1, Frame alignframe, + public UserDefinedColours(Component caller, Color col, Frame alignframe, String title) { this.caller = caller; - originalColour = col1; + originalColour = new FeatureColour(col); originalLabel = title; setForDialog(title, alignframe); - setTargetColour(col1); + setTargetColour(col); dialog.setVisible(true); } @@ -161,7 +166,7 @@ public class UserDefinedColours extends Panel implements ActionListener, */ public UserDefinedColours(Object caller, String label, Color colour) { - this(caller, label, colour, colour); + this(caller, label, new FeatureColour(colour), colour); } /** @@ -172,13 +177,13 @@ public class UserDefinedColours extends Panel implements ActionListener, * @param graduatedColor */ public UserDefinedColours(FeatureSettings me, String type, - GraduatedColor graduatedColor) + FeatureColourI graduatedColor) { - this(me, type, graduatedColor, graduatedColor.getMaxColor()); + this(me, type, graduatedColor, graduatedColor.getMaxColour()); } - private UserDefinedColours(Object caller, String label, Object ocolour, - Color colour) + private UserDefinedColours(Object caller, String label, + FeatureColourI ocolour, Color colour) { this.caller = caller; originalColour = ocolour; @@ -228,6 +233,7 @@ public class UserDefinedColours extends Panel implements ActionListener, } + @Override public void actionPerformed(ActionEvent evt) { final Object source = evt.getSource(); @@ -257,6 +263,7 @@ public class UserDefinedColours extends Panel implements ActionListener, } } + @Override public void adjustmentValueChanged(AdjustmentEvent evt) { if (evt.getSource() == rScroller) @@ -404,14 +411,9 @@ public class UserDefinedColours extends Panel implements ActionListener, { final Button button = new Button(); Color col = Color.white; - if (oldColourScheme != null) + if (oldColourScheme != null && oldColourScheme.isSimple()) { - try - { - col = oldColourScheme.findColour(aa.charAt(0), -1, null); - } catch (Exception ex) - { - } + col = oldColourScheme.findColour(aa.charAt(0), 0, null, null, 0f); } button.setBackground(col); oldColours.addElement(col); @@ -420,6 +422,7 @@ public class UserDefinedColours extends Panel implements ActionListener, button.setFont(new java.awt.Font("Verdana", 1, 10)); button.addMouseListener(new java.awt.event.MouseAdapter() { + @Override public void mousePressed(MouseEvent e) { colourButtonPressed(e); @@ -451,7 +454,8 @@ public class UserDefinedColours extends Panel implements ActionListener, { if (caller instanceof FeatureSettings) { - ((FeatureSettings) caller).setUserColour(originalLabel, getColor()); + ((FeatureSettings) caller).setUserColour(originalLabel, + new FeatureColour(getColor())); } else if (caller instanceof AnnotationColourChooser) { @@ -468,7 +472,8 @@ public class UserDefinedColours extends Panel implements ActionListener, } else if (caller instanceof FeatureRenderer) { - ((FeatureRenderer) caller).colourPanel.updateColor(getColor()); + ((FeatureRenderer) caller).colourPanel + .updateColor(new FeatureColour(getColor())); } else if (caller instanceof FeatureColourChooser) { @@ -495,20 +500,24 @@ public class UserDefinedColours extends Panel implements ActionListener, } UserColourScheme ucs = new UserColourScheme(newColours); - if (ap != null) - { - ucs.setThreshold(0, ap.av.isIgnoreGapsConsensus()); - } + // if (ap != null) + // { + // ucs.setThreshold(0, ap.av.isIgnoreGapsConsensus()); + // } if (ap != null) { if (seqGroup != null) { - seqGroup.cs = ucs; + seqGroup.cs = new ResidueShader(ucs); + seqGroup.getGroupColourScheme().setThreshold(0, + ap.av.isIgnoreGapsConsensus()); } else { ap.av.setGlobalColourScheme(ucs); + ap.av.getResidueShading().setThreshold(0, + ap.av.isIgnoreGapsConsensus()); } ap.seqPanel.seqCanvas.img = null; ap.paintAlignment(true); @@ -537,12 +546,12 @@ public class UserDefinedColours extends Panel implements ActionListener, if (originalLabel.equals("Min Colour")) { ((AnnotationColourChooser) caller) - .minColour_actionPerformed((Color) originalColour); + .minColour_actionPerformed(originalColour.getColour()); } else { ((AnnotationColourChooser) caller) - .maxColour_actionPerformed((Color) originalColour); + .maxColour_actionPerformed(originalColour.getColour()); } } else if (caller instanceof FeatureRenderer) @@ -556,12 +565,12 @@ public class UserDefinedColours extends Panel implements ActionListener, if (originalLabel.indexOf("inimum") > -1) { ((FeatureColourChooser) caller) - .minColour_actionPerformed((Color) originalColour); + .minColour_actionPerformed(originalColour.getColour()); } else { ((FeatureColourChooser) caller) - .maxColour_actionPerformed((Color) originalColour); + .maxColour_actionPerformed(originalColour.getColour()); } } if (dialog != null) @@ -573,35 +582,25 @@ public class UserDefinedColours extends Panel implements ActionListener, return; } - Color[] newColours = new Color[24]; - for (int i = 0; i < 24; i++) - { - newColours[i] = (Color) oldColours.elementAt(i); - buttonPanel.getComponent(i).setBackground(newColours[i]); - } - - UserColourScheme ucs = new UserColourScheme(newColours); - if (ap != null) { if (seqGroup != null) { - seqGroup.cs = ucs; + seqGroup.cs = new ResidueShader(oldColourScheme); + if (oldColourScheme instanceof PIDColourScheme + || oldColourScheme instanceof Blosum62ColourScheme) + { + seqGroup.cs.setConsensus(AAFrequency.calculate( + seqGroup.getSequences(ap.av.getHiddenRepSequences()), 0, + ap.av.getAlignment().getWidth())); + } } else { - ap.av.setGlobalColourScheme(ucs); + ap.av.setGlobalColourScheme(oldColourScheme); } ap.paintAlignment(true); } - else if (jmol != null) - { - jmol.setJalviewColourScheme(ucs); - } - else if (pdbcanvas != null) - { - pdbcanvas.pdb.setColours(ucs); - } frame.setVisible(false); }