Java Code Examples for org.jfree.chart.plot.XYPlot#setDomainAxis()

The following examples show how to use org.jfree.chart.plot.XYPlot#setDomainAxis() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChartPanelTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks that a call to the zoomInDomain() method, for a plot with more
 * than one domain axis, generates just one ChartChangeEvent.
 */
@Test
public void test2502355_zoomInDomain() {
    DefaultXYDataset dataset = new DefaultXYDataset();
    JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X",
            "Y", dataset, PlotOrientation.VERTICAL, false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDomainAxis(1, new NumberAxis("X2"));
    ChartPanel panel = new ChartPanel(chart);
    chart.addChangeListener(this);
    this.chartChangeEvents.clear();
    panel.zoomInDomain(1.0, 2.0);
    assertEquals(1, this.chartChangeEvents.size());
}
 
Example 2
Source File: ChartPanelTest.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Checks that a call to the zoomInDomain() method, for a plot with more
 * than one domain axis, generates just one ChartChangeEvent.
 */
@Test
public void test2502355_zoomInDomain() {
    DefaultXYDataset dataset = new DefaultXYDataset();
    JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X",
            "Y", dataset, PlotOrientation.VERTICAL, false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDomainAxis(1, new NumberAxis("X2"));
    ChartPanel panel = new ChartPanel(chart);
    chart.addChangeListener(this);
    this.chartChangeEvents.clear();
    panel.zoomInDomain(1.0, 2.0);
    assertEquals(1, this.chartChangeEvents.size());
}
 
Example 3
Source File: PannableTimeChartPanel.java    From jsonde with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public PannableTimeChartPanel(long startTime, long endTime, TimeSeriesCollection dataset) {

        double interval = ((endTime - startTime) / (30000.));

        JFreeChart chart = ChartFactory.createXYLineChart(
                "Memory Telemtry View", "Time",
                "Memory (Mb)", dataset, PlotOrientation.VERTICAL,
                true, true, false
        );

        plot = (XYPlot) chart.getPlot();

        DateAxis domainAxis = new DateAxis();
        plot.setDomainAxis(domainAxis);
        domainAxis.setLabelAngle(Math.PI / 2);
        domainAxis.setAutoRange(true);
        domainAxis.setMinimumDate(new Date(startTime));
        domainAxis.setMaximumDate(new Date(startTime + 30L * 1000L));

        plot.setDomainPannable(true);

        setLayout(new BorderLayout());

        add(new ChartPanel(chart), BorderLayout.CENTER);
        JScrollBar panScrollBar = new JScrollBar(JScrollBar.HORIZONTAL);

        rangeModel = new DefaultBoundedRangeModel();
        rangeModel.setMinimum(0);
        rangeModel.setMaximum((int)((interval - 1) * 100));
        rangeModel.addChangeListener(this);

        panScrollBar.setModel(rangeModel);

        add(panScrollBar, BorderLayout.SOUTH);

    }
 
Example 4
Source File: ChartPanelTest.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Checks that a call to the restoreAutoDomainBounds() method, for a plot
 * with more than one range axis, generates just one ChartChangeEvent.
 */
@Test
public void test2502355_restoreAutoDomainBounds() {
    DefaultXYDataset dataset = new DefaultXYDataset();
    JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X",
            "Y", dataset, PlotOrientation.VERTICAL, false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDomainAxis(1, new NumberAxis("X2"));
    ChartPanel panel = new ChartPanel(chart);
    chart.addChangeListener(this);
    this.chartChangeEvents.clear();
    panel.restoreAutoDomainBounds();
    assertEquals(1, this.chartChangeEvents.size());
}
 
Example 5
Source File: ChartPanelTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks that a call to the zoomOutDomain() method, for a plot with more
 * than one domain axis, generates just one ChartChangeEvent.
 */
public void test2502355_zoomOutDomain() {
    DefaultXYDataset dataset = new DefaultXYDataset();
    JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X",
            "Y", dataset, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDomainAxis(1, new NumberAxis("X2"));
    ChartPanel panel = new ChartPanel(chart);
    chart.addChangeListener(this);
    this.chartChangeEvents.clear();
    panel.zoomOutDomain(1.0, 2.0);
    assertEquals(1, this.chartChangeEvents.size());
}
 
Example 6
Source File: ChartPanelTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks that a call to the zoomInDomain() method, for a plot with more
 * than one domain axis, generates just one ChartChangeEvent.
 */
public void test2502355_zoomInDomain() {
    DefaultXYDataset dataset = new DefaultXYDataset();
    JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X",
            "Y", dataset, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDomainAxis(1, new NumberAxis("X2"));
    ChartPanel panel = new ChartPanel(chart);
    chart.addChangeListener(this);
    this.chartChangeEvents.clear();
    panel.zoomInDomain(1.0, 2.0);
    assertEquals(1, this.chartChangeEvents.size());
}
 
