Skip to content
Snippets Groups Projects
Commit 8f46a3f5 authored by Tim Molter's avatar Tim Molter
Browse files

clean up generics more

parent b97876fa
Branches
No related tags found
No related merge requests found
...@@ -16,9 +16,9 @@ ...@@ -16,9 +16,9 @@
*/ */
package org.knowm.xchart.standalone; package org.knowm.xchart.standalone;
import org.knowm.xchart.Chart_XY;
import org.knowm.xchart.QuickChart; import org.knowm.xchart.QuickChart;
import org.knowm.xchart.SwingWrapper; import org.knowm.xchart.SwingWrapper;
import org.knowm.xchart.internal.chartpart.Chart;
/** /**
* Creates a simple Chart using QuickChart * Creates a simple Chart using QuickChart
...@@ -31,7 +31,7 @@ public class Example0 { ...@@ -31,7 +31,7 @@ public class Example0 {
double[] yData = new double[] { 2.0, 1.0, 0.0 }; double[] yData = new double[] { 2.0, 1.0, 0.0 };
// Create Chart // Create Chart
Chart chart = QuickChart.getChart("Sample Chart", "X", "Y", "y(x)", xData, yData); Chart_XY chart = QuickChart.getChart("Sample Chart", "X", "Y", "y(x)", xData, yData);
// Show it // Show it
new SwingWrapper(chart).displayChart(); new SwingWrapper(chart).displayChart();
......
...@@ -49,7 +49,7 @@ public final class QuickChart { ...@@ -49,7 +49,7 @@ public final class QuickChart {
* @param yData An array containing Y-Axis data * @param yData An array containing Y-Axis data
* @return a Chart Object * @return a Chart Object
*/ */
public static Chart getChart(String chartTitle, String xTitle, String yTitle, String seriesName, double[] xData, double[] yData) { public static Chart_XY getChart(String chartTitle, String xTitle, String yTitle, String seriesName, double[] xData, double[] yData) {
double[][] yData2d = { yData }; double[][] yData2d = { yData };
if (seriesName == null) { if (seriesName == null) {
...@@ -71,7 +71,7 @@ public final class QuickChart { ...@@ -71,7 +71,7 @@ public final class QuickChart {
* @param yData An array of double arrays containing multiple Y-Axis data * @param yData An array of double arrays containing multiple Y-Axis data
* @return a Chart Object * @return a Chart Object
*/ */
public static Chart getChart(String chartTitle, String xTitle, String yTitle, String[] seriesNames, double[] xData, double[][] yData) { public static Chart_XY getChart(String chartTitle, String xTitle, String yTitle, String[] seriesNames, double[] xData, double[][] yData) {
// Create Chart // Create Chart
Chart_XY chart = new Chart_XY(WIDTH, HEIGHT); Chart_XY chart = new Chart_XY(WIDTH, HEIGHT);
......
...@@ -30,11 +30,11 @@ import org.knowm.xchart.internal.chartpart.Chart; ...@@ -30,11 +30,11 @@ import org.knowm.xchart.internal.chartpart.Chart;
* *
* @author timmolter * @author timmolter
*/ */
public class SwingWrapper { public class SwingWrapper<T extends Chart> {
private String windowTitle = "XChart"; private String windowTitle = "XChart";
private List<Chart> charts = new ArrayList<Chart>(); private List<T> charts = new ArrayList<T>();
private int numRows; private int numRows;
private int numColumns; private int numColumns;
...@@ -43,7 +43,7 @@ public class SwingWrapper { ...@@ -43,7 +43,7 @@ public class SwingWrapper {
* *
* @param chart * @param chart
*/ */
public SwingWrapper(Chart chart) { public SwingWrapper(T chart) {
this.charts.add(chart); this.charts.add(chart);
} }
...@@ -53,7 +53,7 @@ public class SwingWrapper { ...@@ -53,7 +53,7 @@ public class SwingWrapper {
* *
* @param charts * @param charts
*/ */
public SwingWrapper(List<Chart> charts) { public SwingWrapper(List<T> charts) {
this.charts = charts; this.charts = charts;
...@@ -68,7 +68,7 @@ public class SwingWrapper { ...@@ -68,7 +68,7 @@ public class SwingWrapper {
* @param numRows - the number of rows * @param numRows - the number of rows
* @param numColumns - the number of columns * @param numColumns - the number of columns
*/ */
public SwingWrapper(List<Chart> charts, int numRows, int numColumns) { public SwingWrapper(List<T> charts, int numRows, int numColumns) {
this.charts = charts; this.charts = charts;
this.numRows = numRows; this.numRows = numRows;
...@@ -103,7 +103,7 @@ public class SwingWrapper { ...@@ -103,7 +103,7 @@ public class SwingWrapper {
public void run() { public void run() {
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel chartPanel = new XChartPanel(charts.get(0)); JPanel chartPanel = new XChartPanel<T>(charts.get(0));
frame.add(chartPanel); frame.add(chartPanel);
// Display the window. // Display the window.
...@@ -146,9 +146,9 @@ public class SwingWrapper { ...@@ -146,9 +146,9 @@ public class SwingWrapper {
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(new GridLayout(numRows, numColumns)); frame.getContentPane().setLayout(new GridLayout(numRows, numColumns));
for (Chart chart : charts) { for (T chart : charts) {
if (chart != null) { if (chart != null) {
JPanel chartPanel = new XChartPanel(chart); JPanel chartPanel = new XChartPanel<T>(chart);
frame.add(chartPanel); frame.add(chartPanel);
} }
else { else {
......
...@@ -28,7 +28,7 @@ import de.erichseifert.vectorgraphics2d.VectorGraphics2D; ...@@ -28,7 +28,7 @@ import de.erichseifert.vectorgraphics2d.VectorGraphics2D;
/** /**
* A helper class with static methods for saving Charts as bitmaps * A helper class with static methods for saving Charts as bitmaps
* *
* @author timmolter * @author timmolter
*/ */
public final class VectorGraphicsEncoder { public final class VectorGraphicsEncoder {
......
...@@ -41,7 +41,6 @@ import javax.swing.filechooser.FileFilter; ...@@ -41,7 +41,6 @@ import javax.swing.filechooser.FileFilter;
import org.knowm.xchart.BitmapEncoder.BitmapFormat; import org.knowm.xchart.BitmapEncoder.BitmapFormat;
import org.knowm.xchart.VectorGraphicsEncoder.VectorGraphicsFormat; import org.knowm.xchart.VectorGraphicsEncoder.VectorGraphicsFormat;
import org.knowm.xchart.internal.Series;
import org.knowm.xchart.internal.Series_AxesChart; import org.knowm.xchart.internal.Series_AxesChart;
import org.knowm.xchart.internal.chartpart.Chart; import org.knowm.xchart.internal.chartpart.Chart;
...@@ -293,7 +292,7 @@ public class XChartPanel<T extends Chart> extends JPanel { ...@@ -293,7 +292,7 @@ public class XChartPanel<T extends Chart> extends JPanel {
* @param newErrorBarData - set null if there are no error bars * @param newErrorBarData - set null if there are no error bars
* @return * @return
*/ */
public Series updateSeries(String seriesName, List<?> newXData, List<? extends Number> newYData, List<? extends Number> newErrorBarData) { public Series_AxesChart updateSeries(String seriesName, List<?> newXData, List<? extends Number> newYData, List<? extends Number> newErrorBarData) {
Map<String, Series_AxesChart> seriesMap = chart.getSeriesMap(); Map<String, Series_AxesChart> seriesMap = chart.getSeriesMap();
Series_AxesChart series = seriesMap.get(seriesName); Series_AxesChart series = seriesMap.get(seriesName);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment