X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FAnnotationPanel.java;h=fc7232e33d4995555ad3e192fe5f3f00875dadbc;hb=52fd681e0f239e20df19fd7560d4b999104ba222;hp=1b4a230a526f78d0d50d6dfe7a7d906372bc5fd0;hpb=b27f973bd368619235ff19f706afb28b81c731e7;p=jalview.git diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index 1b4a230..fc7232e 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); @@ -635,6 +641,8 @@ public class AnnotationPanel extends JPanel implements MouseListener, */ public void drawComponent(Graphics g, int startRes, int endRes) { + + g.setFont(av.getFont()); if (fm == null) @@ -644,13 +652,14 @@ public class AnnotationPanel extends JPanel implements MouseListener, g.setColor(Color.white); g.fillRect(0, 0, (endRes - startRes) * av.charWidth, getHeight()); - if ((av.alignment.getAlignmentAnnotation() == null) || + if ( (av.alignment.getAlignmentAnnotation() == null) || (av.alignment.getAlignmentAnnotation().length < 1)) { g.setColor(Color.white); g.fillRect(0, 0, getWidth(), getHeight()); g.setColor(Color.black); - g.drawString("Alignment has no annotations", 20, 15); + if(av.validCharWidth) + g.drawString("Alignment has no annotations", 20, 15); return; } @@ -705,20 +714,17 @@ public class AnnotationPanel extends JPanel implements MouseListener, } int column = startRes; - int yPos = startRes; - while (yPos < endRes) + while (column < endRes) { if (av.hasHiddenColumns) { - column = av.getColumnSelection().adjustForHiddenColumns(yPos); + column = av.getColumnSelection().adjustForHiddenColumns(column); if (column > row.annotations.length-1) { break; } } - else - column = yPos; if ((row.annotations.length <= column) || (row.annotations[column] == null)) @@ -730,7 +736,7 @@ public class AnnotationPanel extends JPanel implements MouseListener, validRes = true; } - x = (yPos - startRes) * av.charWidth; + x = (column - startRes) * av.charWidth; if (activeRow == i) { @@ -751,7 +757,7 @@ public class AnnotationPanel extends JPanel implements MouseListener, } } - if (validRes && + if (av.validCharWidth && validRes && (row.annotations[column].displayCharacter.length() > 0)) { @@ -765,10 +771,13 @@ public class AnnotationPanel extends JPanel implements MouseListener, g.drawString(row.annotations[column].displayCharacter, x+charOffset, y + iconOffset + 3); } - else if (((row.annotations[column - 1] == null) - || - (!row.annotations[column].displayCharacter.equals( - row.annotations[column - 1].displayCharacter)))) + else if ( + row.annotations[column - 1] == null + ||(!row.annotations[column].displayCharacter.equals( + row.annotations[column - 1].displayCharacter) + || + (row.annotations[column].displayCharacter.length() <2 && + row.annotations[column].secondaryStructure==' '))) { g.drawString(row.annotations[column].displayCharacter, x+charOffset, y + iconOffset + 3); @@ -784,20 +793,46 @@ public class AnnotationPanel extends JPanel implements MouseListener, { case 'H': g.setColor(HELIX_COLOUR); - g.fillRoundRect(lastSSX, y + 4 + iconOffset, - x - lastSSX, 7, 8, 8); + if(MAC) + { + //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); + break; + } + + int sCol = (lastSSX / av.charWidth) + startRes; + int x1 = lastSSX; + int x2 = x; + 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) ; + x1 += av.charWidth/2; + } + + if(row.annotations[column]==null || + row.annotations[column].secondaryStructure!='H') + { + g.fillArc(x-av.charWidth, y+4+iconOffset, av.charWidth, 7, 270,180); + x2 -= av.charWidth/2; + } + + g.fillRect(x1, y+4+iconOffset, x2-x1+1, 7); break; case 'E': g.setColor(SHEET_COLOUR); g.fillRect(lastSSX, y + 4 + iconOffset, x - lastSSX - 4, 7); - g.fillPolygon(new int[] { x - 4, x - 4, x }, + g.fillPolygon(new int[] { x - 5, x - 5, x }, new int[] { y + iconOffset, y + 14 + iconOffset, - y + 8 + iconOffset + y + 7 + iconOffset }, 3); break; @@ -824,7 +859,7 @@ public class AnnotationPanel extends JPanel implements MouseListener, } } - yPos++; + column++; } x += av.charWidth; @@ -834,22 +869,50 @@ public class AnnotationPanel extends JPanel implements MouseListener, switch (lastSS) { case 'H': - g.setColor(HELIX_COLOUR); + 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 - lastSSX, 7, 8, 8); + x - lastSSX, 7, 8, 8); + break; + } + + + int sCol = (lastSSX / av.charWidth) + startRes; + int x1 = lastSSX; + int x2 = x; + + 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) ; + x1 += av.charWidth/2; + } + + if(row.annotations[column]==null || + row.annotations[column].secondaryStructure!='H') + { + g.fillArc(x-av.charWidth, y+4+iconOffset, av.charWidth, 7, 270,180); + x2 -= av.charWidth/2; + } + + g.fillRect(x1, y+4+iconOffset, x2-x1+1, 7); break; case 'E': g.setColor(SHEET_COLOUR); - if (row.annotations[endRes] !=null - && row.annotations[endRes].secondaryStructure != 'E') + if (row.annotations[endRes] ==null + || row.annotations[endRes].secondaryStructure != 'E') { g.fillRect(lastSSX, y + 4 + iconOffset, x - lastSSX - 4, 7); g.fillPolygon(new int[] - {x - 4, x - 4, x}, + {x - 5, x - 5, x}, new int[] { y + iconOffset, y + 14 + iconOffset, @@ -865,7 +928,8 @@ public class AnnotationPanel extends JPanel implements MouseListener, default: g.setColor(Color.gray); - g.fillRect(lastSSX, y + 6 + iconOffset, x - lastSSX, 2); + if(!av.wrapAlignment || endRes==av.endRes) + g.fillRect(lastSSX, y + 6 + iconOffset, x - lastSSX, 2); break; } @@ -934,7 +998,6 @@ public class AnnotationPanel extends JPanel implements MouseListener, if(sRes>aa.annotations.length) return; - eRes = Math.min(eRes, aa.annotations.length); int x = 0; @@ -942,6 +1005,8 @@ public class AnnotationPanel extends JPanel implements MouseListener, if(eRes aaMax) { break; } } - else - column = yPos; - - yPos ++; if(aa.annotations[column]==null || aa.annotations[column-1]==null) { x+=av.charWidth; + column ++; continue; } @@ -990,6 +1051,9 @@ public class AnnotationPanel extends JPanel implements MouseListener, 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++; + } if(aa.threshold!=null) { @@ -1031,31 +1095,26 @@ public class AnnotationPanel extends JPanel implements MouseListener, int column = sRes; - int yPos = sRes; int aaMax = aa.annotations.length-1; - while( yPos < eRes ) + while( column < eRes ) { if(av.hasHiddenColumns) { - column = av.getColumnSelection().adjustForHiddenColumns(yPos); + column = av.getColumnSelection().adjustForHiddenColumns(column); if(column > aaMax) { break; } } - else - column = yPos; - - yPos ++; if (aa.annotations[column] == null) { x += av.charWidth; + column ++; continue; } - g.setColor(aa.annotations[column].colour); y1 = y - (int) (((aa.annotations[column].value-min) / (range)) * aa.graphHeight); @@ -1065,6 +1124,8 @@ public class AnnotationPanel extends JPanel implements MouseListener, g.fillRect(x, y1, av.charWidth, y2-y1 ); x += av.charWidth; + column ++; + } if(aa.threshold!=null) {