All Downloads are FREE. Search and download functionalities are using the official Maven repository.

hudson.util.DataSetBuilder Maven / Gradle / Ivy

package hudson.util;

import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;

import java.util.ArrayList;
import java.util.List;
import java.util.TreeSet;

/**
 * Builds {@link CategoryDataset}.
 *
 * 

* This code works around an issue in {@link DefaultCategoryDataset} where * order of addition changes the way they are drawn. */ public final class DataSetBuilder { private List values = new ArrayList(); private List rows = new ArrayList(); private List columns = new ArrayList(); public void add( Number value, Row rowKey, Column columnKey ) { values.add(value); rows.add(rowKey); columns.add(columnKey); } public CategoryDataset build() { DefaultCategoryDataset ds = new DefaultCategoryDataset(); TreeSet rowSet = new TreeSet(rows); TreeSet colSet = new TreeSet(columns); Comparable[] _rows = rowSet.toArray(new Comparable[rowSet.size()]); Comparable[] _cols = colSet.toArray(new Comparable[colSet.size()]); // insert rows and columns in the right order for (Comparable r : _rows) ds.setValue(null, r, _cols[0]); for (Comparable c : _cols) ds.setValue(null, _rows[0], c); for( int i=0; i





© 2015 - 2025 Weber Informatics LLC | Privacy Policy