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.jfree.chart.demo.CategoryStepChartDemo1.java

private static JFreeChart createChart(CategoryDataset categorydataset) {
    CategoryStepRenderer categorysteprenderer = new CategoryStepRenderer(true);
    categorysteprenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    CategoryAxis categoryaxis = new CategoryAxis("Category");
    NumberAxis numberaxis = new NumberAxis("Value");
    CategoryPlot categoryplot = new CategoryPlot(categorydataset, categoryaxis, numberaxis,
            categorysteprenderer);// w  ww  .  jav a2s.  co  m
    JFreeChart jfreechart = new JFreeChart("Category Step Chart", categoryplot);
    jfreechart.setBackgroundPaint(Color.white);
    categoryplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setDomainGridlinesVisible(true);
    categoryplot.setDomainGridlinePaint(Color.white);
    categoryplot.setRangeGridlinesVisible(true);
    categoryplot.setRangeGridlinePaint(Color.white);
    categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    categoryaxis.setLowerMargin(0.0D);
    categoryaxis.setUpperMargin(0.0D);
    categoryaxis.addCategoryLabelToolTip("Type 1", "The first type.");
    categoryaxis.addCategoryLabelToolTip("Type 2", "The second type.");
    categoryaxis.addCategoryLabelToolTip("Type 3", "The third type.");
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis.setLabelAngle(0.0D);
    return jfreechart;
}

From source file:Modelos.Grafica.java

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

From source file:Modelos.Grafica.java

private void configurarRangeAxis(NumberAxis rangeAxis) {
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setTickUnit(new NumberTickUnit(5));
    rangeAxis.setRange(0, 100);/*from  w  w w.j  a va  2  s  .  c  om*/
}

From source file:pwm.visualizer.MotivationDistributionPanel.java

private JPanel createPanel(String title) {
    IntervalXYDataset xybardataset = new XYBarDataset(motivationDataSet, 0.2D);
    JFreeChart jfreechart = ChartFactory.createXYBarChart(title, "", false, "Likelihood", xybardataset,
            PlotOrientation.VERTICAL, true, false, false);
    xyplot = (XYPlot) jfreechart.getPlot();
    NumberAxis numberaxis = (NumberAxis) xyplot.getDomainAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer();
    xybarrenderer.setDrawBarOutline(false);

    return new ChartPanel(jfreechart);
}

From source file:com.hello2morrow.sonargraph.jenkinsplugin.model.XYLineAndShapePlot.java

@Override
protected void applyRendering(XYPlot plot) {
    NumberAxis axis = (NumberAxis) plot.getDomainAxis();
    axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setSeriesPaint(0, DATA_COLOR);

    //Unfortunately, the tooltips are not visible, when the graph gets rendered as a PNG
    StandardXYToolTipGenerator toolTipGenerator = new StandardXYToolTipGenerator() {
        private static final long serialVersionUID = -5803780142385784897L;

        @Override// ww w .ja va  2 s.c  o m
        public String generateToolTip(XYDataset dataset, int series, int item) {
            return new StringBuilder(BUILD).append(dataset.getXValue(series, item)).append(COLON)
                    .append(dataset.getYValue(series, item)).toString();
        }
    };
    renderer.setBaseToolTipGenerator(toolTipGenerator);
}

From source file:jmbench.plots.SummaryWhiskerPlot.java