Example 7
Source File: ChartPanelTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks that a call to the restoreAutoDomainBounds() method, for a plot
 * with more than one range axis, generates just one ChartChangeEvent.
 */
@Test
public void test2502355_restoreAutoDomainBounds() {
    DefaultXYDataset dataset = new DefaultXYDataset();
    JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X",
            "Y", dataset, PlotOrientation.VERTICAL, false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDomainAxis(1, new NumberAxis("X2"));
    ChartPanel panel = new ChartPanel(chart);
    chart.addChangeListener(this);
    this.chartChangeEvents.clear();
    panel.restoreAutoDomainBounds();
    assertEquals(1, this.chartChangeEvents.size());
}
 
Example 8
Source File: ChartPanelTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks that a call to the zoomOutDomain() method, for a plot with more
 * than one domain axis, generates just one ChartChangeEvent.
 */
@Test
public void test2502355_zoomOutDomain() {
    DefaultXYDataset dataset = new DefaultXYDataset();
    JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X",
            "Y", dataset, PlotOrientation.VERTICAL, false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDomainAxis(1, new NumberAxis("X2"));
    ChartPanel panel = new ChartPanel(chart);
    chart.addChangeListener(this);
    this.chartChangeEvents.clear();
    panel.zoomOutDomain(1.0, 2.0);
    assertEquals(1, this.chartChangeEvents.size());
}
 
Example 9
Source File: ChartPanelTest.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Checks that a call to the zoomOutDomain() method, for a plot with more
 * than one domain axis, generates just one ChartChangeEvent.
 */
@Test
public void test2502355_zoomOutDomain() {
    DefaultXYDataset dataset = new DefaultXYDataset();
    JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X",
            "Y", dataset, PlotOrientation.VERTICAL, false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDomainAxis(1, new NumberAxis("X2"));
    ChartPanel panel = new ChartPanel(chart);
    chart.addChangeListener(this);
    this.chartChangeEvents.clear();
    panel.zoomOutDomain(1.0, 2.0);
    assertEquals(1, this.chartChangeEvents.size());
}
 
Example 10
Source File: RenderUtils.java    From heroic with Apache License 2.0 5 votes vote down vote up
private static JFreeChart buildChart(
    final String title, final XYDataset lineAndShape, final XYDataset interval,
    final XYItemRenderer lineAndShapeRenderer, final XYItemRenderer intervalRenderer
) {
    final ValueAxis timeAxis = new DateAxis();
    timeAxis.setLowerMargin(0.02);
    timeAxis.setUpperMargin(0.02);

    final NumberAxis valueAxis = new NumberAxis();
    valueAxis.setAutoRangeIncludesZero(false);

    final XYPlot plot = new XYPlot();

    plot.setDomainAxis(0, timeAxis);
    plot.setRangeAxis(0, valueAxis);

    plot.setDataset(0, lineAndShape);
    plot.setRenderer(0, lineAndShapeRenderer);

    plot.setDomainAxis(1, timeAxis);
    plot.setRangeAxis(1, valueAxis);

    plot.setDataset(1, interval);
    plot.setRenderer(1, intervalRenderer);

    return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
}
 
Example 11
Source File: ChartPanelTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Checks that a call to the restoreAutoDomainBounds() method, for a plot
 * with more than one range axis, generates just one ChartChangeEvent.
 */
@Test
public void test2502355_restoreAutoDomainBounds() {
    DefaultXYDataset dataset = new DefaultXYDataset();
    JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X",
            "Y", dataset, PlotOrientation.VERTICAL, false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDomainAxis(1, new NumberAxis("X2"));
    ChartPanel panel = new ChartPanel(chart);
    chart.addChangeListener(this);
    this.chartChangeEvents.clear();
    panel.restoreAutoDomainBounds();
    assertEquals(1, this.chartChangeEvents.size());
}
 
Example 12
Source File: ChartPanelTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Checks that a call to the zoomOutDomain() method, for a plot with more
 * than one domain axis, generates just one ChartChangeEvent.
 */
@Test
public void test2502355_zoomOutDomain() {
    DefaultXYDataset dataset = new DefaultXYDataset();
    JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X",
            "Y", dataset, PlotOrientation.VERTICAL, false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDomainAxis(1, new NumberAxis("X2"));
    ChartPanel panel = new ChartPanel(chart);
    chart.addChangeListener(this);
    this.chartChangeEvents.clear();
    panel.zoomOutDomain(1.0, 2.0);
    assertEquals(1, this.chartChangeEvents.size());
}
 
Example 13
Source File: ChartPanelTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Checks that a call to the zoomInDomain() method, for a plot with more
 * than one domain axis, generates just one ChartChangeEvent.
 */
