Example usage for org.jfree.chart.title TextTitle DEFAULT_FONT

List of usage examples for org.jfree.chart.title TextTitle DEFAULT_FONT

Introduction

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

Prototype

Font DEFAULT_FONT

To view the source code for org.jfree.chart.title TextTitle DEFAULT_FONT.

Click Source Link

Document

The default font.

Usage

From source file:net.sf.jasperreports.components.spiderchart.FillSpiderChart.java

protected JFreeChart evaluateChart(byte evaluation) throws JRException {
    maxValue = (Double) fillContext.evaluate(getPlot().getMaxValueExpression(), evaluation);
    titleText = (String) fillContext.evaluate(getChartSettings().getTitleExpression(), evaluation);
    subtitleText = (String) fillContext.evaluate(getChartSettings().getSubtitleExpression(), evaluation);
    anchorName = (String) fillContext.evaluate(getChartSettings().getAnchorNameExpression(), evaluation);
    hyperlinkReference = (String) fillContext.evaluate(getChartSettings().getHyperlinkReferenceExpression(),
            evaluation);//  ww w.  jav a 2  s . co m
    hyperlinkAnchor = (String) fillContext.evaluate(getChartSettings().getHyperlinkAnchorExpression(),
            evaluation);
    hyperlinkPage = (Integer) fillContext.evaluate(getChartSettings().getHyperlinkPageExpression(), evaluation);
    hyperlinkTooltip = (String) fillContext.evaluate(getChartSettings().getHyperlinkTooltipExpression(),
            evaluation);
    hyperlinkParameters = JRFillHyperlinkHelper.evaluateHyperlinkParameters(getChartSettings(),
            expressionEvaluator, evaluation);

    dataset.evaluateDatasetRun(evaluation);
    dataset.finishDataset();

    chartHyperlinkProvider = new CategoryChartHyperlinkProvider(dataset.getItemHyperlinks());

    bookmarkLevel = getChartSettings().getBookmarkLevel();

    SpiderWebPlot spiderWebPlot = new SpiderWebPlot((DefaultCategoryDataset) dataset.getCustomDataset());

    if (getPlot().getAxisLineColor() != null) {
        spiderWebPlot.setAxisLinePaint(getPlot().getAxisLineColor());
    }
    if (getPlot().getAxisLineWidth() != null) {
        spiderWebPlot.setAxisLineStroke(new BasicStroke(getPlot().getAxisLineWidth()));
    }
    if (getPlot().getBackcolor() != null) {
        spiderWebPlot.setBackgroundPaint(getPlot().getBackcolor());
    }
    if (getPlot().getBackgroundAlpha() != null) {
        spiderWebPlot.setBackgroundAlpha(getPlot().getBackgroundAlpha());
    }
    if (getPlot().getForegroundAlpha() != null) {
        spiderWebPlot.setForegroundAlpha(getPlot().getForegroundAlpha());
    }
    if (getPlot().getHeadPercent() != null) {
        spiderWebPlot.setHeadPercent(getPlot().getHeadPercent());
    }
    if (getPlot().getInteriorGap() != null) {
        spiderWebPlot.setInteriorGap(getPlot().getInteriorGap());
    }
    if (getPlot().getLabelColor() != null) {
        spiderWebPlot.setLabelPaint(getPlot().getLabelColor());
    }
    if (getPlot().getLabelFont() != null) {
        spiderWebPlot.setLabelFont(JRFontUtil.getAwtFont(getPlot().getLabelFont(), Locale.getDefault()));
    }
    if (getPlot().getLabelGap() != null) {
        spiderWebPlot.setAxisLabelGap(getPlot().getLabelGap());
    }
    if (maxValue != null) {
        spiderWebPlot.setMaxValue(maxValue);
    }
    if (getPlot().getRotation() != null) {
        spiderWebPlot.setDirection(getPlot().getRotation().getRotation());
    }
    if (getPlot().getStartAngle() != null) {
        spiderWebPlot.setStartAngle(getPlot().getStartAngle());
    }
    if (getPlot().getTableOrder() != null) {
        spiderWebPlot.setDataExtractOrder(getPlot().getTableOrder().getOrder());
    }
    if (getPlot().getWebFilled() != null) {
        spiderWebPlot.setWebFilled(getPlot().getWebFilled());
    }

    spiderWebPlot.setToolTipGenerator(new StandardCategoryToolTipGenerator());
    spiderWebPlot.setLabelGenerator(new StandardCategoryItemLabelGenerator());

    Font titleFont = getChartSettings().getTitleFont() != null
            ? JRFontUtil.getAwtFont(getChartSettings().getTitleFont(), Locale.getDefault())
            : TextTitle.DEFAULT_FONT;

    JFreeChart jfreechart = new JFreeChart(titleText, titleFont, spiderWebPlot, true);

    if (chartSettings.getBackcolor() != null) {
        jfreechart.setBackgroundPaint(chartSettings.getBackcolor());
    }

    RectangleEdge titleEdge = getEdge(getChartSettings().getTitlePosition(), RectangleEdge.TOP);

    if (titleText != null) {
        TextTitle title = jfreechart.getTitle();
        title.setText(titleText);
        if (getChartSettings().getTitleColor() != null) {
            title.setPaint(getChartSettings().getTitleColor());
        }

        title.setFont(titleFont);
        title.setPosition(titleEdge);
        jfreechart.setTitle(title);
    }

    if (subtitleText != null) {
        TextTitle subtitle = new TextTitle(subtitleText);
        subtitle.setText(subtitleText);
        if (getChartSettings().getSubtitleColor() != null) {
            subtitle.setPaint(getChartSettings().getSubtitleColor());
        }

        if (getChartSettings().getSubtitleColor() != null) {
            Font subtitleFont = getChartSettings().getSubtitleFont() != null
                    ? JRFontUtil.getAwtFont(getChartSettings().getSubtitleFont(), Locale.getDefault())
                    : TextTitle.DEFAULT_FONT;
            subtitle.setFont(subtitleFont);
        }

        subtitle.setPosition(titleEdge);

        jfreechart.addSubtitle(subtitle);
    }

    // Apply all of the legend formatting options
    LegendTitle legend = jfreechart.getLegend();

    if (legend != null) {
        legend.setVisible((chartSettings.getShowLegend() == null || chartSettings.getShowLegend()));
        if (legend.isVisible()) {
            if (getChartSettings().getLegendColor() != null) {
                legend.setItemPaint(getChartSettings().getLegendColor());
            }
            if (getChartSettings().getLegendBackgroundColor() != null) {
                legend.setBackgroundPaint(getChartSettings().getLegendBackgroundColor());
            }

            if (getChartSettings().getLegendFont() != null) {
                legend.setItemFont(
                        JRFontUtil.getAwtFont(getChartSettings().getLegendFont(), Locale.getDefault()));
            }
            legend.setPosition(getEdge(getChartSettings().getLegendPosition(), RectangleEdge.BOTTOM));
        }
    }
    return jfreechart;

}

