Package com.positive.charts.data.xy

Examples of com.positive.charts.data.xy.XYDataset


    // iterate through the datasets that map to the axis and get the union
    // of the ranges.
    final Iterator iterator = mappedDatasets.iterator();
    while (iterator.hasNext()) {
      final XYDataset d = (XYDataset) iterator.next();
      if (d != null) {
        final XYItemRenderer r = this.getRendererForDataset(d);
        if (isDomainAxis) {
          if (r != null) {
            result = Range.combine(result, r.findDomainBounds(d));
View Full Code Here


   *            the dataset index.
   *
   * @return The dataset (possibly <code>null</code>).
   */
  public XYDataset getDataset(final int index) {
    XYDataset result = null;
    if (this.datasets.size() > index) {
      result = (XYDataset) this.datasets.get(index);
    }
    return result;
  }
View Full Code Here

      return this.fixedLegendItems;
    }
    final LegendItemCollection result = new LegendItemCollection();
    final int count = this.datasets.size();
    for (int datasetIndex = 0; datasetIndex < count; datasetIndex++) {
      final XYDataset dataset = this.getDataset(datasetIndex);
      if (dataset != null) {
        XYItemRenderer renderer = this.getRenderer(datasetIndex);
        if (renderer == null) {
          renderer = this.getRenderer(0);
        }
        if (renderer != null) {
          final int seriesCount = dataset.getSeriesCount();
          for (int i = 0; i < seriesCount; i++) {
            if (renderer.isSeriesVisible(i)
                && renderer.isSeriesVisibleInLegend(i)) {
              final LegendItem item = renderer.getLegendItem(
                  datasetIndex, i);
View Full Code Here

   *
   * @return The series count.
   */
  public int getSeriesCount() {
    int result = 0;
    final XYDataset dataset = this.getDataset();
    if (dataset != null) {
      result = dataset.getSeriesCount();
    }
    return result;
  }
View Full Code Here

   */
  public boolean render(final GC gc, final Rectangle dataArea,
      final int index, final PlotRenderingInfo info,
      final CrosshairState cstate) {

    final XYDataset dataset = this.getDataset(index);
    if (DatasetUtilities.isEmptyOrNull(dataset)) {
      return false;
    }

    final ValueAxis xAxis = this.getDomainAxisForDataset(index);
    final ValueAxis yAxis = this.getRangeAxisForDataset(index);
    XYItemRenderer renderer = this.getRenderer(index);
    if (renderer == null) {
      renderer = this.getRenderer();
    }

    // assert renderer != null : "Renderer is null";

    final XYItemRendererState state = renderer.initialise(gc, dataArea,
        this, dataset, info);
    final int passCount = renderer.getPassCount();

    final SeriesRenderingOrder seriesOrder = this.getSeriesRenderingOrder();
    if (seriesOrder == SeriesRenderingOrder.REVERSE) {
      // render series in reverse order
      for (int pass = 0; pass < passCount; pass++) {
        final int seriesCount = dataset.getSeriesCount();
        for (int series = seriesCount - 1; series >= 0; series--) {
          final int itemCount = dataset.getItemCount(series);
          for (int item = 0; item < itemCount; item++) {
            renderer.drawItem(gc, state, dataArea, info, this,
                xAxis, yAxis, dataset, series, item, cstate,
                pass);
          }
        }
      }
    } else {
      // render series in forward order
      for (int pass = 0; pass < passCount; pass++) {
        final int seriesCount = dataset.getSeriesCount();
        for (int series = 0; series < seriesCount; series++) {
          final int itemCount = dataset.getItemCount(series);
          for (int item = 0; item < itemCount; item++) {
            renderer.drawItem(gc, state, dataArea, info, this,
                xAxis, yAxis, dataset, series, item, cstate,
                pass);
          }
View Full Code Here

   *            the dataset index.
   * @param dataset
   *            the dataset (<code>null</code> permitted).
   */
  public void setDataset(final int index, final XYDataset dataset) {
    final XYDataset existing = this.getDataset(index);
    if (existing != null) {
      existing.removeChangeListener(this);
    }
    if (index == this.datasets.size()) {
      this.datasets.add(index, dataset);
    } else {
      this.datasets.set(index, dataset);
View Full Code Here

   */
  public LegendItem getLegendItem(final int datasetIndex, final int series) {
    LegendItem result = null;
    final XYPlot xyplot = this.getPlot();
    if (xyplot != null) {
      final XYDataset dataset = xyplot.getDataset(datasetIndex);
      if (dataset != null) {

        final String label = this.legendItemLabelGenerator
            .generateLabel(dataset, series);
        final String description = label;
        String toolTipText = null;
        if (this.getLegendItemToolTipGenerator() != null) {
          toolTipText = this.getLegendItemToolTipGenerator()
              .generateLabel(dataset, series);
        }
        String urlText = null;
        if (this.getLegendItemURLGenerator() != null) {
          urlText = this.getLegendItemURLGenerator().generateLabel(
              dataset, series);
        }
        final Rectangle shape = this.lookupSeriesShape(series);
        final Color paint = this.getSeriesPaint(series);
        final Color outlinePaint = this
            .lookupSeriesOutlinePaint(series);
        final Stroke outlineStroke = this
            .lookupSeriesOutlineStroke(series);
        result = new LegendItem(label, description, toolTipText,
            urlText, shape, paint, outlineStroke, outlinePaint);
        result.setSeriesKey(dataset.getSeriesKey(series));
        result.setSeriesKey(dataset.getSeriesKey(series));
        result.setSeriesIndex(series);
        result.setDataset(dataset);
        result.setDatasetIndex(datasetIndex);
      }
    }
View Full Code Here

    if (this.plot == null) {
      return new LegendItemCollection();
    }
    final LegendItemCollection result = new LegendItemCollection();
    final int index = this.plot.getIndexOf(this);
    final XYDataset dataset = this.plot.getDataset(index);
    if (dataset != null) {
      final int seriesCount = dataset.getSeriesCount();
      for (int i = 0; i < seriesCount; i++) {
        if (this.isSeriesVisibleInLegend(i)) {
          final LegendItem item = this.getLegendItem(index, i);
          if (item != null) {
            result.add(item);
View Full Code Here

  }

  public boolean render(final GC gc, final Rectangle dataArea,
      final int index, final PlotRenderingInfo info) {

    final XYDataset dataset = this.getDataset(index);
    if (DatasetUtilities.isEmptyOrNull(dataset)) {
      return false;
    }

    XYItemRenderer renderer = this.getRenderer(index);
    if (renderer == null) {
      renderer = this.getRenderer();
    }

    final ValueAxis domainAxis = this.getDomainAxisForDataset(index);
    final ValueAxis rangeAxis = this.getRangeAxisForDataset(index);
    final double lowerBound = domainAxis.getLowerBound();
    final double upperBound = domainAxis.getUpperBound();

    List series;
    if (dataset instanceof TableXYDataset) {
      series = ((TableXYDataset) dataset).getSeries();
    } else if (dataset instanceof XYSeriesCollection) {
      series = ((XYSeriesCollection) dataset).getSeries();
    } else {
      return false;
    }

    for (final Iterator iter = series.iterator(); iter.hasNext();) {
      final XYSeries s = (XYSeries) iter.next();
      final List items = s.getItems();
      if (items.size() == 0) {
        continue;
      }

      int fromIndex = Collections.binarySearch(items, new XYDataItem(
          lowerBound, 0));
      if (fromIndex < 0) {
        fromIndex = -fromIndex - 2;
      }
      if (fromIndex < 0) {
        fromIndex = 0;
      }
      int toIndex = Collections.binarySearch(items, new XYDataItem(
          upperBound, 0));
      if (toIndex < 0) {
        toIndex = -toIndex;
      }
      if (toIndex >= items.size()) {
        toIndex = items.size() - 1;
      }
      final List subSeries = items.subList(fromIndex, toIndex);

      renderer.drawSeriesItems(gc, dataArea, info, this, domainAxis,
          rangeAxis, dataset, dataset.indexOf(s.getKey()), subSeries);
    }

    return true;
  }
View Full Code Here

TOP

Related Classes of com.positive.charts.data.xy.XYDataset

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.