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

项目:parabuild-ci    文件:XYPlotTests.java   
/**
 * Creates a sample dataset.
 *
 * @return Series 1.
 */
private IntervalXYDataset createDataset1() {

    // create dataset 1...
    TimeSeries series1 = new TimeSeries("Series 1", Day.class);
    series1.add(new Day(1, MonthConstants.MARCH, 2002), 12353.3);
    series1.add(new Day(2, MonthConstants.MARCH, 2002), 13734.4);
    series1.add(new Day(3, MonthConstants.MARCH, 2002), 14525.3);
    series1.add(new Day(4, MonthConstants.MARCH, 2002), 13984.3);
    series1.add(new Day(5, MonthConstants.MARCH, 2002), 12999.4);
    series1.add(new Day(6, MonthConstants.MARCH, 2002), 14274.3);
    series1.add(new Day(7, MonthConstants.MARCH, 2002), 15943.5);
    series1.add(new Day(8, MonthConstants.MARCH, 2002), 14845.3);
    series1.add(new Day(9, MonthConstants.MARCH, 2002), 14645.4);
    series1.add(new Day(10, MonthConstants.MARCH, 2002), 16234.6);
    series1.add(new Day(11, MonthConstants.MARCH, 2002), 17232.3);
    series1.add(new Day(12, MonthConstants.MARCH, 2002), 14232.2);
    series1.add(new Day(13, MonthConstants.MARCH, 2002), 13102.2);
    series1.add(new Day(14, MonthConstants.MARCH, 2002), 14230.2);
    series1.add(new Day(15, MonthConstants.MARCH, 2002), 11235.2);

    TimeSeriesCollection collection = new TimeSeriesCollection(series1);
    return collection;

}
项目:ccu-historian    文件:XYPlotTest.java   
/**
 * Creates a sample dataset.
 *
 * @return Series 1.
 */
private IntervalXYDataset createDataset1() {

    // create dataset 1...
    TimeSeries series1 = new TimeSeries("Series 1", Day.class);
    series1.add(new Day(1, MonthConstants.MARCH, 2002), 12353.3);
    series1.add(new Day(2, MonthConstants.MARCH, 2002), 13734.4);
    series1.add(new Day(3, MonthConstants.MARCH, 2002), 14525.3);
    series1.add(new Day(4, MonthConstants.MARCH, 2002), 13984.3);
    series1.add(new Day(5, MonthConstants.MARCH, 2002), 12999.4);
    series1.add(new Day(6, MonthConstants.MARCH, 2002), 14274.3);
    series1.add(new Day(7, MonthConstants.MARCH, 2002), 15943.5);
    series1.add(new Day(8, MonthConstants.MARCH, 2002), 14845.3);
    series1.add(new Day(9, MonthConstants.MARCH, 2002), 14645.4);
    series1.add(new Day(10, MonthConstants.MARCH, 2002), 16234.6);
    series1.add(new Day(11, MonthConstants.MARCH, 2002), 17232.3);
    series1.add(new Day(12, MonthConstants.MARCH, 2002), 14232.2);
    series1.add(new Day(13, MonthConstants.MARCH, 2002), 13102.2);
    series1.add(new Day(14, MonthConstants.MARCH, 2002), 14230.2);
    series1.add(new Day(15, MonthConstants.MARCH, 2002), 11235.2);

    TimeSeriesCollection collection = new TimeSeriesCollection(series1);
    return collection;

}
项目:AgentWorkbench    文件:TimeSeriesChartTab.java   
@Override
    public void replaceModel(DataModel newModel) {
        this.dataModel = newModel;

//      this.chartPanel.setChart(ChartFactory.createTimeSeriesChart(
//              this.dataModel.getOntologyModel().getChartSettings().getChartTitle(), 
//              this.dataModel.getOntologyModel().getChartSettings().getXAxisLabel(), 
//              this.dataModel.getOntologyModel().getChartSettings().getYAxisLabel(), 
//              ((TimeSeriesDataModel)this.dataModel).getTimeSeriesChartModel().getTimeSeriesCollection(), 
//              true, false, false
//      ));
//      
//      applySettings();

        TimeSeriesCollection tsc = ((TimeSeriesDataModel)this.dataModel).getTimeSeriesChartModel().getTimeSeriesCollection();
        this.chartPanel.getChart().getXYPlot().setDataset(tsc);

        dataModel.getChartModel().addObserver(this);
    }
项目:open-java-trade-manager    文件:ChartJDialog.java   
private void plotTradeBubblesOnChart(ArrayList<Integer> toPlot, String p, int k, int j)
  {
    final Plot main_plot = (Plot)((CombinedDomainXYPlot)this.candlestickChart.getPlot()).getSubplots().get(0);
      final XYPlot plot = (XYPlot) main_plot;

    final TimeSeries series = new TimeSeries(p);
///*
for(Integer i: toPlot)
{
    switch(j)
    {
    case 0:
        series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getOpen());
        break;
    case 1:
        series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getHigh());
        break;
    case 2:
        series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getLow());
        break;
    case 3:
        series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getClose());
        break;
    }

}
/*
for (int i = 0; i < defaultHighLowDataset.getSeriesCount(); i++) 
{
          series.add(new Minute(defaultHighLowDataset.getXDate(0, i)),plot[i]);
      }
*/
XYDataset dataSet = new TimeSeriesCollection(series);

