X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FSequenceRenderer.java;h=8d7755cf2d96da99f89c053de76d0233ee334653;hb=d587f1aa61946dc14f6f089cf1dc2a3116cfb773;hp=ec93abf246f244f59897e1ba794ce5c91b17450e;hpb=27b78e7d308dd52df87135dd815740ad1a64b1ab;p=jalview.git diff --git a/src/jalview/gui/SequenceRenderer.java b/src/jalview/gui/SequenceRenderer.java index ec93abf..8d7755c 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); } /** @@ -219,10 +227,14 @@ public class SequenceRenderer if(end+1>=seq.getLength()) end = seq.getLength()-1; - graphics.setColor(Color.black); + graphics.setColor(av.textColour); - if(monospacedFont && av.showText && allGroups.length==0 && !av.getColourText()) + if(monospacedFont + && av.showText + && allGroups.length==0 + && !av.getColourText() + && av.thresholdTextColour==0) { if(av.renderGaps) graphics.drawString(seq.getSequence(start, end + 1), 0, y1); @@ -234,9 +246,11 @@ public class SequenceRenderer } else { + boolean getboxColour = false; for (int i = start; i <= end; i++) { - graphics.setColor(Color.black); + graphics.setColor(av.textColour); + getboxColour = false; s = seq.getCharAt(i); if (!renderGaps && jalview.util.Comparison.isGap(s)) { @@ -250,11 +264,26 @@ public class SequenceRenderer continue; } - if (currentSequenceGroup.getColourText()) + if (currentSequenceGroup.thresholdTextColour > 0 + || currentSequenceGroup.getColourText()) { + getboxColour = true; getBoxColour(currentSequenceGroup.cs, seq, i); - graphics.setColor(resBoxColour.darker()); + + if (currentSequenceGroup.getColourText()) + graphics.setColor(resBoxColour.darker()); + + if (currentSequenceGroup.thresholdTextColour > 0) + { + if (resBoxColour.getRed() + + resBoxColour.getBlue() + + resBoxColour.getGreen() < currentSequenceGroup.thresholdTextColour) + graphics.setColor(currentSequenceGroup.textColour2); + } } + else + graphics.setColor(currentSequenceGroup.textColour); + } else { @@ -265,6 +294,7 @@ public class SequenceRenderer if (av.getColourText()) { + getboxColour = true; getBoxColour(av.globalColourScheme, seq, i); if (av.getShowBoxes()) @@ -276,17 +306,28 @@ public class SequenceRenderer graphics.setColor(resBoxColour); } } + + if (av.thresholdTextColour > 0) + { + if (!getboxColour) + getBoxColour(av.globalColourScheme, seq, i); + + if (resBoxColour.getRed() + + resBoxColour.getBlue() + + resBoxColour.getGreen() < av.thresholdTextColour) + graphics.setColor(av.textColour2); + } + } - charOffset = (av.charWidth - fm.charWidth(s)) / 2; - // System.out.print(s); - graphics.drawString(String.valueOf(s), - charOffset + av.charWidth * (i - start), - y1); + + charOffset = (av.charWidth - fm.charWidth(s)) / 2; + graphics.drawString(String.valueOf(s), + charOffset + av.charWidth * (i - start), + y1); } - // System.out.println("\n"); } } @@ -340,17 +381,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); + } } } @@ -360,17 +404,18 @@ public class SequenceRenderer int charOffset = 0; 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); + } } }