33import org .igv .Globals ;
44import org .igv .event .IGVEvent ;
55import org .igv .event .IGVEventObserver ;
6- import org .igv .hic .HicFile ;
76import org .igv .jbrowse .CircularViewUtilities ;
87import org .igv .logging .LogManager ;
98import org .igv .logging .Logger ;
109import org .igv .prefs .Constants ;
1110import org .igv .prefs .PreferencesManager ;
12- import org .igv .renderer .ContinuousColorScale ;
1311import org .igv .renderer .GraphicUtils ;
1412import org .igv .track .AbstractTrack ;
1513import org .igv .track .RenderContext ;
1614import org .igv .track .TrackClickEvent ;
1715import org .igv .track .TrackMenuUtils ;
1816import org .igv .ui .FontManager ;
19- import org .igv .ui .IGV ;
2017import org .igv .ui .panel .FrameManager ;
2118import org .igv .ui .panel .IGVPopupMenu ;
2219import org .igv .ui .panel .ReferenceFrame ;
@@ -67,18 +64,22 @@ enum ArcOption {ALL, ONE_END, BOTH_ENDS}
6764 private JMenuItem maxScoreItem ;
6865
6966 InteractionTrack .Direction direction = UP ; //DOWN;
70- protected GraphType graphType ; // GraphType.block; //
67+ protected GraphType graphType = GraphType . NESTED_ARC ; // GraphType.block; //
7168 private ArcOption arcOption = ArcOption .ALL ;
7269 int thickness = 1 ;
7370 boolean autoscale = true ;
7471 double maxScore = -1 ;
7572 int gap = 5 ;
7673 boolean showBlocks = false ;
7774 protected boolean useScore = false ;
75+ protected boolean isHIC = false ;
7876 private Map <GraphType , BedPERenderer > renderers ;
7977
78+ private Color defaultColor = new Color (180 , 25 , 137 );
79+
80+
8081 ContactMapView contactMapView ;
81- float transparency = 0.1f ;
82+ float transparency = 1.0f ;
8283 protected String normalization = "NONE" ;
8384 protected int maxFeatureCount = 20000 ;
8485
@@ -98,7 +99,6 @@ public InteractionTrack(ResourceLocator locator, InteractionSource src) {
9899 this .featureSource = src ;
99100
100101 setHeight (250 , true );
101- setColor (new Color (180 , 25 , 137 ));
102102
103103 renderers = new HashMap <>();
104104 renderers .put (GraphType .NESTED_ARC , new NestedArcRenderer (this ));
@@ -111,10 +111,7 @@ public InteractionTrack(ResourceLocator locator, InteractionSource src) {
111111 graphType = GraphType .valueOf (typeString );
112112 } catch (IllegalArgumentException e ) {
113113 log .error ("Illegal graph type: " + typeString , e );
114- graphType = GraphType .NESTED_ARC ; // default
115114 }
116- } else {
117- graphType = GraphType .PROPORTIONAL_ARC ;
118115 }
119116
120117 String directionString = PreferencesManager .getPreferences ().get (Constants .ARC_DIRECTION );
@@ -308,7 +305,7 @@ public IGVPopupMenu getPopupMenu(TrackClickEvent te) {
308305 item .addActionListener (evt -> TrackMenuUtils .changeTrackColor (Collections .singleton (InteractionTrack .this )));
309306 menu .add (item );
310307
311- if (supportsGraphTypeSelection () ) {
308+ if (! isHIC ) {
312309 menu .addSeparator ();
313310 menu .add (new JLabel ("<html><b>Graph Type</b>" ));
314311 //enum GraphType {BLOCK, ARC, PROPORTIONAL_ARC}
@@ -322,7 +319,7 @@ public IGVPopupMenu getPopupMenu(TrackClickEvent te) {
322319 JRadioButtonMenuItem mm = new JRadioButtonMenuItem (entry .getKey ());
323320 mm .setSelected (InteractionTrack .this .graphType == entry .getValue ());
324321 mm .addActionListener (evt -> {
325- setGraphType ( entry .getValue () );
322+ this . graphType = entry .getValue ();
326323 PreferencesManager .getPreferences ().put (Constants .ARC_TYPE , entry .getValue ().toString ());
327324 autoscaleCB .setEnabled (graphType == GraphType .PROPORTIONAL_ARC );
328325 maxScoreItem .setEnabled (graphType == GraphType .PROPORTIONAL_ARC );
@@ -363,7 +360,7 @@ public IGVPopupMenu getPopupMenu(TrackClickEvent te) {
363360 });
364361 menu .add (showBlocksCB );
365362
366- if (supportsAutoscaleMenu () ) {
363+ if (! isHIC ) {
367364 menu .addSeparator ();
368365 autoscaleCB = new JCheckBoxMenuItem ("Autoscale" );
369366 autoscaleCB .setSelected (autoscale );
@@ -424,127 +421,42 @@ public IGVPopupMenu getPopupMenu(TrackClickEvent te) {
424421 menu .add (item );
425422
426423
427- final JMenuItem transparencyItem = new JMenuItem ("Set Transparency..." );
428- transparencyItem .addActionListener (e -> {
429- final JSlider slider = new JSlider (1 , 100 , (int ) (InteractionTrack .this .transparency * 100 ));
430- slider .setMajorTickSpacing (10 );
431- slider .setPaintTicks (true );
432-
433- // Create a label to show the current value
434- final JLabel valueLabel = new JLabel (String .format ("%.2f" , InteractionTrack .this .transparency ));
435-
436- slider .addChangeListener (changeEvent -> {
437- JSlider source = (JSlider ) changeEvent .getSource ();
438- float value = source .getValue () / 100.0f ;
439- InteractionTrack .this .transparency = value ;
440- valueLabel .setText (String .format ("%.2f" , value ));
441- InteractionTrack .this .repaint ();
442- });
443-
444- JPanel panel = new JPanel (new BorderLayout ());
445- panel .add (slider , BorderLayout .CENTER );
446- panel .add (valueLabel , BorderLayout .SOUTH );
447-
448- final Frame parent = IGV .hasInstance () ? IGV .getInstance ().getMainFrame () : null ;
449- JOptionPane .showMessageDialog (parent , panel , "Set Transparency for " + InteractionTrack .this .getDisplayName (), JOptionPane .PLAIN_MESSAGE );
450- });
451- menu .add (transparencyItem );
452-
453-
454- final JMenuItem maxFeatureCountItem = new JMenuItem ("Set Maximum Feature Count..." );
455- maxFeatureCountItem .addActionListener (e -> {
456- final JSlider slider = new JSlider (1000 , 20000 , InteractionTrack .this .maxFeatureCount );
457- slider .setMajorTickSpacing (5000 );
458- slider .setPaintTicks (true );
459-
460- final JLabel valueLabel = new JLabel (String .valueOf (InteractionTrack .this .maxFeatureCount ));
424+ if (isHIC ) {
425+ addHICItems (te , menu );
461426
462- slider .addChangeListener (changeEvent -> {
463- JSlider source = (JSlider ) changeEvent .getSource ();
464- int value = source .getValue ();
465- InteractionTrack .this .maxFeatureCount = value ;
466- valueLabel .setText (String .valueOf (value ));
467- InteractionTrack .this .loadedIntervalMap .clear ();
468- InteractionTrack .this .repaint ();
469- });
470-
471- JPanel panel = new JPanel (new BorderLayout ());
472- panel .add (slider , BorderLayout .CENTER );
473- panel .add (valueLabel , BorderLayout .SOUTH );
474-
475- final Frame parent = IGV .hasInstance () ? IGV .getInstance ().getMainFrame () : null ;
476- JOptionPane .showMessageDialog (parent , panel , "Set Max Feature Count for " + InteractionTrack .this .getDisplayName (), JOptionPane .PLAIN_MESSAGE );
477- });
478- menu .add (maxFeatureCountItem );
479-
480-
481- // Hook for subclass-specific menu items (e.g., HiC normalization options)
482- addFormatSpecificMenuItems (menu , te );
483-
484- if (supportsFeatureWindowMenu ()) {
427+ } else {
428+ // Not hic
485429 menu .addSeparator ();
486430 menu .add (TrackMenuUtils .getChangeFeatureWindow (Collections .singletonList (this )));
487- }
488431
489- // Experimental JBrowse.
490- if (PreferencesManager .getPreferences ().getAsBoolean (Constants .CIRC_VIEW_ENABLED ) &&
491- CircularViewUtilities .ping () &&
492- supportsCircularView ()) {
493- menu .addSeparator ();
494- JMenuItem circViewItem = new JMenuItem ("Add Features to Circular View" );
495- circViewItem .addActionListener (e -> {
496- List <ReferenceFrame > frames = te .getFrame () != null ?
497- Collections .singletonList (te .getFrame ()) :
498- FrameManager .getFrames ();
499- List <? extends BedPE > visibleFeatures = getVisibleFeatures (frames );
500- CircularViewUtilities .sendBedpeToJBrowse (visibleFeatures , InteractionTrack .this .getName (), InteractionTrack .this .getColor ());
501- });
502- menu .add (circViewItem );
503- menu .addSeparator ();
432+
433+ // Experimental JBrowse.
434+ if (PreferencesManager .getPreferences ().getAsBoolean (Constants .CIRC_VIEW_ENABLED ) &&
435+ CircularViewUtilities .ping ()) {
436+ menu .addSeparator ();
437+ JMenuItem circViewItem = new JMenuItem ("Add Features to Circular View" );
438+ circViewItem .addActionListener (e -> {
439+ List <ReferenceFrame > frames = te .getFrame () != null ?
440+ Collections .singletonList (te .getFrame ()) :
441+ FrameManager .getFrames ();
442+ List <? extends BedPE > visibleFeatures = getVisibleFeatures (frames );
443+ CircularViewUtilities .sendBedpeToJBrowse (visibleFeatures , InteractionTrack .this .getName (), InteractionTrack .this .getColor ());
444+ });
445+ menu .add (circViewItem );
446+ menu .addSeparator ();
447+ }
504448 }
505449
506450 return menu ;
507451 }
508452
509- private void setGraphType (GraphType value ) {
510- // TODO adjust height
511- this .graphType = value ;
512- }
513-
514- /**
515- * Hook method for subclasses to add format-specific menu items.
516- * Default implementation does nothing.
517- */
518- protected void addFormatSpecificMenuItems (IGVPopupMenu menu , TrackClickEvent te ) {
519- // Default: no additional menu items
520- }
521-
522- /**
523- * Hook method for subclasses to indicate if graph type selection is supported.
524- */
525- protected boolean supportsGraphTypeSelection () {
526- return true ;
453+ void addHICItems (TrackClickEvent te , IGVPopupMenu menu ) {
454+ // Override in HIC subclass
527455 }
528456
529- /**
530- * Hook method for subclasses to indicate if circular view is supported.
531- */
532- protected boolean supportsCircularView () {
533- return true ;
534- }
535-
536- /**
537- * Hook method for subclasses to indicate if autoscale menu is supported.
538- */
539- protected boolean supportsAutoscaleMenu () {
540- return true ;
541- }
542-
543- /**
544- * Hook method for subclasses to indicate if feature window menu is supported.
545- */
546- protected boolean supportsFeatureWindowMenu () {
547- return true ;
457+ @ Override
458+ public void setColor (Color color ) {
459+ super .setColor (color );
548460 }
549461
550462 @ Override
0 commit comments