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

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

Introduction

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

Prototype

public void setDataAreaRatio(double ratio) 

Source Link

Document

Sets the data area ratio.

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   w w  w.j a v  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();
    }//from w ww .  j  a  v  a2s.  co m
    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:edu.umn.natsrl.evaluation.ContourPlotter.java

private boolean createContourPlot() {

    if (chart != null) {
        return true;
    }//from  w  w  w  . j a va 2  s. com

    if (this.cv == null || this.ncv == 0 || this.colors == null) {
        return false;
    }

    String date = null;
    Vector<EvaluationResult> results = (Vector<EvaluationResult>) this.eval.getResult().clone();

    if (results.size() > 2) {
        date = "  [average of " + (results.size() - 1) + " days]";
    } else {
        date = "  [" + results.get(0).getName() + "]";
    }

    final String title = section.getName() + date;
    final String xAxisLabel = "";
    final String yAxisLabel = "";
    final String zAxisLabel = "";

    this.xAxis = new NumberAxis(xAxisLabel);
    this.yAxis = new NumberAxis(yAxisLabel);
    this.zColorBar = new ColorBar(zAxisLabel);

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

    this.yAxis.setAutoRangeIncludesZero(false);

    this.yAxis.setStreetName(this.streetNames);
    ((NumberAxis) this.xAxis).setTime(this.plotTimes);
    ((NumberAxis) this.zColorBar.getAxis()).setColor(cv, unit);
    ((NumberAxis) this.xAxis).setLowerMargin(0.0);
    ((NumberAxis) this.xAxis).setUpperMargin(0.0);

    this.yAxis.setLowerMargin(0.0);
    this.yAxis.setUpperMargin(0.0);
    this.xAxis.setRange(0, numX - 1);
    this.yAxis.setRange(0, numY - 1);
    this.zColorBar.getAxis().setTickMarksVisible(true);

    final ContourDataset data = createDataset();
    //        for(Number n : data.getZValues()) {
    //            System.out.println("Data=" + n);
    //        }
    final ContourPlot plot = new ContourPlot(data, this.xAxis, this.yAxis, this.zColorBar, ncv);

    plot.SetContourValue(cv, ncv, colors, numX, numY);
    plot.setDataAreaRatio(ratio);

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

    return true;
}

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

/**
 * Creates a ContourPlot chart./*w w w  . jav a  2 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.//from   w  w  w  .  j a  v a  2  s . co  m
 *
 * @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;

}