/*
- * 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.
*
*/
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.FeatureColour;
+import jalview.schemes.PIDColourScheme;
import jalview.schemes.ResidueProperties;
import jalview.schemes.UserColourScheme;
import jalview.util.MessageManager;
import java.awt.event.MouseEvent;
import java.util.Vector;
-public class UserDefinedColours extends Panel implements ActionListener,
- AdjustmentListener, FocusListener
+public class UserDefinedColours extends Panel
+ implements ActionListener, AdjustmentListener, FocusListener
{
AlignmentPanel ap;
Button selectedButton;
- Vector<Color> oldColours = new Vector<Color>();
+ Vector<Color> oldColours = new Vector<>();
ColourSchemeI oldColourScheme;
Frame frame;
- MCview.AppletPDBCanvas pdbcanvas;
+ mc_view.AppletPDBCanvas pdbcanvas;
AppletJmol jmol;
if (seqGroup != null)
{
- oldColourScheme = seqGroup.cs;
+ oldColourScheme = seqGroup.getColourScheme();
}
else
{
init();
}
- public UserDefinedColours(MCview.AppletPDBCanvas pdb)
+ public UserDefinedColours(mc_view.AppletPDBCanvas pdb)
{
this.pdbcanvas = pdb;
init();
// // not 1.1 compatible!
// dialog = new Dialog(((JVDialog)alignframe), title, true);
// } else {
- throw new Error(
- MessageManager
- .getString("label.error_unsupported_owwner_user_colour_scheme"));
+ throw new Error(MessageManager.getString(
+ "label.error_unsupported_owwner_user_colour_scheme"));
}
dialog.add(this);
int height = 160 + alignframe.getInsets().top + getInsets().bottom;
int width = 400;
- dialog.setBounds(alignframe.getBounds().x
- + (alignframe.getSize().width - width) / 2,
+ dialog.setBounds(
+ alignframe.getBounds().x
+ + (alignframe.getSize().width - width) / 2,
alignframe.getBounds().y
- + (alignframe.getSize().height - height) / 2, width,
- height);
+ + (alignframe.getSize().height - height) / 2,
+ width, height);
}
{
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);
}
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);
+ ap.paintAlignment(true, true);
}
else if (jmol != null)
{
- jmol.setJalviewColourScheme(ucs);
+ jmol.colourByJalviewColourScheme(ucs);
}
else if (pdbcanvas != null)
{
return;
}
- Color[] newColours = new Color[24];
- for (int i = 0; i < 24; i++)
- {
- newColours[i] = 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);
+ ap.paintAlignment(true, true);
}
frame.setVisible(false);