org.jfree.data.UnknownKeyException Java Examples

The following examples show how to use org.jfree.data.UnknownKeyException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultKeyedValuesTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some tests for the removeValue() method.
 */
public void testRemoveValue() {
    DefaultKeyedValues data = new DefaultKeyedValues();
    data.addValue("A", new Double(1.0));
    data.addValue("B", null);
    data.addValue("C", new Double(3.0));
    data.addValue("D", new Double(2.0));
    assertEquals(1, data.getIndex("B"));
    data.removeValue("B");
    assertEquals(-1, data.getIndex("B"));
    
    boolean pass = false;
    try {
        data.removeValue("XXX");
    }
    catch (UnknownKeyException e) {
        pass = true;   
    }
    assertTrue(pass);
}
 
Example #2
Source File: DefaultKeyedValuesTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some tests for the removeValue() method.
 */
public void testRemoveValue() {
    DefaultKeyedValues data = new DefaultKeyedValues();
    data.addValue("A", new Double(1.0));
    data.addValue("B", null);
    data.addValue("C", new Double(3.0));
    data.addValue("D", new Double(2.0));
    assertEquals(1, data.getIndex("B"));
    data.removeValue("B");
    assertEquals(-1, data.getIndex("B"));

    boolean pass = false;
    try {
        data.removeValue("XXX");
    }
    catch (UnknownKeyException e) {
        pass = true;
    }
    assertTrue(pass);
}
 
Example #3
Source File: DefaultKeyedValues2DTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some basic checks for the removeColumn(Comparable) method.
 */
public void testRemoveColumnByKey() {
    DefaultKeyedValues2D d = new DefaultKeyedValues2D();
    d.addValue(new Double(1.0), "R1", "C1");
    d.addValue(new Double(2.0), "R2", "C2");
    d.removeColumn("C2");
    d.addValue(new Double(3.0), "R2", "C2");
    assertEquals(3.0, d.getValue("R2", "C2").doubleValue(), EPSILON);

    // check for unknown column
    boolean pass = false;
    try {
        d.removeColumn("XXX");
    }
    catch (UnknownKeyException e) {
        pass = true;
    }
    assertTrue(pass);
}
 
Example #4
Source File: DefaultKeyedValues2DTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some basic checks for the removeColumn(Comparable) method.
 */
public void testRemoveColumnByKey() {
	DefaultKeyedValues2D d = new DefaultKeyedValues2D();
	d.addValue(new Double(1.0), "R1", "C1");
	d.addValue(new Double(2.0), "R2", "C2");
	d.removeColumn("C2");
	d.addValue(new Double(3.0), "R2", "C2");
	assertEquals(3.0, d.getValue("R2", "C2").doubleValue(), EPSILON);
	
	// check for unknown column
	boolean pass = false;
	try {
		d.removeColumn("XXX");
	}
	catch (UnknownKeyException e) {
		pass = true;
	}
	assertTrue(pass);
}
 
Example #5
Source File: DefaultBoxAndWhiskerCategoryDatasetTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for the remove method.
 */
@Test
public void testRemove() {
    DefaultBoxAndWhiskerCategoryDataset data
            = new DefaultBoxAndWhiskerCategoryDataset();

    boolean pass = false;
    try {
        data.remove("R1", "R2");
    }
    catch (UnknownKeyException e) {
        pass = true;
    }
    assertTrue(pass);
    data.add(new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0,
            new ArrayList()), "R1", "C1");
    assertEquals(new Range(7.0, 8.0), data.getRangeBounds(false));
    assertEquals(new Range(7.0, 8.0), data.getRangeBounds(true));

    data.add(new BoxAndWhiskerItem(2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5,
            new ArrayList()), "R2", "C1");
    assertEquals(new Range(7.0, 9.5), data.getRangeBounds(false));
    assertEquals(new Range(7.0, 9.5), data.getRangeBounds(true));

    data.remove("R1", "C1");
    assertEquals(new Range(8.5, 9.5), data.getRangeBounds(false));
    assertEquals(new Range(8.5, 9.5), data.getRangeBounds(true));
}
 
Example #6
Source File: Chart_16_DefaultIntervalCategoryDataset_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Returns the end data value for one category in a series.
 *
 * @param series  the required series.
 * @param category  the required category.
 *
 * @return The end data value for one category in a series (null possible).
 * 
 * @see #getEndValue(int, int)
 */