From source file:piramide.interaction.reasoner.FuzzyReasonerWizardFacade.java

private BufferedImage createErrorMessagesImage(String text) {
    final Font font = TextTitle.DEFAULT_FONT;
    final Font bigBold = new Font(font.getName(), Font.BOLD, 24);
    final FontRenderContext frc = new FontRenderContext(null, true, false);
    final TextLayout layout = new TextLayout(text, bigBold, frc);
    final Rectangle2D bounds = layout.getBounds();
    final int w = (int) Math.ceil(bounds.getWidth());
    final int h = (int) Math.ceil(bounds.getHeight());
    final BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
    final Graphics2D g = image.createGraphics();
    g.setColor(Color.WHITE);//from  www  .  jav a  2  s  .  c om
    g.fillRect(0, 0, w, h);
    g.setColor(Color.RED);
    g.setFont(bigBold);
    g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
    g.drawString(text, (float) -bounds.getX(), (float) -bounds.getY());
    g.dispose();
    return image;
}

From source file:org.ash.history.detail.StackedChartDetail.java

/**
 * Creates the chart./*from  w  ww.  j  av  a  2 s  .  c  o m*/
 * 
 * @return the jfreechart
 */
private JFreeChart createChart() {

    xAxis = new DateAxis("time");
    xAxis.setLabel(null);

    chart = ChartFactory.createStackedXYAreaChart("", // chart title
            "X Value", // domain axis label
            "Active Sessions", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // the plot orientation
            xAxis, // xAxis
            false, // legend
            true, // tooltips
            false // urls
    );

    chart.getTitle()
            .setFont(new Font(TextTitle.DEFAULT_FONT.getFontName(), TextTitle.DEFAULT_FONT.getStyle(), 14));

    plot = (XYPlot) chart.getPlot();
    renderer = new StackedXYAreaRenderer3();
    renderer.setRoundXCoordinates(true);
    renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0} ({1}, {2})",
            new SimpleDateFormat("HH:mm"), new DecimalFormat("0.0")));
    plot.setRenderer(0, renderer);
    plot.getRangeAxis().setLowerBound(0.0);
    plot.getRangeAxis().setAutoRange(true);

    // Set format for x axis
    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("HH:mm"));

    // Add legend to right
    LegendTitle legend = new LegendTitle(chart.getPlot());

    BlockContainer wrapper = new BlockContainer(new BorderArrangement());
    wrapper.setFrame(new BlockBorder(1.0, 1.0, 1.0, 1.0));

    BlockContainer itemss = legend.getItemContainer();
    itemss.setPadding(2, 10, 5, 2);
    wrapper.add(itemss);
    legend.setWrapper(wrapper);

    legend.setPosition(RectangleEdge.RIGHT);
    legend.setHorizontalAlignment(HorizontalAlignment.LEFT);

    legend.setItemFont(new Font(LegendTitle.DEFAULT_ITEM_FONT.getFontName(),
            LegendTitle.DEFAULT_ITEM_FONT.getStyle(), 10));

    chart.addSubtitle(legend);

    return chart;
}

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