plot.setDataset(k, dataSet);
    XYItemRenderer ir = new XYShapeRenderer();
    //ir.s

    plot.setRenderer(k, ir);
  }
项目:open-java-trade-manager    文件:ChartJDialog.java   
private XYDataset createIndicatorPlot(String name, Double[] plot)
{
    final TimeSeries series = new TimeSeries(name);
    ///*
    for (int i = 0; i < chartDatas.size(); i++) 
    {
           series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),plot[i]);
       }
    /*
    for (int i = 0; i < defaultHighLowDataset.getSeriesCount(); i++) 
    {
           series.add(new Minute(defaultHighLowDataset.getXDate(0, i)),plot[i]);
       }
    */
       return new TimeSeriesCollection(series);
}
项目:financehelper    文件:IndustryTimeSeriesChart.java   
private XYDataset createDataset(List<String> industrys) {
    TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
    if (industrys != null) {
        for (String industry : industrys) {
            TimeSeries timeseries = new TimeSeries(industry + "资金统计",
                    org.jfree.data.time.Day.class);
            List<IndustryInfo> industryInfos = industryInfoDao.get(industry);
            Double value = 0.0;
            if (industryInfos != null) {
                for (IndustryInfo industryInfo : industryInfos) {
                    value = value + industryInfo.getTotal() / 10000;
                    timeseries.add(new Day(DateUtil.parse(String.valueOf(industryInfo.getDate()), DateUtil.DATE_FORMAT_DAY_SHORT)), value);
                }
            }
            timeseriescollection.addSeries(timeseries);
        }
    }
    return timeseriescollection;
}
项目:financehelper    文件:IndustryRiseChart.java   
private XYDataset createDataset(List<String> industrys) {
    TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
    if (industrys != null) {
        for (String industry : industrys) {
            TimeSeries timeseries = new TimeSeries(industry + "涨跌统计",
                    org.jfree.data.time.Day.class);
            List<IndustryInfo> industryInfos = industryInfoDao.get(industry);
            BigDecimal value = new BigDecimal(0);
            if (industryInfos != null) {
                for (IndustryInfo industryInfo : industryInfos) {
                    if (industryInfo.getRise() != null) {
                        value = value.add(industryInfo.getRise());
                    }
                    timeseries.add(new Day(DateUtil.parse(String.valueOf(industryInfo.getDate()), DateUtil.DATE_FORMAT_DAY_SHORT)), value);
                }
            }
            timeseriescollection.addSeries(timeseries);
        }
    }
    return timeseriescollection;
}
项目:parabuild-ci    文件:TimeSeriesCollectionTests.java   
/**
 * Tests the remove series method.
 */
public void testRemoveSeries() {

    final TimeSeriesCollection c1 = new TimeSeriesCollection();

    final TimeSeries s1 = new TimeSeries("Series 1");
    final TimeSeries s2 = new TimeSeries("Series 2");
    final TimeSeries s3 = new TimeSeries("Series 3");
    final TimeSeries s4 = new TimeSeries("Series 4");

    c1.addSeries(s1);
    c1.addSeries(s2);
    c1.addSeries(s3);
    c1.addSeries(s4);

    c1.removeSeries(s3);

    final TimeSeries s = c1.getSeries(2);
    final boolean b1 = s.equals(s4);
    assertTrue(b1);

}
项目:parabuild-ci    文件:SWTMultipleAxisDemo1.java   
/**
 * Creates a sample dataset.
 * 
 * @param name  the dataset name.
 * @param base  the starting value.
 * @param start  the starting period.
 * @param count  the number of values to generate.
 *
 * @return The dataset.
 */
private static XYDataset createDataset(String name, double base, 
                                       RegularTimePeriod start, int count) {

    TimeSeries series = new TimeSeries(name, start.getClass());
    RegularTimePeriod period = start;
    double value = base;
    for (int i = 0; i < count; i++) {
        series.add(period, value);    
        period = period.next();
        value = value * (1 + (Math.random() - 0.495) / 10.0);
    }

    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(series);

    return dataset;

}
项目:parabuild-ci    文件:TimeSeriesCollectionTests.java   
/**
 * Tests the remove series method.
 */
