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

clean up generics more

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