@Override
public void updatePlotter() {
    final int categoryCount = prepareData();

    SwingUtilities.invokeLater(new Runnable() {

        @Override/*  www .j av  a2s. co  m*/
        public void run() {
            scrollablePlotterPanel.remove(viewScrollBar);
        }
    });

    if (categoryCount > MAX_CATEGORY_VIEW_COUNT && showScrollbar) {
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                viewScrollBar.setOrientation(Adjustable.HORIZONTAL);
                scrollablePlotterPanel.add(viewScrollBar, BorderLayout.SOUTH);
            }
        });

        this.slidingCategoryDataSet = new SlidingCategoryDataset(categoryDataSet, 0, MAX_CATEGORY_VIEW_COUNT);
        viewScrollBar.setMaximum(categoryCount);
        viewScrollBar.setValue(0);

    } else {
        this.slidingCategoryDataSet = null;
    }

    if (categoryCount <= MAX_CATEGORIES) {

        SpiderWebPlot plot = new SpiderWebPlot(categoryDataSet);

        plot.setAxisLinePaint(Color.LIGHT_GRAY);
        plot.setOutlinePaint(Color.WHITE);

        plot.setLabelGenerator(new StandardCategoryItemLabelGenerator());

        JFreeChart chart = new JFreeChart("", TextTitle.DEFAULT_FONT, plot, true);

        double[] colorValues = null;
        if (groupByColumn >= 0 && this.dataTable.isNominal(groupByColumn)) {
            colorValues = new double[this.dataTable.getNumberOfValues(groupByColumn)];
        } else {
            colorValues = new double[categoryDataSet.getColumnCount()];
        }
        for (int i = 0; i < colorValues.length; i++) {
            colorValues[i] = i;
        }

        if (panel != null) {
            panel.setChart(chart);
        } else {
            panel = new AbstractChartPanel(chart, getWidth(), getHeight() - MARGIN);
            scrollablePlotterPanel.add(panel, BorderLayout.CENTER);
            final ChartPanelShiftController controller = new ChartPanelShiftController(panel);
            panel.addMouseListener(controller);
            panel.addMouseMotionListener(controller);
        }

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

        // legend settings
        LegendTitle legend = chart.getLegend();
        if (legend != null) {
            legend.setPosition(RectangleEdge.TOP);
            legend.setFrame(BlockBorder.NONE);
            legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
            legend.setItemFont(LABEL_FONT);
        }
        if (groupByColumn < 0) {
            // no legend is needed when there is no group-by selection
            chart.removeLegend();
        }
        // ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!!
        panel.getChartRenderingInfo().setEntityCollection(null);
    } else {
        LogService.getRoot().log(Level.INFO,
                "com.rapidminer.gui.plotter.charts.BarChartPlotter.too_many_columns",
                new Object[] { categoryCount, MAX_CATEGORIES });
    }
}

From source file:org.martus.client.swingui.actions.ActionMenuCharts.java

