| 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 java.awt.Graphics; |
| 24 |
|
|
| 25 |
|
import jalview.api.AlignmentColsCollectionI; |
| 26 |
|
import jalview.api.AlignmentRowsCollectionI; |
| 27 |
|
import jalview.datamodel.AlignmentI; |
| 28 |
|
import jalview.datamodel.HiddenColumns; |
| 29 |
|
import jalview.datamodel.HiddenSequences; |
| 30 |
|
|
| |
|
| 96.9% |
Uncovered Elements: 2 (65) |
Complexity: 22 |
Complexity Density: 0.59 |
|
| 31 |
|
public abstract class OverviewDimensions |
| 32 |
|
{ |
| 33 |
|
protected static final int MAX_WIDTH = 400; |
| 34 |
|
|
| 35 |
|
protected static final int MIN_WIDTH = 120; |
| 36 |
|
|
| 37 |
|
protected static final int MIN_SEQ_HEIGHT = 40; |
| 38 |
|
|
| 39 |
|
protected static final int MAX_SEQ_HEIGHT = 300; |
| 40 |
|
|
| 41 |
|
private static final int DEFAULT_GRAPH_HEIGHT = 20; |
| 42 |
|
|
| 43 |
|
protected int width; |
| 44 |
|
|
| 45 |
|
protected int sequencesHeight; |
| 46 |
|
|
| 47 |
|
protected int graphHeight = DEFAULT_GRAPH_HEIGHT; |
| 48 |
|
|
| 49 |
|
protected int boxX = -1; |
| 50 |
|
|
| 51 |
|
protected int boxY = -1; |
| 52 |
|
|
| 53 |
|
protected int boxWidth = -1; |
| 54 |
|
|
| 55 |
|
protected int boxHeight = -1; |
| 56 |
|
|
| 57 |
|
protected int alwidth; |
| 58 |
|
|
| 59 |
|
protected int alheight; |
| 60 |
|
|
| 61 |
|
protected float widthRatio; |
| 62 |
|
|
| 63 |
|
protected float heightRatio; |
| 64 |
|
|
| 65 |
|
|
| 66 |
|
|
| 67 |
|
|
| 68 |
|
@param |
| 69 |
|
|
| 70 |
|
@param |
| 71 |
|
|
| 72 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 5 |
Complexity Density: 0.42 |
|
| 73 |
88 |
public OverviewDimensions(ViewportRanges ranges,... |
| 74 |
|
boolean showAnnotationPanel) |
| 75 |
|
{ |
| 76 |
|
|
| 77 |
88 |
float initialScale = (float) ranges.getAbsoluteAlignmentWidth() |
| 78 |
|
/ (float) ranges.getAbsoluteAlignmentHeight(); |
| 79 |
|
|
| 80 |
88 |
if (!showAnnotationPanel) |
| 81 |
|
{ |
| 82 |
2 |
graphHeight = 0; |
| 83 |
|
} |
| 84 |
|
|
| 85 |
88 |
if (ranges.getAbsoluteAlignmentWidth() > ranges |
| 86 |
|
.getAbsoluteAlignmentHeight()) |
| 87 |
|
{ |
| 88 |
|
|
| 89 |
47 |
width = MAX_WIDTH; |
| 90 |
47 |
sequencesHeight = Math.round(MAX_WIDTH / initialScale); |
| 91 |
47 |
if (sequencesHeight < MIN_SEQ_HEIGHT) |
| 92 |
|
{ |
| 93 |
25 |
sequencesHeight = MIN_SEQ_HEIGHT; |
| 94 |
|
} |
| 95 |
|
} |
| 96 |
|
else |
| 97 |
|
{ |
| 98 |
|
|
| 99 |
41 |
width = Math.round(MAX_WIDTH * initialScale); |
| 100 |
41 |
sequencesHeight = MAX_SEQ_HEIGHT; |
| 101 |
|
|
| 102 |
41 |
if (width < MIN_WIDTH) |
| 103 |
|
{ |
| 104 |
4 |
width = MIN_WIDTH; |
| 105 |
|
} |
| 106 |
|
} |
| 107 |
|
} |
| 108 |
|
|
| 109 |
|
|
| 110 |
|
|
| 111 |
|
|
| 112 |
|
@param |
| 113 |
|
|
| 114 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 115 |
20 |
public void drawBox(Graphics g)... |
| 116 |
|
{ |
| 117 |
20 |
g.drawRect(boxX, boxY, boxWidth, boxHeight); |
| 118 |
20 |
g.drawRect(boxX + 1, boxY + 1, boxWidth - 2, boxHeight - 2); |
| 119 |
|
} |
| 120 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 121 |
362 |
public int getBoxX()... |
| 122 |
|
{ |
| 123 |
362 |
return boxX; |
| 124 |
|
} |
| 125 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 126 |
353 |
public int getBoxY()... |
| 127 |
|
{ |
| 128 |
353 |
return boxY; |
| 129 |
|
} |
| 130 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 131 |
357 |
public int getBoxWidth()... |
| 132 |
|
{ |
| 133 |
357 |
return boxWidth; |
| 134 |
|
} |
| 135 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 136 |
339 |
public int getBoxHeight()... |
| 137 |
|
{ |
| 138 |
339 |
return boxHeight; |
| 139 |
|
} |
| 140 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 141 |
1805 |
public int getWidth()... |
| 142 |
|
{ |
| 143 |
1805 |
return width; |
| 144 |
|
} |
| 145 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 146 |
1682 |
public int getHeight()... |
| 147 |
|
{ |
| 148 |
1682 |
return sequencesHeight + graphHeight; |
| 149 |
|
} |
| 150 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 151 |
853 |
public int getSequencesHeight()... |
| 152 |
|
{ |
| 153 |
853 |
return sequencesHeight; |
| 154 |
|
} |
| 155 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 156 |
776 |
public int getGraphHeight()... |
| 157 |
|
{ |
| 158 |
776 |
return graphHeight; |
| 159 |
|
} |
| 160 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 161 |
387 |
public float getPixelsPerCol()... |
| 162 |
|
{ |
| 163 |
387 |
resetAlignmentDims(); |
| 164 |
387 |
return 1 / widthRatio; |
| 165 |
|
} |
| 166 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 167 |
387 |
public float getPixelsPerSeq()... |
| 168 |
|
{ |
| 169 |
387 |
resetAlignmentDims(); |
| 170 |
387 |
return 1 / heightRatio; |
| 171 |
|
} |
| 172 |
|
|
| |
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 173 |
701 |
public void setWidth(int w)... |
| 174 |
|
{ |
| 175 |
701 |
width = w < 1 ? 1 : w; |
| 176 |
701 |
widthRatio = (float) alwidth / width; |
| 177 |
|
} |
| 178 |
|
|
| |
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 179 |
701 |
public void setHeight(int h)... |
| 180 |
|
{ |
| 181 |
701 |
sequencesHeight = (h < 1 ? 1 : h) - graphHeight; |
| 182 |
701 |
heightRatio = (float) alheight / sequencesHeight; |
| 183 |
|
} |
| 184 |
|
|
| 185 |
|
|
| 186 |
|
|
| 187 |
|
|
| 188 |
|
@param |
| 189 |
|
|
| 190 |
|
@param |
| 191 |
|
|
| 192 |
|
@param |
| 193 |
|
|
| 194 |
|
@param |
| 195 |
|
|
| 196 |
|
|
| 197 |
|
public abstract void updateViewportFromMouse(int mousex, int mousey, |
| 198 |
|
HiddenSequences hiddenSeqs, HiddenColumns hiddenCols); |
| 199 |
|
|
| 200 |
|
|
| 201 |
|
|
| 202 |
|
|
| 203 |
|
@param |
| 204 |
|
|
| 205 |
|
@param |
| 206 |
|
|
| 207 |
|
@param |
| 208 |
|
|
| 209 |
|
@param |
| 210 |
|
|
| 211 |
|
|
| 212 |
|
public abstract void adjustViewportFromMouse(int mousex, int mousey, |
| 213 |
|
HiddenSequences hiddenSeqs, HiddenColumns hiddenCols); |
| 214 |
|
|
| 215 |
|
|
| 216 |
|
|
| 217 |
|
|
| 218 |
|
|
| 219 |
|
@param |
| 220 |
|
|
| 221 |
|
@param |
| 222 |
|
|
| 223 |
|
@param |
| 224 |
|
|
| 225 |
|
@param |
| 226 |
|
|
| 227 |
|
|
| 228 |
|
public abstract void setDragPoint(int x, int y, |
| 229 |
|
HiddenSequences hiddenSeqs, HiddenColumns hiddenCols); |
| 230 |
|
|
| 231 |
|
|
| 232 |
|
|
| 233 |
|
|
| 234 |
|
|
| 235 |
|
protected abstract void updateViewportFromTopLeft(int leftx, int topy, |
| 236 |
|
HiddenSequences hiddenSeqs, HiddenColumns hiddenCols); |
| 237 |
|
|
| 238 |
|
|
| 239 |
|
|
| 240 |
|
|
| 241 |
|
@param |
| 242 |
|
|
| 243 |
|
@param |
| 244 |
|
|
| 245 |
|
|
| 246 |
|
public abstract void setBoxPosition(HiddenSequences hiddenSeqs, |
| 247 |
|
HiddenColumns hiddenCols); |
| 248 |
|
|
| 249 |
|
|
| 250 |
|
|
| 251 |
|
|
| 252 |
|
@param |
| 253 |
|
|
| 254 |
|
@return |
| 255 |
|
|
| 256 |
|
public abstract AlignmentColsCollectionI getColumns(AlignmentI al); |
| 257 |
|
|
| 258 |
|
|
| 259 |
|
|
| 260 |
|
|
| 261 |
|
@param |
| 262 |
|
|
| 263 |
|
@return |
| 264 |
|
|
| 265 |
|
public abstract AlignmentRowsCollectionI getRows(AlignmentI al); |
| 266 |
|
|
| 267 |
|
|
| 268 |
|
|
| 269 |
|
|
| 270 |
|
protected abstract void resetAlignmentDims(); |
| 271 |
|
|
| 272 |
|
|
| 273 |
|
|
| 274 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
| 275 |
468 |
protected void setBoxPosition(int startRes, int startSeq, int vpwidth,... |
| 276 |
|
int vpheight) |
| 277 |
|
{ |
| 278 |
468 |
resetAlignmentDims(); |
| 279 |
|
|
| 280 |
|
|
| 281 |
468 |
int xPos = Math.min(startRes, alwidth - vpwidth + 1); |
| 282 |
468 |
boxX = Math.round(xPos / widthRatio); |
| 283 |
468 |
boxY = Math.round(startSeq / heightRatio); |
| 284 |
|
|
| 285 |
|
|
| 286 |
468 |
boxWidth = Math.round(vpwidth / widthRatio); |
| 287 |
|
|
| 288 |
|
|
| 289 |
468 |
boxHeight = Math.round(vpheight / heightRatio); |
| 290 |
|
} |
| 291 |
|
|
| 292 |
|
|
| 293 |
|
|
| 294 |
|
|
| 295 |
|
@param |
| 296 |
|
|
| 297 |
|
@param |
| 298 |
|
|
| 299 |
|
@return |
| 300 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 301 |
42 |
public boolean isPositionInBox(int x, int y)... |
| 302 |
|
{ |
| 303 |
42 |
return (x > boxX && y > boxY && x < boxX + boxWidth |
| 304 |
|
&& y < boxY + boxHeight); |
| 305 |
|
} |
| 306 |
|
|
| 307 |
|
|
| 308 |
|
|
| 309 |
|
|
| 310 |
|
protected abstract int getLeftXFromCentreX(int mousex, |
| 311 |
|
HiddenColumns hidden); |
| 312 |
|
|
| 313 |
|
|
| 314 |
|
|
| 315 |
|
|
| 316 |
|
protected abstract int getTopYFromCentreY(int mousey, |
| 317 |
|
HiddenSequences hidden); |
| 318 |
|
|
| 319 |
|
} |