public void testRemoveSeries() {

    TimeSeriesCollection c1 = new TimeSeriesCollection();

    TimeSeries s1 = new TimeSeries("Series 1");
    TimeSeries s2 = new TimeSeries("Series 2");
    TimeSeries s3 = new TimeSeries("Series 3");
    TimeSeries s4 = new TimeSeries("Series 4");

    c1.addSeries(s1);
    c1.addSeries(s2);
    c1.addSeries(s3);
    c1.addSeries(s4);

    c1.removeSeries(s3);

    TimeSeries s = c1.getSeries(2);
    boolean b1 = s.equals(s4);
    assertTrue(b1);

}
项目:parabuild-ci    文件:SymbolicXYItemLabelGenerator.java   
/**
 * Generates a tool tip text item for a particular item within a series.
 *
 * @param data  the dataset.
 * @param series  the series number (zero-based index).
 * @param item  the item number (zero-based index).
 *
 * @return The tool tip text (possibly <code>null</code>).
 */
public String generateToolTip(XYDataset data, int series, int item) {

    String xStr, yStr;
    if (data instanceof YisSymbolic) {
        yStr = ((YisSymbolic) data).getYSymbolicValue(series, item);
    }
    else {
        double y = data.getYValue(series, item);
        yStr = Double.toString(round(y, 2));
    }
    if (data instanceof XisSymbolic) {
        xStr = ((XisSymbolic) data).getXSymbolicValue(series, item);
    }
    else if (data instanceof TimeSeriesCollection) {
        RegularTimePeriod p
            = ((TimeSeriesCollection) data).getSeries(series)
                .getTimePeriod(item);
        xStr = p.toString();
    }
    else {
        double x = data.getXValue(series, item);
        xStr = Double.toString(round(x, 2));
    }
    return "X: " + xStr + ", Y: " + yStr;
}
项目:ccu-historian    文件:SWTMultipleAxisDemo1.java   
/**
 * Creates a sample dataset.
 *
 * @param name  the dataset name.
 * @param base  the starting value.
 * @param start  the starting period.
 * @param count  the number of values to generate.
 *
 * @return The dataset.
 */
private static XYDataset createDataset(String name, double base,
                                       RegularTimePeriod start, int count) {

    TimeSeries series = new TimeSeries(name);
    RegularTimePeriod period = start;
    double value = base;
    for (int i = 0; i < count; i++) {
        series.add(period, value);
        period = period.next();
        value = value * (1 + (Math.random() - 0.495) / 10.0);
    }

    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(series);

    return dataset;

}
项目:ccu-historian    文件:JFreeChartTest.java   
/**
 * Serialize a time seroes chart, restore it, and check for equality.
 */
@Test
public void testSerialization4() {

    RegularTimePeriod t = new Day();
    TimeSeries series = new TimeSeries("Series 1");
    series.add(t, 36.4);
    t = t.next();
    series.add(t, 63.5);
    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(series);

    JFreeChart c1 = ChartFactory.createTimeSeriesChart("Test", "Date",
            "Value", dataset);
    JFreeChart c2 = (JFreeChart) TestUtilities.serialised(c1);
    assertEquals(c1, c2);
}
项目:jfreechart    文件:JFreeChartTest.java   
/**
 * Serialize a time seroes chart, restore it, and check for equality.
 */
@Test
public void testSerialization4() {

    RegularTimePeriod t = new Day();
    TimeSeries series = new TimeSeries("Series 1");
    series.add(t, 36.4);
    t = t.next();
    series.add(t, 63.5);
    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(series);

    JFreeChart c1 = ChartFactory.createTimeSeriesChart("Test", "Date",
            "Value", dataset);
    JFreeChart c2 = (JFreeChart) TestUtils.serialised(c1);
    assertEquals(c1, c2);
}
项目:jfreechart    文件:XYPlotTest.java   
/**
 * Creates a sample dataset.
 *
 * @return Series 1.
 */
