/**
   * Returns a legend item for the specified series. The default method is overridden so that the
   * legend displays circles for all series.
   *
   * @param datasetIndex the dataset index (zero-based).
   * @param series the series index (zero-based).
   * @return A legend item for the series.
   */
  public LegendItem getLegendItem(int datasetIndex, int series) {
    LegendItem result = null;
    XYPlot plot = getPlot();
    if (plot == null) {
      return null;
    }

    XYDataset dataset = plot.getDataset(datasetIndex);
    if (dataset != null) {
      if (getItemVisible(series, 0)) {
        String label = getLegendItemLabelGenerator().generateLabel(dataset, series);
        String description = label;
        String toolTipText = null;
        if (getLegendItemToolTipGenerator() != null) {
          toolTipText = getLegendItemToolTipGenerator().generateLabel(dataset, series);
        }
        String urlText = null;
        if (getLegendItemURLGenerator() != null) {
          urlText = getLegendItemURLGenerator().generateLabel(dataset, series);
        }
        Shape shape = lookupLegendShape(series);
        Paint paint = lookupSeriesPaint(series);
        Paint outlinePaint = lookupSeriesOutlinePaint(series);
        Stroke outlineStroke = lookupSeriesOutlineStroke(series);
        result =
            new LegendItem(
                label,
                description,
                toolTipText,
                urlText,
                shape,
                paint,
                outlineStroke,
                outlinePaint);
        result.setLabelFont(lookupLegendTextFont(series));
        Paint labelPaint = lookupLegendTextPaint(series);
        if (labelPaint != null) {
          result.setLabelPaint(labelPaint);
        }
        result.setDataset(dataset);
        result.setDatasetIndex(datasetIndex);
        result.setSeriesKey(dataset.getSeriesKey(series));
        result.setSeriesIndex(series);
      }
    }
    return result;
  }
예제 #2
0
 /**
  * Returns a default legend item for the specified series. Subclasses should override this method
  * to generate customised items.
  *
  * @param datasetIndex the dataset index (zero-based).
  * @param series the series index (zero-based).
  * @return A legend item for the series.
  */
 @Override
 public LegendItem getLegendItem(int datasetIndex, int series) {
   XYPlot xyplot = getPlot();
   if (xyplot == null) {
     return null;
   }
   XYDataset dataset = xyplot.getDataset(datasetIndex);
   if (dataset == null) {
     return null;
   }
   LegendItem result;
   XYSeriesLabelGenerator lg = getLegendItemLabelGenerator();
   String label = lg.generateLabel(dataset, series);
   String description = label;
   String toolTipText = null;
   if (getLegendItemToolTipGenerator() != null) {
     toolTipText = getLegendItemToolTipGenerator().generateLabel(dataset, series);
   }
   String urlText = null;
   if (getLegendItemURLGenerator() != null) {
     urlText = getLegendItemURLGenerator().generateLabel(dataset, series);
   }
   Shape shape = this.legendBar;
   Paint paint = lookupSeriesPaint(series);
   Paint outlinePaint = lookupSeriesOutlinePaint(series);
   Stroke outlineStroke = lookupSeriesOutlineStroke(series);
   if (this.drawBarOutline) {
     result =
         new LegendItem(
             label, description, toolTipText, urlText, shape, paint, outlineStroke, outlinePaint);
   } else {
     result = new LegendItem(label, description, toolTipText, urlText, shape, paint);
   }
   result.setLabelFont(lookupLegendTextFont(series));
   Paint labelPaint = lookupLegendTextPaint(series);
   if (labelPaint != null) {
     result.setLabelPaint(labelPaint);
   }
   result.setDataset(dataset);
   result.setDatasetIndex(datasetIndex);
   result.setSeriesKey(dataset.getSeriesKey(series));
   result.setSeriesIndex(series);
   if (getGradientPaintTransformer() != null) {
     result.setFillPaintTransformer(getGradientPaintTransformer());
   }
   return result;
 }
예제 #3
0
  /**
   * Returns a legend item for a series.
   *
   * @param datasetIndex the dataset index (zero-based).
   * @param series the series index (zero-based).
   * @return The legend item.
   */
  @Override
  public LegendItem getLegendItem(int datasetIndex, int series) {

    // if there is no plot, there is no dataset to access...
    CategoryPlot cp = getPlot();
    if (cp == null) {
      return null;
    }

    // check that a legend item needs to be displayed...
    if (!isSeriesVisible(series) || !isSeriesVisibleInLegend(series)) {
      return null;
    }

    CategoryDataset dataset = cp.getDataset(datasetIndex);
    String label = getLegendItemLabelGenerator().generateLabel(dataset, series);
    String description = label;
    String toolTipText = null;
    if (getLegendItemToolTipGenerator() != null) {
      toolTipText = getLegendItemToolTipGenerator().generateLabel(dataset, series);
    }
    String urlText = null;
    if (getLegendItemURLGenerator() != null) {
      urlText = getLegendItemURLGenerator().generateLabel(dataset, series);
    }
    Shape shape = lookupLegendShape(series);
    Paint paint = lookupSeriesPaint(series);
    Paint outlinePaint = lookupSeriesOutlinePaint(series);
    Stroke outlineStroke = lookupSeriesOutlineStroke(series);

    LegendItem result =
        new LegendItem(
            label, description, toolTipText, urlText, shape, paint, outlineStroke, outlinePaint);
    result.setLabelFont(lookupLegendTextFont(series));
    Paint labelPaint = lookupLegendTextPaint(series);
    if (labelPaint != null) {
      result.setLabelPaint(labelPaint);
    }
    result.setDataset(dataset);
    result.setDatasetIndex(datasetIndex);
    result.setSeriesKey(dataset.getRowKey(series));
    result.setSeriesIndex(series);
    return result;
  }
  /**
   * Returns a legend item for a series.
   *
   * @param datasetIndex the dataset index (zero-based).
   * @param series the series index (zero-based).
   * @return The legend item.
   */
  public LegendItem getLegendItem(int datasetIndex, int series) {

    CategoryPlot p = getPlot();
    if (p == null) {
      return null;
    }

    // check that a legend item needs to be displayed...
    if (!isSeriesVisible(series) || !isSeriesVisibleInLegend(series)) {
      return null;
    }

    CategoryDataset dataset = p.getDataset(datasetIndex);
    String label = getLegendItemLabelGenerator().generateLabel(dataset, series);
    String description = label;
    String toolTipText = null;
    if (getLegendItemToolTipGenerator() != null) {
      toolTipText = getLegendItemToolTipGenerator().generateLabel(dataset, series);
    }
    String urlText = null;
    if (getLegendItemURLGenerator() != null) {
      urlText = getLegendItemURLGenerator().generateLabel(dataset, series);
    }
    Shape shape = lookupLegendShape(series);
    Paint paint = lookupSeriesPaint(series);

    LegendItem item = new LegendItem(label, description, toolTipText, urlText, shape, paint);
    item.setLabelFont(lookupLegendTextFont(series));
    Paint labelPaint = lookupLegendTextPaint(series);
    if (labelPaint != null) {
      item.setLabelPaint(labelPaint);
    }
    item.setSeriesKey(dataset.getRowKey(series));
    item.setSeriesIndex(series);
    item.setDataset(dataset);
    item.setDatasetIndex(datasetIndex);
    return item;
  }
