Example usage for org.jfree.chart.plot CombinedDomainXYPlot add

List of usage examples for org.jfree.chart.plot CombinedDomainXYPlot add

Introduction

In this page you can find the example usage for org.jfree.chart.plot CombinedDomainXYPlot add.

Prototype

public void add(XYPlot subplot, int weight) 

Source Link

Document

Adds a subplot with the specified weight and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:org.codehaus.mojo.chronos.chart.ChartUtil.java

static CombinedDomainXYPlot createCombinedPlot(DateAxis timeAxis, XYPlot xyplot1, XYPlot xyplot2) {
    CombinedDomainXYPlot combineddomainxyplot = new CombinedDomainXYPlot(timeAxis);
    combineddomainxyplot.setGap(GAP);// www  .j a v  a  2 s .c  o m
    combineddomainxyplot.add(xyplot1, 2);
    combineddomainxyplot.add(xyplot2, 1);
    combineddomainxyplot.setOrientation(PlotOrientation.VERTICAL);
    return combineddomainxyplot;
}

From source file:de.cebitec.readXplorer.plotting.CreatePlots.java

private synchronized static JFreeChart createCombinedChart(XYSeriesCollection normal, XYSeriesCollection posInf,
        XYSeriesCollection negInf, String xName, String yName, XYToolTipGenerator toolTip) {

    final NumberAxis domainAxis = new NumberAxis(xName);

    // create subplot 1...
    final XYDataset data1 = normal;
    final XYItemRenderer renderer1 = new XYShapeRenderer();
    renderer1.setBaseToolTipGenerator(toolTip);
    final NumberAxis rangeAxis1 = new NumberAxis(yName);
    final XYPlot subplot1 = new XYPlot(data1, domainAxis, rangeAxis1, renderer1);
    subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    // create subplot 2...
    final XYDataset data2 = negInf;
    final XYItemRenderer renderer2 = new XYShapeRenderer();
    renderer2.setBaseToolTipGenerator(toolTip);
    final NumberAxis rangeAxis2 = new NumberAxis() {
        @Override//from w ww  .  jav a2 s  .c  o m
        public List refreshTicks(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) {
            List myTicks = new ArrayList();
            myTicks.add(new NumberTick(0, "-Inf", TextAnchor.CENTER_RIGHT, TextAnchor.CENTER_RIGHT, 0.0));
            return myTicks;
        }
    };
    rangeAxis2.setAutoRangeIncludesZero(false);
    final XYPlot subplot2 = new XYPlot(data2, domainAxis, rangeAxis2, renderer2);
    subplot2.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    // create subplot 3...
    final XYDataset data3 = posInf;
    final XYItemRenderer renderer3 = new XYShapeRenderer();
    renderer3.setBaseToolTipGenerator(toolTip);
    final NumberAxis rangeAxis3 = new NumberAxis() {
        @Override
        public List refreshTicks(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) {
            List myTicks = new ArrayList();
            myTicks.add(new NumberTick(0, "Inf", TextAnchor.CENTER_RIGHT, TextAnchor.CENTER_RIGHT, 0.0));
            return myTicks;
        }
    };
    rangeAxis3.setAutoRangeIncludesZero(false);
    final XYPlot subplot3 = new XYPlot(data3, domainAxis, rangeAxis3, renderer3);
    subplot2.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    // parent plot...
    final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(domainAxis);
    plot.setGap(0);

    // add the subplots...
    plot.add(subplot3, 1);
    plot.add(subplot1, 10);
    plot.add(subplot2, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);

    // return a new chart containing the overlaid plot...
    return new JFreeChart(plot);

}

From source file:pisco.batch.visu.BatchingChartFactory.java

private static JFreeChart createCombinedChart(String title, XYPlot batchplot, XYPlot objPlot) {
    CombinedDomainXYPlot plot = new CombinedDomainXYPlot(createDateAxis());
    plot.setGap(10.0);//from w  ww  . j a v  a2  s  . c o m
    plot.add(objPlot, 1);
    plot.add(batchplot, 2);
    plot.setOrientation(PlotOrientation.VERTICAL);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
    CHOCO_THEME.apply(chart);
    return chart;
}

