Skip to content

Commit 0728225

Browse files
committed
Line connecting dots on graphs can now be disabled.
Fix #186
1 parent b8f3928 commit 0728225

6 files changed

Lines changed: 43 additions & 13 deletions

File tree

src/main/java/fiji/plugin/trackmate/features/EdgeCollectionDataset.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,12 @@ public EdgeCollectionDataset(
7070
final DisplaySettings ds,
7171
final String xFeature,
7272
final List< String > yFeatures,
73-
final List< DefaultWeightedEdge > edges )
73+
final List< DefaultWeightedEdge > edges,
74+
final boolean addLines )
7475
{
7576
super( model, selectionModel, ds, xFeature, yFeatures );
7677
this.edges = edges;
77-
this.edgeMap = createEdgeMap( edges, model.getTrackModel() );
78+
this.edgeMap = addLines ? createEdgeMap( edges, model.getTrackModel() ) : null;
7879
this.labelGenerator = edge -> String.format( "%s → %s",
7980
model.getTrackModel().getEdgeSource( edge ).getName(), model.getTrackModel().getEdgeTarget( edge ).getName() );
8081
}
@@ -170,7 +171,7 @@ protected void drawPrimaryLine(
170171
final ValueAxis rangeAxis,
171172
final Rectangle2D dataArea )
172173
{
173-
if ( !edgeMap.containsKey( Integer.valueOf( item ) ) )
174+
if ( edgeMap == null || !edgeMap.containsKey( Integer.valueOf( item ) ) )
174175
return;
175176

176177
final RectangleEdge xAxisLocation = plot.getDomainAxisEdge();

src/main/java/fiji/plugin/trackmate/features/EdgeFeatureGrapher.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,16 @@ public class EdgeFeatureGrapher extends AbstractFeatureGrapher
4040

4141
private final DisplaySettings ds;
4242

43+
private final boolean addLines;
44+
4345
public EdgeFeatureGrapher(
4446
final List< DefaultWeightedEdge > edges,
4547
final String xFeature,
4648
final List< String > yFeatures,
4749
final Model model,
4850
final SelectionModel selectionModel,
49-
final DisplaySettings displaySettings )
51+
final DisplaySettings displaySettings,
52+
final boolean addLines )
5053
{
5154
super(
5255
xFeature,
@@ -60,6 +63,7 @@ public EdgeFeatureGrapher(
6063
this.model = model;
6164
this.selectionModel = selectionModel;
6265
this.ds = displaySettings;
66+
this.addLines = addLines;
6367
}
6468

6569
@Override
@@ -71,6 +75,7 @@ protected ModelDataset buildMainDataSet( final List< String > targetYFeatures )
7175
ds,
7276
xFeature,
7377
targetYFeatures,
74-
edges );
78+
edges,
79+
addLines );
7580
}
7681
}

src/main/java/fiji/plugin/trackmate/features/SpotCollectionDataset.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,12 @@ public SpotCollectionDataset(
6666
final DisplaySettings ds,
6767
final String xFeature,
6868
final List< String > yFeatures,
69-
final List< Spot > spots )
69+
final List< Spot > spots,
70+
final boolean addLines )
7071
{
7172
super( model, selectionModel, ds, xFeature, yFeatures );
7273
this.spots = spots;
73-
this.edgeMap = createEdgeMap( spots, model.getTrackModel() );
74+
this.edgeMap = addLines ? createEdgeMap( spots, model.getTrackModel() ) : null;
7475
}
7576

