Example usage for org.jfree.chart LegendItemCollection add

List of usage examples for org.jfree.chart LegendItemCollection add

Introduction

In this page you can find the example usage for org.jfree.chart LegendItemCollection add.

Prototype

public void add(LegendItem item) 

Source Link

Document

Adds a legend item to the collection.

Usage

From source file:org.tsho.dmc2.core.chart.DmcLyapunovPlot.java

public LegendItemCollection getLegendItems() {
    if (type != AREA)
        return null;

    Stroke stroke = new BasicStroke(1.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL);
    Shape shape = new Rectangle2D.Double(-3, -3, 6, 6);

    LegendItemCollection legendItems = new LegendItemCollection();
    legendItems.add(new LegendItem("both zero", "", shape, true, Color.black, stroke, Color.yellow, stroke));

    legendItems.add(new LegendItem("zero, positive", "", shape, true, Color.red, stroke, Color.yellow, stroke));

    legendItems//from w w w .j  a  v  a 2s.  co  m
            .add(new LegendItem("zero, negative", "", shape, true, Color.blue, stroke, Color.yellow, stroke));

    legendItems.add(
            new LegendItem("positive, negative", "", shape, true, Color.green, stroke, Color.yellow, stroke));

    legendItems
            .add(new LegendItem("both positive", "", shape, true, Color.orange, stroke, Color.yellow, stroke));

    legendItems.add(new LegendItem("both negative", "", shape, true, Color.pink, stroke, Color.yellow, stroke));

    return legendItems;
}

From source file:org.jax.haplotype.analysis.visualization.GenomicGraphFactory.java

/**
 * Create a SNP block graph for the given parameters. This graph
 * will show where the intervals do and don't exist. Interval lists
 * are organized with the X axis label matching the list's key
 * @param snpIntervals/*from   w  w w.  j av  a2s.  com*/
 *          the blocks
 * @param startInBasePairs
 *          the x location to start the graph at
 * @param extentInBasePairs
 *          the extent to use for the graph
 * @param maximumImageBlockCount
 *          the max # of separate image blocks to use
 * @param renderAxes
 *          if true render the axes... otherwise dont
 * @param legendText
 *          the text to use for the legend
 * @param yAxisText
 *          the text to use for the y axis
 * @param trueColor
 *          the color to use for true
 * @param falseColor
 *          the color to use for false 
 * @return
 *          the graph
 */
public JFreeChart createSnpIntervalGraph(
        final Map<String, ? extends List<? extends BasePairInterval>> snpIntervals, final long startInBasePairs,
        final long extentInBasePairs, final int maximumImageBlockCount, final boolean renderAxes,
        final String legendText, final String yAxisText, final Color trueColor, final Color falseColor) {
    XYDataset dataset = snpIntervalsToDataset(snpIntervals, startInBasePairs, extentInBasePairs,
            maximumImageBlockCount);

    NumberAxis xAxis = new NumberAxis("SNP Position (Base Pairs)");
    xAxis.setAutoRangeIncludesZero(false);
    xAxis.setRange(new Range(startInBasePairs, startInBasePairs + extentInBasePairs));
    String[] sortedStrainNames = extractSortedStrainNames(snpIntervals);
    for (int strainIndex = 0; strainIndex < sortedStrainNames.length; strainIndex++) {
        LOG.info("Strain Name: " + sortedStrainNames[strainIndex]);
    }
    SymbolAxis yAxis = new SymbolAxis(yAxisText == null ? "" : yAxisText, sortedStrainNames);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
    LegendItemCollection items = new LegendItemCollection();
    if (legendText != null) {
        items.add(new LegendItem(legendText, null, null, null, new Rectangle2D.Double(-3.0, -3.0, 6.0, 6.0),
                trueColor, new BasicStroke(), Color.BLACK));
    }
    plot.setFixedLegendItems(items);

    XYBlockRenderer r = new XYBlockRenderer();
    SmoothPaintScale ps = new SmoothPaintScale(0.0, 1.0, falseColor, trueColor);

    r.setPaintScale(ps);
    r.setBlockHeight(1.0);
    r.setBlockWidth(1.0);
    plot.setRenderer(r);

    final JFreeChart chart;
    if (renderAxes) {
        chart = new JFreeChart("Identical By State Blocks", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    } else {
        xAxis.setVisible(false);
        yAxis.setVisible(false);
        plot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
        chart = new JFreeChart(plot);
    }

    chart.setBackgroundPaint(Color.WHITE);

    return chart;
}

From source file:scheduler.benchmarker.manager.CreateCombinedCategoryPlot.java

private LegendItemCollection createCustomLegend() {
    LegendItemCollection legend = new LegendItemCollection();
    Shape shape = new Rectangle(10, 10);
    Stroke stroke = new BasicStroke(1F);
    HashMap<String, Color> pColors = pluginColors.getPlugins();
    Iterator it = pColors.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry pairs = (Map.Entry) it.next();
        legend.add(new LegendItem(String.valueOf(pairs.getKey()), null, null, null, shape,
                (Color) pairs.getValue(), stroke, Color.BLACK));
    }/*w w  w .jav a2  s . co m*/
    return legend;
}

