X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FIdCanvas.java;h=b2a5ede4432814a78eb35cc665fddb58ab85c9be;hb=0fc704a18faa7d11b6d02876bb6c1e8bc19f343c;hp=1f91e26be49b5af5c4143b30e1c647b0c812abf1;hpb=f3bc67915e61855d87866b4a614fe7a953813408;p=jalview.git diff --git a/src/jalview/gui/IdCanvas.java b/src/jalview/gui/IdCanvas.java index 1f91e26..b2a5ede 100755 --- a/src/jalview/gui/IdCanvas.java +++ b/src/jalview/gui/IdCanvas.java @@ -43,6 +43,9 @@ public class IdCanvas extends JPanel int imgHeight = 0; boolean fastPaint = false; java.util.Vector searchResults; + FontMetrics fm; + AnnotationLabels labels = null; + AnnotationPanel ap; /** * Creates a new IdCanvas object. @@ -67,6 +70,8 @@ public class IdCanvas extends JPanel */ public void drawIdString(Graphics2D gg, SequenceI s, int i, int starty, int ypos) { + int xPos = 0; + int panelWidth = getWidth(); int charHeight = av.charHeight; if ((searchResults != null) && searchResults.contains(s)) @@ -86,15 +91,21 @@ 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); } + if (av.rightAlignIds) + { + xPos = panelWidth - fm.stringWidth( + s.getDisplayId(av.getShowJVSuffix()) + ) - 4; + } gg.drawString( s.getDisplayId(av.getShowJVSuffix()), - 0, (((i - starty + 1) * charHeight) + ypos) - (charHeight / 5)); + xPos, (((i - starty + 1) * charHeight) + ypos) - (charHeight / 5)); if (av.hasHiddenRows && av.showHiddenMarkers) drawMarker(i, starty, ypos); @@ -190,6 +201,7 @@ public class IdCanvas extends JPanel } gg = (Graphics2D) image.getGraphics(); + //Fill in the background gg.setColor(Color.white); gg.fillRect(0, 0, getWidth(), imgHeight); @@ -211,6 +223,7 @@ public class IdCanvas extends JPanel av.getFont().getSize()); gg.setFont(italic); + fm = gg.getFontMetrics(); if (av.antiAlias) gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, @@ -228,13 +241,16 @@ public class IdCanvas extends JPanel maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1; int annotationHeight = 0; - AnnotationLabels labels = null; + if(av.showAnnotation) { - AnnotationPanel ap = new AnnotationPanel(av); + if (ap == null) + ap = new AnnotationPanel(av); + annotationHeight = ap.adjustPanelHeight(); - labels = new AnnotationLabels(av); + if (labels == null) + labels = new AnnotationLabels(av); } int hgap = av.charHeight; @@ -279,10 +295,18 @@ public class IdCanvas extends JPanel else { //Now draw the id strings + int panelWidth = getWidth(); + int xPos = 0; + 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); @@ -290,21 +314,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; } @@ -315,9 +339,15 @@ public class IdCanvas extends JPanel gg.setColor(currentTextColor); - String string = av.alignment.getSequenceAt(i).getDisplayId( av.getShowJVSuffix()); + String string = sequence.getDisplayId( av.getShowJVSuffix()); + + + if(av.rightAlignIds) + { + xPos = panelWidth - fm.stringWidth(string) - 4; + } - gg.drawString(string, 0, + gg.drawString(string, xPos, (((i - starty) * av.charHeight) + av.charHeight) - (av.charHeight / 5)); @@ -331,12 +361,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) @@ -375,7 +425,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);