Skip to content

Fix IDE warnings across xchart, xchart-demo, and xchart-site#944

Merged
timmolter merged 8 commits into
developfrom
timmolter/investigate-ide-warnings
May 22, 2026
Merged

Fix IDE warnings across xchart, xchart-demo, and xchart-site#944
timmolter merged 8 commits into
developfrom
timmolter/investigate-ide-warnings

Conversation

@timmolter
Copy link
Copy Markdown
Member

Motivation

The codebase had accumulated a significant number of IDE warnings: raw generic types, unused variables/fields, unused imports, and dead code. These add noise to the IDE, make it harder to spot real issues, and signal areas where the type system isn't being used to its full potential.

What changed

Core library (xchart/src/)

  • Introduced IChart -- a non-generic rendering interface (paint, getWidth, getHeight, getTitle) implemented by Chart<ST,S>. This eliminates the need for Chart<?,?> wildcards throughout the encoder APIs (BitmapEncoder, VectorGraphicsEncoder, PdfboxGraphicsEncoder), which now accept IChart / List<? extends IChart>.
  • Fixed all raw type usages in the core: Chart, AxisPair, Annotation, ChartBuilder, ColocatedSlaveLabels, PlotContent_XY, Axis_ -- all now properly parameterized with <?,?> or specific bounds.
  • Removed unused fields: Cursor.chart, ToolTips.chart, Legend_HorizontalBar.axesChartStyler.
  • Removed unused local variables: AxisPair.leftStart, AxisTickCalculator_.averageValue, Trapezoid.halfSize.
  • Removed unused import in Theme.java and dead empty method in PlotContent_OHLC.
  • Fixed unused variable assignments in RegressionIssue536Test.

Demo (xchart-demo/src/)

  • Added diamond operator <> to all raw SwingWrapper constructor calls (15 sites) and typed variable declarations.
  • Parameterized all raw JComboBox, Class, Constructor, and HashMap usages in ChartStylePanel.
  • Parameterized raw XChartPanel field and method params in ChartStylePanel and XChartStyleDemo.
  • Fixed TestForIssue1: List<Chart> -> List<XYChart>.
  • Removed unused local variable assignments (series return values that were never read) across BarChart11, BarChart12, DialChart02, LineChart08, TestForIssue390, TestForIssue545.
  • Removed unused imports across several standalone test files.

Site (xchart-site/src/)

  • Removed a now-unnecessary @SuppressWarnings("unchecked") in GenerateSite.

Notes

  • XChartPanel<T extends Chart<?,?>> and SwingWrapper<T extends Chart<?,?>> deliberately retain their typed bounds -- they call getStyler(), enableInteractionData(), etc., which require the full Chart API rather than just IChart.
  • No behavior changes; this is purely a compiler/IDE hygiene pass. All 44 xchart unit tests pass and the full mvn clean verify build is green.

timmolter and others added 8 commits May 22, 2026 14:17
…types

- Remove unused local variables: leftStart (AxisPair), averageValue
  (AxisTickCalculator_), halfSize (Trapezoid), bytes (2 test files)
- Remove unused field axesChartStyler in Legend_HorizontalBar
- Remove unused import java.util.Collections from Axis_X
- Remove empty unused private method paintLine from PlotContent_OHLC
- Fix raw type warnings: Chart, AxisPair, Axis_X, Axis_Y, Axis_ all
  parameterized with <?,?> wildcards in:
  PdfboxGraphicsEncoder, VectorGraphicsEncoder, SwingWrapper,
  ChartBuilder, Annotation, AnnotationImage, AnnotationTextPanel,
  Cursor, ToolTips, Chart, PlotContent_XY, Axis_, AxisTitle,
  ColocatedSlaveLabels
- Add @SuppressWarnings("unchecked") to ChartBuilder fluent methods
  and Cursor seriesMap cast (inherently safe, wildcards cannot express
  the bounds more precisely here)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The PdfboxGraphicsEncoder API was tightened from raw List<Chart> to
List<? extends Chart<?,?>>. Update the demo callsite accordingly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add IChart (paint/getWidth/getHeight/getTitle) as the minimal rendering
contract. Chart<ST,S> implements it. BitmapEncoder, VectorGraphicsEncoder
and PdfboxGraphicsEncoder now accept IChart / List<? extends IChart>
instead of Chart<?,?> / List<? extends Chart<?,?>>, removing generic
wildcards from all public encoder APIs.

XChartPanel and SwingWrapper retain their Chart<ST,S> bounds because
they need getStyler(), enableInteractionData() etc.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Cursor.java: remove chart field (only used in constructor to extract styler/seriesMap)
- ToolTips.java: same — chart field stored but never read after construction
- Theme.java: remove unused import of org.knowm.xchart.style.Styler
  (Styler.LegendPosition is already covered by the inner-class import)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add diamond operator to all raw SwingWrapper usages (15 sites)
- Type SwingWrapper variable declarations with proper chart types
- Fix raw JComboBox usages in ChartStylePanel.java with proper type params
- Fix raw Class/Constructor/HashMap usages in ChartStylePanel.java
- Remove unused imports (IOException, XYSeries, Collection, Styler, etc.)
- Fix TestForIssue83 to use XYStyler instead of raw Styler

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Prevents stray compiled class files from being tracked if javac is ever
run directly in the source tree.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Remove unused local variables (series1/2 in BarChart11, staked1/2/3
  in BarChart12, series in DialChart02/LineChart08, bubbleSeries in
  TestForIssue545, min/max/nbInstances in TestForIssue390)
- Parameterize XChartPanel raw types in ChartStylePanel and XChartStyleDemo
- Fix raw Chart type in TestForIssue1 (List<Chart> -> List<XYChart>)
- Remove unnecessary @SuppressWarnings("unchecked") in GenerateSite
- Remove now-unused series imports after variable removals

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@timmolter timmolter merged commit e7c7bf2 into develop May 22, 2026
1 check passed
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