private JFreeChart createPieChart(HashMap<String, Integer> counts, String selectedFieldLabel) throws Exception {
    DefaultPieDataset pieDataset = createPieDataset(counts);

    JFreeChart pieChart = ChartFactory.createPieChart(getChartTitle(selectedFieldLabel), // Title
            pieDataset, // Dataset
            false, // Show legend
            true, // tooltips
            new Locale(getLocalization().getCurrentLanguageCode()));

    pieChart.addSubtitle(new TextTitle(getLocalization().getFieldLabel("ChartSelectedBulletinsDisclaimerPie"),
            TextTitle.DEFAULT_FONT, TextTitle.DEFAULT_TEXT_PAINT, RectangleEdge.BOTTOM,
            TextTitle.DEFAULT_HORIZONTAL_ALIGNMENT, TextTitle.DEFAULT_VERTICAL_ALIGNMENT,
            TextTitle.DEFAULT_PADDING));

    PiePlot piePlot = (PiePlot) pieChart.getPlot();
    piePlot.setLabelGenerator(new MartusPieSectionLabelGenerator(getLocalization()));
    return pieChart;
}

From source file:org.orbeon.oxf.processor.serializer.legacy.JFreeChartSerializer.java

protected JFreeChart drawChart(ChartConfig chartConfig, final Dataset ds) {
    JFreeChart chart = null;/*from  w ww .jav  a2s.  c o m*/
    Axis categoryAxis = null;
    if (ds instanceof XYSeriesCollection) {
        categoryAxis = new RestrictedNumberAxis(chartConfig.getCategoryTitle());
    } else if (ds instanceof TimeSeriesCollection) {
        categoryAxis = new DateAxis(chartConfig.getCategoryTitle());
        ((DateAxis) categoryAxis).setDateFormatOverride(new SimpleDateFormat(chartConfig.getDateFormat()));
        if (chartConfig.getCategoryLabelAngle() == 90) {
            ((DateAxis) categoryAxis).setVerticalTickLabels(true);
        } else {
            if (chartConfig.getCategoryLabelAngle() != 0)
                throw new OXFException(
                        "The only supported values of category-label-angle for time-series charts are 0 or 90");
        }
    } else {
        categoryAxis = new CategoryAxis(chartConfig.getCategoryTitle());
        ((CategoryAxis) categoryAxis).setCategoryLabelPositions(chartConfig.getCategoryLabelPosition());
    }
    NumberAxis valueAxis = new RestrictedNumberAxis(chartConfig.getSerieTitle());
    valueAxis.setAutoRangeIncludesZero(chartConfig.getSerieAutoRangeIncludeZero());
    AbstractRenderer renderer = null;
    Plot plot = null;

    switch (chartConfig.getType()) {
    case ChartConfig.VERTICAL_BAR_TYPE:
    case ChartConfig.HORIZONTAL_BAR_TYPE:
        renderer = (ds instanceof ItemPaintCategoryDataset) ? new BarRenderer() {
            public Paint getItemPaint(int row, int column) {
                Paint p = ((ItemPaintCategoryDataset) ds).getItemPaint(row, column);
                if (p != null)
                    return p;
                else
                    return getSeriesPaint(row);
            }
        } : new BarRenderer();

        plot = new CategoryPlot((CategoryDataset) ds, (CategoryAxis) categoryAxis, (ValueAxis) valueAxis,
                (CategoryItemRenderer) renderer);

        if (chartConfig.getType() == ChartConfig.VERTICAL_BAR_TYPE)
            ((CategoryPlot) plot).setOrientation(PlotOrientation.VERTICAL);
        else
            ((CategoryPlot) plot).setOrientation(PlotOrientation.HORIZONTAL);

        break;
    case ChartConfig.STACKED_VERTICAL_BAR_TYPE:
    case ChartConfig.STACKED_HORIZONTAL_BAR_TYPE:
        renderer = (ds instanceof ItemPaintCategoryDataset) ? new StackedBarRenderer() {
            public Paint getItemPaint(int row, int column) {
                Paint p = ((ItemPaintCategoryDataset) ds).getItemPaint(row, column);
                if (p != null)
                    return p;
                else
                    return getSeriesPaint(row);
            }
        } : new StackedBarRenderer();
        plot = new CategoryPlot((CategoryDataset) ds, (CategoryAxis) categoryAxis, (ValueAxis) valueAxis,
                (CategoryItemRenderer) renderer);

        if (chartConfig.getType() == ChartConfig.STACKED_VERTICAL_BAR_TYPE)
            ((CategoryPlot) plot).setOrientation(PlotOrientation.VERTICAL);
        else
            ((CategoryPlot) plot).setOrientation(PlotOrientation.HORIZONTAL);
        break;
    case ChartConfig.LINE_TYPE:
        renderer = (ds instanceof ItemPaintCategoryDataset) ? new LineAndShapeRenderer(true, false) {
            public Paint getItemPaint(int row, int column) {
                Paint p = ((ItemPaintCategoryDataset) ds).getItemPaint(row, column);
                if (p != null)
                    return p;
                else
                    return getSeriesPaint(row);
            }
        } : (new LineAndShapeRenderer(true, false));
        plot = new CategoryPlot((CategoryDataset) ds, (CategoryAxis) categoryAxis, (ValueAxis) valueAxis,
                (CategoryItemRenderer) renderer);
        ((CategoryPlot) plot).setOrientation(PlotOrientation.VERTICAL);
        break;
    case ChartConfig.AREA_TYPE:
        renderer = (ds instanceof ItemPaintCategoryDataset) ? new AreaRenderer() {
            public Paint getItemPaint(int row, int column) {
                Paint p = ((ItemPaintCategoryDataset) ds).getItemPaint(row, column);
                if (p != null)
                    return p;
                else
                    return getSeriesPaint(row);
            }
        } : new AreaRenderer();
        plot = new CategoryPlot((CategoryDataset) ds, (CategoryAxis) categoryAxis, (ValueAxis) valueAxis,
                (CategoryItemRenderer) renderer);
        ((CategoryPlot) plot).setOrientation(PlotOrientation.VERTICAL);
        break;
    case ChartConfig.VERTICAL_BAR3D_TYPE:
    case ChartConfig.HORIZONTAL_BAR3D_TYPE:
        categoryAxis = new CategoryAxis3D(chartConfig.getCategoryTitle());
        valueAxis = new NumberAxis3D(chartConfig.getSerieTitle());
        renderer = (ds instanceof ItemPaintCategoryDataset) ? new BarRenderer3D() {
            public Paint getItemPaint(int row, int column) {
                Paint p = ((ItemPaintCategoryDataset) ds).getItemPaint(row, column);
                if (p != null)
                    return p;
                else
                    return getSeriesPaint(row);
            }
        } : new BarRenderer3D();
        plot = new CategoryPlot((CategoryDataset) ds, (CategoryAxis) categoryAxis, (ValueAxis) valueAxis,
                (CategoryItemRenderer) renderer);

        if (chartConfig.getType() == ChartConfig.VERTICAL_BAR3D_TYPE)
            ((CategoryPlot) plot).setOrientation(PlotOrientation.VERTICAL);
        else
            ((CategoryPlot) plot).setOrientation(PlotOrientation.HORIZONTAL);

        break;
    case ChartConfig.STACKED_VERTICAL_BAR3D_TYPE:
    case ChartConfig.STACKED_HORIZONTAL_BAR3D_TYPE:
        categoryAxis = new CategoryAxis3D(chartConfig.getCategoryTitle());
        valueAxis = new NumberAxis3D(chartConfig.getSerieTitle());
        renderer = (ds instanceof ItemPaintCategoryDataset) ? new StackedBarRenderer3D() {
            public Paint getItemPaint(int row, int column) {
                Paint p = ((ItemPaintCategoryDataset) ds).getItemPaint(row, column);
                if (p != null)
                    return p;
                else
                    return getSeriesPaint(row);
            }
        } : new StackedBarRenderer3D();
        plot = new CategoryPlot((CategoryDataset) ds, (CategoryAxis) categoryAxis, (ValueAxis) valueAxis,
                (CategoryItemRenderer) renderer);

        if (chartConfig.getType() == ChartConfig.STACKED_VERTICAL_BAR3D_TYPE)
            ((CategoryPlot) plot).setOrientation(PlotOrientation.VERTICAL);
        else
            ((CategoryPlot) plot).setOrientation(PlotOrientation.HORIZONTAL);

        break;
    case ChartConfig.PIE_TYPE:
    case ChartConfig.PIE3D_TYPE:
        categoryAxis = null;
        valueAxis = null;
        renderer = null;
        ExtendedPieDataset pds = (ExtendedPieDataset) ds;

        plot = chartConfig.getType() == ChartConfig.PIE_TYPE ? new PiePlot(pds) : new PiePlot3D(pds);

        PiePlot pp = (PiePlot) plot;
        pp.setLabelGenerator(new StandardPieSectionLabelGenerator());

        for (int i = 0; i < pds.getItemCount(); i++) {
            Paint p = pds.getPaint(i);
            if (p != null)
                pp.setSectionPaint(i, p);

            pp.setExplodePercent(i, pds.getExplodePercent(i));

            Paint paint = pds.getPaint(i);
            if (paint != null)
                pp.setSectionPaint(i, paint);
        }
        break;
    case ChartConfig.XY_LINE_TYPE:
        renderer = new XYLineAndShapeRenderer(true, false);
        plot = new XYPlot((XYDataset) ds, (ValueAxis) categoryAxis, (ValueAxis) valueAxis,
                (XYLineAndShapeRenderer) renderer);
        break;
    case ChartConfig.TIME_SERIES_TYPE:
        renderer = new XYLineAndShapeRenderer(true, false);
        plot = new XYPlot((XYDataset) ds, (DateAxis) categoryAxis, (ValueAxis) valueAxis,
                (XYLineAndShapeRenderer) renderer);
        break;
    default:
        throw new OXFException("Chart Type not supported");
    }

    if (categoryAxis != null) {
        categoryAxis.setLabelPaint(chartConfig.getTitleColor());
        categoryAxis.setTickLabelPaint(chartConfig.getTitleColor());
        categoryAxis.setTickMarkPaint(chartConfig.getTitleColor());
        if (categoryAxis instanceof RestrictedNumberAxis) {
            ((RestrictedNumberAxis) categoryAxis).setMaxTicks(chartConfig.getMaxNumOfLabels());
        }
        if (categoryAxis instanceof CategoryAxis && chartConfig.getCategoryMargin() != 0)
            ((CategoryAxis) categoryAxis).setCategoryMargin(chartConfig.getCategoryMargin());
    }

    if (valueAxis != null) {
        valueAxis.setLabelPaint(chartConfig.getTitleColor());
        valueAxis.setTickLabelPaint(chartConfig.getTitleColor());
        valueAxis.setTickMarkPaint(chartConfig.getTitleColor());
        ((RestrictedNumberAxis) valueAxis).setMaxTicks(chartConfig.getMaxNumOfLabels());
    }

    if (renderer != null) {
        if (renderer instanceof XYLineAndShapeRenderer) {
            ((XYLineAndShapeRenderer) renderer).setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
        } else {
            ((CategoryItemRenderer) renderer)
                    .setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
        }
        if (renderer instanceof BarRenderer)
            ((BarRenderer) renderer).setItemMargin(chartConfig.getBarMargin());

        int j = 0;
        for (Iterator i = chartConfig.getValueIterator(); i.hasNext();) {
            Value v = (Value) i.next();
            renderer.setSeriesPaint(j, v.getColor());
            j++;
        }
    }

    plot.setOutlinePaint(chartConfig.getTitleColor());
    CustomLegend legend = chartConfig.getLegendConfig();
    chart = new JFreeChart(chartConfig.getTitle(), TextTitle.DEFAULT_FONT, plot, false);
    if (legend.isVisible()) {
        legend.setSources(new LegendItemSource[] { plot });
        chart.addLegend(legend);
    }
    chart.setBackgroundPaint(chartConfig.getBackgroundColor());
    TextTitle textTitle = new TextTitle(chartConfig.getTitle(), TextTitle.DEFAULT_FONT,
            chartConfig.getTitleColor(), TextTitle.DEFAULT_POSITION, TextTitle.DEFAULT_HORIZONTAL_ALIGNMENT,
            TextTitle.DEFAULT_VERTICAL_ALIGNMENT, TextTitle.DEFAULT_PADDING);
    chart.setTitle(textTitle);
    return chart;
}