private IntervalXYDataset createDataset1() {

    // create dataset 1...
    TimeSeries series1 = new TimeSeries("Series 1");
    series1.add(new Day(1, MonthConstants.MARCH, 2002), 12353.3);
    series1.add(new Day(2, MonthConstants.MARCH, 2002), 13734.4);
    series1.add(new Day(3, MonthConstants.MARCH, 2002), 14525.3);
    series1.add(new Day(4, MonthConstants.MARCH, 2002), 13984.3);
    series1.add(new Day(5, MonthConstants.MARCH, 2002), 12999.4);
    series1.add(new Day(6, MonthConstants.MARCH, 2002), 14274.3);
    series1.add(new Day(7, MonthConstants.MARCH, 2002), 15943.5);
    series1.add(new Day(8, MonthConstants.MARCH, 2002), 14845.3);
    series1.add(new Day(9, MonthConstants.MARCH, 2002), 14645.4);
    series1.add(new Day(10, MonthConstants.MARCH, 2002), 16234.6);
    series1.add(new Day(11, MonthConstants.MARCH, 2002), 17232.3);
    series1.add(new Day(12, MonthConstants.MARCH, 2002), 14232.2);
    series1.add(new Day(13, MonthConstants.MARCH, 2002), 13102.2);
    series1.add(new Day(14, MonthConstants.MARCH, 2002), 14230.2);
    series1.add(new Day(15, MonthConstants.MARCH, 2002), 11235.2);

    TimeSeriesCollection collection = new TimeSeriesCollection(series1);
    return collection;

}
项目:jasperreports    文件:TimeSeriesChartHyperlinkProvider.java   
@Override
public JRPrintHyperlink getEntityHyperlink(ChartEntity entity)
{
    JRPrintHyperlink printHyperlink = null;
    if (hasHyperlinks() && entity instanceof XYItemEntity)
    {
        XYItemEntity itemEntity = (XYItemEntity) entity;
        TimeSeriesCollection dataset = (TimeSeriesCollection) itemEntity.getDataset();
        TimeSeries series = dataset.getSeries(itemEntity.getSeriesIndex());
        Map<RegularTimePeriod, JRPrintHyperlink> serieHyperlinks = itemHyperlinks.get(series.getKey());
        if (serieHyperlinks != null)
        {
            RegularTimePeriod timePeriod = series.getTimePeriod(itemEntity.getItem());
            printHyperlink = serieHyperlinks.get(timePeriod);
        }
    }
    return printHyperlink;
}
项目:aya-lang    文件:SWTMultipleAxisDemo1.java   
/**
 * Creates a sample dataset.
 *
 * @param name  the dataset name.
 * @param base  the starting value.
 * @param start  the starting period.
 * @param count  the number of values to generate.
 *
 * @return The dataset.
 */
private static XYDataset createDataset(String name, double base,
                                       RegularTimePeriod start, int count) {

    TimeSeries series = new TimeSeries(name);
    RegularTimePeriod period = start;
    double value = base;
    for (int i = 0; i < count; i++) {
        series.add(period, value);
        period = period.next();
        value = value * (1 + (Math.random() - 0.495) / 10.0);
    }

    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(series);

    return dataset;

}
项目:aya-lang    文件:JFreeChartTest.java   
/**
 * Serialize a time seroes chart, restore it, and check for equality.
 */
@Test
public void testSerialization4() {

    RegularTimePeriod t = new Day();
    TimeSeries series = new TimeSeries("Series 1");
    series.add(t, 36.4);
    t = t.next();
    series.add(t, 63.5);
    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(series);

    JFreeChart c1 = ChartFactory.createTimeSeriesChart("Test", "Date",
            "Value", dataset);
    JFreeChart c2 = (JFreeChart) TestUtilities.serialised(c1);
    assertEquals(c1, c2);
}
项目:aya-lang    文件:XYPlotTest.java   
/**
 * Creates a sample dataset.
 *
 * @return Series 1.
 */
private IntervalXYDataset createDataset1() {

    // create dataset 1...
    TimeSeries series1 = new TimeSeries("Series 1", Day.class);
    series1.add(new Day(1, MonthConstants.MARCH, 2002), 12353.3);
    series1.add(new Day(2, MonthConstants.MARCH, 2002), 13734.4);
    series1.add(new Day(3, MonthConstants.MARCH, 2002), 14525.3);
    series1.add(new Day(4, MonthConstants.MARCH, 2002), 13984.3);
    series1.add(new Day(5, MonthConstants.MARCH, 2002), 12999.4);
    series1.add(new Day(6, MonthConstants.MARCH, 2002), 14274.3);
    series1.add(new Day(7, MonthConstants.MARCH, 2002), 15943.5);
    series1.add(new Day(8, MonthConstants.MARCH, 2002), 14845.3);
    series1.add(new Day(9, MonthConstants.MARCH, 2002), 14645.4);
    series1.add(new Day(10, MonthConstants.MARCH, 2002), 16234.6);
    series1.add(new Day(11, MonthConstants.MARCH, 2002), 17232.3);
    series1.add(new Day(12, MonthConstants.MARCH, 2002), 14232.2);
    series1.add(new Day(13, MonthConstants.MARCH, 2002), 13102.2);
    series1.add(new Day(14, MonthConstants.MARCH, 2002), 14230.2);
    series1.add(new Day(15, MonthConstants.MARCH, 2002), 11235.2);

    TimeSeriesCollection collection = new TimeSeriesCollection(series1);
    return collection;

}
项目:genotick    文件:GenoJFreeChart.java   
private JFreeChart createChartObject(String title, TimeChartDefinition definition) {
    boolean legend = true;
    OHLCSeriesCollection ohlcSeriesCollection = new OHLCSeriesCollection();
    TimeSeriesCollection timeSeriesCollection = new TimeSeriesCollection();
    definition.ohlcSeries.forEach((seriesTitle, series) -> ohlcSeriesCollection.addSeries(series));
    definition.timeSeries.forEach((seriesTitle, series) -> timeSeriesCollection.addSeries(series));
    JFreeChart chartObject = ChartFactory.createCandlestickChart(
            title, "time", "price", ohlcSeriesCollection, legend);
    XYPlot xyPlot = chartObject.getXYPlot();
    NumberAxis numberAxis = (NumberAxis)xyPlot.getRangeAxis();
    DateAxis dateAxis = (DateAxis)xyPlot.getDomainAxis();
    dateAxis.setDateFormatOverride(new SimpleDateFormat("dd-LLL-yy hh:mm", Locale.ENGLISH));
    CandlestickRenderer renderer = (CandlestickRenderer)xyPlot.getRenderer();
    renderer.setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_SMALLEST);
    for (int i = 0, size = definition.ohlcSeries.size(); i < size; ++i) {
        renderer.setSeriesPaint(i, Color.decode("#222222"));
    }
    numberAxis.setAutoRangeIncludesZero(false);
    addDatasetToPlot(xyPlot, timeSeriesCollection);
    return chartObject;
}
项目:HTML5_WebSite    文件:SymbolicXYItemLabelGenerator.java   
/**
 * Generates a tool tip text item for a particular item within a series.
 *
 * @param data  the dataset.
 * @param series  the series number (zero-based index).
 * @param item  the item number (zero-based index).
 *
 * @return The tool tip text (possibly <code>null</code>).
 */
