Package org.jfree.chart

Examples of org.jfree.chart.LegendItem


         int seriesCount = dataset.getSeriesCount();
         for (int i = 0; i < seriesCount; i++)
         {
            if (isSeriesVisibleInLegend(i))
            {
               LegendItem item = getLegendItem(index, i);
               if (item != null)
               {
                  result.add(item);
               }
            }
View Full Code Here


         urlText = getLegendItemURLGenerator().generateLabel(dataset,
                 series);
      }
      Shape shape = lookupLegendShape(series);
      Paint paint = lookupSeriesPaint(series);
      LegendItem item = new LegendItem(label, paint);
      item.setToolTipText(toolTipText);
      item.setURLText(urlText);
      item.setLabelFont(lookupLegendTextFont(series));
      Paint labelPaint = lookupLegendTextPaint(series);
      if (labelPaint != null)
      {
         item.setLabelPaint(labelPaint);
      }
      item.setSeriesKey(dataset.getSeriesKey(series));
      item.setSeriesIndex(series);
      item.setDataset(dataset);
      item.setDatasetIndex(datasetIndex);

      if (getTreatLegendShapeAsLine())
      {
         item.setLineVisible(true);
         item.setLine(shape);
         item.setLinePaint(paint);
         item.setShapeVisible(false);
      }
      else
      {
         Paint outlinePaint = lookupSeriesOutlinePaint(series);
         Stroke outlineStroke = lookupSeriesOutlineStroke(series);
         item.setOutlinePaint(outlinePaint);
         item.setOutlineStroke(outlineStroke);
      }
      return item;
   }
View Full Code Here

                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;
    }
View Full Code Here

                    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;
    }
View Full Code Here

     * @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;
    }
View Full Code Here

        Shape shape = lookupLegendShape(series);
        Paint paint = lookupSeriesPaint(series);
        Paint outlinePaint = lookupSeriesOutlinePaint(series);
        Stroke outlineStroke = lookupSeriesOutlineStroke(series);

        LegendItem item = new LegendItem(label, description, toolTipText,
                urlText, shape, paint, outlineStroke, outlinePaint);
        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;
    }
View Full Code Here

        }
        int seriesCount = dataset.getRowCount();
        if (plot.getRowRenderingOrder().equals(SortOrder.ASCENDING)) {
            for (int i = 0; i < seriesCount; i++) {
                if (isSeriesVisibleInLegend(i)) {
                    LegendItem item = getLegendItem(index, i);
                    if (item != null) {
                        result.add(item);
                    }
                }
            }
        }
        else {
            for (int i = seriesCount - 1; i >= 0; i--) {
                if (isSeriesVisibleInLegend(i)) {
                    LegendItem item = getLegendItem(index, i);
                    if (item != null) {
                        result.add(item);
                    }
                }
            }
View Full Code Here

     * @param series  the series index.
     *
     * @return The legend item.
     */
    public LegendItem getLegendItem(int series) {
        LegendItem result = null;
        PolarPlot plot = getPlot();
        if (plot == null) {
            return null;
        }
        XYDataset dataset = plot.getDataset(plot.getIndexOf(this));
        if (dataset == null) {
            return null;
        }
       
        String toolTipText = null;
        if (getLegendItemToolTipGenerator() != null) {
            toolTipText = getLegendItemToolTipGenerator().generateLabel(
                    dataset, series);
        }
        String urlText = null;
        if (getLegendItemURLGenerator() != null) {
            urlText = getLegendItemURLGenerator().generateLabel(dataset,
                    series);
        }

        String label = dataset.getSeriesKey(series).toString();
        String description = label;
        Shape shape = lookupSeriesShape(series);
        Paint paint;
        if (this.useFillPaint) {
            paint = lookupSeriesFillPaint(series);
        }
        else {
            paint = lookupSeriesPaint(series);
        }
        Stroke stroke = lookupSeriesStroke(series);
        Paint outlinePaint = lookupSeriesOutlinePaint(series);
        Stroke outlineStroke = lookupSeriesOutlineStroke(series);
        boolean shapeOutlined = isSeriesFilled(series)
                && this.drawOutlineWhenFilled;
        result = new LegendItem(label, description, toolTipText, urlText,
                getShapesVisible(), shape, /* shapeFilled=*/ true, paint,
                shapeOutlined, outlinePaint, outlineStroke,
                /* lineVisible= */ true, this.legendLine, stroke, paint);
        result.setToolTipText(toolTipText);
        result.setURLText(urlText);
        result.setDataset(dataset);

        return result;
    }
View Full Code Here

               Paint paint = lookupSeriesPaint(
                       ((Integer) entry.getValue()).intValue());
               Paint outlinePaint = Color.black;
               Stroke outlineStroke = DEFAULT_STROKE;

               result.add(new LegendItem(label, description, null,
                       null, shape, paint, outlineStroke, outlinePaint));

            }
         }
         else
         {
            // in this case, every color has a range of values
            Set unique = new HashSet();
           
            for (Iterator i = this.paintIndex.entrySet().iterator();
                    i.hasNext();)
            {
               Map.Entry entry = (Map.Entry) i.next();
               if (unique.add(entry.getValue()))
               {
                  String label = getMinPaintValue(
                          (Integer) entry.getValue()).toString()
                          + " - " + getMaxPaintValue(
                          (Integer) entry.getValue()).toString();
                  String description = label;
                  Shape shape = new Rectangle2D.Double(1d, 1d, 1d, 1d);
                 
                  Paint paint = getSeriesPaint(
                          ((Integer) entry.getValue()).intValue());
                 
                  Paint outlinePaint = Color.black;
                  Stroke outlineStroke = DEFAULT_STROKE;

                  result.add(new LegendItem(label, description,
                          null, null, shape, paint, outlineStroke,
                          outlinePaint));
               }
            } // end foreach map entry
         } // end else
View Full Code Here

  @Override
  public LegendItem getLegendItem(int dataSetIndex, int seriesNum) {
    // Only show a legend item for a series for one dataset.
    // In the case of the light curve plot, there is only one,
    // whereas in the case of the phase plot there are two.
    LegendItem item = null;

    if (dataSetIndex == 0) {
      item = super.getLegendItem(dataSetIndex, seriesNum);
    }
   
View Full Code Here

TOP

Related Classes of org.jfree.chart.LegendItem

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.