public ResidueShaderI cs;
// start column (base 0)
- int startRes = 0;
+ private int startRes = 0;
// end column (base 0)
int endRes = 0;
this.displayText = displayText;
this.colourText = colourText;
this.cs = new ResidueShader(scheme);
-
- 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;
- }
-
+ startRes = start;
endRes = end;
recalcConservation();
}
displayText = seqsel.displayText;
colourText = seqsel.colourText;
- 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;
- }
-
+ startRes = seqsel.startRes;
endRes = seqsel.endRes;
cs = new ResidueShader((ResidueShader) seqsel.cs);
if (seqsel.description != null)
*
* @param i
*/
- public void setStartRes(int i)
+ public void setStartRes(int newStart)
{
- int before = startRes;
- startRes = i;
- changeSupport.firePropertyChange(SEQ_GROUP_CHANGED, before, startRes);
+ newStart= Math.max(0,newStart); // sanity check for negative start column positions
+ int before = startRes;
+ startRes = newStart;
+
+ changeSupport.firePropertyChange(SEQ_GROUP_CHANGED, before, startRes);
+
+
+
}
/**
package jalview.gui;
+import static org.testng.Assert.assertTrue;
+
+import jalview.datamodel.Alignment;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceGroup;
+import jalview.datamodel.SequenceI;
+
+import java.awt.event.MouseEvent;
+
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
}
@Test(groups = "Functional")
- public void testColumnSelection()
+ public void testPreventNegativeStartColumn()
{
+ SequenceI seq1 = new Sequence("Seq1", "MATRESS");
+ SequenceI seq2 = new Sequence("Seq2", "MADNESS");
+ AlignmentI al = new Alignment(new SequenceI[] { seq1, seq2 });
+
+ AlignFrame alignFrame = new AlignFrame(al, al.getWidth(),
+ al.getHeight());
+ ScalePanel scalePanel = new ScalePanel(
+ alignFrame.getViewport(), alignFrame.alignPanel
+ );
+
+ MouseEvent mouse = new MouseEvent(
+ scalePanel, 0, 1, 0, 4, 0, 1, false
+ );
+ scalePanel.mousePressed(mouse);
+ scalePanel.mouseDragged(mouse);
+ mouse = new MouseEvent(scalePanel, 0, 1, 0, -30, 0, 1, false);
+ scalePanel.mouseReleased(mouse);
+
+ SequenceGroup sg = scalePanel.av.getSelectionGroup();
+ int startCol = sg.getStartRes();
+
+ assertTrue(startCol >= 0);
+
}