X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fjalview%2Fgui%2FSequenceRenderer.java;h=739187bcd53af277812f6ee524abb06452a3fadf;hb=38ae1e61b0cd4fdbf6c9be24cb5f53382a4e6d51;hp=ab6c1aba4ff84585b3dad6aa52c59953edfd57b4;hpb=c77ccc33971183dba9cb66b40886a6b61fe8eaa0;p=jalview.git diff --git a/src/jalview/gui/SequenceRenderer.java b/src/jalview/gui/SequenceRenderer.java index ab6c1ab..739187b 100755 --- a/src/jalview/gui/SequenceRenderer.java +++ b/src/jalview/gui/SequenceRenderer.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 @@ -61,7 +61,14 @@ public class SequenceRenderer { graphics = g; fm = g.getFontMetrics(); - monospacedFont = fm.getStringBounds("M",g).getWidth()==fm.getStringBounds("|",g).getWidth(); + + // If EPS graphics, stringWidth will be a double, not an int + double dwidth = fm.getStringBounds("M", g).getWidth(); + + monospacedFont = + (dwidth == fm.getStringBounds("|",g).getWidth() + && (float)av.charWidth == dwidth); + this.renderGaps = renderGaps; } @@ -129,7 +136,8 @@ public class SequenceRenderer drawBoxes(seq, start, end, y1); - drawText(seq, start, end, y1); + if (av.validCharWidth) + drawText(seq, start, end, y1); } /** @@ -224,7 +232,13 @@ public class SequenceRenderer if(monospacedFont && av.showText && allGroups.length==0 && !av.getColourText()) { + if(av.renderGaps) graphics.drawString(seq.getSequence(start, end + 1), 0, y1); + else + { + char gap = av.getGapCharacter(); + graphics.drawString( seq.getSequence(start, end+1).replace(gap, ' '), 0, y1); + } } else { @@ -334,17 +348,20 @@ public class SequenceRenderer char s = '~'; // Need to find the sequence position here. - for (int i = start; i <= end; i++) + if(av.validCharWidth) { + for (int i = start; i <= end; i++) + { if (i < seq.getLength()) { - s = seq.getSequence().charAt(i); + s = seq.getSequence().charAt(i); } charOffset = (av.charWidth - fm.charWidth(s)) / 2; graphics.drawString(String.valueOf(s), - charOffset + x1 + (av.charWidth * (i - start)), - (y1 + av.charHeight) - pady); + charOffset + x1 + (av.charWidth * (i - start)), + (y1 + av.charHeight) - pady); + } } } @@ -352,19 +369,20 @@ public class SequenceRenderer { int pady = av.charHeight / 5; int charOffset = 0; - graphics.setColor(Color.lightGray); + graphics.setColor(Color.black); graphics.fillRect(x1, y1, av.charWidth, av.charHeight); - graphics.setColor(Color.white); - - graphics.setColor(Color.white); - char s = seq.getCharAt(res); + if(av.validCharWidth) + { + graphics.setColor(Color.white); - charOffset = (av.charWidth - fm.charWidth(s)) / 2; - graphics.drawString(String.valueOf(s), - charOffset + x1, - (y1 + av.charHeight) - pady); + char s = seq.getCharAt(res); + charOffset = (av.charWidth - fm.charWidth(s)) / 2; + graphics.drawString(String.valueOf(s), + charOffset + x1, + (y1 + av.charHeight) - pady); + } } }