feat (display/rtplot): extract RTScaledWidgetRepresentation + add show_scale_labels to Tank - #3767
Conversation
|
|
@shroffk , will test next week |
|
We could also do this at the codeathon |
30c5e29 to
64ee8fb
Compare
…scale_labels to Tank Move everything in TankRepresentation that only depends on the ScaledPVWidget contract into an abstract RTScaledWidgetRepresentation: creating the RTTank, forwarding value and range updates, evaluating the alarm limits, the orientation transform and the update scheduling. TankRepresentation keeps the Tank specific listeners and colors. The behaviour of the Tank widget does not change. Add a 'show_scale_labels' property (default true) to the Tank so that stacked widgets can share one labelled scale: with the property off, YAxisImpl draws the tick marks and the axis line only. Tick positions are the same as with labels. TankWidgetUnitTest covers the new property.
64ee8fb to
6c28558
Compare
|
Rebased onto current master (the branch was ~265 commits behind) and squashed into one commit; the diff is what it was, minus the items below. The rebase turned up one real problem, now fixed: the branch had moved the Tank's border descriptor into Other changes since the April version, from a review pass before re-submitting:
Two related PRs, in case it helps to plan the codeathon:
|
|



Summary
Refactors the Tank widget's JavaFX wiring to eliminate the duplication that
existed between
TankRepresentationand (the future)RTProgressBarRepresentation,and adds a new
show_scale_labelsproperty toTankWidgetand the underlyingYAxisImplcanvas axis.This PR depends on: tank_scale_refactor (already merged as #3760).
It is recommended to merge this after #3766
(parallel_rendering preference for RTTank), but the two PRs are independent —
each applies cleanly on top of master without the other.
Merging this PR, also sets up the base class and show_scale_labels infrastructure
needed by the RTTank-based Progress Bar refactor, which will be submitted as the next PR.
What Changed
New:
RTScaledWidgetRepresentation<W>abstract base classA generic base for all widget representations whose JFX node is an
RTTank.Handles everything that depends only on the
ScaledPVWidgetcontract:RTTankSubclasses provide four template methods:
isHorizontal()horizontalpropertyregisterLookListeners()unregisterLookListeners()applyLookToTank(w, h)configureTank()is an optional no-op hook called once after tank creation.Result:
TankRepresentationcollapses from ~270 lines to ~90 lines ofwidget-specific code.
RTProgressBarRepresentation(PR3) is ~110 lines.ScaledPVWidget— newpropShowScaleLabelsdescriptorshow_scale_labels(boolean, defaulttrue) is added toScaledPVWidgetso both Tank and ProgressBar inherit it without duplication.
TankWidget— newshow_scale_labelspropertyExposes
show_scale_labelsin the property editor. Defaulttruepreservesexisting behaviour.
RTTank—setScaleLabelsVisible(boolean)Delegates to both
YAxisImplinstances (left and right scale). Each axisfires
requestLayout()/requestRefresh()internally viaplot_part_listenerwhen its state changes, so no extra
need_layoutorrequestUpdate()callsare needed in RTTank.
YAxisImpl— ticks-only rendering mode (show_labels)show_labels = falsegetDesiredPixelSizeTICK_LENGTH(10 px) immediately — no label metrics computedgetPixelGaps{0, 0}— rotated labels no longer overhang endpointspaintdrawTickLabelandpaintLabels; tick marks and axis line draw normallyshow_labelsisvolatilebecause it is read on the Java2D render threadand written on the JFX application thread.
setScaleLabelsVisiblehas an early-return guard to suppress spuriousrelayout when the value has not actually changed.
Use case: stacked widgets sharing a single labelled scale
Backward Compatibility
show_scale_labels=true— existing.bobfiles load and displayidentically.
<show_scale_labels>is silently ignored by older Phoebus.RTScaledWidgetRepresentationis package-private. No public API change.Files Changed
RTScaledWidgetRepresentation.java | 343 +++ (new)
TankRepresentation.java | 241 +/--
RTTank.java | 102 ++-
YAxisImpl.java | 38 ++-
ScaledPVWidget.java | 36 ++-
TankWidget.java | 39 +/-
Messages.java | 2 +
messages.properties | 2 +
8 files changed, ~548 insertions, ~255 deletions
Design Decisions
show_labelsasvolatilesetScaleLabelsVisible) and read on the Java2D render thread (paint,getDesiredPixelSize). Withoutvolatilethe write may not be visible to the render thread.requestUpdateinsetScaleLabelsVisibleYAxisImplaxes callrequestLayout()/requestRefresh()themselves when the value changes; these propagate toRTTank.need_layoutandrequestUpdate()viaplot_part_listener. A second explicit call would cause a redundant double-render.show_scale_labelsinScaledPVWidgetdefinePropertiesentry inScaledPVWidgettrueand a future Meter or Thermometer to choose differently.