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

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

Introduction

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

Prototype

public void setStandardTickUnits(TickUnitSource source) 

Source Link

Document

Sets the source for obtaining standard tick units for the axis and sends an AxisChangeEvent to all registered listeners.

Usage

From source file:org.csml.tommo.sugar.heatmap.MappingQualityMatrixChart.java

public static MappingQualityMatrixChart createNiceChart(MappingQualityMatrixDataset dataset,
        PaintScale paintScale) {//ww  w .  j  a  v a2  s .  c  o m

    Rectangle range = dataset.getMappingQualityMatrix().getRange();
    String xLabel = "X from " + range.x + " to " + (range.x + range.width);
    String yLabel = "Y from " + range.y + " to " + (range.y + range.height);

    NumberAxis xAxis = new NumberAxis(xLabel);
    xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    xAxis.setTickLabelsVisible(true);
    xAxis.setLowerMargin(0.0);
    xAxis.setUpperMargin(0.0);

    NumberAxis yAxis = new NumberAxis(yLabel);
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    yAxis.setTickLabelsVisible(true);
    yAxis.setLowerMargin(0.0);
    yAxis.setUpperMargin(0.0);

    MappingQualityMatrixChart chart = createChart(dataset, xAxis, yAxis, paintScale);

    // draw paint scale legend
    chart.setPaintScaleLegend(paintScale);

    return chart;
}

From source file:org.csml.tommo.sugar.heatmap.MeanQualityMatrixChart.java

public static MeanQualityMatrixChart createNiceChart(MeanQualityMatrixDataset dataset, PaintScale paintScale) {

    Rectangle range = dataset.getMeanQualityMatrix().getRange();
    String xLabel = "X from " + range.x + " to " + (range.x + range.width);
    String yLabel = "Y from " + range.y + " to " + (range.y + range.height);

    NumberAxis xAxis = new NumberAxis(xLabel);
    xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    xAxis.setTickLabelsVisible(true);/*from w w  w  . j a  v a  2 s  .  c o m*/
    xAxis.setLowerMargin(0.0);
    xAxis.setUpperMargin(0.0);

    NumberAxis yAxis = new NumberAxis(yLabel);
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    yAxis.setTickLabelsVisible(true);
    yAxis.setLowerMargin(0.0);
    yAxis.setUpperMargin(0.0);

    MeanQualityMatrixChart chart = createChart(dataset, xAxis, yAxis, paintScale);

    // draw paint scale legend
    chart.setPaintScaleLegend(paintScale);

    return chart;
}

From source file:org.jfree.chart.demo.selection.SelectionDemo4.java

/**
 * Creates a chart./*from  ww w  .  ja  va 2s  . co  m*/
 * 
 * @param dataset  a dataset.
 * 
 * @return The chart.
 */
private static JFreeChart createChart(IntervalXYDataset dataset, DatasetSelectionExtension<XYCursor> ext) {
    JFreeChart chart = ChartFactory.createHistogram("SelectionDemo4", null, null, dataset);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDomainPannable(true);
    plot.setRangePannable(true);
    plot.setForegroundAlpha(0.85f);
    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(true);
    renderer.setDefaultOutlinePaint(Color.red);
    renderer.setBarPainter(new StandardXYBarPainter());
    renderer.setShadowVisible(false);

    //add selection specific rendering
    IRSUtilities.setSelectedItemPaint(renderer, ext, Color.white);

    //register plot as selection change listener
    ext.addChangeListener(plot);

    return chart;
}

From source file:userInterface.StateAdminRole.DecisionChart4JPanel.java

