X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FIdCanvas.java;h=c9ed3051c6790c454183b10d6faf8fd5db4dfeb3;hb=3e3378e2ccfea39a2b161600c5a2029716acd1b7;hp=5959493fa0cbe6b739a33b9907378dddd310eabb;hpb=628a29c56cc280f434f3568f3bf79555e1c77726;p=jalview.git diff --git a/src/jalview/gui/IdCanvas.java b/src/jalview/gui/IdCanvas.java index 5959493..c9ed305 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()); } /** @@ -86,7 +86,7 @@ public class IdCanvas extends JPanel } else { - gg.setColor(s.getColor()); + gg.setColor(av.getSequenceColour(s)); gg.fillRect(0, ((i - starty) * charHeight) + ypos, getWidth(), charHeight); gg.setColor(Color.black); @@ -173,6 +173,8 @@ public class IdCanvas extends JPanel return; } + int oldHeight = imgHeight; + imgHeight = getHeight(); imgHeight -= (imgHeight % av.charHeight); @@ -181,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); @@ -276,9 +280,15 @@ public class IdCanvas extends JPanel { //Now draw the id strings + SequenceI sequence; //Now draw the id strings for (int i = starty; i < endy; i++) { + sequence = av.alignment.getSequenceAt(i); + + if(sequence==null) + continue; + if (av.hasHiddenRows) { setHiddenFont(i); @@ -286,21 +296,21 @@ public class IdCanvas extends JPanel // Selected sequence colours if ( (searchResults != null) && - searchResults.contains(av.alignment.getSequenceAt(i))) + searchResults.contains(sequence)) { currentColor = Color.black; currentTextColor = Color.white; } else if ( (av.getSelectionGroup() != null) && av.getSelectionGroup().getSequences(false).contains( - av.alignment.getSequenceAt(i))) + sequence)) { currentColor = Color.lightGray; currentTextColor = Color.black; } else { - currentColor = av.alignment.getSequenceAt(i).getColor(); + currentColor = av.getSequenceColour(sequence); currentTextColor = Color.black; } @@ -311,7 +321,7 @@ public class IdCanvas extends JPanel gg.setColor(currentTextColor); - String string = av.alignment.getSequenceAt(i).getDisplayId( av.getShowJVSuffix()); + String string = sequence.getDisplayId( av.getShowJVSuffix()); gg.drawString(string, 0, (((i - starty) * av.charHeight) + av.charHeight) - @@ -327,12 +337,32 @@ public class IdCanvas extends JPanel 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); + + 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; + + for(int j=0; j lastIndex + 1); - boolean above = (nextIndex>hiddenIndex+1); + boolean above = (nextIndex > hiddenIndex+1); + gg.setColor(Color.blue); if(below) @@ -371,7 +401,9 @@ public class IdCanvas extends JPanel 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);