Skip to content
Snippets Groups Projects
Commit 5c8353b2 authored by timmolter's avatar timmolter
Browse files

new Constructor - The number of rows and columns will be calculated automatically

parent 1e738625
No related branches found
No related tags found
No related merge requests found
......@@ -51,6 +51,8 @@ public class SwingWrapper {
* Deprecated Constructor - use the one that takes a Collection! This will be removed in next version.
*
* @param charts
* @param numRows
* @param numColumns
*/
@Deprecated
public SwingWrapper(Chart[] charts, int numRows, int numColumns) {
......@@ -62,10 +64,27 @@ public class SwingWrapper {
this.numColumns = numColumns;
}
/**
* Constructor - The number of rows and columns will be calculated automatically
*
* @param charts
* @param numRows
* @param numColumns
*/
public SwingWrapper(List<Chart> charts) {
this.charts = charts;
this.numRows = (int) (Math.sqrt(charts.size()) + .5);
this.numColumns = (int) ((double) charts.size() / this.numRows + 1);
}
/**
* Constructor
*
* @param charts
* @param numRows - the number of rows
* @param numColumns - the number of columns
*/
public SwingWrapper(List<Chart> charts, int numRows, int numColumns) {
......
......@@ -31,17 +31,14 @@ public class Example4 {
public static void main(String[] args) {
int numRows = 2;
int numCols = 2;
int numCharts = 4;
List<Chart> charts = new ArrayList<Chart>();
for (int i = 0; i < numRows; i++) {
for (int j = 0; j < numCols; j++) {
charts.add(QuickChart.getChart(i + "," + j, "X", "Y", null, null, getRandomWalk(1000)));
}
for (int i = 0; i < numCharts; i++) {
charts.add(QuickChart.getChart("" + i, "X", "Y", null, null, getRandomWalk(1000)));
}
new SwingWrapper(charts, numRows, numCols).displayChartMatrix();
new SwingWrapper(charts).displayChartMatrix();
}
/**
......
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