X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationPanel.java;h=0f025b594eb0150c55448b36b80cbce7d5b6d509;hb=e33cdacd2ac2836504375c538574a0f1cafec7e3;hp=f64843a45c158b4b44f8fd6ae0c797276788a02b;hpb=4675978613749be5019b17c34c0a918631502512;p=jalview.git diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index f64843a..0f025b5 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -61,6 +61,8 @@ public class AnnotationPanel extends JPanel implements MouseListener, int max; //used by mouseDragged to see if user boolean mouseDragging = false; + boolean MAC = false; + /** * Creates a new AnnotationPanel object. * @@ -68,6 +70,10 @@ public class AnnotationPanel extends JPanel implements MouseListener, */ public AnnotationPanel(AlignmentPanel ap) { + + if(System.getProperty("os.name").startsWith("Mac")) + MAC = true; + ToolTipManager.sharedInstance().registerComponent(this); ToolTipManager.sharedInstance().setInitialDelay(0); ToolTipManager.sharedInstance().setDismissDelay(10000); @@ -272,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) @@ -303,6 +313,7 @@ public class AnnotationPanel extends JPanel implements MouseListener, } } + if (SwingUtilities.isRightMouseButton(evt)) { if (av.getColumnSelection() == null) @@ -635,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) @@ -660,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; @@ -683,7 +692,6 @@ public class AnnotationPanel extends JPanel implements MouseListener, lastSS = ' '; lastSSX = 0; - if (row.graph>0) { if(row.graphGroup>-1 && graphGroupDrawn[ row.graphGroup ] ) @@ -707,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)) @@ -730,7 +740,6 @@ public class AnnotationPanel extends JPanel implements MouseListener, validRes = true; } - x = (column - startRes) * av.charWidth; if (activeRow == i) { @@ -744,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); } } } @@ -762,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 ( @@ -773,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); } } @@ -787,11 +798,21 @@ public class AnnotationPanel extends JPanel implements MouseListener, { case 'H': g.setColor(HELIX_COLOUR); + if(MAC) + { + //Off by 1 offset when drawing rects and ovals + //to offscreen image on the MAC + g.fillRoundRect(lastSSX, y + 4 + iconOffset, + 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(row.annotations[sCol-1]==null || + if(sCol==0 || + row.annotations[sCol-1]==null || row.annotations[sCol-1].secondaryStructure!='H') { g.fillArc(lastSSX, y+4+iconOffset, av.charWidth+1, 7, 90,180) ; @@ -801,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; } @@ -811,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, @@ -825,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; } @@ -839,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) { @@ -854,12 +883,22 @@ public class AnnotationPanel extends JPanel implements MouseListener, { case 'H': g.setColor(HELIX_COLOUR); + if (MAC) + { + //Off by 1 offset when drawing rects and ovals + //to offscreen image on the MAC + g.fillRoundRect(lastSSX, y + 4 + iconOffset, + x*av.charWidth - lastSSX, 7, 8, 8); + break; + } + int sCol = (lastSSX / av.charWidth) + startRes; int x1 = lastSSX; int x2 = x; - if(row.annotations[sCol-1]==null || + if(sCol==0 || + row.annotations[sCol-1]==null || row.annotations[sCol-1].secondaryStructure!='H') { g.fillArc(lastSSX, y+4+iconOffset, av.charWidth+1, 7, 90,180) ; @@ -884,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, @@ -895,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; @@ -903,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; } @@ -972,7 +1014,6 @@ public class AnnotationPanel extends JPanel implements MouseListener, if(sRes>aa.annotations.length) return; - eRes = Math.min(eRes, aa.annotations.length); int x = 0; @@ -980,10 +1021,11 @@ public class AnnotationPanel extends JPanel implements MouseListener, if(eRes aaMax) - { - break; - } + } + + if (column > aaMax) + { + break; } if(aa.annotations[column]==null || aa.annotations[column-1]==null) { - x+=av.charWidth; - column ++; + x++; continue; } + 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; - - 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); @@ -1053,38 +1096,36 @@ 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 = (int)(y - (0-min / (range))*aa.graphHeight); + y2 = y - (int)((0-min / (range))*aa.graphHeight); g.setColor(Color.gray); 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; } @@ -1092,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) @@ -1118,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));