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 .Plotable ;
45+ import org .mastodon .views .grapher .display .ScreenTransformState ;
4546
4647public class GrapherGuiState
4748{
@@ -100,40 +101,39 @@ private GrapherGuiState()
100101 */
101102 public static final String GRAPHER_SHOW_EDGES_KEY = "GrapherShowEdges" ;
102103
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 )
104+ public static < V extends Vertex < E > & HasTimepoint & HasLabel & Ref < V >, E extends Edge < V > & Ref < E > > void
105+ writeGuiState ( final ScreenTransformState screenTransformState , final FeatureGraphConfig config ,
106+ final Map < String , Object > guiState )
105107 {
106- DataDisplayFrame < V , E > frame = frameProvider .getFrame ();
107108 // Transform.
108- final ScreenTransform transform = frame . getDataDisplayPanel (). getScreenTransform () .get ();
109+ final ScreenTransform transform = screenTransformState .get ();
109110 guiState .put ( GRAPHER_TRANSFORM_KEY , transform );
110111 // Feature graph config.
111- writeFeatureGraphConfig ( frame , guiState );
112+ writeFeatureGraphConfig ( config , guiState );
112113 }
113114
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 )
115+ public static < V extends Vertex < E > & HasTimepoint & HasLabel & Ref < V >, E extends Edge < V > & Ref < E > > void
116+ loadGuiState ( final Map < String , Object > guiState , final ScreenTransformState screenTransformState ,
117+ final GrapherSidePanel <V , E > sidePanel , final FeatureGraphConfig defaultConfig ,
118+ final Plotable plotable )
117119 {
118- DataDisplayFrame < V , E > frame = frameSupplier .getFrame ();
119-
120120 // Read Screen Transform.
121121 final ScreenTransform screenTransform = ( ScreenTransform ) guiState .get ( GRAPHER_TRANSFORM_KEY );
122122 if ( null != screenTransform )
123- frame . getDataDisplayPanel (). getScreenTransform () .set ( screenTransform );
123+ screenTransformState .set ( screenTransform );
124124
125125 // Read Feature graph config.
126- FeatureGraphConfig config = loadFeatureGraphConfig ( frame , guiState , defaultConfig );
127- frame . getVertexSidePanel () .setGraphConfig ( config );
126+ FeatureGraphConfig config = loadFeatureGraphConfig ( sidePanel , guiState , defaultConfig );
127+ sidePanel .setGraphConfig ( config );
128128
129129 // Plot with loaded transform and config.
130- frame .plot ( screenTransform );
130+ if ( plotable != null )
131+ plotable .plot ( screenTransform );
131132 }
132133
133134 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 )
135+ writeFeatureGraphConfig ( final FeatureGraphConfig config , final Map < String , Object > guiState )
135136 {
136- FeatureGraphConfig config = frame .getVertexSidePanel ().getGraphConfig ();
137137 // X-axis feature.
138138 FeatureSpecPair featureSpecPairX = config .getXFeature ();
139139 guiState .put ( GRAPHER_X_AXIS_FEATURE_IS_EDGE_KEY , featureSpecPairX .isEdgeFeature () );
@@ -150,11 +150,12 @@ private GrapherGuiState()
150150 guiState .put ( GRAPHER_SHOW_EDGES_KEY , config .drawConnected () );
151151 }
152152
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 )
153+ public static < V extends Vertex < E > & HasTimepoint & HasLabel & Ref < V >, E extends Edge < V > & Ref < E > > FeatureGraphConfig
154+ loadFeatureGraphConfig (
155+ final GrapherSidePanel <V , E > sidePanel , final Map < String , Object > guiState ,
156+ final FeatureGraphConfig defaultConfig
157+ )
156158 {
157- GrapherSidePanel sidePanel = frame .getVertexSidePanel ();
158159 FeatureSpecPair featureSpecPairX = loadFeatureSpecPair ( guiState , sidePanel , GRAPHER_X_AXIS_FEATURE_IS_EDGE_KEY ,
159160 GRAPHER_X_AXIS_FEATURE_SPEC_KEY , GRAPHER_X_AXIS_FEATURE_PROJECTION_KEY , GRAPHER_X_AXIS_INCOMING_EDGE_KEY );
160161 FeatureSpecPair featureSpecPairY = loadFeatureSpecPair ( guiState , sidePanel , GRAPHER_Y_AXIS_FEATURE_IS_EDGE_KEY ,
@@ -165,7 +166,7 @@ private GrapherGuiState()
165166 return new FeatureGraphConfig ( featureSpecPairX , featureSpecPairY , FeatureGraphConfig .GraphDataItemsSource .CONTEXT , showEdges );
166167 }
167168
168- 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 ,
169170 final String edgeKey , final String featureSpecKey , final String projectionKey , final String incomingEdgeKey )
170171 {
171172 Boolean isEdgeFeature = ( Boolean ) guiState .get ( edgeKey );
0 commit comments