public String generateToolTip(XYDataset data, int series, int item) {

    String xStr, yStr;
    if (data instanceof YisSymbolic) {
        yStr = ((YisSymbolic) data).getYSymbolicValue(series, item);
    }
    else {
        double y = data.getYValue(series, item);
        yStr = Double.toString(round(y, 2));
    }
    if (data instanceof XisSymbolic) {
        xStr = ((XisSymbolic) data).getXSymbolicValue(series, item);
    }
    else if (data instanceof TimeSeriesCollection) {
        RegularTimePeriod p
            = ((TimeSeriesCollection) data).getSeries(series)
                .getTimePeriod(item);
        xStr = p.toString();
    }
    else {
        double x = data.getXValue(series, item);
        xStr = Double.toString(round(x, 2));
    }
    return "X: " + xStr + ", Y: " + yStr;
}
项目:AnSoMia    文件:MarketValueChart.java   
/**
 * Creates the dataset.
 *
 * @return the XY dataset
 */
private XYDataset createDataset() {

    TimeSeriesCollection dataset = new TimeSeriesCollection();
    TimeSeries s1 = new TimeSeries(this.values1_des);

    for(int i = 0; i < this.values1.length; i++) {
        s1.add(new Day(dates.get(i)), this.values1[i]);
    }
    dataset.addSeries(s1);

    if(this.values2 != null) {
     TimeSeries s2 = new TimeSeries(this.values2_des);

     for(int i = 0; i < this.values2.length; i++) {
        s2.add(new Day(dates.get(i)), this.values2[i]);
     }

     dataset.addSeries(s2);
    }

    return dataset;

}
项目:AndroidRobot    文件:MemInfo.java   
@SuppressWarnings("deprecation")
private void createTable(Composite rtComp) {
    thread1 = new Thread(this);
    lastValue = 100D;
    // 创建时序图对象
    timeseries = new TimeSeries(
        "实时内存",
        MemInfo.class$org$jfree$data$time$Millisecond != null ? MemInfo.class$org$jfree$data$time$Millisecond
            : (MemInfo.class$org$jfree$data$time$Millisecond = MemInfo
                .getClass("org.jfree.data.time.Millisecond")));
    TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(timeseries);
    // 创建图表面板
    disp = shell.getDisplay();
    final ChartComposite frame = new ChartComposite(rtComp, SWT.NONE,
        createChart(timeseriescollection), true);
    frame.pack();
    MemInfo.startThread();
}
项目:AndroidRobot    文件:FpsInfo.java   
@SuppressWarnings("deprecation")
private void createTable(Composite rtComp) {
    thread1 = new Thread(this);
    lastValue = 20D;
    // 创建时序图对象
    timeseries = new TimeSeries(
        "实时FPS",
        FpsInfo.class$org$jfree$data$time$Millisecond != null ? FpsInfo.class$org$jfree$data$time$Millisecond
            : (FpsInfo.class$org$jfree$data$time$Millisecond = FpsInfo
                .getClass("org.jfree.data.time.Millisecond")));
    TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(timeseries);
    // 创建图表面板
    disp = shell.getDisplay();
    final ChartComposite frame = new ChartComposite(rtComp, SWT.NONE,
        createChart(timeseriescollection), true);
    frame.pack();
    FpsInfo.startThread();
}
项目:PI    文件:SymbolicXYItemLabelGenerator.java   
/**
 * Generates a tool tip text item for a particular item within a series.
 *
 * @param data  the dataset.
 * @param series  the series number (zero-based index).
 * @param item  the item number (zero-based index).
 *
 * @return The tool tip text (possibly <code>null</code>).
 */