From source file:org.jfree.chart.demo.DualAxisDemo5.java

/**
 * Creates a chart.//from ww  w.  ja v  a  2s .c o m
 * 
 * @param dataset1  the first dataset.
 * @param dataset2  the second dataset.
 * 
 * @return A chart.
 */
private JFreeChart createChart(final CategoryDataset dataset1, final CategoryDataset dataset2) {

    final CategoryAxis domainAxis = new CategoryAxis("Category");
    final NumberAxis rangeAxis = new NumberAxis("Value");
    final BarRenderer renderer1 = new BarRenderer();
    final CategoryPlot plot = new CategoryPlot(dataset1, domainAxis, rangeAxis, renderer1) {

        /**
         * Override the getLegendItems() method to handle special case.
         *
         * @return the legend items.
         */
        public LegendItemCollection getLegendItems() {

            final LegendItemCollection result = new LegendItemCollection();

            final CategoryDataset data = getDataset();
            if (data != null) {
                final CategoryItemRenderer r = getRenderer();
                if (r != null) {
                    final LegendItem item = r.getLegendItem(0, 0);
                    result.add(item);
                }
            }

            // the JDK 1.2.2 compiler complained about the name of this
            // variable 
            final CategoryDataset dset2 = getDataset(1);
            if (dset2 != null) {
                final CategoryItemRenderer renderer2 = getRenderer(1);
                if (renderer2 != null) {
                    final LegendItem item = renderer2.getLegendItem(1, 1);
                    result.add(item);
                }
            }

            return result;

        }

    };

    final JFreeChart chart = new JFreeChart("Dual Axis Bar Chart", plot);
    chart.setBackgroundPaint(Color.white);
    //        chart.getLegend().setAnchor(Legend.SOUTH);
    plot.setBackgroundPaint(new Color(0xEE, 0xEE, 0xFF));
    plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
    plot.setDataset(1, dataset2);
    plot.mapDatasetToRangeAxis(1, 1);
    final ValueAxis axis2 = new NumberAxis("Secondary");
    plot.setRangeAxis(1, axis2);
    plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT);
    final BarRenderer renderer2 = new BarRenderer();
    plot.setRenderer(1, renderer2);

    return chart;
}

From source file:org.altaprise.vawr.charts.demos.StackedBarChartDemo4.java

/**
 * Creates the legend items for the chart.  In this case, we set them manually because we
 * only want legend items for a subset of the data series.
 * /*from   w w  w.  ja  v  a 2  s  .c  o  m*/
 * @return The legend items.
 */
