2323import org .csstudio .display .builder .model .widgets .plots .PlotWidgetPointType ;
2424import org .csstudio .display .builder .model .widgets .plots .PlotWidgetProperties .AxisWidgetProperty ;
2525import org .csstudio .display .builder .model .widgets .plots .PlotWidgetProperties .TraceWidgetProperty ;
26+ import org .csstudio .display .builder .model .widgets .plots .PlotWidgetProperties .YAxisWidgetProperty ;
2627import org .csstudio .display .builder .model .widgets .plots .PlotWidgetTraceType ;
2728import org .csstudio .display .builder .model .widgets .plots .XYPlotWidget ;
2829import org .csstudio .display .builder .model .widgets .plots .XYPlotWidget .MarkerProperty ;
@@ -67,7 +68,7 @@ public class XYPlotRepresentation extends RegionBaseRepresentation<Pane, XYPlotW
6768 private final DirtyFlag dirty_position = new DirtyFlag ();
6869 private final DirtyFlag dirty_range = new DirtyFlag ();
6970 private final DirtyFlag dirty_config = new DirtyFlag ();
70- private final WidgetPropertyListener <List <AxisWidgetProperty >> yaxes_listener = this ::yAxesChanged ;
71+ private final WidgetPropertyListener <List <YAxisWidgetProperty >> yaxes_listener = this ::yAxesChanged ;
7172 private final UntypedWidgetPropertyListener position_listener = this ::positionChanged ;
7273 private final WidgetPropertyListener <List <TraceWidgetProperty >> traces_listener = this ::tracesChanged ;
7374 private final WidgetPropertyListener <Instant > configure_listener = (p , o , n ) -> plot .showConfigurationDialog ();
@@ -481,7 +482,7 @@ protected void registerListeners()
481482 trackAxisChanges (model_widget .propXAxis ());
482483
483484 // Track initial Y axis
484- final List <AxisWidgetProperty > y_axes = model_widget .propYAxes ().getValue ();
485+ final List <YAxisWidgetProperty > y_axes = model_widget .propYAxes ().getValue ();
485486 trackAxisChanges (y_axes .get (0 ));
486487 // Create additional Y axes from model
487488 if (y_axes .size () > 1 )
@@ -512,7 +513,7 @@ protected void unregisterListeners()
512513 model_widget .propLegend ().removePropertyListener (config_listener );
513514
514515 ignoreAxisChanges (model_widget .propXAxis ());
515- final List <AxisWidgetProperty > y_axes = model_widget .propYAxes ().getValue ();
516+ final List <YAxisWidgetProperty > y_axes = model_widget .propYAxes ().getValue ();
516517 for (AxisWidgetProperty axis : y_axes )
517518 ignoreAxisChanges (axis );
518519 model_widget .propYAxes ().removePropertyListener (yaxes_listener );
@@ -543,6 +544,8 @@ private void trackAxisChanges(final AxisWidgetProperty axis)
543544 axis .titleFont ().addUntypedPropertyListener (config_listener );
544545 axis .scaleFont ().addUntypedPropertyListener (config_listener );
545546 axis .visible ().addUntypedPropertyListener (config_listener );
547+ if (axis instanceof YAxisWidgetProperty )
548+ ((YAxisWidgetProperty ) axis ).onRight ().addUntypedPropertyListener (config_listener );
546549 }
547550
548551 /** Ignore changed axis properties
@@ -559,15 +562,17 @@ private void ignoreAxisChanges(final AxisWidgetProperty axis)
559562 axis .titleFont ().removePropertyListener (config_listener );
560563 axis .scaleFont ().removePropertyListener (config_listener );
561564 axis .visible ().removePropertyListener (config_listener );
565+ if (axis instanceof YAxisWidgetProperty )
566+ ((YAxisWidgetProperty ) axis ).onRight ().removePropertyListener (config_listener );
562567 }
563568
564- private void yAxesChanged (final WidgetProperty <List <AxisWidgetProperty >> property ,
565- final List <AxisWidgetProperty > removed , final List <AxisWidgetProperty > added )
569+ private void yAxesChanged (final WidgetProperty <List <YAxisWidgetProperty >> property ,
570+ final List <YAxisWidgetProperty > removed , final List <YAxisWidgetProperty > added )
566571 {
567572 // Remove axis
568573 if (removed != null )
569574 { // Notification holds the one removed axis, which was the last one
570- final AxisWidgetProperty axis = removed .get (0 );
575+ final YAxisWidgetProperty axis = removed .get (0 );
571576 final int index = plot .getYAxes ().size ()-1 ;
572577 ignoreAxisChanges (axis );
573578 plot .removeYAxis (index );
@@ -577,7 +582,7 @@ private void yAxesChanged(final WidgetProperty<List<AxisWidgetProperty>> propert
577582 // Notification will hold the one added axis,
578583 // but initial call from registerListeners() will hold all axes to add
579584 if (added != null )
580- for (AxisWidgetProperty axis : added )
585+ for (YAxisWidgetProperty axis : added )
581586 {
582587 plot .addYAxis (axis .title ().getValue ());
583588 trackAxisChanges (axis );
@@ -643,7 +648,7 @@ private void updateConfig()
643648 plot .setLegendFont (JFXUtil .convert (model_widget .propXAxis ().titleFont ().getValue ()));
644649
645650 // Update Y Axes
646- final List <AxisWidgetProperty > model_y = model_widget .propYAxes ().getValue ();
651+ final List <YAxisWidgetProperty > model_y = model_widget .propYAxes ().getValue ();
647652 if (plot .getYAxes ().size () != model_y .size ())
648653 {
649654 logger .log (Level .WARNING , "Plot has " + plot .getYAxes ().size () + " while model has " + model_y .size () + " Y axes" );
@@ -654,6 +659,7 @@ private void updateConfig()
654659 {
655660 plot_axis .useTraceNames (!legend );
656661 updateAxisConfig (plot_axis , model_y .get (i ));
662+ plot_axis .setOnRight (model_y .get (i ).onRight ().getValue ());
657663 ++i ;
658664 }
659665 }
@@ -677,7 +683,7 @@ private void updateRanges()
677683 updateAxisRange (plot .getXAxis (), model_widget .propXAxis ());
678684
679685 // Update Y Axes
680- final List <AxisWidgetProperty > model_y = model_widget .propYAxes ().getValue ();
686+ final List <YAxisWidgetProperty > model_y = model_widget .propYAxes ().getValue ();
681687 if (plot .getYAxes ().size () != model_y .size ())
682688 {
683689 logger .log (Level .WARNING , "Plot has " + plot .getYAxes ().size () + " while model has " + model_y .size () + " Y axes" );
0 commit comments