public Number getEndValue(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 getEndValue(seriesIndex, itemIndex);
}
 
Example #7
Source File: DefaultStatisticalCategoryDatasetTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for the remove method.
 */
@Test
public void testRemove() {
    DefaultStatisticalCategoryDataset data
            = new DefaultStatisticalCategoryDataset();

    boolean pass = false;
    try {
        data.remove("R1", "R2");
    }
    catch (UnknownKeyException e) {
        pass = true;
    }
    assertTrue(pass);
    data.add(1.0, 0.5, "R1", "C1");
    assertEquals(new Range(1.0, 1.0), data.getRangeBounds(false));
    assertEquals(new Range(0.5, 1.5), data.getRangeBounds(true));

    data.add(1.4, 0.2, "R2", "C1");

    assertEquals(1.0, data.getRangeLowerBound(false), EPSILON);
    assertEquals(1.4, data.getRangeUpperBound(false), EPSILON);
    assertEquals(0.5, data.getRangeLowerBound(true), EPSILON);
    assertEquals(1.6, data.getRangeUpperBound(true), EPSILON);

    data.remove("R1", "C1");

    assertEquals(1.4, data.getRangeLowerBound(false), EPSILON);
    assertEquals(1.4, data.getRangeUpperBound(false), EPSILON);
    assertEquals(1.2, data.getRangeLowerBound(true), EPSILON);
    assertEquals(1.6, data.getRangeUpperBound(true), EPSILON);
}
 
Example #8
Source File: SlidingGanttCategoryDataset.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the value for a pair of keys.
 *
 * @param rowKey  the row key (<code>null</code> not permitted).
 * @param columnKey  the column key (<code>null</code> not permitted).
 *
 * @return The value (possibly <code>null</code>).
 *
 * @throws UnknownKeyException if either key is not defined in the dataset.
 */
@Override
public Number getValue(Comparable rowKey, Comparable columnKey) {
    int r = getRowIndex(rowKey);
    int c = getColumnIndex(columnKey);
    if (c != -1) {
        return this.underlying.getValue(r, c + this.firstCategoryIndex);
    }
    else {
        throw new UnknownKeyException("Unknown columnKey: " + columnKey);
    }
}
 
Example #9
Source File: SlidingGanttCategoryDataset.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the percent complete for a given item.
 *
 * @param rowKey  the row key.
 * @param columnKey  the column key.
 *
 * @return The percent complete.
 */
public Number getPercentComplete(Comparable rowKey, Comparable columnKey) {
    int r = getRowIndex(rowKey);
    int c = getColumnIndex(columnKey);
    if (c != -1) {
        return this.underlying.getPercentComplete(r,
                c + this.firstCategoryIndex);
    }
    else {
        throw new UnknownKeyException("Unknown columnKey: " + columnKey);
    }
}
 
Example #10
Source File: SlidingCategoryDataset.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the value for a pair of keys.
 *
 * @param rowKey  the row key (<code>null</code> not permitted).
 * @param columnKey  the column key (<code>null</code> not permitted).
 *
 * @return The value (possibly <code>null</code>).
 *
 * @throws UnknownKeyException if either key is not defined in the dataset.
 */
@Override
public Number getValue(Comparable rowKey, Comparable columnKey) {
    int r = getRowIndex(rowKey);
    int c = getColumnIndex(columnKey);
    if (c != -1) {
        return this.underlying.getValue(r, c + this.firstCategoryIndex);
    }
    else {
        throw new UnknownKeyException("Unknown columnKey: " + columnKey);
    }
}
 
Example #11
Source File: DefaultStatisticalCategoryDatasetTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for the remove method.
 */
public void testRemove() {
    DefaultStatisticalCategoryDataset data
            = new DefaultStatisticalCategoryDataset();

    boolean pass = false;
    try {
        data.remove("R1", "R2");
    }
    catch (UnknownKeyException e) {
        pass = true;
    }
    assertTrue(pass);
    data.add(1.0, 0.5, "R1", "C1");
    assertEquals(new Range(1.0, 1.0), data.getRangeBounds(false));
    assertEquals(new Range(0.5, 1.5), data.getRangeBounds(true));

    data.add(1.4, 0.2, "R2", "C1");

    assertEquals(1.0, data.getRangeLowerBound(false), EPSILON);
    assertEquals(1.4, data.getRangeUpperBound(false), EPSILON);
    assertEquals(0.5, data.getRangeLowerBound(true), EPSILON);
    assertEquals(1.6, data.getRangeUpperBound(true), EPSILON);

    data.remove("R1", "C1");

    assertEquals(1.4, data.getRangeLowerBound(false), EPSILON);
    assertEquals(1.4, data.getRangeUpperBound(false), EPSILON);
    assertEquals(1.2, data.getRangeLowerBound(true), EPSILON);
    assertEquals(1.6, data.getRangeUpperBound(true), EPSILON);
}
 
