X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FIdCanvas.java;h=7b4d4eefa747e400cd312b947ac3f4c671d0b239;hb=ddf3aca722d27da4bd2c58e9f0ab0909ba9639c0;hp=d3b56bea723690c97915ba89278711467ed02302;hpb=b35cf05a104a56835520b166eb8e46d76780834e;p=jalview.git diff --git a/src/jalview/gui/IdCanvas.java b/src/jalview/gui/IdCanvas.java index d3b56be..7b4d4ee 100755 --- a/src/jalview/gui/IdCanvas.java +++ b/src/jalview/gui/IdCanvas.java @@ -43,6 +43,7 @@ public class IdCanvas extends JPanel int imgHeight = 0; boolean fastPaint = false; java.util.Vector searchResults; + FontMetrics fm; /** * Creates a new IdCanvas object. @@ -67,6 +68,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 +89,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.idsAlignRight) + { + 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 +199,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 +221,7 @@ public class IdCanvas extends JPanel av.getFont().getSize()); gg.setFont(italic); + fm = gg.getFontMetrics(); if (av.antiAlias) gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, @@ -279,10 +290,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 +309,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 +334,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.idsAlignRight) + { + xPos = panelWidth - fm.stringWidth(string) - 4; + } - gg.drawString(string, 0, + gg.drawString(string, xPos, (((i - starty) * av.charHeight) + av.charHeight) - (av.charHeight / 5));