| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.renderer; |
| 22 |
|
|
| 23 |
|
import jalview.api.AlignViewportI; |
| 24 |
|
import jalview.datamodel.HiddenColumns; |
| 25 |
|
import jalview.datamodel.SequenceI; |
| 26 |
|
|
| 27 |
|
import java.util.ArrayList; |
| 28 |
|
import java.util.Iterator; |
| 29 |
|
import java.util.List; |
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
@author |
| 35 |
|
|
| 36 |
|
|
| |
|
| 0% |
Uncovered Elements: 50 (50) |
Complexity: 9 |
Complexity Density: 0.26 |
|
| 37 |
|
public class ScaleRenderer |
| 38 |
|
{ |
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 42 |
|
public final class ScaleMark |
| 43 |
|
{ |
| 44 |
|
|
| 45 |
|
|
| 46 |
|
|
| 47 |
|
public final boolean major; |
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 51 |
|
|
| 52 |
|
public final int column; |
| 53 |
|
|
| 54 |
|
|
| 55 |
|
|
| 56 |
|
|
| 57 |
|
public final String text; |
| 58 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 59 |
0 |
ScaleMark(boolean isMajor, int col, String txt)... |
| 60 |
|
{ |
| 61 |
0 |
major = isMajor; |
| 62 |
0 |
column = col; |
| 63 |
0 |
text = txt; |
| 64 |
|
} |
| 65 |
|
} |
| 66 |
|
|
| 67 |
|
|
| 68 |
|
|
| 69 |
|
|
| 70 |
|
@param |
| 71 |
|
@param |
| 72 |
|
|
| 73 |
|
@param |
| 74 |
|
|
| 75 |
|
@return |
| 76 |
|
|
| 77 |
|
|
| 78 |
|
|
| |
|
| 0% |
Uncovered Elements: 49 (49) |
Complexity: 9 |
Complexity Density: 0.26 |
|
| 79 |
0 |
public List<ScaleMark> calculateMarks(AlignViewportI av, int startx,... |
| 80 |
|
int endx) |
| 81 |
|
{ |
| 82 |
0 |
int scalestartx = (startx / 10) * 10; |
| 83 |
|
|
| 84 |
0 |
SequenceI refSeq = av.getAlignment().getSeqrep(); |
| 85 |
0 |
int refSp = 0; |
| 86 |
0 |
int refStartI = 0; |
| 87 |
0 |
int refEndI = -1; |
| 88 |
|
|
| 89 |
0 |
HiddenColumns hc = av.getAlignment().getHiddenColumns(); |
| 90 |
|
|
| 91 |
0 |
if (refSeq != null) |
| 92 |
|
{ |
| 93 |
|
|
| 94 |
|
|
| 95 |
0 |
Iterator<int[]> it = hc.iterator(); |
| 96 |
0 |
int index = refSeq.firstResidueOutsideIterator(it); |
| 97 |
0 |
refSp = hc.absoluteToVisibleColumn(index); |
| 98 |
|
|
| 99 |
0 |
refStartI = refSeq.findIndex(refSeq.getStart()) - 1; |
| 100 |
|
|
| 101 |
0 |
int seqlength = refSeq.getLength(); |
| 102 |
|
|
| 103 |
0 |
int pastEndPos = refSeq.findPosition(seqlength + 1); |
| 104 |
0 |
refEndI = refSeq.findIndex(pastEndPos - 1) - 1; |
| 105 |
|
|
| 106 |
0 |
scalestartx = refSp + ((scalestartx - refSp) / 10) * 10; |
| 107 |
|
} |
| 108 |
|
|
| 109 |
0 |
if (refSeq == null && scalestartx % 10 == 0) |
| 110 |
|
{ |
| 111 |
0 |
scalestartx += 5; |
| 112 |
|
} |
| 113 |
0 |
List<ScaleMark> marks = new ArrayList<>(); |
| 114 |
0 |
String string; |
| 115 |
0 |
int refN, iadj; |
| 116 |
|
|
| 117 |
0 |
for (int i = scalestartx; i <= endx; i += 5) |
| 118 |
|
{ |
| 119 |
0 |
if (((i - refSp) % 10) == 0) |
| 120 |
|
{ |
| 121 |
0 |
if (refSeq == null) |
| 122 |
|
{ |
| 123 |
0 |
iadj = hc.visibleToAbsoluteColumn(i - 1) + 1; |
| 124 |
0 |
string = String.valueOf(iadj); |
| 125 |
|
} |
| 126 |
|
else |
| 127 |
|
{ |
| 128 |
0 |
iadj = hc.visibleToAbsoluteColumn(i - 1); |
| 129 |
0 |
refN = refSeq.findPosition(iadj); |
| 130 |
|
|
| 131 |
|
|
| 132 |
|
|
| 133 |
0 |
if (iadj < refStartI) |
| 134 |
|
{ |
| 135 |
0 |
string = String.valueOf(iadj - refStartI); |
| 136 |
|
} |
| 137 |
0 |
else if (iadj > refEndI) |
| 138 |
|
{ |
| 139 |
0 |
string = "+" + String.valueOf(iadj - refEndI); |
| 140 |
|
} |
| 141 |
|
else |
| 142 |
|
{ |
| 143 |
0 |
string = String.valueOf(refN) + refSeq.getCharAt(iadj); |
| 144 |
|
} |
| 145 |
|
} |
| 146 |
0 |
marks.add(new ScaleMark(true, i - startx - 1, string)); |
| 147 |
|
} |
| 148 |
|
else |
| 149 |
|
{ |
| 150 |
0 |
marks.add(new ScaleMark(false, i - startx - 1, null)); |
| 151 |
|
} |
| 152 |
|
} |
| 153 |
0 |
return marks; |
| 154 |
|
} |
| 155 |
|
|
| 156 |
|
} |