Example usage for org.jfree.chart.axis CompassFormat CompassFormat

List of usage examples for org.jfree.chart.axis CompassFormat CompassFormat

Introduction

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

Prototype

public CompassFormat() 

Source Link

Document

Creates a new formatter using English identifiers.

Usage

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

private static JFreeChart createChart() {
    XYDataset xydataset = createDirectionDataset(600);
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Time", "Date", "Direction", xydataset, true,
            true, false);//from www.  j  a  v a2 s.  c  om
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.getDomainAxis().setLowerMargin(0.0D);
    xyplot.getDomainAxis().setUpperMargin(0.0D);
    NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis();
    numberaxis.setAutoRangeIncludesZero(false);
    TickUnits tickunits = new TickUnits();
    tickunits.add(new NumberTickUnit(180D, new CompassFormat()));
    tickunits.add(new NumberTickUnit(90D, new CompassFormat()));
    tickunits.add(new NumberTickUnit(45D, new CompassFormat()));
    tickunits.add(new NumberTickUnit(22.5D, new CompassFormat()));
    numberaxis.setStandardTickUnits(tickunits);
    xyplot.setRangeAxis(numberaxis);
    XYAreaRenderer xyarearenderer = new XYAreaRenderer();
    NumberAxis numberaxis1 = new NumberAxis("Force");
    numberaxis1.setRange(0.0D, 12D);
    xyarearenderer.setSeriesPaint(0, new Color(0, 0, 255, 128));
    xyplot.setDataset(1, createForceDataset(600));
    xyplot.setRenderer(1, xyarearenderer);
    xyplot.setRangeAxis(1, numberaxis1);
    xyplot.mapDatasetToRangeAxis(1, 1);
    return jfreechart;
}

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

/**
 * Creates a sample chart.//from   www  .ja v a 2  s .  c  om
 * 
 * @return a sample chart.
 */
private JFreeChart createChart() {
    final XYDataset direction = createDirectionDataset(600);
    final JFreeChart chart = ChartFactory.createTimeSeriesChart("Time", "Date", "Direction", direction, true,
            true, false);

    final XYPlot plot = chart.getXYPlot();
    plot.getDomainAxis().setLowerMargin(0.0);
    plot.getDomainAxis().setUpperMargin(0.0);

    // configure the range axis to display directions...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setAutoRangeIncludesZero(false);
    final TickUnits units = new TickUnits();
    units.add(new NumberTickUnit(180.0, new CompassFormat()));
    units.add(new NumberTickUnit(90.0, new CompassFormat()));
    units.add(new NumberTickUnit(45.0, new CompassFormat()));
    units.add(new NumberTickUnit(22.5, new CompassFormat()));
    rangeAxis.setStandardTickUnits(units);

    // add the wind force with a secondary dataset/renderer/axis
    plot.setRangeAxis(rangeAxis);
    final XYItemRenderer renderer2 = new XYAreaRenderer();
    final ValueAxis axis2 = new NumberAxis("Force");
    axis2.setRange(0.0, 12.0);
    renderer2.setSeriesPaint(0, new Color(0, 0, 255, 128));
    plot.setDataset(1, createForceDataset(600));
    plot.setRenderer(1, renderer2);
    plot.setRangeAxis(1, axis2);
    plot.mapDatasetToRangeAxis(1, 1);

    return chart;
}

From source file:com.afunms.system.manage.equipManager.java

/**
 * Creates a sample chart.//from  w w w .jav  a2s . c  om
 * 
 * @return a sample chart.
 */
private JFreeChart createChart() {
    final XYDataset direction = createDirectionDataset(600);
    final JFreeChart chart = ChartFactory.createTimeSeriesChart("", "", "", direction,
            true, true, false);

    final XYPlot plot = chart.getXYPlot();
    plot.getDomainAxis().setLowerMargin(0.0);
    plot.getDomainAxis().setUpperMargin(0.0);
    plot.setRangeCrosshairVisible(true);
    plot.setDomainCrosshairVisible(true);
    plot.setBackgroundPaint(Color.WHITE);
    plot.setForegroundAlpha(0.8f);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.darkGray);
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(new Color(139, 69, 19));
    XYLineAndShapeRenderer render0 = (XYLineAndShapeRenderer) plot.getRenderer(0);
    render0.setSeriesPaint(0, Color.BLUE);

    XYAreaRenderer xyarearenderer = new XYAreaRenderer();
    xyarearenderer.setSeriesPaint(1, Color.GREEN); // 
    xyarearenderer.setSeriesFillPaint(1, Color.GREEN);
    xyarearenderer.setPaint(Color.GREEN);

    // configure the range axis to display directions...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setAutoRangeIncludesZero(false);
    final TickUnits units = new TickUnits();
    units.add(new NumberTickUnit(180.0, new CompassFormat()));
    units.add(new NumberTickUnit(90.0, new CompassFormat()));
    units.add(new NumberTickUnit(45.0, new CompassFormat()));
    units.add(new NumberTickUnit(22.5, new CompassFormat()));
    rangeAxis.setStandardTickUnits(units);

    // add the wind force with a secondary dataset/renderer/axis
    plot.setRangeAxis(rangeAxis);
    final XYItemRenderer renderer2 = new XYAreaRenderer();
    final ValueAxis axis2 = new NumberAxis("");
    axis2.setRange(0.0, 12.0);
    xyarearenderer.setSeriesPaint(1, new Color(0, 204, 0)); // 
    xyarearenderer.setSeriesFillPaint(1, Color.GREEN);
    xyarearenderer.setPaint(Color.GREEN);
    plot.setDataset(1, createForceDataset(600));
    plot.setRenderer(1, xyarearenderer);
    plot.setRangeAxis(1, axis2);
    plot.mapDatasetToRangeAxis(1, 1);

    return chart;
}