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:com.thalesgroup.hudson.plugins.sourcemonitor.SourceMonitorChartBuilder.java

public static JFreeChart buildChart(SourceMonitorBuildAction action) {
    JFreeChart chart = ChartFactory.createStackedAreaChart(null, null, "Number of errors", buildDataset(action),
            PlotOrientation.VERTICAL, true, false, true);

    chart.setBackgroundPaint(Color.white);

    CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setOutlinePaint(null);/*from www. j a v a 2 s .  com*/
    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));

    CategoryItemRenderer firstRender = new DefaultCategoryItemRenderer();
    SourceMonitorRenderer renderer = new SourceMonitorRenderer(action.getUrlName());
    plot.setRenderer(firstRender);

    return chart;
}

From source file:org.esa.beam.smos.visat.GridPointBtDataFlagmatrixToolView.java

@Override
protected JComponent createGridPointComponent() {
    dataset = new DefaultXYZDataset();

    final NumberAxis xAxis = new NumberAxis("Record #");
    xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    xAxis.setAutoRangeIncludesZero(false);
    xAxis.setLowerMargin(0.0);/*  www. j av  a  2s . c o  m*/
    xAxis.setUpperMargin(0.0);

    flagNames = createFlagNames(Dddb.getInstance().getFlagDescriptors(DEFAULT_FLAG_DESCRIPTOR_IDENTIFIER));
    final NumberAxis yAxis = createRangeAxis(flagNames);

    final LookupPaintScale paintScale = new LookupPaintScale(0.0, 4.0, Color.WHITE);
    paintScale.add(0.0, Color.BLACK);
    paintScale.add(1.0, Color.RED);
    paintScale.add(2.0, Color.GREEN);
    paintScale.add(3.0, Color.BLUE);
    paintScale.add(4.0, Color.YELLOW);

    final XYBlockRenderer renderer = new XYBlockRenderer();
    renderer.setPaintScale(paintScale);
    renderer.setBaseToolTipGenerator(new FlagToolTipGenerator(flagNames));

    plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setBackgroundPaint(Color.LIGHT_GRAY);
    plot.setDomainGridlinePaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.WHITE);
    plot.setForegroundAlpha(0.5f);
    plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));
    plot.setNoDataMessage("No data");

    chart = new JFreeChart(null, plot);
    chart.removeLegend();
    chartPanel = new ChartPanel(chart);

    return chartPanel;
}

From source file:jmbench.plots.SummaryWhiskerPlot.java

public JFreeChart createChart() {
    JFreeChart chart = ChartFactory.createBoxAndWhiskerChart(title, "Matrix Libraries", "Relative Performance",
            dataSet, true);/*from   www .ja  v a2 s  .c  o  m*/
    CategoryPlot plot = chart.getCategoryPlot();
    plot.setDomainGridlinesVisible(true);
    plot.setBackgroundPaint(new Color(230, 230, 230));
    plot.setDomainGridlinePaint(new Color(50, 50, 50, 50));
    plot.setDomainGridlineStroke(new BasicStroke(78f));

    chart.getTitle().setFont(new Font("Times New Roman", Font.BOLD, 24));

    String foo = "( Higher is Better )";
    if (subtitle != null)
        foo += "      ( " + subtitle + " )";

    chart.addSubtitle(new TextTitle(foo, new Font("SansSerif", Font.ITALIC, 12)));

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

    return chart;
}

From source file:com.orsonpdf.demo.PDFBarChartDemo1.java

/**
 * Creates a sample chart.//from   www  . j av  a2s  .c o  m
 *
 * @param dataset  a dataset.
 *
 * @return The chart.
 */
private static JFreeChart createChart(CategoryDataset dataset) {

    // create the chart...
    JFreeChart chart = ChartFactory.createLineChart("Statistical Bar Chart Demo 1", "Type", "Value", dataset,
            PlotOrientation.VERTICAL, true, false, false);

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

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

    // customise the renderer...
    StatisticalBarRenderer renderer = new StatisticalBarRenderer();
    renderer.setDrawBarOutline(false);
    renderer.setErrorIndicatorPaint(Color.black);
    renderer.setIncludeBaseInRange(false);
    plot.setRenderer(renderer);

    // ensure the current theme is applied to the renderer just added
    ChartUtilities.applyCurrentTheme(chart);

    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    renderer.setBaseItemLabelsVisible(true);
    renderer.setBaseItemLabelPaint(Color.yellow);
    renderer.setBasePositiveItemLabelPosition(
            new ItemLabelPosition(ItemLabelAnchor.INSIDE6, TextAnchor.BOTTOM_CENTER));

    // set up gradient paints for series...
    GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64));
    GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0));
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    return chart;
}

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

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createBarChart("Bar Chart Demo 9", null, "Value", categorydataset,
            PlotOrientation.VERTICAL, false, true, false);
    TextTitle texttitle = jfreechart.getTitle();
    texttitle.setBorder(0.0D, 0.0D, 1.0D, 0.0D);
    texttitle.setBackgroundPaint(new GradientPaint(0.0F, 0.0F, Color.red, 350F, 0.0F, Color.white, true));
    texttitle.setExpandToFitSpace(true);
    jfreechart.setBackgroundPaint(new GradientPaint(0.0F, 0.0F, Color.yellow, 350F, 0.0F, Color.white, true));
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setNoDataMessage("NO DATA!");
    categoryplot.setBackgroundPaint(null);
    categoryplot.setInsets(new RectangleInsets(10D, 5D, 5D, 5D));
    categoryplot.setOutlinePaint(Color.black);
    categoryplot.setRangeGridlinePaint(Color.gray);
    categoryplot.setRangeGridlineStroke(new BasicStroke(1.0F));
    Paint apaint[] = createPaint();
    CustomBarRenderer custombarrenderer = new CustomBarRenderer(apaint);
    custombarrenderer.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_HORIZONTAL));
    categoryplot.setRenderer(custombarrenderer);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis.setRange(0.0D, 800D);/*from  w  w  w .j a  va2s.  co m*/
    numberaxis.setTickMarkPaint(Color.black);
    return jfreechart;
}

