MCPcopy Create free account
hub / github.com/OpenSourcePhysics/osp / createDataset

Method createDataset

src/org/opensourcephysics/tools/DataTool.java:2003–2028  ·  view source on GitHub ↗

Creates a dataset from double[] of data. @param xPoints the x points @param yPoints the y points @param xName the name of the x column @param yName the name of the y column @param columnID the column ID @param source the Data source providing the ID and colors @return the dataset

(double[] xPoints, double[] yPoints, String xName, String yName, int columnID,
			Data source)

Source from the content-addressed store, hash-verified

2001 * @return the dataset
2002 */
2003 private static Dataset createDataset(double[] xPoints, double[] yPoints, String xName, String yName, int columnID,
2004 Data source) {
2005 if (yPoints == null) {
2006 return null;
2007 }
2008 Dataset dataset = new Dataset();
2009 dataset.setXYColumnNames(xName, yName);
2010 dataset.setConnected(true);
2011 Color[] lineColors = source.getLineColors();
2012 if ((lineColors != null) && (lineColors[columnID] != null)) {
2013 dataset.setLineColor(lineColors[columnID]);
2014 } else {
2015 dataset.setLineColor(DisplayColors.getLineColor(columnID));
2016 }
2017 dataset.setMarkerShape(Dataset.SQUARE);
2018 Color[] fillColors = source.getFillColors();
2019 if ((lineColors != null) && (lineColors[columnID] != null) && (fillColors != null)
2020 && (fillColors[columnID] != null)) {
2021 dataset.setMarkerColor(fillColors[columnID], lineColors[columnID]);
2022 } else {
2023 dataset.setMarkerColor(DisplayColors.getMarkerColor(columnID), DisplayColors.getLineColor(columnID));
2024 }
2025 dataset.setID(source.getID());
2026 dataset.append(xPoints, yPoints);
2027 return dataset;
2028 }
2029
2030 /**
2031 * Copies a dataset. If includeDataAndID is false, only the name and display

Callers 1

getDatasetsMethod · 0.95

Calls 12

setXYColumnNamesMethod · 0.95
setConnectedMethod · 0.95
setLineColorMethod · 0.95
getLineColorMethod · 0.95
setMarkerShapeMethod · 0.95
setMarkerColorMethod · 0.95
getMarkerColorMethod · 0.95
setIDMethod · 0.95
appendMethod · 0.95
getLineColorsMethod · 0.65
getFillColorsMethod · 0.65
getIDMethod · 0.65

Tested by

no test coverage detected