7677
/**
@@ -166,7 +167,7 @@ protected void drawPrimaryLine(
166167
final ValueAxis rangeAxis,
167168
final Rectangle2D dataArea )
168169
{
169-
if ( !edgeMap.containsKey( Integer.valueOf( item ) ) )
170+
if ( edgeMap == null || !edgeMap.containsKey( Integer.valueOf( item ) ) )
170171
return;
171172

172173
final RectangleEdge xAxisLocation = plot.getDomainAxisEdge();

src/main/java/fiji/plugin/trackmate/features/SpotFeatureGrapher.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,16 @@ public class SpotFeatureGrapher extends AbstractFeatureGrapher
3939

4040
private final DisplaySettings ds;
4141

42+
private final boolean addLines;
43+
4244
public SpotFeatureGrapher(
4345
final List< Spot > spots,
4446
final String xFeature,
4547
final List< String > yFeatures,
4648
final Model model,
4749
final SelectionModel selectionModel,
48-
final DisplaySettings displaySettings )
50+
final DisplaySettings displaySettings,
51+
final boolean addLines )
4952
{
5053
super(
5154
xFeature,
@@ -59,6 +62,7 @@ public SpotFeatureGrapher(
5962
this.model = model;
6063
this.selectionModel = selectionModel;
6164
this.ds = displaySettings;
65+
this.addLines = addLines;
6266
}
6367

6468
@Override
@@ -70,6 +74,7 @@ protected ModelDataset buildMainDataSet( final List< String > targetYFeatures )
7074
ds,
7175
xFeature,
7276
targetYFeatures,
73-
spots );
77+
spots,
78+
addLines );
7479
}
7580
}

src/main/java/fiji/plugin/trackmate/gui/components/GrapherPanel.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,14 @@
3232
import java.util.Map;
3333
import java.util.Set;
3434

35+
import javax.swing.BoxLayout;
3536
import javax.swing.ButtonGroup;
37+
import javax.swing.JCheckBox;
3638
import javax.swing.JFrame;
3739
import javax.swing.JLabel;
3840
import javax.swing.JPanel;
3941
import javax.swing.JRadioButton;
42+
import javax.swing.JSeparator;
4043
import javax.swing.JTabbedPane;
4144
import javax.swing.SwingConstants;
4245
import javax.swing.SwingUtilities;
@@ -87,6 +90,8 @@ public class GrapherPanel extends JPanel
8790

8891
private final JRadioButton rdbtnTracks;
8992

93+
private final JCheckBox chkboxConnectDots;
94+
9095
/*
9196
* CONSTRUCTOR
9297
*/
@@ -149,6 +154,7 @@ public GrapherPanel( final TrackMate trackmate, final SelectionModel selectionMo
149154
panelTracks.add( trackFeatureSelectionPanel );
150155

151156
panelSelection = new JPanel();
157+
panelSelection.setLayout( new BoxLayout( panelSelection, BoxLayout.LINE_AXIS ) );
152158
add( panelSelection, BorderLayout.SOUTH );
153159

154160
rdbtnAll = new JRadioButton( "All" );
@@ -168,6 +174,13 @@ public GrapherPanel( final TrackMate trackmate, final SelectionModel selectionMo
168174
btngrp.add( rdbtnSelection );
169175
btngrp.add( rdbtnTracks );
170176
rdbtnAll.setSelected( true );
177+
178+
panelSelection.add( new JSeparator( SwingConstants.VERTICAL ) );
179+
180+
chkboxConnectDots = new JCheckBox( "Connect" );
181+
chkboxConnectDots.setFont( chkboxConnectDots.getFont().deriveFont( chkboxConnectDots.getFont().getSize() - 2f ) );
182+
chkboxConnectDots.setSelected( true );
183+
panelSelection.add( chkboxConnectDots );
171184
}
172185

173186
public FeaturePlotSelectionPanel getSpotFeatureSelectionPanel()
@@ -209,14 +222,16 @@ else if ( rdbtnSelection.isSelected() )
209222
selectionModel.getEdgeSelection(), 0 );
210223
spots = new ArrayList<>( selectionModel.getSpotSelection() );
211224
}
225+
final boolean addLines = chkboxConnectDots.isSelected();
212226

213227
final SpotFeatureGrapher grapher = new SpotFeatureGrapher(
214228
spots,
215229
xFeature,
216230
yFeatures,
217231
trackmate.getModel(),
218232
selectionModel,
219-
displaySettings );
233+
displaySettings,
234+
addLines );
220235
final JFrame frame = grapher.render();
221236
frame.setIconImage( Icons.PLOT_ICON.getImage() );
222237
frame.setTitle( trackmate.getSettings().imp.getShortTitle() + " spot features" );
@@ -253,14 +268,16 @@ else if ( rdbtnSelection.isSelected() )
253268
selectionModel.getEdgeSelection(), 0 );
254269
edges = new ArrayList<>( selectionModel.getEdgeSelection() );
255270
}
271+
final boolean addLines = chkboxConnectDots.isSelected();
256272

257273
final EdgeFeatureGrapher grapher = new EdgeFeatureGrapher(
258274
edges,
259275
xFeature,
260276
yFeatures,
261277
trackmate.getModel(),
262278
selectionModel,
263-
displaySettings );
279+
displaySettings,
280+
addLines );
264281
final JFrame frame = grapher.render();
265282
frame.setIconImage( Icons.PLOT_ICON.getImage() );
266283
frame.setTitle( trackmate.getSettings().imp.getShortTitle() + " edge features" );

src/test/java/fiji/plugin/trackmate/interactivetests/SpotFeatureGrapherExample.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ public static void main( final String[] args )
6767
Y,
6868
model,
6969
selectionModel,
70-
DisplaySettings.defaultStyle().copy() );
70+
DisplaySettings.defaultStyle().copy(),
71+
true );
7172
final JFrame frame = grapher.render();
7273
frame.setLocationRelativeTo( null );
7374
frame.setVisible( true );

0 commit comments

Comments
 (0)