@Test
public void test2502355_zoomInDomain() {
    DefaultXYDataset dataset = new DefaultXYDataset();
    JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X",
            "Y", dataset, PlotOrientation.VERTICAL, false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDomainAxis(1, new NumberAxis("X2"));
    ChartPanel panel = new ChartPanel(chart);
    chart.addChangeListener(this);
    this.chartChangeEvents.clear();
    panel.zoomInDomain(1.0, 2.0);
    assertEquals(1, this.chartChangeEvents.size());
}
 
Example 14
Source File: ChartPanelTest.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Checks that a call to the restoreAutoDomainBounds() method, for a plot
 * with more than one range axis, generates just one ChartChangeEvent.
 */
@Test
public void test2502355_restoreAutoDomainBounds() {
    DefaultXYDataset dataset = new DefaultXYDataset();
    JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X",
            "Y", dataset, PlotOrientation.VERTICAL, false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDomainAxis(1, new NumberAxis("X2"));
    ChartPanel panel = new ChartPanel(chart);
    chart.addChangeListener(this);
    this.chartChangeEvents.clear();
    panel.restoreAutoDomainBounds();
    assertEquals(1, this.chartChangeEvents.size());
}
 
Example 15
Source File: ChartPanelTest.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Checks that a call to the zoomOutDomain() method, for a plot with more
 * than one domain axis, generates just one ChartChangeEvent.
 */
@Test
public void test2502355_zoomOutDomain() {
    DefaultXYDataset dataset = new DefaultXYDataset();
    JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X",
            "Y", dataset, PlotOrientation.VERTICAL, false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDomainAxis(1, new NumberAxis("X2"));
    ChartPanel panel = new ChartPanel(chart);
    chart.addChangeListener(this);
    this.chartChangeEvents.clear();
    panel.zoomOutDomain(1.0, 2.0);
    assertEquals(1, this.chartChangeEvents.size());
}
 
Example 16
Source File: ChartPanelTest.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Checks that a call to the zoomInDomain() method, for a plot with more
 * than one domain axis, generates just one ChartChangeEvent.
 */
@Test
public void test2502355_zoomInDomain() {
    DefaultXYDataset dataset = new DefaultXYDataset();
    JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X",
            "Y", dataset, PlotOrientation.VERTICAL, false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDomainAxis(1, new NumberAxis("X2"));
    ChartPanel panel = new ChartPanel(chart);
    chart.addChangeListener(this);
    this.chartChangeEvents.clear();
    panel.zoomInDomain(1.0, 2.0);
    assertEquals(1, this.chartChangeEvents.size());
}
 
Example 17
Source File: ChartPanelTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Checks that a call to the restoreAutoDomainBounds() method, for a plot
 * with more than one range axis, generates just one ChartChangeEvent.
 */
@Test
public void test2502355_restoreAutoDomainBounds() {
    DefaultXYDataset dataset = new DefaultXYDataset();
    JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X",
            "Y", dataset, PlotOrientation.VERTICAL, false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDomainAxis(1, new NumberAxis("X2"));
    ChartPanel panel = new ChartPanel(chart);
    chart.addChangeListener(this);
    this.chartChangeEvents.clear();
    panel.restoreAutoDomainBounds();
    assertEquals(1, this.chartChangeEvents.size());
}
 
Example 18
Source File: ChartPanelTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Checks that a call to the zoomOutDomain() method, for a plot with more
 * than one domain axis, generates just one ChartChangeEvent.
 */
@Test
public void test2502355_zoomOutDomain() {
    DefaultXYDataset dataset = new DefaultXYDataset();
    JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X",
            "Y", dataset, PlotOrientation.VERTICAL, false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDomainAxis(1, new NumberAxis("X2"));
    ChartPanel panel = new ChartPanel(chart);
    chart.addChangeListener(this);
    this.chartChangeEvents.clear();
    panel.zoomOutDomain(1.0, 2.0);
    assertEquals(1, this.chartChangeEvents.size());
}
 
