Skip to content

Commit 96d927d

Browse files
refactor: x/y plot widget remove unused grid_color property
1 parent dad762d commit 96d927d

File tree

3 files changed

+34
-12
lines changed

3 files changed

+34
-12
lines changed

app/display/convert-edm/src/main/java/org/csstudio/display/converter/edm/widgets/Convert_xyGraphClass.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ public Convert_xyGraphClass(final EdmConverter converter, final Widget parent, f
4040

4141
convertColor(r.getBgColor(), widget.propBackground());
4242
convertColor(r.getFgColor(), widget.propForeground());
43-
convertColor(r.getFgColor(), widget.propGridColor());
43+
widget.propYAxes().getValue().forEach(propYAxis -> {
44+
convertColor(r.getFgColor(), propYAxis.color());
45+
});
4446

4547
// X Axis
4648
if (r.getXLabel() == null)

app/display/model/src/main/java/org/csstudio/display/builder/model/widgets/plots/XYPlotWidget.java

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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
{

app/display/representation-javafx/src/main/java/org/csstudio/display/builder/representation/javafx/widgets/plots/XYPlotRepresentation.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,6 @@ protected void registerListeners()
475475

476476
model_widget.propBackground().addUntypedPropertyListener(config_listener);
477477
model_widget.propForeground().addUntypedPropertyListener(config_listener);
478-
model_widget.propGridColor().addUntypedPropertyListener(config_listener);
479478
model_widget.propTitle().addUntypedPropertyListener(config_listener);
480479
model_widget.propTitleFont().addUntypedPropertyListener(config_listener);
481480
model_widget.propToolbar().addUntypedPropertyListener(config_listener);
@@ -508,7 +507,6 @@ protected void unregisterListeners()
508507
{
509508
model_widget.propBackground().removePropertyListener(config_listener);
510509
model_widget.propForeground().removePropertyListener(config_listener);
511-
model_widget.propGridColor().removePropertyListener(config_listener);
512510
model_widget.propTitle().removePropertyListener(config_listener);
513511
model_widget.propTitleFont().removePropertyListener(config_listener);
514512
model_widget.propToolbar().removePropertyListener(config_listener);
@@ -638,7 +636,6 @@ private void updateConfig()
638636
final Color foreground = JFXUtil.convert(model_widget.propForeground().getValue());
639637
plot.setForeground(foreground);
640638
plot.setBackground(JFXUtil.convert(model_widget.propBackground().getValue()));
641-
// plot.setGridColor(JFXUtil.convert(model_widget.propGridColor().getValue()));
642639
plot.setTitleFont(JFXUtil.convert(model_widget.propTitleFont().getValue()));
643640
plot.setTitle(model_widget.propTitle().getValue());
644641

0 commit comments

Comments
 (0)