Java 类org.jfree.data.time.TimePeriodValues 实例源码

项目:parabuild-ci    文件:TimePeriodValuesTests.java   
/**
 * Tests the equals method.
 */
public void testEquals() {
    final TimePeriodValues s1 = new TimePeriodValues("Time Series 1");
    final TimePeriodValues s2 = new TimePeriodValues("Time Series 2");
    final boolean b1 = s1.equals(s2);
    assertFalse("b1", b1);

    s2.setName("Time Series 1");
    final boolean b2 = s1.equals(s2);
    assertTrue("b2", b2);

    final RegularTimePeriod p1 = new Day();
    final RegularTimePeriod p2 = p1.next();
    s1.add(p1, 100.0);
    s1.add(p2, 200.0);
    final boolean b3 = s1.equals(s2);
    assertFalse("b3", b3);

    s2.add(p1, 100.0);
    s2.add(p2, 200.0);
    final boolean b4 = s1.equals(s2);
    assertTrue("b4", b4);

}
项目:parabuild-ci    文件:TimePeriodValuesTests.java   
/**
 * Some checks for the add() methods.
 */
public void testAdd() {
    TimePeriodValues tpv = new TimePeriodValues("Test");
    MySeriesChangeListener listener = new MySeriesChangeListener();
    tpv.addChangeListener(listener);
    tpv.add(new TimePeriodValue(new SimpleTimePeriod(new Date(1L), 
            new Date(3L)), 99.0));
    assertEquals(99.0, tpv.getValue(0).doubleValue(), EPSILON);
    assertEquals(tpv, listener.getLastEvent().getSource());

    // a null item should throw an IllegalArgumentException
    boolean pass = false;
    try {
        tpv.add((TimePeriodValue) null);
    }
    catch (IllegalArgumentException e) {
        pass = true;
    }
    assertTrue(pass);
}
项目:parabuild-ci    文件:TimePeriodValuesCollectionTests.java   
/**
 * A test for bug report 1161340.  I wasn't able to reproduce the problem
 * with this test.
 */
public void test1161340() {
    TimePeriodValuesCollection dataset = new TimePeriodValuesCollection();
    TimePeriodValues v1 = new TimePeriodValues("V1");
    v1.add(new Day(11, 3, 2005), 1.2);
    v1.add(new Day(12, 3, 2005), 3.4);
    dataset.addSeries(v1);
    assertEquals(1, dataset.getSeriesCount());
    dataset.removeSeries(v1);
    assertEquals(0, dataset.getSeriesCount());

    TimePeriodValues v2 = new TimePeriodValues("V2");
    v1.add(new Day(5, 3, 2005), 1.2);
    v1.add(new Day(6, 3, 2005), 3.4);
    dataset.addSeries(v2);
    assertEquals(1, dataset.getSeriesCount());
}
项目:parabuild-ci    文件:TimePeriodValuesCollectionTests.java   
/**
 * Tests the equals() method.
 */
public void testEquals() {

    TimePeriodValuesCollection c1 = new TimePeriodValuesCollection();
    TimePeriodValuesCollection c2 = new TimePeriodValuesCollection();
    assertTrue(c1.equals(c2));

    c1.setDomainIsPointsInTime(!c1.getDomainIsPointsInTime());
    assertFalse(c1.equals(c2));
    c2.setDomainIsPointsInTime(c1.getDomainIsPointsInTime());
    assertTrue(c1.equals(c2));

    c1.setXPosition(TimePeriodAnchor.END);
    assertFalse(c1.equals(c2));
    c2.setXPosition(TimePeriodAnchor.END);
    assertTrue(c1.equals(c2));

    TimePeriodValues v1 = new TimePeriodValues("Test");
    TimePeriodValues v2 = new TimePeriodValues("Test");

    c1.addSeries(v1);
    assertFalse(c1.equals(c2));
    c2.addSeries(v2);
    assertTrue(c1.equals(c2));
}
项目:jasperreports    文件:TimePeriodChartHyperlinkProvider.java   
@Override
public JRPrintHyperlink getEntityHyperlink(ChartEntity entity)
{
    JRPrintHyperlink printHyperlink = null;
    if (hasHyperlinks() && entity instanceof XYItemEntity)
    {
        XYItemEntity itemEntity = (XYItemEntity) entity;
        TimePeriodValuesCollection dataset = (TimePeriodValuesCollection) itemEntity.getDataset();
        TimePeriodValues series = dataset.getSeries(itemEntity.getSeriesIndex());
        Map<TimePeriod, JRPrintHyperlink> serieHyperlinks = itemHyperlinks.get(series.getKey());
        if (serieHyperlinks != null)
        {
            TimePeriod timePeriod = series.getTimePeriod(itemEntity.getItem());
            printHyperlink = serieHyperlinks.get(timePeriod);
        }
    }
    return printHyperlink;
}
项目:SMVHunter    文件:DisplaySyncHistogram.java   
/**
 * Resets the display.
 */
