/**
  * Gets the buffer/cache for values. Values set in the buffer will be applied to the target
  * dataset when the transition takes place.
  *
  * @return
  */
 public XYMultipleSeriesDataset getBuffer() {
   if (datasetCache == null) {
     datasetCache = new XYMultipleSeriesDataset();
     for (int i = 0; i < dataset.getSeriesCount(); i++) {
       datasetCache.addSeries(new XYSeries(dataset.getSeriesAt(i).getTitle()));
     }
     seriesTransitions = new XYSeriesTransition[dataset.getSeries().length];
     for (int i = 0; i < seriesTransitions.length; i++) {
       seriesTransitions[i] = new XYSeriesTransition(getChart(), dataset.getSeriesAt(i));
       seriesTransitions[i].setBuffer(datasetCache.getSeriesAt(i));
     }
   }
   return datasetCache;
 }
Ejemplo n.º 2
0
  public void setRegion(String region) {
    this.currentRegion = region;
    renderer.setChartTitle(region);
    renderer.getSeriesRendererAt(0).setColor(colors[viewMode]);
    ((XYSeriesRenderer) renderer.getSeriesRendererAt(0))
        .setFillBelowLineColor(0x33000000 | colors[viewMode]);
    if (getComponentForm() != null) {

      XYMultiSeriesTransition t = new XYMultiSeriesTransition(chart, dataSet);
      RegionData[] rdArr = data.getRegionData(region);
      for (RegionData rd : rdArr) {
        switch (viewMode) {
          case VIEW_MODE_POPULATION:
            dataSet.getSeriesAt(0).setTitle("Population");
            t.getBuffer().getSeriesAt(POPULATION).add(rd.year, rd.pop);
            break;
          case VIEW_MODE_DENSITY:
            dataSet.getSeriesAt(0).setTitle("Density (People per square mile)");
            t.getBuffer().getSeriesAt(POPULATION).add(rd.year, rd.density);
            break;
          default:
            throw new RuntimeException("Illegal view mode.");
        }

        // t.getBuffer().getSeriesAt(DENSITY).add(rd.year, rd.density);
        // t.getBuffer().getSeriesAt(RANK).add(rd.year, rd.rank);
      }
      t.animateChart();
    } else {
      RegionData[] rdArr = data.getRegionData(region);
      renderer.getSeriesRendererAt(0).setColor(colors[viewMode]);
      for (RegionData rd : rdArr) {

        switch (viewMode) {
          case VIEW_MODE_POPULATION:
            dataSet.getSeriesAt(POPULATION).add(rd.year, rd.pop);
            dataSet.getSeriesAt(0).setTitle("Population");

            break;
          case VIEW_MODE_DENSITY:
            dataSet.getSeriesAt(0).setTitle("Density (People per square mile)");
            dataSet.getSeriesAt(POPULATION).add(rd.year, rd.density);
            break;
          default:
            throw new RuntimeException("Illegal view mode");
        }
      }
      Log.p("Finished adding pop data");
    }
  }