Example usage for org.jfree.chart LegendItem getShape

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

Introduction

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

Prototype

public Shape getShape() 

Source Link

Document

Returns the shape used to label the series represented by this legend item.

Usage

From source file:ca.nengo.plot.impl.DefaultPlotter.java

private static LegendItem getCopy(LegendItem original, String newLabel) {
    return new LegendItem(newLabel, null, //description
            null, //tooltip text
            null, //URL
            original.isShapeVisible(), original.getShape(), original.isShapeFilled(), original.getFillPaint(),
            original.isShapeOutlineVisible(), original.getOutlinePaint(), original.getOutlineStroke(),
            original.isLineVisible(), original.getLine(), original.getLineStroke(), original.getLinePaint());
}

From source file:gda.plots.SimpleLegendTitle.java

/**
 * Overrides the super class method to create a SimpleLegendGraphic instead of a LegendGraphic and a
 * SimpleLegendLabelBlock instead of a LabelBlock (otherwise identical except private field names replaced with
 * method calls). Assumes it will be passed a SimpleLegendItem and uses it to get the SimpleXYSeries to pass on to
 * the SimpleLegendGraphic and SimpleLegendLabelBlock.
 * /* w ww.ja va  2s.  c o  m*/
 * @param item
 *            the LegendItem for which the LegendItemBlock is to be created
 * @return the LegendItemBlock created
 */
@Override
protected Block createLegendItemBlock(LegendItem item) {
    BlockContainer result = null;
    if (item instanceof SimpleLegendItem) {
        LegendGraphic lg = new SimpleLegendGraphic(item.getShape(), item.getFillPaint(),
                ((SimpleLegendItem) item).getSeries());
        lg.setShapeFilled(item.isShapeFilled());
        lg.setLine(item.getLine());
        lg.setLineStroke(item.getLineStroke());
        lg.setLinePaint(item.getLinePaint());
        lg.setLineVisible(item.isLineVisible());
        lg.setShapeVisible(item.isShapeVisible());
        lg.setShapeOutlineVisible(item.isShapeOutlineVisible());
        lg.setOutlinePaint(item.getOutlinePaint());
        lg.setOutlineStroke(item.getOutlineStroke());
        lg.setPadding(getLegendItemGraphicPadding());

        BlockContainer legendItem = new BlockContainer(new BorderArrangement());
        lg.setShapeAnchor(getLegendItemGraphicAnchor());
        lg.setShapeLocation(getLegendItemGraphicLocation());
        legendItem.add(lg, getLegendItemGraphicEdge());
        LabelBlock labelBlock = new SimpleLegendLabelBlock(item.getLabel(), getItemFont(), getItemPaint(),
                ((SimpleLegendItem) item).getSeries());
        labelBlock.setPadding(getItemLabelPadding());
        labelBlock.setToolTipText(item.getLabel());
        // labelBlock.setToolTipText("click");
        legendItem.add(labelBlock);

        result = new BlockContainer(new CenterArrangement());
        result.add(legendItem);
    }

    return result;
}

From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.legend.SmartLegendTitle.java

