Example usage for org.jfree.chart.axis NumberAxis createIntegerTickUnits

List of usage examples for org.jfree.chart.axis NumberAxis createIntegerTickUnits

Introduction

In this page you can find the example usage for org.jfree.chart.axis NumberAxis createIntegerTickUnits.

Prototype

public static TickUnitSource createIntegerTickUnits() 

Source Link

Document

Returns a collection of tick units for integer values.

Usage

From source file:org.bench4Q.console.ui.section.S_SPSSection.java

private JPanel printWIPSPic() throws IOException {
    double[][] value = sessionSmooth();
    for (int i = 0; i < value[0].length; ++i) {
        value[0][i] = i;// www  .  j  a  v a  2  s  .com
        // value[1][i] = webInteractionThroughput[i];.
    }

    DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset();
    String series1 = "Basic";
    String series2 = "real";

    for (int i = 0; i < value[0].length; ++i) {
        defaultcategorydataset.addValue(value[1][i], series1, new Integer((int) value[0][i]));
        defaultcategorydataset.addValue(session[1][i], series2, new Integer((int) value[0][i]));
    }

    JFreeChart chart = ChartFactory.createLineChart("SPS = " + SPS, "time", "SPS", defaultcategorydataset,
            PlotOrientation.VERTICAL, true, true, false);
    chart.setBackgroundPaint(Color.white);
    CategoryPlot categoryplot = (CategoryPlot) chart.getPlot();
    categoryplot.setBackgroundPaint(Color.WHITE);
    categoryplot.setRangeGridlinePaint(Color.white);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis.setAutoRangeIncludesZero(true);
    LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer();
    lineandshaperenderer.setShapesVisible(false);
    lineandshaperenderer.setSeriesStroke(0, new BasicStroke(2.0F, 1, 1, 1.0F, new float[] { 1F, 1F }, 0.0F));
    lineandshaperenderer.setSeriesStroke(1,
            new BasicStroke(2.0F, 1, 0, 2.0F, new float[] { 1F, 10000F }, 0.0F));
    return new ChartPanel(chart);
}

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

/**
 * Creates a chart./*from   w  w w  .ja  v  a2  s .c o m*/
 * 
 * @param dataset  the data for the chart.
 * 
 * @return a chart.
 */
protected JFreeChart createChart(XYDataset dataset) {

    // create the chart...
    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
    );

    chart.setBackgroundPaint(Color.white);

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

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    // renderer.setSeriesLinesVisible(0, false);
    //   renderer.setSeriesShapesVisible(1, false);
    renderer.setBaseLinesVisible(false);

    plot.setRenderer(renderer);

    // change the auto tick unit selection to integer units only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:syg_Wykresy.PanelRysunek_Wykres.java

