1 19 package jcckit.data; 20 21 import jcckit.util.ConfigParameters; 22 23 28 public class DataCurve extends DataContainer implements DataElement { 29 30 public static final String X_KEY = "x", 31 Y_KEY = "y", 32 TITLE_KEY = "title"; 33 34 private final String _title; 35 private DataContainer _container; 36 37 38 public DataCurve(String title) { 39 _title = title; 40 } 41 42 56 public DataCurve(ConfigParameters config) { 57 this(config.get(TITLE_KEY, "")); 58 double[] xPoints = config.getDoubleArray(X_KEY); 59 double[] yPoints = config.getDoubleArray(Y_KEY); 60 int n = Math.min(xPoints.length, yPoints.length); 61 for (int i = 0; i < n; i++) { 62 addElement(new DataPoint(xPoints[i], yPoints[i])); 63 } 64 } 65 66 69 public DataContainer getContainer() { 70 return _container; 71 } 72 73 74 77 public void setContainer(DataContainer container) { 78 _container = container; 79 } 80 81 82 public String getTitle() { 83 return _title; 84 } 85 86 90 protected boolean isValid(DataElement element) { 91 return element instanceof DataPoint; 92 } 93 } 94 | Popular Tags |