| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.viewmodel; |
| 22 |
|
|
| 23 |
|
import jalview.datamodel.AlignmentI; |
| 24 |
|
import jalview.datamodel.HiddenColumns; |
| 25 |
|
|
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| |
|
| 0% |
Uncovered Elements: 302 (302) |
Complexity: 85 |
Complexity Density: 0.47 |
|
| 32 |
|
public class ViewportRanges extends ViewportProperties |
| 33 |
|
{ |
| 34 |
|
public static final String STARTRES = "startres"; |
| 35 |
|
|
| 36 |
|
public static final String ENDRES = "endres"; |
| 37 |
|
|
| 38 |
|
public static final String STARTSEQ = "startseq"; |
| 39 |
|
|
| 40 |
|
public static final String ENDSEQ = "endseq"; |
| 41 |
|
|
| 42 |
|
public static final String STARTRESANDSEQ = "startresandseq"; |
| 43 |
|
|
| 44 |
|
public static final String MOVE_VIEWPORT = "move_viewport"; |
| 45 |
|
|
| 46 |
|
private boolean wrappedMode = false; |
| 47 |
|
|
| 48 |
|
|
| 49 |
|
private int startRes; |
| 50 |
|
|
| 51 |
|
|
| 52 |
|
private int endRes; |
| 53 |
|
|
| 54 |
|
|
| 55 |
|
private int startSeq; |
| 56 |
|
|
| 57 |
|
|
| 58 |
|
private int endSeq; |
| 59 |
|
|
| 60 |
|
|
| 61 |
|
private AlignmentI al; |
| 62 |
|
|
| 63 |
|
|
| 64 |
|
|
| 65 |
|
|
| 66 |
|
@param |
| 67 |
|
|
| 68 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 69 |
0 |
public ViewportRanges(AlignmentI alignment)... |
| 70 |
|
{ |
| 71 |
|
|
| 72 |
0 |
this.startRes = 0; |
| 73 |
0 |
this.endRes = alignment.getWidth() - 1; |
| 74 |
0 |
this.startSeq = 0; |
| 75 |
0 |
this.endSeq = alignment.getHeight() - 1; |
| 76 |
0 |
this.al = alignment; |
| 77 |
|
} |
| 78 |
|
|
| 79 |
|
|
| 80 |
|
|
| 81 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 82 |
0 |
public int getAbsoluteAlignmentWidth()... |
| 83 |
|
{ |
| 84 |
0 |
return al.getWidth(); |
| 85 |
|
} |
| 86 |
|
|
| 87 |
|
|
| 88 |
|
|
| 89 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 90 |
0 |
public int getAbsoluteAlignmentHeight()... |
| 91 |
|
{ |
| 92 |
0 |
return al.getHeight() + al.getHiddenSequences().getSize(); |
| 93 |
|
} |
| 94 |
|
|
| 95 |
|
|
| 96 |
|
|
| 97 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 98 |
0 |
public int getVisibleAlignmentWidth()... |
| 99 |
|
{ |
| 100 |
0 |
return al.getVisibleWidth(); |
| 101 |
|
} |
| 102 |
|
|
| 103 |
|
|
| 104 |
|
|
| 105 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 106 |
0 |
public int getVisibleAlignmentHeight()... |
| 107 |
|
{ |
| 108 |
0 |
return al.getHeight(); |
| 109 |
|
} |
| 110 |
|
|
| 111 |
|
|
| 112 |
|
|
| 113 |
|
|
| 114 |
|
|
| 115 |
|
@param |
| 116 |
|
|
| 117 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 118 |
0 |
public void setStartRes(int res)... |
| 119 |
|
{ |
| 120 |
0 |
int width = getViewportWidth(); |
| 121 |
0 |
setStartEndRes(res, res + width - 1); |
| 122 |
|
} |
| 123 |
|
|
| 124 |
|
|
| 125 |
|
|
| 126 |
|
|
| 127 |
|
|
| 128 |
|
|
| 129 |
|
@param |
| 130 |
|
|
| 131 |
|
@param |
| 132 |
|
|
| 133 |
|
|
| |
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 4 |
Complexity Density: 0.5 |
|
| 134 |
0 |
public void setStartEndRes(int start, int end)... |
| 135 |
|
{ |
| 136 |
0 |
int[] oldvalues = updateStartEndRes(start, end); |
| 137 |
0 |
int oldstartres = oldvalues[0]; |
| 138 |
0 |
int oldendres = oldvalues[1]; |
| 139 |
|
|
| 140 |
0 |
if (oldstartres == startRes && oldendres == endRes) |
| 141 |
|
{ |
| 142 |
0 |
return; |
| 143 |
|
} |
| 144 |
|
|
| 145 |
|
|
| 146 |
|
|
| 147 |
0 |
changeSupport.firePropertyChange(STARTRES, oldstartres, startRes); |
| 148 |
0 |
if (oldstartres == startRes) |
| 149 |
|
{ |
| 150 |
|
|
| 151 |
|
|
| 152 |
|
|
| 153 |
|
|
| 154 |
|
|
| 155 |
|
|
| 156 |
|
|
| 157 |
0 |
changeSupport.firePropertyChange(ENDRES, oldendres, endRes); |
| 158 |
|
} |
| 159 |
|
} |
| 160 |
|
|
| 161 |
|
|
| 162 |
|
|
| 163 |
|
|
| 164 |
|
|
| 165 |
|
@param |
| 166 |
|
|
| 167 |
|
@param |
| 168 |
|
|
| 169 |
|
@return |
| 170 |
|
|
| |
|
| 0% |
Uncovered Elements: 22 (22) |
Complexity: 7 |
Complexity Density: 0.5 |
|
| 171 |
0 |
private int[] updateStartEndRes(int start, int end)... |
| 172 |
|
{ |
| 173 |
0 |
int oldstartres = this.startRes; |
| 174 |
|
|
| 175 |
|
|
| 176 |
|
|
| 177 |
|
|
| 178 |
0 |
int lastColumn = getVisibleAlignmentWidth() - 1; |
| 179 |
0 |
if (!wrappedMode && (start > lastColumn)) |
| 180 |
|
{ |
| 181 |
0 |
startRes = Math.max(lastColumn, 0); |
| 182 |
|
} |
| 183 |
0 |
else if (start < 0) |
| 184 |
|
{ |
| 185 |
0 |
startRes = 0; |
| 186 |
|
} |
| 187 |
|
else |
| 188 |
|
{ |
| 189 |
0 |
startRes = start; |
| 190 |
|
} |
| 191 |
|
|
| 192 |
0 |
int oldendres = this.endRes; |
| 193 |
0 |
if (end < 0) |
| 194 |
|
{ |
| 195 |
0 |
endRes = 0; |
| 196 |
|
} |
| 197 |
0 |
else if (!wrappedMode && (end > lastColumn)) |
| 198 |
|
{ |
| 199 |
0 |
endRes = Math.max(lastColumn, 0); |
| 200 |
|
} |
| 201 |
|
else |
| 202 |
|
{ |
| 203 |
0 |
endRes = end; |
| 204 |
|
} |
| 205 |
0 |
return new int[] { oldstartres, oldendres }; |
| 206 |
|
} |
| 207 |
|
|
| 208 |
|
|
| 209 |
|
|
| 210 |
|
|
| 211 |
|
|
| 212 |
|
|
| 213 |
|
@param |
| 214 |
|
|
| 215 |
|
|
| |
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 216 |
0 |
public void setStartSeq(int seq)... |
| 217 |
|
{ |
| 218 |
0 |
int startseq = seq; |
| 219 |
0 |
int height = getViewportHeight(); |
| 220 |
0 |
if (startseq + height - 1 > getVisibleAlignmentHeight() - 1) |
| 221 |
|
{ |
| 222 |
0 |
startseq = getVisibleAlignmentHeight() - height; |
| 223 |
|
} |
| 224 |
0 |
setStartEndSeq(startseq, startseq + height - 1); |
| 225 |
|
} |
| 226 |
|
|
| 227 |
|
|
| 228 |
|
|
| 229 |
|
|
| 230 |
|
|
| 231 |
|
|
| 232 |
|
@param |
| 233 |
|
|
| 234 |
|
@param |
| 235 |
|
|
| 236 |
|
|
| |
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
| 237 |
0 |
public void setStartEndSeq(int start, int end)... |
| 238 |
|
{ |
| 239 |
0 |
int[] oldvalues = updateStartEndSeq(start, end); |
| 240 |
0 |
int oldstartseq = oldvalues[0]; |
| 241 |
0 |
int oldendseq = oldvalues[1]; |
| 242 |
|
|
| 243 |
0 |
changeSupport.firePropertyChange(STARTSEQ, oldstartseq, startSeq); |
| 244 |
0 |
if (oldstartseq == startSeq) |
| 245 |
|
{ |
| 246 |
|
|
| 247 |
|
|
| 248 |
0 |
changeSupport.firePropertyChange(ENDSEQ, oldendseq, endSeq); |
| 249 |
|
} |
| 250 |
|
} |
| 251 |
|
|
| 252 |
|
|
| 253 |
|
|
| 254 |
|
|
| 255 |
|
|
| 256 |
|
@param |
| 257 |
|
|
| 258 |
|
@param |
| 259 |
|
|
| 260 |
|
@return |
| 261 |
|
|
| |
|
| 0% |
Uncovered Elements: 22 (22) |
Complexity: 5 |
Complexity Density: 0.36 |
|
| 262 |
0 |
private int[] updateStartEndSeq(int start, int end)... |
| 263 |
|
{ |
| 264 |
0 |
int oldstartseq = this.startSeq; |
| 265 |
0 |
int visibleHeight = getVisibleAlignmentHeight(); |
| 266 |
0 |
if (start > visibleHeight - 1) |
| 267 |
|
{ |
| 268 |
0 |
startSeq = Math.max(visibleHeight - 1, 0); |
| 269 |
|
} |
| 270 |
0 |
else if (start < 0) |
| 271 |
|
{ |
| 272 |
0 |
startSeq = 0; |
| 273 |
|
} |
| 274 |
|
else |
| 275 |
|
{ |
| 276 |
0 |
startSeq = start; |
| 277 |
|
} |
| 278 |
|
|
| 279 |
0 |
int oldendseq = this.endSeq; |
| 280 |
0 |
if (end >= visibleHeight) |
| 281 |
|
{ |
| 282 |
0 |
endSeq = Math.max(visibleHeight - 1, 0); |
| 283 |
|
} |
| 284 |
0 |
else if (end < 0) |
| 285 |
|
{ |
| 286 |
0 |
endSeq = 0; |
| 287 |
|
} |
| 288 |
|
else |
| 289 |
|
{ |
| 290 |
0 |
endSeq = end; |
| 291 |
|
} |
| 292 |
0 |
return new int[] { oldstartseq, oldendseq }; |
| 293 |
|
} |
| 294 |
|
|
| 295 |
|
|
| 296 |
|
|
| 297 |
|
|
| 298 |
|
|
| 299 |
|
@param |
| 300 |
|
|
| 301 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 302 |
0 |
public void setEndSeq(int seq)... |
| 303 |
|
{ |
| 304 |
|
|
| 305 |
0 |
setStartEndSeq(Math.max(0, seq + 1 - getViewportHeight()), seq); |
| 306 |
|
} |
| 307 |
|
|
| 308 |
|
|
| 309 |
|
|
| 310 |
|
|
| 311 |
|
|
| 312 |
|
|
| 313 |
|
@param |
| 314 |
|
|
| 315 |
|
@param |
| 316 |
|
|
| 317 |
|
|
| |
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 2 |
Complexity Density: 0.2 |
|
| 318 |
0 |
public void setStartResAndSeq(int res, int seq)... |
| 319 |
|
{ |
| 320 |
0 |
int width = getViewportWidth(); |
| 321 |
0 |
int[] oldresvalues = updateStartEndRes(res, res + width - 1); |
| 322 |
|
|
| 323 |
0 |
int startseq = seq; |
| 324 |
0 |
int height = getViewportHeight(); |
| 325 |
0 |
if (startseq + height - 1 > getVisibleAlignmentHeight() - 1) |
| 326 |
|
{ |
| 327 |
0 |
startseq = getVisibleAlignmentHeight() - height; |
| 328 |
|
} |
| 329 |
0 |
int[] oldseqvalues = updateStartEndSeq(startseq, startseq + height - 1); |
| 330 |
|
|
| 331 |
0 |
int[] old = new int[] { oldresvalues[0], oldseqvalues[0] }; |
| 332 |
0 |
int[] newresseq = new int[] { startRes, startSeq }; |
| 333 |
0 |
changeSupport.firePropertyChange(STARTRESANDSEQ, old, newresseq); |
| 334 |
|
} |
| 335 |
|
|
| 336 |
|
|
| 337 |
|
|
| 338 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 339 |
0 |
public int getStartRes()... |
| 340 |
|
{ |
| 341 |
0 |
return startRes; |
| 342 |
|
} |
| 343 |
|
|
| 344 |
|
|
| 345 |
|
|
| 346 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 347 |
0 |
public int getEndRes()... |
| 348 |
|
{ |
| 349 |
0 |
return endRes; |
| 350 |
|
} |
| 351 |
|
|
| 352 |
|
|
| 353 |
|
|
| 354 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 355 |
0 |
public int getStartSeq()... |
| 356 |
|
{ |
| 357 |
0 |
return startSeq; |
| 358 |
|
} |
| 359 |
|
|
| 360 |
|
|
| 361 |
|
|
| 362 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 363 |
0 |
public int getEndSeq()... |
| 364 |
|
{ |
| 365 |
0 |
return endSeq; |
| 366 |
|
} |
| 367 |
|
|
| 368 |
|
|
| 369 |
|
|
| 370 |
|
|
| 371 |
|
|
| 372 |
|
|
| 373 |
|
@param |
| 374 |
|
|
| 375 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 376 |
0 |
public void setViewportWidth(int w)... |
| 377 |
|
{ |
| 378 |
0 |
setStartEndRes(startRes, startRes + w - 1); |
| 379 |
|
} |
| 380 |
|
|
| 381 |
|
|
| 382 |
|
|
| 383 |
|
|
| 384 |
|
|
| 385 |
|
|
| 386 |
|
@param |
| 387 |
|
|
| 388 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 389 |
0 |
public void setViewportHeight(int h)... |
| 390 |
|
{ |
| 391 |
0 |
setStartEndSeq(startSeq, startSeq + h - 1); |
| 392 |
|
} |
| 393 |
|
|
| 394 |
|
|
| 395 |
|
|
| 396 |
|
|
| 397 |
|
|
| 398 |
|
|
| 399 |
|
@param |
| 400 |
|
|
| 401 |
|
@param |
| 402 |
|
|
| 403 |
|
|
| |
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 404 |
0 |
public void setViewportStartAndWidth(int start, int w)... |
| 405 |
|
{ |
| 406 |
0 |
int vpstart = Math.max(0, start); |
| 407 |
|
|
| 408 |
0 |
if (!wrappedMode) |
| 409 |
|
{ |
| 410 |
|
|
| 411 |
0 |
int maxStart = getVisibleAlignmentWidth() - w; |
| 412 |
0 |
if (maxStart >= 0) |
| 413 |
|
{ |
| 414 |
0 |
vpstart = Math.min(vpstart, maxStart); |
| 415 |
|
} |
| 416 |
|
|
| 417 |
|
} |
| 418 |
0 |
setStartEndRes(vpstart, vpstart + w - 1); |
| 419 |
|
} |
| 420 |
|
|
| 421 |
|
|
| 422 |
|
|
| 423 |
|
|
| 424 |
|
|
| 425 |
|
|
| 426 |
|
@param |
| 427 |
|
|
| 428 |
|
@param |
| 429 |
|
|
| 430 |
|
|
| |
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 431 |
0 |
public void setViewportStartAndHeight(int start, int h)... |
| 432 |
|
{ |
| 433 |
0 |
int vpstart = Math.max(0, start); |
| 434 |
0 |
int maxStart = getVisibleAlignmentHeight() - h; |
| 435 |
0 |
if (maxStart > 0) |
| 436 |
|
{ |
| 437 |
|
|
| 438 |
|
|
| 439 |
|
|
| 440 |
0 |
vpstart = Math.min(vpstart, maxStart); |
| 441 |
|
} |
| 442 |
0 |
setStartEndSeq(vpstart, vpstart + h - 1); |
| 443 |
|
} |
| 444 |
|
|
| 445 |
|
|
| 446 |
|
|
| 447 |
|
|
| 448 |
|
@return |
| 449 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 450 |
0 |
public int getViewportWidth()... |
| 451 |
|
{ |
| 452 |
0 |
return (endRes - startRes + 1); |
| 453 |
|
} |
| 454 |
|
|
| 455 |
|
|
| 456 |
|
|
| 457 |
|
|
| 458 |
|
@return |
| 459 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 460 |
0 |
public int getViewportHeight()... |
| 461 |
|
{ |
| 462 |
0 |
return (endSeq - startSeq + 1); |
| 463 |
|
} |
| 464 |
|
|
| 465 |
|
|
| 466 |
|
|
| 467 |
|
|
| 468 |
|
@param |
| 469 |
|
|
| 470 |
|
|
| 471 |
|
@return |
| 472 |
|
|
| |
|
| 0% |
Uncovered Elements: 22 (22) |
Complexity: 6 |
Complexity Density: 0.5 |
|
| 473 |
0 |
public boolean scrollUp(boolean up)... |
| 474 |
|
{ |
| 475 |
|
|
| 476 |
|
|
| 477 |
|
|
| 478 |
|
|
| 479 |
0 |
if (up) |
| 480 |
|
{ |
| 481 |
0 |
if (wrappedMode) |
| 482 |
|
{ |
| 483 |
0 |
pageUp(); |
| 484 |
|
} |
| 485 |
|
else |
| 486 |
|
{ |
| 487 |
0 |
if (startSeq < 1) |
| 488 |
|
{ |
| 489 |
0 |
return false; |
| 490 |
|
} |
| 491 |
0 |
setStartSeq(startSeq - 1); |
| 492 |
|
} |
| 493 |
|
} |
| 494 |
|
else |
| 495 |
|
{ |
| 496 |
0 |
if (wrappedMode) |
| 497 |
|
{ |
| 498 |
0 |
pageDown(); |
| 499 |
|
} |
| 500 |
|
else |
| 501 |
|
{ |
| 502 |
0 |
if (endSeq >= getVisibleAlignmentHeight() - 1) |
| 503 |
|
{ |
| 504 |
0 |
return false; |
| 505 |
|
} |
| 506 |
0 |
setStartSeq(startSeq + 1); |
| 507 |
|
} |
| 508 |
|
} |
| 509 |
0 |
return true; |
| 510 |
|
} |
| 511 |
|
|
| 512 |
|
|
| 513 |
|
|
| 514 |
|
|
| 515 |
|
@param |
| 516 |
|
|
| 517 |
|
|
| 518 |
|
@return |
| 519 |
|
|
| |
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 4 |
Complexity Density: 0.5 |
|
| 520 |
0 |
public boolean scrollRight(boolean right)... |
| 521 |
|
{ |
| 522 |
0 |
if (!right) |
| 523 |
|
{ |
| 524 |
0 |
if (startRes < 1) |
| 525 |
|
{ |
| 526 |
0 |
return false; |
| 527 |
|
} |
| 528 |
|
|
| 529 |
0 |
setStartRes(startRes - 1); |
| 530 |
|
} |
| 531 |
|
else |
| 532 |
|
{ |
| 533 |
0 |
if (endRes >= getVisibleAlignmentWidth() - 1) |
| 534 |
|
{ |
| 535 |
0 |
return false; |
| 536 |
|
} |
| 537 |
|
|
| 538 |
0 |
setStartRes(startRes + 1); |
| 539 |
|
} |
| 540 |
|
|
| 541 |
0 |
return true; |
| 542 |
|
} |
| 543 |
|
|
| 544 |
|
|
| 545 |
|
|
| 546 |
|
|
| 547 |
|
|
| 548 |
|
|
| 549 |
|
@param |
| 550 |
|
|
| 551 |
|
|
| 552 |
|
@return |
| 553 |
|
|
| |
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 554 |
0 |
public boolean scrollToWrappedVisible(int res)... |
| 555 |
|
{ |
| 556 |
0 |
int newStartRes = calcWrappedStartResidue(res); |
| 557 |
0 |
if (newStartRes == startRes) |
| 558 |
|
{ |
| 559 |
0 |
return false; |
| 560 |
|
} |
| 561 |
0 |
setStartRes(newStartRes); |
| 562 |
|
|
| 563 |
0 |
return true; |
| 564 |
|
} |
| 565 |
|
|
| 566 |
|
|
| 567 |
|
|
| 568 |
|
|
| 569 |
|
@param |
| 570 |
|
|
| 571 |
|
@return |
| 572 |
|
|
| |
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 4 |
Complexity Density: 0.36 |
|
| 573 |
0 |
private int calcWrappedStartResidue(int res)... |
| 574 |
|
{ |
| 575 |
0 |
int oldStartRes = startRes; |
| 576 |
0 |
int width = getViewportWidth(); |
| 577 |
|
|
| 578 |
0 |
boolean up = res < oldStartRes; |
| 579 |
0 |
int widthsToScroll = Math.abs((res - oldStartRes) / width); |
| 580 |
0 |
if (up) |
| 581 |
|
{ |
| 582 |
0 |
widthsToScroll++; |
| 583 |
|
} |
| 584 |
|
|
| 585 |
0 |
int residuesToScroll = width * widthsToScroll; |
| 586 |
0 |
int newStartRes = up ? oldStartRes - residuesToScroll |
| 587 |
|
: oldStartRes + residuesToScroll; |
| 588 |
0 |
if (newStartRes < 0) |
| 589 |
|
{ |
| 590 |
0 |
newStartRes = 0; |
| 591 |
|
} |
| 592 |
0 |
return newStartRes; |
| 593 |
|
} |
| 594 |
|
|
| 595 |
|
|
| 596 |
|
|
| 597 |
|
|
| 598 |
|
@param |
| 599 |
|
|
| 600 |
|
@param |
| 601 |
|
|
| 602 |
|
|
| |
|
| 0% |
Uncovered Elements: 23 (23) |
Complexity: 7 |
Complexity Density: 0.64 |
|
| 603 |
0 |
public void scrollToVisible(int x, int y)... |
| 604 |
|
{ |
| 605 |
0 |
while (y < startSeq) |
| 606 |
|
{ |
| 607 |
0 |
scrollUp(true); |
| 608 |
|
} |
| 609 |
0 |
while (y > endSeq) |
| 610 |
|
{ |
| 611 |
0 |
scrollUp(false); |
| 612 |
|
} |
| 613 |
|
|
| 614 |
0 |
HiddenColumns hidden = al.getHiddenColumns(); |
| 615 |
0 |
while (x < hidden.visibleToAbsoluteColumn(startRes)) |
| 616 |
|
{ |
| 617 |
0 |
if (!scrollRight(false)) |
| 618 |
|
{ |
| 619 |
0 |
break; |
| 620 |
|
} |
| 621 |
|
} |
| 622 |
0 |
while (x > hidden.visibleToAbsoluteColumn(endRes)) |
| 623 |
|
{ |
| 624 |
0 |
if (!scrollRight(true)) |
| 625 |
|
{ |
| 626 |
0 |
break; |
| 627 |
|
} |
| 628 |
|
} |
| 629 |
|
} |
| 630 |
|
|
| 631 |
|
|
| 632 |
|
|
| 633 |
|
|
| 634 |
|
@param |
| 635 |
|
|
| 636 |
|
@param |
| 637 |
|
|
| 638 |
|
|
| |
|
| 0% |
Uncovered Elements: 32 (32) |
Complexity: 8 |
Complexity Density: 0.33 |
|
| 639 |
0 |
public boolean setViewportLocation(int x, int y)... |
| 640 |
|
{ |
| 641 |
0 |
boolean changedLocation = false; |
| 642 |
|
|
| 643 |
|
|
| 644 |
0 |
int visX = al.getHiddenColumns().absoluteToVisibleColumn(x); |
| 645 |
0 |
int visY = al.getHiddenSequences().findIndexWithoutHiddenSeqs(y); |
| 646 |
|
|
| 647 |
|
|
| 648 |
0 |
if (startRes > visX || visX > endRes |
| 649 |
|
|| startSeq > visY && visY > endSeq) |
| 650 |
|
{ |
| 651 |
0 |
int[] old = new int[] { startRes, startSeq }; |
| 652 |
0 |
int[] newresseq; |
| 653 |
0 |
if (wrappedMode) |
| 654 |
|
{ |
| 655 |
0 |
int newstartres = calcWrappedStartResidue(visX); |
| 656 |
0 |
setStartRes(newstartres); |
| 657 |
0 |
newresseq = new int[] { startRes, startSeq }; |
| 658 |
|
} |
| 659 |
|
else |
| 660 |
|
{ |
| 661 |
|
|
| 662 |
0 |
int newstartres = visX; |
| 663 |
0 |
int width = getViewportWidth(); |
| 664 |
0 |
if (newstartres + width - 1 > getVisibleAlignmentWidth() - 1) |
| 665 |
|
{ |
| 666 |
0 |
newstartres = getVisibleAlignmentWidth() - width; |
| 667 |
|
} |
| 668 |
0 |
updateStartEndRes(newstartres, newstartres + width - 1); |
| 669 |
|
|
| 670 |
|
|
| 671 |
0 |
int newstartseq = visY; |
| 672 |
0 |
int height = getViewportHeight(); |
| 673 |
0 |
if (newstartseq + height - 1 > getVisibleAlignmentHeight() - 1) |
| 674 |
|
{ |
| 675 |
0 |
newstartseq = getVisibleAlignmentHeight() - height; |
| 676 |
|
} |
| 677 |
0 |
updateStartEndSeq(newstartseq, newstartseq + height - 1); |
| 678 |
|
|
| 679 |
0 |
newresseq = new int[] { startRes, startSeq }; |
| 680 |
|
} |
| 681 |
0 |
changedLocation = true; |
| 682 |
0 |
changeSupport.firePropertyChange(MOVE_VIEWPORT, old, newresseq); |
| 683 |
|
} |
| 684 |
0 |
return changedLocation; |
| 685 |
|
} |
| 686 |
|
|
| 687 |
|
|
| 688 |
|
|
| 689 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 690 |
0 |
public void pageUp()... |
| 691 |
|
{ |
| 692 |
0 |
if (wrappedMode) |
| 693 |
|
{ |
| 694 |
0 |
setStartRes(Math.max(0, getStartRes() - getViewportWidth())); |
| 695 |
|
} |
| 696 |
|
else |
| 697 |
|
{ |
| 698 |
0 |
setViewportStartAndHeight(startSeq - (endSeq - startSeq), |
| 699 |
|
getViewportHeight()); |
| 700 |
|
} |
| 701 |
|
} |
| 702 |
|
|
| 703 |
|
|
| 704 |
|
|
| 705 |
|
|
| |
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
| 706 |
0 |
public void pageDown()... |
| 707 |
|
{ |
| 708 |
0 |
if (wrappedMode) |
| 709 |
|
{ |
| 710 |
|
|
| 711 |
|
|
| 712 |
|
|
| 713 |
|
|
| 714 |
0 |
int newStart = getStartRes() |
| 715 |
|
+ Math.max(getViewportHeight(), getViewportWidth()); |
| 716 |
|
|
| 717 |
|
|
| 718 |
|
|
| 719 |
|
|
| 720 |
|
|
| 721 |
0 |
if (newStart < getVisibleAlignmentWidth()) |
| 722 |
|
{ |
| 723 |
0 |
setStartRes(newStart); |
| 724 |
|
} |
| 725 |
|
} |
| 726 |
|
else |
| 727 |
|
{ |
| 728 |
0 |
setViewportStartAndHeight(endSeq, getViewportHeight()); |
| 729 |
|
} |
| 730 |
|
} |
| 731 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 732 |
0 |
public void setWrappedMode(boolean wrapped)... |
| 733 |
|
{ |
| 734 |
0 |
wrappedMode = wrapped; |
| 735 |
|
} |
| 736 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 737 |
0 |
public boolean isWrappedMode()... |
| 738 |
|
{ |
| 739 |
0 |
return wrappedMode; |
| 740 |
|
} |
| 741 |
|
|
| 742 |
|
|
| 743 |
|
|
| 744 |
|
|
| 745 |
|
|
| 746 |
|
|
| 747 |
|
|
| 748 |
|
|
| 749 |
|
|
| 750 |
|
|
| 751 |
|
|
| 752 |
|
|
| 753 |
|
|
| 754 |
|
|
| 755 |
|
@param |
| 756 |
|
|
| 757 |
|
@return |
| 758 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 759 |
0 |
public int getWrappedScrollPosition(final int topLeftColumn)... |
| 760 |
|
{ |
| 761 |
0 |
int w = getViewportWidth(); |
| 762 |
|
|
| 763 |
|
|
| 764 |
|
|
| 765 |
|
|
| 766 |
0 |
int scroll = topLeftColumn / w; |
| 767 |
|
|
| 768 |
|
|
| 769 |
|
|
| 770 |
|
|
| 771 |
0 |
scroll += topLeftColumn % w > 0 ? 1 : 0; |
| 772 |
|
|
| 773 |
0 |
return scroll; |
| 774 |
|
} |
| 775 |
|
|
| 776 |
|
|
| 777 |
|
|
| 778 |
|
|
| 779 |
|
|
| 780 |
|
@param |
| 781 |
|
@return |
| 782 |
|
|
| |
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
| 783 |
0 |
public int getWrappedMaxScroll(int topLeftColumn)... |
| 784 |
|
{ |
| 785 |
0 |
int scrollPosition = getWrappedScrollPosition(topLeftColumn); |
| 786 |
|
|
| 787 |
|
|
| 788 |
|
|
| 789 |
|
|
| 790 |
0 |
int columnsRemaining = getVisibleAlignmentWidth() - topLeftColumn; |
| 791 |
0 |
int width = getViewportWidth(); |
| 792 |
0 |
int widthsRemaining = columnsRemaining / width |
| 793 |
0 |
+ (columnsRemaining % width > 0 ? 1 : 0) - 1; |
| 794 |
0 |
int maxScroll = scrollPosition + widthsRemaining; |
| 795 |
|
|
| 796 |
0 |
return maxScroll; |
| 797 |
|
} |
| 798 |
|
|
| 799 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 800 |
0 |
@Override... |
| 801 |
|
public String toString() { |
| 802 |
0 |
return "[ViewportRange " + startSeq + "-" + endSeq + ", "+ startRes + "-" + endRes + "]"; |
| 803 |
|
} |
| 804 |
|
} |