private void initGUI() {
    try {//  ww  w.  j  a  v  a2 s  .  c  o m
        GridLayout thisLayout = new GridLayout(1, 1);
        thisLayout.setHgap(5);
        thisLayout.setVgap(5);
        thisLayout.setColumns(1);
        this.setLayout(thisLayout);
        setPreferredSize(new Dimension(400, 300));

        if (this.wykres) {

            XYSeries series = new XYSeries("Sygna "
                    + (this.sygnalWyswietlany.getrodzaj() == rodzaj_sygnalu.CIAGLY ? "cigy" : "dyskretny"));
            double punkt;
            double ta = this.sygnalWyswietlany.gett1();

            if (this.sygnalWyswietlany.getrodzaj() == rodzaj_sygnalu.CIAGLY
                    || sygnalWyswietlany.getPunktyY_wykres().size() <= 0) {
                punkt = this.sygnalWyswietlany.gett1();
                while (ta <= this.sygnalWyswietlany.gett1() + this.sygnalWyswietlany.getd()) {
                    punkt = this.sygnalWyswietlany.wykres_punkty(punkt, ta);
                    this.sygnalWyswietlany.setPunktyY_wykres(punkt);
                    series.add(ta, punkt);
                    if (this.sygnalWyswietlany.getrodzaj() == rodzaj_sygnalu.CIAGLY) {
                        if (this.sygnalWyswietlany.gettyp() != 9 && this.sygnalWyswietlany.gettyp() != 10)
                            ta = ta + this.sygnalWyswietlany.getkroczek();
                        else
                            ta = ta + this.sygnalWyswietlany.getkroczek() * 10;
                    } else {
                        if (this.sygnalWyswietlany.gettyp() != 9 && this.sygnalWyswietlany.gettyp() != 10)
                            ta = ta + this.sygnalWyswietlany.getkrok();
                        else
                            ta = ta + this.sygnalWyswietlany.getkrok() * 10;
                    }
                }
            } else if (this.sygnalWyswietlany.getrodzaj() == rodzaj_sygnalu.DYSKRETNY
                    && sygnalWyswietlany.getPunktyY_wykres().size() > 0) {
                int iloscProbek = (int) (this.sygnalWyswietlany.getPunktyY_wykres().size());
                for (int i = 0; i < iloscProbek; i++) {
                    punkt = this.sygnalWyswietlany.getPunktzindexu(i);
                    series.add(ta, punkt);
                    ta = ta + this.sygnalWyswietlany.getkrok();
                }
            }

            XYSeriesCollection dataset = new XYSeriesCollection(series);
            JFreeChart chart;

            if ((this.sygnalWyswietlany.gettyp() != 9 && this.sygnalWyswietlany.gettyp() != 10)
                    && (this.sygnalWyswietlany.getrodzaj() == rodzaj_sygnalu.CIAGLY)) {
                chart = ChartFactory.createXYLineChart(null, null, null, dataset, PlotOrientation.VERTICAL,
                        true, true, true);

                final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
                renderer.setSeriesLinesVisible(0, false);
            } else {
                chart = ChartFactory.createXYLineChart(null, null, null, dataset, PlotOrientation.VERTICAL,
                        true, true, true);

                final XYPlot plot = chart.getXYPlot();
                final XYDotRenderer renderer = new XYDotRenderer();
                renderer.setDotHeight(3);
                renderer.setDotWidth(3);
                plot.setRenderer(renderer);

                final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
                rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
            }

            // JOptionPane.showMessageDialog(null, "Rysowanie wykresu...",
            // "PanelRysunek_Wykres", JOptionPane.INFORMATION_MESSAGE);

            ChartPanel chartpanel = new ChartPanel(chart);
            chartpanel.setDomainZoomable(true);

            this.add(chartpanel);
        }

        Application.getInstance().getContext().getResourceMap(getClass()).injectComponents(this);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.joey.software.memoryToolkit.MemoryUsagePanel.java

/**
 * Creates a new application.//from  ww w .j a  va  2s  . co  m
 * 
 * @param historyCount
 *            the history count (in milliseconds).
 */
public MemoryUsagePanel(int historyCount, int interval) {
    super(new BorderLayout());
    // create two series that automatically discard data more than 30
    // seconds old...
    this.total = new TimeSeries("Total Memory", Millisecond.class);
    this.total.setMaximumItemCount(historyCount);
    this.free = new TimeSeries("Free Memory", Millisecond.class);
    this.free.setMaximumItemCount(historyCount);
    this.used = new TimeSeries("Used Memory", Millisecond.class);
    this.used.setMaximumItemCount(historyCount);
    this.max = new TimeSeries("Used Memory", Millisecond.class);
    this.max.setMaximumItemCount(historyCount);
    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(this.total);
    dataset.addSeries(this.free);
    dataset.addSeries(this.used);
    dataset.addSeries(this.max);

    DateAxis domain = new DateAxis("Time");
    NumberAxis range = new NumberAxis("Memory");

    domain.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    range.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    domain.setLabelFont(new Font("SansSerif", Font.PLAIN, 14));

    range.setLabelFont(new Font("SansSerif", Font.PLAIN, 14));
    XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false);
    renderer.setSeriesPaint(0, Color.red);
    renderer.setSeriesPaint(1, Color.green);
    renderer.setSeriesPaint(2, Color.black);

    renderer.setStroke(new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
    XYPlot plot = new XYPlot(dataset, domain, range, renderer);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    domain.setAutoRange(true);
    domain.setLowerMargin(0.0);
    domain.setUpperMargin(0.0);
    domain.setTickLabelsVisible(true);
    range.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    JFreeChart chart = new JFreeChart("JVM Memory Usage", new Font("SansSerif", Font.BOLD, 24), plot, true);
    chart.setBackgroundPaint(Color.white);
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4),
            BorderFactory.createLineBorder(Color.black)));
    add(chartPanel);

    gen = new DataGenerator(interval);

}

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

/**
 * Creates a chart./*  w ww. j  a va2  s.com*/
 * 
 * @param dataset  the data for the chart.
 * 
 * @return a chart.
 */
protected JFreeChart createChart(XYDataset dataset) {

    // create the chart...
    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...
    chart.setBackgroundPaint(Color.white);

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

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);
    renderer.setBaseLinesVisible(false);
    renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());

    // change the auto tick unit selection to integer units only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setAutoRangeIncludesZero(false);
    rangeAxis.setUpperMargin(0);
    rangeAxis.setLowerMargin(0);

    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    domainAxis.setAutoRangeIncludesZero(false);
    domainAxis.setUpperMargin(0);
    domainAxis.setLowerMargin(0);

    // OPTIONAL CUSTOMISATION COMPLETED.
    setXSummary(dataset);
    return chart;

}

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

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

    //   create the chart...
    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...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    XYPlot plot = (XYPlot) chart.getPlot();

    plot.setBackgroundPaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    //  renderer.setSeriesShape(0, java.awt.Shape.round);
    renderer.setBaseShapesVisible(false);
    renderer.setBaseShapesFilled(false);
    renderer.setBaseLinesVisible(true);

    renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());

    //change the auto tick unit selection to integer units only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setAutoRangeIncludesZero(false);
    rangeAxis.setUpperMargin(0.05);
    rangeAxis.setLowerMargin(0.05);

    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    domainAxis.setAutoRangeIncludesZero(false);
    //  domainAxis.setTickLabelsVisible(false);
    // domainAxis.setTickMarksVisible(false);      
    domainAxis.setUpperMargin(0.05);
    domainAxis.setLowerMargin(0.05);

    // OPTIONAL CUSTOMISATION COMPLETED.
    setYSummary(dataset);

    return chart;
}