private LegendItemCollection createLegendItems() {
    LegendItemCollection result = new LegendItemCollection();
    LegendItem item1 = new LegendItem("US", new Color(0x22, 0x22, 0xFF));
    LegendItem item2 = new LegendItem("Europe", new Color(0x22, 0xFF, 0x22));
    LegendItem item3 = new LegendItem("Asia", new Color(0xFF, 0x22, 0x22));
    LegendItem item4 = new LegendItem("Middle East", new Color(0xFF, 0xFF, 0x22));
    result.add(item1);
    result.add(item2);
    result.add(item3);
    result.add(item4);
    return result;
}

From source file:com.rapidminer.gui.plotter.charts.ParallelPlotter2.java

@Override
public void updatePlotter() {
    prepareData();//from w  ww.  j  a va2s.  c  om

    JFreeChart chart = createChart(this.dataset);

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // general plot settings
    XYPlot plot = chart.getXYPlot();
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);

    // domain axis
    SymbolAxis axis = null;
    if (this.dataTable.isSupportingColumnWeights()) {
        List<Double> weightList = new LinkedList<>();
        for (int column = 0; column < dataTable.getNumberOfColumns(); column++) {
            if ((!dataTable.isSpecial(column)) && (column != colorColumn)) {
                weightList.add(this.dataTable.getColumnWeight(column));
            }
        }
        double[] weights = new double[weightList.size()];
        int index = 0;
        for (Double d : weightList) {
            weights[index++] = d;
        }
        axis = new WeightBasedSymbolAxis(null, domainAxisMap, weights);
    } else {
        axis = new SymbolAxis(null, domainAxisMap);
    }
    axis.setTickLabelFont(LABEL_FONT);
    axis.setLabelFont(LABEL_FONT_BOLD);

    // rotate labels
    if (isLabelRotating()) {
        axis.setTickLabelsVisible(true);
        axis.setVerticalTickLabels(true);
    }

    chart.getXYPlot().setDomainAxis(axis);

    // renderer
    final ColorizedLineAndShapeRenderer renderer = new ColorizedLineAndShapeRenderer(this.colorMap);
    plot.setRenderer(renderer);

    // legend settings
    if ((colorColumn >= 0) && (this.dataTable.isNominal(colorColumn))) {
        final LegendItemCollection legendItemCollection = new LegendItemCollection();
        for (int i = 0; i < this.dataTable.getNumberOfValues(colorColumn); i++) {
            legendItemCollection.add(new LegendItem(this.dataTable.mapIndex(colorColumn, i), null, null, null,
                    new Rectangle2D.Double(0, 0, 7, 7),
                    getColorProvider()
                            .getPointColor(i / (double) (this.dataTable.getNumberOfValues(colorColumn) - 1)),
                    new BasicStroke(0.75f), Color.GRAY));
        }
        chart.addLegend(new LegendTitle(new LegendItemSource() {

            @Override
            public LegendItemCollection getLegendItems() {
                return legendItemCollection;
            }
        }));

        LegendTitle legend = chart.getLegend();
        if (legend != null) {
            legend.setPosition(RectangleEdge.TOP);
            legend.setFrame(BlockBorder.NONE);
            legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
            legend.setItemFont(LABEL_FONT);
        }
    } else if (colorColumn >= 0) {
        chart.addLegend(new LegendTitle(new LegendItemSource() {

            @Override
            public LegendItemCollection getLegendItems() {
                LegendItemCollection itemCollection = new LegendItemCollection();
                itemCollection.add(new LegendItem("Dummy"));
                return itemCollection;
            }
        }) {

            private static final long serialVersionUID = 1288380309936848376L;

            @Override
            public Object draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area,
                    java.lang.Object params) {
                if (dataTable.isDate(colorColumn) || dataTable.isTime(colorColumn)
                        || dataTable.isDateTime(colorColumn)) {
                    drawSimpleDateLegend(g2, (int) (area.getCenterX() - 170), (int) (area.getCenterY() + 7),
                            dataTable, colorColumn, renderer.getMinColorValue(), renderer.getMaxColorValue());
                    return new BlockResult();
                } else {
                    final String minColorString = Tools.formatNumber(renderer.getMinColorValue());
                    final String maxColorString = Tools.formatNumber(renderer.getMaxColorValue());
                    drawSimpleNumericalLegend(g2, (int) (area.getCenterX() - 90), (int) (area.getCenterY() + 7),
                            dataTable.getColumnName(colorColumn), minColorString, maxColorString);
                    return new BlockResult();
                }
            }

            @Override
            public void draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area) {
                draw(g2, area, null);
            }

        });
    }

    // chart panel
    if (panel instanceof AbstractChartPanel) {
        panel.setChart(chart);
    } else {
        panel = new AbstractChartPanel(chart, getWidth(), getHeight() - MARGIN);
        final ChartPanelShiftController controller = new ChartPanelShiftController(panel);
        panel.addMouseListener(controller);
        panel.addMouseMotionListener(controller);
    }

    // ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!!
    panel.getChartRenderingInfo().setEntityCollection(null);
}