From source file:org.pentaho.platform.uifoundation.chart.JFreeChartEngine.java

/**
 * Creates a java.awt.TexturePaint object from an XML node from the dial definition document
 * //  w w w  .j a va2 s. c o  m
 * @param XML
 *          Node from the dial definition
 * @param width
 *          of the chart
 * @param height
 *          of the chart
 * @return Paint object defined by the node / public static Paint getTexturePaint( Node node, int width, int
 *         height ) {
 * 
 *         if( node == null ) { return null; } int rectWidth=width; int rectHeight=height; int x=0; int y=0; //
 *         Get Image try{ Node imageNode = node.selectSingleNode( "background-image" ); //$NON-NLS-1$ if(
 *         imageNode != null ) { String imageName = imageNode.getText().toString(); String fileName =
 *         PentahoSystem.getApplicationContext().getSolutionPath( imageName ); int offset = fileName.lastIndexOf(
 *         "." ); //$NON-NLS-1$ String type = offset == -1 ? "jpg" : fileName.substring(offset + 1);
 *         //$NON-NLS-1$
 * 
 *         BufferedImage image = new BufferedImage( width, height, BufferedImage.TYPE_INT_ARGB);
 * 
 *         ImageIO.write(image, type, new File( fileName ));
 * 
 *         Node rectangle= node.selectSingleNode("rectangle"); //$NON-NLS-1$ if( rectangle != null ) { Node
 *         tmpNode = rectangle.selectSingleNode("width"); //$NON-NLS-1$ if( tmpNode != null ) {
 *         rectWidth=Integer.parseInt(tmpNode.getText().toString().trim()); //$NON-NLS-1$ } tmpNode =
 *         rectangle.selectSingleNode("height"); //$NON-NLS-1$ if( tmpNode != null ) {
 *         rectHeight=Integer.parseInt(tmpNode.getText().toString().trim()); //$NON-NLS-1$ } tmpNode =
 *         rectangle.selectSingleNode("x"); //$NON-NLS-1$ if( tmpNode != null ) {
 *         x=Integer.parseInt(tmpNode.getText().toString().trim()); //$NON-NLS-1$ } tmpNode =
 *         rectangle.selectSingleNode("y"); //$NON-NLS-1$ if( tmpNode != null ) {
 *         y=Integer.parseInt(tmpNode.getText().toString().trim()); //$NON-NLS-1$ } }
 * 
 *         Rectangle2D rect = new Rectangle2D.Double(x,y,rectWidth,rectHeight);
 * 
 *         return new TexturePaint(image,rect); }
 * 
 *         }catch(Exception e){e.printStackTrace();} return null; }
 */
