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:sim.app.sugarscape.Charts.java

JFreeChart createAgeHistoChart() {
    JFreeChart chart = ChartFactory.createHistogram("Age Distribution", "Age", "Count", model.age_hist_dataset,
            PlotOrientation.VERTICAL, true, true, false);
    model.age_histo_chart = chart;/*w w  w  .ja  va 2s.co  m*/

    //CategoryDataset dataset1 = createDataset1();
    NumberAxis rangeAxis1 = new NumberAxis("Age");
    rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    org.jfree.chart.axis.NumberAxis domainAxis = new NumberAxis("Bins");
    XYPlot plot = chart.getXYPlot();
    ValueAxis xAxis = plot.getDomainAxis();
    xAxis.setRange(0, 100);
    XYItemRenderer renderer1 = plot.getRenderer();
    renderer1.setSeriesPaint(0, Color.MAGENTA);
    return chart;
}

From source file:sim.app.sugarscape.Charts.java

JFreeChart createTradeChart() {
    JFreeChart chart = ChartFactory.createXYLineChart("Trading and Population over Time", "Time", "Level",
            model.agents_series_coll, PlotOrientation.VERTICAL, true, true, false);
    model.trade_chart = chart;/*  www.j av  a 2  s. c om*/
    NumberAxis rangeAxis1 = new NumberAxis("Time");
    rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    org.jfree.chart.axis.NumberAxis domainAxis = new NumberAxis("Bins");
    XYPlot plot = chart.getXYPlot();
    ValueAxis xAxis = plot.getDomainAxis();
    XYItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesPaint(0, Color.BLUE);
    plot.setDataset(1, model.trade_coll);
    XYItemRenderer rend2 = new StandardXYItemRenderer();
    //if (rend2 != null)
    rend2.setSeriesPaint(1, Color.BLACK);
    plot.setRenderer(1, rend2);
    return chart;
}

From source file:vteaexploration.plotgatetools.gates.PolygonGate.java

@Override
public void createInChartSpace(ChartPanel chart) {

    int[] x1Points = new int[vertices.size()];
    int[] y1Points = new int[vertices.size()];
    double xChartPoint;
    double yChartPoint;

    for (int i = 0; i <= vertices.size() - 1; i++) {
        x1Points[i] = (int) ((Point2D) vertices.get(i)).getX();
        y1Points[i] = (int) ((Point2D) vertices.get(i)).getY();
    }/*from w  ww.ja v  a 2  s. co  m*/

    for (int index = 0; index < x1Points.length; index++) {

        Rectangle2D plotArea = chart.getScreenDataArea();
        XYPlot plot = (XYPlot) chart.getChart().getPlot();
        xChartPoint = plot.getDomainAxis().java2DToValue(x1Points[index], plotArea, plot.getDomainAxisEdge());
        yChartPoint = plot.getRangeAxis().java2DToValue(y1Points[index], plotArea, plot.getRangeAxisEdge());

        this.verticesInChartSpace.add(new Point2D.Double(xChartPoint, yChartPoint));
    }

}

From source file:de.hs.mannheim.modUro.diagram.JCellCountDiagram.java

protected JFreeChart createChart(XYDataset dataset, String name) {
    String title = name;/*from w w  w . j  ava2s  .  co  m*/

    JFreeChart xyLineChart = ChartFactory.createXYLineChart(title, // title
            "t", // x-axis label
            "n", // y-axis label
            dataset);

    String fontName = "Palatino";
    xyLineChart.getTitle().setFont(new Font(fontName, Font.BOLD, 18));

    XYPlot plot = (XYPlot) xyLineChart.getPlot();
    plot.setDomainPannable(true);
    plot.setRangePannable(true);
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    plot.getDomainAxis().setLowerMargin(0.0);
    plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
    plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));
    plot.getRangeAxis().setLowerMargin(0.0);
    // plot.getRangeAxis().setRange(0.0, 1.01);
    plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
    plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.gray);
    xyLineChart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14));
    xyLineChart.getLegend().setFrame(BlockBorder.NONE);
    xyLineChart.getLegend().setHorizontalAlignment(HorizontalAlignment.CENTER);
    XYItemRenderer r = plot.getRenderer();
    // set the default stroke for all series
    int i = 0;
    for (String celltype : getTimeSeries().getDataSeriesNames()) {
        r.setSeriesPaint(i, CellTypeColor.getColor(celltype));
        i++;
    }
    r.setSeriesPaint(i, Color.BLACK);
    return xyLineChart;
}

