Example usage for org.jfree.chart JFreeChart getPlot

List of usage examples for org.jfree.chart JFreeChart getPlot

Introduction

In this page you can find the example usage for org.jfree.chart JFreeChart getPlot.

Prototype

public Plot getPlot() 

Source Link

Document

Returns the plot for the chart.

Usage

From source file:org.operamasks.faces.render.graph.CurveChartRenderer.java

protected JFreeChart createChart(UIChart comp) {
    JFreeChart chart = super.createChart(comp);

    if (chart != null) {
        Plot plot = chart.getPlot();
        if (plot instanceof CategoryPlot) {
            ((CategoryPlot) plot).setRenderer(new CurveAndShapeRenderer(true, false));
        } else if (plot instanceof XYPlot) {
            ((XYPlot) plot).setRenderer(new XYCurveAndShapeRenderer(true, false));
        }//from  www .j a va  2s.  c  om
    }

    return chart;
}

From source file:org.talend.dataprofiler.chart.util.TopChartFactory.java

/**
 * /*from www  .j  a  v  a 2s .c  om*/
 * DOC zshen Comment method "createMatchRuleBarChart".
 * 
 * @param title
 * @param dataset
 * @return
 */
public static JFreeChart createMatchRuleBarChart(String categoryAxisLabel, String valueAxisLabel,
        CategoryDataset dataset) {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart localJFreeChart = ChartFactory.createBarChart(null, categoryAxisLabel, valueAxisLabel, dataset,
            PlotOrientation.VERTICAL, false, true, false);

    localJFreeChart.addSubtitle(new TextTitle(
            Messages.getString("DataChart.title", sumItemCount(dataset), sumGroupCount(dataset)))); //$NON-NLS-1$
    CategoryPlot plot = (CategoryPlot) localJFreeChart.getPlot();
    // get real color list from ChartDecorator.COLOR_LIST dataset.getColumnKeys()
    List<Color> currentColorList = null;
    try {
        currentColorList = getCurrentColorList(dataset.getColumnKeys());
    } catch (NumberFormatException e) {
        log.warn(e, e);
        currentColorList = ChartDecorator.COLOR_LIST;
    }
    BarRenderer barRenderer = new TalendBarRenderer(true, currentColorList);
    barRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    barRenderer.setBaseItemLabelsVisible(true);
    // remove the shadow
    barRenderer.setShadowVisible(Boolean.FALSE);
    plot.setRenderer(barRenderer);

    CategoryAxis localCategoryAxis = plot.getDomainAxis();
    localCategoryAxis.setCategoryMargin(0.25D);
    localCategoryAxis.setUpperMargin(0.02D);
    localCategoryAxis.setLowerMargin(0.02D);

    NumberAxis localNumberAxis = (NumberAxis) plot.getRangeAxis();
    localNumberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    localNumberAxis.setUpperMargin(0.1D);
    return localJFreeChart;
}

From source file:net.sf.jasperreports.customizers.axis.RangeAxisCustomizer.java

@Override
public void customize(JFreeChart jfc, JRChart jrc) {
    ValueAxis valueAxis = null;/*from   ww  w. j  a  va  2s . c  o m*/

    if ((jfc.getPlot() instanceof XYPlot)) {
        valueAxis = jfc.getXYPlot().getRangeAxis();
    } else if (jfc.getPlot() instanceof CategoryPlot) {
        valueAxis = jfc.getCategoryPlot().getRangeAxis();
    }

    if (valueAxis != null) {
        configValueAxis(valueAxis, PROPERTY_MIN_VALUE, PROPERTY_MAX_VALUE);

        if (valueAxis instanceof NumberAxis) {
            configNumberAxis((NumberAxis) valueAxis, PROPERTY_TICK_UNIT);
        }
    }
}

From source file:uk.ac.ed.epcc.webapp.charts.jfreechart.JFreeChartData.java

private JFreeChart getCustomisedJFreeChart() {
    JFreeChart chart = getJFreeChart();
    chart.getPlot().setBackgroundPaint(
            new GradientPaint(0.0f, 0.0F, new Color(0.75F, 0.75F, 1.0F), 0.0F, 100.0F, Color.white, false));
    if (title != null && title.trim().length() > 0) {
        chart.setTitle(title);//from   ww  w  . ja v a 2  s .c o m
    }
    return chart;
}

From source file:dbseer.gui.events.InformationChartMouseListener.java

