*/
package jalview.appletgui;
+import jalview.analysis.Conservation;
import jalview.datamodel.SequenceGroup;
import jalview.renderer.ResidueShaderI;
import jalview.util.MessageManager;
import java.awt.event.MouseListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
-import java.util.Iterator;
+import java.util.List;
public class SliderPanel extends Panel implements ActionListener,
AdjustmentListener, MouseListener
conservationSlider.setTitle(MessageManager.formatMessage(
"label.conservation_colour_increment",
new String[] { source == null ? BACKGROUND : source }));
- if (ap.av.getAlignment().getGroups() != null)
+ List<SequenceGroup> groups = ap.av.getAlignment().getGroups();
+ if (groups != null && !groups.isEmpty())
{
sp.setAllGroupsCheckEnabled(true);
}
{
return;
}
-
- ResidueShaderI toChange = cs;
- Iterator<SequenceGroup> allGroups = null;
-
- if (allGroupsCheck.getState())
+ if (forConservation)
{
- allGroups = ap.av.getAlignment().getGroups().listIterator();
+ cs.setConservationApplied(true);
+ cs.setConservationInc(i);
+ }
+ else
+ {
+ cs.setThreshold(i, ap.av.isIgnoreGapsConsensus());
}
- while (toChange != null)
+ if (allGroupsCheck.getState())
{
- if (forConservation)
+ for (SequenceGroup group : ap.av.getAlignment().getGroups())
{
- toChange.setConservationInc(i);
- }
- else
- {
- toChange.setThreshold(i, ap.av.isIgnoreGapsConsensus());
- }
- if (allGroups != null && allGroups.hasNext())
- {
- while ((toChange = allGroups.next().cs) == null
- && allGroups.hasNext())
+ ResidueShaderI groupColourScheme = group.getGroupColourScheme();
+ if (forConservation)
{
- ;
+ if (!groupColourScheme.conservationApplied())
+ {
+ /*
+ * first time the colour scheme has had Conservation shading applied
+ * - compute conservation
+ */
+ Conservation c = new Conservation("Group",
+ group.getSequences(null), group.getStartRes(),
+ group.getEndRes());
+ c.calculate();
+ c.verdict(false, ap.av.getConsPercGaps());
+ group.cs.setConservation(c);
+
+ }
+ groupColourScheme.setConservationApplied(true);
+ groupColourScheme.setConservationInc(i);
+ }
+ else
+ {
+ groupColourScheme.setThreshold(i, ap.av.isIgnoreGapsConsensus());
}
- }
- else
- {
- toChange = null;
}
}
ap.seqPanel.seqCanvas.repaint();
-
}
public void setAllGroupsCheckEnabled(boolean b)
{
+ allGroupsCheck.setState(ap.av.getColourAppliesToAllGroups());
allGroupsCheck.setEnabled(b);
}
colourText = seqsel.colourText;
startRes = seqsel.startRes;
endRes = seqsel.endRes;
- cs = new ResidueShader(seqsel.getColourScheme());
+ cs = seqsel.cs;// new ResidueShader(seqsel.getColourScheme());
if (seqsel.description != null)
{
description = new String(seqsel.description);
*/
package jalview.gui;
+import jalview.analysis.Conservation;
import jalview.datamodel.SequenceGroup;
import jalview.jbgui.GSliderPanel;
import jalview.renderer.ResidueShaderI;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.beans.PropertyVetoException;
+import java.util.List;
import javax.swing.JInternalFrame;
import javax.swing.JLayeredPane;
"label.conservation_colour_increment",
new String[] { source == null ? BACKGROUND : source }));
- if (ap.av.getAlignment().getGroups() != null)
+ List<SequenceGroup> groups = ap.av.getAlignment().getGroups();
+ if (groups != null && !groups.isEmpty())
{
sliderPanel.setAllGroupsCheckEnabled(true);
}
{
ap.av.setThreshold(percent);
}
- updateColourScheme(percent, cs);
+ updateColourScheme(percent, cs, null);
if (allGroupsCheck.isSelected())
{
- for (SequenceGroup sg : ap.av.getAlignment().getGroups())
+ List<SequenceGroup> groups = ap.av.getAlignment().getGroups();
+ for (SequenceGroup sg : groups)
{
- updateColourScheme(percent, sg.getGroupColourScheme());
+ updateColourScheme(percent, sg.getGroupColourScheme(), sg);
}
}
*
* @param percent
* @param scheme
+ * @param sg
*/
- protected void updateColourScheme(int percent, ResidueShaderI scheme)
+ protected void updateColourScheme(int percent, ResidueShaderI scheme,
+ SequenceGroup sg)
{
if (scheme == null)
{
}
if (forConservation)
{
+ if (!scheme.conservationApplied())
+ {
+ /*
+ * first time the colour scheme has had Conservation shading applied
+ * - compute conservation
+ */
+ Conservation c = new Conservation("Group", sg.getSequences(null),
+ sg.getStartRes(), sg.getEndRes());
+ c.calculate();
+ c.verdict(false, ap.av.getConsPercGaps());
+ sg.cs.setConservation(c);
+
+ }
+ scheme.setConservationApplied(true);
scheme.setConservationInc(percent);
}
else
public void setAllGroupsCheckEnabled(boolean b)
{
allGroupsCheck.setEnabled(b);
+ allGroupsCheck.setSelected(ap.av.getColourAppliesToAllGroups());
}
/**
SequenceGroup sg2 = new SequenceGroup(sg);
assertEquals(sg2.getName(), sg.getName());
assertEquals(sg2.getDescription(), sg.getDescription());
- assertNotSame(sg2.getGroupColourScheme(), sg.getGroupColourScheme());
+ assertSame(sg2.getGroupColourScheme(), sg.getGroupColourScheme());
assertSame(sg2.getColourScheme(), sg.getColourScheme());
assertEquals(sg2.getDisplayBoxes(), sg.getDisplayBoxes());
assertEquals(sg2.getDisplayText(), sg.getDisplayText());