public String generateToolTip(XYDataset data, int series, int item) {

    String xStr, yStr;
    if (data instanceof YisSymbolic) {
        yStr = ((YisSymbolic) data).getYSymbolicValue(series, item);
    }
    else {
        double y = data.getYValue(series, item);
        yStr = Double.toString(round(y, 2));
    }
    if (data instanceof XisSymbolic) {
        xStr = ((XisSymbolic) data).getXSymbolicValue(series, item);
    }
    else if (data instanceof TimeSeriesCollection) {
        RegularTimePeriod p
            = ((TimeSeriesCollection) data).getSeries(series)
                .getTimePeriod(item);
        xStr = p.toString();
    }
    else {
        double x = data.getXValue(series, item);
        xStr = Double.toString(round(x, 2));
    }
    return "X: " + xStr + ", Y: " + yStr;
}
项目:WS-Attacker    文件:ChartObject.java   
private IntervalXYDataset createDatasetNumberRequestsUntampered()
{

    Date currentDate;
    long currentMsTs;
    final TimeSeries series = new TimeSeries( "Sent Untampered Requests per Second" );
    if ( model.getMapLogEntryIntervalUntampered() != null )
    {
        for ( Map.Entry<Integer, LogEntryInterval> log : model.getMapLogEntryIntervalUntampered().entrySet() )
        {
            // Create TS from model.startTime and log.getIntervalNumber();
            currentMsTs = model.getTsAttackStart() + log.getValue().getIntervalNumber();
            currentDate = new Date( currentMsTs );
            series.add( new Second( currentDate ), ( log.getValue().getNumberRequests() ) );
        }
    }

    final TimeSeriesCollection dataset = new TimeSeriesCollection( series );
    dataset.setXPosition( TimePeriodAnchor.MIDDLE );

    return dataset;
}
项目:WS-Attacker    文件:ChartObject.java   
private IntervalXYDataset createDatasetNumberRequestsTampered()
{

    Date currentDate;
    long currentMsTs;
    final TimeSeries series = new TimeSeries( "Sent Tampered Requests per Second" );
    if ( model.getMapLogEntryIntervalTampered() != null )
    {
        for ( Map.Entry<Integer, LogEntryInterval> log : model.getMapLogEntryIntervalTampered().entrySet() )
        {
            // Create TS from model.startTime and log.getIntervalNumber();
            currentMsTs = model.getTsAttackStart() + log.getValue().getIntervalNumber();
            currentDate = new Date( currentMsTs );
            series.add( new Second( currentDate ), ( log.getValue().getNumberRequests() ) );
        }
    }

    final TimeSeriesCollection dataset = new TimeSeriesCollection( series );
    dataset.setXPosition( TimePeriodAnchor.MIDDLE );

    return dataset;
}
项目:logdog    文件:SyncedChartPanel.java   
void clear() {
    synchronized (mChartLock) {
        XYPlot plot = (XYPlot) getChart().getPlot();
        for (int datasetIndex = 0; datasetIndex < plot.getDatasetCount(); ++datasetIndex) {
            TimeSeriesCollection dataset = (TimeSeriesCollection) plot.getDataset(datasetIndex);
            if (dataset != null) {
                for (int seriesIndex = 0; seriesIndex < dataset.getSeriesCount(); ++seriesIndex) {
                    TimeSeriesWithStats ts = (TimeSeriesWithStats) dataset.getSeries(seriesIndex);
                    ts.clear();
                }
            }
        }
        // Remove any zoom
        restoreAutoBounds();
        mChartScrollBar.reset();
    }
}
项目:jablus    文件:TimeGraphPanel.java   
/** Remove a data series */
public void removeSeries(String name){
    TimeSeriesCollection dataset = (TimeSeriesCollection)chart.getXYPlot().getDataset(0);
    int id = ((Integer)seriesIds.get(name)).intValue();
    dataset.removeSeries(id);
    // Decrament all ids greater than id
    for(Enumeration i = seriesIds.keys(); i.hasMoreElements();){
        String k = (String)i.nextElement();
        int tmpId = seriesIds.get(k);
        if(tmpId > id){
            tmpId--;
            seriesIds.put(k, tmpId);
            chart.getXYPlot().getRenderer().setSeriesPaint(tmpId, seriesPaint.get(k));
        }
    }
    seriesCount--;
}
项目:jablus    文件:TimeGraphPanel.java   
/** Add a data item to the end of a series */
    public void addData(String name, double value){
//System.out.println("TimeGraphPanel: Adding data " + name + "=" + value);
        TimeSeries series = null;
        if(hiddenSeries.containsKey(name))
            series = hiddenSeries.get(name);
        else{
            TimeSeriesCollection dataset = (TimeSeriesCollection)chart.getXYPlot().getDataset(0);
            int id = seriesIds.get(name);
            series = dataset.getSeries(id);
        }
        if(series.getItemCount() == 0){
            series.add(new Week(startTime), value);
        }
        else{
//System.out.println("TimeGraphPanel: seriesDescription = " + series.getDomainDescription());
            series.add(series.getNextTimePeriod(), value);
        }

    }
