Skip to content

Commit b8b8759

Browse files
author
Stefan Hahmann
committed
Make methods GrapherGuiState.writeGuiState() and GrapherGuiState.loadGuiState() public
1 parent 163272e commit b8b8759

3 files changed

Lines changed: 51 additions & 30 deletions

File tree

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

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
* %%
77
* Redistribution and use in source and binary forms, with or without
88
* modification, are permitted provided that the following conditions are met:
9-
*
9+
*
1010
* 1. Redistributions of source code must retain the above copyright notice,
1111
* this list of conditions and the following disclaimer.
1212
* 2. Redistributions in binary form must reproduce the above copyright notice,
1313
* this list of conditions and the following disclaimer in the documentation
1414
* and/or other materials provided with the distribution.
15-
*
15+
*
1616
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1717
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1818
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -38,10 +38,10 @@
3838
import org.mastodon.model.HasLabel;
3939
import org.mastodon.spatial.HasTimepoint;
4040
import org.mastodon.views.grapher.datagraph.ScreenTransform;
41-
import org.mastodon.views.grapher.display.DataDisplayFrame;
4241
import org.mastodon.views.grapher.display.FeatureGraphConfig;
4342
import org.mastodon.views.grapher.display.FeatureSpecPair;
4443
import org.mastodon.views.grapher.display.GrapherSidePanel;
44+
import org.mastodon.views.grapher.display.ScreenTransformState;
4545

