Example usage for org.jfree.chart.plot ContourPlot ContourPlot

List of usage examples for org.jfree.chart.plot ContourPlot ContourPlot

Introduction

In this page you can find the example usage for org.jfree.chart.plot ContourPlot ContourPlot.

Prototype

public ContourPlot(ContourDataset dataset, ValueAxis domainAxis, ValueAxis rangeAxis, ColorBar colorBar) 

Source Link

Document

Constructs a contour plot with the specified axes (other attributes take default values).

Usage

From source file:de.berlios.statcvs.xml.report.ActivityProgressionChart.java

private JFreeChart createContourPlot() {
    Grouper grouper = settings.getGrouper(new ModuleGrouper(settings.getModules(content)));

    ContourDataset data = createDataset(grouper);
    if (data == null) {
        return null;
    }//from ww w. j  av  a  2 s.  c o  m

    ValueAxis xAxis = new DateAxis(I18n.tr("Date"));

    SymbolicAxis yAxis = new SymbolicAxis(grouper.getName(), (String[]) groupNames.toArray(new String[0]));
    yAxis.setInverted(true);
    yAxis.setLowerMargin(0.0);
    yAxis.setUpperMargin(0.0);

    ColorBar zAxis = new ColorBar(I18n.tr("Commit Activity (%)"));
    zAxis.getAxis();

    ContourPlot plot = new ContourPlot(data, xAxis, yAxis, zAxis);
    //plot.setRenderAsPoints(true);
    // don't use plot units for ratios when x axis is date
    plot.setDataAreaRatio(0.0);
    plot.setColorBarLocation(RectangleEdge.BOTTOM);

    return new JFreeChart(settings.getProjectName(), null, plot, false);
}

From source file:net.sf.statcvs.output.xml.chart.ModuleActivityChart.java

private JFreeChart createContourPlot() {
    String title = Settings.getProjectName();
    String xAxisLabel = I18n.tr("Date");
    String yAxisLabel = I18n.tr("Modules");
    String zAxisLabel = I18n.tr("Commit Activity (%)");

    xAxis = new DateAxis(xAxisLabel);
    //xAxis = new HorizontalNumberAxis(xAxisLabel);

    List dirs = content.getDirectories();
    String[] ax = new String[dirs.size()];
    for (int i = 0; i < dirs.size(); i++) {
        ax[i] = (String) ((Directory) dirs.get(i)).getPath();
    }/*w ww  . j av a2s  .  c  om*/
    yAxis = new AlignedVerticalSymbolicAxis(yAxisLabel, ax);

    zAxis = new ColorBar(zAxisLabel);

    //yAxis.setAutoRangeIncludesZero(false);
    //zAxis.setAutoRangeIncludesZero(false);

    yAxis.setInverted(true);

    yAxis.setLowerMargin(0.0);
    yAxis.setUpperMargin(0.0);

    //zAxis.setInverted(false);
    //zAxis.setTickMarksVisible(true);

    ContourDataset data = createDataset();
    ContourPlot plot = new ContourPlot(data, xAxis, yAxis, zAxis);
    //plot.setRenderAsPoints(true);
    ratio = Math.abs(ratio); // don't use plot units for ratios when x axis is date
    plot.setDataAreaRatio(ratio);

    return new JFreeChart(title, null, plot, false);
}

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

/**
 * Creates a ContourPlot chart./*from   w  w w.  j  ava2 s  .c o  m*/
 *
 * @return the chart.
 */
private JFreeChart createContourPlot() {

    final String title = "Contour Plot";
    final String xAxisLabel = "X Values";
    final String yAxisLabel = "Y Values";
    final String zAxisLabel = "Color Values";

    if (xIsDate) {
        this.xAxis = new DateAxis(xAxisLabel);
        xIsLog = false; // force axis to be linear when displaying dates
    } else {
        if (xIsLog) {
            this.xAxis = new LogarithmicAxis(xAxisLabel);
        } else {
            this.xAxis = new NumberAxis(xAxisLabel);
        }
    }

    if (yIsLog) {
        this.yAxis = new LogarithmicAxis(yAxisLabel);
    } else {
        this.yAxis = new NumberAxis(yAxisLabel);
    }

    if (zIsLog) {
        this.zColorBar = new ColorBar(zAxisLabel);
    } else {
        this.zColorBar = new ColorBar(zAxisLabel);
    }

    if (this.xAxis instanceof NumberAxis) {
        ((NumberAxis) this.xAxis).setAutoRangeIncludesZero(false);
        ((NumberAxis) this.xAxis).setInverted(xIsInverted);
    }

    this.yAxis.setAutoRangeIncludesZero(false);

    this.yAxis.setInverted(yIsInverted);

    if (!xIsDate) {
        ((NumberAxis) this.xAxis).setLowerMargin(0.0);
        ((NumberAxis) this.xAxis).setUpperMargin(0.0);
    }

    this.yAxis.setLowerMargin(0.0);
    this.yAxis.setUpperMargin(0.0);

    this.zColorBar.getAxis().setInverted(zIsInverted);
    this.zColorBar.getAxis().setTickMarksVisible(true);

    final ContourDataset data = createDataset();

    final ContourPlot plot = new ContourPlot(data, this.xAxis, this.yAxis, this.zColorBar);

    if (xIsDate) {
        ratio = Math.abs(ratio); // don't use plot units for ratios when x axis is date
    }
    plot.setDataAreaRatio(ratio);

    final JFreeChart chart = new JFreeChart(title, null, plot, false);
    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.green));

    return chart;

}

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