@Override
void resetUI() {
    super.resetUI();
    XYPlot xyPlot = mChart.getXYPlot();

    AbstractXYItemRenderer br = new XYBarRenderer();
    mDatasetsSyncHist = new TimePeriodValues[NUM_AUTHS+1];

    @SuppressWarnings("unchecked")
    Map<SimpleTimePeriod, Integer> mTimePeriodMapTmp[] = new HashMap[NUM_AUTHS + 1];
    mTimePeriodMap = mTimePeriodMapTmp;

    TimePeriodValuesCollection tpvc = new TimePeriodValuesCollection();
    xyPlot.setDataset(tpvc);
    xyPlot.setRenderer(br);

    for (int i = 0; i < NUM_AUTHS + 1; i++) {
        br.setSeriesPaint(i, AUTH_COLORS[i]);
        mDatasetsSyncHist[i] = new TimePeriodValues(AUTH_NAMES[i]);
        tpvc.addSeries(mDatasetsSyncHist[i]);
        mTimePeriodMap[i] = new HashMap<SimpleTimePeriod, Integer>();

    }
}
项目:nabs    文件:TimePeriodValuesTests.java   
/**
 * Some checks for the add() methods.
 */
public void testAdd() {
    TimePeriodValues tpv = new TimePeriodValues("Test");
    MySeriesChangeListener listener = new MySeriesChangeListener();
    tpv.addChangeListener(listener);
    tpv.add(new TimePeriodValue(new SimpleTimePeriod(new Date(1L), 
            new Date(3L)), 99.0));
    assertEquals(99.0, tpv.getValue(0).doubleValue(), EPSILON);
    assertEquals(tpv, listener.getLastEvent().getSource());

    // a null item should throw an IllegalArgumentException
    boolean pass = false;
    try {
        tpv.add((TimePeriodValue) null);
    }
    catch (IllegalArgumentException e) {
        pass = true;
    }
    assertTrue(pass);
}
项目:nabs    文件:TimePeriodValuesCollectionTests.java   
/**
 * A test for bug report 1161340.  I wasn't able to reproduce the problem
 * with this test.
 */
public void test1161340() {
    TimePeriodValuesCollection dataset = new TimePeriodValuesCollection();
    TimePeriodValues v1 = new TimePeriodValues("V1");
    v1.add(new Day(11, 3, 2005), 1.2);
    v1.add(new Day(12, 3, 2005), 3.4);
    dataset.addSeries(v1);
    assertEquals(1, dataset.getSeriesCount());
    dataset.removeSeries(v1);
    assertEquals(0, dataset.getSeriesCount());

    TimePeriodValues v2 = new TimePeriodValues("V2");
    v1.add(new Day(5, 3, 2005), 1.2);
    v1.add(new Day(6, 3, 2005), 3.4);
    dataset.addSeries(v2);
    assertEquals(1, dataset.getSeriesCount());
}
项目:nabs    文件:TimePeriodValuesCollectionTests.java   
/**
 * Tests the equals() method.
 */
public void testEquals() {

    TimePeriodValuesCollection c1 = new TimePeriodValuesCollection();
    TimePeriodValuesCollection c2 = new TimePeriodValuesCollection();
    assertTrue(c1.equals(c2));

    c1.setDomainIsPointsInTime(!c1.getDomainIsPointsInTime());
    assertFalse(c1.equals(c2));
    c2.setDomainIsPointsInTime(c1.getDomainIsPointsInTime());
    assertTrue(c1.equals(c2));

    c1.setXPosition(TimePeriodAnchor.END);
    assertFalse(c1.equals(c2));
    c2.setXPosition(TimePeriodAnchor.END);
    assertTrue(c1.equals(c2));

    TimePeriodValues v1 = new TimePeriodValues("Test");
    TimePeriodValues v2 = new TimePeriodValues("Test");

    c1.addSeries(v1);
    assertFalse(c1.equals(c2));
    c2.addSeries(v2);
    assertTrue(c1.equals(c2));
}
项目:astor    文件:TimePeriodValuesTests.java   
/**
 * Some checks for the add() methods.
 */
public void testAdd() {
    TimePeriodValues tpv = new TimePeriodValues("Test");
    MySeriesChangeListener listener = new MySeriesChangeListener();
    tpv.addChangeListener(listener);
    tpv.add(new TimePeriodValue(new SimpleTimePeriod(new Date(1L), 
            new Date(3L)), 99.0));
    assertEquals(99.0, tpv.getValue(0).doubleValue(), EPSILON);
    assertEquals(tpv, listener.getLastEvent().getSource());

    // a null item should throw an IllegalArgumentException
    boolean pass = false;
    try {
        tpv.add((TimePeriodValue) null);
    }
    catch (IllegalArgumentException e) {
        pass = true;
    }
    assertTrue(pass);
}
项目:astor    文件:TimePeriodValuesCollectionTests.java   
/**
 * A test for bug report 1161340.  I wasn't able to reproduce the problem
 * with this test.
 */