Example 19
Source File: Scatter.java    From hortonmachine with GNU General Public License v3.0 4 votes vote down vote up
public JFreeChart getChart() {
    if (chart == null) {
        chart = ChartFactory.createXYLineChart(title, // chart title
                xLabel,
                // domain axis label
                yLabel,
                // range axis label
                dataset,
                // data
                PlotOrientation.VERTICAL,
                // orientation
                true,
                // include legend
                true,
                // tooltips?
                false
        // URLs?
        );

        XYPlot plot = (XYPlot) chart.getPlot();
        if (xLog) {
            LogAxis xAxis = new LogAxis("");
            xAxis.setBase(10);
            plot.setDomainAxis(xAxis);
        }
        if (yLog) {
            LogAxis yAxis = new LogAxis("");
            yAxis.setBase(10);
            plot.setRangeAxis(yAxis);
        }

        if (colors == null) {
            colors = ColorBrewer.getPairedColors(dataset.getSeriesCount());
        }
        for( int i = 0; i < colors.length; i++ ) {
            plot.getRenderer().setSeriesPaint(i, colors[i]);
        }

        ValueAxis rangeAxis = plot.getRangeAxis();
        if (rangeAxis instanceof NumberAxis) {
            NumberAxis axis = (NumberAxis) rangeAxis;
            axis.setAutoRangeIncludesZero(false);
        }

        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
        double x = 1.5;
        double w = x * 2;
        renderer.setSeriesShape(0, new Ellipse2D.Double(-x, x, w, w));
        setShapeLinesVisibility(plot);
    }
    return chart;
}
 
Example 20
Source File: ScatterPlotPanel.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
private void createUI() {

        final XYPlot plot = getPlot();
        plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));
        plot.setNoDataMessage(NO_DATA_MESSAGE);
        int confidenceDSIndex = 0;
        int regressionDSIndex = 1;
        int scatterpointsDSIndex = 2;
        plot.setDataset(confidenceDSIndex, acceptableDeviationDataset);
        plot.setDataset(regressionDSIndex, regressionDataset);
        plot.setDataset(scatterpointsDSIndex, scatterpointsDataset);

        plot.addAnnotation(r2Annotation);

        final DeviationRenderer identityRenderer = new DeviationRenderer(true, false);
        identityRenderer.setSeriesPaint(0, StatisticChartStyling.SAMPLE_DATA_PAINT);
        identityRenderer.setSeriesFillPaint(0, StatisticChartStyling.SAMPLE_DATA_FILL_PAINT);
        plot.setRenderer(confidenceDSIndex, identityRenderer);

        final DeviationRenderer regressionRenderer = new DeviationRenderer(true, false);
        regressionRenderer.setSeriesPaint(0, StatisticChartStyling.REGRESSION_DATA_PAINT);
        regressionRenderer.setSeriesFillPaint(0, StatisticChartStyling.REGRESSION_DATA_FILL_PAINT);
        plot.setRenderer(regressionDSIndex, regressionRenderer);

        final XYErrorRenderer scatterPointsRenderer = new XYErrorRenderer();
        scatterPointsRenderer.setDrawXError(true);
        scatterPointsRenderer.setErrorStroke(new BasicStroke(1));
        scatterPointsRenderer.setErrorPaint(StatisticChartStyling.CORRELATIVE_POINT_OUTLINE_PAINT);
        scatterPointsRenderer.setSeriesShape(0, StatisticChartStyling.CORRELATIVE_POINT_SHAPE);
        scatterPointsRenderer.setSeriesOutlinePaint(0, StatisticChartStyling.CORRELATIVE_POINT_OUTLINE_PAINT);
        scatterPointsRenderer.setSeriesFillPaint(0, StatisticChartStyling.CORRELATIVE_POINT_FILL_PAINT);
        scatterPointsRenderer.setSeriesLinesVisible(0, false);
        scatterPointsRenderer.setSeriesShapesVisible(0, true);
        scatterPointsRenderer.setSeriesOutlineStroke(0, new BasicStroke(1.0f));
        scatterPointsRenderer.setSeriesToolTipGenerator(0, (dataset, series, item) -> {
            final XYIntervalSeriesCollection collection = (XYIntervalSeriesCollection) dataset;
            final Comparable key = collection.getSeriesKey(series);
            final double xValue = collection.getXValue(series, item);
            final double endYValue = collection.getEndYValue(series, item);
            final double yValue = collection.getYValue(series, item);
            return String.format("%s: mean = %6.2f, sigma = %6.2f | %s: value = %6.2f",
                                 getRasterName(), yValue, endYValue - yValue,
                                 key, xValue);
        });
        plot.setRenderer(scatterpointsDSIndex, scatterPointsRenderer);

        final boolean autoRangeIncludesZero = false;
        final boolean xLog = scatterPlotModel.xAxisLogScaled;
        final boolean yLog = scatterPlotModel.yAxisLogScaled;
        plot.setDomainAxis(
                StatisticChartStyling.updateScalingOfAxis(xLog, plot.getDomainAxis(), autoRangeIncludesZero));
        plot.setRangeAxis(StatisticChartStyling.updateScalingOfAxis(yLog, plot.getRangeAxis(), autoRangeIncludesZero));

        createUI(createChartPanel(chart), createInputParameterPanel(), bindingContext);

        plot.getDomainAxis().addChangeListener(domainAxisChangeListener);
        scatterPlotDisplay.setMouseWheelEnabled(true);
        scatterPlotDisplay.setMouseZoomable(true);
    }