X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FIdCanvas.java;h=ac82e12a36e8925fd8478c825e4e2bfc3c05cf6d;hb=7bc226b58110fa26d9dbd3f0c78095d06909ffc3;hp=97730191def5251c84a5dac291a872a995deae1a;hpb=55e2e9b22b133db8b9ff0979b0338a33081fc8fd;p=jalview.git diff --git a/src/jalview/appletgui/IdCanvas.java b/src/jalview/appletgui/IdCanvas.java index 9773019..ac82e12 100755 --- a/src/jalview/appletgui/IdCanvas.java +++ b/src/jalview/appletgui/IdCanvas.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -43,7 +43,7 @@ public class IdCanvas { setLayout(null); this.av = av; - PaintRefresher.Register(this, av.alignment); + PaintRefresher.Register(this, av.getSequenceSetId()); } public void drawIdString(Graphics gg, SequenceI s, int i, int starty, @@ -54,31 +54,35 @@ public class IdCanvas if (searchResults != null && searchResults.contains(s)) { gg.setColor(Color.black); - gg.fillRect(0, ((i - starty) * charHeight) + ypos, + gg.fillRect(0, ( (i - starty) * charHeight) + ypos, getSize().width, charHeight); gg.setColor(Color.white); } else if (av.getSelectionGroup() != null && - av.getSelectionGroup().sequences.contains(s)) + av.getSelectionGroup().getSequences(null).contains(s)) { gg.setColor(Color.lightGray); - gg.fillRect(0, ((i - starty) * charHeight) + ypos, + gg.fillRect(0, ( (i - starty) * charHeight) + ypos, getSize().width, charHeight); gg.setColor(Color.white); } else { - gg.setColor(s.getColor()); - gg.fillRect(0, ((i - starty) * charHeight) + ypos, + gg.setColor(av.getSequenceColour(s)); + gg.fillRect(0, ( (i - starty) * charHeight) + ypos, getSize().width, charHeight); gg.setColor(Color.black); } - - gg.drawString( s.getDisplayId(av.getShowJVSuffix()), 0, - ((i - starty) * charHeight) + ypos + + gg.drawString(s.getDisplayId(av.getShowJVSuffix()), 0, + ( (i - starty) * charHeight) + ypos + charHeight - (charHeight / 5)); + if (av.hasHiddenRows && av.showHiddenMarkers) + { + drawMarker(i, starty, ypos); + } + } public void fastPaint(int vertical) @@ -163,23 +167,34 @@ 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(); @@ -188,85 +203,101 @@ public class IdCanvas int hgap = av.charHeight; 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++) + { + if (av.hasHiddenRows) + { + setHiddenFont(i); + } + else + { + gg.setFont(italic); + } + + SequenceI s = av.alignment.getSequenceAt(i); + drawIdString(gg, s, i, 0, ypos); + } + + if (labels != null) { - for (int i = starty; i < av.alignment.getHeight(); i++) - { - SequenceI s = av.alignment.getSequenceAt(i); - drawIdString(gg, s, i, 0, ypos); - } - - if(labels!=null) - { - gg.setFont(av.getFont()); - gg.translate(0, ypos+(av.getAlignment().getHeight() * av.charHeight)); - labels.drawComponent(gg, getSize().width); - gg.translate(0, -ypos-(av.getAlignment().getHeight() * av.charHeight)); - gg.setFont(italic); - } + 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 + SequenceI seq; for (int i = starty; i < endy; i++) { - // Selected sequence colours + if (av.hasHiddenRows) + { + setHiddenFont(i); + } - if (searchResults != null && - searchResults.contains(av.alignment.getSequenceAt(i))) + seq = av.alignment.getSequenceAt(i); + if (seq == null) + { + continue; + } + + // Selected sequence colours + if ( (searchResults != null) && + searchResults.contains(seq)) { - gg.setColor(Color.black); currentColor = Color.black; currentTextColor = Color.white; } - else if (av.getSelectionGroup() != null - && - av.getSelectionGroup().sequences.contains(av.alignment. - getSequenceAt(i))) + else if ( (av.getSelectionGroup() != null) && + av.getSelectionGroup().getSequences(null).contains(seq)) { currentColor = Color.lightGray; currentTextColor = Color.black; } else { - currentColor = av.alignment.getSequenceAt(i).getColor(); + currentColor = av.getSequenceColour(seq); currentTextColor = Color.black; } 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)); - } + gg.drawString(seq.getDisplayId(av.getShowJVSuffix()), + 0, + ( ( (i - starty) * av.charHeight) + av.charHeight) - + (av.charHeight / 5)); - // add a border - gg.setColor(Color.white); - gg.fillRect(getSize().width - 4, 0, 4, getSize().height); + if (av.hasHiddenRows && av.showHiddenMarkers) + { + drawMarker(i, starty, 0); + } + } } - } public void setHighlighted(java.util.Vector found) @@ -274,4 +305,79 @@ public class IdCanvas searchResults = found; repaint(); } + + void drawMarker(int i, int starty, int yoffset) + { + SequenceI[] hseqs = av.alignment.getHiddenSequences().hiddenSequences; + //Use this method here instead of calling hiddenSeq adjust + //3 times. + int hSize = hseqs.length; + + int hiddenIndex = i; + int lastIndex = i - 1; + int nextIndex = i + 1; + + boolean below = (hiddenIndex > lastIndex + 1); + boolean above = (nextIndex > hiddenIndex + 1); + + for (int j = 0; j < hSize; j++) + { + if (hseqs[j] != null) + { + if (j - 1 < hiddenIndex) + { + hiddenIndex++; + } + if (j - 1 < lastIndex) + { + lastIndex++; + } + if (j - 1 < nextIndex) + { + nextIndex++; + } + } + } + + 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()));*/ + } }