Example #12
Source File: DefaultBoxAndWhiskerCategoryDatasetTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for the remove method.
 */
public void testRemove() {
    DefaultBoxAndWhiskerCategoryDataset data
            = new DefaultBoxAndWhiskerCategoryDataset();

    boolean pass = false;
    try {
        data.remove("R1", "R2");
    }
    catch (UnknownKeyException e) {
        pass = true;
    }
    assertTrue(pass);
    data.add(new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0,
            new ArrayList()), "R1", "C1");
    assertEquals(new Range(7.0, 8.0), data.getRangeBounds(false));
    assertEquals(new Range(7.0, 8.0), data.getRangeBounds(true));

    data.add(new BoxAndWhiskerItem(2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5,
            new ArrayList()), "R2", "C1");
    assertEquals(new Range(7.0, 9.5), data.getRangeBounds(false));
    assertEquals(new Range(7.0, 9.5), data.getRangeBounds(true));

    data.remove("R1", "C1");
    assertEquals(new Range(8.5, 9.5), data.getRangeBounds(false));
    assertEquals(new Range(8.5, 9.5), data.getRangeBounds(true));
}
 
Example #13
Source File: SlidingGanttCategoryDataset.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the value for a pair of keys.
 *
 * @param rowKey  the row key (<code>null</code> not permitted).
 * @param columnKey  the column key (<code>null</code> not permitted).
 *
 * @return The value (possibly <code>null</code>).
 *
 * @throws UnknownKeyException if either key is not defined in the dataset.
 */
public Number getValue(Comparable rowKey, Comparable columnKey) {
    int r = getRowIndex(rowKey);
    int c = getColumnIndex(columnKey);
    if (c != -1) {
        return this.underlying.getValue(r, c + this.firstCategoryIndex);
    }
    else {
        throw new UnknownKeyException("Unknown columnKey: " + columnKey);
    }
}
 
Example #14
Source File: SlidingGanttCategoryDataset.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the end value of a sub-interval for a given item.
 *
 * @param rowKey  the row key.
 * @param columnKey  the column key.
 * @param subinterval  the sub-interval.
 *
 * @return The end value (possibly <code>null</code>).
 *
 * @see #getStartValue(Comparable, Comparable, int)
 */
public Number getEndValue(Comparable rowKey, Comparable columnKey,
        int subinterval) {
    int r = getRowIndex(rowKey);
    int c = getColumnIndex(columnKey);
    if (c != -1) {
        return this.underlying.getEndValue(r,
                c + this.firstCategoryIndex, subinterval);
    }
    else {
        throw new UnknownKeyException("Unknown columnKey: " + columnKey);
    }
}
 
Example #15
Source File: DefaultIntervalCategoryDataset.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the end data value for one category in a series.
 *
 * @param series  the required series.
 * @param category  the required category.
 *
 * @return The end data value for one category in a series (null possible).
 * 
 * @see #getEndValue(int, int)
 */
public Number getEndValue(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 getEndValue(seriesIndex, itemIndex);
}
 
Example #16
Source File: DefaultIntervalCategoryDataset.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the end data value for one category in a series.
 *
 * @param series  the required series.
 * @param category  the required category.
 *
 * @return The end data value for one category in a series (null possible).
 *
 * @see #getEndValue(int, int)
 */
@Override
public Number getEndValue(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 getEndValue(seriesIndex, itemIndex);
}
 
Example #17
Source File: SlidingGanttCategoryDataset.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the percentage complete value of a sub-interval for a given item.
 *
 * @param rowKey  the row key.
 * @param columnKey  the column key.
 * @param subinterval  the sub-interval.
 *
 * @return The percent complete value (possibly <code>null</code>).
 *
 * @see #getPercentComplete(int, int, int)
 */
