X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FIdCanvas.java;h=0f5aad9c53eb121e2dff6390b443c336bc35056a;hb=5cd5b6e7864fe435ceb3f5c2f339a436ea0aac93;hp=f7f1b203b5f237c149edfcad4bb7dc4e677b2693;hpb=2c523e27866fc96105bb3c4b2eea04aa83d59718;p=jalview.git diff --git a/src/jalview/appletgui/IdCanvas.java b/src/jalview/appletgui/IdCanvas.java index f7f1b20..0f5aad9 100755 --- a/src/jalview/appletgui/IdCanvas.java +++ b/src/jalview/appletgui/IdCanvas.java @@ -79,6 +79,9 @@ public class IdCanvas ((i - starty) * charHeight) + ypos + charHeight - (charHeight / 5)); + if (av.hasHiddenRows && av.showHiddenMarkers) + drawMarker(i, starty, ypos); + } public void fastPaint(int vertical) @@ -163,23 +166,32 @@ public class IdCanvas gg.setFont(italic); gg.fillRect(0, 0, getSize().width, getSize().height); - drawIds(av.getStartSeq(), av.endSeq); + drawIds(av.startSeq, av.endSeq); g.drawImage(image, 0, 0, this); } void drawIds(int starty, int endy) { + Font italic = new Font(av.getFont().getName(), Font.ITALIC, + av.getFont().getSize()); + + gg.setFont(italic); + Color currentColor = Color.white; Color currentTextColor = Color.black; - Font italic = new Font(av.getFont().getName(), Font.ITALIC, - av.getFont().getSize()); if (av.getWrapAlignment()) { + int maxwidth = av.alignment.getWidth(); + int alheight = av.alignment.getHeight(); + + if (av.hasHiddenColumns) + maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1; + int annotationHeight = 0; AnnotationLabels labels = null; - if(av.showAnnotation) + if (av.showAnnotation) { AnnotationPanel ap = new AnnotationPanel(av); annotationHeight = ap.adjustPanelHeight(); @@ -190,52 +202,61 @@ public class IdCanvas if (av.scaleAboveWrapped) hgap += av.charHeight; - int cHeight = av.getAlignment().getHeight() * av.charHeight + int cHeight = alheight * av.charHeight + hgap + annotationHeight; - int rowSize = av.getEndRes() - av.getStartRes(); + int rowSize = av.getEndRes() - av.getStartRes(); - // Draw the rest of the panels - for (int ypos = hgap, row = av.startRes; - (ypos <= getSize().height) && (row < av.alignment.getWidth()); - ypos += cHeight, row += rowSize) + // Draw the rest of the panels + for (int ypos = hgap, row = av.startRes; + (ypos <= getSize().height) && (row < maxwidth); + ypos += cHeight, row += rowSize) + { + for (int i = starty; i < alheight; i++) { - for (int i = starty; i < av.alignment.getHeight(); i++) - { - SequenceI s = av.alignment.getSequenceAt(i); - gg.setFont(italic); - drawIdString(gg, s, i, 0, ypos); - } - - if(labels!=null) - { - gg.translate(0, ypos+(av.getAlignment().getHeight() * av.charHeight)); - labels.drawComponent(gg, getSize().width); - gg.translate(0, -ypos-(av.getAlignment().getHeight() * av.charHeight)); - } + if (av.hasHiddenRows) + { + setHiddenFont(i); + } + else + gg.setFont(italic); + + SequenceI s = av.alignment.getSequenceAt(i); + drawIdString(gg, s, i, 0, ypos); } + if (labels != null) + { + gg.translate(0, ypos + (alheight * av.charHeight)); + labels.drawComponent(gg, getSize().width); + gg.translate(0, -ypos - (alheight * av.charHeight)); + } + + } } else { + //Now draw the id strings //Now draw the id strings for (int i = starty; i < endy; i++) { - // Selected sequence colours + if (av.hasHiddenRows) + { + setHiddenFont(i); + } - if (searchResults != null && + // Selected sequence colours + if ( (searchResults != null) && searchResults.contains(av.alignment.getSequenceAt(i))) { - gg.setColor(Color.black); currentColor = Color.black; currentTextColor = Color.white; } - else if (av.getSelectionGroup() != null - && - av.getSelectionGroup().getSequences(false).contains(av.alignment. - getSequenceAt(i))) + else if ( (av.getSelectionGroup() != null) && + av.getSelectionGroup().getSequences(false).contains( + av.alignment.getSequenceAt(i))) { currentColor = Color.lightGray; currentTextColor = Color.black; @@ -248,24 +269,22 @@ public class IdCanvas gg.setColor(currentColor); - gg.fillRect(0, - ((i - starty) * av.charHeight), - getSize().width, + gg.fillRect(0, (i - starty) * av.charHeight, getSize().width, av.charHeight); gg.setColor(currentTextColor); - gg.drawString(av.alignment.getSequenceAt(i) - .getDisplayId(av.getShowJVSuffix()), 0, - ((i - starty) * av.charHeight) + - av.charHeight - (av.charHeight / 5)); - } + String string = av.alignment.getSequenceAt(i).getDisplayId(av. + getShowJVSuffix()); - // add a border - gg.setColor(Color.white); - gg.fillRect(getSize().width - 4, 0, 4, getSize().height); - } + gg.drawString(string, 0, + ( ( (i - starty) * av.charHeight) + av.charHeight) - + (av.charHeight / 5)); + if (av.hasHiddenRows && av.showHiddenMarkers) + drawMarker(i, starty, 0); + } + } } public void setHighlighted(java.util.Vector found) @@ -273,4 +292,54 @@ public class IdCanvas searchResults = found; repaint(); } + + void drawMarker(int i, int starty, int yoffset) + { + int hiddenIndex = av.adjustForHiddenSeqs(i); + int lastIndex = av.adjustForHiddenSeqs(i - 1); + int nextIndex = av.adjustForHiddenSeqs(i + 1); + + boolean below = (hiddenIndex > lastIndex + 1); + boolean above = (nextIndex>hiddenIndex+1); + + gg.setColor(Color.blue); + if(below) + { + gg.fillPolygon(new int[] + {getSize().width- av.charHeight, + getSize().width- av.charHeight, + getSize().width}, + new int[] + { + (i - starty) * av.charHeight +yoffset, + (i - starty) * av.charHeight +yoffset+ av.charHeight / 4, + (i - starty) * av.charHeight+yoffset + }, 3); + } + if(above) + { + gg.fillPolygon(new int[] + {getSize().width- av.charHeight, + getSize().width - av.charHeight, + getSize().width }, + new int[] + { + (i - starty+1) * av.charHeight +yoffset, + (i - starty+1) * av.charHeight +yoffset- av.charHeight / 4, + (i - starty+1) * av.charHeight +yoffset + }, 3); + + } + } + + void setHiddenFont(int i) + { + /* System.out.println(i+" "+av.alignment.getHeight()); + if (av.alignment.getSequenceAt(i).getHiddenSequences() != null) + gg.setFont(new Font(av.getFont().getName(), Font.BOLD, + av.getFont().getSize())); + else + gg.setFont(new Font(av.getFont().getName(), Font.ITALIC, + av.getFont().getSize()));*/ + } }