import static org.testng.Assert.assertSame;
import static org.testng.Assert.assertTrue;
+import java.awt.Color;
+import java.util.Iterator;
+
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
import jalview.api.FeatureColourI;
import jalview.bin.Cache;
import jalview.bin.Jalview;
import jalview.schemes.TurnColourScheme;
import jalview.util.MessageManager;
-import java.awt.Color;
-import java.util.Iterator;
-
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
public class AlignFrameTest
{
AlignFrame af;
@AfterMethod(alwaysRun = true)
public void tearDown()
{
- Desktop.instance.closeAll_actionPerformed(null);
+ if (Desktop.instance != null)
+ Desktop.instance.closeAll_actionPerformed(null);
}
/**
- * configure (read-only) properties for test to ensure Consensus is computed for
- * colour Above PID testing
+ * configure (read-only) properties for test to ensure Consensus is computed
+ * for colour Above PID testing
*/
@BeforeMethod(alwaysRun = true)
public void setUp()
/*
* wait for Consensus thread to complete
*/
- synchronized (this)
+ do
{
- while (af.getViewport().getConsensusSeq() == null)
+ try
+ {
+ Thread.sleep(50);
+ } catch (InterruptedException x)
{
- try
- {
- wait(50);
- } catch (InterruptedException e)
- {
- }
}
- }
+ } while (af.getViewport().getCalcManager().isWorking());
}
public static void setUpJvOptionPane()
{
SequenceI seq1 = new Sequence("Seq1", "ABCDEFGHIJ");
SequenceI seq2 = new Sequence("Seq2", "ABCDEFGHIJ");
- seq1.addSequenceFeature(new SequenceFeature("Metal", "", 1, 5, 0f, null));
- seq2.addSequenceFeature(new SequenceFeature("Metal", "", 6, 10, 10f,
- null));
- seq1.addSequenceFeature(new SequenceFeature("Turn", "", 2, 4,
- Float.NaN, null));
- seq2.addSequenceFeature(new SequenceFeature("Turn", "", 7, 9,
- Float.NaN, null));
+ seq1.addSequenceFeature(
+ new SequenceFeature("Metal", "", 1, 5, 0f, null));
+ seq2.addSequenceFeature(
+ new SequenceFeature("Metal", "", 6, 10, 10f, null));
+ seq1.addSequenceFeature(
+ new SequenceFeature("Turn", "", 2, 4, Float.NaN, null));
+ seq2.addSequenceFeature(
+ new SequenceFeature("Turn", "", 7, 9, Float.NaN, null));
AlignmentI al = new Alignment(new SequenceI[] { seq1, seq2 });
AlignFrame alignFrame = new AlignFrame(al, al.getWidth(),
al.getHeight());
assertEquals(alignFrame.getViewport().getAlignment().getHiddenColumns()
.getNumberOfRegions(), 0);
-
/*
* threshold Metal to hide features where score < 5
* seq1 feature in columns 1-5 is hidden
fc.setThreshold(5f);
alignFrame.getFeatureRenderer().setColour("Metal", fc);
assertTrue(alignFrame.hideFeatureColumns("Metal", true));
- HiddenColumns hidden = alignFrame.getViewport().getAlignment().getHiddenColumns();
+ HiddenColumns hidden = alignFrame.getViewport().getAlignment()
+ .getHiddenColumns();
assertEquals(hidden.getNumberOfRegions(), 1);
Iterator<int[]> regions = hidden.iterator();
int[] next = regions.next();
*/
alignFrame.getViewport().showAllHiddenColumns();
assertTrue(alignFrame.hideFeatureColumns("Turn", true));
- regions = alignFrame.getViewport().getAlignment()
- .getHiddenColumns().iterator();
+ regions = alignFrame.getViewport().getAlignment().getHiddenColumns()
+ .iterator();
assertEquals(alignFrame.getViewport().getAlignment().getHiddenColumns()
.getNumberOfRegions(), 2);
next = regions.next();
* <ul>
* <li>with Apply Colour to All Groups not selected, does not change group
* colours</li>
- * <li>with Apply Colour to All Groups selected, does change group colours</li>
+ * <li>with Apply Colour to All Groups selected, does change group
+ * colours</li>
* <li>in neither case, changes alignment or group colour thresholds (PID or
* Conservation)</li>
* </ul>
af.conservationMenuItem_actionPerformed(true);
SliderPanel sp = SliderPanel.getSliderPanel();
assertEquals(sp.getTitle(), MessageManager.formatMessage(
- "label.conservation_colour_increment",
- new String[] { "Background" }));
+ "label.conservation_colour_increment", new String[]
+ { "Background" }));
assertTrue(sp.isForConservation());
sp.valueChanged(20);
assertTrue(av.getResidueShading().conservationApplied());
sp = SliderPanel.getSliderPanel();
assertFalse(sp.isForConservation());
assertEquals(sp.getTitle(), MessageManager.formatMessage(
- "label.percentage_identity_threshold",
- new String[] { "Background" }));
+ "label.percentage_identity_threshold", new String[]
+ { "Background" }));
sp.valueChanged(10);
assertEquals(av.getResidueShading().getThreshold(), 10);
assertTrue(av.getResidueShading().conservationApplied());
*/
PopupMenu popupMenu = new PopupMenu(af.alignPanel, al.getSequenceAt(2),
null);
- popupMenu.changeColour_actionPerformed(JalviewColourScheme.Strand
- .toString());
+ popupMenu.changeColour_actionPerformed(
+ JalviewColourScheme.Strand.toString());
assertTrue(sg.getColourScheme() instanceof StrandColourScheme);
assertEquals(al.getGroups().size(), 1);
assertSame(al.getGroups().get(0), sg);
sp = SliderPanel.getSliderPanel();
assertTrue(sp.isForConservation());
assertEquals(sp.getTitle(), MessageManager.formatMessage(
- "label.conservation_colour_increment",
- new String[] { sg.getName() }));
+ "label.conservation_colour_increment", new String[]
+ { sg.getName() }));
sp.valueChanged(30);
assertTrue(sg.getGroupColourScheme().conservationApplied());
assertEquals(sg.getGroupColourScheme().getConservationInc(), 30);
sp = SliderPanel.getSliderPanel();
assertFalse(sp.isForConservation());
assertEquals(sp.getTitle(), MessageManager.formatMessage(
- "label.percentage_identity_threshold",
- new String[] { sg.getName() }));
+ "label.percentage_identity_threshold", new String[]
+ { sg.getName() }));
sp.valueChanged(40);
assertEquals(sg.getGroupColourScheme().getThreshold(), 40);
// conservation threshold is unchanged:
/*
* inspect the colour of
- * FER_CAPAN.9(I), column 14 (14 base 0)
+ * FER_CAPAN.9(I), column 15 (14 base 0)
* FER_CAPAN.10(SER), column 16 (15 base 0)
*/
SequenceI ferCapan = al.findName("FER_CAPAN");
SliderPanel sp = SliderPanel.getSliderPanel();
assertTrue(sp.isForConservation());
assertEquals(sp.getValue(), 30); // initial slider setting
+ c = rs.findColour('I', 14, ferCapan);
+ Color i_faded = new Color(255, 255, 255);
+ assertEquals(c, i_faded);
sp.valueChanged(10);
assertSame(rs, av.getResidueShading());
+ assertEquals(rs.getConservationInc(), 10);
c = rs.findColour('I', 14, ferCapan);
- Color i_faded = new Color(196, 186, 196);
+ i_faded = new Color(196, 186, 196);
assertEquals(c, i_faded);
c = rs.findColour('S', 15, ferCapan);
Color s_faded = new Color(144, 225, 144);
av.setSelectionGroup(sg);
PopupMenu popupMenu = new PopupMenu(af.alignPanel, al.getSequenceAt(0),
null);
- popupMenu.changeColour_actionPerformed(JalviewColourScheme.Strand
- .toString());
+ popupMenu.changeColour_actionPerformed(
+ JalviewColourScheme.Strand.toString());
assertTrue(sg.getColourScheme() instanceof StrandColourScheme);
assertEquals(al.getGroups().size(), 1);
assertSame(al.getGroups().get(0), sg);
sp = SliderPanel.getSliderPanel();
assertTrue(sp.isForConservation());
assertEquals(sp.getTitle(), MessageManager.formatMessage(
- "label.conservation_colour_increment",
- new String[] { "Background" }));
+ "label.conservation_colour_increment", new String[]
+ { "Background" }));
/*
* make a new View, verify alignment and group colour schemes
sp = SliderPanel.getSliderPanel();
assertTrue(sp.isForConservation());
assertEquals(sp.getTitle(), MessageManager.formatMessage(
- "label.conservation_colour_increment",
- new String[] { "View 1" }));
+ "label.conservation_colour_increment", new String[]
+ { "View 1" }));
sp.valueChanged(22);
assertEquals(av2.getResidueShading().getConservationInc(), 22);
}