From source file:tools.descartes.bungee.chart.ChartGenerator.java

public static JFreeChart intensityChart(final List<ArrivalRateTuple> intensities) {
    final CombinedDomainXYPlot plot = createRelativeTimeSeriesPlot();
    JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    chartCustomization(chart);//  ww w  .j  a  v  a  2  s . c  om

    final XYPlot intensityPlot = createIntensityPlot(intensities);
    plot.add(intensityPlot, 1);

    return chart;
}

From source file:org.jfree.chart.demo.SymbolicXYPlotDemo.java

/**
 * Vertically combined sample1 and sample2 and display it.
 * /*  w  w  w  .  j  av  a  2s . co  m*/
 * @param frameTitle
 *           the frame title.
 * @param data1
 *           the dataset 1.
 * @param data2
 *           the dataset 2.
 */
private static void displayXYSymbolicCombinedVertically(final String frameTitle, final XYDataset data1,
        final XYDataset data2) {

    final String title = "Pollutant Vertically Combined";
    final String xAxisLabel = "Contamination and Type";
    final String yAxisLabel = "Pollutant";

    // combine the x symbolic values of the two data sets
    final String[] combinedXSymbolicValues = SampleXYSymbolicDataset
            .combineXSymbolicDataset((XisSymbolic) data1, (XisSymbolic) data2);

    // make master dataset...
    final CombinedDataset data = new CombinedDataset();
    data.add(data1);
    data.add(data2);

    // decompose data...
    final XYDataset series0 = new SubSeriesDataset(data, 0);
    final XYDataset series1 = new SubSeriesDataset(data, 1);

    // common horizontal and vertical axes
    final SymbolicAxis hsymbolicAxis = new SymbolicAxis(xAxisLabel, combinedXSymbolicValues);

    final SymbolicAxis vsymbolicAxis0 = new SymbolicAxis(yAxisLabel,
            ((YisSymbolic) data1).getYSymbolicValues());

    final SymbolicAxis vsymbolicAxis1 = new SymbolicAxis(yAxisLabel,
            ((YisSymbolic) data2).getYSymbolicValues());

    // create the main plot...
    final CombinedDomainXYPlot mainPlot = new CombinedDomainXYPlot(hsymbolicAxis);

    // add the sub-plots...
    final XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null);
    final XYPlot subplot0 = new XYPlot(series0, null, vsymbolicAxis0, renderer);
    final XYPlot subplot1 = new XYPlot(series1, null, vsymbolicAxis1, renderer);

    mainPlot.add(subplot0, 1);
    mainPlot.add(subplot1, 1);

    // make the chart...
    final JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, mainPlot, true);
    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue));

    // and present it in a frame...
    final JFrame frame = new ChartFrame(frameTitle, chart);
    frame.pack();
    RefineryUtilities.positionFrameRandomly(frame);
    frame.show();

}

From source file:tools.descartes.bungee.chart.ChartGenerator.java

public static JFreeChart createTimeSeriesChart(final List<XYPlot> plots) {
    final CombinedDomainXYPlot plot = createRelativeTimeSeriesPlot();
    plot.setGap(20);/*  w ww . j av a2 s .co  m*/
    JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    boolean manyCharts = plots.size() > 3;
    int num = 0;
    for (XYPlot xyPlot : plots) {
        num++;
        if (manyCharts && xyPlot.getRangeAxis().getLabel() == "Arrival Rate [1/s]") {
            plot.add(xyPlot, 3);
        } else {
            plot.add(xyPlot, 1);
        }

        chart.setBackgroundPaint(Color.white);
        customizePlot(xyPlot);
        if (manyCharts && xyPlot.getRangeAxis().getLabel() != "Arrival Rate [1/s]" && num != 4 && num != 7) {
            xyPlot.getRangeAxis().setLabel("");
        }
    }
    return chart;
}