From source file:com.bdb.weather.display.windrose.WindRosePlot.java

@Override
public LegendItemCollection getLegendItems() {
    ////  w ww .j  a  v  a 2s  .  c o m
    // Create the legend item to differentiate the speed bins
    //
    LegendItemCollection items = new LegendItemCollection();

    LegendItem defaultItem = new LegendItem("Dummy");

    if (data != null) {
        List<SpeedBin> bins = data.getSpeedBins();

        for (int j = 0; j < bins.size(); j++) {
            LegendItem item = new LegendItem(bins.get(j).speedString(), "Speed Bin", "", "",
                    defaultItem.getShape(), binColor[j], defaultItem.getOutlineStroke(),
                    defaultItem.getOutlinePaint());

            items.add(item);
        }
    }
    return items;
}

From source file:RDGraphGenerator.java

/**
 * Creates the legend items for the chart.  In this case, we set them manually because we
 * only want legend items for a subset of the data series.
 *
 * @return The legend items.//from   ww  w  . j  a v a  2s  . c  o  m
 */
private LegendItemCollection createLegendItems() {
    LegendItemCollection result = new LegendItemCollection();
    LegendItem item1 = new LegendItem(type0, new Color(0x22, 0x22, 0xFF));
    LegendItem item2 = new LegendItem(type1, new Color(0x22, 0xFF, 0x22));
    LegendItem item3 = new LegendItem(type2, new Color(0xFF, 0x22, 0x22));
    LegendItem item4 = new LegendItem(type3, new Color(0xFF, 0xFF, 0x22));
    result.add(item1);
    result.add(item2);
    result.add(item3);
    result.add(item4);
    return result;
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.targetcharts.SparkLine.java

@Override
public JFreeChart createChart(DatasetMap datasets) {
    logger.debug("IN");
    XYDataset dataset = (XYDataset) datasets.getDatasets().get("1");

    final JFreeChart sparkLineGraph = ChartFactory.createTimeSeriesChart(null, null, null, dataset, legend,
            false, false);//from   www .j  a v  a  2  s. c o m
    sparkLineGraph.setBackgroundPaint(color);

    TextTitle title = setStyleTitle(name, styleTitle);
    sparkLineGraph.setTitle(title);
    if (subName != null && !subName.equals("")) {
        TextTitle subTitle = setStyleTitle(subName, styleSubTitle);
        sparkLineGraph.addSubtitle(subTitle);
    }

    sparkLineGraph.setBorderVisible(false);
    sparkLineGraph.setBorderPaint(Color.BLACK);
    XYPlot plot = sparkLineGraph.getXYPlot();
    plot.setOutlineVisible(false);
    plot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
    plot.setBackgroundPaint(null);
    plot.setDomainGridlinesVisible(false);
    plot.setDomainCrosshairVisible(false);
    plot.setRangeGridlinesVisible(false);
    plot.setRangeCrosshairVisible(false);
    plot.setBackgroundPaint(color);

    // calculate the last marker color
    Paint colorLast = getLastPointColor();

    // Calculate average, minimum and maximum to draw plot borders.
    boolean isFirst = true;
    double avg = 0, min = Double.POSITIVE_INFINITY, max = Double.NEGATIVE_INFINITY;
    int count = 0;
    for (int i = 0; i < timeSeries.getItemCount(); i++) {
        if (timeSeries.getValue(i) != null) {
            count++;
            if (isFirst) {
                min = timeSeries.getValue(i).doubleValue();
                max = timeSeries.getValue(i).doubleValue();
                isFirst = false;
            }
            double n = timeSeries.getValue(i).doubleValue();
            //calculate avg, min, max
            avg += n;
            if (n < min)
                min = n;
            if (n > max)
                max = n;
        }
    }
    // average
    avg = avg / (double) count;

    // calculate min and max between thresholds!
    boolean isFirst2 = true;
    double lb = 0, ub = 0;
    for (Iterator iterator = thresholds.keySet().iterator(); iterator.hasNext();) {
        Double thres = (Double) iterator.next();
        if (isFirst2 == true) {
            ub = thres.doubleValue();
            lb = thres.doubleValue();
            isFirst2 = false;
        }
        if (thres.doubleValue() > ub)
            ub = thres.doubleValue();
        if (thres.doubleValue() < lb)
            lb = thres.doubleValue();
    }

    plot.getRangeAxis().setRange(new Range(Math.min(lb, min - 2), Math.max(ub, max + 2) + 2));

    addMarker(1, avg, Color.GRAY, 0.8f, plot);
    //addAvaregeSeries(series, plot);
    addPointSeries(timeSeries, plot);

    int num = 3;
    for (Iterator iterator = thresholds.keySet().iterator(); iterator.hasNext();) {
        Double thres = (Double) iterator.next();
        TargetThreshold targThres = thresholds.get(thres);
        Color color = Color.WHITE;
        if (targThres != null && targThres.getColor() != null) {
            color = targThres.getColor();
        }
        if (targThres.isVisible()) {
            addMarker(num++, thres.doubleValue(), color, 0.5f, plot);
        }
    }

    ValueAxis domainAxis = plot.getDomainAxis();
    domainAxis.setVisible(false);
    domainAxis.setUpperMargin(0.2);
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setVisible(false);

    plot.getRenderer().setSeriesPaint(0, Color.BLACK);
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false) {
        public boolean getItemShapeVisible(int _series, int item) {
            TimeSeriesDataItem tsdi = timeSeries.getDataItem(item);
            if (tsdi == null)
                return false;
            Month period = (Month) tsdi.getPeriod();
            int currMonth = period.getMonth();
            int currYear = period.getYearValue();
            int lastMonthFilled = lastMonth.getMonth();
            int lastYearFilled = lastMonth.getYearValue();
            boolean isLast = false;
            if (currYear == lastYearFilled && currMonth == lastMonthFilled) {
                isLast = true;
            }
            return isLast;
        }
    };
    renderer.setSeriesPaint(0, Color.decode("0x000000"));

    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);
    renderer.setDrawOutlines(true);
    renderer.setUseFillPaint(true);
    renderer.setBaseFillPaint(colorLast);
    renderer.setBaseOutlinePaint(Color.BLACK);
    renderer.setUseOutlinePaint(true);
    renderer.setSeriesShape(0, new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0));

    if (wlt_mode.doubleValue() == 0) {
        renderer.setBaseItemLabelsVisible(Boolean.FALSE, true);
    } else {
        renderer.setBaseItemLabelsVisible(Boolean.TRUE, true);
        renderer.setBaseItemLabelFont(
                new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize()));
        renderer.setBaseItemLabelPaint(styleValueLabels.getColor());
        renderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator("{2}", new DecimalFormat("0.###"),
                new DecimalFormat("0.###")) {
            public String generateLabel(CategoryDataset dataset, int row, int column) {
                if (dataset.getValue(row, column) == null || dataset.getValue(row, column).doubleValue() == 0)
                    return "";
                String columnKey = (String) dataset.getColumnKey(column);
                int separator = columnKey.indexOf('-');
                String month = columnKey.substring(0, separator);
                String year = columnKey.substring(separator + 1);
                int monthNum = Integer.parseInt(month);
                if (wlt_mode.doubleValue() >= 1 && wlt_mode.doubleValue() <= 4) {
                    if (wlt_mode.doubleValue() == 2 && column % 2 == 0)
                        return "";

                    Calendar calendar = Calendar.getInstance();
                    calendar.set(Calendar.MONTH, monthNum - 1);
                    SimpleDateFormat dataFormat = new SimpleDateFormat("MMM");
                    return dataFormat.format(calendar.getTime());
                } else
                    return "" + monthNum;
            }
        });
    }

    if (wlt_mode.doubleValue() == 3) {
        renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12,
                org.jfree.ui.TextAnchor.BOTTOM_CENTER, org.jfree.ui.TextAnchor.BOTTOM_RIGHT, Math.PI / 2));
        renderer.setBaseNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6,
                org.jfree.ui.TextAnchor.TOP_CENTER, org.jfree.ui.TextAnchor.HALF_ASCENT_LEFT, Math.PI / 2));

    } else if (wlt_mode.doubleValue() == 4) {
        renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12,
                org.jfree.ui.TextAnchor.BOTTOM_CENTER, org.jfree.ui.TextAnchor.BOTTOM_RIGHT, Math.PI / 4));
        renderer.setBaseNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6,
                org.jfree.ui.TextAnchor.TOP_CENTER, org.jfree.ui.TextAnchor.HALF_ASCENT_LEFT, Math.PI / 4));
    }

    if (legend == true) {
        LegendItemCollection collection = createThresholdLegend(plot);
        LegendItem item = new LegendItem("Avg", "Avg", "Avg", "Avg", new Rectangle(10, 10), colorAverage);
        collection.add(item);
        plot.setFixedLegendItems(collection);

    }

    plot.setRenderer(0, renderer);
    logger.debug("OUT");
    return sparkLineGraph;
}