public static Font getFont(final Node fontNode) {
    Font font = null;
    if (fontNode != null) {
        String fontFamily = TextTitle.DEFAULT_FONT.getFamily();
        int fontStyle = Font.PLAIN;
        int fontSize = TextTitle.DEFAULT_FONT.getSize();

        Node fontFamilyNode = fontNode.selectSingleNode(JFreeChartEngine.FONT_FAMILY_NODE_NAME);
        if ((fontFamilyNode != null) && (fontFamilyNode.getText().length() > 0)) {
            fontFamily = fontFamilyNode.getText();
        }
        Node isBoldNode = fontNode.selectSingleNode(JFreeChartEngine.IS_BOLD_NODE_NAME);
        if (isBoldNode != null) {
            boolean bold = Boolean.valueOf(isBoldNode.getText()).booleanValue();
            if (bold) {
                fontStyle += Font.BOLD;
            }
        }
        Node isItalicNode = fontNode.selectSingleNode(JFreeChartEngine.IS_ITALIC_NODE_NAME);
        if (isItalicNode != null) {
            boolean italic = Boolean.valueOf(isItalicNode.getText()).booleanValue();
            if (italic) {
                fontStyle += Font.ITALIC;
            }
        }
        Node sizeNode = fontNode.selectSingleNode(JFreeChartEngine.SIZE_NODE_NAME);
        if ((sizeNode != null) && (sizeNode.getText().length() > 0)) {
            fontSize = Integer.parseInt(sizeNode.getText());
        }
        font = new Font(fontFamily, fontStyle, fontSize);
    }
    return font;
}

From source file:edu.ucla.stat.SOCR.chart.ChartGenerator_JTable.java

private JFreeChart createCategorySpiderWebChart(String title, CategoryDataset dataset) {
    // get a reference to the plot for further customisation...
    SOCRSpiderWebPlot plot = new SOCRSpiderWebPlot(dataset);
    JFreeChart chart = new JFreeChart(title, TextTitle.DEFAULT_FONT, plot, false);

    LegendTitle legend = new LegendTitle(plot);
    legend.setPosition(RectangleEdge.BOTTOM);

    //renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());
    chart.addSubtitle(legend);/*  w w w  .  jav  a  2 s  .  com*/

    return chart;
}