From: amwaterhouse Date: Tue, 14 Dec 2004 11:21:26 +0000 (+0000) Subject: Drawing of group and rubberband corrected X-Git-Tag: Release_2_0~836 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=6b9e5c5745220083e275a2d5e1d8c73d0dffe077;p=jalview.git Drawing of group and rubberband corrected --- diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 8fcca78..398aad9 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -208,20 +208,18 @@ public class SeqCanvas extends JPanel SequenceI nextSeq; SequenceGroup group=null; - boolean newGroup=false; + boolean inGroup=false; // are we in a defined group? + boolean inRB=false; //Are we in a rubberband group? int sx=-1, sy=-1, ex=-1, ey=-1; int oldStartX=0,oldEndX=0,oldY=0; + int oldRStartX=0,oldREndX=0,oldRY=0; for (int i = y1 ; i < y2 ;i++) { nextSeq = av.getAlignment().getSequenceAt(i); - if(group==null || group!=av.alignment.findGroup( nextSeq )) - newGroup = true; - else - newGroup = false; - group = av.alignment.findGroup( nextSeq ); + group = av.alignment.findGroup( nextSeq ); - sr.drawSequence(g, nextSeq, group,x1,x2, + sr.drawSequence(g, nextSeq, group,x1,x2, (x1 - startx) * charWidth, offset + AlignmentUtil.getPixelHeight(starty, i, av.getCharHeight()), charWidth,charHeight,null, i); @@ -238,10 +236,10 @@ public class SeqCanvas extends JPanel ey = offset + AlignmentUtil.getPixelHeight(starty, i+1, av.getCharHeight()); - if (newGroup) + if (!inGroup) { - g.drawLine(oldStartX, oldY, oldEndX, oldY); // Horizontal, bottom of old box g.drawLine(sx, sy, ex, sy); // Horizontal, top of new box + inGroup=true; } g.drawLine(sx, sy, sx, ey ); // vertical line, left hand side @@ -254,17 +252,18 @@ public class SeqCanvas extends JPanel oldY = ey; } - else if(sx>-1) + else if(inGroup) { g.setColor(Color.lightGray); - g.drawLine(sx, ey, ex, ey); // Horizontal, bottom of old box + g.drawLine(oldStartX, oldY, oldEndX, oldY); // Horizontal, bottom of old box } + else + inGroup = false; group = av.getRubberbandGroup(); - if( group !=null && group.sequences.contains(nextSeq) ) + if( group != null && group.sequences.contains(nextSeq) ) { - g.setColor(Color.red); - + g.setColor(Color.RED.brighter()); sx = (group.getStartRes() - startx) * charWidth; sy = offset + AlignmentUtil.getPixelHeight(starty, i, av.getCharHeight()); @@ -272,10 +271,11 @@ public class SeqCanvas extends JPanel ey = offset + AlignmentUtil.getPixelHeight(starty, i + 1, av.getCharHeight()); - if (newGroup) + if (!inRB) { - g.drawLine(oldStartX, oldY, oldEndX, oldY); // Horizontal, bottom of old box + g.drawLine(sx, sy, ex, sy); // Horizontal, top of new box + inRB = true; } g.drawLine(sx, sy, sx, ey); // vertical line, left hand side @@ -283,11 +283,18 @@ public class SeqCanvas extends JPanel if (i == y2 - 1) // last line of alignment, seal the box g.drawLine(sx, ey, ex, ey); // Horizontal, bottom of old box - // oldStartX = sx; - // oldEndX = ex; - // oldY = ey; - + oldRStartX = sx; + oldREndX = ex; + oldRY = ey; + } + else if(inRB) + { + g.setColor(Color.RED.brighter()); + g.drawLine(oldRStartX, oldRY, oldREndX, oldRY); // Horizontal, bottom of old box + inRB = false; } + else + inRB = false; }