List of usage examples for org.jfree.data DefaultCategoryDataset setValue
public void setValue(final double value, final Comparable rowKey, final Comparable columnKey)
From source file:RDGraphGenerator.java
/** * Creates a sample dataset./*from w w w . j a v a2 s . c o m*/ * * @return A sample dataset. */ private void createDataset() { int firstYear = 0; int firstMonth = 0; try { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br.readLine(); //skip header String line; while ((line = br.readLine()) != null) { StringTokenizer st = new StringTokenizer(line, "\t"); try { String riderID = st.nextToken(); String firstName = st.nextToken(); String lastName = st.nextToken(); double tdist = Double.parseDouble(st.nextToken()); double ttime = Double.parseDouble(st.nextToken()); double dist0 = Double.parseDouble(st.nextToken()); double dist1 = Double.parseDouble(st.nextToken()); double dist2 = Double.parseDouble(st.nextToken()); double dist3 = Double.parseDouble(st.nextToken()); double time0 = Double.parseDouble(st.nextToken()); double time1 = Double.parseDouble(st.nextToken()); double time2 = Double.parseDouble(st.nextToken()); double time3 = Double.parseDouble(st.nextToken()); String month = st.nextToken(); String humanMonth = st.nextToken(); if (firstYear == 0) { StringTokenizer stMonth = new StringTokenizer(month, "-"); firstYear = (int) Double.parseDouble(stMonth.nextToken()); firstMonth = (int) Double.parseDouble(stMonth.nextToken()); } if (riders.get(riderID) == null) { riders.put(riderID, firstName); System.out.println("Creating " + firstName); } DefaultCategoryDataset cd = (DefaultCategoryDataset) riderDistances.get(riderID); DefaultCategoryDataset ct = (DefaultCategoryDataset) riderTimes.get(riderID); if (cd == null) { cd = initializeDataset(firstMonth, firstYear); ct = initializeDataset(firstMonth, firstYear); riderDistances.put(riderID, cd); riderTimes.put(riderID, ct); System.out.println("Creating dataset " + riderID); } System.out.println("Data for " + riderID + " - " + humanMonth); cd.setValue(dist0, "0", humanMonth); cd.setValue(dist1, "1", humanMonth); cd.setValue(dist2, "2", humanMonth); cd.setValue(dist3, "3", humanMonth); ct.setValue(time0, "0", humanMonth); ct.setValue(time1, "1", humanMonth); ct.setValue(time2, "2", humanMonth); ct.setValue(time3, "3", humanMonth); } catch (NoSuchElementException nste) { //Ignore bogus lines. System.err.println("Bogus line in input file:"); System.err.println(line); System.err.println(""); } } } catch (IOException ioe) { ioe.printStackTrace(System.err); } }