From 7f964795c092e1bf4fbee18904b3d3dc1c29ddf8 Mon Sep 17 00:00:00 2001 From: kjvdh Date: Mon, 2 Oct 2017 09:14:44 +0100 Subject: [PATCH] Added check for negative start columns --- src/jalview/datamodel/SequenceGroup.java | 29 ++++++++++++++++++++++-- test/jalview/gui/ValidColumnSelectionTest.java | 21 +++++++++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 test/jalview/gui/ValidColumnSelectionTest.java diff --git a/src/jalview/datamodel/SequenceGroup.java b/src/jalview/datamodel/SequenceGroup.java index e2f15e1..20b23a9 100755 --- a/src/jalview/datamodel/SequenceGroup.java +++ b/src/jalview/datamodel/SequenceGroup.java @@ -184,7 +184,19 @@ public class SequenceGroup implements AnnotatedCollectionI this.displayText = displayText; this.colourText = colourText; this.cs = new ResidueShader(scheme); - startRes = start; + + if (start > 0) // sanity check for negative start column positions + { + startRes = start; + } + else + { + jalview.bin.Cache.log.warn( + "Negative start column index detected, resetting to default index: " + + startRes); + // start = startRes; + } + endRes = end; recalcConservation(); } @@ -208,7 +220,20 @@ public class SequenceGroup implements AnnotatedCollectionI displayBoxes = seqsel.displayBoxes; displayText = seqsel.displayText; colourText = seqsel.colourText; - startRes = seqsel.startRes; + + if (seqsel.startRes > 0) // sanity check for negative start column + // positions + { + startRes = seqsel.startRes; + } + else + { + jalview.bin.Cache.log.warn( + "Negative start column index detected, resetting to default index: " + + startRes); + // seqsel.startRes = startRes; + } + endRes = seqsel.endRes; cs = new ResidueShader((ResidueShader) seqsel.cs); if (seqsel.description != null) diff --git a/test/jalview/gui/ValidColumnSelectionTest.java b/test/jalview/gui/ValidColumnSelectionTest.java new file mode 100644 index 0000000..81d35f2 --- /dev/null +++ b/test/jalview/gui/ValidColumnSelectionTest.java @@ -0,0 +1,21 @@ +package jalview.gui; + +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class ValidColumnSelectionTest +{ + @BeforeClass(alwaysRun = true) + public void setUpJvOptionPane() + { + JvOptionPane.setInteractiveMode(false); + JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); + } + + @Test(groups = "Functional") + public void testColumnSelection() + { + + } + +} -- 1.7.10.2