Package org.jfree.data.xy

Examples of org.jfree.data.xy.XYSeries


public abstract class AbstractSeriesProvider implements SeriesProvider {

    protected Log logger = LogFactory.getLog(getClass());

    protected XYSeries toSeries(String legend, List stats) {
        XYSeries xySeries = new XYSeries(legend, true, false);
        synchronized (stats) {
            for (int i = 0; i < stats.size(); i++) {
                XYDataItem item = (XYDataItem) stats.get(i);
                xySeries.addOrUpdate(item.getX(), item.getY());
            }
        }
        return xySeries;
    }
View Full Code Here


    final XYSeriesCollection xySeriesDataset = (XYSeriesCollection) getDatasourceValue();
    final List seriesList = xySeriesDataset.getSeries();
    final HashMap seriesMap = new HashMap();
    for (int i = 0; i < seriesList.size(); i++)
    {
      final XYSeries series = (XYSeries) seriesList.get(i);
      seriesMap.put(series.getKey(), series);
    }

    final String[] seriesNames = getSeriesName();
    final int maxIndex = Math.min(seriesNames.length, Math.min (this.xValueColumns.size(), this.yValueColumns.size()));
    for (int i = 0; i < maxIndex; i++)
    {
      String seriesName = seriesNames[i];
      final String xColumn = (String) xValueColumns.get(i);
      final String yColumn = (String) yValueColumns.get(i);
      final Object xValueObject = getDataRow().get(xColumn);
      final Object yValueObject = getDataRow().get(yColumn);

      if (isSeriesColumn())
      {
        final Object tmp = getDataRow().get(seriesName);
        if (tmp != null)
        {
          seriesName = tmp.toString();
        }
      }

      if (xValueObject instanceof Number == false)
      {
        continue;
      }
      final Number xValue = (Number) xValueObject;
      final Number yValue = (yValueObject instanceof Number) ? (Number) yValueObject : null;

      XYSeries series = (XYSeries) seriesMap.get(seriesName);
      if (series == null)
      {
        series = new XYSeries(seriesName);
        xySeriesDataset.addSeries(series);
        seriesMap.put (seriesName, series);
      }
      series.add(xValue, yValue);
    }
  }
View Full Code Here

    if (seriesMap == null)
    {
      final HashMap seriesMap = new HashMap();
      for (int i = 0; i < seriesList.size(); i++)
      {
        final XYSeries series = (XYSeries) seriesList.get(i);
        seriesMap.put(series.getKey(), series);
      }
      this.seriesMap = seriesMap;
    }

    final int maxIndex = this.valueColumns.size();
    for (int i = 0; i < maxIndex; i++)
    {
      final Comparable seriesName = querySeriesValue(i);
      final Object valueObject = getDataRow().get((String) valueColumns.get(i));
      final Object timeValueObject = getDataRow().get((String) timeValueColumns.get(i));

      final Number value = (valueObject instanceof Number) ? (Number) valueObject : null;
      final Date timeValue = convertToDate(timeValueObject);
      if (timeValue == null)
      {
        continue;
      }
     
      TimeSeries series = (TimeSeries) seriesMap.get(seriesName);
      if (series == null)
      {
        series = new TimeSeries(seriesName, getTimePeriod());
        timeSeriesDataset.addSeries(series);
        seriesMap.put(seriesName, series);
      }

      final RegularTimePeriod regularTimePeriod =
          RegularTimePeriod.createInstance(getTimePeriod(), timeValue, TimeZone.getDefault());

      final TimeSeriesDataItem timeSeriesDataItem = new TimeSeriesDataItem(regularTimePeriod, value);
      series.add(timeSeriesDataItem);
    }
  }
View Full Code Here

    if (seriesMap == null)
    {
      final HashMap seriesMap = new HashMap();
      for (int i = 0; i < seriesList.size(); i++)
      {
        final XYSeries series = (XYSeries) seriesList.get(i);
        seriesMap.put(series.getKey(), series);
      }
      this.seriesMap = seriesMap;
    }

    final int maxIndex = Math.min (this.xValueColumns.size(), this.yValueColumns.size());
    for (int i = 0; i < maxIndex; i++)
    {
      final Comparable seriesName = querySeriesValue(i);
      final Object xValueObject = getDataRow().get((String) xValueColumns.get(i));
      final Object yValueObject = getDataRow().get((String) yValueColumns.get(i));

      if (xValueObject instanceof Number == false)
      {
        continue;
      }
      final Number xValue = (Number) xValueObject;
      final Number yValue = (yValueObject instanceof Number) ? (Number) yValueObject : null;
     
      XYSeries series = (XYSeries) seriesMap.get(seriesName);
      if (series == null)
      {
        series = new XYSeries(seriesName);
        xySeriesDataset.addSeries(series);
        seriesMap.put(seriesName, series);
      }

      series.add(xValue, yValue, false);
    }
  }
