X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationPanel.java;h=817308503d505ae156bf67c8e4a223a5fbac1341;hb=ef36c8bbd6c5eef95e4d1a2cff57ea772af5110b;hp=bf1372eeac184092917e29aef24eab281de64ff4;hpb=efbf36f3efcd7a971a6ca33d098f54b204f2cae9;p=jalview.git diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index bf1372e..8173085 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -671,8 +671,8 @@ public class AnnotationPanel extends JPanel implements MouseListener, AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); - int x = 0; - int y = 0; + int x = 0, y = 0; + int column=0; char lastSS; int lastSSX; int iconOffset = av.charHeight / 2; @@ -694,7 +694,6 @@ public class AnnotationPanel extends JPanel implements MouseListener, lastSS = ' '; lastSSX = 0; - if (row.graph>0) { if(row.graphGroup>-1 && graphGroupDrawn[ row.graphGroup ] ) @@ -718,18 +717,20 @@ public class AnnotationPanel extends JPanel implements MouseListener, iconOffset = 0; } - int column = startRes; - - while (column < endRes) + x = 0; + while (x < endRes-startRes) { if (av.hasHiddenColumns) { - column = av.getColumnSelection().adjustForHiddenColumns(column); + column = av.getColumnSelection().adjustForHiddenColumns(startRes+x); if (column > row.annotations.length-1) { break; } } + else + column = startRes+x; + if ((row.annotations.length <= column) || (row.annotations[column] == null)) @@ -741,7 +742,6 @@ public class AnnotationPanel extends JPanel implements MouseListener, validRes = true; } - x = (column - startRes) * av.charWidth; if (activeRow == i) { @@ -755,8 +755,8 @@ public class AnnotationPanel extends JPanel implements MouseListener, if (v == column) { - g.fillRect((column - startRes) * av.charWidth, y, - av.charWidth, row.height); + g.fillRect(x * av.charWidth, y, + av.charWidth, av.charHeight); } } } @@ -773,7 +773,8 @@ public class AnnotationPanel extends JPanel implements MouseListener, if (column == 0 || row.graph>0) { - g.drawString(row.annotations[column].displayCharacter, x+charOffset, + g.drawString(row.annotations[column].displayCharacter, + x*av.charWidth+charOffset, y + iconOffset + 3); } else if ( @@ -784,8 +785,9 @@ public class AnnotationPanel extends JPanel implements MouseListener, (row.annotations[column].displayCharacter.length() <2 && row.annotations[column].secondaryStructure==' '))) { - g.drawString(row.annotations[column].displayCharacter, x+charOffset, - y + iconOffset + 3); + g.drawString(row.annotations[column].displayCharacter, + x*av.charWidth+charOffset, + y + iconOffset + 3); } } @@ -803,13 +805,13 @@ public class AnnotationPanel extends JPanel implements MouseListener, //Off by 1 offset when drawing rects and ovals //to offscreen image on the MAC g.fillRoundRect(lastSSX, y + 4 + iconOffset, - x - lastSSX, 7, 8, 8); + x*av.charWidth - lastSSX, 7, 8, 8); break; } int sCol = (lastSSX / av.charWidth) + startRes; int x1 = lastSSX; - int x2 = x; + int x2 = x*av.charWidth; if(sCol==0 || row.annotations[sCol-1]==null || @@ -822,7 +824,10 @@ public class AnnotationPanel extends JPanel implements MouseListener, if(row.annotations[column]==null || row.annotations[column].secondaryStructure!='H') { - g.fillArc(x-av.charWidth, y+4+iconOffset, av.charWidth, 7, 270,180); + g.fillArc(x*av.charWidth-av.charWidth, + y+4+iconOffset, + av.charWidth, + 7, 270,180); x2 -= av.charWidth/2; } @@ -832,8 +837,10 @@ public class AnnotationPanel extends JPanel implements MouseListener, case 'E': g.setColor(SHEET_COLOUR); g.fillRect(lastSSX, y + 4 + iconOffset, - x - lastSSX - 4, 7); - g.fillPolygon(new int[] { x - 5, x - 5, x }, + x*av.charWidth - lastSSX - 4, 7); + g.fillPolygon(new int[] { x*av.charWidth - 5, + x*av.charWidth - 5, + x*av.charWidth }, new int[] { y + iconOffset, y + 14 + iconOffset, @@ -846,7 +853,7 @@ public class AnnotationPanel extends JPanel implements MouseListener, default: g.setColor(Color.gray); g.fillRect(lastSSX, y + 6 + iconOffset, - x - lastSSX, 2); + x*av.charWidth - lastSSX, 2); break; } @@ -860,17 +867,17 @@ public class AnnotationPanel extends JPanel implements MouseListener, lastSS = ' '; } - lastSSX = x; + lastSSX = x*av.charWidth; } } - column++; + x++; } if(column>=row.annotations.length) column = row.annotations.length-1; - x += av.charWidth; + x ++; if (row.hasIcons) { @@ -883,7 +890,7 @@ public class AnnotationPanel extends JPanel implements MouseListener, //Off by 1 offset when drawing rects and ovals //to offscreen image on the MAC g.fillRoundRect(lastSSX, y + 4 + iconOffset, - x - lastSSX, 7, 8, 8); + x*av.charWidth - lastSSX, 7, 8, 8); break; } @@ -918,9 +925,11 @@ public class AnnotationPanel extends JPanel implements MouseListener, || row.annotations[endRes].secondaryStructure != 'E') { g.fillRect(lastSSX, y + 4 + iconOffset, - x - lastSSX - 4, 7); + x*av.charWidth - lastSSX - 4, 7); g.fillPolygon(new int[] - {x - 5, x - 5, x}, + {x*av.charWidth - 5, + x*av.charWidth - 5, + x*av.charWidth}, new int[] { y + iconOffset, y + 14 + iconOffset, @@ -929,7 +938,7 @@ public class AnnotationPanel extends JPanel implements MouseListener, } else g.fillRect(lastSSX, y + 4 + iconOffset, - x - lastSSX, 7); + x*av.charWidth - lastSSX, 7); break; @@ -937,7 +946,8 @@ public class AnnotationPanel extends JPanel implements MouseListener, default: g.setColor(Color.gray); if(!av.wrapAlignment || endRes==av.endRes) - g.fillRect(lastSSX, y + 6 + iconOffset, x - lastSSX, 2); + g.fillRect(lastSSX, y + 6 + iconOffset, + x*av.charWidth - lastSSX, 2); break; } @@ -1017,8 +1027,7 @@ public class AnnotationPanel extends JPanel implements MouseListener, if(sRes==0) { - sRes++; - x+=av.charWidth; + x++; } int y1=y, y2=y; @@ -1033,24 +1042,25 @@ public class AnnotationPanel extends JPanel implements MouseListener, eRes = Math.min(eRes, aa.annotations.length); - int column = sRes; + int column; int aaMax = aa.annotations.length-1; - while( column < eRes ) + while( x < eRes - sRes ) { + column = sRes + x; if(av.hasHiddenColumns) { column = av.getColumnSelection().adjustForHiddenColumns(column); - if(column > aaMax) - { - break; - } + } + + if (column > aaMax) + { + break; } if(aa.annotations[column]==null || aa.annotations[column-1]==null) { - x+=av.charWidth; - column ++; + x++; continue; } @@ -1059,12 +1069,10 @@ public class AnnotationPanel extends JPanel implements MouseListener, y1 = y - (int) (((aa.annotations[column-1].value-min) / range) * graphHeight); y2 = y - (int) (((aa.annotations[column].value-min) / range) * graphHeight); - g.drawLine(x-av.charWidth/2, y1, x+av.charWidth/2, y2); - x += av.charWidth; - - column++; - + g.drawLine(x*av.charWidth-av.charWidth/2, y1, x*av.charWidth+av.charWidth/2, y2); + x ++; } + if(aa.threshold!=null) { g.setColor(aa.threshold.colour); @@ -1090,12 +1098,10 @@ public class AnnotationPanel extends JPanel implements MouseListener, eRes = Math.min(eRes, aa.annotations.length); - int x=0, y1, y2; + int x=0, y1=y, y2=y; float range = max - min; - y1 = y2 = y; - if(min<0) y2 = y - (int)((0-min / (range))*aa.graphHeight); @@ -1103,25 +1109,25 @@ public class AnnotationPanel extends JPanel implements MouseListener, g.drawLine(x,y2,(eRes-sRes)*av.charWidth,y2); - - int column = sRes; + int column; int aaMax = aa.annotations.length-1; - while( column < eRes ) + while( x < eRes-sRes ) { + column = sRes + x; if(av.hasHiddenColumns) { column = av.getColumnSelection().adjustForHiddenColumns(column); - if(column > aaMax) - { + } + + if(column > aaMax) + { break; - } } if (aa.annotations[column] == null) { - x += av.charWidth; - column ++; + x ++; continue; } @@ -1129,12 +1135,11 @@ public class AnnotationPanel extends JPanel implements MouseListener, y1 = y - (int) (((aa.annotations[column].value-min) / (range)) * aa.graphHeight); if(y1-y2>0) - g.fillRect(x, y2, av.charWidth, y1-y2 ); + g.fillRect(x*av.charWidth, y2, av.charWidth, y1-y2 ); else - g.fillRect(x, y1, av.charWidth, y2-y1 ); + g.fillRect(x*av.charWidth, y1, av.charWidth, y2-y1 ); - x += av.charWidth; - column ++; + x ++ ; } if(aa.threshold!=null) @@ -1155,6 +1160,7 @@ public class AnnotationPanel extends JPanel implements MouseListener, // used by overview window public void drawGraph(Graphics g, AlignmentAnnotation aa, int width, int y, int sRes, int eRes) { + eRes = Math.min(eRes, aa.annotations.length); g.setColor(Color.white); g.fillRect(0, 0, width, y); g.setColor(new Color(0, 0, 180));