@@ -122,6 +122,18 @@ protected MarkerProperty(final Widget widget, final String name)
122122 /** Legacy properties that have already triggered a warning */
123123 private final CopyOnWriteArraySet <String > warnings_once = new CopyOnWriteArraySet <>();
124124
125+ /** Moving gridline color to individual Y-Axes was a backwards-incompatible change
126+ * So the major was incremented from 2.0.0 to 3.0.0
127+ */
128+ private static final Version VERSION = Version .parse ("3.0.0" );
129+
130+ /** @return Widget version number */
131+ @ Override
132+ public Version getVersion ()
133+ {
134+ return VERSION ;
135+ }
136+
125137 /** Configurator that handles legacy properties */
126138 private static class Configurator extends WidgetConfigurator
127139 {
@@ -136,6 +148,7 @@ public boolean configureFromXML(final ModelReader model_reader, final Widget wid
136148 {
137149 configureAllPropertiesFromMatchingXML (model_reader , widget , xml );
138150
151+ // Legacy widget
139152 if (xml_version .getMajor () < 2 )
140153 {
141154 if (StripchartWidget .isLegacyStripchart (xml ))
@@ -176,6 +189,24 @@ public boolean configureFromXML(final ModelReader model_reader, final Widget wid
176189 for (TraceWidgetProperty trace : plot .propTraces ().getValue ())
177190 trace .traceName ().setValue ("" );
178191 }
192+
193+ // Newer widgets with some high-level properties moved to individual axes
194+ if (xml_version .getMajor () < 3 ) {
195+
196+ final XYPlotWidget plot = (XYPlotWidget ) widget ;
197+
198+ // If grid color was specified, then use it on each axis
199+ Element gridColor = XMLUtil .getChildElement (xml , "grid_color" );
200+ if (gridColor != null ) {
201+ plot .y_axes .getValue ().forEach (axis -> {
202+ try {
203+ axis .color ().readFromXML (model_reader , gridColor );
204+ } catch (Exception e ) {
205+ logger .log (Level .WARNING , "Could not read widget color from grid_color of V2 X/Y Plot Widget" );
206+ }
207+ });
208+ }
209+ }
179210 return true ;
180211 }
181212
@@ -303,7 +334,6 @@ private boolean handleLegacyTraces(final ModelReader model_reader,
303334
304335 private volatile WidgetProperty <WidgetColor > foreground ;
305336 private volatile WidgetProperty <WidgetColor > background ;
306- private volatile WidgetProperty <WidgetColor > grid ;
307337 private volatile WidgetProperty <String > title ;
308338 private volatile WidgetProperty <WidgetFont > title_font ;
309339 private volatile WidgetProperty <Boolean > show_toolbar ;
@@ -332,7 +362,6 @@ protected void defineProperties(final List<WidgetProperty<?>> properties)
332362 super .defineProperties (properties );
333363 properties .add (foreground = propForegroundColor .createProperty (this , WidgetColorService .getColor (NamedWidgetColors .TEXT )));
334364 properties .add (background = propBackgroundColor .createProperty (this , WidgetColorService .getColor (NamedWidgetColors .BACKGROUND )));
335- properties .add (grid = propGridColor .createProperty (this , WidgetColorService .getColor (NamedWidgetColors .GRID )));
336365 properties .add (title = PlotWidgetProperties .propTitle .createProperty (this , "" ));
337366 properties .add (title_font = PlotWidgetProperties .propTitleFont .createProperty (this , WidgetFontService .get (NamedWidgetFonts .HEADER2 )));
338367 properties .add (show_toolbar = propToolbar .createProperty (this ,false ));
@@ -399,12 +428,6 @@ public WidgetProperty<WidgetColor> propForeground()
399428 return foreground ;
400429 }
401430
402- /** @return 'grid_color' property */
403- public WidgetProperty <WidgetColor > propGridColor ()
404- {
405- return grid ;
406- }
407-
408431 /** @return 'title' property */
409432 public WidgetProperty <String > propTitle ()
410433 {
0 commit comments