From source file:net.sf.mzmine.chartbasics.gui.javafx.demo.FXCombinedChartGestureDemo.java

private JFreeChart createCombinedChart() {
    // create subplot 1...
    final XYDataset data1 = createDataset();
    final XYItemRenderer renderer1 = new StandardXYItemRenderer();
    final NumberAxis rangeAxis1 = new NumberAxis("Range 1");
    final XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1);

    // create subplot 2...
    final XYDataset data2 = createDataset();
    final XYItemRenderer renderer2 = new StandardXYItemRenderer();
    final NumberAxis rangeAxis2 = new NumberAxis("Range 2");
    final XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2);

    // parent plot...
    final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Domain"));
    plot.setGap(10.0);//  ww  w  . ja v a2  s  .  co  m

    // add the subplots...
    plot.add(subplot1, 1);
    plot.add(subplot2, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);

    // return a new chart containing the overlaid plot...
    return new JFreeChart("CombinedDomainXYPlot Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
}

From source file:sernet.gs.ui.rcp.main.bsi.views.chart.RealisierungLineChart.java

private JFreeChart createProgressChart(Object dataset) {
    final double plotGap = 10.0;
    final int axisUpperBoundPadding = 50;
    final int labelFontSize = 10;
    XYDataset data1 = (XYDataset) dataset;
    XYItemRenderer renderer1 = new StandardXYItemRenderer();
    NumberAxis rangeAxis1 = new NumberAxis(Messages.RealisierungLineChart_1);
    XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1);
    subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new DateAxis(Messages.RealisierungLineChart_2));
    plot.setGap(plotGap);/*from  w w w.  ja  v a 2 s .c  o  m*/

    plot.add(subplot1, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);

    CountMassnahmen command = new CountMassnahmen();
    try {
        command = ServiceFactory.lookupCommandService().executeCommand(command);
    } catch (CommandException e) {
        ExceptionUtil.log(e, Messages.RealisierungLineChart_3);
    }
    int totalNum = command.getTotalCount();

    NumberAxis axis = (NumberAxis) subplot1.getRangeAxis();
    axis.setUpperBound(totalNum + axisUpperBoundPadding);

    ValueMarker bst = new ValueMarker(totalNum);
    bst.setPaint(Color.GREEN);
    bst.setLabel(Messages.RealisierungLineChart_4);
    bst.setLabelAnchor(RectangleAnchor.LEFT);
    bst.setLabelFont(new Font("SansSerif", Font.ITALIC + Font.BOLD, labelFontSize)); //$NON-NLS-1$
    bst.setLabelTextAnchor(TextAnchor.CENTER_LEFT);
    subplot1.addRangeMarker(bst, Layer.BACKGROUND);

    // return a new chart containing the overlaid plot...
    JFreeChart chart = new JFreeChart(Messages.RealisierungLineChart_6, JFreeChart.DEFAULT_TITLE_FONT, plot,
            true);
    chart.setBackgroundPaint(Color.white);
    return chart;
}

From source file:com.bt.aloha.batchtest.Chart.java

private JFreeChart createCombinedChart(XYDataset xydataset1, String titleX1, String labelX1, String labelY1,
        XYDataset xydataset2, String titleX2, String labelX2, String labelY2) {
    CombinedDomainXYPlot combineddomainxyplot = new CombinedDomainXYPlot(new NumberAxis("threads"));
    combineddomainxyplot.setGap(10D);//from  ww w.j a  v  a 2 s .  c o m
    combineddomainxyplot.add(createChart(xydataset1, titleX1, labelX1, labelY1).getXYPlot(), 1);
    combineddomainxyplot.add(createChart(xydataset2, titleX2, labelX2, labelY2).getXYPlot(), 1);
    combineddomainxyplot.setOrientation(PlotOrientation.VERTICAL);
    return new JFreeChart("Historical", JFreeChart.DEFAULT_TITLE_FONT, combineddomainxyplot, true);
}

