Fix IDE warnings across xchart, xchart-demo, and xchart-site#944
Merged
Conversation
…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>
This reverts commit 2cc1b1a.
- 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/)IChart-- a non-generic rendering interface (paint,getWidth,getHeight,getTitle) implemented byChart<ST,S>. This eliminates the need forChart<?,?>wildcards throughout the encoder APIs (BitmapEncoder,VectorGraphicsEncoder,PdfboxGraphicsEncoder), which now acceptIChart/List<? extends IChart>.Chart,AxisPair,Annotation,ChartBuilder,ColocatedSlaveLabels,PlotContent_XY,Axis_-- all now properly parameterized with<?,?>or specific bounds.Cursor.chart,ToolTips.chart,Legend_HorizontalBar.axesChartStyler.AxisPair.leftStart,AxisTickCalculator_.averageValue,Trapezoid.halfSize.Theme.javaand dead empty method inPlotContent_OHLC.RegressionIssue536Test.Demo (
xchart-demo/src/)<>to all rawSwingWrapperconstructor calls (15 sites) and typed variable declarations.JComboBox,Class,Constructor, andHashMapusages inChartStylePanel.XChartPanelfield and method params inChartStylePanelandXChartStyleDemo.TestForIssue1:List<Chart>->List<XYChart>.BarChart11,BarChart12,DialChart02,LineChart08,TestForIssue390,TestForIssue545.Site (
xchart-site/src/)@SuppressWarnings("unchecked")inGenerateSite.Notes
XChartPanel<T extends Chart<?,?>>andSwingWrapper<T extends Chart<?,?>>deliberately retain their typed bounds -- they callgetStyler(),enableInteractionData(), etc., which require the fullChartAPI rather than justIChart.mvn clean verifybuild is green.