@Test public void point2DDatsetsFromVTable3() { VTable data = ValueFactory.newVTable(Arrays.<Class<?>>asList( double.class, double.class, double.class), Arrays.asList("y1", "y2", "y3"), Arrays.<Object>asList(new ArrayDouble(5,4,6), new ArrayDouble(10,20,30), new ArrayDouble(50,40,60))); List<Point2DDataset> datasets = DatasetConversions.point2DDatasetsFromVTable(data, null, null); assertThat(datasets.size(), equalTo(3)); Point2DDataset dataset = datasets.get(0); assertThat(dataset.getCount(), equalTo(3)); assertThat(dataset.getXValues(), equalTo((ListNumber) new ArrayDouble(0,1,2))); assertThat(dataset.getYValues(), equalTo((ListNumber) new ArrayDouble(5,4,6))); dataset = datasets.get(1); assertThat(dataset.getCount(), equalTo(3)); assertThat(dataset.getXValues(), equalTo((ListNumber) new ArrayDouble(0,1,2))); assertThat(dataset.getYValues(), equalTo((ListNumber) new ArrayDouble(10,20,30))); dataset = datasets.get(2); assertThat(dataset.getCount(), equalTo(3)); assertThat(dataset.getXValues(), equalTo((ListNumber) new ArrayDouble(0,1,2))); assertThat(dataset.getYValues(), equalTo((ListNumber) new ArrayDouble(50,40,60))); }
public static List<Point2DDataset> point2DDatasetsFromVTable(VTable vTable, List<String> xColumns, List<String> yColumns) { List<ListNumber> xValues = new ArrayList<>(); List<ListNumber> yValues = new ArrayList<>(); if (xColumns != null && yColumns != null) { for (String column : xColumns) { xValues.add(ValueUtil.numericColumnOf(vTable, column)); } for (String column : yColumns) { yValues.add(ValueUtil.numericColumnOf(vTable, column)); } } else if (xColumns == null && yColumns == null) { for (int i = 0; i < vTable.getColumnCount(); i++) { if (vTable.getColumnType(i).isPrimitive()) { yValues.add((ListNumber) vTable.getColumnData(i)); } } } else { throw new UnsupportedOperationException("Not supported yet."); } if (xValues.isEmpty()) { List<Point2DDataset> datasets = new ArrayList<>(); for (int i = 0; i < yValues.size(); i++) { datasets.add(Point2DDatasets.lineData(ListNumbers.linearList(0, 1, yValues.get(i).size()), yValues.get(i))); } return datasets; } if (xValues.size() == yValues.size()) { List<Point2DDataset> datasets = new ArrayList<>(); for (int i = 0; i < xValues.size(); i++) { datasets.add(Point2DDatasets.lineData(xValues.get(i), yValues.get(i))); } return datasets; } if (xValues.size() == 1) { List<Point2DDataset> datasets = new ArrayList<>(); for (int i = 0; i < yValues.size(); i++) { datasets.add(Point2DDatasets.lineData(xValues.get(0), yValues.get(i))); } return datasets; } throw new UnsupportedOperationException("Not supported yet."); }
DatasetConversions { public static List<Point2DDataset> point2DDatasetsFromVTable(VTable vTable, List<String> xColumns, List<String> yColumns) { List<ListNumber> xValues = new ArrayList<>(); List<ListNumber> yValues = new ArrayList<>(); if (xColumns != null && yColumns != null) { for (String column : xColumns) { xValues.add(ValueUtil.numericColumnOf(vTable, column)); } for (String column : yColumns) { yValues.add(ValueUtil.numericColumnOf(vTable, column)); } } else if (xColumns == null && yColumns == null) { for (int i = 0; i < vTable.getColumnCount(); i++) { if (vTable.getColumnType(i).isPrimitive()) { yValues.add((ListNumber) vTable.getColumnData(i)); } } } else { throw new UnsupportedOperationException("Not supported yet."); } if (xValues.isEmpty()) { List<Point2DDataset> datasets = new ArrayList<>(); for (int i = 0; i < yValues.size(); i++) { datasets.add(Point2DDatasets.lineData(ListNumbers.linearList(0, 1, yValues.get(i).size()), yValues.get(i))); } return datasets; } if (xValues.size() == yValues.size()) { List<Point2DDataset> datasets = new ArrayList<>(); for (int i = 0; i < xValues.size(); i++) { datasets.add(Point2DDatasets.lineData(xValues.get(i), yValues.get(i))); } return datasets; } if (xValues.size() == 1) { List<Point2DDataset> datasets = new ArrayList<>(); for (int i = 0; i < yValues.size(); i++) { datasets.add(Point2DDatasets.lineData(xValues.get(0), yValues.get(i))); } return datasets; } throw new UnsupportedOperationException("Not supported yet."); } }
DatasetConversions { public static List<Point2DDataset> point2DDatasetsFromVTable(VTable vTable, List<String> xColumns, List<String> yColumns) { List<ListNumber> xValues = new ArrayList<>(); List<ListNumber> yValues = new ArrayList<>(); if (xColumns != null && yColumns != null) { for (String column : xColumns) { xValues.add(ValueUtil.numericColumnOf(vTable, column)); } for (String column : yColumns) { yValues.add(ValueUtil.numericColumnOf(vTable, column)); } } else if (xColumns == null && yColumns == null) { for (int i = 0; i < vTable.getColumnCount(); i++) { if (vTable.getColumnType(i).isPrimitive()) { yValues.add((ListNumber) vTable.getColumnData(i)); } } } else { throw new UnsupportedOperationException("Not supported yet."); } if (xValues.isEmpty()) { List<Point2DDataset> datasets = new ArrayList<>(); for (int i = 0; i < yValues.size(); i++) { datasets.add(Point2DDatasets.lineData(ListNumbers.linearList(0, 1, yValues.get(i).size()), yValues.get(i))); } return datasets; } if (xValues.size() == yValues.size()) { List<Point2DDataset> datasets = new ArrayList<>(); for (int i = 0; i < xValues.size(); i++) { datasets.add(Point2DDatasets.lineData(xValues.get(i), yValues.get(i))); } return datasets; } if (xValues.size() == 1) { List<Point2DDataset> datasets = new ArrayList<>(); for (int i = 0; i < yValues.size(); i++) { datasets.add(Point2DDatasets.lineData(xValues.get(0), yValues.get(i))); } return datasets; } throw new UnsupportedOperationException("Not supported yet."); }  }
DatasetConversions { public static List<Point2DDataset> point2DDatasetsFromVTable(VTable vTable, List<String> xColumns, List<String> yColumns) { List<ListNumber> xValues = new ArrayList<>(); List<ListNumber> yValues = new ArrayList<>(); if (xColumns != null && yColumns != null) { for (String column : xColumns) { xValues.add(ValueUtil.numericColumnOf(vTable, column)); } for (String column : yColumns) { yValues.add(ValueUtil.numericColumnOf(vTable, column)); } } else if (xColumns == null && yColumns == null) { for (int i = 0; i < vTable.getColumnCount(); i++) { if (vTable.getColumnType(i).isPrimitive()) { yValues.add((ListNumber) vTable.getColumnData(i)); } } } else { throw new UnsupportedOperationException("Not supported yet."); } if (xValues.isEmpty()) { List<Point2DDataset> datasets = new ArrayList<>(); for (int i = 0; i < yValues.size(); i++) { datasets.add(Point2DDatasets.lineData(ListNumbers.linearList(0, 1, yValues.get(i).size()), yValues.get(i))); } return datasets; } if (xValues.size() == yValues.size()) { List<Point2DDataset> datasets = new ArrayList<>(); for (int i = 0; i < xValues.size(); i++) { datasets.add(Point2DDatasets.lineData(xValues.get(i), yValues.get(i))); } return datasets; } if (xValues.size() == 1) { List<Point2DDataset> datasets = new ArrayList<>(); for (int i = 0; i < yValues.size(); i++) { datasets.add(Point2DDatasets.lineData(xValues.get(0), yValues.get(i))); } return datasets; } throw new UnsupportedOperationException("Not supported yet."); }  static Point2DDataset point2DDatasetFromVTable(VTable vTable,
            String xColumn, String yColumn); static Point3DWithLabelDataset point3DDatasetFromVTable(VTable vTable,
            String xColumn, String yColumn, String sizeColumn, String colorColumn); static List<Point2DDataset> point2DDatasetsFromVTable(VTable vTable, List<String> xColumns, List<String> yColumns); static Cell2DDataset cell2DDatasetsFromVNumberArray(VNumberArray data); static Range toRange(Display display); static Cell1DDataset cell1DDatasetsFromVNumberArray(VNumberArray data); }
