| 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 java.awt.BasicStroke; |
| 24 |
|
import java.awt.Color; |
| 25 |
|
import java.awt.Font; |
| 26 |
|
import java.awt.FontMetrics; |
| 27 |
|
import java.awt.Graphics; |
| 28 |
|
import java.awt.Graphics2D; |
| 29 |
|
import java.awt.Image; |
| 30 |
|
import java.awt.RenderingHints; |
| 31 |
|
import java.awt.Stroke; |
| 32 |
|
import java.awt.geom.AffineTransform; |
| 33 |
|
import java.awt.image.ImageObserver; |
| 34 |
|
import java.util.BitSet; |
| 35 |
|
import java.util.Hashtable; |
| 36 |
|
import java.util.List; |
| 37 |
|
import java.util.Map; |
| 38 |
|
|
| 39 |
|
import org.jfree.graphics2d.svg.SVGGraphics2D; |
| 40 |
|
import org.jibble.epsgraphics.EpsGraphics2D; |
| 41 |
|
|
| 42 |
|
import jalview.analysis.AAFrequency; |
| 43 |
|
import jalview.analysis.AlignmentUtils; |
| 44 |
|
import jalview.analysis.CodingUtils; |
| 45 |
|
import jalview.analysis.Rna; |
| 46 |
|
import jalview.analysis.StructureFrequency; |
| 47 |
|
import jalview.api.AlignViewportI; |
| 48 |
|
import jalview.bin.Cache; |
| 49 |
|
import jalview.bin.Console; |
| 50 |
|
import jalview.datamodel.AlignmentAnnotation; |
| 51 |
|
import jalview.datamodel.Annotation; |
| 52 |
|
import jalview.datamodel.ColumnSelection; |
| 53 |
|
import jalview.datamodel.HiddenColumns; |
| 54 |
|
import jalview.datamodel.ProfilesI; |
| 55 |
|
import jalview.renderer.api.AnnotationRendererFactoryI; |
| 56 |
|
import jalview.renderer.api.AnnotationRowRendererI; |
| 57 |
|
import jalview.schemes.ColourSchemeI; |
| 58 |
|
import jalview.schemes.NucleotideColourScheme; |
| 59 |
|
import jalview.schemes.ResidueProperties; |
| 60 |
|
import jalview.schemes.ZappoColourScheme; |
| 61 |
|
import jalview.util.Constants; |
| 62 |
|
import jalview.util.Platform; |
| 63 |
|
|
| |
|
| 51.2% |
Uncovered Elements: 547 (1,120) |
Complexity: 426 |
Complexity Density: 0.55 |
|
| 64 |
|
public class AnnotationRenderer |
| 65 |
|
{ |
| 66 |
|
private static final int UPPER_TO_LOWER = 'a' - 'A'; |
| 67 |
|
|
| 68 |
|
private static final int CHAR_A = 'A'; |
| 69 |
|
|
| 70 |
|
private static final int CHAR_Z = 'Z'; |
| 71 |
|
|
| 72 |
|
|
| 73 |
|
|
| 74 |
|
|
| 75 |
|
private final boolean debugRedraw; |
| 76 |
|
|
| 77 |
|
private int charWidth, endRes, charHeight; |
| 78 |
|
|
| 79 |
|
private boolean validCharWidth, hasHiddenColumns; |
| 80 |
|
|
| 81 |
|
private FontMetrics fm; |
| 82 |
|
|
| 83 |
|
private final boolean USE_FILL_ROUND_RECT = Platform.isAMacAndNotJS(); |
| 84 |
|
|
| 85 |
|
boolean av_renderHistogram = true, av_renderProfile = true, |
| 86 |
|
av_normaliseProfile = false; |
| 87 |
|
|
| 88 |
|
ResidueShaderI profcolour = null; |
| 89 |
|
|
| 90 |
|
private ColumnSelection columnSelection; |
| 91 |
|
|
| 92 |
|
private HiddenColumns hiddenColumns; |
| 93 |
|
|
| 94 |
|
private ProfilesI hconsensus; |
| 95 |
|
|
| 96 |
|
private Map<String, ProfilesI> hSSconsensus; |
| 97 |
|
|
| 98 |
|
private Hashtable<String, Object>[] complementConsensus; |
| 99 |
|
|
| 100 |
|
private Hashtable<String, Object>[] hStrucConsensus; |
| 101 |
|
|
| 102 |
|
private boolean av_ignoreGapsConsensus; |
| 103 |
|
|
| 104 |
|
private boolean renderingVectors = false; |
| 105 |
|
|
| 106 |
|
private boolean glyphLineDrawn = false; |
| 107 |
|
|
| 108 |
|
|
| 109 |
|
|
| 110 |
|
|
| 111 |
|
|
| 112 |
|
|
| 113 |
|
|
| 114 |
|
|
| 115 |
|
private Image fadedImage; |
| 116 |
|
|
| 117 |
|
|
| 118 |
|
|
| 119 |
|
|
| 120 |
|
private ImageObserver annotationPanel; |
| 121 |
|
|
| 122 |
|
|
| 123 |
|
|
| 124 |
|
|
| 125 |
|
private int imgWidth; |
| 126 |
|
|
| 127 |
|
|
| 128 |
|
|
| 129 |
|
|
| 130 |
|
private int sOffset; |
| 131 |
|
|
| 132 |
|
|
| 133 |
|
|
| 134 |
|
|
| 135 |
|
private int visHeight; |
| 136 |
|
|
| 137 |
|
|
| 138 |
|
|
| 139 |
|
|
| 140 |
|
|
| 141 |
|
private boolean useClip = true; |
| 142 |
|
|
| 143 |
|
|
| 144 |
|
|
| 145 |
|
|
| 146 |
|
|
| 147 |
|
private boolean canClip = false; |
| 148 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 149 |
514 |
public AnnotationRenderer()... |
| 150 |
|
{ |
| 151 |
514 |
this(false); |
| 152 |
|
} |
| 153 |
|
|
| 154 |
|
|
| 155 |
|
|
| 156 |
|
|
| 157 |
|
@param |
| 158 |
|
|
| 159 |
|
|
| 160 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 161 |
514 |
public AnnotationRenderer(boolean debugRedraw)... |
| 162 |
|
{ |
| 163 |
514 |
this.debugRedraw = debugRedraw; |
| 164 |
|
} |
| 165 |
|
|
| 166 |
|
|
| 167 |
|
|
| 168 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
| 169 |
270 |
public void dispose()... |
| 170 |
|
{ |
| 171 |
270 |
hiddenColumns = null; |
| 172 |
270 |
hconsensus = null; |
| 173 |
270 |
hSSconsensus = null; |
| 174 |
270 |
complementConsensus = null; |
| 175 |
270 |
hStrucConsensus = null; |
| 176 |
270 |
fadedImage = null; |
| 177 |
270 |
annotationPanel = null; |
| 178 |
270 |
rendererFactoryI = null; |
| 179 |
|
} |
| 180 |
|
|
| |
|
| 0% |
Uncovered Elements: 36 (36) |
Complexity: 11 |
Complexity Density: 0.5 |
|
| 181 |
0 |
void drawStemAnnot(Graphics g, Annotation[] row_annotations, int lastSSX,... |
| 182 |
|
int x, int y, int iconOffset, int startRes, int column, |
| 183 |
|
boolean validRes, boolean validEnd) |
| 184 |
|
{ |
| 185 |
0 |
int sCol = (lastSSX / charWidth) |
| 186 |
|
+ hiddenColumns.visibleToAbsoluteColumn(startRes); |
| 187 |
0 |
int x1 = lastSSX; |
| 188 |
0 |
int x2 = (x * charWidth); |
| 189 |
|
|
| 190 |
0 |
char dc = (column == 0 || row_annotations[column - 1] == null) ? ' ' |
| 191 |
|
: row_annotations[column - 1].secondaryStructure; |
| 192 |
|
|
| 193 |
0 |
boolean diffupstream = sCol == 0 || row_annotations[sCol - 1] == null |
| 194 |
|
|| dc != row_annotations[sCol - 1].secondaryStructure |
| 195 |
|
|| !validEnd; |
| 196 |
0 |
boolean diffdownstream = !validRes || !validEnd |
| 197 |
|
|| row_annotations[column] == null |
| 198 |
|
|| dc != row_annotations[column].secondaryStructure; |
| 199 |
|
|
| 200 |
0 |
if (diffupstream || diffdownstream) |
| 201 |
|
{ |
| 202 |
|
|
| 203 |
0 |
drawGlyphLine(g, lastSSX, x, y, iconOffset); |
| 204 |
|
} |
| 205 |
0 |
g.setColor(STEM_COLOUR); |
| 206 |
|
|
| 207 |
0 |
if (column > 0 && Rna.isClosingParenthesis(dc)) |
| 208 |
|
{ |
| 209 |
0 |
if (diffupstream) |
| 210 |
|
|
| 211 |
|
|
| 212 |
|
{ |
| 213 |
|
|
| 214 |
|
|
| 215 |
|
|
| 216 |
|
|
| 217 |
0 |
fillPolygon(g, new int[] { lastSSX + 5, lastSSX + 5, lastSSX }, |
| 218 |
|
new int[] |
| 219 |
|
{ y + iconOffset + 1, y + 13 + iconOffset, |
| 220 |
|
y + 7 + iconOffset }, |
| 221 |
|
3); |
| 222 |
0 |
x1 += 5; |
| 223 |
|
} |
| 224 |
0 |
if (diffdownstream) |
| 225 |
|
{ |
| 226 |
0 |
x2 -= 1; |
| 227 |
|
} |
| 228 |
|
} |
| 229 |
|
else |
| 230 |
|
{ |
| 231 |
|
|
| 232 |
0 |
if (diffdownstream) |
| 233 |
|
{ |
| 234 |
|
|
| 235 |
|
|
| 236 |
|
|
| 237 |
|
|
| 238 |
0 |
fillPolygon(g, new int[] { x2 - 6, x2 - 6, x2 - 1 }, |
| 239 |
|
new int[] |
| 240 |
|
{ y + iconOffset + 1, y + 13 + iconOffset, |
| 241 |
|
y + 7 + iconOffset }, |
| 242 |
|
3); |
| 243 |
0 |
x2 -= 5; |
| 244 |
|
} |
| 245 |
0 |
if (diffupstream) |
| 246 |
|
{ |
| 247 |
0 |
x1 += 1; |
| 248 |
|
} |
| 249 |
|
} |
| 250 |
|
|
| 251 |
0 |
unsetAntialias(g); |
| 252 |
0 |
fillRect(g, x1, y + 4 + iconOffset, x2 - x1, 6); |
| 253 |
|
} |
| 254 |
|
|
| |
|
| 0% |
Uncovered Elements: 36 (36) |
Complexity: 11 |
Complexity Density: 0.5 |
|
| 255 |
0 |
void drawNotCanonicalAnnot(Graphics g, Color nonCanColor,... |
| 256 |
|
Annotation[] row_annotations, int lastSSX, int x, int y, |
| 257 |
|
int iconOffset, int startRes, int column, boolean validRes, |
| 258 |
|
boolean validEnd) |
| 259 |
|
{ |
| 260 |
|
|
| 261 |
|
|
| 262 |
0 |
int sCol = (lastSSX / charWidth) |
| 263 |
|
+ hiddenColumns.visibleToAbsoluteColumn(startRes); |
| 264 |
0 |
int x1 = lastSSX; |
| 265 |
0 |
int x2 = (x * charWidth); |
| 266 |
|
|
| 267 |
0 |
String dc = (column == 0 || row_annotations[column - 1] == null) ? "" |
| 268 |
|
: row_annotations[column - 1].displayCharacter; |
| 269 |
|
|
| 270 |
0 |
boolean diffupstream = sCol == 0 || row_annotations[sCol - 1] == null |
| 271 |
|
|| !dc.equals(row_annotations[sCol - 1].displayCharacter) |
| 272 |
|
|| !validEnd; |
| 273 |
0 |
boolean diffdownstream = !validRes || !validEnd |
| 274 |
|
|| row_annotations[column] == null |
| 275 |
|
|| !dc.equals(row_annotations[column].displayCharacter); |
| 276 |
|
|
| 277 |
|
|
| 278 |
|
|
| 279 |
|
|
| 280 |
0 |
if (diffupstream || diffdownstream) |
| 281 |
|
{ |
| 282 |
|
|
| 283 |
0 |
drawGlyphLine(g, lastSSX, x, y, iconOffset); |
| 284 |
|
} |
| 285 |
0 |
g.setColor(nonCanColor); |
| 286 |
0 |
if (column > 0 && Rna.isClosingParenthesis(dc)) |
| 287 |
|
{ |
| 288 |
|
|
| 289 |
0 |
if (diffupstream) |
| 290 |
|
|
| 291 |
|
|
| 292 |
|
{ |
| 293 |
0 |
fillPolygon(g, new int[] { lastSSX + 5, lastSSX + 5, lastSSX }, |
| 294 |
|
new int[] |
| 295 |
|
{ y + iconOffset + 1, y + 13 + iconOffset, |
| 296 |
|
y + 7 + iconOffset }, |
| 297 |
|
3); |
| 298 |
0 |
x1 += 5; |
| 299 |
|
} |
| 300 |
0 |
if (diffdownstream) |
| 301 |
|
{ |
| 302 |
0 |
x2 -= 1; |
| 303 |
|
} |
| 304 |
|
} |
| 305 |
|
else |
| 306 |
|
{ |
| 307 |
|
|
| 308 |
|
|
| 309 |
0 |
if (diffdownstream) |
| 310 |
|
{ |
| 311 |
0 |
fillPolygon(g, new int[] { x2 - 6, x2 - 6, x2 - 1 }, |
| 312 |
|
new int[] |
| 313 |
|
{ y + iconOffset + 1, y + 13 + iconOffset, |
| 314 |
|
y + 7 + iconOffset }, |
| 315 |
|
3); |
| 316 |
0 |
x2 -= 5; |
| 317 |
|
} |
| 318 |
0 |
if (diffupstream) |
| 319 |
|
{ |
| 320 |
0 |
x1 += 1; |
| 321 |
|
} |
| 322 |
|
} |
| 323 |
|
|
| 324 |
0 |
unsetAntialias(g); |
| 325 |
0 |
fillRect(g, x1, y + 4 + iconOffset, x2 - x1, 6); |
| 326 |
|
} |
| 327 |
|
|
| 328 |
|
|
| 329 |
|
|
| |
|
| 88.9% |
Uncovered Elements: 2 (18) |
Complexity: 3 |
Complexity Density: 0.21 |
|
| 330 |
2735 |
public void updateFromAwtRenderPanel(AwtRenderPanelI annotPanel,... |
| 331 |
|
AlignViewportI av) |
| 332 |
|
{ |
| 333 |
2735 |
fm = annotPanel.getFontMetrics(); |
| 334 |
2735 |
annotationPanel = annotPanel; |
| 335 |
2735 |
fadedImage = annotPanel.getFadedImage(); |
| 336 |
2735 |
imgWidth = annotPanel.getFadedImageWidth(); |
| 337 |
|
|
| 338 |
2735 |
int[] bounds = annotPanel.getVisibleVRange(); |
| 339 |
2735 |
if (bounds != null) |
| 340 |
|
{ |
| 341 |
2468 |
sOffset = bounds[0]; |
| 342 |
2468 |
visHeight = bounds[1]; |
| 343 |
2468 |
if (visHeight == 0) |
| 344 |
|
{ |
| 345 |
0 |
useClip = false; |
| 346 |
|
} |
| 347 |
|
else |
| 348 |
|
{ |
| 349 |
2468 |
useClip = canClip; |
| 350 |
|
} |
| 351 |
|
} |
| 352 |
|
else |
| 353 |
|
{ |
| 354 |
267 |
useClip = false; |
| 355 |
|
} |
| 356 |
|
|
| 357 |
2735 |
rendererFactoryI = AnnotationRendererFactory.getRendererFactory(); |
| 358 |
2735 |
updateFromAlignViewport(av); |
| 359 |
|
} |
| 360 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (23) |
Complexity: 4 |
Complexity Density: 0.21 |
|
| 361 |
2735 |
public void updateFromAlignViewport(AlignViewportI av)... |
| 362 |
|
{ |
| 363 |
2735 |
charWidth = av.getCharWidth(); |
| 364 |
2735 |
endRes = av.getRanges().getEndRes(); |
| 365 |
2735 |
charHeight = av.getCharHeight(); |
| 366 |
2735 |
hasHiddenColumns = av.hasHiddenColumns(); |
| 367 |
2735 |
validCharWidth = av.isValidCharWidth(); |
| 368 |
2735 |
av_renderHistogram = av.isShowConsensusHistogram(); |
| 369 |
2735 |
av_renderProfile = av.isShowSequenceLogo(); |
| 370 |
2735 |
av_normaliseProfile = av.isNormaliseSequenceLogo(); |
| 371 |
2735 |
profcolour = av.getResidueShading(); |
| 372 |
2735 |
if (profcolour == null || profcolour.getColourScheme() == null) |
| 373 |
|
{ |
| 374 |
|
|
| 375 |
|
|
| 376 |
|
|
| 377 |
|
|
| 378 |
|
|
| 379 |
2395 |
ColourSchemeI col = av.getAlignment().isNucleotide() |
| 380 |
|
? new NucleotideColourScheme() |
| 381 |
|
: new ZappoColourScheme(); |
| 382 |
2395 |
profcolour = new ResidueShader(col); |
| 383 |
|
} |
| 384 |
2735 |
columnSelection = av.getColumnSelection(); |
| 385 |
2735 |
hiddenColumns = av.getAlignment().getHiddenColumns(); |
| 386 |
2735 |
hconsensus = av.getSequenceConsensusHash(); |
| 387 |
2735 |
hSSconsensus = av.getSequenceSSConsensusHash(); |
| 388 |
2735 |
complementConsensus = av.getComplementConsensusHash(); |
| 389 |
2735 |
hStrucConsensus = av.getRnaStructureConsensusHash(); |
| 390 |
2735 |
av_ignoreGapsConsensus = av.isIgnoreGapsConsensus(); |
| 391 |
|
} |
| 392 |
|
|
| 393 |
|
|
| 394 |
|
|
| 395 |
|
|
| 396 |
|
|
| 397 |
|
|
| 398 |
|
@param |
| 399 |
|
@param |
| 400 |
|
@return |
| 401 |
|
|
| |
|
| 27.9% |
Uncovered Elements: 31 (43) |
Complexity: 25 |
Complexity Density: 1.19 |
|
| 402 |
96035 |
int[] getProfileFor(AlignmentAnnotation aa, int column)... |
| 403 |
|
{ |
| 404 |
|
|
| 405 |
|
|
| 406 |
|
|
| 407 |
|
|
| 408 |
96035 |
if (aa.autoCalculated && (aa.label.startsWith("Consensus") |
| 409 |
|
|| aa.label.startsWith("cDNA Consensus"))) |
| 410 |
|
{ |
| 411 |
96035 |
boolean forComplement = aa.label.startsWith("cDNA Consensus"); |
| 412 |
96035 |
if (aa.groupRef != null && aa.groupRef.consensusData != null |
| 413 |
|
&& aa.groupRef.isShowSequenceLogo()) |
| 414 |
|
{ |
| 415 |
|
|
| 416 |
38871 |
return AAFrequency.extractProfile( |
| 417 |
|
aa.groupRef.consensusData.get(column), |
| 418 |
|
aa.groupRef.getIgnoreGapsConsensus()); |
| 419 |
|
} |
| 420 |
|
|
| 421 |
|
|
| 422 |
57164 |
if (aa.groupRef == null && aa.sequenceRef == null) |
| 423 |
|
{ |
| 424 |
57164 |
if (forComplement) |
| 425 |
|
{ |
| 426 |
0 |
return AAFrequency.extractCdnaProfile(complementConsensus[column], |
| 427 |
|
av_ignoreGapsConsensus); |
| 428 |
|
} |
| 429 |
|
else |
| 430 |
|
{ |
| 431 |
57164 |
return AAFrequency.extractProfile(hconsensus.get(column), |
| 432 |
|
av_ignoreGapsConsensus); |
| 433 |
|
} |
| 434 |
|
} |
| 435 |
|
} |
| 436 |
|
|
| 437 |
0 |
if (aa.autoCalculated && aa.label |
| 438 |
|
.startsWith(Constants.SECONDARY_STRUCTURE_CONSENSUS_LABEL)) |
| 439 |
|
{ |
| 440 |
|
|
| 441 |
0 |
if (aa.groupRef != null && aa.groupRef.hSSConsensusProfileMap != null |
| 442 |
|
&& aa.groupRef.isShowSequenceLogo()) |
| 443 |
|
{ |
| 444 |
0 |
for (String source : aa.groupRef.hSSConsensusProfileMap.keySet()) |
| 445 |
|
{ |
| 446 |
0 |
if (aa.description.startsWith(source)) |
| 447 |
|
{ |
| 448 |
|
|
| 449 |
0 |
return AAFrequency |
| 450 |
|
.extractProfile( |
| 451 |
|
aa.groupRef.hSSConsensusProfileMap.get(source) |
| 452 |
|
.get(column), |
| 453 |
|
aa.groupRef.getIgnoreGapsConsensus()); |
| 454 |
|
} |
| 455 |
|
} |
| 456 |
|
} |
| 457 |
|
|
| 458 |
0 |
if (hSSconsensus != null && aa.groupRef == null) |
| 459 |
|
{ |
| 460 |
0 |
for (String source : hSSconsensus.keySet()) |
| 461 |
|
{ |
| 462 |
0 |
if (aa.description.startsWith(source)) |
| 463 |
|
{ |
| 464 |
|
|
| 465 |
0 |
return AAFrequency.extractProfile( |
| 466 |
|
hSSconsensus.get(source).get(column), |
| 467 |
|
av_ignoreGapsConsensus); |
| 468 |
|
} |
| 469 |
|
} |
| 470 |
|
} |
| 471 |
|
|
| 472 |
|
} |
| 473 |
|
|
| 474 |
0 |
if (aa.autoCalculated && aa.label.startsWith("StrucConsensus")) |
| 475 |
|
{ |
| 476 |
|
|
| 477 |
|
|
| 478 |
|
|
| 479 |
|
|
| 480 |
|
|
| 481 |
|
|
| 482 |
|
|
| 483 |
|
|
| 484 |
|
|
| 485 |
|
|
| 486 |
|
|
| 487 |
0 |
if (aa.groupRef == null && aa.sequenceRef == null |
| 488 |
|
&& hStrucConsensus != null && hStrucConsensus.length > column) |
| 489 |
|
{ |
| 490 |
0 |
return StructureFrequency.extractProfile(hStrucConsensus[column], |
| 491 |
|
av_ignoreGapsConsensus); |
| 492 |
|
} |
| 493 |
|
} |
| 494 |
|
|
| 495 |
0 |
return null; |
| 496 |
|
} |
| 497 |
|
|
| 498 |
|
boolean rna = false; |
| 499 |
|
|
| 500 |
|
private AnnotationRendererFactoryI rendererFactoryI; |
| 501 |
|
|
| 502 |
|
|
| 503 |
|
|
| 504 |
|
|
| 505 |
|
@param |
| 506 |
|
|
| 507 |
|
@param |
| 508 |
|
|
| 509 |
|
@param |
| 510 |
|
|
| 511 |
|
@param |
| 512 |
|
|
| 513 |
|
@param |
| 514 |
|
|
| 515 |
|
@param |
| 516 |
|
|
| 517 |
|
@return |
| 518 |
|
|
| 519 |
|
|
| |
|
| 52% |
Uncovered Elements: 245 (510) |
Complexity: 229 |
Complexity Density: 0.65 |
|
| 520 |
2735 |
public boolean drawComponent(AwtRenderPanelI annotPanel,... |
| 521 |
|
AlignViewportI av, Graphics g, int activeRow, int startRes, |
| 522 |
|
int endRes) |
| 523 |
|
{ |
| 524 |
2735 |
if (g instanceof EpsGraphics2D || g instanceof SVGGraphics2D) |
| 525 |
|
{ |
| 526 |
14 |
this.setVectorRendering(true); |
| 527 |
|
} |
| 528 |
2735 |
Graphics2D g2d = (Graphics2D) g; |
| 529 |
|
|
| 530 |
2735 |
long stime = System.currentTimeMillis(); |
| 531 |
2735 |
boolean usedFaded = false; |
| 532 |
|
|
| 533 |
|
|
| 534 |
|
|
| 535 |
2735 |
updateFromAwtRenderPanel(annotPanel, av); |
| 536 |
2735 |
fm = g.getFontMetrics(); |
| 537 |
2735 |
AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation(); |
| 538 |
|
|
| 539 |
2735 |
if (aa == null) |
| 540 |
|
{ |
| 541 |
0 |
return false; |
| 542 |
|
} |
| 543 |
2735 |
int x = 0, y = 0; |
| 544 |
2735 |
int column = 0; |
| 545 |
2735 |
char lastSS; |
| 546 |
2735 |
int lastSSX; |
| 547 |
2735 |
int iconOffset = 0; |
| 548 |
2735 |
boolean validRes = false; |
| 549 |
2735 |
boolean validEnd = false; |
| 550 |
2735 |
boolean labelAllCols = false; |
| 551 |
|
|
| 552 |
|
|
| 553 |
2735 |
boolean scaleColLabel = false; |
| 554 |
2735 |
final AlignmentAnnotation consensusAnnot = av |
| 555 |
|
.getAlignmentConsensusAnnotation(); |
| 556 |
2735 |
final AlignmentAnnotation structConsensusAnnot = av |
| 557 |
|
.getAlignmentStrucConsensusAnnotation(); |
| 558 |
2735 |
final AlignmentAnnotation complementConsensusAnnot = av |
| 559 |
|
.getComplementConsensusAnnotation(); |
| 560 |
2735 |
final List<AlignmentAnnotation> ssConsensusAnnot = av |
| 561 |
|
.getAlignmentSecondaryStructureConsensusAnnotation(); |
| 562 |
|
|
| 563 |
2735 |
BitSet graphGroupDrawn = new BitSet(); |
| 564 |
2735 |
int charOffset = 0; |
| 565 |
|
|
| 566 |
|
|
| 567 |
2735 |
int yfrom = 0, f_i = 0, yto = 0, f_to = 0; |
| 568 |
2735 |
boolean clipst = false, clipend = false; |
| 569 |
17812 |
for (int i = 0; i < aa.length; i++) |
| 570 |
|
{ |
| 571 |
15082 |
AlignmentAnnotation row = aa[i]; |
| 572 |
15082 |
boolean renderHistogram = true; |
| 573 |
15082 |
boolean renderProfile = false; |
| 574 |
15082 |
boolean normaliseProfile = false; |
| 575 |
15082 |
boolean isRNA = row.isRNA(); |
| 576 |
|
|
| 577 |
|
|
| 578 |
|
|
| 579 |
|
|
| 580 |
|
|
| 581 |
15082 |
if (row.groupRef != null && (row == row.groupRef.getConsensus() |
| 582 |
|
|| (row.groupRef.getSSConsensus(null) != null |
| 583 |
|
&& row.groupRef.getSSConsensus(null).contains(row)))) |
| 584 |
|
{ |
| 585 |
618 |
renderHistogram = row.groupRef.isShowConsensusHistogram(); |
| 586 |
618 |
renderProfile = row.groupRef.isShowSequenceLogo(); |
| 587 |
618 |
normaliseProfile = row.groupRef.isNormaliseSequenceLogo(); |
| 588 |
|
} |
| 589 |
14464 |
else if (row == consensusAnnot || row == structConsensusAnnot |
| 590 |
|
|| row == complementConsensusAnnot |
| 591 |
|
|| (ssConsensusAnnot != null |
| 592 |
|
&& ssConsensusAnnot.contains(row))) |
| 593 |
|
{ |
| 594 |
2730 |
renderHistogram = av_renderHistogram; |
| 595 |
2730 |
renderProfile = av_renderProfile; |
| 596 |
2730 |
normaliseProfile = av_normaliseProfile; |
| 597 |
|
} |
| 598 |
|
|
| 599 |
15082 |
Annotation[] row_annotations = row.annotations; |
| 600 |
15082 |
if (!row.isForDisplay()) |
| 601 |
|
{ |
| 602 |
1756 |
continue; |
| 603 |
|
} |
| 604 |
|
|
| 605 |
13326 |
labelAllCols = row.showAllColLabels; |
| 606 |
13326 |
scaleColLabel = row.scaleColLabel; |
| 607 |
13326 |
lastSS = ' '; |
| 608 |
13326 |
lastSSX = 0; |
| 609 |
|
|
| 610 |
13326 |
if (!useClip || ((y - charHeight) < visHeight |
| 611 |
|
&& (y + row.height + charHeight * 2) >= sOffset)) |
| 612 |
|
{ |
| 613 |
13326 |
if (!clipst) |
| 614 |
|
{ |
| 615 |
2722 |
clipst = true; |
| 616 |
2722 |
yfrom = y; |
| 617 |
2722 |
f_i = i; |
| 618 |
|
} |
| 619 |
13326 |
yto = y; |
| 620 |
13326 |
f_to = i; |
| 621 |
13326 |
if (row.graph > 0) |
| 622 |
|
{ |
| 623 |
11480 |
if (row.graphGroup > -1 && graphGroupDrawn.get(row.graphGroup)) |
| 624 |
|
{ |
| 625 |
0 |
continue; |
| 626 |
|
} |
| 627 |
|
|
| 628 |
|
|
| 629 |
11480 |
y += row.height; |
| 630 |
|
|
| 631 |
11480 |
if (row.hasText) |
| 632 |
|
{ |
| 633 |
10449 |
iconOffset = charHeight - fm.getDescent(); |
| 634 |
10449 |
y -= charHeight; |
| 635 |
|
} |
| 636 |
|
} |
| 637 |
1846 |
else if (row.hasText) |
| 638 |
|
{ |
| 639 |
1121 |
iconOffset = charHeight - fm.getDescent(); |
| 640 |
|
|
| 641 |
|
} |
| 642 |
|
else |
| 643 |
|
{ |
| 644 |
725 |
iconOffset = 0; |
| 645 |
|
} |
| 646 |
|
|
| 647 |
13326 |
if (row.autoCalculated && av.isCalculationInProgress(row)) |
| 648 |
|
{ |
| 649 |
404 |
y += charHeight; |
| 650 |
404 |
usedFaded = true; |
| 651 |
404 |
g.drawImage(fadedImage, 0, y - row.height, imgWidth, y, 0, |
| 652 |
|
y - row.height, imgWidth, y, annotationPanel); |
| 653 |
399 |
g.setColor(Color.black); |
| 654 |
|
|
| 655 |
|
|
| 656 |
399 |
continue; |
| 657 |
|
} |
| 658 |
|
|
| 659 |
|
|
| 660 |
|
|
| 661 |
|
|
| 662 |
|
|
| 663 |
|
|
| 664 |
|
|
| 665 |
|
|
| 666 |
|
|
| 667 |
|
|
| 668 |
|
|
| 669 |
|
|
| 670 |
|
|
| 671 |
|
|
| 672 |
|
|
| 673 |
|
|
| 674 |
|
|
| 675 |
|
|
| 676 |
|
|
| 677 |
|
|
| 678 |
|
|
| 679 |
|
|
| 680 |
|
|
| 681 |
|
|
| 682 |
|
|
| 683 |
|
|
| 684 |
|
|
| 685 |
|
|
| 686 |
|
|
| 687 |
12922 |
this.glyphLineDrawn = false; |
| 688 |
12922 |
x = (startRes == 0) ? 0 : -1; |
| 689 |
637356 |
while (x < endRes - startRes) |
| 690 |
|
{ |
| 691 |
624434 |
if (hasHiddenColumns) |
| 692 |
|
{ |
| 693 |
130020 |
column = hiddenColumns.visibleToAbsoluteColumn(startRes + x); |
| 694 |
130020 |
if (column > row_annotations.length - 1) |
| 695 |
|
{ |
| 696 |
0 |
break; |
| 697 |
|
} |
| 698 |
|
} |
| 699 |
|
else |
| 700 |
|
{ |
| 701 |
494414 |
column = startRes + x; |
| 702 |
|
} |
| 703 |
|
|
| 704 |
624434 |
if ((row_annotations == null) |
| 705 |
|
|| (row_annotations.length <= column) |
| 706 |
|
|| (row_annotations[column] == null)) |
| 707 |
|
{ |
| 708 |
116586 |
validRes = false; |
| 709 |
|
} |
| 710 |
|
else |
| 711 |
|
{ |
| 712 |
507848 |
validRes = true; |
| 713 |
|
} |
| 714 |
624434 |
final String displayChar = validRes |
| 715 |
|
? row_annotations[column].displayCharacter |
| 716 |
|
: null; |
| 717 |
624434 |
if (x > -1) |
| 718 |
|
{ |
| 719 |
620322 |
unsetAntialias(g); |
| 720 |
620322 |
if (activeRow == i) |
| 721 |
|
{ |
| 722 |
0 |
g.setColor(Color.red); |
| 723 |
|
|
| 724 |
0 |
if (columnSelection != null) |
| 725 |
|
{ |
| 726 |
0 |
if (columnSelection.contains(column)) |
| 727 |
|
{ |
| 728 |
0 |
fillRect(g, x * charWidth, y, charWidth, charHeight); |
| 729 |
|
} |
| 730 |
|
} |
| 731 |
|
} |
| 732 |
620322 |
if (row.getInvalidStrucPos() > x) |
| 733 |
|
{ |
| 734 |
0 |
g.setColor(Color.orange); |
| 735 |
0 |
fillRect(g, x * charWidth, y, charWidth, charHeight); |
| 736 |
|
} |
| 737 |
620322 |
else if (row.getInvalidStrucPos() == x) |
| 738 |
|
{ |
| 739 |
0 |
g.setColor(Color.orange.darker()); |
| 740 |
0 |
fillRect(g, x * charWidth, y, charWidth, charHeight); |
| 741 |
|
} |
| 742 |
620322 |
if (validCharWidth && validRes && displayChar != null |
| 743 |
|
&& (displayChar.length() > 0)) |
| 744 |
|
{ |
| 745 |
|
|
| 746 |
356394 |
float fmWidth = fm.charsWidth(displayChar.toCharArray(), 0, |
| 747 |
|
displayChar.length()); |
| 748 |
|
|
| 749 |
|
|
| 750 |
|
|
| 751 |
|
|
| 752 |
|
|
| 753 |
356394 |
boolean scaledToFit = false; |
| 754 |
356394 |
float fmScaling = 1f; |
| 755 |
356394 |
if (scaleColLabel && fmWidth > charWidth) |
| 756 |
|
{ |
| 757 |
0 |
scaledToFit = true; |
| 758 |
0 |
fmScaling = charWidth; |
| 759 |
0 |
fmScaling /= fmWidth; |
| 760 |
|
|
| 761 |
0 |
fmWidth = charWidth; |
| 762 |
|
} |
| 763 |
|
|
| 764 |
356394 |
charOffset = (int) ((charWidth - fmWidth) / 2f); |
| 765 |
|
|
| 766 |
356394 |
if (row_annotations[column].colour == null) |
| 767 |
|
{ |
| 768 |
151019 |
g2d.setColor(Color.black); |
| 769 |
|
} |
| 770 |
|
else |
| 771 |
|
{ |
| 772 |
205375 |
g2d.setColor(row_annotations[column].colour); |
| 773 |
|
} |
| 774 |
|
|
| 775 |
|
|
| 776 |
|
|
| 777 |
|
|
| 778 |
|
|
| 779 |
356394 |
final int xPos = (x * charWidth) + charOffset; |
| 780 |
356394 |
final int yPos = y + iconOffset; |
| 781 |
|
|
| 782 |
|
|
| 783 |
|
|
| 784 |
|
|
| 785 |
356394 |
g2d.translate(xPos, yPos); |
| 786 |
356394 |
if (scaledToFit) |
| 787 |
|
{ |
| 788 |
|
|
| 789 |
|
|
| 790 |
|
|
| 791 |
|
|
| 792 |
0 |
g2d.transform( |
| 793 |
|
AffineTransform.getScaleInstance(fmScaling, 1.0)); |
| 794 |
|
} |
| 795 |
356394 |
setAntialias(g); |
| 796 |
356394 |
if (column == 0 || row.graph > 0) |
| 797 |
|
{ |
| 798 |
350480 |
g2d.drawString(displayChar, 0, 0); |
| 799 |
|
} |
| 800 |
5914 |
else if (row_annotations[column - 1] == null || (labelAllCols |
| 801 |
|
|| !displayChar.equals( |
| 802 |
|
row_annotations[column - 1].displayCharacter) |
| 803 |
|
|| (displayChar.length() < 2 |
| 804 |
|
&& row_annotations[column].secondaryStructure == ' '))) |
| 805 |
|
{ |
| 806 |
5738 |
g2d.drawString(displayChar, 0, 0); |
| 807 |
|
} |
| 808 |
356394 |
if (scaledToFit) |
| 809 |
|
{ |
| 810 |
|
|
| 811 |
|
|
| 812 |
|
|
| 813 |
|
|
| 814 |
0 |
g2d.transform(AffineTransform |
| 815 |
|
.getScaleInstance(1D / fmScaling, 1.0)); |
| 816 |
|
} |
| 817 |
356394 |
g2d.translate(-xPos, -yPos); |
| 818 |
|
} |
| 819 |
|
} |
| 820 |
624434 |
if (row.hasIcons) |
| 821 |
|
{ |
| 822 |
73133 |
char ss = validRes ? row_annotations[column].secondaryStructure |
| 823 |
|
: '-'; |
| 824 |
|
|
| 825 |
73133 |
if (ss == '(') |
| 826 |
|
{ |
| 827 |
|
|
| 828 |
0 |
if (displayChar.indexOf(')') > -1) |
| 829 |
|
{ |
| 830 |
|
|
| 831 |
0 |
ss = ')'; |
| 832 |
|
|
| 833 |
|
} |
| 834 |
|
} |
| 835 |
73133 |
if (ss == '[') |
| 836 |
|
{ |
| 837 |
0 |
if ((displayChar.indexOf(']') > -1)) |
| 838 |
|
{ |
| 839 |
0 |
ss = ']'; |
| 840 |
|
|
| 841 |
|
} |
| 842 |
|
} |
| 843 |
73133 |
if (ss == '{') |
| 844 |
|
{ |
| 845 |
|
|
| 846 |
0 |
if (displayChar.indexOf('}') > -1) |
| 847 |
|
{ |
| 848 |
0 |
ss = '}'; |
| 849 |
|
|
| 850 |
|
} |
| 851 |
|
} |
| 852 |
73133 |
if (ss == '<') |
| 853 |
|
{ |
| 854 |
|
|
| 855 |
0 |
if (displayChar.indexOf('<') > -1) |
| 856 |
|
{ |
| 857 |
0 |
ss = '>'; |
| 858 |
|
|
| 859 |
|
} |
| 860 |
|
} |
| 861 |
73133 |
if (isRNA && (ss >= CHAR_A) && (ss <= CHAR_Z)) |
| 862 |
|
{ |
| 863 |
|
|
| 864 |
0 |
int ssLowerCase = ss + UPPER_TO_LOWER; |
| 865 |
|
|
| 866 |
0 |
if (displayChar.indexOf(ssLowerCase) > -1) |
| 867 |
|
{ |
| 868 |
0 |
ss = (char) ssLowerCase; |
| 869 |
|
} |
| 870 |
|
} |
| 871 |
|
|
| 872 |
73133 |
if (!validRes || (ss != lastSS)) |
| 873 |
|
{ |
| 874 |
|
|
| 875 |
58011 |
if (x > -1) |
| 876 |
|
{ |
| 877 |
|
|
| 878 |
|
|
| 879 |
|
|
| 880 |
|
|
| 881 |
|
|
| 882 |
57224 |
switch (lastSS) |
| 883 |
|
{ |
| 884 |
0 |
case '(': |
| 885 |
0 |
case ')': |
| 886 |
0 |
drawStemAnnot(g, row_annotations, lastSSX, x, y, |
| 887 |
|
iconOffset, startRes, column, validRes, validEnd); |
| 888 |
|
|
| 889 |
0 |
break; |
| 890 |
|
|
| 891 |
775 |
case 'H': |
| 892 |
775 |
if (!isRNA) |
| 893 |
|
{ |
| 894 |
775 |
drawHelixAnnot(g, row_annotations, lastSSX, x, y, |
| 895 |
|
iconOffset, startRes, column, validRes, |
| 896 |
|
validEnd); |
| 897 |
775 |
break; |
| 898 |
|
} |
| 899 |
|
|
| 900 |
4103 |
case 'E': |
| 901 |
4103 |
if (!isRNA) |
| 902 |
|
{ |
| 903 |
4103 |
drawSheetAnnot(g, row_annotations, lastSSX, x, y, |
| 904 |
|
iconOffset, startRes, column, validRes, |
| 905 |
|
validEnd); |
| 906 |
4103 |
break; |
| 907 |
|
} |
| 908 |
|
|
| 909 |
|
|
| 910 |
0 |
case '{': |
| 911 |
0 |
case '}': |
| 912 |
0 |
case '[': |
| 913 |
0 |
case ']': |
| 914 |
0 |
case '>': |
| 915 |
0 |
case '<': |
| 916 |
0 |
case 'A': |
| 917 |
0 |
case 'a': |
| 918 |
0 |
case 'B': |
| 919 |
0 |
case 'b': |
| 920 |
0 |
case 'C': |
| 921 |
0 |
case 'c': |
| 922 |
0 |
case 'D': |
| 923 |
0 |
case 'd': |
| 924 |
0 |
case 'e': |
| 925 |
0 |
case 'F': |
| 926 |
0 |
case 'f': |
| 927 |
0 |
case 'G': |
| 928 |
0 |
case 'g': |
| 929 |
0 |
case 'h': |
| 930 |
0 |
case 'I': |
| 931 |
0 |
case 'i': |
| 932 |
0 |
case 'J': |
| 933 |
0 |
case 'j': |
| 934 |
0 |
case 'K': |
| 935 |
0 |
case 'k': |
| 936 |
0 |
case 'L': |
| 937 |
0 |
case 'l': |
| 938 |
0 |
case 'M': |
| 939 |
0 |
case 'm': |
| 940 |
0 |
case 'N': |
| 941 |
0 |
case 'n': |
| 942 |
0 |
case 'O': |
| 943 |
0 |
case 'o': |
| 944 |
0 |
case 'P': |
| 945 |
0 |
case 'p': |
| 946 |
0 |
case 'Q': |
| 947 |
0 |
case 'q': |
| 948 |
0 |
case 'R': |
| 949 |
0 |
case 'r': |
| 950 |
0 |
case 'S': |
| 951 |
0 |
case 's': |
| 952 |
0 |
case 'T': |
| 953 |
0 |
case 't': |
| 954 |
0 |
case 'U': |
| 955 |
0 |
case 'u': |
| 956 |
0 |
case 'V': |
| 957 |
0 |
case 'v': |
| 958 |
0 |
case 'W': |
| 959 |
0 |
case 'w': |
| 960 |
0 |
case 'X': |
| 961 |
0 |
case 'x': |
| 962 |
0 |
case 'Y': |
| 963 |
0 |
case 'y': |
| 964 |
0 |
case 'Z': |
| 965 |
0 |
case 'z': |
| 966 |
|
|
| 967 |
0 |
Color nonCanColor = getNotCanonicalColor(lastSS); |
| 968 |
0 |
drawNotCanonicalAnnot(g, nonCanColor, row_annotations, |
| 969 |
|
lastSSX, x, y, iconOffset, startRes, column, |
| 970 |
|
validRes, validEnd); |
| 971 |
|
|
| 972 |
0 |
break; |
| 973 |
52346 |
default: |
| 974 |
52346 |
if (isVectorRendering()) |
| 975 |
|
{ |
| 976 |
|
|
| 977 |
0 |
drawGlyphLine(g, lastSSX, endRes - x, y, iconOffset); |
| 978 |
|
|
| 979 |
0 |
this.glyphLineDrawn = true; |
| 980 |
|
} |
| 981 |
|
else |
| 982 |
|
{ |
| 983 |
52346 |
drawGlyphLine(g, lastSSX, x, y, iconOffset); |
| 984 |
|
} |
| 985 |
52346 |
break; |
| 986 |
|
} |
| 987 |
|
} |
| 988 |
58011 |
if (validRes) |
| 989 |
|
{ |
| 990 |
5304 |
lastSS = ss; |
| 991 |
|
} |
| 992 |
|
else |
| 993 |
|
{ |
| 994 |
52707 |
lastSS = ' '; |
| 995 |
|
} |
| 996 |
58011 |
if (x > -1) |
| 997 |
|
{ |
| 998 |
57224 |
lastSSX = (x * charWidth); |
| 999 |
|
} |
| 1000 |
|
} |
| 1001 |
|
} |
| 1002 |
624434 |
column++; |
| 1003 |
624434 |
x++; |
| 1004 |
|
} |
| 1005 |
12922 |
if (column >= row_annotations.length) |
| 1006 |
|
{ |
| 1007 |
2298 |
column = row_annotations.length - 1; |
| 1008 |
2298 |
validEnd = false; |
| 1009 |
|
} |
| 1010 |
|
else |
| 1011 |
|
{ |
| 1012 |
10624 |
validEnd = true; |
| 1013 |
|
} |
| 1014 |
12922 |
if ((row_annotations == null) || (row_annotations.length <= column) |
| 1015 |
|
|| (row_annotations[column] == null)) |
| 1016 |
|
{ |
| 1017 |
2341 |
validRes = false; |
| 1018 |
|
} |
| 1019 |
|
else |
| 1020 |
|
{ |
| 1021 |
10581 |
validRes = true; |
| 1022 |
|
} |
| 1023 |
|
|
| 1024 |
|
|
| 1025 |
12922 |
if (row.hasIcons) |
| 1026 |
|
{ |
| 1027 |
1274 |
switch (lastSS) |
| 1028 |
|
{ |
| 1029 |
|
|
| 1030 |
7 |
case 'H': |
| 1031 |
7 |
if (!isRNA) |
| 1032 |
|
{ |
| 1033 |
7 |
drawHelixAnnot(g, row_annotations, lastSSX, x, y, iconOffset, |
| 1034 |
|
startRes, column, validRes, validEnd); |
| 1035 |
7 |
break; |
| 1036 |
|
} |
| 1037 |
|
|
| 1038 |
|
|
| 1039 |
115 |
case 'E': |
| 1040 |
115 |
if (!isRNA) |
| 1041 |
|
{ |
| 1042 |
115 |
drawSheetAnnot(g, row_annotations, lastSSX, x, y, iconOffset, |
| 1043 |
|
startRes, column, validRes, validEnd); |
| 1044 |
115 |
break; |
| 1045 |
|
} |
| 1046 |
|
|
| 1047 |
|
|
| 1048 |
0 |
case '(': |
| 1049 |
0 |
case ')': |
| 1050 |
|
|
| 1051 |
0 |
drawStemAnnot(g, row_annotations, lastSSX, x, y, iconOffset, |
| 1052 |
|
startRes, column, validRes, validEnd); |
| 1053 |
|
|
| 1054 |
0 |
break; |
| 1055 |
0 |
case '{': |
| 1056 |
0 |
case '}': |
| 1057 |
0 |
case '[': |
| 1058 |
0 |
case ']': |
| 1059 |
0 |
case '>': |
| 1060 |
0 |
case '<': |
| 1061 |
0 |
case 'A': |
| 1062 |
0 |
case 'a': |
| 1063 |
0 |
case 'B': |
| 1064 |
0 |
case 'b': |
| 1065 |
0 |
case 'C': |
| 1066 |
0 |
case 'c': |
| 1067 |
0 |
case 'D': |
| 1068 |
0 |
case 'd': |
| 1069 |
0 |
case 'e': |
| 1070 |
0 |
case 'F': |
| 1071 |
0 |
case 'f': |
| 1072 |
0 |
case 'G': |
| 1073 |
0 |
case 'g': |
| 1074 |
0 |
case 'h': |
| 1075 |
0 |
case 'I': |
| 1076 |
0 |
case 'i': |
| 1077 |
0 |
case 'J': |
| 1078 |
0 |
case 'j': |
| 1079 |
0 |
case 'K': |
| 1080 |
0 |
case 'k': |
| 1081 |
0 |
case 'L': |
| 1082 |
0 |
case 'l': |
| 1083 |
0 |
case 'M': |
| 1084 |
0 |
case 'm': |
| 1085 |
0 |
case 'N': |
| 1086 |
0 |
case 'n': |
| 1087 |
0 |
case 'O': |
| 1088 |
0 |
case 'o': |
| 1089 |
0 |
case 'P': |
| 1090 |
0 |
case 'p': |
| 1091 |
0 |
case 'Q': |
| 1092 |
0 |
case 'q': |
| 1093 |
0 |
case 'R': |
| 1094 |
0 |
case 'r': |
| 1095 |
0 |
case 'T': |
| 1096 |
0 |
case 't': |
| 1097 |
0 |
case 'U': |
| 1098 |
0 |
case 'u': |
| 1099 |
0 |
case 'V': |
| 1100 |
0 |
case 'v': |
| 1101 |
0 |
case 'W': |
| 1102 |
0 |
case 'w': |
| 1103 |
0 |
case 'X': |
| 1104 |
0 |
case 'x': |
| 1105 |
0 |
case 'Y': |
| 1106 |
0 |
case 'y': |
| 1107 |
0 |
case 'Z': |
| 1108 |
0 |
case 'z': |
| 1109 |
|
|
| 1110 |
0 |
Color nonCanColor = getNotCanonicalColor(lastSS); |
| 1111 |
0 |
drawNotCanonicalAnnot(g, nonCanColor, row_annotations, lastSSX, |
| 1112 |
|
x, y, iconOffset, startRes, column, validRes, validEnd); |
| 1113 |
0 |
break; |
| 1114 |
1152 |
default: |
| 1115 |
1152 |
if (isVectorRendering()) |
| 1116 |
|
{ |
| 1117 |
|
|
| 1118 |
0 |
drawGlyphLine(g, lastSSX, endRes - x, y, iconOffset); |
| 1119 |
|
|
| 1120 |
0 |
this.glyphLineDrawn = true; |
| 1121 |
|
} |
| 1122 |
|
else |
| 1123 |
|
{ |
| 1124 |
1152 |
drawGlyphLine(g, lastSSX, x, y, iconOffset); |
| 1125 |
|
} |
| 1126 |
1152 |
break; |
| 1127 |
|
} |
| 1128 |
|
} |
| 1129 |
|
|
| 1130 |
12922 |
if (row.graph > 0 && row.graphHeight > 0) |
| 1131 |
|
{ |
| 1132 |
11076 |
if (row.graph == AlignmentAnnotation.LINE_GRAPH) |
| 1133 |
|
{ |
| 1134 |
736 |
if (row.graphGroup > -1 && !graphGroupDrawn.get(row.graphGroup)) |
| 1135 |
|
{ |
| 1136 |
|
|
| 1137 |
|
|
| 1138 |
0 |
float groupmax = -999999, groupmin = 9999999; |
| 1139 |
0 |
for (int gg = 0; gg < aa.length; gg++) |
| 1140 |
|
{ |
| 1141 |
0 |
if (aa[gg].graphGroup != row.graphGroup) |
| 1142 |
|
{ |
| 1143 |
0 |
continue; |
| 1144 |
|
} |
| 1145 |
|
|
| 1146 |
0 |
if (aa[gg] != row) |
| 1147 |
|
{ |
| 1148 |
0 |
aa[gg].visible = false; |
| 1149 |
|
} |
| 1150 |
0 |
if (aa[gg].graphMax > groupmax) |
| 1151 |
|
{ |
| 1152 |
0 |
groupmax = aa[gg].graphMax; |
| 1153 |
|
} |
| 1154 |
0 |
if (aa[gg].graphMin < groupmin) |
| 1155 |
|
{ |
| 1156 |
0 |
groupmin = aa[gg].graphMin; |
| 1157 |
|
} |
| 1158 |
|
} |
| 1159 |
|
|
| 1160 |
0 |
for (int gg = 0; gg < aa.length; gg++) |
| 1161 |
|
{ |
| 1162 |
0 |
if (aa[gg].graphGroup == row.graphGroup) |
| 1163 |
|
{ |
| 1164 |
0 |
drawLineGraph(g, aa[gg], aa[gg].annotations, startRes, |
| 1165 |
|
endRes, y, groupmin, groupmax, row.graphHeight); |
| 1166 |
|
} |
| 1167 |
|
} |
| 1168 |
|
|
| 1169 |
0 |
graphGroupDrawn.set(row.graphGroup); |
| 1170 |
|
} |
| 1171 |
|
else |
| 1172 |
|
{ |
| 1173 |
736 |
drawLineGraph(g, row, row_annotations, startRes, endRes, y, |
| 1174 |
|
row.graphMin, row.graphMax, row.graphHeight); |
| 1175 |
|
} |
| 1176 |
|
} |
| 1177 |
10340 |
else if (row.graph == AlignmentAnnotation.BAR_GRAPH) |
| 1178 |
|
{ |
| 1179 |
10040 |
drawBarGraph(g, row, row_annotations, startRes, endRes, |
| 1180 |
|
row.graphMin, row.graphMax, y, renderHistogram, |
| 1181 |
|
renderProfile, normaliseProfile); |
| 1182 |
|
} |
| 1183 |
|
else |
| 1184 |
|
{ |
| 1185 |
300 |
AnnotationRowRendererI renderer = rendererFactoryI |
| 1186 |
|
.getRendererFor(row); |
| 1187 |
300 |
if (renderer != null) |
| 1188 |
|
{ |
| 1189 |
300 |
renderer.renderRow(g, charWidth, charHeight, hasHiddenColumns, |
| 1190 |
|
av, hiddenColumns, columnSelection, row, |
| 1191 |
|
row_annotations, startRes, endRes, row.graphMin, |
| 1192 |
|
row.graphMax, y); |
| 1193 |
|
} |
| 1194 |
300 |
if (debugRedraw) |
| 1195 |
|
{ |
| 1196 |
0 |
if (renderer == null) |
| 1197 |
|
{ |
| 1198 |
0 |
System.err |
| 1199 |
|
.println("No renderer found for " + row.toString()); |
| 1200 |
|
} |
| 1201 |
|
else |
| 1202 |
|
{ |
| 1203 |
0 |
Console.warn( |
| 1204 |
|
"rendered with " + renderer.getClass().toString()); |
| 1205 |
|
} |
| 1206 |
|
} |
| 1207 |
|
|
| 1208 |
|
} |
| 1209 |
|
} |
| 1210 |
|
} |
| 1211 |
|
else |
| 1212 |
|
{ |
| 1213 |
0 |
if (clipst && !clipend) |
| 1214 |
|
{ |
| 1215 |
0 |
clipend = true; |
| 1216 |
|
} |
| 1217 |
|
} |
| 1218 |
12922 |
if (row.graph > 0 && row.hasText) |
| 1219 |
|
{ |
| 1220 |
10045 |
y += charHeight; |
| 1221 |
|
} |
| 1222 |
|
|
| 1223 |
12922 |
if (row.graph == 0) |
| 1224 |
|
{ |
| 1225 |
1846 |
y += aa[i].height; |
| 1226 |
|
} |
| 1227 |
|
} |
| 1228 |
2730 |
if (debugRedraw) |
| 1229 |
|
{ |
| 1230 |
0 |
if (canClip) |
| 1231 |
|
{ |
| 1232 |
0 |
if (clipst) |
| 1233 |
|
{ |
| 1234 |
0 |
Console.warn("Start clip at : " + yfrom + " (index " + f_i + ")"); |
| 1235 |
|
} |
| 1236 |
0 |
if (clipend) |
| 1237 |
|
{ |
| 1238 |
0 |
Console.warn("End clip at : " + yto + " (index " + f_to + ")"); |
| 1239 |
|
} |
| 1240 |
|
} |
| 1241 |
0 |
; |
| 1242 |
0 |
Console.warn("Annotation Rendering time:" |
| 1243 |
|
+ (System.currentTimeMillis() - stime)); |
| 1244 |
|
} |
| 1245 |
2730 |
; |
| 1246 |
|
|
| 1247 |
2730 |
return !usedFaded; |
| 1248 |
|
} |
| 1249 |
|
|
| 1250 |
|
public static final Color GLYPHLINE_COLOR = Color.gray; |
| 1251 |
|
|
| 1252 |
|
public static final Color SHEET_COLOUR = Color.green; |
| 1253 |
|
|
| 1254 |
|
public static final Color HELIX_COLOUR = Color.red; |
| 1255 |
|
|
| 1256 |
|
public static final Color STEM_COLOUR = Color.blue; |
| 1257 |
|
|
| 1258 |
|
|
| 1259 |
|
|
| |
|
| 71.4% |
Uncovered Elements: 2 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 1260 |
58488 |
void drawGlyphLine(Graphics g, int lastSSX, int x, int y, int iconOffset)... |
| 1261 |
|
{ |
| 1262 |
58488 |
if (glyphLineDrawn) |
| 1263 |
|
{ |
| 1264 |
|
|
| 1265 |
|
|
| 1266 |
0 |
return; |
| 1267 |
|
} |
| 1268 |
58488 |
unsetAntialias(g); |
| 1269 |
58488 |
g.setColor(GLYPHLINE_COLOR); |
| 1270 |
58488 |
g.fillRect(lastSSX, y + 6 + iconOffset, (x * charWidth) - lastSSX, 2); |
| 1271 |
|
} |
| 1272 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 6 |
Complexity Density: 0.86 |
|
| 1273 |
4218 |
void drawSheetAnnot(Graphics g, Annotation[] row,... |
| 1274 |
|
|
| 1275 |
|
int lastSSX, int x, int y, int iconOffset, int startRes, |
| 1276 |
|
int column, boolean validRes, boolean validEnd) |
| 1277 |
|
{ |
| 1278 |
4218 |
if (!validEnd || !validRes || row == null || row[column] == null |
| 1279 |
|
|| row[column].secondaryStructure != 'E') |
| 1280 |
|
{ |
| 1281 |
|
|
| 1282 |
4208 |
drawGlyphLine(g, lastSSX, x, y, iconOffset); |
| 1283 |
|
|
| 1284 |
4208 |
g.setColor(SHEET_COLOUR); |
| 1285 |
4208 |
fillRect(g, lastSSX, y + 4 + iconOffset, |
| 1286 |
|
(x * charWidth) - lastSSX - 4, 6); |
| 1287 |
4208 |
fillPolygon(g, |
| 1288 |
|
new int[] |
| 1289 |
|
{ (x * charWidth) - 6, (x * charWidth) - 6, |
| 1290 |
|
(x * charWidth - 1) }, |
| 1291 |
|
new int[] |
| 1292 |
|
{ y + iconOffset + 1, y + 13 + iconOffset, |
| 1293 |
|
y + 7 + iconOffset }, |
| 1294 |
|
3); |
| 1295 |
|
} |
| 1296 |
|
else |
| 1297 |
|
{ |
| 1298 |
10 |
g.setColor(SHEET_COLOUR); |
| 1299 |
10 |
fillRect(g, lastSSX, y + 4 + iconOffset, (x * charWidth) - lastSSX, |
| 1300 |
|
6); |
| 1301 |
|
} |
| 1302 |
|
} |
| 1303 |
|
|
| |
|
| 55.3% |
Uncovered Elements: 17 (38) |
Complexity: 13 |
Complexity Density: 0.5 |
|
| 1304 |
782 |
void drawHelixAnnot(Graphics g, Annotation[] row, int lastSSX, int x,... |
| 1305 |
|
int y, int iconOffset, int startRes, int column, boolean validRes, |
| 1306 |
|
boolean validEnd) |
| 1307 |
|
{ |
| 1308 |
782 |
int sCol = (lastSSX / charWidth) |
| 1309 |
|
+ hiddenColumns.visibleToAbsoluteColumn(startRes); |
| 1310 |
782 |
int x1 = lastSSX; |
| 1311 |
782 |
int x2 = (x * charWidth); |
| 1312 |
|
|
| 1313 |
782 |
if (USE_FILL_ROUND_RECT || isVectorRendering()) |
| 1314 |
|
{ |
| 1315 |
|
|
| 1316 |
0 |
drawGlyphLine(g, lastSSX, x, y, iconOffset); |
| 1317 |
|
|
| 1318 |
0 |
g.setColor(HELIX_COLOUR); |
| 1319 |
0 |
setAntialias(g); |
| 1320 |
0 |
int ofs = charWidth / 2; |
| 1321 |
|
|
| 1322 |
|
|
| 1323 |
0 |
fillRoundRect(g, lastSSX, y + 3 + iconOffset, x2 - x1 - 1, 8, 8, 8); |
| 1324 |
0 |
if (sCol == 0 || row[sCol - 1] == null |
| 1325 |
|
|| row[sCol - 1].secondaryStructure != 'H') |
| 1326 |
|
{ |
| 1327 |
|
} |
| 1328 |
|
else |
| 1329 |
|
{ |
| 1330 |
0 |
fillRoundRect(g, lastSSX, y + 3 + iconOffset, x2 - x1 - ofs, 8, 0, |
| 1331 |
|
0); |
| 1332 |
|
} |
| 1333 |
0 |
if (!validRes || row[column] == null |
| 1334 |
|
|| row[column].secondaryStructure != 'H') |
| 1335 |
|
{ |
| 1336 |
|
|
| 1337 |
|
} |
| 1338 |
|
else |
| 1339 |
|
{ |
| 1340 |
0 |
fillRoundRect(g, lastSSX + ofs, y + 3 + iconOffset, x2 - x1 - ofs, |
| 1341 |
|
8, 0, 0); |
| 1342 |
|
} |
| 1343 |
|
|
| 1344 |
0 |
return; |
| 1345 |
|
} |
| 1346 |
|
|
| 1347 |
782 |
boolean leftEnd = sCol == 0 || row[sCol - 1] == null |
| 1348 |
|
|| row[sCol - 1].secondaryStructure != 'H'; |
| 1349 |
782 |
boolean rightEnd = !validRes || row[column] == null |
| 1350 |
|
|| row[column].secondaryStructure != 'H'; |
| 1351 |
|
|
| 1352 |
782 |
if (leftEnd || rightEnd) |
| 1353 |
|
{ |
| 1354 |
782 |
drawGlyphLine(g, lastSSX, x, y, iconOffset); |
| 1355 |
|
} |
| 1356 |
782 |
g.setColor(HELIX_COLOUR); |
| 1357 |
|
|
| 1358 |
782 |
if (leftEnd) |
| 1359 |
|
{ |
| 1360 |
782 |
fillArc(g, lastSSX, y + 3 + iconOffset, charWidth, 8, 90, 180); |
| 1361 |
782 |
x1 += charWidth / 2; |
| 1362 |
|
} |
| 1363 |
|
|
| 1364 |
782 |
if (rightEnd) |
| 1365 |
|
{ |
| 1366 |
775 |
fillArc(g, ((x - 1) * charWidth), y + 3 + iconOffset, charWidth, 8, |
| 1367 |
|
270, 180); |
| 1368 |
775 |
x2 -= charWidth / 2; |
| 1369 |
|
} |
| 1370 |
|
|
| 1371 |
782 |
fillRect(g, x1, y + 3 + iconOffset, x2 - x1, 8); |
| 1372 |
|
} |
| 1373 |
|
|
| |
|
| 80.5% |
Uncovered Elements: 15 (77) |
Complexity: 15 |
Complexity Density: 0.28 |
|
| 1374 |
736 |
void drawLineGraph(Graphics g, AlignmentAnnotation _aa,... |
| 1375 |
|
Annotation[] aa_annotations, int sRes, int eRes, int y, float min, |
| 1376 |
|
float max, int graphHeight) |
| 1377 |
|
{ |
| 1378 |
736 |
if (sRes > aa_annotations.length) |
| 1379 |
|
{ |
| 1380 |
0 |
return; |
| 1381 |
|
} |
| 1382 |
736 |
Stroke roundStroke = new BasicStroke(1, BasicStroke.CAP_ROUND, |
| 1383 |
|
BasicStroke.JOIN_ROUND); |
| 1384 |
736 |
Stroke squareStroke = new BasicStroke(1, BasicStroke.CAP_SQUARE, |
| 1385 |
|
BasicStroke.JOIN_MITER); |
| 1386 |
736 |
Graphics2D g2d = (Graphics2D) g; |
| 1387 |
736 |
Stroke prevStroke = g2d.getStroke(); |
| 1388 |
736 |
g2d.setStroke(roundStroke); |
| 1389 |
|
|
| 1390 |
736 |
int x = 0; |
| 1391 |
|
|
| 1392 |
|
|
| 1393 |
736 |
if (eRes < endRes) |
| 1394 |
|
{ |
| 1395 |
0 |
eRes++; |
| 1396 |
|
} |
| 1397 |
|
|
| 1398 |
736 |
eRes = Math.min(eRes, aa_annotations.length); |
| 1399 |
|
|
| 1400 |
736 |
if (sRes == 0) |
| 1401 |
|
{ |
| 1402 |
736 |
x++; |
| 1403 |
|
} |
| 1404 |
|
|
| 1405 |
736 |
int y1 = y, y2 = y; |
| 1406 |
736 |
float range = max - min; |
| 1407 |
|
|
| 1408 |
|
|
| 1409 |
736 |
if (min < 0) |
| 1410 |
|
{ |
| 1411 |
0 |
y2 = y - (int) ((0 - min / range) * graphHeight); |
| 1412 |
|
} |
| 1413 |
|
|
| 1414 |
736 |
g.setColor(Color.gray); |
| 1415 |
736 |
drawLine(g, squareStroke, x * charWidth - charWidth, y2, |
| 1416 |
|
(eRes - sRes) * charWidth, y2); |
| 1417 |
|
|
| 1418 |
736 |
eRes = Math.min(eRes, aa_annotations.length); |
| 1419 |
|
|
| 1420 |
736 |
int column; |
| 1421 |
736 |
int aaMax = aa_annotations.length - 1; |
| 1422 |
|
|
| 1423 |
35559 |
while (x < eRes - sRes) |
| 1424 |
|
{ |
| 1425 |
34823 |
column = sRes + x; |
| 1426 |
34823 |
if (hasHiddenColumns) |
| 1427 |
|
{ |
| 1428 |
8352 |
column = hiddenColumns.visibleToAbsoluteColumn(column); |
| 1429 |
|
} |
| 1430 |
|
|
| 1431 |
34823 |
if (column > aaMax) |
| 1432 |
|
{ |
| 1433 |
0 |
break; |
| 1434 |
|
} |
| 1435 |
|
|
| 1436 |
34823 |
if (aa_annotations[column] == null) |
| 1437 |
|
{ |
| 1438 |
17184 |
x++; |
| 1439 |
17184 |
continue; |
| 1440 |
|
} |
| 1441 |
|
|
| 1442 |
17639 |
if (aa_annotations[column].colour == null) |
| 1443 |
|
{ |
| 1444 |
4473 |
g.setColor(Color.black); |
| 1445 |
|
} |
| 1446 |
|
else |
| 1447 |
|
{ |
| 1448 |
13166 |
g.setColor(aa_annotations[column].colour); |
| 1449 |
|
} |
| 1450 |
|
|
| 1451 |
17639 |
if (aa_annotations[column - 1] == null |
| 1452 |
|
&& aa_annotations.length > column + 1 |
| 1453 |
|
&& aa_annotations[column + 1] == null) |
| 1454 |
|
{ |
| 1455 |
|
|
| 1456 |
1564 |
y1 = y - (int) (((aa_annotations[column].value - min) / range) |
| 1457 |
|
* graphHeight); |
| 1458 |
1564 |
drawLine(g, x * charWidth + charWidth / 4, y1, |
| 1459 |
|
x * charWidth + 3 * charWidth / 4, y1); |
| 1460 |
1564 |
x++; |
| 1461 |
1564 |
continue; |
| 1462 |
|
} |
| 1463 |
|
|
| 1464 |
16075 |
if (aa_annotations[column - 1] == null) |
| 1465 |
|
{ |
| 1466 |
580 |
x++; |
| 1467 |
580 |
continue; |
| 1468 |
|
} |
| 1469 |
|
|
| 1470 |
15495 |
y1 = y - (int) (((aa_annotations[column - 1].value - min) / range) |
| 1471 |
|
* graphHeight); |
| 1472 |
15495 |
y2 = y - (int) (((aa_annotations[column].value - min) / range) |
| 1473 |
|
* graphHeight); |
| 1474 |
|
|
| 1475 |
15495 |
drawLine(g, (x - 1) * charWidth + charWidth / 2, y1, |
| 1476 |
|
x * charWidth + charWidth / 2, y2); |
| 1477 |
15495 |
x++; |
| 1478 |
|
} |
| 1479 |
|
|
| 1480 |
736 |
if (_aa.threshold != null) |
| 1481 |
|
{ |
| 1482 |
0 |
g.setColor(_aa.threshold.colour); |
| 1483 |
0 |
Graphics2D g2 = (Graphics2D) g; |
| 1484 |
0 |
Stroke s = new BasicStroke(1, BasicStroke.CAP_SQUARE, |
| 1485 |
|
BasicStroke.JOIN_ROUND, 3f, new float[] |
| 1486 |
|
{ 5f, 3f }, 0f); |
| 1487 |
|
|
| 1488 |
0 |
y2 = (int) (y - ((_aa.threshold.value - min) / range) * graphHeight); |
| 1489 |
0 |
drawLine(g, s, 0, y2, (eRes - sRes) * charWidth, y2); |
| 1490 |
|
} |
| 1491 |
736 |
g2d.setStroke(prevStroke); |
| 1492 |
|
} |
| 1493 |
|
|
| |
|
| 70.2% |
Uncovered Elements: 42 (141) |
Complexity: 27 |
Complexity Density: 0.3 |
|
| 1494 |
10040 |
@SuppressWarnings("unused")... |
| 1495 |
|
void drawBarGraph(Graphics g, AlignmentAnnotation _aa, |
| 1496 |
|
Annotation[] aa_annotations, int sRes, int eRes, float min, |
| 1497 |
|
float max, int y, boolean renderHistogram, boolean renderProfile, |
| 1498 |
|
boolean normaliseProfile) |
| 1499 |
|
{ |
| 1500 |
10040 |
if (sRes > aa_annotations.length) |
| 1501 |
|
{ |
| 1502 |
0 |
return; |
| 1503 |
|
} |
| 1504 |
10040 |
Font ofont = g.getFont(); |
| 1505 |
10040 |
eRes = Math.min(eRes, aa_annotations.length); |
| 1506 |
|
|
| 1507 |
10040 |
int x = 0, y1 = y, y2 = y; |
| 1508 |
|
|
| 1509 |
10040 |
float range = max - min; |
| 1510 |
|
|
| 1511 |
10040 |
if (min < 0) |
| 1512 |
|
{ |
| 1513 |
0 |
y2 = y - (int) ((0 - min / (range)) * _aa.graphHeight); |
| 1514 |
|
} |
| 1515 |
|
|
| 1516 |
10040 |
g.setColor(Color.gray); |
| 1517 |
|
|
| 1518 |
10040 |
drawLine(g, x, y2, (eRes - sRes) * charWidth, y2); |
| 1519 |
|
|
| 1520 |
10040 |
int column; |
| 1521 |
10040 |
int aaMax = aa_annotations.length - 1; |
| 1522 |
|
|
| 1523 |
|
|
| 1524 |
|
|
| 1525 |
|
|
| 1526 |
|
|
| 1527 |
10040 |
boolean _aa_is_dssp3 = _aa.autoCalculated && _aa.label |
| 1528 |
|
.startsWith(Constants.SECONDARY_STRUCTURE_CONSENSUS_LABEL); |
| 1529 |
|
|
| 1530 |
471745 |
while (x < eRes - sRes) |
| 1531 |
|
{ |
| 1532 |
461705 |
column = sRes + x; |
| 1533 |
461705 |
if (hasHiddenColumns) |
| 1534 |
|
{ |
| 1535 |
121407 |
column = hiddenColumns.visibleToAbsoluteColumn(column); |
| 1536 |
|
} |
| 1537 |
|
|
| 1538 |
461705 |
if (column > aaMax) |
| 1539 |
|
{ |
| 1540 |
0 |
break; |
| 1541 |
|
} |
| 1542 |
|
|
| 1543 |
461705 |
if (aa_annotations[column] == null) |
| 1544 |
|
{ |
| 1545 |
2296 |
x++; |
| 1546 |
2296 |
continue; |
| 1547 |
|
} |
| 1548 |
459409 |
if (aa_annotations[column].colour == null) |
| 1549 |
|
{ |
| 1550 |
150895 |
g.setColor(Color.black); |
| 1551 |
|
} |
| 1552 |
|
else |
| 1553 |
|
{ |
| 1554 |
308514 |
g.setColor(aa_annotations[column].colour); |
| 1555 |
|
} |
| 1556 |
|
|
| 1557 |
459409 |
y1 = y - (int) (((aa_annotations[column].value - min) / (range)) |
| 1558 |
|
* _aa.graphHeight); |
| 1559 |
|
|
| 1560 |
459409 |
if (renderHistogram) |
| 1561 |
|
{ |
| 1562 |
458575 |
if (y1 - y2 > 0) |
| 1563 |
|
{ |
| 1564 |
0 |
fillRect(g, x * charWidth, y2, charWidth, y1 - y2); |
| 1565 |
|
} |
| 1566 |
|
else |
| 1567 |
|
{ |
| 1568 |
458575 |
fillRect(g, x * charWidth, y1, charWidth, y2 - y1); |
| 1569 |
|
} |
| 1570 |
|
} |
| 1571 |
|
|
| 1572 |
459409 |
if (renderProfile) |
| 1573 |
|
{ |
| 1574 |
|
|
| 1575 |
|
|
| 1576 |
|
|
| 1577 |
|
|
| 1578 |
96035 |
int profl[] = getProfileFor(_aa, column); |
| 1579 |
|
|
| 1580 |
|
|
| 1581 |
96035 |
if (profl != null && profl[2] != 0) |
| 1582 |
|
{ |
| 1583 |
|
|
| 1584 |
|
|
| 1585 |
96035 |
boolean isStructureProfile = profl[0] == AlignmentAnnotation.STRUCTURE_PROFILE; |
| 1586 |
96035 |
boolean isCdnaProfile = profl[0] == AlignmentAnnotation.CDNA_PROFILE; |
| 1587 |
96035 |
float ht = normaliseProfile ? y - _aa.graphHeight : y1; |
| 1588 |
96035 |
final double normaliseFactor = normaliseProfile ? _aa.graphHeight |
| 1589 |
|
: (y2 - y1); |
| 1590 |
|
|
| 1591 |
|
|
| 1592 |
|
|
| 1593 |
|
|
| 1594 |
|
|
| 1595 |
96035 |
char[] dc = new char[isStructureProfile ? 2 |
| 1596 |
96035 |
: (isCdnaProfile ? 3 : 1)]; |
| 1597 |
|
|
| 1598 |
|
|
| 1599 |
|
|
| 1600 |
|
|
| 1601 |
|
|
| 1602 |
|
|
| 1603 |
|
|
| 1604 |
|
|
| 1605 |
96035 |
double asc = fm.getAscent(); |
| 1606 |
96035 |
double dec = fm.getDescent(); |
| 1607 |
96035 |
double fht = fm.getHeight(); |
| 1608 |
|
|
| 1609 |
96035 |
double scale = 1f / (normaliseProfile ? profl[2] : 100f); |
| 1610 |
|
|
| 1611 |
|
|
| 1612 |
|
|
| 1613 |
|
|
| 1614 |
|
|
| 1615 |
|
|
| 1616 |
96035 |
float ht2 = ht; |
| 1617 |
|
|
| 1618 |
|
|
| 1619 |
280793 |
for (int i = 0, c = 3, last = profl[1]; i < last; i++) |
| 1620 |
|
{ |
| 1621 |
|
|
| 1622 |
184758 |
String s; |
| 1623 |
184758 |
if (isStructureProfile) |
| 1624 |
|
{ |
| 1625 |
|
|
| 1626 |
0 |
dc[0] = (char) profl[c++]; |
| 1627 |
0 |
dc[1] = (char) profl[c++]; |
| 1628 |
0 |
s = new String(dc); |
| 1629 |
|
} |
| 1630 |
184758 |
else if (isCdnaProfile) |
| 1631 |
|
{ |
| 1632 |
0 |
CodingUtils.decodeCodon2(profl[c++], dc); |
| 1633 |
0 |
s = new String(dc); |
| 1634 |
|
} |
| 1635 |
|
else |
| 1636 |
|
{ |
| 1637 |
184758 |
dc[0] = (char) profl[c++]; |
| 1638 |
184758 |
s = new String(dc); |
| 1639 |
|
} |
| 1640 |
|
|
| 1641 |
|
|
| 1642 |
184758 |
int percent = profl[c++]; |
| 1643 |
184758 |
if (percent == 0) |
| 1644 |
|
{ |
| 1645 |
|
|
| 1646 |
0 |
continue; |
| 1647 |
|
} |
| 1648 |
184758 |
double newHeight = normaliseFactor * scale * percent; |
| 1649 |
|
|
| 1650 |
|
|
| 1651 |
|
|
| 1652 |
|
|
| 1653 |
|
|
| 1654 |
184758 |
Color colour = null; |
| 1655 |
184758 |
if (isCdnaProfile) |
| 1656 |
|
{ |
| 1657 |
0 |
final String codonTranslation = ResidueProperties |
| 1658 |
|
.codonTranslate(s); |
| 1659 |
0 |
colour = profcolour.findColour(codonTranslation.charAt(0), |
| 1660 |
|
column, null); |
| 1661 |
|
} |
| 1662 |
184758 |
else if (_aa_is_dssp3) |
| 1663 |
|
{ |
| 1664 |
|
|
| 1665 |
|
|
| 1666 |
0 |
colour = profcolour.findSSColour(dc[0], column); |
| 1667 |
|
} |
| 1668 |
|
else |
| 1669 |
|
{ |
| 1670 |
|
|
| 1671 |
184758 |
colour = profcolour.findColour(dc[0], column, null); |
| 1672 |
|
} |
| 1673 |
184758 |
g.setColor(colour == Color.white ? Color.lightGray : colour); |
| 1674 |
|
|
| 1675 |
|
|
| 1676 |
|
|
| 1677 |
|
|
| 1678 |
|
|
| 1679 |
|
|
| 1680 |
|
|
| 1681 |
184758 |
double sx = 1f * charWidth / fm.charsWidth(dc, 0, dc.length); |
| 1682 |
184758 |
double sy = newHeight / asc; |
| 1683 |
184758 |
double newAsc = asc * sy; |
| 1684 |
184758 |
double newDec = dec * sy; |
| 1685 |
|
|
| 1686 |
|
|
| 1687 |
|
|
| 1688 |
|
|
| 1689 |
|
|
| 1690 |
|
|
| 1691 |
184758 |
if (Platform.isJS()) |
| 1692 |
|
{ |
| 1693 |
|
|
| 1694 |
|
|
| 1695 |
|
|
| 1696 |
|
|
| 1697 |
|
|
| 1698 |
0 |
final int hght = (int) (ht2 + (newAsc - newDec)); |
| 1699 |
0 |
Graphics2D gg = (Graphics2D) g; |
| 1700 |
0 |
int xShift = (int) Math.round(x * charWidth / sx); |
| 1701 |
0 |
int yShift = (int) Math.round(hght / sy); |
| 1702 |
0 |
gg.transform(AffineTransform.getScaleInstance(sx, sy)); |
| 1703 |
0 |
gg.drawString(s, xShift, yShift); |
| 1704 |
0 |
gg.transform( |
| 1705 |
|
AffineTransform.getScaleInstance(1D / sx, 1D / sy)); |
| 1706 |
0 |
ht2 += newHeight; |
| 1707 |
|
} |
| 1708 |
|
else |
| 1709 |
|
|
| 1710 |
|
|
| 1711 |
|
|
| 1712 |
|
|
| 1713 |
|
|
| 1714 |
|
{ |
| 1715 |
|
|
| 1716 |
|
|
| 1717 |
184758 |
final int hght = (int) (ht + (newAsc - newDec)); |
| 1718 |
184758 |
Font font = ofont |
| 1719 |
|
.deriveFont(AffineTransform.getScaleInstance(sx, sy)); |
| 1720 |
184758 |
g.setFont(font); |
| 1721 |
184758 |
g.drawChars(dc, 0, dc.length, x * charWidth, hght); |
| 1722 |
184758 |
g.setFont(ofont); |
| 1723 |
|
|
| 1724 |
184758 |
ht += newHeight; |
| 1725 |
|
} |
| 1726 |
|
} |
| 1727 |
|
} |
| 1728 |
|
} |
| 1729 |
459409 |
x++; |
| 1730 |
|
} |
| 1731 |
10040 |
if (_aa.threshold != null) |
| 1732 |
|
{ |
| 1733 |
0 |
g.setColor(_aa.threshold.colour); |
| 1734 |
0 |
Stroke s = new BasicStroke(1, BasicStroke.CAP_SQUARE, |
| 1735 |
|
BasicStroke.JOIN_ROUND, 3f, new float[] |
| 1736 |
|
{ 5f, 3f }, 0f); |
| 1737 |
|
|
| 1738 |
0 |
y2 = (int) (y |
| 1739 |
|
- ((_aa.threshold.value - min) / range) * _aa.graphHeight); |
| 1740 |
0 |
drawLine(g, s, 0, y2, (eRes - sRes) * charWidth, y2); |
| 1741 |
|
} |
| 1742 |
|
} |
| 1743 |
|
|
| 1744 |
|
|
| |
|
| 0% |
Uncovered Elements: 23 (23) |
Complexity: 5 |
Complexity Density: 0.33 |
|
| 1745 |
0 |
public void drawGraph(Graphics g, AlignmentAnnotation _aa,... |
| 1746 |
|
Annotation[] aa_annotations, int width, int y, int sRes, int eRes) |
| 1747 |
|
{ |
| 1748 |
0 |
eRes = Math.min(eRes, aa_annotations.length); |
| 1749 |
0 |
g.setColor(Color.white); |
| 1750 |
0 |
fillRect(g, 0, 0, width, y); |
| 1751 |
0 |
g.setColor(new Color(0, 0, 180)); |
| 1752 |
|
|
| 1753 |
0 |
int x = 0, height; |
| 1754 |
|
|
| 1755 |
0 |
for (int j = sRes; j < eRes; j++) |
| 1756 |
|
{ |
| 1757 |
0 |
if (aa_annotations[j] != null) |
| 1758 |
|
{ |
| 1759 |
0 |
if (aa_annotations[j].colour == null) |
| 1760 |
|
{ |
| 1761 |
0 |
g.setColor(Color.black); |
| 1762 |
|
} |
| 1763 |
|
else |
| 1764 |
|
{ |
| 1765 |
0 |
g.setColor(aa_annotations[j].colour); |
| 1766 |
|
} |
| 1767 |
|
|
| 1768 |
0 |
height = (int) ((aa_annotations[j].value / _aa.graphMax) * y); |
| 1769 |
0 |
if (height > y) |
| 1770 |
|
{ |
| 1771 |
0 |
height = y; |
| 1772 |
|
} |
| 1773 |
|
|
| 1774 |
0 |
fillRect(g, x, y - height, charWidth, height); |
| 1775 |
|
} |
| 1776 |
0 |
x += charWidth; |
| 1777 |
|
} |
| 1778 |
|
} |
| 1779 |
|
|
| |
|
| 0% |
Uncovered Elements: 91 (91) |
Complexity: 59 |
Complexity Density: 0.65 |
|
| 1780 |
0 |
Color getNotCanonicalColor(char lastss)... |
| 1781 |
|
{ |
| 1782 |
0 |
switch (lastss) |
| 1783 |
|
{ |
| 1784 |
0 |
case '{': |
| 1785 |
0 |
case '}': |
| 1786 |
0 |
return new Color(255, 125, 5); |
| 1787 |
|
|
| 1788 |
0 |
case '[': |
| 1789 |
0 |
case ']': |
| 1790 |
0 |
return new Color(245, 115, 10); |
| 1791 |
|
|
| 1792 |
0 |
case '>': |
| 1793 |
0 |
case '<': |
| 1794 |
0 |
return new Color(235, 135, 15); |
| 1795 |
|
|
| 1796 |
0 |
case 'A': |
| 1797 |
0 |
case 'a': |
| 1798 |
0 |
return new Color(225, 105, 20); |
| 1799 |
|
|
| 1800 |
0 |
case 'B': |
| 1801 |
0 |
case 'b': |
| 1802 |
0 |
return new Color(215, 145, 30); |
| 1803 |
|
|
| 1804 |
0 |
case 'C': |
| 1805 |
0 |
case 'c': |
| 1806 |
0 |
return new Color(205, 95, 35); |
| 1807 |
|
|
| 1808 |
0 |
case 'D': |
| 1809 |
0 |
case 'd': |
| 1810 |
0 |
return new Color(195, 155, 45); |
| 1811 |
|
|
| 1812 |
0 |
case 'E': |
| 1813 |
0 |
case 'e': |
| 1814 |
0 |
return new Color(185, 85, 55); |
| 1815 |
|
|
| 1816 |
0 |
case 'F': |
| 1817 |
0 |
case 'f': |
| 1818 |
0 |
return new Color(175, 165, 65); |
| 1819 |
|
|
| 1820 |
0 |
case 'G': |
| 1821 |
0 |
case 'g': |
| 1822 |
0 |
return new Color(170, 75, 75); |
| 1823 |
|
|
| 1824 |
0 |
case 'H': |
| 1825 |
0 |
case 'h': |
| 1826 |
0 |
return new Color(160, 175, 85); |
| 1827 |
|
|
| 1828 |
0 |
case 'I': |
| 1829 |
0 |
case 'i': |
| 1830 |
0 |
return new Color(150, 65, 95); |
| 1831 |
|
|
| 1832 |
0 |
case 'J': |
| 1833 |
0 |
case 'j': |
| 1834 |
0 |
return new Color(140, 185, 105); |
| 1835 |
|
|
| 1836 |
0 |
case 'K': |
| 1837 |
0 |
case 'k': |
| 1838 |
0 |
return new Color(130, 55, 110); |
| 1839 |
|
|
| 1840 |
0 |
case 'L': |
| 1841 |
0 |
case 'l': |
| 1842 |
0 |
return new Color(120, 195, 120); |
| 1843 |
|
|
| 1844 |
0 |
case 'M': |
| 1845 |
0 |
case 'm': |
| 1846 |
0 |
return new Color(110, 45, 130); |
| 1847 |
|
|
| 1848 |
0 |
case 'N': |
| 1849 |
0 |
case 'n': |
| 1850 |
0 |
return new Color(100, 205, 140); |
| 1851 |
|
|
| 1852 |
0 |
case 'O': |
| 1853 |
0 |
case 'o': |
| 1854 |
0 |
return new Color(90, 35, 150); |
| 1855 |
|
|
| 1856 |
0 |
case 'P': |
| 1857 |
0 |
case 'p': |
| 1858 |
0 |
return new Color(85, 215, 160); |
| 1859 |
|
|
| 1860 |
0 |
case 'Q': |
| 1861 |
0 |
case 'q': |
| 1862 |
0 |
return new Color(75, 25, 170); |
| 1863 |
|
|
| 1864 |
0 |
case 'R': |
| 1865 |
0 |
case 'r': |
| 1866 |
0 |
return new Color(65, 225, 180); |
| 1867 |
|
|
| 1868 |
0 |
case 'S': |
| 1869 |
0 |
case 's': |
| 1870 |
0 |
return new Color(55, 15, 185); |
| 1871 |
|
|
| 1872 |
0 |
case 'T': |
| 1873 |
0 |
case 't': |
| 1874 |
0 |
return new Color(45, 235, 195); |
| 1875 |
|
|
| 1876 |
0 |
case 'U': |
| 1877 |
0 |
case 'u': |
| 1878 |
0 |
return new Color(35, 5, 205); |
| 1879 |
|
|
| 1880 |
0 |
case 'V': |
| 1881 |
0 |
case 'v': |
| 1882 |
0 |
return new Color(25, 245, 215); |
| 1883 |
|
|
| 1884 |
0 |
case 'W': |
| 1885 |
0 |
case 'w': |
| 1886 |
0 |
return new Color(15, 0, 225); |
| 1887 |
|
|
| 1888 |
0 |
case 'X': |
| 1889 |
0 |
case 'x': |
| 1890 |
0 |
return new Color(10, 255, 235); |
| 1891 |
|
|
| 1892 |
0 |
case 'Y': |
| 1893 |
0 |
case 'y': |
| 1894 |
0 |
return new Color(5, 150, 245); |
| 1895 |
|
|
| 1896 |
0 |
case 'Z': |
| 1897 |
0 |
case 'z': |
| 1898 |
0 |
return new Color(0, 80, 255); |
| 1899 |
|
|
| 1900 |
0 |
default: |
| 1901 |
0 |
Console.info("This is not a interaction : " + lastss); |
| 1902 |
0 |
return null; |
| 1903 |
|
|
| 1904 |
|
} |
| 1905 |
|
} |
| 1906 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 1907 |
4208 |
private void fillPolygon(Graphics g, int[] xpoints, int[] ypoints, int n)... |
| 1908 |
|
{ |
| 1909 |
4208 |
setAntialias(g); |
| 1910 |
4208 |
g.fillPolygon(xpoints, ypoints, n); |
| 1911 |
|
} |
| 1912 |
|
|
| 1913 |
|
|
| 1914 |
|
|
| 1915 |
|
|
| 1916 |
|
|
| 1917 |
|
|
| 1918 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 1919 |
463575 |
private void fillRect(Graphics g, int a, int b, int c, int d)... |
| 1920 |
|
{ |
| 1921 |
463575 |
unsetAntialias(g); |
| 1922 |
463575 |
g.fillRect(a, b, c, d); |
| 1923 |
|
} |
| 1924 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 1925 |
0 |
private void fillRoundRect(Graphics g, int a, int b, int c, int d, int e,... |
| 1926 |
|
int f) |
| 1927 |
|
{ |
| 1928 |
0 |
setAntialias(g); |
| 1929 |
0 |
g.fillRoundRect(a, b, c, d, e, f); |
| 1930 |
|
} |
| 1931 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 1932 |
1557 |
private void fillArc(Graphics g, int a, int b, int c, int d, int e, int f)... |
| 1933 |
|
{ |
| 1934 |
1557 |
setAntialias(g); |
| 1935 |
1557 |
g.fillArc(a, b, c, d, e, f); |
| 1936 |
|
} |
| 1937 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 1938 |
736 |
private void drawLine(Graphics g, Stroke s, int a, int b, int c, int d)... |
| 1939 |
|
{ |
| 1940 |
736 |
Graphics2D g2d = (Graphics2D) g; |
| 1941 |
736 |
Stroke p = g2d.getStroke(); |
| 1942 |
736 |
g2d.setStroke(s); |
| 1943 |
736 |
drawLine(g, a, b, c, d); |
| 1944 |
736 |
g2d.setStroke(p); |
| 1945 |
|
} |
| 1946 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 1947 |
27835 |
private void drawLine(Graphics g, int a, int b, int c, int d)... |
| 1948 |
|
{ |
| 1949 |
27835 |
setAntialias(g); |
| 1950 |
27835 |
g.drawLine(a, b, c, d); |
| 1951 |
|
} |
| 1952 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
| 1953 |
389994 |
private void setAntialias(Graphics g)... |
| 1954 |
|
{ |
| 1955 |
389994 |
if (isVectorRendering()) |
| 1956 |
|
{ |
| 1957 |
|
|
| 1958 |
3643 |
return; |
| 1959 |
|
} |
| 1960 |
386351 |
if (Cache.getDefault("ANTI_ALIAS", true)) |
| 1961 |
|
{ |
| 1962 |
70134 |
Graphics2D g2d = (Graphics2D) g; |
| 1963 |
70134 |
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, |
| 1964 |
|
RenderingHints.VALUE_ANTIALIAS_ON); |
| 1965 |
|
} |
| 1966 |
|
} |
| 1967 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 1968 |
1142385 |
private void unsetAntialias(Graphics g)... |
| 1969 |
|
{ |
| 1970 |
1142385 |
if (isVectorRendering()) |
| 1971 |
|
{ |
| 1972 |
|
|
| 1973 |
10048 |
return; |
| 1974 |
|
} |
| 1975 |
1132337 |
Graphics2D g2d = (Graphics2D) g; |
| 1976 |
1132337 |
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, |
| 1977 |
|
RenderingHints.VALUE_ANTIALIAS_OFF); |
| 1978 |
|
} |
| 1979 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1980 |
14 |
public void setVectorRendering(boolean b)... |
| 1981 |
|
{ |
| 1982 |
14 |
renderingVectors = b; |
| 1983 |
|
} |
| 1984 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1985 |
1586659 |
public boolean isVectorRendering()... |
| 1986 |
|
{ |
| 1987 |
1586659 |
return renderingVectors; |
| 1988 |
|
} |
| 1989 |
|
} |