From source file:org.esa.beam.smos.visat.GridPointBtDataChartToolView.java

@Override
protected JComponent createGridPointComponent() {
    coPolDataset = new YIntervalSeriesCollection();
    crossPolDataset = new YIntervalSeriesCollection();
    chart = ChartFactory.createXYLineChart(null, null, null, coPolDataset, PlotOrientation.VERTICAL, true, // Legend?
            true, false);//www  .j  a v  a  2s  .c o m

    plot = chart.getXYPlot();
    plot.setNoDataMessage("No data");
    plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));

    final NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
    xAxis.setLabel("Incidence Angle (deg)");
    xAxis.setRange(0, 70);
    xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    final NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setLabel("Co-Pol BT(K)");
    yAxis.setRange(50, 350);

    final NumberAxis yAxis2 = new NumberAxis("Cross-Pol BT(K)");
    yAxis2.setRange(-25, 25);
    plot.setRangeAxis(1, yAxis2);
    plot.setDataset(1, crossPolDataset);
    plot.mapDatasetToRangeAxis(1, 1);

    DeviationRenderer coPolRenderer = new DeviationRenderer(true, false);
    coPolRenderer.setSeriesFillPaint(0, new Color(255, 127, 127));
    coPolRenderer.setSeriesFillPaint(1, new Color(127, 127, 255));
    DeviationRenderer crossPolRenderer = new DeviationRenderer(true, false);
    crossPolRenderer.setSeriesFillPaint(0, new Color(127, 255, 127));
    crossPolRenderer.setSeriesFillPaint(1, new Color(255, 255, 127));
    plot.setRenderer(0, coPolRenderer);
    plot.setRenderer(1, crossPolRenderer);

    return new ChartPanel(chart);
}

From source file:edu.wpi.cs.wpisuitetng.modules.requirementsmanager.view.charts.AbstractRequirementStatistics.java

protected JFreeChart buildLineChart(final String title, final String category, final String axisLabel) {
    final JFreeChart chart = ChartFactory.createLineChart(title, category, axisLabel,
            toCategoryDataset(category), PlotOrientation.VERTICAL, false, false, false);
    final CategoryPlot xyPlot = (CategoryPlot) chart.getPlot();
    final NumberAxis range = (NumberAxis) xyPlot.getRangeAxis();
    range.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    return chart;
}

From source file:edu.memphis.ccrg.lida.framework.gui.panels.ActivationChartPanel.java

/** Creates new form JChartGuiPanel */
public ActivationChartPanel() {
    chart = ChartFactory.createXYLineChart("", "Tick", "Activation", dataset, PlotOrientation.VERTICAL, true,
            true, false);/* ww  w  . j  ava2  s .c  o  m*/
    chart.setBackgroundPaint(new Color(238, 233, 233));
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    initComponents();
}

From source file:Modelos.Grafica.java

private void configurarDomainAxis(NumberAxis domainAxis) {
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    domainAxis.setTickUnit(new NumberTickUnit(5));
}

From source file:com.googlecode.logVisualizer.chart.LineChartBuilder.java

private JFreeChart createChart(final XYDataset dataset) {
    final JFreeChart chart = ChartFactory.createXYLineChart(getTitle(), xLable, yLable, dataset,
            PlotOrientation.VERTICAL, isIncludeLegend(), true, false);
    final XYPlot plot = (XYPlot) chart.getPlot();

    double lastXValue = 0;
    if (dataset.getSeriesCount() > 0)
        lastXValue = dataset.getXValue(0, dataset.getItemCount(0) - 1);

    plot.setDomainAxis(new FixedZoomNumberAxis(lastXValue));
    plot.getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.black);
    plot.setRangeGridlinePaint(Color.black);
    plot.setNoDataMessage("No data available");
    if (dataset.getSeriesCount() > 0)
        ((NumberAxis) plot.getDomainAxis()).setUpperBound(lastXValue);
    ((NumberAxis) plot.getRangeAxis()).setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    for (int i = 0; i < dataset.getSeriesCount(); i++) {
        renderer.setSeriesShapesVisible(i, false);
        renderer.setSeriesStroke(i, new BasicStroke(2));
    }/* w ww . jav  a  2  s  .  c  o m*/
    renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    plot.setRenderer(renderer);

    return chart;
}