Example usage for org.jfree.chart.plot XYPlot getDomainAxis

List of usage examples for org.jfree.chart.plot XYPlot getDomainAxis

Introduction

In this page you can find the example usage for org.jfree.chart.plot XYPlot getDomainAxis.

Prototype

public ValueAxis getDomainAxis() 

Source Link

Document

Returns the domain axis with index 0.

Usage

From source file:entrenamiento.grafica2.java

public grafica2() {
    XYSeries sxy = new XYSeries("pesos");
    datosxy.removeAllSeries();/* ww  w .  j a v  a 2  s . c  om*/
    //sxy.add(x[0], y[0]);
    y = new double[Entrenamiento2.valor.length];
    y = Entrenamiento2.valor;
    int n = y.length;
    for (int i = 0; i < n; i++) {
        sxy.add(i, y[i]);
        // System.out.print(x[i]+"-"+i+" ");
    }
    datosxy.addSeries(sxy);
    graficaxy = ChartFactory.createXYLineChart("Grafica de Progreso", "tiempo", "RM-pesos", datosxy,
            PlotOrientation.VERTICAL, true, true, true);
    graficaxy.setBackgroundPaint(Color.white);
    XYPlot plot = (XYPlot) graficaxy.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    configurarDomainAxis(domainAxis);

    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);
        renderer.setDrawSeriesLineAsPath(true);
    }
}

From source file:CargarEntrenamiento.grafica2.java

public grafica2() {
    datosxy.removeAllSeries();/*from  w  ww .  j  a  va 2  s  .c o  m*/
    XYSeries sxy = new XYSeries("pesos");
    //sxy.add(x[0], y[0]);
    y = new double[cargarEntreno.valorentreno.length];
    y = cargarEntreno.valorentreno;
    int n = y.length;
    for (int i = 0; i < n; i++) {
        sxy.add(i, y[i]);
        // System.out.print(x[i]+"-"+i+" ");
    }
    datosxy.addSeries(sxy);
    graficaxy = ChartFactory.createXYLineChart("Grafica de Progreso", "tiempo", "RM-pesos", datosxy,
            PlotOrientation.VERTICAL, true, true, true);
    graficaxy.setBackgroundPaint(Color.white);
    XYPlot plot = (XYPlot) graficaxy.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    configurarDomainAxis(domainAxis);

    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);
        renderer.setDrawSeriesLineAsPath(true);
    }
}

From source file:org.zaproxy.zap.extension.customFire.ScanProgressDialog.java

