@Test public void testGetValue() { double[] starts_S1 = new double[] {0.1, 0.2, 0.3}; double[] starts_S2 = new double[] {0.3, 0.4, 0.5}; double[] ends_S1 = new double[] {0.5, 0.6, 0.7}; double[] ends_S2 = new double[] {0.7, 0.8, 0.9}; double[][] starts = new double[][] {starts_S1, starts_S2}; double[][] ends = new double[][] {ends_S1, ends_S2}; DefaultIntervalCategoryDataset d = new DefaultIntervalCategoryDataset( new Comparable[] {"Series 1", "Series 2"}, new Comparable[] {"Category 1", "Category 2", "Category 3"}, DataUtilities.createNumberArray2D(starts), DataUtilities.createNumberArray2D(ends)); assertEquals(0.1, d.getStartValue("Series 1", "Category 1")); assertEquals(0.2, d.getStartValue("Series 1", "Category 2")); assertEquals(0.3, d.getStartValue("Series 1", "Category 3")); assertEquals(0.3, d.getStartValue("Series 2", "Category 1")); assertEquals(0.4, d.getStartValue("Series 2", "Category 2")); assertEquals(0.5, d.getStartValue("Series 2", "Category 3")); assertEquals(0.5, d.getEndValue("Series 1", "Category 1")); assertEquals(0.6, d.getEndValue("Series 1", "Category 2")); assertEquals(0.7, d.getEndValue("Series 1", "Category 3")); assertEquals(0.7, d.getEndValue("Series 2", "Category 1")); assertEquals(0.8, d.getEndValue("Series 2", "Category 2")); assertEquals(0.9, d.getEndValue("Series 2", "Category 3")); try { d.getValue("XX", "Category 1"); fail("UnknownKeyException should have been thrown with provided key"); } catch (UnknownKeyException e) { assertEquals("Unknown 'series' key.", e.getMessage()); } try { d.getValue("Series 1", "XX"); fail("UnknownKeyException should have been thrown with provided key"); } catch (UnknownKeyException e) { assertEquals("Unknown 'category' key.", e.getMessage()); } }
@Override public Number getValue(Comparable series, Comparable category) { int seriesIndex = getSeriesIndex(series); if (seriesIndex < 0) { throw new UnknownKeyException("Unknown 'series' key."); } int itemIndex = getColumnIndex(category); if (itemIndex < 0) { throw new UnknownKeyException("Unknown 'category' key."); } return getValue(seriesIndex, itemIndex); }
DefaultIntervalCategoryDataset extends AbstractSeriesDataset implements IntervalCategoryDataset { @Override public Number getValue(Comparable series, Comparable category) { int seriesIndex = getSeriesIndex(series); if (seriesIndex < 0) { throw new UnknownKeyException("Unknown 'series' key."); } int itemIndex = getColumnIndex(category); if (itemIndex < 0) { throw new UnknownKeyException("Unknown 'category' key."); } return getValue(seriesIndex, itemIndex); } }
DefaultIntervalCategoryDataset extends AbstractSeriesDataset implements IntervalCategoryDataset { @Override public Number getValue(Comparable series, Comparable category) { int seriesIndex = getSeriesIndex(series); if (seriesIndex < 0) { throw new UnknownKeyException("Unknown 'series' key."); } int itemIndex = getColumnIndex(category); if (itemIndex < 0) { throw new UnknownKeyException("Unknown 'category' key."); } return getValue(seriesIndex, itemIndex); } DefaultIntervalCategoryDataset(double[][] starts, double[][] ends);  DefaultIntervalCategoryDataset(Number[][] starts, Number[][] ends);  DefaultIntervalCategoryDataset(String[] seriesNames,
                                          Number[][] starts,
                                          Number[][] ends);  DefaultIntervalCategoryDataset(Comparable[] seriesKeys,
                                          Comparable[] categoryKeys,
                                          Number[][] starts,
                                          Number[][] ends); }
