X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FSequenceRenderer.java;h=a382c604a4937f0d54a03395780236d15c6cb6d0;hb=28d2a0b7dde7f6751d9e063fc2e11da065d284a4;hp=1c7c4ce85c32ad89ab7b32d6d2f562078a88a437;hpb=b2b7e99113e1f0962140fc72d989cc826799a2d4;p=jalview.git diff --git a/src/jalview/appletgui/SequenceRenderer.java b/src/jalview/appletgui/SequenceRenderer.java index 1c7c4ce..a382c60 100755 --- a/src/jalview/appletgui/SequenceRenderer.java +++ b/src/jalview/appletgui/SequenceRenderer.java @@ -20,10 +20,10 @@ */ package jalview.appletgui; -import jalview.api.FeatureRenderer; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; import jalview.renderer.ResidueShaderI; +import jalview.renderer.seqfeatures.FeatureColourFinder; import java.awt.Color; import java.awt.Font; @@ -69,8 +69,7 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer this.renderGaps = renderGaps; } - @Override - public Color getResidueBoxColour(SequenceI seq, int i) + protected Color getResidueBoxColour(SequenceI seq, int i) { allGroups = av.getAlignment().findAllGroups(seq); @@ -83,7 +82,7 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer } else if (av.getShowBoxes()) { - getBoxColour(av.getViewportColourScheme(), seq, i); + getBoxColour(av.getResidueShading(), seq, i); } return resBoxColour; @@ -96,27 +95,27 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer * * @param seq * @param position - * @param fr + * @param finder * @return */ @Override public Color getResidueColour(final SequenceI seq, int position, - FeatureRenderer fr) + FeatureColourFinder finder) { // TODO replace 8 or so code duplications with calls to this method // (refactored as needed) Color col = getResidueBoxColour(seq, position); - if (fr != null) + if (finder != null) { - col = fr.findFeatureColour(col, seq, position); + col = finder.findFeatureColour(col, seq, position); } return col; } void getBoxColour(ResidueShaderI shader, SequenceI seq, int i) { - if (shader != null) + if (shader.getColourScheme() != null) { resBoxColour = shader.findColour(seq.getCharAt(i), i, seq); } @@ -163,8 +162,8 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer int length = seq.getLength(); int curStart = -1; - int curWidth = av.getCharWidth(), avCharWidth = av.getCharWidth(), avCharHeight = av - .getCharHeight(); + int curWidth = av.getCharWidth(), avCharWidth = av.getCharWidth(), + avCharHeight = av.getCharHeight(); Color tempColour = null; while (i <= end) @@ -182,7 +181,7 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer } else if (av.getShowBoxes()) { - getBoxColour(av.getViewportColourScheme(), seq, i); + getBoxColour(av.getResidueShading(), seq, i); } } @@ -272,7 +271,7 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer if (av.getColourText()) { - getBoxColour(av.getViewportColourScheme(), seq, i); + getBoxColour(av.getResidueShading(), seq, i); if (av.getShowBoxes()) { graphics.setColor(resBoxColour.darker()); @@ -310,8 +309,8 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer } charOffset = (avCharWidth - fm.charWidth(s)) / 2; - graphics.drawString(String.valueOf(s), charOffset + avCharWidth - * (i - start), y1); + graphics.drawString(String.valueOf(s), + charOffset + avCharWidth * (i - start), y1); } } @@ -334,21 +333,25 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer // currentSequenceGroup.getConsensus() char conschar = (usesrep) ? (currentGroup == null || position < currentGroup.getStartRes() - || position > currentGroup.getEndRes() ? av.getAlignment() - .getSeqrep().getCharAt(position) - : (currentGroup.getSeqrep() != null ? currentGroup.getSeqrep() - .getCharAt(position) : av.getAlignment().getSeqrep() - .getCharAt(position))) + || position > currentGroup.getEndRes() + ? av.getAlignment().getSeqrep().getCharAt(position) + : (currentGroup.getSeqrep() != null + ? currentGroup.getSeqrep().getCharAt(position) + : av.getAlignment().getSeqrep() + .getCharAt(position))) : (currentGroup != null && currentGroup.getConsensus() != null && position >= currentGroup.getStartRes() - && position <= currentGroup.getEndRes() && currentGroup - .getConsensus().annotations.length > position) ? currentGroup - .getConsensus().annotations[position].displayCharacter - .charAt(0) - : av.getAlignmentConsensusAnnotation().annotations[position].displayCharacter - .charAt(0); + && position <= currentGroup.getEndRes() + && currentGroup + .getConsensus().annotations.length > position) + ? currentGroup + .getConsensus().annotations[position].displayCharacter + .charAt(0) + : av.getAlignmentConsensusAnnotation().annotations[position].displayCharacter + .charAt(0); if (!jalview.util.Comparison.isGap(conschar) - && (sequenceChar == conschar || sequenceChar + CHAR_TO_UPPER == conschar)) + && (sequenceChar == conschar + || sequenceChar + CHAR_TO_UPPER == conschar)) { sequenceChar = conservedChar; } @@ -375,14 +378,15 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer return false; } - public void drawHighlightedText(SequenceI seq, int start, int end, - int x1, int y1) + public void drawHighlightedText(SequenceI seq, int start, int end, int x1, + int y1) { int avCharWidth = av.getCharWidth(), avCharHeight = av.getCharHeight(); int pady = avCharHeight / 5; int charOffset = 0; graphics.setColor(Color.black); - graphics.fillRect(x1, y1, avCharWidth * (end - start + 1), avCharHeight); + graphics.fillRect(x1, y1, avCharWidth * (end - start + 1), + avCharHeight); graphics.setColor(Color.white); char s = '~'; @@ -397,8 +401,9 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer } charOffset = (avCharWidth - fm.charWidth(s)) / 2; - graphics.drawString(String.valueOf(s), charOffset + x1 - + avCharWidth * (i - start), y1 + avCharHeight - pady); + graphics.drawString(String.valueOf(s), + charOffset + x1 + avCharWidth * (i - start), + y1 + avCharHeight - pady); } } }