From source file:com.graphhopper.jsprit.analysis.toolbox.Plotter.java

private LegendTitle createLegend(final Collection<VehicleRoute> routes, final XYSeriesCollection shipments,
        final XYPlot plot) {
    LegendItemSource lis = new LegendItemSource() {

        @Override//from  ww w.j a v a2 s.  c  o  m
        public LegendItemCollection getLegendItems() {
            LegendItemCollection lic = new LegendItemCollection();
            LegendItem vehLoc = new LegendItem("vehLoc", Color.RED);
            vehLoc.setShape(ELLIPSE);
            vehLoc.setShapeVisible(true);
            lic.add(vehLoc);
            if (containsServiceAct) {
                LegendItem item = new LegendItem("service", Color.BLUE);
                item.setShape(ELLIPSE);
                item.setShapeVisible(true);
                lic.add(item);
            }
            if (containsPickupAct) {
                LegendItem item = new LegendItem("pickup", Color.GREEN);
                item.setShape(ELLIPSE);
                item.setShapeVisible(true);
                lic.add(item);
            }
            if (containsDeliveryAct) {
                LegendItem item = new LegendItem("delivery", Color.BLUE);
                item.setShape(ELLIPSE);
                item.setShapeVisible(true);
                lic.add(item);
            }
            if (routes != null) {
                LegendItem item = new LegendItem("firstActivity", Color.BLACK);
                Shape upTriangle = ShapeUtilities.createUpTriangle(3.0f);
                item.setShape(upTriangle);
                item.setOutlinePaint(Color.BLACK);

                item.setLine(upTriangle);
                item.setLinePaint(Color.BLACK);
                item.setShapeVisible(true);

                lic.add(item);
            }
            if (!shipments.getSeries().isEmpty()) {
                lic.add(plot.getRenderer(1).getLegendItem(1, 0));
            }
            if (routes != null) {
                lic.addAll(plot.getRenderer(2).getLegendItems());
            }
            return lic;
        }
    };

    LegendTitle legend = new LegendTitle(lis);
    legend.setPosition(RectangleEdge.BOTTOM);
    return legend;
}