From source file:net.nosleep.superanalyzer.analysis.views.PlayCountView.java

private void createChart() {
    _chart = ChartFactory.createXYBarChart(Misc.getString("PLAY_COUNT"), Misc.getString("PLAY_COUNT"), false,
            Misc.getString("NUMBER_OF_SONGS"), _dataset, PlotOrientation.VERTICAL, false, true, false);

    _chart.addSubtitle(HomePanel.createSubtitle(Misc.getString("PLAY_COUNT_SUBTITLE")));

    // then customise it a little...
    XYPlot plot = (XYPlot) _chart.getPlot();
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
    plot.setForegroundAlpha(0.75f);//from w  ww  .j  a v a 2s.co m

    ChartUtilities.applyCurrentTheme(_chart);

    renderer.setBarPainter(new StandardXYBarPainter());
    renderer.setShadowVisible(false);

    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);

    domainAxis.setLowerMargin(0);
    domainAxis.setUpperMargin(0);
    // domainAxis.setLowerBound(0);
    // domainAxis.setAutoRangeIncludesZero(true);
    // domainAxis.setAutoRangeStickyZero(true);

    Misc.formatChart(plot);
    renderer.setSeriesPaint(0, Theme.getColorSet()[1]);

}

From source file:sim.app.sugarscape.Charts.java

JFreeChart createChart2() {
    JFreeChart chart2 = ChartFactory.createXYLineChart("Wealth Distribution", // the title of the chart
            "Time step",
            //"% Population",                                          // the label for the X axis
            "Gini Coefficient",
            // % Wealththe label for the Y axis
            new XYSeriesCollection(model.gini_coeff), // the dataset for the chart
            PlotOrientation.VERTICAL, // the orientation of the chart
            true, // a flag specifying whether or not a legend is required
            true, // a flag specifying whether or not tooltips should be generated
            false); // a flag specifying whether or not the chart should generate URLs

    XYPlot plot = chart2.getXYPlot();

    ValueAxis xAxis = plot.getDomainAxis();
    xAxis.setFixedDimension(100);//  w w  w.j  a  va  2  s . c  om
    //xAxis.setRange(0,100);
    //yAxis.setRange(0,1);
    XYItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesPaint(0, Color.black);
    //System.out.println("done creating chart");
    return chart2;
}

From source file:net.sf.maltcms.chromaui.foldChangeViewer.tasks.FoldChangeViewLoaderWorker.java

private void configurePlot(XYPlot plot, RTUnit rtAxisUnit) {
    NumberAxis domainAxis = null;/*from  w  ww .  j  a va  2s  . c om*/
    if (plot.getDomainAxis() == null) {
        domainAxis = new NumberAxis("log2 fold change");
        plot.setDomainAxis(domainAxis);
    } else {
        domainAxis = (NumberAxis) plot.getDomainAxis();
    }
    //        domainAxis.setNumberFormatOverride(new RTNumberFormatter(rtAxisUnit));
    //        domainAxis.setLabel("RT[" + rtAxisUnit.name().toLowerCase() + "]");
    plot.setRangeZeroBaselineVisible(true);
    plot.setDomainZeroBaselineVisible(true);
    domainAxis.setAutoRange(true);
    domainAxis.setAutoRangeIncludesZero(false);
    NumberAxis rangeAxis = null;
    if (plot.getRangeAxis() == null) {
        rangeAxis = new NumberAxis("-log10 p-value");
        plot.setRangeAxis(rangeAxis);
    } else {
        rangeAxis = (NumberAxis) plot.getRangeAxis();
    }
    rangeAxis.setAutoRange(true);
    rangeAxis.setAutoRangeIncludesZero(true);
    Logger.getLogger(getClass().getName()).info("Adding chart");
    plot.setBackgroundPaint(Color.WHITE);
    ChartCustomizer.setSeriesColors(plot, 0.8f);
}

From source file:io.sanfran.wikiTrends.extraction.plots.PlotTimeSeries.java

