X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FIdCanvas.java;h=d3b56bea723690c97915ba89278711467ed02302;hb=4059c82f431d3f98931b290d9a72da2a54a0fc95;hp=a05c6c0120e280c5862c95c106781f7ec3f95323;hpb=df9b85c1cf39894039018499fe802406cc37f209;p=jalview.git diff --git a/src/jalview/gui/IdCanvas.java b/src/jalview/gui/IdCanvas.java index a05c6c0..d3b56be 100755 --- a/src/jalview/gui/IdCanvas.java +++ b/src/jalview/gui/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) 2006 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 @@ -53,7 +53,7 @@ public class IdCanvas extends JPanel { setLayout(new BorderLayout()); this.av = av; - PaintRefresher.Register(this, av.alignment); + PaintRefresher.Register(this, av.getSequenceSetId()); } /** @@ -65,8 +65,7 @@ public class IdCanvas extends JPanel * @param starty DOCUMENT ME! * @param ypos DOCUMENT ME! */ - public void drawIdString(Graphics2D gg, SequenceI s, int i, int starty, - int ypos) + public void drawIdString(Graphics2D gg, SequenceI s, int i, int starty, int ypos) { int charHeight = av.charHeight; @@ -96,6 +95,11 @@ public class IdCanvas extends JPanel gg.drawString( s.getDisplayId(av.getShowJVSuffix()), 0, (((i - starty + 1) * charHeight) + ypos) - (charHeight / 5)); + + if (av.hasHiddenRows && av.showHiddenMarkers) + drawMarker(i, starty, ypos); + + } /** @@ -169,6 +173,8 @@ public class IdCanvas extends JPanel return; } + int oldHeight = imgHeight; + imgHeight = getHeight(); imgHeight -= (imgHeight % av.charHeight); @@ -177,15 +183,17 @@ public class IdCanvas extends JPanel return; } - image = new BufferedImage(getWidth(), imgHeight, - BufferedImage.TYPE_INT_RGB); - gg = (Graphics2D) image.getGraphics(); + if(oldHeight!=imgHeight || image.getWidth(this)!=getWidth()) + { + image = new BufferedImage(getWidth(), imgHeight, + BufferedImage.TYPE_INT_RGB); + } + gg = (Graphics2D) image.getGraphics(); //Fill in the background gg.setColor(Color.white); gg.fillRect(0, 0, getWidth(), imgHeight); - drawIds(av.getStartSeq(), av.endSeq); g.drawImage(image, 0, 0, this); @@ -249,7 +257,7 @@ public class IdCanvas extends JPanel { if (av.hasHiddenRows) { - setHiddenFont(i, starty); + setHiddenFont(i); } else gg.setFont(italic); @@ -264,16 +272,20 @@ public class IdCanvas extends JPanel labels.drawComponent(gg, getWidth()); 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++) { if (av.hasHiddenRows) { - setHiddenFont(i, starty); + setHiddenFont(i); } // Selected sequence colours @@ -308,34 +320,84 @@ public class IdCanvas extends JPanel gg.drawString(string, 0, (((i - starty) * av.charHeight) + av.charHeight) - (av.charHeight / 5)); + + if(av.hasHiddenRows && av.showHiddenMarkers) + drawMarker(i, starty, 0); + } } } - void setHiddenFont(int i, int starty) + void drawMarker(int i, int starty, int yoffset) { - Font italic = new Font(av.getFont().getName(), Font.ITALIC, - av.getFont().getSize()); - Font bold = new Font(av.getFont().getName(), Font.BOLD, - av.getFont().getSize()); - int tmp, hiddenIndex = starty; - tmp = av.adjustForHiddenSeqs(i); + SequenceI [] hseqs = av.alignment.getHiddenSequences().hiddenSequences; + //Use this method here instead of calling hiddenSeq adjust + //3 times. + int hSize = hseqs.length; - if (av.adjustForHiddenSeqs(i - 1) == tmp - 1) - { - hiddenIndex = tmp; - } + int hiddenIndex = i; + int lastIndex = i - 1; + int nextIndex = i + 1; - if (hiddenIndex != tmp) + for(int j=0; j lastIndex + 1); + boolean above = (nextIndex > hiddenIndex+1); + + + gg.setColor(Color.blue); + if(below) + { + gg.fillPolygon(new int[] + {getWidth()- av.charHeight, + getWidth()- av.charHeight, + getWidth()}, + 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[] + {getWidth()- av.charHeight, + getWidth()- av.charHeight, + getWidth() }, + 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) + { + Font italic = new Font(av.getFont().getName(), Font.ITALIC, + av.getFont().getSize()); + Font bold = new Font(av.getFont().getName(), Font.BOLD, + av.getFont().getSize()); + - if (av.alignment.getSequenceAt(i).getHiddenSequences() != null) + if (av.alignment.getSequenceAt(i)!=null + && av.alignment.getSequenceAt(i).getHiddenSequences() != null) gg.setFont(bold); else gg.setFont(italic);