@Override
public void chartMouseMoved(ChartMouseEvent event) {
    Rectangle2D dataArea = chartPanel.getScreenDataArea();
    JFreeChart chart = event.getChart();
    XYPlot plot = (XYPlot) chart.getPlot();
    ValueAxis xAxis = plot.getDomainAxis();
    double x = xAxis.java2DToValue(event.getTrigger().getX(), dataArea, RectangleEdge.BOTTOM);
    chartPanel.getVerticalCrossHair().setValue(x);
}

From source file:de.xirp.chart.ChartManager.java

/**
 * Returns a scatter chart. The chart is generated fromm the given
 * {@link de.xirp.db.Record} and key array. The
 * record is evaluated from the given start to the given stop time
 * or evaluated completely if the <code>origTime</code> flag is
 * set to <code>true</code>.
 * /*from   w  w w .ja va2  s.  c  om*/
 * @param record
 *            The record containing the data.
 * @param keys
 *            The keys to use.
 * @param start
 *            The start time.
 * @param stop
 *            The stop time.
 * @param origTime
 *            A flag indicating if the original time should be
 *            used.
 * @return A scatter chart.
 * @see org.jfree.chart.JFreeChart
 * @see de.xirp.db.Record
 */
private static JFreeChart createScatterChart(Record record, String[] keys, long start, long stop,
        boolean origTime) {

    String chartTitle = createChartTitle(record, keys);

    List<Observed> all = new ArrayList<Observed>();
    TimeSeriesCollection dataset = createTimeSeriesAndFillAllObservedList(all, record, keys, origTime, start,
            stop);

    JFreeChart chart = ChartFactory.createScatterPlot(chartTitle, I18n.getString("ChartManager.text.time"), //$NON-NLS-1$
            I18n.getString("ChartManager.text.value"), dataset, PlotOrientation.VERTICAL, true, true, false); //$NON-NLS-1$

    XYPlot plot = (XYPlot) chart.getPlot();
    setXYPlot(plot, new Date(record.getStart()));
    XYDotRenderer dr = new XYDotRenderer();
    dr.setDotWidth(3);
    dr.setDotHeight(3);
    plot.setRenderer(dr);

    exportAutomatically(all, chart);

    return chart;
}

From source file:net.sf.dynamicreports.design.transformation.chartcustomizer.PieChartLabelFormatCustomizer.java

@Override
public void customize(JFreeChart chart, ReportParameters reportParameters) {
    PiePlot plot = (PiePlot) chart.getPlot();
    if (labelFormat == null) {
        plot.setLabelGenerator(null);/* ww  w . j a  v a 2  s. c  o m*/
    } else {
        plot.setLabelGenerator(new StandardPieSectionLabelGenerator(labelFormat,
                new DecimalFormat(valuePattern), new DecimalFormat(percentValuePattern + "%")));
    }
}

From source file:net.sf.jasperreports.customizers.marker.CategoryMarkerCustomizer.java

@Override
public void customize(JFreeChart jfc, JRChart jrc) {
    if (jfc.getPlot() instanceof CategoryPlot) {
        Marker marker = createMarker(jrc);
        if (marker != null) {
            addMarker(jfc.getPlot(), marker);
        }/*w w w .ja  v  a  2 s  .c  o m*/
    }
}

From source file:org.apache.qpid.disttest.charting.chartbuilder.BaseChartBuilder.java

private void configureYAxisBounds(final ChartingDefinition chartingDefinition, final JFreeChart chart) {
    if (chart.getPlot() != null && chart.getPlot() instanceof XYPlot) {
        ValueAxis rangeAxis = chart.getXYPlot().getRangeAxis();
        if (chartingDefinition.getYAxisLowerBound() != null) {
            rangeAxis.setLowerBound(chartingDefinition.getYAxisLowerBound());
        }/* ww w . j  a  va  2 s. co m*/
        if (chartingDefinition.getYAxisUpperBound() != null) {
            rangeAxis.setUpperBound(chartingDefinition.getYAxisUpperBound());
        }
    }
}

From source file:framepackage.MyPieChart.java

public MyPieChart() {

    DefaultPieDataset pieDataset = new DefaultPieDataset();
    pieDataset.setValue("Online", new Integer(10));
    pieDataset.setValue("Offline", new Integer(20));
    pieDataset.setValue("Busy", new Integer(30));
    pieDataset.setValue("Away", new Integer(40));
    JFreeChart chart = ChartFactory.createPieChart("my pie", pieDataset, true, true, true);

    PiePlot P = (PiePlot) chart.getPlot();
    //P.setForegroundAlpha(TOP_ALIGNMENT);
    ChartFrame f = new ChartFrame("chart", chart);
    f.setVisible(true);//from w w  w  . j a  va  2  s  .  co m
    f.setSize(500, 700);
}