private static JFreeChart createChart1(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createBarChart("Total Vaccinations", "Hospital", "Value",
            categorydataset, PlotOrientation.VERTICAL, true, true, false);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setDomainGridlinesVisible(true);
    categoryplot.setRangeCrosshairVisible(true);
    categoryplot.setRangeCrosshairPaint(Color.blue);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer();
    barrenderer.setDrawBarOutline(false);
    GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, new Color(0, 0, 64));
    GradientPaint gradientpaint1 = new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, new Color(0, 64, 0));
    GradientPaint gradientpaint2 = new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, new Color(64, 0, 0));
    barrenderer.setSeriesPaint(0, gradientpaint);
    barrenderer.setSeriesPaint(1, gradientpaint1);
    barrenderer.setSeriesPaint(2, gradientpaint2);
    barrenderer.setLegendItemToolTipGenerator(new StandardCategorySeriesLabelGenerator("Tooltip: {0}"));
    CategoryAxis categoryaxis = categoryplot.getDomainAxis();
    categoryaxis.setCategoryLabelPositions(
            CategoryLabelPositions.createUpRotationLabelPositions(0.52359877559829882D));
    return jfreechart;
}

From source file:org.radargun.reporting.BarPlotGenerator.java

/**
 * @param operation Name of the plotted operation
 * @param ranges ranges[0] = min, ranges[ranges.length - 1] = max
 * @param counts counts[i] is number of entries with value >= ranges[i - 1] and < ranges[i]
 * @param reportDir//from   w  w w  .j a  v  a  2s  .  c  om
 * @param filename
 * @throws IOException
 */
public static void generate(String operation, long[] ranges, long[] counts, String reportDir, String filename)
        throws IOException {
    XYSeries series = new XYSeries(operation + " response times");
    long totalCount = 0;
    for (long count : counts) {
        totalCount += count;
    }
    double left = Math.log10(ranges[0]);
    double right = Math.log10(ranges[ranges.length - 1]);

    for (int i = 0; i < counts.length; i++) {
        series.add(Math.log10(ranges[i]), (double) counts[i] / totalCount);
    }
    series.add(right, 0d);
    XYDataset dataset = new XYSeriesCollection(series);
    JFreeChart chart = ChartFactory.createXYStepAreaChart(operation + " response time histogram",
            "Response time", "Percentage", dataset, PlotOrientation.VERTICAL, false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    NumberAxis d = (NumberAxis) plot.getDomainAxis();
    d.setRange(left, right);
    d.setStandardTickUnits(new HistoTickUnitSource());
    plot.setDomainAxis(d);
    FileOutputStream output = new FileOutputStream(new File(reportDir + File.separator + filename));
    ChartUtilities.writeChartAsPNG(output, chart, 1024, 768);
    output.close();
}

From source file:org.jfree.expdemo.SelectionDemo4.java

/**
 * Creates a chart.//from w w w.j a v a  2 s  . c  om
 * 
 * @param dataset
 *            a dataset.
 * 
 * @return The chart.
 */
private static JFreeChart createChart(IntervalXYDataset dataset, DatasetSelectionExtension ext) {
    JFreeChart chart = ChartFactory.createHistogram("SelectionDemo4", null, null, dataset,
            PlotOrientation.VERTICAL, true, true, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDomainPannable(true);
    plot.setRangePannable(true);
    plot.setForegroundAlpha(0.85f);
    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(true);
    renderer.setBaseOutlinePaint(Color.red);
    renderer.setBarPainter(new StandardXYBarPainter());
    renderer.setShadowVisible(false);

    //add selection specific rendering
    IRSUtilities.setSelectedItemPaint(renderer, ext, Color.white);

    //register plot as selection change listener
    ext.addSelectionChangeListener(plot);

    return chart;
}

From source file:ChartUsingJava.CombinedCategoryPlotDemo1.java

/**
 * Creates a chart./*  ww w . j  a v  a  2  s .com*/
 *
 * @return A chart.
 */
private static JFreeChart createChart() {

    CategoryDataset dataset1 = createDataset1();
    NumberAxis rangeAxis1 = new NumberAxis("Value");
    rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    LineAndShapeRenderer renderer1 = new LineAndShapeRenderer();
    renderer1.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    CategoryPlot subplot1 = new CategoryPlot(dataset1, null, rangeAxis1, renderer1);
    subplot1.setDomainGridlinesVisible(true);

    CategoryDataset dataset2 = createDataset2();
    NumberAxis rangeAxis2 = new NumberAxis("Value");
    rangeAxis2.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    BarRenderer renderer2 = new BarRenderer();
    renderer2.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    CategoryPlot subplot2 = new CategoryPlot(dataset2, null, rangeAxis2, renderer2);
    subplot2.setDomainGridlinesVisible(true);

    CategoryAxis domainAxis = new CategoryAxis("Category");
    CombinedCategoryPlot plot = new CombinedCategoryPlot(domainAxis, new NumberAxis("Range"));
    plot.add(subplot1, 2);
    plot.add(subplot2, 1);

    JFreeChart result = new JFreeChart("Combined Domain Category Plot Demo",
            new Font("SansSerif", Font.BOLD, 12), plot, true);
    return result;

}

From source file:userInterface.StateAdminRole.DecisionCartJPanel2.java

private static JFreeChart createChart1(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createBarChart("Order Statistics", "Hospital", "Value",
            categorydataset, PlotOrientation.VERTICAL, true, true, false);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setDomainGridlinesVisible(true);
    categoryplot.setRangeCrosshairVisible(true);
    categoryplot.setRangeCrosshairPaint(Color.blue);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer();
    barrenderer.setDrawBarOutline(false);
    GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, new Color(0, 0, 64));
    GradientPaint gradientpaint1 = new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, new Color(0, 64, 0));
    GradientPaint gradientpaint2 = new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, new Color(64, 0, 0));
    barrenderer.setSeriesPaint(0, gradientpaint);
    barrenderer.setSeriesPaint(1, gradientpaint1);
    barrenderer.setSeriesPaint(2, gradientpaint2);
    barrenderer.setLegendItemToolTipGenerator(new StandardCategorySeriesLabelGenerator("Tooltip: {0}"));
    CategoryAxis categoryaxis = categoryplot.getDomainAxis();
    categoryaxis.setCategoryLabelPositions(
            CategoryLabelPositions.createUpRotationLabelPositions(0.52359877559829882D));
    return jfreechart;
}

