X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationPanel.java;h=a10d58bf64e3232530f7cb9b09ebbd1944a74953;hb=c77ccc33971183dba9cb66b40886a6b61fe8eaa0;hp=0213565b98f22ce005d8521630e0a8ada21f9621;hpb=6cbc1c23947d6812cf5efa36998f237f60f4cc74;p=jalview.git diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index 0213565..a10d58b 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -24,8 +24,6 @@ import java.awt.*; import java.awt.event.*; import java.awt.image.*; -import java.util.*; - import javax.swing.*; @@ -608,8 +606,8 @@ public class AnnotationPanel extends JPanel implements MouseListener, int x = 0; int y = 0; - char[] lastSS = new char[aa.length]; - int[] lastSSX = new int[aa.length]; + char lastSS; + int lastSSX; int iconOffset = av.charHeight / 2; boolean validRes = false; @@ -626,6 +624,8 @@ public class AnnotationPanel extends JPanel implements MouseListener, continue; } + lastSS = ' '; + lastSSX = 0; if (row.graph>0) @@ -653,14 +653,13 @@ public class AnnotationPanel extends JPanel implements MouseListener, int column = startRes; int yPos = startRes; - int aaMax = row.annotations.length-1; while (yPos < endRes) { if (av.hasHiddenColumns) { column = av.getColumnSelection().adjustForHiddenColumns(yPos); - if (column > aaMax) + if (column > row.annotations.length-1) { break; } @@ -713,9 +712,10 @@ 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 != row.annotations[column - - 1].displayCharacter))) + else if (((row.annotations[column - 1] == null) + || + (!row.annotations[column].displayCharacter.equals( + row.annotations[column - 1].displayCharacter)))) { g.drawString(row.annotations[column].displayCharacter, x+charOffset, y + iconOffset + 3); @@ -725,21 +725,21 @@ public class AnnotationPanel extends JPanel implements MouseListener, if (row.hasIcons) { if (!validRes || - (row.annotations[column].secondaryStructure != lastSS[i])) + (row.annotations[column].secondaryStructure != lastSS)) { - switch (lastSS[i]) + switch (lastSS) { case 'H': g.setColor(HELIX_COLOUR); - g.fillRoundRect(lastSSX[i], y + 4 + iconOffset, - x - lastSSX[i], 7, 8, 8); + g.fillRoundRect(lastSSX, y + 4 + iconOffset, + x - lastSSX, 7, 8, 8); break; case 'E': g.setColor(SHEET_COLOUR); - g.fillRect(lastSSX[i], y + 4 + iconOffset, - x - lastSSX[i] - 4, 7); + g.fillRect(lastSSX, y + 4 + iconOffset, + x - lastSSX - 4, 7); g.fillPolygon(new int[] { x - 4, x - 4, x }, new int[] { @@ -752,22 +752,22 @@ public class AnnotationPanel extends JPanel implements MouseListener, default: g.setColor(Color.gray); - g.fillRect(lastSSX[i], y + 6 + iconOffset, - x - lastSSX[i], 2); + g.fillRect(lastSSX, y + 6 + iconOffset, + x - lastSSX, 2); break; } if (validRes) { - lastSS[i] = row.annotations[column].secondaryStructure; + lastSS = row.annotations[column].secondaryStructure; } else { - lastSS[i] = ' '; + lastSS = ' '; } - lastSSX[i] = x; + lastSSX = x; } } @@ -778,12 +778,12 @@ public class AnnotationPanel extends JPanel implements MouseListener, if (row.hasIcons) { - switch (lastSS[i]) + switch (lastSS) { case 'H': g.setColor(HELIX_COLOUR); - g.fillRoundRect(lastSSX[i], y + 4 + iconOffset, - x - lastSSX[i], 7, 8, 8); + g.fillRoundRect(lastSSX, y + 4 + iconOffset, + x - lastSSX, 7, 8, 8); break; @@ -793,8 +793,8 @@ public class AnnotationPanel extends JPanel implements MouseListener, if (row.annotations[endRes] !=null && row.annotations[endRes].secondaryStructure != 'E') { - g.fillRect(lastSSX[i], y + 4 + iconOffset, - x - lastSSX[i] - 4, 7); + g.fillRect(lastSSX, y + 4 + iconOffset, + x - lastSSX - 4, 7); g.fillPolygon(new int[] {x - 4, x - 4, x}, new int[] @@ -804,17 +804,15 @@ public class AnnotationPanel extends JPanel implements MouseListener, }, 3); } else - g.fillRect(lastSSX[i], y + 4 + iconOffset, - x - lastSSX[i], 7); + g.fillRect(lastSSX, y + 4 + iconOffset, + x - lastSSX, 7); break; - case 'C': - break; default: g.setColor(Color.gray); - g.fillRect(lastSSX[i], y + 6 + iconOffset, x - lastSSX[i], 2); + g.fillRect(lastSSX, y + 6 + iconOffset, x - lastSSX, 2); break; } @@ -883,6 +881,8 @@ public class AnnotationPanel extends JPanel implements MouseListener, if(sRes>aa.annotations.length) return; + eRes = Math.min(eRes, aa.annotations.length); + int x = 0; //Adjustment for fastpaint to left @@ -916,7 +916,7 @@ public class AnnotationPanel extends JPanel implements MouseListener, new float[] { 5f, 3f }, 0f)); y2 = (int)(y - ((aa.threshold.value-min) / range)*graphHeight); - g.drawLine(x-av.charWidth,y2,(eRes-sRes+1)*av.charWidth,y2); + g.drawLine(x-av.charWidth,y2,(eRes-sRes)*av.charWidth,y2); g2.setStroke(new BasicStroke()); } @@ -963,6 +963,8 @@ public class AnnotationPanel extends JPanel implements MouseListener, if(sRes>aa.annotations.length) return; + eRes = Math.min(eRes, aa.annotations.length); + int x=0, y1, y2; float range = max - min; @@ -977,7 +979,7 @@ public class AnnotationPanel extends JPanel implements MouseListener, new float[] { 5f, 3f }, 0f)); y2 = (int)(y - ((aa.threshold.value-min) / range)*aa.graphHeight); - g.drawLine(x-av.charWidth,y2,(eRes-sRes+1)*av.charWidth,y2); + g.drawLine(x-av.charWidth,y2,(eRes-sRes)*av.charWidth,y2); g2.setStroke(new BasicStroke()); } @@ -988,7 +990,7 @@ public class AnnotationPanel extends JPanel implements MouseListener, g.setColor(Color.gray); - g.drawLine(x,y2,(eRes-sRes+1)*av.charWidth,y2); + g.drawLine(x,y2,(eRes-sRes)*av.charWidth,y2); int column = sRes;