overlaps = seq.findFeatures(start + 1, end + 1,
+ type);
+ for (SequenceFeature sf : overlaps)
{
- final SequenceFeature sequenceFeature = lastSequenceFeatures[sfindex];
- if (!sequenceFeature.type.equals(type))
- {
- continue;
- }
-
- if (featureGroups != null
- && sequenceFeature.featureGroup != null
- && sequenceFeature.featureGroup.length() != 0
- && featureGroups.containsKey(sequenceFeature.featureGroup)
- && !featureGroups.get(sequenceFeature.featureGroup)
- .booleanValue())
+ /*
+ * a feature type may be flagged as shown but the group
+ * an instance of it belongs to may be hidden
+ */
+ if (featureGroupNotShown(sf))
{
continue;
}
- if (!offscreenRender
- && (sequenceFeature.getBegin() > epos || sequenceFeature
- .getEnd() < spos))
- {
- continue;
- }
+ Color featureColour = getColour(sf);
+ boolean isContactFeature = sf.isContactFeature();
- if (offscreenRender && offscreenImage == null)
+ int featureStartCol = seq.findIndex(sf.begin);
+ int featureEndCol = sf.begin == sf.end ? featureStartCol : seq
+ .findIndex(sf.end);
+ if (isContactFeature)
{
- if (sequenceFeature.begin <= start
- && sequenceFeature.end >= start)
+ boolean drawn = renderFeature(g, seq, featureStartCol - 1,
+ featureStartCol - 1, featureColour, start, end, y1,
+ colourOnly);
+ drawn |= renderFeature(g, seq, featureEndCol - 1,
+ featureEndCol - 1, featureColour, start, end, y1,
+ colourOnly);
+ if (drawn)
{
- // this is passed out to the overview and other sequence renderers
- // (e.g. molecule viewer) to get displayed colour for rendered
- // sequence
- currentColour = new Integer(getColour(sequenceFeature).getRGB());
- // used to be retreived from av.featuresDisplayed
- // currentColour = av.featuresDisplayed
- // .get(sequenceFeatures[sfindex].type);
-
+ drawnColour = featureColour;
}
}
- else if (sequenceFeature.type.equals("disulfide bond"))
- {
- renderFeature(g, seq, seq.findIndex(sequenceFeature.begin) - 1,
- seq.findIndex(sequenceFeature.begin) - 1,
- getColour(sequenceFeature)
- // new Color(((Integer) av.featuresDisplayed
- // .get(sequenceFeatures[sfindex].type)).intValue())
- , start, end, y1);
- renderFeature(g, seq, seq.findIndex(sequenceFeature.end) - 1,
- seq.findIndex(sequenceFeature.end) - 1,
- getColour(sequenceFeature)
- // new Color(((Integer) av.featuresDisplayed
- // .get(sequenceFeatures[sfindex].type)).intValue())
- , start, end, y1);
-
- }
- else if (showFeature(sequenceFeature))
+ else if (showFeature(sf))
{
- if (av_isShowSeqFeatureHeight
- && sequenceFeature.score != Float.NaN)
+ /*
+ * showing feature score by height of colour
+ * is not implemented as a selectable option
+ *
+ if (av.isShowSequenceFeaturesHeight()
+ && !Float.isNaN(sequenceFeature.score))
{
- renderScoreFeature(g, seq,
+ boolean drawn = renderScoreFeature(g, seq,
seq.findIndex(sequenceFeature.begin) - 1,
- seq.findIndex(sequenceFeature.end) - 1,
- getColour(sequenceFeature), start, end, y1,
- normaliseScore(sequenceFeature));
+ seq.findIndex(sequenceFeature.end) - 1, featureColour,
+ start, end, y1, normaliseScore(sequenceFeature),
+ colourOnly);
+ if (drawn)
+ {
+ drawnColour = featureColour;
+ }
}
else
{
- renderFeature(g, seq, seq.findIndex(sequenceFeature.begin) - 1,
- seq.findIndex(sequenceFeature.end) - 1,
- getColour(sequenceFeature), start, end, y1);
- }
+ */
+ boolean drawn = renderFeature(g, seq,
+ featureStartCol - 1,
+ featureEndCol - 1, featureColour,
+ start, end, y1, colourOnly);
+ if (drawn)
+ {
+ drawnColour = featureColour;
+ }
+ /*}*/
}
-
}
-
}
- if (transparency != 1.0f && g != null && transparencyAvailable)
+ if (transparency != 1.0f && g != null)
{
+ /*
+ * reset transparency
+ */
Graphics2D g2 = (Graphics2D) g;
- g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
- 1.0f));
+ g2.setComposite(NO_TRANSPARENCY);
}
- }
- boolean transparencyAvailable = true;
-
- protected void setTransparencyAvailable(boolean isTransparencyAvailable)
- {
- transparencyAvailable = isTransparencyAvailable;
- }
-
- @Override
- public boolean isTransparencyAvailable()
- {
- return transparencyAvailable;
+ return drawnColour;
}
/**
@@ -394,9 +374,60 @@ public class FeatureRenderer extends
* discover and display.
*
*/
+ @Override
public void featuresAdded()
{
- lastSeq = null;
findAllFeatures();
}
+
+ /**
+ * 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.
+ *
+ * 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
+ * if different behaviour is wanted.
+ *
+ * @param seq
+ * @param column
+ * (1..)
+ * @return
+ */
+ Color findFeatureColour(SequenceI seq, int column)
+ {
+ /*
+ * check for new feature added while processing
+ */
+ updateFeatures();
+
+ /*
+ * 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--)
+ {
+ String type = renderOrder[renderIndex];
+ if (!showFeatureOfType(type))
+ {
+ continue;
+ }
+
+ List overlaps = seq.findFeatures(column, column,
+ type);
+ for (SequenceFeature sequenceFeature : overlaps)
+ {
+ if (!featureGroupNotShown(sequenceFeature))
+ {
+ return getColour(sequenceFeature);
+ }
+ }
+ }
+
+ /*
+ * no displayed feature found at position
+ */
+ return null;
+ }
}