X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fjalview%2Frenderer%2FScaleRenderer.java;h=c7406a5339638e919a30429de3cfa2dd0f3398e5;hb=60d67f3a980b29fd2039d2c3ad81ee6863f82548;hp=9fec2565ba8eda9533914f2c1b6da3f73e3ee1dd;hpb=d1707d4c26db76cfeb640f0dbeb3e3427fd40eb7;p=jalview.git diff --git a/src/jalview/renderer/ScaleRenderer.java b/src/jalview/renderer/ScaleRenderer.java index 9fec256..c7406a5 100644 --- a/src/jalview/renderer/ScaleRenderer.java +++ b/src/jalview/renderer/ScaleRenderer.java @@ -34,12 +34,24 @@ import java.util.List; */ public class ScaleRenderer { + /** + * Represents one major or minor scale mark + */ public final class ScaleMark { + /** + * true for a major scale mark, false for minor + */ public final boolean major; + /** + * visible column position (0..) e.g. 19 + */ public final int column; + /** + * text (if any) to show e.g. "20" + */ public final String text; ScaleMark(boolean isMajor, int col, String txt) @@ -68,17 +80,23 @@ public class ScaleRenderer int scalestartx = (startx / 10) * 10; SequenceI refSeq = av.getAlignment().getSeqrep(); - int refSp = 0, refStartI = 0, refEndI = -1; + int refSp = 0; + int refStartI = 0; + int refEndI = -1; if (refSeq != null) { - // find bounds and set origin appopriately + // find bounds and set origin appropriately // locate first visible position for this sequence - int[] refbounds = av.getAlignment().getHiddenColumns() - .locateVisibleBoundsOfSequence(refSeq); + refSp = av.getAlignment().getHiddenColumns() + .locateVisibleStartOfSequence(refSeq); + + refStartI = refSeq.findIndex(refSeq.getStart()) - 1; + + int seqlength = refSeq.getLength(); + // get sequence position past the end of the sequence + int pastEndPos = refSeq.findPosition(seqlength + 1); + refEndI = refSeq.findIndex(pastEndPos - 1) - 1; - refSp = refbounds[0]; - refStartI = refbounds[4]; - refEndI = refbounds[5]; scalestartx = refSp + ((scalestartx - refSp) / 10) * 10; } @@ -86,24 +104,24 @@ public class ScaleRenderer { scalestartx += 5; } - List marks = new ArrayList(); + List marks = new ArrayList<>(); String string; int refN, iadj; // todo: add a 'reference origin column' to set column number relative to - for (int i = scalestartx; i < endx; i += 5) + for (int i = scalestartx; i <= endx; i += 5) { if (((i - refSp) % 10) == 0) { if (refSeq == null) { iadj = av.getAlignment().getHiddenColumns() - .adjustForHiddenColumns(i - 1) + 1; + .visibleToAbsoluteColumn(i - 1) + 1; string = String.valueOf(iadj); } else { iadj = av.getAlignment().getHiddenColumns() - .adjustForHiddenColumns(i - 1); + .visibleToAbsoluteColumn(i - 1); refN = refSeq.findPosition(iadj); // TODO show bounds if position is a gap // - ie L--R -> "1L|2R" for