项目:jablus    文件:TimeGraphPanel.java   
private void setVisible(String seriesName, boolean visible){
    TimeSeriesCollection dataset = (TimeSeriesCollection)chart.getXYPlot().getDataset(0);
    if(!seriesIds.containsKey(seriesName)) return;
    int id = seriesIds.get(seriesName);
    if(visible){
        if(!hiddenSeries.containsKey(seriesName)) return;
        addSeries(seriesName, hiddenSeries.get(seriesName), seriesPaint.get(seriesName));
        hiddenSeries.remove(seriesName);
    }
    else{
        if(hiddenSeries.containsKey(seriesName)) return;
        TimeSeries series = dataset.getSeries(id);
        removeSeries(seriesName);
        hiddenSeries.put(seriesName, series);
    }
    repaint();
}
项目:OTCAnalyser    文件:GraphWindow.java   
public synchronized void addChartPanel(String currency, boolean byMonth) {
    TimeSeriesCollection dataset = LineGraphMaker.makeDataset();
  datasets.add(dataset);
  String currencyName = currency;
  if (currency.isEmpty()) {
    currencyName = "Unknown Currency";
  }
  String timePeriod = "Day";
  if (byMonth) {
    timePeriod = "Month";
  }
  JFreeChart chart = LineGraphMaker.makeChart("Prices by " + timePeriod, currencyName, dataset, byMonth);
  chart.setBackgroundPaint(chartColor);
  XYPlot plot = (XYPlot) chart.getPlot();
  plot.setBackgroundPaint(plotColor);
  ChartPanel panel = new ChartPanel(chart);
  chartPanels.add(panel);
  ChartEditorManager.setChartEditorFactory(new NewDefaultChartEditorFactory());
  panel.setFillZoomRectangle(true);
  panel.setMouseWheelEnabled(true);
  currencies.add(currency);
}
项目:OTCAnalyser    文件:GraphWindow.java   
public synchronized void addTradesToDatasets(List<PriceTimePair> maxes, List<PriceTimePair> mins,
    List<PriceTimePair> avgs,List<PriceTimePair> trendLine, String currency, boolean byMonth) {
  if (!currencies.contains(currency)) {
    addChartPanel(currency, byMonth);
  }
  int i = currencies.indexOf(currency);
  TimeSeriesCollection dataset = datasets.get(i);
  LineGraphMaker.addToSeries(maxes, dataset, LineGraphMaker.MAX, byMonth);
  LineGraphMaker.addToSeries(mins, dataset, LineGraphMaker.MIN, byMonth);
  LineGraphMaker.addToSeries(avgs, dataset, LineGraphMaker.AVG, byMonth);
  LineGraphMaker.addToSeries(trendLine, dataset, LineGraphMaker.TREND_LINE, byMonth);
  if (currencies.size() > 1) {
    makeToolBar();
  }
  if (pnl.getComponentCount() == 0) {
    currentChart = chartPanels.get(0);
    pnl.add(currentChart);
  }
}
项目:nabs    文件:SWTMultipleAxisDemo1.java   
/**
 * Creates a sample dataset.
 * 
 * @param name  the dataset name.
 * @param base  the starting value.
 * @param start  the starting period.
 * @param count  the number of values to generate.
 *
 * @return The dataset.
 */
private static XYDataset createDataset(String name, double base, 
                                       RegularTimePeriod start, int count) {

    TimeSeries series = new TimeSeries(name, start.getClass());
    RegularTimePeriod period = start;
    double value = base;
    for (int i = 0; i < count; i++) {
        series.add(period, value);    
        period = period.next();
        value = value * (1 + (Math.random() - 0.495) / 10.0);
    }

    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(series);

    return dataset;

}
项目:nabs    文件:XYPlotTests.java   
/**
 * Creates a sample dataset.
 *
 * @return Series 1.
 */
private IntervalXYDataset createDataset1() {

    // create dataset 1...
    TimeSeries series1 = new TimeSeries("Series 1", Day.class);
    series1.add(new Day(1, MonthConstants.MARCH, 2002), 12353.3);
    series1.add(new Day(2, MonthConstants.MARCH, 2002), 13734.4);
    series1.add(new Day(3, MonthConstants.MARCH, 2002), 14525.3);
    series1.add(new Day(4, MonthConstants.MARCH, 2002), 13984.3);
    series1.add(new Day(5, MonthConstants.MARCH, 2002), 12999.4);
    series1.add(new Day(6, MonthConstants.MARCH, 2002), 14274.3);
    series1.add(new Day(7, MonthConstants.MARCH, 2002), 15943.5);
    series1.add(new Day(8, MonthConstants.MARCH, 2002), 14845.3);
    series1.add(new Day(9, MonthConstants.MARCH, 2002), 14645.4);
    series1.add(new Day(10, MonthConstants.MARCH, 2002), 16234.6);
    series1.add(new Day(11, MonthConstants.MARCH, 2002), 17232.3);
    series1.add(new Day(12, MonthConstants.MARCH, 2002), 14232.2);
    series1.add(new Day(13, MonthConstants.MARCH, 2002), 13102.2);
    series1.add(new Day(14, MonthConstants.MARCH, 2002), 14230.2);
    series1.add(new Day(15, MonthConstants.MARCH, 2002), 11235.2);

    TimeSeriesCollection collection = new TimeSeriesCollection(series1);
    return collection;

}
项目:nabs    文件:TimeSeriesCollectionTests.java   
/**
 * Tests the remove series method.
 */
