Skip to content

Phase 6: Rendering cleanup — PlotContent_Category + PlotContent_XY#961

Open
timmolter wants to merge 2 commits into
developfrom
timmolter/phase-6-rendering-cleanup
Open

Phase 6: Rendering cleanup — PlotContent_Category + PlotContent_XY#961
timmolter wants to merge 2 commits into
developfrom
timmolter/phase-6-rendering-cleanup

Conversation

@timmolter
Copy link
Copy Markdown
Member

Summary

Low-risk rendering cleanup targeting the two largest PlotContent_* classes. No logic changes — pixel output is identical before and after.


Step 1: Rename PlotContent_Category_BarPlotContent_Category

The _Bar suffix was a historical artifact. The class renders all CategorySeries render styles (Bar, Stick, Line, Area, Scatter, SteppedBar). Updated the single instantiation site in Plot_Category.java.


Step 2: Extract private methods from PlotContent_Category.doPaint()

The 490-line doPaint() is now a clean loop dispatcher. Extracted:

Method What it does
computeBarDimensions(series, categoryCounter, gridStep, xLeftMargin, seriesCounter) Calculates barWidth and xOffset for a given category/series position (was an anonymous braced scope)
processSteppedBarDataPoint(g, series, y, yOffset, zeroOffset, xOffset, gridStep, seriesCounter, isLastPoint, steppedPath, steppedReturnPath, previousY) Accumulates one data point into the stepped-bar path; handles stacked sign-change mid-draw; returns updated previousY
finalizeSteppedBar(g, series, steppedPath, steppedReturnPath) Draws the accumulated stepped-bar path after all data points for a series are processed

Key design decisions:

  • Stacking accumulator arrays are passed as parameters, not fields
  • steppedPath/steppedReturnPath pre-initialized as empty ArrayLists so they can be passed into extracted methods; isEmpty() replaces the null sentinel check
  • drawLabels() was already properly extracted — left as-is

Step 3: Extract paintErrorBar() from PlotContent_XY.doPaint()

The 47-line error bar block (top/bottom value + three Line2D segments) was self-contained. Extracted into private paintErrorBar(...).


Verification

mvn test -pl xchart
Tests run: 73, Failures: 0, Errors: 0, Skipped: 0 — BUILD SUCCESS
mvn fmt:check -pl xchart — BUILD SUCCESS

timmolter and others added 2 commits May 29, 2026 21:30
The _Bar suffix was a historical artifact from when category charts
only supported bar rendering. The class now renders all CategorySeries
render styles: Bar, Stick, Line, Area, Scatter, and SteppedBar.

Update the single instantiation site in Plot_Category.java accordingly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The 47-line error bar drawing block (top/bottom value calculation +
drawing three Line2D segments) is self-contained. Extract it into a
private paintErrorBar() helper to reduce doPaint() length and improve
readability.

No logic changes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant