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

removed setTheme from styleManager for issue 33 : https://github.com/timmolter/XChart/issues/33

parent e5ca9b37
Branches
No related tags found
No related merge requests found
...@@ -46,7 +46,6 @@ public class CSVExporter { ...@@ -46,7 +46,6 @@ public class CSVExporter {
} }
} }
} }
} }
public static void writeCSVColumns(Series series, String path2Dir) { public static void writeCSVColumns(Series series, String path2Dir) {
......
...@@ -29,6 +29,8 @@ import java.math.BigDecimal; ...@@ -29,6 +29,8 @@ import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.xeiam.xchart.StyleManager.ChartTheme;
/** /**
* This class is used to create a Chart object from a folder containing one or more CSV files. The parent folder's name becomes the title of the chart. Each CSV file in the folder becomes a series on * This class is used to create a Chart object from a folder containing one or more CSV files. The parent folder's name becomes the title of the chart. Each CSV file in the folder becomes a series on
* the chart. the CSV file's name becomes the series' name. * the chart. the CSV file's name becomes the series' name.
...@@ -44,15 +46,21 @@ public class CSVImporter { ...@@ -44,15 +46,21 @@ public class CSVImporter {
/** /**
* @param path2Directory * @param path2Directory
* @param dataOrientation
* @param width * @param width
* @param height * @param height
* @param chartTheme
* @return * @return
*/ */
public static Chart getChartFromCSVDir(String path2Directory, DataOrientation dataOrientation, int width, int height) { public static Chart getChartFromCSVDir(String path2Directory, DataOrientation dataOrientation, int width, int height, ChartTheme chartTheme) {
// 1. get the directory, name chart the dir name // 1. get the directory, name chart the dir name
Chart chart = null;
Chart chart = new Chart(width, height); if (chartTheme != null) {
chart = new Chart(width, height, chartTheme);
} else {
chart = new Chart(width, height);
}
// 2. get all the csv files in the dir // 2. get all the csv files in the dir
File[] csvFiles = getAllFiles(path2Directory, ".*.csv"); File[] csvFiles = getAllFiles(path2Directory, ".*.csv");
...@@ -72,6 +80,18 @@ public class CSVImporter { ...@@ -72,6 +80,18 @@ public class CSVImporter {
return chart; return chart;
} }
/**
* @param path2Directory
* @param dataOrientation
* @param width
* @param height
* @return
*/
public static Chart getChartFromCSVDir(String path2Directory, DataOrientation dataOrientation, int width, int height) {
return getChartFromCSVDir(path2Directory, dataOrientation, width, height, null);
}
private static String[] getSeriesDataFromCSVRows(File csvFile) { private static String[] getSeriesDataFromCSVRows(File csvFile) {
String[] xAndYData = new String[2]; String[] xAndYData = new String[2];
......
...@@ -21,8 +21,12 @@ import java.util.Collection; ...@@ -21,8 +21,12 @@ import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.Map; import java.util.Map;
import com.xeiam.xchart.StyleManager.ChartTheme;
import com.xeiam.xchart.internal.chartpart.ChartPainter; import com.xeiam.xchart.internal.chartpart.ChartPainter;
import com.xeiam.xchart.internal.style.GGPlot2Theme;
import com.xeiam.xchart.internal.style.MatlabTheme;
import com.xeiam.xchart.internal.style.Theme; import com.xeiam.xchart.internal.style.Theme;
import com.xeiam.xchart.internal.style.XChartTheme;
/** /**
* An XChart Chart * An XChart Chart
...@@ -42,6 +46,27 @@ public class Chart { ...@@ -42,6 +46,27 @@ public class Chart {
public Chart(int width, int height) { public Chart(int width, int height) {
chartPainter = new ChartPainter(width, height); chartPainter = new ChartPainter(width, height);
}
/**
* Constructor
*
* @param width
* @param height
* @param chartTheme
*/
public Chart(int width, int height, ChartTheme chartTheme) {
chartPainter = new ChartPainter(width, height);
if (chartTheme == ChartTheme.XChart) {
setTheme(new XChartTheme());
} else if (chartTheme == ChartTheme.GGPlot2) {
setTheme(new GGPlot2Theme());
} else if (chartTheme == ChartTheme.Matlab) {
setTheme(new MatlabTheme());
}
} }
/** /**
...@@ -51,8 +76,7 @@ public class Chart { ...@@ -51,8 +76,7 @@ public class Chart {
*/ */
public Chart(ChartBuilder chartBuilder) { public Chart(ChartBuilder chartBuilder) {
this(chartBuilder.width, chartBuilder.height); this(chartBuilder.width, chartBuilder.height, chartBuilder.chartTheme);
getStyleManager().setChartTheme(chartBuilder.chartTheme);
setChartTitle(chartBuilder.title); setChartTitle(chartBuilder.title);
setXAxisTitle(chartBuilder.xAxisTitle); setXAxisTitle(chartBuilder.xAxisTitle);
setYAxisTitle(chartBuilder.yAxisTitle); setYAxisTitle(chartBuilder.yAxisTitle);
......
...@@ -27,8 +27,6 @@ import java.awt.Stroke; ...@@ -27,8 +27,6 @@ import java.awt.Stroke;
import java.util.Locale; import java.util.Locale;
import java.util.TimeZone; import java.util.TimeZone;
import com.xeiam.xchart.internal.style.GGPlot2Theme;
import com.xeiam.xchart.internal.style.MatlabTheme;
import com.xeiam.xchart.internal.style.Theme; import com.xeiam.xchart.internal.style.Theme;
import com.xeiam.xchart.internal.style.XChartTheme; import com.xeiam.xchart.internal.style.XChartTheme;
...@@ -201,28 +199,12 @@ public class StyleManager { ...@@ -201,28 +199,12 @@ public class StyleManager {
* *
* @param theme * @param theme
*/ */
public void setTheme(Theme theme) { protected void setTheme(Theme theme) {
this.theme = theme; this.theme = theme;
setAllStyles(); setAllStyles();
} }
/**
* Set the ChartTheme the style manager should use
*
* @param theme
*/
public void setChartTheme(ChartTheme chartTheme) {
if (chartTheme == ChartTheme.XChart) {
setTheme(new XChartTheme());
} else if (chartTheme == ChartTheme.GGPlot2) {
setTheme(new GGPlot2Theme());
} else if (chartTheme == ChartTheme.Matlab) {
setTheme(new MatlabTheme());
}
}
public Theme getTheme() { public Theme getTheme() {
return theme; return theme;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment