X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Frenderer%2Fseqfeatures%2FFeatureRenderer.java;h=1f47da3421c039c2f9f15950421709927a2004bc;hb=483abbfd34bb2e47698f4cb04e21531c2b11924a;hp=541288eaf1a2297fb61d07421a94e827159e1181;hpb=bba9e58f08fc55c0f789f8354d1444e5c5e1b0e6;p=jalview.git diff --git a/src/jalview/renderer/seqfeatures/FeatureRenderer.java b/src/jalview/renderer/seqfeatures/FeatureRenderer.java index 541288e..1f47da3 100644 --- a/src/jalview/renderer/seqfeatures/FeatureRenderer.java +++ b/src/jalview/renderer/seqfeatures/FeatureRenderer.java @@ -101,8 +101,7 @@ public class FeatureRenderer extends FeatureRendererModel g.setColor(featureColour); - g.fillRect((i - start) * charWidth, y1, charWidth, - charHeight); + g.fillRect((i - start) * charWidth, y1, charWidth, charHeight); if (colourOnly || !validCharWidth) { @@ -111,8 +110,8 @@ public class FeatureRenderer extends FeatureRendererModel g.setColor(Color.white); int charOffset = (charWidth - fm.charWidth(s)) / 2; - g.drawString(String.valueOf(s), charOffset - + (charWidth * (i - start)), pady); + g.drawString(String.valueOf(s), + charOffset + (charWidth * (i - start)), pady); } return true; } @@ -200,8 +199,8 @@ public class FeatureRenderer extends FeatureRendererModel g.setColor(Color.black); int charOffset = (charWidth - fm.charWidth(s)) / 2; - g.drawString(String.valueOf(s), charOffset - + (charWidth * (i - start)), pady); + g.drawString(String.valueOf(s), + charOffset + (charWidth * (i - start)), pady); } return true; } @@ -217,7 +216,8 @@ public class FeatureRenderer extends FeatureRendererModel return null; } - if (Comparison.isGap(seq.getCharAt(column))) + // column is 'base 1' but getCharAt is an array index (ie from 0) + if (Comparison.isGap(seq.getCharAt(column - 1))) { /* * returning null allows the colour scheme to provide gap colour @@ -309,14 +309,39 @@ public class FeatureRenderer extends FeatureRendererModel for (SequenceFeature sf : overlaps) { Color featureColour = fc.getColor(sf); - int visibleStart = Math.max(sf.getBegin(), - visiblePositions.getBegin()); + if (featureColour == null) + { + // score feature outwith threshold for colouring + continue; + } + + /* + * if feature starts/ends outside the visible range, + * restrict to visible positions (or if a contact feature, + * to a single position) + */ + int visibleStart = sf.getBegin(); + if (visibleStart < visiblePositions.getBegin()) + { + visibleStart = sf.isContactFeature() ? sf.getEnd() + : visiblePositions.getBegin(); + } + int visibleEnd = sf.getEnd(); + if (visibleEnd > visiblePositions.getEnd()) + { + visibleEnd = sf.isContactFeature() ? sf.getBegin() + : visiblePositions.getEnd(); + } + int featureStartCol = seq.findIndex(visibleStart); - int visibleEnd = Math.min(sf.getEnd(), visiblePositions.getEnd()); int featureEndCol = sf.begin == sf.end ? featureStartCol : seq .findIndex(visibleEnd); - if (sf.isContactFeature()) + // Color featureColour = getColour(sequenceFeature); + + boolean isContactFeature = sf.isContactFeature(); + + if (isContactFeature) { boolean drawn = renderFeature(g, seq, featureStartCol - 1, featureStartCol - 1, featureColour, start, end, y1, @@ -329,7 +354,7 @@ public class FeatureRenderer extends FeatureRendererModel drawnColour = featureColour; } } - else if (showFeature(sf)) + else { /* * showing feature score by height of colour @@ -391,7 +416,8 @@ public class FeatureRenderer extends FeatureRendererModel * Returns the sequence feature colour rendered at the given column position, * or null if none found. The feature of highest render order (i.e. on top) is * found, subject to both feature type and feature group being visible, and - * its colour returned. + * its colour returned. This method is suitable when no feature transparency + * applied (only the topmost visible feature colour is rendered). *

* Note this method does not check for a gap in the column so would return the * colour for features enclosing a gapped column. Check for gap before calling @@ -413,7 +439,8 @@ public class FeatureRenderer extends FeatureRendererModel * inspect features in reverse renderOrder (the last in the array is * displayed on top) until we find one that is rendered at the position */ - for (int renderIndex = renderOrder.length - 1; renderIndex >= 0; renderIndex--) + for (int renderIndex = renderOrder.length + - 1; renderIndex >= 0; renderIndex--) { String type = renderOrder[renderIndex]; if (!showFeatureOfType(type)) @@ -427,11 +454,15 @@ public class FeatureRenderer extends FeatureRendererModel { if (!featureGroupNotShown(sequenceFeature)) { - return getColour(sequenceFeature); + Color col = getColour(sequenceFeature); + if (col != null) + { + return col; + } } } } - + /* * no displayed feature found at position */