Example usage for org.jfree.chart.title LegendGraphic LegendGraphic

List of usage examples for org.jfree.chart.title LegendGraphic LegendGraphic

Introduction

In this page you can find the example usage for org.jfree.chart.title LegendGraphic LegendGraphic.

Prototype

public LegendGraphic(Shape shape, Paint fillPaint) 

Source Link

Document

Creates a new legend graphic.

Usage

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

private Block createDefaultLegendItem(LegendItem item) {
    BlockContainer result = null;//  w  w w.j  a  v  a2  s  .c o 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 w  w .j av  a2 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;
}