public Number getPercentComplete(Comparable rowKey, Comparable columnKey,
        int subinterval) {
    int r = getRowIndex(rowKey);
    int c = getColumnIndex(columnKey);
    if (c != -1) {
        return this.underlying.getPercentComplete(r,
                c + this.firstCategoryIndex, subinterval);
    }
    else {
        throw new UnknownKeyException("Unknown columnKey: " + columnKey);
    }
}
 
Example #18
Source File: Chart_16_DefaultIntervalCategoryDataset_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Returns the end data value for one category in a series.
 *
 * @param series  the required series.
 * @param category  the required category.
 *
 * @return The end data value for one category in a series (null possible).
 * 
 * @see #getEndValue(int, int)
 */
public Number getEndValue(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 getEndValue(seriesIndex, itemIndex);
}
 
Example #19
Source File: Chart_16_DefaultIntervalCategoryDataset_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Returns the start data value for one category in a series.
 *
 * @param series  the required series.
 * @param category  the required category.
 *
 * @return The start data value for one category in a series 
 *         (possibly <code>null</code>).
 *         
 * @see #getStartValue(int, int)
 */
public Number getStartValue(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 getStartValue(seriesIndex, itemIndex);
}
 
Example #20
Source File: SlidingGanttCategoryDataset.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the end value of a sub-interval for a given item.
 *
 * @param rowKey  the row key.
 * @param columnKey  the column key.
 * @param subinterval  the sub-interval.
 *
 * @return The end value (possibly <code>null</code>).
 *
 * @see #getStartValue(Comparable, Comparable, int)
 */
@Override
public Number getEndValue(Comparable rowKey, Comparable columnKey,
        int subinterval) {
    int r = getRowIndex(rowKey);
    int c = getColumnIndex(columnKey);
    if (c != -1) {
        return this.underlying.getEndValue(r,
                c + this.firstCategoryIndex, subinterval);
    }
    else {
        throw new UnknownKeyException("Unknown columnKey: " + columnKey);
    }
}
 
Example #21
Source File: DefaultIntervalCategoryDataset.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the end data value for one category in a series.
 *
 * @param series  the required series.
 * @param category  the required category.
 *
 * @return The end data value for one category in a series (null possible).
 *
 * @see #getEndValue(int, int)
 */
public Number getEndValue(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 getEndValue(seriesIndex, itemIndex);
}
 
Example #22
Source File: SlidingGanttCategoryDataset.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the start value for the interval for a given series and category.
 *
 * @param rowKey  the series key.
 * @param columnKey  the category key.
 *
 * @return The start value (possibly <code>null</code>).
 *
 * @see #getEndValue(Comparable, Comparable)
 */
public Number getStartValue(Comparable rowKey, Comparable columnKey) {
    int r = getRowIndex(rowKey);
    int c = getColumnIndex(columnKey);
    if (c != -1) {
        return this.underlying.getStartValue(r, c + this.firstCategoryIndex);
    }
    else {
        throw new UnknownKeyException("Unknown columnKey: " + columnKey);
    }
}
 
Example #23
Source File: SlidingCategoryDataset.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the value for a pair of keys.
 *
 * @param rowKey  the row key (<code>null</code> not permitted).
 * @param columnKey  the column key (<code>null</code> not permitted).
 *
 * @return The value (possibly <code>null</code>).
 *
 * @throws UnknownKeyException if either key is not defined in the dataset.
 */
@Override
public Number getValue(Comparable rowKey, Comparable columnKey) {
    int r = getRowIndex(rowKey);
    int c = getColumnIndex(columnKey);
    if (c != -1) {
        return this.underlying.getValue(r, c + this.firstCategoryIndex);
    }
    else {
        throw new UnknownKeyException("Unknown columnKey: " + columnKey);
    }
}
 
Example #24
Source File: DefaultIntervalCategoryDataset.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the end data value for one category in a series.
 *
 * @param series  the required series.
 * @param category  the required category.
 *
 * @return The end data value for one category in a series (null possible).
 *
 * @see #getEndValue(int, int)
 */
@Override
public Number getEndValue(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 getEndValue(seriesIndex, itemIndex);
}
 