From source file:com.itemanalysis.jmetrik.graph.itemmap.ItemMapPanel.java

public void setGraph() {
    HistogramChartDataset personDataset = null;
    HistogramChartDataset itemData = null;

    try {//from ww w .j a  v a  2s. c  o  m
        //get titles
        String chartTitle = command.getFreeOption("title").getString();
        String chartSubtitle = command.getFreeOption("subtitle").getString();
        PlotOrientation itemMapOrientation = PlotOrientation.HORIZONTAL;

        //create common x-axis
        NumberAxis domainAxis = new NumberAxis();
        domainAxis.setLabel("Logits");

        //create histogram
        personDataset = new HistogramChartDataset();
        ValueAxis rangeAxis = new NumberAxis("Person Density");
        if (itemMapOrientation == PlotOrientation.HORIZONTAL)
            rangeAxis.setInverted(true);
        XYBarRenderer renderer = new XYBarRenderer();
        renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
        renderer.setURLGenerator(new StandardXYURLGenerator());
        renderer.setDrawBarOutline(true);
        renderer.setShadowVisible(false);
        XYPlot personPlot = new XYPlot(personDataset, null, rangeAxis, renderer);
        personPlot.setOrientation(PlotOrientation.HORIZONTAL);

        //create scatterplot of item difficulty
        itemData = new HistogramChartDataset();
        NumberAxis itemRangeAxis = new NumberAxis("Item Frequency");
        if (itemMapOrientation == PlotOrientation.VERTICAL) {
            itemRangeAxis.setInverted(true);
        }

        XYBarRenderer itemRenderer = new XYBarRenderer();
        itemRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
        itemRenderer.setURLGenerator(new StandardXYURLGenerator());
        itemRenderer.setDrawBarOutline(true);
        itemRenderer.setShadowVisible(false);
        XYPlot itemPlot = new XYPlot(itemData, null, itemRangeAxis, itemRenderer);
        itemPlot.setOrientation(PlotOrientation.HORIZONTAL);

        //combine the two charts
        CombinedDomainXYPlot cplot = new CombinedDomainXYPlot(domainAxis);
        cplot.add(personPlot, 3);
        cplot.add(itemPlot, 2);
        cplot.setGap(8.0);
        cplot.setDomainGridlinePaint(Color.white);
        cplot.setDomainGridlinesVisible(true);
        cplot.setOrientation(itemMapOrientation);

        //            //next four lines are temp setting for book
        //            //these four lines will create a histogram with white bars so it appears as just the bar outline
        //            renderer.setBarPainter(new StandardXYBarPainter());
        //            renderer.setSeriesPaint(0, Color.white);
        //            itemRenderer.setBarPainter(new StandardXYBarPainter());
        //            itemRenderer.setSeriesPaint(0, Color.white);

        chart = new JFreeChart(chartTitle, JFreeChart.DEFAULT_TITLE_FONT, cplot, false);
        chart.setBackgroundPaint(Color.white);
        if (chartSubtitle != null && !"".equals(chartSubtitle)) {
            chart.addSubtitle(new TextTitle(chartSubtitle));
        }

        ChartPanel panel = new ChartPanel(chart);
        panel.getPopupMenu().addSeparator();
        this.addJpgMenuItem(this, panel.getPopupMenu());
        panel.setPreferredSize(new Dimension(width, height));

        //            //temp setting for book
        //            this.addLocalEPSMenuItem(this, panel.getPopupMenu(), chart);//remove this line for public release versions

        chart.setPadding(new RectangleInsets(20.0, 5.0, 20.0, 5.0));
        this.setBackground(Color.WHITE);
        this.add(panel);
    } catch (IllegalArgumentException ex) {
        logger.fatal(ex.getMessage(), ex);
        this.firePropertyChange("error", "", "Error - Check log for details.");
    }

}