public void test1161340() {
    TimePeriodValuesCollection dataset = new TimePeriodValuesCollection();
    TimePeriodValues v1 = new TimePeriodValues("V1");
    v1.add(new Day(11, 3, 2005), 1.2);
    v1.add(new Day(12, 3, 2005), 3.4);
    dataset.addSeries(v1);
    assertEquals(1, dataset.getSeriesCount());
    dataset.removeSeries(v1);
    assertEquals(0, dataset.getSeriesCount());

    TimePeriodValues v2 = new TimePeriodValues("V2");
    v1.add(new Day(5, 3, 2005), 1.2);
    v1.add(new Day(6, 3, 2005), 3.4);
    dataset.addSeries(v2);
    assertEquals(1, dataset.getSeriesCount());
}
项目:astor    文件:TimePeriodValuesCollectionTests.java   
/**
 * Tests the equals() method.
 */
public void testEquals() {

    TimePeriodValuesCollection c1 = new TimePeriodValuesCollection();
    TimePeriodValuesCollection c2 = new TimePeriodValuesCollection();
    assertTrue(c1.equals(c2));

    c1.setXPosition(TimePeriodAnchor.END);
    assertFalse(c1.equals(c2));
    c2.setXPosition(TimePeriodAnchor.END);
    assertTrue(c1.equals(c2));

    TimePeriodValues v1 = new TimePeriodValues("Test");
    TimePeriodValues v2 = new TimePeriodValues("Test");

    c1.addSeries(v1);
    assertFalse(c1.equals(c2));
    c2.addSeries(v2);
    assertTrue(c1.equals(c2));
}
项目:astor    文件:TimePeriodValuesCollectionTests.java   
/**
 * Some checks for the getDomainBounds() method.
 */
public void testGetDomainBoundsWithoutInterval() {
    // check empty dataset
    TimePeriodValuesCollection dataset = new TimePeriodValuesCollection();
    Range r = dataset.getDomainBounds(false);
    assertNull(r);

    // check dataset with one time period
    TimePeriodValues s1 = new TimePeriodValues("S1");
    s1.add(new SimpleTimePeriod(1000L, 2000L), 1.0);
    dataset.addSeries(s1);
    r = dataset.getDomainBounds(false);
    assertEquals(1500.0, r.getLowerBound(), EPSILON);
    assertEquals(1500.0, r.getUpperBound(), EPSILON);

    // check dataset with two time periods
    s1.add(new SimpleTimePeriod(1500L, 3000L), 2.0);
    r = dataset.getDomainBounds(false);
    assertEquals(1500.0, r.getLowerBound(), EPSILON);
    assertEquals(2250.0, r.getUpperBound(), EPSILON);  
}
项目:ControlAndroidDeviceFromPC    文件:DisplaySyncHistogram.java   
/**
 * Resets the display.
 */
@Override
void resetUI() {
    super.resetUI();
    XYPlot xyPlot = mChart.getXYPlot();

    AbstractXYItemRenderer br = new XYBarRenderer();
    mDatasetsSyncHist = new TimePeriodValues[NUM_AUTHS+1];

    @SuppressWarnings("unchecked")
    Map<SimpleTimePeriod, Integer> mTimePeriodMapTmp[] = new HashMap[NUM_AUTHS + 1];
    mTimePeriodMap = mTimePeriodMapTmp;

    TimePeriodValuesCollection tpvc = new TimePeriodValuesCollection();
    xyPlot.setDataset(tpvc);
    xyPlot.setRenderer(br);

    for (int i = 0; i < NUM_AUTHS + 1; i++) {
        br.setSeriesPaint(i, AUTH_COLORS[i]);
        mDatasetsSyncHist[i] = new TimePeriodValues(AUTH_NAMES[i]);
        tpvc.addSeries(mDatasetsSyncHist[i]);
        mTimePeriodMap[i] = new HashMap<SimpleTimePeriod, Integer>();

    }
}
项目:ezScrum    文件:ChartUtil.java   
private XYDataset createBarDataset() {
    final TimePeriodValuesCollection result = new TimePeriodValuesCollection();
    Set<String> nameSet = this.m_dataSetMap.keySet();

    for (String name : nameSet) {
        final TimePeriodValues series = new TimePeriodValues(name);

        Map<Date, ? extends Number> map = m_dataSetMap.get(name);

        Iterator<Date> ir = map.keySet().iterator();

        while (ir.hasNext()) {
            Date key = ir.next();
            series.add(new SimpleTimePeriod(key, new Date(key.getTime()
                    + (m_interval * OneDay))), map.get(key));
        }

        result.addSeries(series);
    }
    return result;
}
项目:parabuild-ci    文件:TimePeriodValuesTests.java   
/**
 * Add a value to series A for 1999.  It should be added at index 0.
 */
public void testAddValue() {

    final TimePeriodValues tpvs = new TimePeriodValues("Test");
    try {
        tpvs.add(new Year(1999), new Integer(1));
    }
    catch (SeriesException e) {
        System.err.println("TimePeriodValuesTests.testAddValue: problem adding to series.");
    }

    final int value = tpvs.getValue(0).intValue();
    assertEquals(1, value);

}
项目:parabuild-ci    文件:TimePeriodValuesTests.java   
/**
 * Add a value to series A for 1999.  It should be added at index 0.
 */