View Full Code Here

        }
        XYSeriesCollection xyDataset = new XYSeriesCollection();
        for (int i = 0; i < getSeriesName().length; i++)
        {
          String s = getSeriesName()[i];
          XYSeries series = new XYSeries(s, true, true);
          xyDataset.addSeries(series);
          this.series.put(s, series);

        }
        this.xyDataset = xyDataset;
        //results.add(categoryDataset);
      }
      else
      {
        if (FunctionUtilities.isLayoutLevel(event))
        {
          // Activate the current group, which was filled in the prepare run.
          //currentIndex += 1;
          //categoryDataset = results.get(currentIndex);
        }
      }
    }
    else
    {
      // reset ...
      if (FunctionUtilities.isDefinedPrepareRunLevel(this, event))
      {
        if (LOG.isDebugEnabled())
        {
          LOG.debug("XYDataSetCollectorFunction.groupStarted ");//NON-NLS
        }
        XYSeriesCollection xyDataset = new XYSeriesCollection();
        for (int i = 0; i < getSeriesName().length; i++)
        {
          String s = getSeriesName()[i];
          XYSeries series = new XYSeries(s, true, true);
          xyDataset.addSeries(series);
          this.series.put(s, series);
        }
        this.xyDataset = xyDataset;
        //results.add(categoryDataset);
View Full Code Here

        String sn = (String) seriesNames.get(i);
        final Object o = getDataRow().get(sn);
        if (o instanceof Number)
        {
          Number y = (Number) o;
          final XYSeries o1 = (XYSeries) series.get(sn);
          o1.add(x, y);
        }
      }
    }

  }
View Full Code Here

  {
    final ExtCategoryTableXYDataset tableXYDataset = new ExtCategoryTableXYDataset();
    final int count = xyDataset.getSeriesCount();
    for (int i = 0; i < count; i++)
    {
      final XYSeries timeSeries = xyDataset.getSeries(i);
      final Comparable key = timeSeries.getKey();
      final int itemCount = timeSeries.getItemCount();
      for (int ic = 0; ic < itemCount; ic++)
      {
        final XYDataItem seriesDataItem = timeSeries.getDataItem(ic);
        tableXYDataset.add(seriesDataItem.getX(), seriesDataItem.getY(), key, false);
      }
    }
    return tableXYDataset;
  }
View Full Code Here

      for(int i = 0; i < xySeries.length; i++)
      {
        JRFillXySeries crtXySeries = xySeries[i];

        Comparable seriesName = crtXySeries.getSeries();
        XYSeries xySrs = (XYSeries)seriesMap.get(seriesName);
        if (xySrs == null)
        {
          xySrs =  new XYSeries(seriesName);
          seriesNames.add(seriesName);
          seriesMap.put(seriesName, xySrs);
        }
       
        xySrs.addOrUpdate(
          crtXySeries.getXValue(),
          crtXySeries.getYValue()
          );
       
        if (crtXySeries.getLabelExpression() != null)
View Full Code Here

  {
    if (sampleXyDataset == null)
    {
      XYSeriesCollection dataset = new XYSeriesCollection();

      XYSeries series = new XYSeries("First");
      series.add(1.0, 500.2);
      series.add(5.0, 694.1);
      series.add(4.0, 100.0);
      series.add(12.5, 734.4);
      series.add(17.3, 453.2);
      series.add(21.2, 500.2);
      series.add(21.9, null);
      series.add(25.6, 734.4);
      series.add(30.0, 453.2);
      dataset.addSeries(series);

      series = new XYSeries("Second");
      series.add(2.0, 400.2);
      series.add(6.0, 594.1);
      series.add(5.0, 90.0);
      series.add(13.5, 634.4);
      series.add(18.3, 353.2);
      series.add(22.2, 400.2);
      series.add(22.9, null);
      series.add(26.6, 634.4);
      series.add(31.0, 353.2);
      dataset.addSeries(series);

      series = new XYSeries("Third");
      series.add(0.0, 600.2);
      series.add(4.0, 794.1);
      series.add(3.0, 200.0);
      series.add(11.5, 834.4);
      series.add(16.3, 553.2);
      series.add(20.2, 600.2);
      series.add(20.9, null);
      series.add(24.6, 834.4);
      series.add(29.0, 553.2);
      dataset.addSeries(series);
     
      sampleXyDataset = dataset;
    }
View Full Code Here

                dist.put(d, 1);
            }
        }

        //Distribution series
        XYSeries dSeries = ChartUtils.createXYSeries(dist, pName);

        XYSeriesCollection dataset = new XYSeriesCollection();
        dataset.addSeries(dSeries);

        JFreeChart chart = ChartFactory.createXYLineChart(
View Full Code Here

TOP

Related Classes of org.jfree.data.xy.XYSeries

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.