private Block createDefaultLegendItem(LegendItem item) {
    BlockContainer result = null;/*from   w  ww.java  2 s  . co m*/

    Shape shape = item.getShape();
    if (shape == null) {
        shape = new Rectangle();
    }
    LegendGraphic lg = new LegendGraphic(shape, item.getFillPaint());
    lg.setFillPaintTransformer(item.getFillPaintTransformer());
    lg.setShapeFilled(item.isShapeFilled());
    lg.setLine(item.getLine());
    lg.setLineStroke(item.getLineStroke());
    lg.setLinePaint(item.getLinePaint());
    lg.setLineVisible(item.isLineVisible());
    lg.setShapeVisible(item.isShapeVisible());
    lg.setShapeOutlineVisible(item.isShapeOutlineVisible());
    lg.setOutlinePaint(item.getOutlinePaint());
    lg.setOutlineStroke(item.getOutlineStroke());
    lg.setPadding(getLegendItemGraphicPadding());

    LegendItemBlockContainer legendItem = new LegendItemBlockContainer(new BorderArrangement(),
            item.getDataset(), item.getSeriesKey());
    lg.setShapeAnchor(getLegendItemGraphicAnchor());
    lg.setShapeLocation(getLegendItemGraphicLocation());
    legendItem.add(lg, getLegendItemGraphicEdge());

    Font textFont = item.getLabelFont();
    if (textFont == null) {
        textFont = getItemFont();
    }
    Paint textPaint = item.getLabelPaint();
    if (textPaint == null) {
        textPaint = getItemPaint();
    }
    LabelBlock labelBlock = new LabelBlock(item.getLabel(), textFont, textPaint);
    labelBlock.setPadding(getItemLabelPadding());
    legendItem.add(labelBlock);
    legendItem.setToolTipText(item.getToolTipText());
    legendItem.setURLText(item.getURLText());

    result = new BlockContainer(new CenterArrangement());
    result.add(legendItem);

    return result;
}

From source file:org.codehaus.mojo.dashboard.report.plugin.chart.time.MarkerTimeChartDecorator.java

/**
 * Creates a legend item block.//from w  ww.  j av  a 2 s. com
 * 
 * @param item
 *            the legend item.
 * 
 * @return The block.
 */
protected Block createLegendItemBlock(LegendItem item, int i) {
    BlockContainer result = null;
    LegendGraphic lg = new LegendGraphic(item.getShape(), item.getFillPaint());
    lg.setFillPaintTransformer(item.getFillPaintTransformer());
    lg.setShapeFilled(true);
    lg.setLine(item.getLine());
    lg.setLineStroke(item.getLineStroke());
    lg.setLinePaint(item.getFillPaint());
    lg.setLineVisible(true);
    lg.setShapeVisible(true);
    lg.setShapeOutlineVisible(true);
    lg.setOutlinePaint(item.getFillPaint());
    lg.setOutlineStroke(item.getOutlineStroke());
    lg.setPadding(new RectangleInsets(2.0, 2.0, 2.0, 2.0));

    LegendItemBlockContainer legendItem = new LegendItemBlockContainer(new BorderArrangement(), 0, i);
    lg.setShapeAnchor(RectangleAnchor.CENTER);
    lg.setShapeLocation(RectangleAnchor.CENTER);
    legendItem.add(lg, RectangleEdge.LEFT);

    LabelBlock labelBlock = new LabelBlock(item.getLabel(), new Font("SansSerif", Font.BOLD, 10), Color.black);
    labelBlock.setPadding(new RectangleInsets(2.0, 2.0, 2.0, 2.0));
    legendItem.add(labelBlock);
    legendItem.setToolTipText(item.getToolTipText());
    legendItem.setURLText(item.getURLText());

    result = new BlockContainer(new CenterArrangement());
    result.add(legendItem);

    return result;
}

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

@Override
public LegendItemCollection getLegendItems() {
    ////from   w  ww  .  j a  v  a 2  s  .  com
    // 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:org.geotools.renderer.chart.GeometryRenderer.java

@Override
public LegendItem getLegendItem(int datasetIndex, int series) {
    LegendItem li = super.getLegendItem(datasetIndex, series);

    Stroke outlineStroke = getItemStroke(series, 0);
    Paint fillPaint = li.getFillPaint();
    Paint outlinePaint = fillPaint;

    if (!fillCoordinates) {
        fillPaint = new Color(255, 255, 255, 255);
    }/*from   w  w  w.j a  v a 2 s . c o  m*/
    return new LegendItem(li.getLabel(), li.getDescription(), li.getToolTipText(), li.getURLText(),
            li.getShape(), fillPaint, outlineStroke, outlinePaint);
}