public void testRemoveSeries() {

    TimeSeriesCollection c1 = new TimeSeriesCollection();

    TimeSeries s1 = new TimeSeries("Series 1");
    TimeSeries s2 = new TimeSeries("Series 2");
    TimeSeries s3 = new TimeSeries("Series 3");
    TimeSeries s4 = new TimeSeries("Series 4");

    c1.addSeries(s1);
    c1.addSeries(s2);
    c1.addSeries(s3);
    c1.addSeries(s4);

    c1.removeSeries(s3);

    TimeSeries s = c1.getSeries(2);
    boolean b1 = s.equals(s4);
    assertTrue(b1);

}
项目:nabs    文件:SymbolicXYItemLabelGenerator.java   
/**
 * Generates a tool tip text item for a particular item within a series.
 *
 * @param data  the dataset.
 * @param series  the series number (zero-based index).
 * @param item  the item number (zero-based index).
 *
 * @return The tool tip text (possibly <code>null</code>).
 */
public String generateToolTip(XYDataset data, int series, int item) {

    String xStr, yStr;
    if (data instanceof YisSymbolic) {
        yStr = ((YisSymbolic) data).getYSymbolicValue(series, item);
    }
    else {
        double y = data.getYValue(series, item);
        yStr = Double.toString(round(y, 2));
    }
    if (data instanceof XisSymbolic) {
        xStr = ((XisSymbolic) data).getXSymbolicValue(series, item);
    }
    else if (data instanceof TimeSeriesCollection) {
        RegularTimePeriod p
            = ((TimeSeriesCollection) data).getSeries(series)
                .getTimePeriod(item);
        xStr = p.toString();
    }
    else {
        double x = data.getXValue(series, item);
        xStr = Double.toString(round(x, 2));
    }
    return "X: " + xStr + ", Y: " + yStr;
}
项目:offspring    文件:OffspringChartComposite.java   
private IntervalXYDataset createVolumeDataset() {
  List<IRate> rates = rateProvider.getRates(base, quote);
  TimeSeries series = new TimeSeries("Volume");
  boolean non_zero_found = false;
  if (rates != null) {
    for (IRate rate : rates) {
      Date date = new Date(rate.getTimestamp());
      double vol = rate.getTotalVol();
      series.addOrUpdate(new Hour(date), vol);
      if (vol > 0)
        non_zero_found = true;
    }
  }
  if (non_zero_found == false)
    return null;

  TimeSeriesCollection dataset = new TimeSeriesCollection(series);
  dataset.setDomainIsPointsInTime(true);
  return dataset;
}
项目:cooper    文件:ExecuteHistoryChartPanel.java   
private XYDataset createDataset() throws JDependException {

        TimeSeries scoreSeries = new TimeSeries("总分");
        TimeSeries dSeries = new TimeSeries("抽象程度合理性");
        TimeSeries balanceSeries = new TimeSeries("内聚性");
        TimeSeries relationSeries = new TimeSeries("关系合理性");

        AnalysisResult result;

        for (ExecuteResultSummry summary : this.results.keySet()) {

            result = this.results.get(summary);
            scoreSeries.add(new Minute(summary.getCreateDate()), result.getScore());
            dSeries.add(new Minute(summary.getCreateDate()), result.getDistance());
            balanceSeries.add(new Minute(summary.getCreateDate()), result.getBalance());
            relationSeries.add(new Minute(summary.getCreateDate()), result.getRelationRationality());
        }

        TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
        timeseriescollection.addSeries(scoreSeries);
        timeseriescollection.addSeries(dSeries);
        timeseriescollection.addSeries(balanceSeries);
        timeseriescollection.addSeries(relationSeries);

        return timeseriescollection;
    }
项目:ECG-Viewer    文件:SWTMultipleAxisDemo1.java   
/**
 * Creates a sample dataset.
 *
 * @param name  the dataset name.
 * @param base  the starting value.
 * @param start  the starting period.
 * @param count  the number of values to generate.
 *
 * @return The dataset.
 */
private static XYDataset createDataset(String name, double base,
                                       RegularTimePeriod start, int count) {

    TimeSeries series = new TimeSeries(name);
    RegularTimePeriod period = start;
    double value = base;
    for (int i = 0; i < count; i++) {
        series.add(period, value);
        period = period.next();
        value = value * (1 + (Math.random() - 0.495) / 10.0);
    }

    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(series);

    return dataset;

}