/**
 * Creates a ContourPlot chart./* w  w  w. ja va 2  s .c  om*/
 *
 * @return the ContourPlot chart.
 */
private JFreeChart createContourPlot() {

    final String title = "Contour Plot";
    final String xAxisLabel = "X Values";
    final String yAxisLabel = "Y Values";
    final String zAxisLabel = "Color Values";

    if (xIsDate) {
        this.xAxis = new DateAxis(xAxisLabel);
        xIsLog = false; // force axis to be linear when displaying dates
    } else {
        if (xIsLog) {
            this.xAxis = new LogarithmicAxis(xAxisLabel);
        } else {
            this.xAxis = new NumberAxis(xAxisLabel);
        }
    }

    if (yIsLog) {
        this.yAxis = new LogarithmicAxis(yAxisLabel);
    } else {
        this.yAxis = new NumberAxis(yAxisLabel);
    }

    if (zIsLog) {
        this.zColorBar = new ColorBar(zAxisLabel);
    } else {
        this.zColorBar = new ColorBar(zAxisLabel);
    }

    if (this.xAxis instanceof NumberAxis) {
        ((NumberAxis) this.xAxis).setAutoRangeIncludesZero(false);
        ((NumberAxis) this.xAxis).setInverted(xIsInverted);
    }

    this.yAxis.setAutoRangeIncludesZero(false);

    this.yAxis.setInverted(yIsInverted);

    if (!xIsDate) {
        ((NumberAxis) this.xAxis).setLowerMargin(0.0);
        ((NumberAxis) this.xAxis).setUpperMargin(0.0);
    }

    this.yAxis.setLowerMargin(0.0);
    this.yAxis.setUpperMargin(0.0);

    if (!xIsDate) {
        this.xAxis.setRange(10.5, 15.0);
    }
    this.yAxis.setRange(3.5, 7.0);

    this.zColorBar.getAxis().setInverted(zIsInverted);
    this.zColorBar.getAxis().setTickMarksVisible(true);

    final ContourDataset data = createDataset();

    final ContourPlot plot = new ContourPlot(data, this.xAxis, this.yAxis, this.zColorBar);

    if (xIsDate) {
        ratio = Math.abs(ratio); // don't use plot units for ratios when x axis is date
    }

    if (asPoints) {
        plot.setRenderAsPoints(true);
    }
    plot.setDataAreaRatio(ratio);

    if (annotate) {
        if (asPoints) {
            final Number[] xValues = data.getXValues();
            final Number[] yValues = data.getYValues();
            //Number[] zValues = data.getZValues();

            final Font font = new Font("SansSerif", Font.PLAIN, 20);

            for (int i = 0; i < xValues.length; i++) {
                final XYTextAnnotation xyAnn = new XYTextAnnotation(Integer.toString(i),
                        xValues[i].doubleValue(), yValues[i].doubleValue());
                xyAnn.setFont(font);
                plot.addAnnotation(xyAnn);
            }
        } else {
            final Font font = new Font("SansSerif", Font.PLAIN, 20);

            for (int i = 0; i < this.tmpDoubleX.length; i++) {
                final XYTextAnnotation xyAnn = new XYTextAnnotation(Integer.toString(i), this.tmpDoubleX[i],
                        this.tmpDoubleY[i]);
                xyAnn.setFont(font);
                plot.addAnnotation(xyAnn);
            }
        }

    }

    if (fillOutline || drawOutline) {
        initShoreline();
        plot.setClipPath(new ClipPath(this.xOutline, this.yOutline, true, fillOutline, drawOutline));
    }

    final JFreeChart chart = new JFreeChart(title, null, plot, false);

    // then customise it a little...
    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.green));

    return chart;

}