4646
public class GrapherGuiState
4747
{
@@ -100,40 +100,46 @@ private GrapherGuiState()
100100
*/
101101
public static final String GRAPHER_SHOW_EDGES_KEY = "GrapherShowEdges";
102102

103-
static < V extends Vertex< E > & HasTimepoint & HasLabel & Ref< V >, E extends Edge< V > & Ref< E > > void
104-
writeGuiState( final DataDisplayFrameSupplier< V, E > frameProvider, final Map< String, Object > guiState )
103+
public static < V extends Vertex< E > & HasTimepoint & HasLabel & Ref< V >, E extends Edge< V > & Ref< E > > void
104+
writeGuiState( final ScreenTransformState screenTransformState, final FeatureGraphConfig config,
105+
final Map< String, Object > guiState )
105106
{
106-
DataDisplayFrame< V, E > frame = frameProvider.getFrame();
107107
// Transform.
108-
final ScreenTransform transform = frame.getDataDisplayPanel().getScreenTransform().get();
108+
final ScreenTransform transform = screenTransformState.get();
109109
guiState.put( GRAPHER_TRANSFORM_KEY, transform );
110110
// Feature graph config.
111-
writeFeatureGraphConfig( frame, guiState );
111+
writeFeatureGraphConfig( config, guiState );
112112
}
113113

114-
static < V extends Vertex< E > & HasTimepoint & HasLabel & Ref< V >, E extends Edge< V > & Ref< E > > void
115-
loadGuiState( final DataDisplayFrameSupplier< V, E > frameSupplier, final Map< String, Object > guiState,
116-
final FeatureGraphConfig defaultConfig )
114+
public static < V extends Vertex< E > & HasTimepoint & HasLabel & Ref< V >, E extends Edge< V > & Ref< E > > void
115+
loadGuiState( final Map< String, Object > guiState, final ScreenTransformState screenTransformState,
116+
final GrapherSidePanel sidePanel, final FeatureGraphConfig defaultConfig )
117117
{
118-
DataDisplayFrame< V, E > frame = frameSupplier.getFrame();
118+
loadGuiState( guiState, screenTransformState, sidePanel, defaultConfig, null );
119+
}
119120

121+
static < V extends Vertex< E > & HasTimepoint & HasLabel & Ref< V >, E extends Edge< V > & Ref< E > > void
122+
loadGuiState( final Map< String, Object > guiState, final ScreenTransformState screenTransformState,
123+
final GrapherSidePanel sidePanel, final FeatureGraphConfig defaultConfig,
124+
final DataDisplayFrameSupplier< V, E > frameSupplier )
125+
{
120126
// Read Screen Transform.
121127
final ScreenTransform screenTransform = ( ScreenTransform ) guiState.get( GRAPHER_TRANSFORM_KEY );
122128
if ( null != screenTransform )
123-
frame.getDataDisplayPanel().getScreenTransform().set( screenTransform );
129+
screenTransformState.set( screenTransform );
124130

125131
// Read Feature graph config.
126-
FeatureGraphConfig config = loadFeatureGraphConfig( frame, guiState, defaultConfig );
127-
frame.getVertexSidePanel().setGraphConfig( config );
132+
FeatureGraphConfig config = loadFeatureGraphConfig( sidePanel, guiState, defaultConfig );
133+
sidePanel.setGraphConfig( config );
128134

129135
// Plot with loaded transform and config.
130-
frame.plot( screenTransform );
136+
if ( frameSupplier != null )
137+
frameSupplier.getFrame().plot( screenTransform );
131138
}
132139

133140
private static < V extends Vertex< E > & HasTimepoint & HasLabel & Ref< V >, E extends Edge< V > & Ref< E > > void
134-
writeFeatureGraphConfig( final DataDisplayFrame< V, E > frame, final Map< String, Object > guiState )
141+
writeFeatureGraphConfig( final FeatureGraphConfig config, final Map< String, Object > guiState )
135142
{
136-
FeatureGraphConfig config = frame.getVertexSidePanel().getGraphConfig();
137143
// X-axis feature.
138144
FeatureSpecPair featureSpecPairX = config.getXFeature();
139145
guiState.put( GRAPHER_X_AXIS_FEATURE_IS_EDGE_KEY, featureSpecPairX.isEdgeFeature() );
@@ -150,11 +156,12 @@ private GrapherGuiState()
150156
guiState.put( GRAPHER_SHOW_EDGES_KEY, config.drawConnected() );
151157
}
152158

153-
private static < V extends Vertex< E > & HasTimepoint & HasLabel & Ref< V >, E extends Edge< V > & Ref< E > > FeatureGraphConfig
154-
loadFeatureGraphConfig( final DataDisplayFrame< V, E > frame, final Map< String, Object > guiState,
155-
final FeatureGraphConfig defaultConfig )
159+
public static < V extends Vertex< E > & HasTimepoint & HasLabel & Ref< V >, E extends Edge< V > & Ref< E > > FeatureGraphConfig
160+
loadFeatureGraphConfig(
161+
final GrapherSidePanel sidePanel, final Map< String, Object > guiState,
162+
final FeatureGraphConfig defaultConfig
163+
)
156164
{
157-
GrapherSidePanel sidePanel = frame.getVertexSidePanel();
158165
FeatureSpecPair featureSpecPairX = loadFeatureSpecPair( guiState, sidePanel, GRAPHER_X_AXIS_FEATURE_IS_EDGE_KEY,
159166
GRAPHER_X_AXIS_FEATURE_SPEC_KEY, GRAPHER_X_AXIS_FEATURE_PROJECTION_KEY, GRAPHER_X_AXIS_INCOMING_EDGE_KEY );
160167
FeatureSpecPair featureSpecPairY = loadFeatureSpecPair( guiState, sidePanel, GRAPHER_Y_AXIS_FEATURE_IS_EDGE_KEY,

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
* %%
77
* Redistribution and use in source and binary forms, with or without
88
* modification, are permitted provided that the following conditions are met:
9-
*
9+
*
1010
* 1. Redistributions of source code must retain the above copyright notice,
1111
* this list of conditions and the following disclaimer.
1212
* 2. Redistributions in binary form must reproduce the above copyright notice,
1313
* this list of conditions and the following disclaimer in the documentation
1414
* and/or other materials provided with the distribution.
15-
*
15+
*
1616
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1717
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1818
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -31,8 +31,11 @@
3131
import java.util.Map;
3232

3333
import org.mastodon.mamut.ProjectModel;
34+
import org.mastodon.mamut.model.branch.BranchLink;
35+
import org.mastodon.mamut.model.branch.BranchSpot;
3436
import org.mastodon.mamut.views.AbstractMamutViewFactory;
3537
import org.mastodon.mamut.views.MamutViewFactory;
38+
import org.mastodon.views.grapher.display.DataDisplayFrame;
3639
import org.scijava.Priority;
3740
import org.scijava.plugin.Plugin;
3841

@@ -51,15 +54,19 @@ public MamutBranchViewGrapher create( final ProjectModel projectModel )
5154
public Map< String, Object > getGuiState( final MamutBranchViewGrapher view )
5255
{
5356
final Map< String, Object > guiState = super.getGuiState( view );
54-
GrapherGuiState.writeGuiState( view, guiState );
57+
DataDisplayFrame< BranchSpot, BranchLink > frame = view.getFrame();
58+
GrapherGuiState.writeGuiState( frame.getDataDisplayPanel().getScreenTransform(), frame.getVertexSidePanel().getGraphConfig(),
59+
guiState );
5560
return guiState;
5661
}
5762

5863
@Override
5964
public void restoreGuiState( final MamutBranchViewGrapher view, final Map< String, Object > guiState )
6065
{
6166
super.restoreGuiState( view, guiState );
62-
GrapherGuiState.loadGuiState( view, guiState, MamutBranchViewGrapher.getFeatureGraphConfig() );
67+
DataDisplayFrame< BranchSpot, BranchLink > frame = view.getFrame();
68+
GrapherGuiState.loadGuiState( guiState, frame.getDataDisplayPanel().getScreenTransform(), frame.getVertexSidePanel(),
69+
MamutBranchViewGrapher.getFeatureGraphConfig(), view );
6370
}
6471

6572
@Override

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
* %%
77
* Redistribution and use in source and binary forms, with or without
88
* modification, are permitted provided that the following conditions are met:
9-
*
9+
*
1010
* 1. Redistributions of source code must retain the above copyright notice,
1111
* this list of conditions and the following disclaimer.
1212
* 2. Redistributions in binary form must reproduce the above copyright notice,
1313
* this list of conditions and the following disclaimer in the documentation
1414
* and/or other materials provided with the distribution.
15-
*
15+
*
1616
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1717
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1818
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -31,9 +31,12 @@
3131
import java.util.Map;
3232

3333
import org.mastodon.mamut.ProjectModel;
34+
import org.mastodon.mamut.model.Link;
35+
import org.mastodon.mamut.model.Spot;
3436
import org.mastodon.mamut.views.AbstractMamutViewFactory;
3537
import org.mastodon.mamut.views.MamutViewFactory;
3638
import org.mastodon.ui.coloring.ColorBarOverlay.Position;
39+
import org.mastodon.views.grapher.display.DataDisplayFrame;
3740
import org.scijava.Priority;
3841
import org.scijava.plugin.Plugin;
3942

@@ -82,7 +85,9 @@ public MamutViewGrapher create( final ProjectModel projectModel )
8285
public Map< String, Object > getGuiState( final MamutViewGrapher view )
8386
{
8487
final Map< String, Object > guiState = super.getGuiState( view );
85-
GrapherGuiState.writeGuiState( view, guiState );
88+
DataDisplayFrame< Spot, Link > frame = view.getFrame();
89+
GrapherGuiState.writeGuiState( frame.getDataDisplayPanel().getScreenTransform(), frame.getVertexSidePanel().getGraphConfig(),
90+
guiState );
8691
return guiState;
8792
}
8893

@@ -91,7 +96,9 @@ public Map< String, Object > getGuiState( final MamutViewGrapher view )
9196
public void restoreGuiState( final MamutViewGrapher view, final Map< String, Object > guiState )
9297
{
9398
super.restoreGuiState( view, guiState );
94-
GrapherGuiState.loadGuiState( view, guiState, MamutViewGrapher.getFeatureGraphConfig() );
99+
DataDisplayFrame< Spot, Link > frame = view.getFrame();
100+
GrapherGuiState.loadGuiState( guiState, frame.getDataDisplayPanel().getScreenTransform(), frame.getVertexSidePanel(),
101+
MamutViewGrapher.getFeatureGraphConfig(), view );
95102
}
96103

97104
@Override

0 commit comments

Comments
 (0)