Skip to content

Commit

Permalink
Remove context chooser from MamutBranchViewGrapher
Browse files Browse the repository at this point in the history
* Similarly to the MamutBranchViewTrackScheme, the context chooser can currently not really be used in MamutBranchView(s), since the context chooser / the context provider can provide spots, but in the branch view branch spots are required and translation between them is with the current architecture not possible
  • Loading branch information
stefanhahmann committed Dec 19, 2024
1 parent 8b3fba9 commit 4dbc9a7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public class GrapherInitializer< V extends Vertex< E > & HasTimepoint & HasLabel
GrapherInitializer( final DataGraph< V, E > graph, final ProjectModel appModel,
final SelectionModel< DataVertex, DataEdge > selectionModel, final NavigationHandler< DataVertex, DataEdge > navigationHandler,
final FocusModel< DataVertex > focusModel, final HighlightModel< DataVertex, DataEdge > highlightModel,
final GroupHandle groupHandle
final GroupHandle groupHandle, final DataContextListener< V > contextListener
)
{
this.viewGraph = graph;
Expand All @@ -143,8 +143,7 @@ public class GrapherInitializer< V extends Vertex< E > & HasTimepoint & HasLabel
layout = new DataGraphLayout<>( viewGraph, selectionModel );

// ContextChooser
final DataContextListener< V > contextListener = new DataContextListener<>( viewGraph );
contextChooser = new ContextChooser<>( contextListener );
this.contextChooser = contextListener == null ? null : new ContextChooser<>( contextListener );

// Style
final DataDisplayStyleManager dataDisplayStyleManager = appModel.getWindowManager().getManager( DataDisplayStyleManager.class );
Expand Down Expand Up @@ -178,7 +177,8 @@ public class GrapherInitializer< V extends Vertex< E > & HasTimepoint & HasLabel

// Panel
this.panel = frame.getDataDisplayPanel();
contextListener.setContextListener( panel );
if ( contextListener != null )
contextListener.setContextListener( panel );

// Style listener
styleUpdateListener = panel::repaint;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
*/
package org.mastodon.mamut.views.grapher;

import java.util.Iterator;
import java.util.function.BiConsumer;

import net.imglib2.loops.LoopBuilder;
import org.apache.commons.lang3.function.TriFunction;
import org.mastodon.app.ui.ViewMenuBuilder.JMenuHandle;
Expand All @@ -43,8 +46,6 @@
import org.mastodon.ui.coloring.HasColorBarOverlay;
import org.mastodon.ui.coloring.HasColoringModel;
import org.mastodon.ui.keymap.KeyConfigContexts;
import org.mastodon.views.context.ContextChooser;
import org.mastodon.views.context.HasContextChooser;
import org.mastodon.views.grapher.datagraph.DataEdge;
import org.mastodon.views.grapher.datagraph.DataGraph;
import org.mastodon.views.grapher.datagraph.DataVertex;
Expand All @@ -55,11 +56,8 @@
import org.mastodon.views.grapher.display.FeatureSpecPair;
import org.mastodon.views.grapher.display.InertialScreenTransformEventHandler;

import java.util.Iterator;
import java.util.function.BiConsumer;

public class MamutBranchViewGrapher extends MamutBranchView< DataGraph< BranchSpot, BranchLink >, DataVertex, DataEdge >
implements HasContextChooser< BranchSpot >, HasColoringModel, HasColorBarOverlay, DataDisplayFrameSupplier< BranchSpot, BranchLink >
implements HasColoringModel, HasColorBarOverlay, DataDisplayFrameSupplier< BranchSpot, BranchLink >
{

private final GrapherInitializer< BranchSpot, BranchLink > grapherInitializer;
Expand All @@ -74,7 +72,7 @@ public class MamutBranchViewGrapher extends MamutBranchView< DataGraph< BranchSp
new String[] { KeyConfigContexts.GRAPHER } );

grapherInitializer = new GrapherInitializer<>( viewGraph, appModel, selectionModel, navigationHandler, focusModel, highlightModel,
getGroupHandle() );
getGroupHandle(), null );
grapherInitializer.getFrame().setTitle( "Grapher Branch" );
InertialScreenTransformEventHandler handler = grapherInitializer.getFrame().getDataDisplayPanel().getTransformEventHandler();
handler.setMinScaleX( 0.1d );
Expand Down Expand Up @@ -119,12 +117,6 @@ public DataDisplayFrame< BranchSpot, BranchLink > getFrame()
return ( DataDisplayFrame< BranchSpot, BranchLink > ) super.getFrame();
}

