@@ -26,13 +26,13 @@ class GraphController {
26
26
private final ResizableCanvas canvas ;
27
27
private final int archFactor = 5 ;
28
28
29
- private DrawableSegment clicked1 ;
30
- private DrawableSegment clicked2 ;
29
+ private DrawableSegment clicked ;
30
+ private DrawableSegment clickedShift ;
31
+ private DrawableSNP clickedSNP ;
32
+ private DrawableSNP clickedSNPShift ;
31
33
32
34
private int centerNodeInt ;
33
35
private boolean drawSNP = false ;
34
- private DrawableSegment highlightSegmentShift ;
35
- private DrawableSegment highlightSegment ;
36
36
37
37
private HighlightController highlightController ;
38
38
@@ -235,7 +235,6 @@ private void drawSNP(GraphicsContext gc, DrawableSNP drawableSNP) {
235
235
236
236
int size = drawableSNP .getMutations ().size ();
237
237
int seqNumber = 0 ;
238
-
239
238
gc .strokeRoundRect (locX , locY , width , height , archFactor , archFactor );
240
239
241
240
for (DrawableSegment drawableSegment : drawableSNP .getMutations ()) {
@@ -347,17 +346,29 @@ public void zoom(double scale) {
347
346
private void draw (GraphicsContext gc ) {
348
347
gc .clearRect (0 , 0 , canvas .getWidth (), canvas .getHeight ());
349
348
350
- if (clicked1 != null ) {
351
- highlightNode (clicked1 , Color .DARKTURQUOISE );
352
- clicked1 .setStrokeWidth (5.0 * subGraph .getZoomLevel ());
349
+ if (clicked != null ) {
350
+ highlightNode (clicked , Color .DARKTURQUOISE );
351
+ clicked .setStrokeWidth (5.0 * subGraph .getZoomLevel ());
353
352
}
354
- if (clicked2 != null ) {
355
- highlightNode (clicked2 , Color .PURPLE );
356
- clicked2 .setStrokeWidth (5.0 * subGraph .getZoomLevel ());
353
+ if (clickedSNP != null ) {
354
+ highlightNode (clickedSNP , Color .DARKTURQUOISE );
355
+ clickedSNP .setStrokeWidth (5.0 * subGraph .getZoomLevel ());
357
356
}
358
- if (clicked1 == clicked2 && clicked1 != null && clicked2 != null ) {
359
- highlightNode (clicked1 , Color .DARKCYAN );
360
- clicked1 .setStrokeWidth (5.0 * subGraph .getZoomLevel ());
357
+ if (clickedShift != null ) {
358
+ highlightNode (clickedShift , Color .PURPLE );
359
+ clickedShift .setStrokeWidth (5.0 * subGraph .getZoomLevel ());
360
+ }
361
+ if (clickedSNPShift != null ) {
362
+ highlightNode (clickedSNPShift , Color .PURPLE );
363
+ clickedSNPShift .setStrokeWidth (5.0 * subGraph .getZoomLevel ());
364
+ }
365
+ if (clicked == clickedShift && clicked != null && clickedShift != null ) {
366
+ highlightNode (clicked , Color .DARKCYAN );
367
+ clicked .setStrokeWidth (5.0 * subGraph .getZoomLevel ());
368
+ }
369
+ if (clickedSNP == clickedSNPShift && clickedSNP != null && clickedSNPShift != null ) {
370
+ highlightNode (clickedSNP , Color .DARKCYAN );
371
+ clickedSNP .setStrokeWidth (5.0 * subGraph .getZoomLevel ());
361
372
}
362
373
363
374
boolean didLoad = subGraph .checkDynamicLoad (0 , canvas .getWidth ());
@@ -434,8 +445,17 @@ public void highlightByGenome(int genomeID, Color color) {
434
445
*/
435
446
void setSNP () {
436
447
drawSNP = !drawSNP ;
437
- clicked1 = null ;
438
- clicked2 = null ;
448
+ resetClicked ();
449
+ }
450
+
451
+ /**
452
+ * Resets which nodes are clicked on.
453
+ */
454
+ void resetClicked () {
455
+ clicked = null ;
456
+ clickedShift = null ;
457
+ clickedSNP = null ;
458
+ clickedSNPShift = null ;
439
459
}
440
460
441
461
/**
@@ -450,28 +470,47 @@ public Drawable onClick(double x, double y) {
450
470
}
451
471
452
472
/**
453
- * Method to hightlight the node clicked on.
473
+ * Method to highlight the node clicked on.
454
474
*
455
475
* @param segment is the {@link DrawableSegment} clicked on.
476
+ * @param snp is the {@link DrawableSNP} clicked on.
456
477
* @param shiftPressed boolean true if shift was pressed during the click.
457
478
*/
458
- public void highlightClicked (DrawableSegment segment , boolean shiftPressed ) {
479
+ public void highlightClicked (DrawableSegment segment , DrawableSNP snp , boolean shiftPressed ) {
459
480
if (shiftPressed ) {
460
- if (highlightSegmentShift != null ) {
461
- this .highlightSegmentShift .colorize (subGraph );
481
+ if (clicked != null ) {
482
+ this .clicked .colorize (subGraph );
483
+ }
484
+ if (clickedSNP != null ) {
485
+ this .clickedSNP .colorize (subGraph );
486
+ }
487
+ this .clicked = segment ;
488
+ this .clickedSNP = snp ;
489
+ if (segment != null ) {
490
+ highlightNode (segment , Color .DARKTURQUOISE );
491
+ segment .setStrokeWidth (5.0 * subGraph .getZoomLevel ()); //Correct thickness when zoomed
492
+ }
493
+ if (snp != null ) {
494
+ highlightNode (snp , Color .DARKTURQUOISE );
495
+ snp .setStrokeWidth (5.0 * subGraph .getZoomLevel ()); //Correct thickness when zoomed
462
496
}
463
- this .highlightSegmentShift = segment ;
464
- this .clicked1 = segment ;
465
- highlightNode (segment , Color .DARKTURQUOISE );
466
- segment .setStrokeWidth (5.0 * subGraph .getZoomLevel ()); //Correct thickness when zoomed
467
497
} else {
468
- if (highlightSegment != null ) {
469
- this .highlightSegment .colorize (subGraph );
498
+ if (clickedShift != null ) {
499
+ this .clickedShift .colorize (subGraph );
500
+ }
501
+ if (clickedSNPShift != null ) {
502
+ this .clickedSNPShift .colorize (subGraph );
503
+ }
504
+ this .clickedShift = segment ;
505
+ this .clickedSNPShift = snp ;
506
+ if (segment != null ) {
507
+ highlightNode (segment , Color .PURPLE );
508
+ segment .setStrokeWidth (5.0 * subGraph .getZoomLevel ()); //Correct thickness when zoomed
509
+ }
510
+ if (snp != null ) {
511
+ highlightNode (snp , Color .PURPLE );
512
+ snp .setStrokeWidth (5.0 * subGraph .getZoomLevel ()); //Correct thickness when zoomed
470
513
}
471
- this .highlightSegment = segment ;
472
- this .clicked2 = segment ;
473
- highlightNode (segment , Color .PURPLE );
474
- segment .setStrokeWidth (5.0 * subGraph .getZoomLevel ()); //Correct thickness when zoomed
475
514
}
476
515
draw (canvas .getGraphicsContext2D ());
477
516
}
@@ -498,11 +537,23 @@ public Collection<Integer> getGenomesEdge(DrawableEdge edge) {
498
537
return null ;
499
538
}
500
539
501
- public Collection <DrawableNode > getParentSegments (DrawableSegment node ) {
540
+ /**
541
+ * Method to return the segments in a given edge.
542
+ *
543
+ * @param node the Drawable segment the check which parent segments it contains.
544
+ * @return Collection<Integer> of the parents segments in the node.
545
+ */
546
+ Collection <DrawableNode > getParentSegments (DrawableSegment node ) {
502
547
return subGraph .getParentSegments (node );
503
548
}
504
549
505
- public Collection <DrawableNode > getChildSegments (DrawableSegment node ) {
550
+ /**
551
+ * Method to return the segments in a given edge.
552
+ *
553
+ * @param node the Drawable segment the check which child segments it contains.
554
+ * @return Collection<Integer> of the child segments in the node.
555
+ */
556
+ Collection <DrawableNode > getChildSegments (DrawableSegment node ) {
506
557
return subGraph .getChildSegments (node );
507
558
}
508
559
0 commit comments