public void testAddValue() {

    TimePeriodValues tpvs = new TimePeriodValues("Test");
    try {
        tpvs.add(new Year(1999), new Integer(1));
    }
    catch (SeriesException e) {
        System.err.println("Problem adding to series.");
    }

    int value = tpvs.getValue(0).intValue();
    assertEquals(1, value);

}
项目:parabuild-ci    文件:TimePeriodValuesTests.java   
/**
 * A test for bug report 1161329.
 */
public void test1161329() {
    TimePeriodValues tpv = new TimePeriodValues("Test");
    RegularTimePeriod t = new Day();
    tpv.add(t, 1.0);
    t = t.next();
    tpv.add(t, 2.0);
    tpv.delete(0, 1);
    assertEquals(0, tpv.getItemCount());
    tpv.add(t, 2.0);
    assertEquals(1, tpv.getItemCount());
}
项目:jasperreports    文件:ConvertChartContext.java   
private XYDataset createTimePeriodDataset()
{
    if (sampleTimePeriodDataset == null)
    {
        TimePeriodValuesCollection dataset = new TimePeriodValuesCollection();

        Day today = new Day();
        TimePeriodValues series1 = new TimePeriodValues("First");
        TimePeriodValues series2 = new TimePeriodValues("Second");

        for (int i = 0; i < 24; i++) 
        {
            Minute m0 = new Minute(0, new Hour(i, today));
            Minute m1 = new Minute(15, new Hour(i, today));
            Minute m2 = new Minute(30, new Hour(i, today));
            Minute m3 = new Minute(45, new Hour(i, today));
            Minute m4 = new Minute(0, new Hour(i + 1, today));
            series1.add(new SimpleTimePeriod(m0.getStart(), m1.getStart()), Math.random());
            series2.add(new SimpleTimePeriod(m1.getStart(), m2.getStart()), Math.random());
            series1.add(new SimpleTimePeriod(m2.getStart(), m3.getStart()), Math.random());
            series2.add(new SimpleTimePeriod(m3.getStart(), m4.getStart()), Math.random());
        }

        dataset.addSeries(series1);
        dataset.addSeries(series2);

        sampleTimePeriodDataset = dataset;
    }

    return sampleTimePeriodDataset;
}
项目:SMVHunter    文件:DisplaySyncHistogram.java   
private void addToPeriod(TimePeriodValues tpv[], int auth, SimpleTimePeriod period,
        double value) {
    int index;
    if (mTimePeriodMap[auth].containsKey(period)) {
        index = mTimePeriodMap[auth].get(period);
        double oldValue = tpv[auth].getValue(index).doubleValue();
        tpv[auth].update(index, oldValue + value);
    } else {
        index = tpv[auth].getItemCount();
        mTimePeriodMap[auth].put(period, index);
        tpv[auth].add(period, value);
    }
}
项目:SMVHunter    文件:DisplaySyncPerf.java   
/**
 * Resets the display.
 */
@Override
void resetUI() {
    super.resetUI();
    XYPlot xyPlot = mChart.getXYPlot();
    xyPlot.getRangeAxis().setVisible(false);
    mTooltipGenerator = new CustomXYToolTipGenerator();

    @SuppressWarnings("unchecked")
    List<String>[] mTooltipsTmp = new List[NUM_SERIES];
    mTooltips = mTooltipsTmp;

    XYBarRenderer br = new XYBarRenderer();
    br.setUseYInterval(true);
    mDatasets = new TimePeriodValues[NUM_SERIES];

    TimePeriodValuesCollection tpvc = new YIntervalTimePeriodValuesCollection(1);
    xyPlot.setDataset(tpvc);
    xyPlot.setRenderer(br);

    for (int i = 0; i < NUM_SERIES; i++) {
        br.setSeriesPaint(i, SERIES_COLORS[i]);
        mDatasets[i] = new TimePeriodValues(SERIES_NAMES[i]);
        tpvc.addSeries(mDatasets[i]);
        mTooltips[i] = new ArrayList<String>();
        mTooltipGenerator.addToolTipSeries(mTooltips[i]);
        br.setSeriesToolTipGenerator(i, mTooltipGenerator);
    }
}
项目:PDFReporter-Studio    文件:ConvertChartContext.java   
private XYDataset createTimePeriodDataset() {
    if (sampleTimePeriodDataset == null) {
        TimePeriodValuesCollection dataset = new TimePeriodValuesCollection();

        Day today = new Day();
        TimePeriodValues series1 = new TimePeriodValues("First");
        TimePeriodValues series2 = new TimePeriodValues("Second");

        for (int i = 0; i < 24; i++) {
            Minute m0 = new Minute(0, new Hour(i, today));
            Minute m1 = new Minute(15, new Hour(i, today));
            Minute m2 = new Minute(30, new Hour(i, today));
            Minute m3 = new Minute(45, new Hour(i, today));
            Minute m4 = new Minute(0, new Hour(i + 1, today));
            series1.add(new SimpleTimePeriod(m0.getStart(), m1.getStart()), Math.random());
            series2.add(new SimpleTimePeriod(m1.getStart(), m2.getStart()), Math.random());
            series1.add(new SimpleTimePeriod(m2.getStart(), m3.getStart()), Math.random());
            series2.add(new SimpleTimePeriod(m3.getStart(), m4.getStart()), Math.random());
        }

        dataset.addSeries(series1);
        dataset.addSeries(series2);

        sampleTimePeriodDataset = dataset;
    }

    return sampleTimePeriodDataset;
}
项目:nabs    文件:TimePeriodValuesTests.java   
/**
 * Add a value to series A for 1999.  It should be added at index 0.
 */
