Example usage for org.jfree.chart LegendItem setShape

List of usage examples for org.jfree.chart LegendItem setShape

Introduction

In this page you can find the example usage for org.jfree.chart LegendItem setShape.

Prototype

public void setShape(Shape shape) 

Source Link

Document

Sets the shape for the legend item.

Usage

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  w ww  .jav a2s .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;
}

From source file:jspritTest.util.Plotter.java

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

        public LegendItemCollection getLegendItems() {
            LegendItemCollection lic = new LegendItemCollection();
            LegendItem vehLoc = new LegendItem("vehLoc", Color.RED);
            vehLoc.setShape(ELLIPSE);
            vehLoc.setShapeVisible(true);
            lic.add(vehLoc);// w w  w .  j  a  v  a2  s .  c  o  m
            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;
}