X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationPanel.java;h=0f025b594eb0150c55448b36b80cbce7d5b6d509;hb=e33cdacd2ac2836504375c538574a0f1cafec7e3;hp=add320903b7251739a7c9f13fa897b8924b872f3;hpb=dd6cfbc651f3c57bbf492737ba790c6479a96b62;p=jalview.git diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index add3209..0f025b5 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -278,13 +278,17 @@ public class AnnotationPanel extends JPanel implements MouseListener, */ public void mousePressed(MouseEvent evt) { - int height = 0; - activeRow = -1; + AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); if(aa==null) return; + + int height = 0; + activeRow = -1; + + for (int i = 0; i < aa.length; i++) { if (aa[i].visible) @@ -309,6 +313,7 @@ public class AnnotationPanel extends JPanel implements MouseListener, } } + if (SwingUtilities.isRightMouseButton(evt)) { if (av.getColumnSelection() == null) @@ -641,8 +646,6 @@ public class AnnotationPanel extends JPanel implements MouseListener, */ public void drawComponent(Graphics g, int startRes, int endRes) { - - g.setFont(av.getFont()); if (fm == null) @@ -666,8 +669,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; @@ -689,7 +692,6 @@ public class AnnotationPanel extends JPanel implements MouseListener, lastSS = ' '; lastSSX = 0; - if (row.graph>0) { if(row.graphGroup>-1 && graphGroupDrawn[ row.graphGroup ] ) @@ -713,18 +715,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)) @@ -736,7 +740,6 @@ public class AnnotationPanel extends JPanel implements MouseListener, validRes = true; } - x = (column - startRes) * av.charWidth; if (activeRow == i) { @@ -750,8 +753,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); } } } @@ -768,7 +771,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 ( @@ -779,8 +783,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); } } @@ -798,13 +803,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 || @@ -817,7 +822,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; } @@ -827,8 +835,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, @@ -841,7 +851,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; } @@ -855,14 +865,17 @@ public class AnnotationPanel extends JPanel implements MouseListener, lastSS = ' '; } - lastSSX = x; + lastSSX = x*av.charWidth; } } - column++; + x++; } - x += av.charWidth; + if(column>=row.annotations.length) + column = row.annotations.length-1; + + x ++; if (row.hasIcons) { @@ -875,7 +888,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; } @@ -910,9 +923,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, @@ -921,7 +936,7 @@ public class AnnotationPanel extends JPanel implements MouseListener, } else g.fillRect(lastSSX, y + 4 + iconOffset, - x - lastSSX, 7); + x*av.charWidth - lastSSX, 7); break; @@ -929,7 +944,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; } @@ -1009,8 +1025,7 @@ public class AnnotationPanel extends JPanel implements MouseListener, if(sRes==0) { - sRes++; - x+=av.charWidth; + x++; } int y1=y, y2=y; @@ -1025,24 +1040,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; } @@ -1050,15 +1066,11 @@ public class AnnotationPanel extends JPanel implements MouseListener, g.setColor(aa.annotations[column].colour); 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; - - if(aa.annotations[column].value==0) - System.out.println(y1+" "+y2); - - 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); @@ -1084,12 +1096,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); @@ -1097,25 +1107,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; } @@ -1123,12 +1133,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) @@ -1149,6 +1158,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));