public void testAddValue() {

    TimePeriodValues tpvs = new TimePeriodValues("Test");
    try {
        tpvs.add(new Year(1999), new Integer(1));
    }
    catch (SeriesException e) {
        System.err.println("Problem adding to series.");
    }

    int value = tpvs.getValue(0).intValue();
    assertEquals(1, value);

}
项目:nabs    文件:TimePeriodValuesTests.java   
/**
 * A test for bug report 1161329.
 */
public void test1161329() {
    TimePeriodValues tpv = new TimePeriodValues("Test");
    RegularTimePeriod t = new Day();
    tpv.add(t, 1.0);
    t = t.next();
    tpv.add(t, 2.0);
    tpv.delete(0, 1);
    assertEquals(0, tpv.getItemCount());
    tpv.add(t, 2.0);
    assertEquals(1, tpv.getItemCount());
}
项目:astor    文件:TimePeriodValuesTests.java   
/**
 * Add a value to series A for 1999.  It should be added at index 0.
 */
public void testAddValue() {

    TimePeriodValues tpvs = new TimePeriodValues("Test");
    try {
        tpvs.add(new Year(1999), new Integer(1));
    }
    catch (SeriesException e) {
        System.err.println("Problem adding to series.");
    }

    int value = tpvs.getValue(0).intValue();
    assertEquals(1, value);

}
项目:astor    文件:TimePeriodValuesTests.java   
/**
 * A test for bug report 1161329.
 */
public void test1161329() {
    TimePeriodValues tpv = new TimePeriodValues("Test");
    RegularTimePeriod t = new Day();
    tpv.add(t, 1.0);
    t = t.next();
    tpv.add(t, 2.0);
    tpv.delete(0, 1);
    assertEquals(0, tpv.getItemCount());
    tpv.add(t, 2.0);
    assertEquals(1, tpv.getItemCount());
}
项目:astor    文件:TimePeriodValuesTests.java   
/**
 * Some tests for the getMinStartIndex() method.
 */
public void testGetMinStartIndex() {
    TimePeriodValues s = new TimePeriodValues("Test");
    assertEquals(-1, s.getMinStartIndex());
    s.add(new SimpleTimePeriod(100L, 200L), 1.0);
    assertEquals(0, s.getMinStartIndex());
    s.add(new SimpleTimePeriod(300L, 400L), 2.0);
    assertEquals(0, s.getMinStartIndex());
    s.add(new SimpleTimePeriod(0L, 50L), 3.0);
    assertEquals(2, s.getMinStartIndex());
}
项目:astor    文件:TimePeriodValuesTests.java   
/**
 * Some tests for the getMaxStartIndex() method.
 */
public void testGetMaxStartIndex() {
    TimePeriodValues s = new TimePeriodValues("Test");
    assertEquals(-1, s.getMaxStartIndex());
    s.add(new SimpleTimePeriod(100L, 200L), 1.0);
    assertEquals(0, s.getMaxStartIndex());
    s.add(new SimpleTimePeriod(300L, 400L), 2.0);
    assertEquals(1, s.getMaxStartIndex());
    s.add(new SimpleTimePeriod(0L, 50L), 3.0);
    assertEquals(1, s.getMaxStartIndex());
}
项目:astor    文件:TimePeriodValuesTests.java   
/**
 * Some tests for the getMinMiddleIndex() method.
 */
public void testGetMinMiddleIndex() {
    TimePeriodValues s = new TimePeriodValues("Test");
    assertEquals(-1, s.getMinMiddleIndex());
    s.add(new SimpleTimePeriod(100L, 200L), 1.0);
    assertEquals(0, s.getMinMiddleIndex());
    s.add(new SimpleTimePeriod(300L, 400L), 2.0);
    assertEquals(0, s.getMinMiddleIndex());
    s.add(new SimpleTimePeriod(0L, 50L), 3.0);
    assertEquals(2, s.getMinMiddleIndex());
}
项目:astor    文件:TimePeriodValuesTests.java   
/**
 * Some tests for the getMaxMiddleIndex() method.
 */
public void testGetMaxMiddleIndex() {
    TimePeriodValues s = new TimePeriodValues("Test");
    assertEquals(-1, s.getMaxMiddleIndex());
    s.add(new SimpleTimePeriod(100L, 200L), 1.0);
    assertEquals(0, s.getMaxMiddleIndex());
    s.add(new SimpleTimePeriod(300L, 400L), 2.0);
    assertEquals(1, s.getMaxMiddleIndex());
    s.add(new SimpleTimePeriod(0L, 50L), 3.0);
    assertEquals(1, s.getMaxMiddleIndex());
    s.add(new SimpleTimePeriod(150L, 200L), 4.0);
    assertEquals(1, s.getMaxMiddleIndex());
}
项目:astor    文件:TimePeriodValuesTests.java   
/**
 * Some tests for the getMinEndIndex() method.
 */
