Example usage for org.jfree.data.general HeatMapDataset getYSampleCount

List of usage examples for org.jfree.data.general HeatMapDataset getYSampleCount

Introduction

In this page you can find the example usage for org.jfree.data.general HeatMapDataset getYSampleCount.

Prototype

public int getYSampleCount();

Source Link

Document

Returns the number of y values (or samples) for the dataset.

Usage

From source file:org.jfree.data.general.HeatMapUtilities.java

/**
 * Returns a dataset containing one series that holds a copy of the (y, z)
 * data from one column (x-index) of the specified dataset.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param column  the column (x) index./*from  w ww  .  ja v a  2 s . co  m*/
 * @param seriesName  the series name (<code>null</code> not permitted).
 *
 * @return The dataset.
 */
public static XYDataset extractColumnFromHeatMapDataset(HeatMapDataset dataset, int column,
        Comparable seriesName) {
    XYSeries series = new XYSeries(seriesName);
    int rows = dataset.getYSampleCount();
    for (int r = 0; r < rows; r++) {
        series.add(dataset.getYValue(r), dataset.getZValue(column, r));
    }
    XYSeriesCollection result = new XYSeriesCollection(series);
    return result;
}

From source file:org.jfree.data.general.HeatMapUtils.java

/**
 * Creates an image that displays the values from the specified dataset.
 *
 * @param dataset  the dataset ({@code null} not permitted).
 * @param paintScale  the paint scale for the z-values ({@code null}
 *         not permitted)./*from  ww w.  ja  v  a  2  s . c  om*/
 *
 * @return A buffered image.
 */
public static BufferedImage createHeatMapImage(HeatMapDataset dataset, PaintScale paintScale) {

    Args.nullNotPermitted(dataset, "dataset");
    Args.nullNotPermitted(paintScale, "paintScale");
    int xCount = dataset.getXSampleCount();
    int yCount = dataset.getYSampleCount();
    BufferedImage image = new BufferedImage(xCount, yCount, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2 = image.createGraphics();
    for (int xIndex = 0; xIndex < xCount; xIndex++) {
        for (int yIndex = 0; yIndex < yCount; yIndex++) {
            double z = dataset.getZValue(xIndex, yIndex);
            Paint p = paintScale.getPaint(z);
            g2.setPaint(p);
            g2.fillRect(xIndex, yCount - yIndex - 1, 1, 1);
        }
    }
    return image;
}

From source file:org.jfree.data.general.HeatMapUtilities.java

/**
 * Creates an image that displays the values from the specified dataset.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param paintScale  the paint scale for the z-values (<code>null</code>
 *         not permitted)./*from ww  w  .j a v a  2  s.c  o m*/
 *
 * @return A buffered image.
 */
public static BufferedImage createHeatMapImage(HeatMapDataset dataset, PaintScale paintScale) {

    ParamChecks.nullNotPermitted(dataset, "dataset");
    ParamChecks.nullNotPermitted(paintScale, "paintScale");
    int xCount = dataset.getXSampleCount();
    int yCount = dataset.getYSampleCount();
    BufferedImage image = new BufferedImage(xCount, yCount, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2 = image.createGraphics();
    for (int xIndex = 0; xIndex < xCount; xIndex++) {
        for (int yIndex = 0; yIndex < yCount; yIndex++) {
            double z = dataset.getZValue(xIndex, yIndex);
            Paint p = paintScale.getPaint(z);
            g2.setPaint(p);
            g2.fillRect(xIndex, yCount - yIndex - 1, 1, 1);
        }
    }
    return image;
}