Example #25
Source File: DefaultIntervalCategoryDataset.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the start data value for one category in a series.
 *
 * @param series  the required series.
 * @param category  the required category.
 *
 * @return The start data value for one category in a series
 *         (possibly <code>null</code>).
 *
 * @see #getStartValue(int, int)
 */
@Override
public Number getStartValue(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 getStartValue(seriesIndex, itemIndex);
}
 
Example #26
Source File: XYSeriesCollection.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a series from the collection.
 * 
 * @param key  the key (<code>null</code> not permitted).
 * 
 * @return The series with the specified key.
 * 
 * @throws UnknownKeyException if <code>key</code> is not found in the
 *         collection.
 * 
 * @since 1.0.9
 */
public XYSeries getSeries(Comparable key) {
    if (key == null) {
        throw new IllegalArgumentException("Null 'key' argument.");
    }
    Iterator iterator = this.data.iterator();
    while (iterator.hasNext()) {
        XYSeries series = (XYSeries) iterator.next();
        if (key.equals(series.getKey())) {
            return series;
        }
    }
    throw new UnknownKeyException("Key not found: " + key);
}
 
Example #27
Source File: SlidingGanttCategoryDataset.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the end value for the interval for a given series and category.
 *
 * @param rowKey  the series key.
 * @param columnKey  the category key.
 *
 * @return The end value (possibly <code>null</code>).
 *
 * @see #getStartValue(Comparable, Comparable)
 */
@Override
public Number getEndValue(Comparable rowKey, Comparable columnKey) {
    int r = getRowIndex(rowKey);
    int c = getColumnIndex(columnKey);
    if (c != -1) {
        return this.underlying.getEndValue(r, c + this.firstCategoryIndex);
    }
    else {
        throw new UnknownKeyException("Unknown columnKey: " + columnKey);
    }
}
 
Example #28
Source File: SlidingGanttCategoryDataset.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the start value for the interval for a given series and category.
 *
 * @param rowKey  the series key.
 * @param columnKey  the category key.
 *
 * @return The start value (possibly <code>null</code>).
 *
 * @see #getEndValue(Comparable, Comparable)
 */
@Override
public Number getStartValue(Comparable rowKey, Comparable columnKey) {
    int r = getRowIndex(rowKey);
    int c = getColumnIndex(columnKey);
    if (c != -1) {
        return this.underlying.getStartValue(r,
                c + this.firstCategoryIndex);
    }
    else {
        throw new UnknownKeyException("Unknown columnKey: " + columnKey);
    }
}
 
Example #29
Source File: DefaultBoxAndWhiskerCategoryDatasetTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Some checks for the remove method.
 */
@Test
public void testRemove() {
    DefaultBoxAndWhiskerCategoryDataset data
            = new DefaultBoxAndWhiskerCategoryDataset();

    boolean pass = false;
    try {
        data.remove("R1", "R2");
    }
    catch (UnknownKeyException e) {
        pass = true;
    }
    assertTrue(pass);
    data.add(new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0,
            new ArrayList()), "R1", "C1");
    assertEquals(new Range(7.0, 8.0), data.getRangeBounds(false));
    assertEquals(new Range(7.0, 8.0), data.getRangeBounds(true));

    data.add(new BoxAndWhiskerItem(2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5,
            new ArrayList()), "R2", "C1");
    assertEquals(new Range(7.0, 9.5), data.getRangeBounds(false));
    assertEquals(new Range(7.0, 9.5), data.getRangeBounds(true));

    data.remove("R1", "C1");
    assertEquals(new Range(8.5, 9.5), data.getRangeBounds(false));
    assertEquals(new Range(8.5, 9.5), data.getRangeBounds(true));
}
 
Example #30
Source File: SlidingGanttCategoryDataset.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the start value of a sub-interval for a given item.
 *
 * @param rowKey  the row key.
 * @param columnKey  the column key.
 * @param subinterval  the sub-interval.
 *
 * @return The start value (possibly <code>null</code>).
 *
 * @see #getEndValue(Comparable, Comparable, int)
 */
@Override
public Number getStartValue(Comparable rowKey, Comparable columnKey,
        int subinterval) {
    int r = getRowIndex(rowKey);
    int c = getColumnIndex(columnKey);
    if (c != -1) {
        return this.underlying.getStartValue(r,
                c + this.firstCategoryIndex, subinterval);
    }
    else {
        throw new UnknownKeyException("Unknown columnKey: " + columnKey);
    }
}