public void getMinEndIndex() {
    TimePeriodValues s = new TimePeriodValues("Test");
    assertEquals(-1, s.getMinEndIndex());
    s.add(new SimpleTimePeriod(100L, 200L), 1.0);
    assertEquals(0, s.getMinEndIndex());
    s.add(new SimpleTimePeriod(300L, 400L), 2.0);
    assertEquals(0, s.getMinEndIndex());
    s.add(new SimpleTimePeriod(0L, 50L), 3.0);
    assertEquals(2, s.getMinEndIndex());
}
项目:astor    文件:TimePeriodValuesTests.java   
/**
 * Some tests for the getMaxEndIndex() method.
 */
public void getMaxEndIndex() {
    TimePeriodValues s = new TimePeriodValues("Test");
    assertEquals(-1, s.getMaxEndIndex());
    s.add(new SimpleTimePeriod(100L, 200L), 1.0);
    assertEquals(0, s.getMaxEndIndex());
    s.add(new SimpleTimePeriod(300L, 400L), 2.0);
    assertEquals(1, s.getMaxEndIndex());
    s.add(new SimpleTimePeriod(0L, 50L), 3.0);
    assertEquals(1, s.getMaxEndIndex());
}
项目:astor    文件:TimePeriodValuesCollectionTests.java   
/**
 * Some more checks for the getDomainBounds() method.
 * 
 * @see #testGetDomainBoundsWithoutInterval()
 */
public void testGetDomainBoundsWithInterval() {
    // check empty dataset
    TimePeriodValuesCollection dataset = new TimePeriodValuesCollection();
    Range r = dataset.getDomainBounds(true);
    assertNull(r);

    // check dataset with one time period
    TimePeriodValues s1 = new TimePeriodValues("S1");
    s1.add(new SimpleTimePeriod(1000L, 2000L), 1.0);
    dataset.addSeries(s1);
    r = dataset.getDomainBounds(true);
    assertEquals(1000.0, r.getLowerBound(), EPSILON);
    assertEquals(2000.0, r.getUpperBound(), EPSILON);

    // check dataset with two time periods
    s1.add(new SimpleTimePeriod(1500L, 3000L), 2.0);
    r = dataset.getDomainBounds(true);
    assertEquals(1000.0, r.getLowerBound(), EPSILON);
    assertEquals(3000.0, r.getUpperBound(), EPSILON);

    // add a third time period
    s1.add(new SimpleTimePeriod(6000L, 7000L), 1.5);
    r = dataset.getDomainBounds(true);
    assertEquals(1000.0, r.getLowerBound(), EPSILON);
    assertEquals(7000.0, r.getUpperBound(), EPSILON);

    // add a fourth time period
    s1.add(new SimpleTimePeriod(4000L, 5000L), 1.4);
    r = dataset.getDomainBounds(true);
    assertEquals(1000.0, r.getLowerBound(), EPSILON);
    assertEquals(7000.0, r.getUpperBound(), EPSILON);    
}
项目:ControlAndroidDeviceFromPC    文件:DisplaySyncHistogram.java   
private void addToPeriod(TimePeriodValues tpv[], int auth, SimpleTimePeriod period,
        double value) {
    int index;
    if (mTimePeriodMap[auth].containsKey(period)) {
        index = mTimePeriodMap[auth].get(period);
        double oldValue = tpv[auth].getValue(index).doubleValue();
        tpv[auth].update(index, oldValue + value);
    } else {
        index = tpv[auth].getItemCount();
        mTimePeriodMap[auth].put(period, index);
        tpv[auth].add(period, value);
    }
}
项目:ControlAndroidDeviceFromPC    文件:DisplaySyncPerf.java   
/**
 * Resets the display.
 */
@Override
void resetUI() {
    super.resetUI();
    XYPlot xyPlot = mChart.getXYPlot();
    xyPlot.getRangeAxis().setVisible(false);
    mTooltipGenerator = new CustomXYToolTipGenerator();

    @SuppressWarnings("unchecked")
    List<String>[] mTooltipsTmp = new List[NUM_SERIES];
    mTooltips = mTooltipsTmp;

    XYBarRenderer br = new XYBarRenderer();
    br.setUseYInterval(true);
    mDatasets = new TimePeriodValues[NUM_SERIES];

    TimePeriodValuesCollection tpvc = new YIntervalTimePeriodValuesCollection(1);
    xyPlot.setDataset(tpvc);
    xyPlot.setRenderer(br);

    for (int i = 0; i < NUM_SERIES; i++) {
        br.setSeriesPaint(i, SERIES_COLORS[i]);
        mDatasets[i] = new TimePeriodValues(SERIES_NAMES[i]);
        tpvc.addSeries(mDatasets[i]);
        mTooltips[i] = new ArrayList<String>();
        mTooltipGenerator.addToolTipSeries(mTooltips[i]);
        br.setSeriesToolTipGenerator(i, mTooltipGenerator);
    }
}
项目:parabuild-ci    文件:TimePeriodValuesTests.java   
/**
 * Tests the equals method.
 */
