Skip to content

Commit 03d1cf6

Browse files
author
Stefan Hahmann
committed
Use GrapherSidePanel generic
1 parent b93592e commit 03d1cf6

4 files changed

Lines changed: 20 additions & 21 deletions

File tree

src/main/java/org/mastodon/mamut/views/grapher/GrapherGuiState.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,7 @@ private GrapherGuiState()
114114

115115
public static < V extends Vertex< E > & HasTimepoint & HasLabel & Ref< V >, E extends Edge< V > & Ref< E > > void
116116
loadGuiState( final Map< String, Object > guiState, final ScreenTransformState screenTransformState,
117-
final GrapherSidePanel sidePanel, final FeatureGraphConfig defaultConfig )
118-
{
119-
loadGuiState( guiState, screenTransformState, sidePanel, defaultConfig, null );
120-
}
121-
122-
public static < V extends Vertex< E > & HasTimepoint & HasLabel & Ref< V >, E extends Edge< V > & Ref< E > > void
123-
loadGuiState( final Map< String, Object > guiState, final ScreenTransformState screenTransformState,
124-
final GrapherSidePanel sidePanel, final FeatureGraphConfig defaultConfig,
117+
final GrapherSidePanel<V, E> sidePanel, final FeatureGraphConfig defaultConfig,
125118
final Plotable plotable )
126119
{
127120
// Read Screen Transform.
@@ -159,7 +152,7 @@ private GrapherGuiState()
159152

160153
public static < V extends Vertex< E > & HasTimepoint & HasLabel & Ref< V >, E extends Edge< V > & Ref< E > > FeatureGraphConfig
161154
loadFeatureGraphConfig(
162-
final GrapherSidePanel sidePanel, final Map< String, Object > guiState,
155+
final GrapherSidePanel<V, E> sidePanel, final Map< String, Object > guiState,
163156
final FeatureGraphConfig defaultConfig
164157
)
165158
{
@@ -173,7 +166,7 @@ private GrapherGuiState()
173166
return new FeatureGraphConfig( featureSpecPairX, featureSpecPairY, FeatureGraphConfig.GraphDataItemsSource.CONTEXT, showEdges );
174167
}
175168

176-
private static FeatureSpecPair loadFeatureSpecPair( final Map< String, Object > guiState, final GrapherSidePanel sidePanel,
169+
private static < V extends Vertex< E >, E extends Edge< V > > FeatureSpecPair loadFeatureSpecPair( final Map< String, Object > guiState, final GrapherSidePanel<V, E> sidePanel,
177170
final String edgeKey, final String featureSpecKey, final String projectionKey, final String incomingEdgeKey )
178171
{
179172
Boolean isEdgeFeature = ( Boolean ) guiState.get( edgeKey );

src/main/java/org/mastodon/views/grapher/display/DataDisplayFrame.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public class DataDisplayFrame< V extends Vertex< E > & HasTimepoint & HasLabel,
6969

7070
private final DataDisplayPanel< V, E > dataDisplayPanel;
7171

72-
private final GrapherSidePanel sidePanel;
72+
private final GrapherSidePanel<V, E> sidePanel;
7373

7474
private final FeatureModel featureModel;
7575

@@ -116,7 +116,7 @@ public DataDisplayFrame(
116116
* Side panel.
117117
*/
118118

119-
sidePanel = new GrapherSidePanel( nSources, contextChooser );
119+
sidePanel = new GrapherSidePanel<>( nSources, contextChooser );
120120
sidePanel.getBtnPlot().addActionListener( e -> plot( false ) );
121121

122122
final FeatureModelListener featureModelListener = () -> sidePanel.setFeatures(
@@ -183,7 +183,7 @@ public DataDisplayPanel< V, E > getDataDisplayPanel()
183183
return dataDisplayPanel;
184184
}
185185

186-
public GrapherSidePanel getVertexSidePanel()
186+
public GrapherSidePanel<V, E> getVertexSidePanel()
187187
{
188188
return sidePanel;
189189
}
@@ -194,8 +194,10 @@ public GrapherSidePanel getVertexSidePanel()
194194
*/
195195
public void plot( boolean keepCurrentScreenTransform )
196196
{
197-
dataDisplayPanel.plot( sidePanel.getGraphConfig(), featureModel,
198-
keepCurrentScreenTransform ? dataDisplayPanel.getScreenTransform().get() : null );
197+
if ( keepCurrentScreenTransform )
198+
plot( dataDisplayPanel.getScreenTransform().get() );
199+
else
200+
plot( null );
199201
}
200202

201203
public void plot( final ScreenTransform transform )

src/main/java/org/mastodon/views/grapher/display/GrapherSidePanel.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@
5858
import org.mastodon.feature.FeatureProjectionSpec;
5959
import org.mastodon.feature.FeatureSpec;
6060
import org.mastodon.feature.Multiplicity;
61+
import org.mastodon.graph.Edge;
62+
import org.mastodon.graph.Vertex;
6163
import org.mastodon.graph.io.RawGraphIO.FileIdToGraphMap;
6264
import org.mastodon.mamut.feature.MamutRawFeatureModelIO;
6365
import org.mastodon.mamut.io.project.MamutProject;
@@ -79,7 +81,7 @@
7981
*
8082
* @author Jean-Yves Tinevez
8183
*/
82-
public class GrapherSidePanel extends JPanel
84+
public class GrapherSidePanel< V extends Vertex< E >, E extends Edge< V > > extends JPanel
8385
{
8486

8587
private static final long serialVersionUID = 1L;
@@ -104,9 +106,9 @@ public class GrapherSidePanel extends JPanel
104106

105107
private final JButton btnPlot;
106108

107-
private final ContextChooser< ? > contextChooser;
109+
private final ContextChooser< V > contextChooser;
108110

109-
public GrapherSidePanel( final int nSources, final ContextChooser< ? > contextChooser )
111+
public GrapherSidePanel( final int nSources, final ContextChooser< V > contextChooser )
110112
{
111113
this.nSources = nSources;
112114
this.specs = new ArrayList<>();
@@ -435,9 +437,9 @@ public FeatureProjectionSpec getFeatureProjectionSpec( final String projectionKe
435437
return null;
436438
}
437439

438-
public ContextChooser< Spot > getContextChooser()
440+
public ContextChooser< V > getContextChooser()
439441
{
440-
return Cast.unchecked( this.contextChooser );
442+
return this.contextChooser;
441443
}
442444

443445
private static final FeatureModel demoFM()
@@ -473,7 +475,7 @@ public static void main( final String[] args ) throws ClassNotFoundException, In
473475
FeatureUtils.collectFeatureMap( fm, Spot.class );
474476
final Map< FeatureSpec< ?, Link >, Feature< Link > > linkFeatures =
475477
FeatureUtils.collectFeatureMap( fm, Link.class );
476-
final GrapherSidePanel gsp = new GrapherSidePanel( 2, new ContextChooser<>( null ) );
478+
final GrapherSidePanel<Spot, Link> gsp = new GrapherSidePanel<Spot, Link>( 2, new ContextChooser<>( null ) );
477479
gsp.setFeatures( spotFeatures, linkFeatures );
478480

479481
final JFrame frame = new JFrame( "Grapher side panel" );

src/main/java/org/mastodon/views/grapher/display/Plotable.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@
55
public interface Plotable
66
{
77
void plot( final ScreenTransform screenTransform );
8+
9+
void plot( final boolean keepCurrentScreenTransform );
810
}

0 commit comments

Comments
 (0)