From source file:edu.turtlekit2.tools.chart.ChartWindow.java

/**
 * Creates a chart. Local use.//from ww w . j  a  v a2s .  c  o m
 * @param dataset - the data for the chart.
 * @param title - the name of the chart
 * @param xName - the name of the x-axis.
 * @param yName - the name of the y-axis.
 * @return a chart.
 */
private JFreeChart createChart(final XYDataset dataset, String title, String xName, String yName) {
    // create the chart...
    final JFreeChart chart = ChartFactory.createXYLineChart(title, // chart title
            xName, // x axis label
            yName, // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );

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

    // get a reference to the plot for further customisation...
    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    //      final XYAreaRenderer2 renderer = new XYAreaRenderer2();
    renderer.setSeriesShapesVisible(0, false);
    renderer.setSeriesShapesVisible(1, false);
    renderer.setSeriesShapesVisible(2, false);
    plot.setRenderer(renderer);

    //      renderer.setSeriesStroke(
    //               0, new BasicStroke(
    //                   2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
    //                   1.0f, new float[] {1.0f, 6.0f}, 0.0f
    //               )
    //           );
    //           renderer.setSeriesStroke(
    //               1, new BasicStroke(
    //                   2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
    //                   1.0f, new float[] {1.0f, 6.0f}, 0.0f
    //               )
    //           );
    //           renderer.setSeriesStroke(
    //               2, new BasicStroke(
    //                   2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
    //                   1.0f, new float[] {1.0f, 6.0f}, 0.0f
    //               )
    //           );
    //      
    // change the auto tick unit selection to integer units only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    return chart;
}

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

/**
 * Creates a chart./*from ww  w.  j a va 2s.  c  om*/
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
private JFreeChart createChart(final CategoryDataset dataset) {

    final CategoryItemRenderer renderer = new CategoryStepRenderer(true);
    final CategoryAxis domainAxis = new CategoryAxis("Category");
    final ValueAxis rangeAxis = new NumberAxis("Value");
    final CategoryPlot plot = new CategoryPlot(dataset, domainAxis, rangeAxis, renderer);
    final JFreeChart chart = new JFreeChart("Category Step Chart", plot);

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

    // set the background color for the chart...
    //        final StandardLegend legend = (StandardLegend) chart.getLegend();
    //      legend.setAnchor(StandardLegend.SOUTH);

    chart.setBackgroundPaint(Color.white);

    //        plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    domainAxis.addCategoryLabelToolTip("Type 1", "The first type.");
    domainAxis.addCategoryLabelToolTip("Type 2", "The second type.");
    domainAxis.addCategoryLabelToolTip("Type 3", "The third type.");

    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setLabelAngle(0 * Math.PI / 2.0);
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:de.mpg.mpi_inf.bioinf.netanalyzer.ui.charts.JFreeChartConn.java

/**
 * Creates a histogram chart that displays the given integer histogram data.
 * /*  ww  w.j  a v a 2s.c o  m*/
 * @param aHistogram
 *            Complex parameter that stores the data to be visualized.
 * @param aSettings
 *            Settings group for integer histogram.
 * @return Newly created chart control.
 */
public static JFreeChart createHistogram(IntHistogram aHistogram, IntHistogramGroup aSettings) {

    XYSeriesCollection collection = fromIntHistogram(aHistogram);
    JFreeChart chart = ChartFactory.createHistogram(null, // title
            convertLabel(aSettings.axes.getDomainAxisLabel()), // label of X axis
            convertLabel(aSettings.axes.getRangeAxisLabel()), // label of Y axis
            collection, // dataset
            PlotOrientation.VERTICAL, // orientation
            false, // create legend
            false, // display tooltips
            false); // generate urls
    XYPlot plot = chart.getXYPlot();
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    updateGeneral(plot, aSettings.general);
    updateAxes(chart, aSettings.axes, aSettings.grid);
    updateBars(plot, aSettings.bars);
    chart.setBackgroundPaint(null);
    return chart;
}

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

/**
 * Creates a chart./* w w  w  .  j  ava2 s.  co m*/
 * 
 * @param dataset  the data for the chart.
 * 
 * @return a chart.
 */
protected JFreeChart createChart(XYDataset dataset) {

    // create the chart...
    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...
    chart.setBackgroundPaint(Color.white);

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

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);
    renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());

    // change the auto tick unit selection to integer units only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    // OPTIONAL CUSTOMISATION COMPLETED.

    setXSummary(dataset);
    return chart;

}