public void testEquals() {
    TimePeriodValues s1 = new TimePeriodValues("Time Series 1");
    TimePeriodValues s2 = new TimePeriodValues("Time Series 2");
    boolean b1 = s1.equals(s2);
    assertFalse("b1", b1);

    s2.setKey("Time Series 1");
    boolean b2 = s1.equals(s2);
    assertTrue("b2", b2);

    // domain description
    s1.setDomainDescription("XYZ");
    assertFalse(s1.equals(s2));
    s2.setDomainDescription("XYZ");
    assertTrue(s1.equals(s2));

    // domain description - null
    s1.setDomainDescription(null);
    assertFalse(s1.equals(s2));
    s2.setDomainDescription(null);
    assertTrue(s1.equals(s2));

    // range description
    s1.setRangeDescription("XYZ");
    assertFalse(s1.equals(s2));
    s2.setRangeDescription("XYZ");
    assertTrue(s1.equals(s2));

    // range description - null
    s1.setRangeDescription(null);
    assertFalse(s1.equals(s2));
    s2.setRangeDescription(null);
    assertTrue(s1.equals(s2));

    RegularTimePeriod p1 = new Day();
    RegularTimePeriod p2 = p1.next();
    s1.add(p1, 100.0);
    s1.add(p2, 200.0);
    boolean b3 = s1.equals(s2);
    assertFalse("b3", b3);

    s2.add(p1, 100.0);
    s2.add(p2, 200.0);
    boolean b4 = s1.equals(s2);
    assertTrue("b4", b4);

}
项目:SMVHunter    文件:DisplaySync.java   
/**
 * Resets the display.
 */
@Override
void resetUI() {
    super.resetUI();
    XYPlot xyPlot = mChart.getXYPlot();

    XYBarRenderer br = new XYBarRenderer();
    mDatasetsSync = new TimePeriodValues[NUM_AUTHS];

    @SuppressWarnings("unchecked")
    List<String> mTooltipsSyncTmp[] = new List[NUM_AUTHS];
    mTooltipsSync = mTooltipsSyncTmp;

    mTooltipGenerators = new CustomXYToolTipGenerator[NUM_AUTHS];

    TimePeriodValuesCollection tpvc = new TimePeriodValuesCollection();
    xyPlot.setDataset(tpvc);
    xyPlot.setRenderer(0, br);

    XYLineAndShapeRenderer ls = new XYLineAndShapeRenderer();
    ls.setBaseLinesVisible(false);
    mDatasetsSyncTickle = new TimeSeries[NUM_AUTHS];
    TimeSeriesCollection tsc = new TimeSeriesCollection();
    xyPlot.setDataset(1, tsc);
    xyPlot.setRenderer(1, ls);

    mDatasetError = new TimeSeries("Errors", FixedMillisecond.class);
    xyPlot.setDataset(2, new TimeSeriesCollection(mDatasetError));
    XYLineAndShapeRenderer errls = new XYLineAndShapeRenderer();
    errls.setBaseLinesVisible(false);
    errls.setSeriesPaint(0, Color.RED);
    xyPlot.setRenderer(2, errls);

    for (int i = 0; i < NUM_AUTHS; i++) {
        br.setSeriesPaint(i, AUTH_COLORS[i]);
        ls.setSeriesPaint(i, AUTH_COLORS[i]);
        mDatasetsSync[i] = new TimePeriodValues(AUTH_NAMES[i]);
        tpvc.addSeries(mDatasetsSync[i]);
        mTooltipsSync[i] = new ArrayList<String>();
        mTooltipGenerators[i] = new CustomXYToolTipGenerator();
        br.setSeriesToolTipGenerator(i, mTooltipGenerators[i]);
        mTooltipGenerators[i].addToolTipSeries(mTooltipsSync[i]);

        mDatasetsSyncTickle[i] = new TimeSeries(AUTH_NAMES[i] + " tickle",
                FixedMillisecond.class);
        tsc.addSeries(mDatasetsSyncTickle[i]);
        ls.setSeriesShape(i, ShapeUtilities.createUpTriangle(2.5f));
    }
}
项目:nabs    文件:TimePeriodValuesTests.java   
/**
 * Tests the equals method.
 */