private static JFreeChart createChart(XYDataset dataset, String title) {

    JFreeChart chart = ChartFactory.createTimeSeriesChart(title, // title
            "Date", // x-axis label
            "Page visits", // y-axis label
            dataset, // data
            true, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );//from   ww  w  . ja v a 2s.  c om

    chart.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) chart.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);

    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(false); // if you want visible dots -> true
        renderer.setBaseShapesFilled(false); // if you want visible dots -> true

        if (seriesWidth != null) {
            for (int i = 0; i < seriesWidth.size(); i++) {
                renderer.setSeriesStroke(i, new BasicStroke(seriesWidth.get(i)));
            }
        }
        if (seriesColor != null) {
            for (int i = 0; i < seriesColor.size(); i++) {
                renderer.setSeriesPaint(i, seriesColor.get(i));
            }
        }

    }

    DateAxis axis = (DateAxis) plot.getDomainAxis();
    //axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
    axis.setDateFormatOverride(new SimpleDateFormat("dd-MM-yyyy"));

    return chart;

}

From source file:carfuzzy.Operations.java

public JFreeChart setYAxisForImplication(double imp, XYSeries series, XYSeriesCollection collection,
        Output out) {//from   ww w  .j av  a2s  .  co  m
    JFreeChart chart;
    if (out == Output.stop) {
        series.updateByIndex(0, imp);
        series.updateByIndex(1, imp);
        series.updateByIndex(2, imp);
    } else if (out == Output.speedUp) {
        series.updateByIndex(1, imp);
        series.updateByIndex(2, imp);
        series.updateByIndex(3, imp);
    } else {
        series.updateByIndex(1, imp);
        series.updateByIndex(2, imp);
    }
    collection.addSeries(series);
    String x_axis = "Implication";

    chart = XYGraph.drawChart(collection, x_axis, "Membership");
    XYPlot plot = chart.getXYPlot();
    ValueAxis xaxis = plot.getDomainAxis();
    xaxis.setRange(0, 10);
    XYItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesStroke(0, new BasicStroke(3.5f));
    return chart;
}

From source file:api3.transform.PlotWave.java

public void plot(double[][] signal, String name, long samplerate) {

    frame.setTitle(name);/*from  ww w  .j  a v  a2  s . c o m*/

    XYSeries[] soundWave = new XYSeries[signal.length];
    for (int j = 0; j < signal.length; ++j) {
        soundWave[j] = new XYSeries("sygnal" + j);
        for (int i = 0; i < signal[0].length; ++i) {
            double index = (samplerate == 0) ? i : 1000.0 * (double) i / (double) samplerate;
            soundWave[j].add(index, signal[j][i]);
        }
    }

    XYSeriesCollection dataset = new XYSeriesCollection();
    for (int j = 0; j < signal.length; ++j) {
        dataset.addSeries(soundWave[j]);
    }

    JFreeChart chart = //            (samplerate ==0 )?
            //            ChartFactory.createXYBarChart(
            //            name,
            //            "prbka",
            //            false,
            //            "warto",
            //            new XYBarDataset(dataset,0.0625),
            //            PlotOrientation.VERTICAL,
            //            true,false,false)
            //            :
            ChartFactory.createXYLineChart(name, "prbka", "warto", dataset,
                    PlotOrientation.VERTICAL, true, false, false);

    XYPlot plot = (XYPlot) chart.getPlot();

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

    slider.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent event) {
            int value = slider.getValue();
            double minimum = domainAxis.getRange().getLowerBound();
            double maximum = domainAxis.getRange().getUpperBound();
            double delta = (0.1f * (domainAxis.getRange().getLength()));
            if (value < lastValue) { // left
                minimum = minimum - delta;
                maximum = maximum - delta;
            } else { // right
                minimum = minimum + delta;
                maximum = maximum + delta;
            }
            DateRange range = new DateRange(minimum, maximum);
            domainAxis.setRange(range);
            lastValue = value;
            if (lastValue == slider.getMinimum() || lastValue == slider.getMaximum()) {
                slider.setValue(SLIDER_DEFAULT_VALUE);
            }
        }

    });

    plot.addRangeMarker(new ValueMarker(0, Color.BLACK, new BasicStroke(1)));

    ChartPanel chartPanel = new ChartPanel(chart);
    Border border = BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4),
            BorderFactory.createEtchedBorder());
    chartPanel.setBorder(border);

    chartPanel.addMouseWheelListener(addZoomWheel());

    panel.add(chartPanel);
    JPanel dashboard = new JPanel(new BorderLayout());
    dashboard.setBorder(BorderFactory.createEmptyBorder(0, 4, 4, 4));
    dashboard.add(slider);
    panel.add(dashboard, BorderLayout.SOUTH);

    frame.getContentPane().add((JPanel) panel, BorderLayout.CENTER);

    frame.pack();
    frame.setVisible(true);
}