1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package org.utgenome.graphics;
25
26 public class ChromosomeWindow
27 {
28 private long startIndexOnChromosome;
29 private long endIndexOnChromosome;
30 private long range;
31 private int rank = -1;
32 private int leftMargin = 50;
33
34 public ChromosomeWindow(long startIndexOnChromosome, long endIndexOnChromosome, int rank)
35 {
36 this.startIndexOnChromosome = startIndexOnChromosome;
37 this.endIndexOnChromosome = endIndexOnChromosome;
38 this.rank = rank;
39
40 range = width(endIndexOnChromosome, startIndexOnChromosome) + 1;
41 }
42
43 public ChromosomeWindow(long startIndexOnChromosome, long endIndexOnChromosome)
44 {
45 this(startIndexOnChromosome, endIndexOnChromosome, -1);
46 }
47
48 public static long width(long x1, long x2)
49 {
50 return (x1 < x2) ? x2 - x1 : x1 - x2;
51 }
52
53 public int getXPosOnWindow(long indexOnChromosome, int canvasWidth)
54 {
55 double v = (indexOnChromosome - startIndexOnChromosome) * (double) canvasWidth;
56
57 double v2 = v / (double) range;
58 return (int) v2 + leftMargin;
59 }
60
61 public long getChromosomeStart()
62 {
63 return startIndexOnChromosome;
64 }
65 public void setChromosomeStart(long startIndexOnChromosome)
66 {
67 this.startIndexOnChromosome = startIndexOnChromosome;
68 range = width(endIndexOnChromosome, startIndexOnChromosome) + 1;
69 }
70
71 public long getChromosomeEnd()
72 {
73 return endIndexOnChromosome;
74 }
75 public void setChromosomeEnd(long endIndexOnChromosome)
76 {
77 this.endIndexOnChromosome = endIndexOnChromosome;
78 range = width(endIndexOnChromosome, startIndexOnChromosome) + 1;
79 }
80
81 public long getChromosomeRange()
82 {
83 return range;
84 }
85
86 public int getRank()
87 {
88 return rank;
89 }
90 public void setRank(int rank)
91 {
92 this.rank = rank;
93 }
94
95 public int getLeftMargin(){
96 return leftMargin;
97 }
98 public void setLeftMargin(int leftMargin){
99 this.leftMargin = leftMargin;
100 }
101
102 public long getRange(){
103 return range;
104 }
105 }