예제 #5
0
  /**
   * Returns a legend item for the specified series.
   *
   * @param datasetIndex the dataset index (zero-based).
   * @param series the series index (zero-based).
   * @return A legend item for the series (possibly <code>null</code>).
   */
  public LegendItem getLegendItem(int datasetIndex, int series) {

    // if the renderer isn't assigned to a plot, then we don't have a
    // dataset...
    XYPlot plot = getPlot();
    if (plot == null) {
      return null;
    }

    XYDataset dataset = plot.getDataset(datasetIndex);
    if (dataset == null) {
      return null;
    }

    LegendItem result = null;
    if (getItemVisible(series, 0)) {
      String label = getLegendItemLabelGenerator().generateLabel(dataset, series);
      String description = label;
      String toolTipText = null;
      if (getLegendItemToolTipGenerator() != null) {
        toolTipText = getLegendItemToolTipGenerator().generateLabel(dataset, series);
      }
      String urlText = null;
      if (getLegendItemURLGenerator() != null) {
        urlText = getLegendItemURLGenerator().generateLabel(dataset, series);
      }
      Paint fillPaint = lookupSeriesPaint(series);
      result =
          new LegendItem(label, description, toolTipText, urlText, getLegendShape(), fillPaint);
      result.setSeriesKey(dataset.getSeriesKey(series));
      result.setSeriesIndex(series);
      result.setDataset(dataset);
      result.setDatasetIndex(datasetIndex);
    }

    return result;
  }
예제 #6
0
  /**
   * Returns a legend item for the specified series.
   *
   * @param datasetIndex the dataset index (zero-based).
   * @param series the series index (zero-based).
   * @return A legend item for the series (possibly {@code null}).
   */
  @Override
  public LegendItem getLegendItem(int datasetIndex, int series) {
    XYPlot plot = getPlot();
    if (plot == null) {
      return null;
    }

    XYDataset dataset = plot.getDataset(datasetIndex);
    if (dataset == null) {
      return null;
    }

    if (!getItemVisible(series, 0)) {
      return null;
    }
    String label = getLegendItemLabelGenerator().generateLabel(dataset, series);
    String description = label;
    String toolTipText = null;
    if (getLegendItemToolTipGenerator() != null) {
      toolTipText = getLegendItemToolTipGenerator().generateLabel(dataset, series);
    }
    String urlText = null;
    if (getLegendItemURLGenerator() != null) {
      urlText = getLegendItemURLGenerator().generateLabel(dataset, series);
    }
    boolean shapeIsVisible = getItemShapeVisible(series, 0);
    Shape shape = lookupLegendShape(series);
    boolean shapeIsFilled = getItemShapeFilled(series, 0);
    Paint fillPaint =
        (this.useFillPaint ? lookupSeriesFillPaint(series) : lookupSeriesPaint(series));
    boolean shapeOutlineVisible = this.drawOutlines;
    Paint outlinePaint =
        (this.useOutlinePaint ? lookupSeriesOutlinePaint(series) : lookupSeriesPaint(series));
    Stroke outlineStroke = lookupSeriesOutlineStroke(series);
    boolean lineVisible = getItemLineVisible(series, 0);
    Stroke lineStroke = lookupSeriesStroke(series);
    Paint linePaint = lookupSeriesPaint(series);
    LegendItem result =
        new LegendItem(
            label,
            description,
            toolTipText,
            urlText,
            shapeIsVisible,
            shape,
            shapeIsFilled,
            fillPaint,
            shapeOutlineVisible,
            outlinePaint,
            outlineStroke,
            lineVisible,
            this.legendLine,
            lineStroke,
            linePaint);
    result.setLabelFont(lookupLegendTextFont(series));
    Paint labelPaint = lookupLegendTextPaint(series);
    if (labelPaint != null) {
      result.setLabelPaint(labelPaint);
    }
    result.setSeriesKey(dataset.getSeriesKey(series));
    result.setSeriesIndex(series);
    result.setDataset(dataset);
    result.setDatasetIndex(datasetIndex);

    return result;
  }