DatasetConversions { public static List<Point2DDataset> point2DDatasetsFromVTable(VTable vTable, List<String> xColumns, List<String> yColumns) { List<ListNumber> xValues = new ArrayList<>(); List<ListNumber> yValues = new ArrayList<>(); if (xColumns != null && yColumns != null) { for (String column : xColumns) { xValues.add(ValueUtil.numericColumnOf(vTable, column)); } for (String column : yColumns) { yValues.add(ValueUtil.numericColumnOf(vTable, column)); } } else if (xColumns == null && yColumns == null) { for (int i = 0; i < vTable.getColumnCount(); i++) { if (vTable.getColumnType(i).isPrimitive()) { yValues.add((ListNumber) vTable.getColumnData(i)); } } } else { throw new UnsupportedOperationException("Not supported yet."); } if (xValues.isEmpty()) { List<Point2DDataset> datasets = new ArrayList<>(); for (int i = 0; i < yValues.size(); i++) { datasets.add(Point2DDatasets.lineData(ListNumbers.linearList(0, 1, yValues.get(i).size()), yValues.get(i))); } return datasets; } if (xValues.size() == yValues.size()) { List<Point2DDataset> datasets = new ArrayList<>(); for (int i = 0; i < xValues.size(); i++) { datasets.add(Point2DDatasets.lineData(xValues.get(i), yValues.get(i))); } return datasets; } if (xValues.size() == 1) { List<Point2DDataset> datasets = new ArrayList<>(); for (int i = 0; i < yValues.size(); i++) { datasets.add(Point2DDatasets.lineData(xValues.get(0), yValues.get(i))); } return datasets; } throw new UnsupportedOperationException("Not supported yet."); }  static Point2DDataset point2DDatasetFromVTable(VTable vTable,
            String xColumn, String yColumn); static Point3DWithLabelDataset point3DDatasetFromVTable(VTable vTable,
            String xColumn, String yColumn, String sizeColumn, String colorColumn); static List<Point2DDataset> point2DDatasetsFromVTable(VTable vTable, List<String> xColumns, List<String> yColumns); static Cell2DDataset cell2DDatasetsFromVNumberArray(VNumberArray data); static Range toRange(Display display); static Cell1DDataset cell1DDatasetsFromVNumberArray(VNumberArray data);  }