public void testEquals() {
    TimePeriodValues s1 = new TimePeriodValues("Time Series 1");
    TimePeriodValues s2 = new TimePeriodValues("Time Series 2");
    boolean b1 = s1.equals(s2);
    assertFalse("b1", b1);

    s2.setKey("Time Series 1");
    boolean b2 = s1.equals(s2);
    assertTrue("b2", b2);

    // domain description
    s1.setDomainDescription("XYZ");
    assertFalse(s1.equals(s2));
    s2.setDomainDescription("XYZ");
    assertTrue(s1.equals(s2));

    // domain description - null
    s1.setDomainDescription(null);
    assertFalse(s1.equals(s2));
    s2.setDomainDescription(null);
    assertTrue(s1.equals(s2));

    // range description
    s1.setRangeDescription("XYZ");
    assertFalse(s1.equals(s2));
    s2.setRangeDescription("XYZ");
    assertTrue(s1.equals(s2));

    // range description - null
    s1.setRangeDescription(null);
    assertFalse(s1.equals(s2));
    s2.setRangeDescription(null);
    assertTrue(s1.equals(s2));

    RegularTimePeriod p1 = new Day();
    RegularTimePeriod p2 = p1.next();
    s1.add(p1, 100.0);
    s1.add(p2, 200.0);
    boolean b3 = s1.equals(s2);
    assertFalse("b3", b3);

    s2.add(p1, 100.0);
    s2.add(p2, 200.0);
    boolean b4 = s1.equals(s2);
    assertTrue("b4", b4);

}
项目:astor    文件:TimePeriodValuesTests.java   
/**
 * Tests the equals method.
 */
public void testEquals() {
    TimePeriodValues s1 = new TimePeriodValues("Time Series 1");
    TimePeriodValues s2 = new TimePeriodValues("Time Series 2");
    boolean b1 = s1.equals(s2);
    assertFalse("b1", b1);

    s2.setKey("Time Series 1");
    boolean b2 = s1.equals(s2);
    assertTrue("b2", b2);

    // domain description
    s1.setDomainDescription("XYZ");
    assertFalse(s1.equals(s2));
    s2.setDomainDescription("XYZ");
    assertTrue(s1.equals(s2));

    // domain description - null
    s1.setDomainDescription(null);
    assertFalse(s1.equals(s2));
    s2.setDomainDescription(null);
    assertTrue(s1.equals(s2));

    // range description
    s1.setRangeDescription("XYZ");
    assertFalse(s1.equals(s2));
    s2.setRangeDescription("XYZ");
    assertTrue(s1.equals(s2));

    // range description - null
    s1.setRangeDescription(null);
    assertFalse(s1.equals(s2));
    s2.setRangeDescription(null);
    assertTrue(s1.equals(s2));

    RegularTimePeriod p1 = new Day();
    RegularTimePeriod p2 = p1.next();
    s1.add(p1, 100.0);
    s1.add(p2, 200.0);
    boolean b3 = s1.equals(s2);
    assertFalse("b3", b3);

    s2.add(p1, 100.0);
    s2.add(p2, 200.0);
    boolean b4 = s1.equals(s2);
    assertTrue("b4", b4);

}
项目:ControlAndroidDeviceFromPC    文件:DisplaySync.java   
/**
 * Resets the display.
 */
@Override
void resetUI() {
    super.resetUI();
    XYPlot xyPlot = mChart.getXYPlot();

    XYBarRenderer br = new XYBarRenderer();
    mDatasetsSync = new TimePeriodValues[NUM_AUTHS];

    @SuppressWarnings("unchecked")
    List<String> mTooltipsSyncTmp[] = new List[NUM_AUTHS];
    mTooltipsSync = mTooltipsSyncTmp;

    mTooltipGenerators = new CustomXYToolTipGenerator[NUM_AUTHS];

    TimePeriodValuesCollection tpvc = new TimePeriodValuesCollection();
    xyPlot.setDataset(tpvc);
    xyPlot.setRenderer(0, br);

    XYLineAndShapeRenderer ls = new XYLineAndShapeRenderer();
    ls.setBaseLinesVisible(false);
    mDatasetsSyncTickle = new TimeSeries[NUM_AUTHS];
    TimeSeriesCollection tsc = new TimeSeriesCollection();
    xyPlot.setDataset(1, tsc);
    xyPlot.setRenderer(1, ls);

    mDatasetError = new TimeSeries("Errors", FixedMillisecond.class);
    xyPlot.setDataset(2, new TimeSeriesCollection(mDatasetError));
    XYLineAndShapeRenderer errls = new XYLineAndShapeRenderer();
    errls.setBaseLinesVisible(false);
    errls.setSeriesPaint(0, Color.RED);
    xyPlot.setRenderer(2, errls);

    for (int i = 0; i < NUM_AUTHS; i++) {
        br.setSeriesPaint(i, AUTH_COLORS[i]);
        ls.setSeriesPaint(i, AUTH_COLORS[i]);
        mDatasetsSync[i] = new TimePeriodValues(AUTH_NAMES[i]);
        tpvc.addSeries(mDatasetsSync[i]);
        mTooltipsSync[i] = new ArrayList<String>();
        mTooltipGenerators[i] = new CustomXYToolTipGenerator();
        br.setSeriesToolTipGenerator(i, mTooltipGenerators[i]);
        mTooltipGenerators[i].addToolTipSeries(mTooltipsSync[i]);

        mDatasetsSyncTickle[i] = new TimeSeries(AUTH_NAMES[i] + " tickle",
                FixedMillisecond.class);
        tsc.addSeries(mDatasetsSyncTickle[i]);
        ls.setSeriesShape(i, ShapeUtilities.createUpTriangle(2.5f));
    }
}