public JFreeChart createChart() {
    JFreeChart chart = ChartFactory.createBoxAndWhiskerChart(title, "Matrix Libraries", "Relative Performance",
            dataSet, true);/*from   www  .  j a  v a 2 s.com*/
    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:org.jfree.chart.demo.LineChart.java

private JFreeChart createChart(final XYDataset dataset) {

    // create the chart...
    final JFreeChart chart = ChartFactory.createXYLineChart("Line Chart", // chart title
            "X", // x axis label
            "Y", // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );/*from ww w . jav a 2 s .  c  o m*/

    chart.setBackgroundPaint(Color.white);

    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

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

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

    return chart;

}

From source file:ch.zhaw.ias.dito.ui.util.BlockPlotPanel.java

public BlockPlotPanel(Matrix m, double lowerBound, double upperBound) {
    super(new BorderLayout());
    NumberAxis xAxis = new NumberAxis();
    xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    xAxis.setLowerMargin(1.0);//from ww w.  j a  v  a2s . co m
    xAxis.setUpperMargin(0.0);
    NumberAxis yAxis = new NumberAxis();
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    yAxis.setLowerMargin(1.0);
    yAxis.setUpperMargin(0.0);
    XYBlockRenderer renderer = new XYBlockRenderer();
    renderer.setBaseToolTipGenerator(new XYToolTipGenerator() {
        @Override
        public String generateToolTip(XYDataset dataset, int series, int item) {
            XYZDataset xyzDataset = (XYZDataset) dataset;
            double x = xyzDataset.getXValue(series, item);
            double y = xyzDataset.getYValue(series, item);
            double z = xyzDataset.getZValue(series, item);
            return ("X=" + x + ", Y=" + y + ", Z=" + z);
        }
    });
    PaintScale scale = new ColorPaintScale(lowerBound, upperBound);
    renderer.setPaintScale(scale);
    ValueAxis axis = new NumberAxis();
    axis.setLowerBound(scale.getLowerBound());
    axis.setUpperBound(scale.getUpperBound());
    PaintScaleLegend legend = new PaintScaleLegend(scale, axis);
    legend.setMargin(new RectangleInsets(10, 10, 10, 10));
    legend.setPosition(RectangleEdge.RIGHT);

    MatrixXYDataset dataset = new MatrixXYDataset(m);
    plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    chart = new JFreeChart(plot);
    chart.removeLegend();
    chart.addSubtitle(legend);
    chart.setBackgroundPaint(Color.white);

    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setDisplayToolTips(true);
    this.add(chartPanel, BorderLayout.CENTER);
}

From source file:it.alus.GPSreceiver.instruments.SatelliteRadar.java

public SatelliteRadar() {
    super(null);// w  w  w  .  jav  a2  s. c  om
    azimuth = new int[MAX_SAT];
    elevation = new int[MAX_SAT];
    snr = new int[MAX_SAT];
    resetArray();
    satSeries = new XYSeries("Satellites");
    XYSeriesCollection seriescollection = new XYSeriesCollection();
    seriescollection.addSeries(satSeries);
    jChart = ChartFactory.createPolarChart("Satellites", seriescollection, true, false, false);
    jChart.setBackgroundPaint(Color.white);
    PolarPlot polarplot = (PolarPlot) jChart.getPlot();
    polarplot.setBackgroundPaint(Color.lightGray);
    polarplot.setAngleGridlinePaint(Color.white);
    polarplot.setRadiusGridlinePaint(Color.white);
    NumberAxis numberaxis = (NumberAxis) polarplot.getAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    super.setChart(jChart);
    super.setMouseZoomable(false);
    super.setPreferredSize(new Dimension(500, 270));
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.boxcharts.SimpleBox.java

public JFreeChart createChart(DatasetMap datasetMap) {

    BoxAndWhiskerCategoryDataset dataset = (BoxAndWhiskerCategoryDataset) datasetMap.getDatasets().get("1");

    JFreeChart chart = ChartFactory.createBoxAndWhiskerChart(name, categoryLabel, valueLabel, dataset, false);

    TextTitle title = setStyleTitle(name, styleTitle);
    chart.setTitle(title);/*from  www .ja  v  a 2s.c  o  m*/
    if (subName != null && !subName.equals("")) {
        TextTitle subTitle = setStyleTitle(subName, styleSubTitle);
        chart.addSubtitle(subTitle);
    }

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    BoxAndWhiskerRenderer renderer = (BoxAndWhiskerRenderer) plot.getRenderer();
    chart.setBackgroundPaint(Color.white);

    plot.setBackgroundPaint(new Color(Integer.decode("#c0c0c0").intValue()));
    plot.setDomainGridlinePaint(Color.WHITE);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);
    renderer.setFillBox(true);
    renderer.setArtifactPaint(Color.BLACK);
    renderer.setSeriesPaint(0, new Color(Integer.decode("#0000FF").intValue()));

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setRange(min, max);

    return chart;
}