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
3838import org .mastodon .model .HasLabel ;
3939import org .mastodon .spatial .HasTimepoint ;
4040import org .mastodon .views .grapher .datagraph .ScreenTransform ;
41- import org .mastodon .views .grapher .display .DataDisplayFrame ;
4241import org .mastodon .views .grapher .display .FeatureGraphConfig ;
4342import org .mastodon .views .grapher .display .FeatureSpecPair ;
4443import org .mastodon .views .grapher .display .GrapherSidePanel ;
44+ import org .mastodon .views .grapher .display .ScreenTransformState ;
4545
4646public 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 ,
0 commit comments