From source file:org.jenkinsci.plugins.todos.TodosChartBuilder.java

/**
 * Build a trend chart from the provided data.
 * //w  w w  . j a  v  a 2  s .  com
 * @param action
 *            the build action
 * @return the trend chart
 */
public static JFreeChart buildChart(TodosBuildAction action) {
    String strComments = Messages.Todos_ReportSummary_Comments();

    JFreeChart chart = ChartFactory.createStackedAreaChart(null, null, strComments, buildDataset(action),
            PlotOrientation.VERTICAL, true, false, true);

    chart.setBackgroundPaint(Color.white);

    CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setOutlinePaint(null);
    plot.setForegroundAlpha(0.8f);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.black);

    CategoryAxis domainAxis = new ShiftedCategoryAxis(null);
    plot.setDomainAxis(domainAxis);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    domainAxis.setCategoryMargin(0.0);

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

    // Crop extra space around the graph
    plot.setInsets(new RectangleInsets(0, 0, 0, 5.0));

    TodosAreaRenderer renderer = new TodosAreaRenderer(action.getUrlName());
    plot.setRenderer(renderer);

    return chart;
}

From source file:edu.coeia.charts.LineChartPanel.java

/**
 * Creates a sample chart.//from   ww  w .  ja v  a2 s  . c o m
 *
 * @param dataset  a dataset.
 *
 * @return The chart.
 */
private static JFreeChart createChart(final CategoryDataset dataset) {

    // create the chart...
    final JFreeChart chart = ChartFactory.createLineChart("Frequency of Messages", // chart title
            "Time of Messages", // domain axis label
            "Number of Messages", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );

    chart.setBackgroundPaint(Color.white);

    final CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.white);

    // customise the range axis...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setAutoRangeIncludesZero(true);

    // customise the renderer...
    final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setSeriesStroke(0, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
            new float[] { 10.0f, 6.0f }, 0.0f));

    renderer.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
            new float[] { 6.0f, 6.0f }, 0.0f));

    renderer.setSeriesStroke(2, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
            new float[] { 2.0f, 6.0f }, 0.0f));

    return chart;
}