+ return mf.features.size() - i;
+ }
+ }
+ return 0;
+ }
+
+ /**
+ * Appends the feature at rpos to the given buffer
+ *
+ * @param sb
+ * @param rpos
+ * @param minmax
+ * @param feature
+ */
+ boolean appendFeature(final StringBuilder sb0, int rpos,
+ FeatureRendererModel fr, SequenceFeature feature,
+ MappedFeatures mf, int maxlength)
+ {
+ int begin = feature.getBegin();
+ int end = feature.getEnd();
+
+ /*
+ * if this is a virtual features, convert begin/end to the
+ * coordinates of the sequence it is mapped to
+ */
+ int[] beginRange = null; // feature start in local coordinates
+ int[] endRange = null; // feature end in local coordinates
+ if (mf != null)
+ {
+ if (feature.isContactFeature())
+ {
+ /*
+ * map start and end points individually
+ */
+ beginRange = mf.getMappedPositions(begin, begin);
+ endRange = begin == end ? beginRange
+ : mf.getMappedPositions(end, end);
+ }
+ else
+ {
+ /*
+ * map the feature extent
+ */
+ beginRange = mf.getMappedPositions(begin, end);
+ endRange = beginRange;
+ }
+ if (beginRange == null || endRange == null)
+ {
+ // something went wrong
+ return false;
+ }
+ begin = beginRange[0];
+ end = endRange[endRange.length - 1];
+ }
+
+ StringBuilder sb = new StringBuilder();
+ if (feature.isContactFeature())
+ {
+ /*
+ * include if rpos is at start or end position of [mapped] feature
+ */
+ boolean showContact = (mf == null) && (rpos == begin || rpos == end);
+ boolean showMappedContact = (mf != null) && ((rpos >= beginRange[0]
+ && rpos <= beginRange[beginRange.length - 1])
+ || (rpos >= endRange[0]
+ && rpos <= endRange[endRange.length - 1]));
+ if (showContact || showMappedContact)
+ {
+ if (sb0.length() > 6)