DefaultIntervalCategoryDataset extends AbstractSeriesDataset implements IntervalCategoryDataset { @Override public Number getValue(Comparable series, Comparable category) { int seriesIndex = getSeriesIndex(series); if (seriesIndex < 0) { throw new UnknownKeyException("Unknown 'series' key."); } int itemIndex = getColumnIndex(category); if (itemIndex < 0) { throw new UnknownKeyException("Unknown 'category' key."); } return getValue(seriesIndex, itemIndex); } DefaultIntervalCategoryDataset(double[][] starts, double[][] ends);  DefaultIntervalCategoryDataset(Number[][] starts, Number[][] ends);  DefaultIntervalCategoryDataset(String[] seriesNames,
                                          Number[][] starts,
                                          Number[][] ends);  DefaultIntervalCategoryDataset(Comparable[] seriesKeys,
                                          Comparable[] categoryKeys,
                                          Number[][] starts,
                                          Number[][] ends); @Override int getSeriesCount(); int getSeriesIndex(Comparable seriesKey); @Override Comparable getSeriesKey(int series); void setSeriesKeys(Comparable[] seriesKeys); int getCategoryCount(); @Override List<Comparable> getColumnKeys(); void setCategoryKeys(Comparable[] categoryKeys); @Override Number getValue(Comparable series, Comparable category); @Override Number getValue(int series, int category); @Override Number getStartValue(Comparable series, Comparable category); @Override Number getStartValue(int series, int category); @Override Number getEndValue(Comparable series, Comparable category); @Override Number getEndValue(int series, int category); void setStartValue(int series, Comparable category, Number value); void setEndValue(int series, Comparable category, Number value); int getCategoryIndex(Comparable category); @Override Comparable getColumnKey(int column); @Override int getColumnIndex(Comparable columnKey); @Override int getRowIndex(Comparable rowKey); @Override List<Comparable> getRowKeys(); @Override Comparable getRowKey(int row); @Override int getColumnCount(); @Override int getRowCount(); @Override boolean equals(Object obj); @Override Object clone(); }
DefaultIntervalCategoryDataset extends AbstractSeriesDataset implements IntervalCategoryDataset { @Override public Number getValue(Comparable series, Comparable category) { int seriesIndex = getSeriesIndex(series); if (seriesIndex < 0) { throw new UnknownKeyException("Unknown 'series' key."); } int itemIndex = getColumnIndex(category); if (itemIndex < 0) { throw new UnknownKeyException("Unknown 'category' key."); } return getValue(seriesIndex, itemIndex); } DefaultIntervalCategoryDataset(double[][] starts, double[][] ends);  DefaultIntervalCategoryDataset(Number[][] starts, Number[][] ends);  DefaultIntervalCategoryDataset(String[] seriesNames,
                                          Number[][] starts,
                                          Number[][] ends);  DefaultIntervalCategoryDataset(Comparable[] seriesKeys,
                                          Comparable[] categoryKeys,
                                          Number[][] starts,
                                          Number[][] ends); @Override int getSeriesCount(); int getSeriesIndex(Comparable seriesKey); @Override Comparable getSeriesKey(int series); void setSeriesKeys(Comparable[] seriesKeys); int getCategoryCount(); @Override List<Comparable> getColumnKeys(); void setCategoryKeys(Comparable[] categoryKeys); @Override Number getValue(Comparable series, Comparable category); @Override Number getValue(int series, int category); @Override Number getStartValue(Comparable series, Comparable category); @Override Number getStartValue(int series, int category); @Override Number getEndValue(Comparable series, Comparable category); @Override Number getEndValue(int series, int category); void setStartValue(int series, Comparable category, Number value); void setEndValue(int series, Comparable category, Number value); int getCategoryIndex(Comparable category); @Override Comparable getColumnKey(int column); @Override int getColumnIndex(Comparable columnKey); @Override int getRowIndex(Comparable rowKey); @Override List<Comparable> getRowKeys(); @Override Comparable getRowKey(int row); @Override int getColumnCount(); @Override int getRowCount(); @Override boolean equals(Object obj); @Override Object clone();  }