@Override
public ContextChooser< BranchSpot > getContextChooser()
{
return grapherInitializer.getContextChooser();
}

@Override
public ColoringModel getColoringModel()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.mastodon.ui.keymap.KeyConfigContexts;
import org.mastodon.views.context.ContextChooser;
import org.mastodon.views.context.HasContextChooser;
import org.mastodon.views.grapher.datagraph.DataContextListener;
import org.mastodon.views.grapher.datagraph.DataEdge;
import org.mastodon.views.grapher.datagraph.DataGraph;
import org.mastodon.views.grapher.datagraph.DataVertex;
Expand Down Expand Up @@ -74,8 +75,9 @@ public class MamutViewGrapher extends MamutView< DataGraph< Spot, Link >, DataVe
new String[] { KeyConfigContexts.GRAPHER } );


final DataContextListener< Spot > contextListener = new DataContextListener<>( viewGraph );
grapherInitializer = new GrapherInitializer<>( viewGraph, appModel, selectionModel, navigationHandler, focusModel, highlightModel,
getGroupHandle() );
getGroupHandle(), contextListener );
grapherInitializer.setOnClose( this );
grapherInitializer.initFeatureConfig( getFeatureGraphConfig() );
setFrame( grapherInitializer.getFrame() ); // this creates viewActions and viewBehaviours thus must be called before installActions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,23 @@ public GrapherSidePanel( final int nSources, final ContextChooser< ? > contextCh
rdbtnContext.setFont( rdbtnContext.getFont().deriveFont( rdbtnContext.getFont().getSize() - 2f ) );
btngrp.add( rdbtnContext );

final ContextChooserPanel< ? > chooserPanel = new ContextChooserPanel<>( contextChooser );
final GridBagConstraints gbcChooserPanel = new GridBagConstraints();
gbcChooserPanel.fill = GridBagConstraints.BOTH;
gbcChooserPanel.insets = new Insets( 0, 5, 5, 5 );
gbcChooserPanel.gridx = 0;
gbcChooserPanel.gridy = 10;
add( chooserPanel, gbcChooserPanel );
if ( contextChooser != null )
{
final ContextChooserPanel< ? > chooserPanel = new ContextChooserPanel<>( contextChooser );
final GridBagConstraints gbcChooserPanel = new GridBagConstraints();
gbcChooserPanel.fill = GridBagConstraints.BOTH;
gbcChooserPanel.insets = new Insets( 0, 5, 5, 5 );
gbcChooserPanel.gridx = 0;
gbcChooserPanel.gridy = 10;
add( chooserPanel, gbcChooserPanel );
for ( final Component c : chooserPanel.getComponents() )
c.setFont( c.getFont().deriveFont( c.getFont().getSize2D() - 2f ) );
// show context box only if the right button is selected.
final EverythingDisablerAndReenabler contextEnabler =
new EverythingDisablerAndReenabler( chooserPanel, new Class[] { Label.class } );
contextEnabler.setEnabled( rdbtnContext.isSelected() );
rdbtnContext.addChangeListener( e -> contextEnabler.setEnabled( rdbtnContext.isSelected() ) );
}

chkboxConnect = new JCheckBox( "Show edges" );
final GridBagConstraints gbcChkboxConnect = new GridBagConstraints();
Expand All @@ -229,9 +239,6 @@ public GrapherSidePanel( final int nSources, final ContextChooser< ? > contextCh
chkboxConnect.setSelected( true );
chkboxConnect.setFont( chkboxConnect.getFont().deriveFont( chkboxConnect.getFont().getSize() - 2f ) );

for ( final Component c : chooserPanel.getComponents() )
c.setFont( c.getFont().deriveFont( c.getFont().getSize2D() - 2f ) );

btnPlot = new JButton( "Plot" );
final GridBagConstraints gbcBtnPlot = new GridBagConstraints();
gbcBtnPlot.anchor = GridBagConstraints.SOUTHEAST;
Expand All @@ -247,11 +254,6 @@ public GrapherSidePanel( final int nSources, final ContextChooser< ? > contextCh
if ( !rdbtnContext.isSelected() )
rdbtnKeepCurrent.setSelected( true );
} );
// show context box only if the right button is selected.
final EverythingDisablerAndReenabler contextEnabler =
new EverythingDisablerAndReenabler( chooserPanel, new Class[] { Label.class } );
contextEnabler.setEnabled( rdbtnContext.isSelected() );
rdbtnContext.addChangeListener( e -> contextEnabler.setEnabled( rdbtnContext.isSelected() ) );
}

/**
Expand Down

0 comments on commit 4dbc9a7

Please sign in to comment.