*/
package jalview.gui;
-import jalview.analysis.AAFrequency;
import jalview.analysis.AlignmentSorter;
import jalview.analysis.AlignmentUtils;
-import jalview.analysis.Conservation;
import jalview.analysis.CrossRef;
import jalview.analysis.Dna;
import jalview.analysis.ParseProperties;
*/
public void changeColour(ColourSchemeI cs)
{
- // TODO: compare with applet and pull up to model method
- int threshold = 0;
+ // TODO: pull up to controller method
if (cs != null)
{
+ // Make sure viewport is up to date w.r.t. any sliders
if (viewport.getAbovePIDThreshold())
{
- threshold = SliderPanel.setPIDSliderSource(alignPanel, cs,
+ int threshold = SliderPanel.setPIDSliderSource(alignPanel, cs,
"Background");
- cs.setThreshold(threshold, viewport.isIgnoreGapsConsensus());
- }
- else
- {
- cs.setThreshold(0, viewport.isIgnoreGapsConsensus());
+ viewport.setThreshold(threshold);
}
if (viewport.getConservationSelected())
{
-
- Alignment al = (Alignment) viewport.getAlignment();
- Conservation c = new Conservation("All",
- ResidueProperties.propHash, 3, al.getSequences(), 0,
- al.getWidth() - 1);
-
- c.calculate();
- c.verdict(false, viewport.getConsPercGaps());
-
- cs.setConservation(c);
-
cs.setConservationInc(SliderPanel.setConservationSlider(alignPanel,
cs, "Background"));
}
- else
- {
- cs.setConservation(null);
- }
-
- cs.setConsensus(viewport.getSequenceConsensusHash());
}
viewport.setGlobalColourScheme(cs);
- if (viewport.getColourAppliesToAllGroups())
- {
-
- for (SequenceGroup sg : viewport.getAlignment().getGroups())
- {
- if (cs == null)
- {
- sg.cs = null;
- continue;
- }
-
- if (cs instanceof ClustalxColourScheme)
- {
- sg.cs = new ClustalxColourScheme(sg,
- viewport.getHiddenRepSequences());
- }
- else if (cs instanceof UserColourScheme)
- {
- sg.cs = new UserColourScheme(((UserColourScheme) cs).getColours());
- }
- else
- {
- try
- {
- sg.cs = cs.getClass().newInstance();
- } catch (Exception ex)
- {
- }
- }
-
- if (viewport.getAbovePIDThreshold()
- || cs instanceof PIDColourScheme
- || cs instanceof Blosum62ColourScheme)
- {
- sg.cs.setThreshold(threshold, viewport.isIgnoreGapsConsensus());
-
- sg.cs.setConsensus(AAFrequency.calculate(
- sg.getSequences(viewport.getHiddenRepSequences()),
- sg.getStartRes(), sg.getEndRes() + 1));
- }
- else
- {
- sg.cs.setThreshold(0, viewport.isIgnoreGapsConsensus());
- }
-
- if (viewport.getConservationSelected())
- {
- Conservation c = new Conservation("Group",
- ResidueProperties.propHash, 3, sg.getSequences(viewport
- .getHiddenRepSequences()), sg.getStartRes(),
- sg.getEndRes() + 1);
- c.calculate();
- c.verdict(false, viewport.getConsPercGaps());
- sg.cs.setConservation(c);
- }
- else
- {
- sg.cs.setConservation(null);
- }
- }
- }
-
- if (alignPanel.getOverviewPanel() != null)
- {
- alignPanel.getOverviewPanel().updateOverviewImage();
- }
-
alignPanel.paintAlignment(true);
}