/**
 * /* w  w  w .  ja  va2 s . c  o  m*/
 * @param dataset
 * @return JFreeChart `
 */
private JFreeChart createChart(final XYDataset dataset) {

    JFreeChart result = ChartFactory.createTimeSeriesChart(null, "Time", "Response/seconds", dataset, true,
            false, false);
    XYPlot plot = result.getXYPlot();
    ValueAxis daxis = plot.getDomainAxis();
    daxis.setAutoRange(true);
    daxis.setAutoRangeMinimumSize(60000.0);

    plot.getRangeAxis().setAutoRangeMinimumSize(20);

    return result;
}

From source file:com.github.dougkelly88.FLIMPlateReaderGUI.FLIMClasses.Classes.FindMaxpoint.java

/**
 * Creates a chart./*ww  w. j a v  a 2s.  co  m*/
 * 
 * @param dataset  the data for the chart.
 * 
 * @return a chart.
 */
public JFreeChart createChart() {

    //http://www.java2s.com/Code/Java/Chart/JFreeChartDualAxisDemo2.htm
    String xlabel = "Delay (ps)";
    String ylabel = "Signal (DN)";

    // create the chart with findmaxpoint results
    final JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title
            xlabel, // x axis label
            ylabel, // y axis label
            findMaxpointData_, // data
            PlotOrientation.VERTICAL, false, // include legend
            true, // tooltips
            false // urls
    );

    final XYPlot plot = chart.getXYPlot();
    // deal with axes and add second dataset
    final NumberAxis yaxis1 = (NumberAxis) plot.getRangeAxis();
    yaxis1.setTickLabelFont(new Font("Dialog", Font.PLAIN, 10));
    yaxis1.setLabelFont(new Font("Dialog", Font.PLAIN, 10));
    final NumberAxis yaxis2 = new NumberAxis(null);
    final NumberAxis xaxis = (NumberAxis) plot.getDomainAxis();
    xaxis.setTickLabelFont(new Font("Dialog", Font.PLAIN, 10));
    xaxis.setLabelFont(new Font("Dialog", Font.PLAIN, 10));
    plot.setRangeAxis(1, yaxis2);
    plot.setDataset(1, gatePositionData_);
    plot.mapDatasetToRangeAxis(1, 1);
    yaxis1.setRange(0, 5000);
    yaxis2.setRange(-1, 1);
    yaxis2.setTickLabelsVisible(false);
    xaxis.setRange(0, 16666);

    // deal with visuals

    final XYLineAndShapeRenderer renderer1 = new XYLineAndShapeRenderer(true, true);
    renderer1.setSeriesPaint(0, Color.RED);
    renderer1.setSeriesStroke(0, new BasicStroke(3));

    //        renderer1.setBaseShapesVisible(true);
    //        renderer1.setSeriesShape(0, ShapeUtilities.createDiagonalCross(4,1));

    plot.setRenderer(0, renderer1);

    //        final StandardXYItemRenderer renderer2 = new StandardXYItemRenderer();
    final XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(false, true);
    renderer2.setSeriesPaint(0, Color.CYAN);
    renderer2.setSeriesShapesFilled(0, Boolean.TRUE);
    renderer2.setBaseShapesVisible(true);
    renderer2.setShape(new Rectangle(-2, -100, 4, 200));
    renderer2.setOutlineStroke(new BasicStroke(1));
    renderer2.setOutlinePaint(Color.GRAY);
    renderer2.setUseOutlinePaint(true);
    plot.setRenderer(1, renderer2);

    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);
    //                
    return chart;

}

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

/**
 * Creates a sample chart./*from   www. j a v  a2s . c  o m*/
 * 
 * @param index  the chart index.
 * @param dataset  the dataset.
 * 
 * @return A chart.
 */
private JFreeChart createChart(int index, XYDataset dataset) {

    // create the chart...
    JFreeChart chart = ChartFactory.createXYLineChart("Chart " + (index + 1), // chart title
            "X", // x axis label
            "Y", // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, false, // include legend
            false, // tooltips
            false // urls
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    //        plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    StandardXYItemRenderer renderer = (StandardXYItemRenderer) plot.getRenderer();
    renderer.setPlotShapes(true);
    renderer.setShapesFilled(true);
    // change the auto tick unit selection to integer units only...
    ValueAxis domainAxis = plot.getDomainAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:slash.navigation.converter.gui.profileview.ProfileView.java

private XYPlot createPlot(JFreeChart chart) {
    XYPlot plot = chart.getXYPlot();
    plot.setForegroundAlpha(0.65F);/*from ww  w  . ja v a 2s  . c o m*/
    plot.setDomainGridlinesVisible(preferences.getBoolean(X_GRID_PREFERENCE, true));
    plot.setRangeGridlinesVisible(preferences.getBoolean(Y_GRID_PREFERENCE, true));

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(createIntegerTickUnits());
    Font font = new JLabel().getFont();
    rangeAxis.setLabelFont(font);

    NumberAxis valueAxis = (NumberAxis) plot.getDomainAxis();
    valueAxis.setStandardTickUnits(createIntegerTickUnits());
    valueAxis.setLowerMargin(0.0);
    valueAxis.setUpperMargin(0.0);
    valueAxis.setLabelFont(font);

    plot.getRenderer().setBaseToolTipGenerator(null);
    return plot;
}

From source file:de.uka.aifb.com.systemDynamics.gui.ModelExecutionChartPanel.java

/**
 * Creates the XY line chart.//  w  w w . ja  v a2s . co  m
 * 
 * @return XY line chart
 */
private JFreeChart createChart() {
    levelNodes = new LevelNode[model.getLevelNodes().size()];
    int i = 0;
    for (LevelNode levelNode : model.getLevelNodes()) {
        levelNodes[i++] = levelNode;
    }
    // sort level nodes alphabetically
    Arrays.sort(levelNodes);

    xySeriesArray = new XYSeries[levelNodes.length];
    XYSeriesCollection data = new XYSeriesCollection();
    for (i = 0; i < xySeriesArray.length; i++) {
        XYSeries xySeries = new XYSeries(levelNodes[i].getNodeName());
        xySeries.add(0.0, levelNodes[i].getCurrentValue());
        data.addSeries(xySeries);
        xySeriesArray[i] = xySeries;
    }
    nextRound = 1;

    chart = ChartFactory.createXYLineChart(null, messages.getString("ModelExecutionChartPanel.Round"),
            messages.getString("ModelExecutionChartPanel.Value"), data, PlotOrientation.VERTICAL, true, false,
            false);
    XYPlot plot = chart.getXYPlot();

    // horizontal axis range: 0 ... maximal rounds
    ((NumberAxis) (chart.getXYPlot().getDomainAxis())).setRangeType(RangeType.POSITIVE);
    plot.getDomainAxis().setAutoRangeMinimumSize(20);

    // only integer values as labels for horizontal axis
    plot.getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // number formatting according to current locale
    ((NumberAxis) (plot.getDomainAxis())).setNumberFormatOverride(NumberFormat.getIntegerInstance(locale));
    ((NumberAxis) (plot.getRangeAxis())).setNumberFormatOverride(NumberFormat.getInstance(locale));

    // legend at top position
    chart.getLegend().setPosition(RectangleEdge.TOP);

    return chart;
}

From source file:edu.ucla.stat.SOCR.chart.demo.LineChartDemo3.java

/**
 * Creates a chart.//  w  w  w .j a  v a 2s .  c o m
 * 
 * @param dataset  a dataset.
 * 
 * @return A chart based on the supplied dataset.
 */
protected JFreeChart createChart(XYDataset dataset) {

    JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title
            domainLabel, // x axis label
            rangeLabel, // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, !legendPanelOn, // include legend
            true, // tooltips
            false // urls
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

    // get a reference to the plot for further customisation...
    XYPlot plot = (XYPlot) chart.getPlot();
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);
    renderer.setDrawOutlines(true);
    renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());

    // change the auto tick unit selection to integer units only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    setXSummary(dataset);
    return chart;
}

From source file:vteaexploration.plottools.panels.XYChartPanel.java

private ChartPanel createChart(int x, int y, int l, String xText, String yText, String lText,
        Color imageGateColor) {/* w w w .  j  a  va  2  s  .c om*/

    XYShapeRenderer renderer = new XYShapeRenderer();
    XYShapeRenderer rendererGate = new XYShapeRenderer();

    PaintScaleLegend psl = new PaintScaleLegend(new LookupPaintScale(0, 100, new Color(0, 0, 0)),
            new NumberAxis(""));

    if (l > 0) {
        double max = getMaximumOfData((ArrayList) plotValues.get(1), l);
        double min = this.getMinimumOfData((ArrayList) plotValues.get(1), l);
        double range = max - min;

        if (max == 0) {
            max = 1;
        }

        //System.out.println("PROFILING-DETAILS: Points to plot: " + ((ArrayList) plotValues.get(1)).size());
        LookupPaintScale ps = new LookupPaintScale(min, max + 100, new Color(0, 0, 0));

        renderer.setPaintScale(ps);

        ps.add(min, TENPERCENT);
        ps.add(min + (1 * (range / 10)), XYChartPanel.TENPERCENT);
        ps.add(min + (2 * (range / 10)), XYChartPanel.TWENTYPERCENT);
        ps.add(min + (3 * (range / 10)), XYChartPanel.THIRTYPERCENT);
        ps.add(min + (4 * (range / 10)), XYChartPanel.FORTYPERCENT);
        ps.add(min + (5 * (range / 10)), XYChartPanel.FIFTYPERCENT);
        ps.add(min + (6 * (range / 10)), XYChartPanel.SIXTYPERCENT);
        ps.add(min + (7 * (range / 10)), XYChartPanel.SEVENTYPERCENT);
        ps.add(min + (8 * (range / 10)), XYChartPanel.EIGHTYPERCENT);
        ps.add(min + (9 * (range / 10)), XYChartPanel.NINETYPERCENT);
        ps.add(max, XYChartPanel.ALLPERCENT);

        NumberAxis lAxis = new NumberAxis(lText);
        lAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

        psl = new PaintScaleLegend(ps, lAxis);
        psl.setBackgroundPaint(VTC._VTC.BACKGROUND);
        psl.setPosition(RectangleEdge.RIGHT);
        psl.setMargin(4, 4, 40, 4);
        psl.setAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);

    } else {

        renderer.setBaseFillPaint(TENPERCENT);
    }

    Ellipse2D shape = new Ellipse2D.Double(0, 0, size, size);
    Ellipse2D shapeGate = new Ellipse2D.Double(-2, -2, size + 4, size + 4);

    renderer.setBaseShape(shape);

    rendererGate.setBaseShape(shapeGate);

    NumberAxis xAxis = new NumberAxis("");
    NumberAxis yAxis = new NumberAxis("");

    xAxis.setAutoRangeIncludesZero(false);
    yAxis.setAutoRangeIncludesZero(false);

    XYPlot plot = new XYPlot(createXYZDataset((ArrayList) plotValues.get(1), x, y, l), xAxis, yAxis, renderer);

    plot.getDomainAxis();
    plot.getRangeAxis();

    plot.setDomainPannable(false);
    plot.setRangePannable(false);

    plot.setRenderer(0, renderer);
    plot.setRenderer(1, rendererGate);

    plot.setDataset(0, createXYZDataset((ArrayList) plotValues.get(1), x, y, l));

    if (imageGate) {
        roiCreated(impoverlay);
        XYZDataset set = createXYZDataset(ImageGateOverlay, x, y, l);
        plot.setDataset(1, set);
        plot.setRenderer(1, new XYShapeRenderer() {
            @Override
            protected java.awt.Paint getPaint(XYDataset dataset, int series, int item) {
                return imageGateOutline;
            }

            @Override
            public Shape getItemShape(int row, int col) {
                return new Ellipse2D.Double(-2, -2, size + 4, size + 4);
            }
        });

    }
    //System.out.println("PROFILING: Generating plot with " + plot.getDatasetCount() + " datasets.");
    //System.out.println("PROFILING: Generating plot with " + ImageGateOverlay.size() + " objects gated.");

    try {
        if (getRangeofData((ArrayList) plotValues.get(1), x) > 16384) {
            LogAxis logAxisX = new LogAxis();
            logAxisX.setAutoRange(true);
            plot.setDomainAxis(logAxisX);
        }

        if (getRangeofData((ArrayList) plotValues.get(1), y) > 16384) {
            LogAxis logAxisY = new LogAxis();
            logAxisY.setAutoRange(true);
            plot.setRangeAxis(logAxisY);
        }
    } catch (NullPointerException e) {
    }
    ;

    JFreeChart chart = new JFreeChart("Plot of " + xText + " vs. " + yText, plot);

    chart.removeLegend();

    //LUT 
    if (l > 0)
        chart.addSubtitle(psl);

    //notifiyUpdatePlotWindowListeners();
    return new ChartPanel(chart, true, true, false, false, true);
}

From source file:edu.ucla.stat.SOCR.chart.demo.XYBarChartDemo1.java

protected JFreeChart createChart(IntervalXYDataset dataset) {
    JFreeChart chart = ChartFactory.createXYBarChart(chartTitle, domainLabel, true, rangeLabel, dataset,
            PlotOrientation.VERTICAL, !legendPanelOn, true, false);

    // then customise it a little...
    // chart.addSubtitle(new TextTitle("Source: http://www.amnestyusa.org/abolish/listbyyear.do"));
    chart.setBackgroundPaint(Color.white);

    XYPlot plot = chart.getXYPlot();
    plot.setRenderer(new ClusteredXYBarRenderer());
    XYItemRenderer renderer = plot.getRenderer();

    StandardXYToolTipGenerator generator = new StandardXYToolTipGenerator("{1} = {2}",
            new SimpleDateFormat("yyyy"), new DecimalFormat("0"));
    renderer.setBaseToolTipGenerator(generator);
    renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());

    plot.setBackgroundPaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.white);

    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    axis.setLowerMargin(0.01);//ww w  .  j  a va 2  s . co m
    axis.setUpperMargin(0.01);
    //      setXSummary(dataset);  X  is time
    return chart;
}