Example usage for org.jfree.data.xy XYZDataset getZValue

List of usage examples for org.jfree.data.xy XYZDataset getZValue

Introduction

In this page you can find the example usage for org.jfree.data.xy XYZDataset getZValue.

Prototype

public double getZValue(int series, int item);

Source Link

Document

Returns the z-value (as a double primitive) for an item within a series.

Usage

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

/**
 * Iterates over the data items of the xyz dataset to find
 * the z-dimension bounds./*from   w  w w  . j  a  v  a2s.  co m*/
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param includeInterval  include the z-interval (if the dataset has a
 *     z-interval.
 *
 * @return The range (possibly <code>null</code>).
 */
public static Range iterateZBounds(XYZDataset dataset, boolean includeInterval) {
    double minimum = Double.POSITIVE_INFINITY;
    double maximum = Double.NEGATIVE_INFINITY;
    int seriesCount = dataset.getSeriesCount();

    for (int series = 0; series < seriesCount; series++) {
        int itemCount = dataset.getItemCount(series);
        for (int item = 0; item < itemCount; item++) {
            double value = dataset.getZValue(series, item);
            if (!Double.isNaN(value)) {
                minimum = Math.min(minimum, value);
                maximum = Math.max(maximum, value);
            }
        }
    }

    if (minimum == Double.POSITIVE_INFINITY) {
        return null;
    } else {
        return new Range(minimum, maximum);
    }
}

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

/**
 * Returns the range of z-values in the specified dataset for the
 * data items belonging to the visible series and with x-values in the
 * given range./*from   w w  w . ja  v  a2s  .co  m*/
 *
 * @param dataset  the dataset ({@code null} not permitted).
 * @param visibleSeriesKeys  the visible series keys ({@code null} not
 *     permitted).
 * @param xRange  the x-range ({@code null} not permitted).
 * @param includeInterval  a flag that determines whether or not the
 *     z-interval for the dataset is included (this only applies if the
 *     dataset has an interval, which is currently not supported).
 *
 * @return The y-range (possibly {@code null}).
 */
public static Range iterateToFindZBounds(XYZDataset dataset, List visibleSeriesKeys, Range xRange,
        boolean includeInterval) {
    Args.nullNotPermitted(dataset, "dataset");
    Args.nullNotPermitted(visibleSeriesKeys, "visibleSeriesKeys");
    Args.nullNotPermitted(xRange, "xRange");

    double minimum = Double.POSITIVE_INFINITY;
    double maximum = Double.NEGATIVE_INFINITY;

    Iterator iterator = visibleSeriesKeys.iterator();
    while (iterator.hasNext()) {
        Comparable seriesKey = (Comparable) iterator.next();
        int series = dataset.indexOf(seriesKey);
        int itemCount = dataset.getItemCount(series);
        for (int item = 0; item < itemCount; item++) {
            double x = dataset.getXValue(series, item);
            double z = dataset.getZValue(series, item);
            if (xRange.contains(x)) {
                if (!Double.isNaN(z)) {
                    minimum = Math.min(minimum, z);
                    maximum = Math.max(maximum, z);
                }
            }
        }
    }

    if (minimum == Double.POSITIVE_INFINITY) {
        return null;
    } else {
        return new Range(minimum, maximum);
    }
}

From source file:net.sf.maltcms.chromaui.charts.FastHeatMapPlot.java

/**
 *
 * @param xyz// w w w  . ja  v  a 2 s.c o m
 * @param sl
 * @param spm
 * @param xybr
 * @param activeGraphics
 * @param dataArea
 * @param info
 * @param crosshairState
 * @return
 */
public BufferedImage prepareData(final XYZDataset xyz, final int sl, final int spm, final XYBlockRenderer xybr,
        Graphics2D activeGraphics, Rectangle2D dataArea, PlotRenderingInfo info,
        CrosshairState crosshairState) {
    long start = System.currentTimeMillis();
    final PaintScale ps = xybr.getPaintScale();
    double minz = Double.POSITIVE_INFINITY, maxz = Double.NEGATIVE_INFINITY;

    for (int i = 0; i < xyz.getSeriesCount(); i++) {
        final int items = xyz.getItemCount(i);
        for (int j = 0; j < items; j++) {
            minz = Math.min(xyz.getZValue(i, j), minz);
            maxz = Math.max(xyz.getZValue(i, j), maxz);
        }
    }
    if (ps instanceof GradientPaintScale) {
        ((GradientPaintScale) ps).setUpperBound(maxz);
        ((GradientPaintScale) ps).setLowerBound(minz);
    }
    Logger.getLogger(getClass().getName()).log(Level.INFO, "Finding min and max data took{0}ms",
            (System.currentTimeMillis() - start));

    //        VolatileImage bi = null;
    //        if (bi == null) {
    //        if (this.getOrientation() == PlotOrientation.VERTICAL) {
    BufferedImage bi = createCompatibleImage(sl, spm, BufferedImage.TRANSLUCENT);
    //        } else {
    //            bi = createCompatibleImage(spm, sl);
    //        }
    //        }else{
    //            img.validate(g.getDeviceConfiguration())
    //        }

    Graphics2D g2 = (Graphics2D) bi.getGraphics();
    g2.setColor((Color) ps.getPaint(ps.getLowerBound()));
    g2.fillRect(0, 0, sl, spm);
    // System.out.println("Using Threshold: " + threshold);
    int height = bi.getHeight();
    //final WritableRaster wr = bi.getRaster();
    XYItemRendererState xyrs = xybr.initialise(g2, dataArea, this, xyz, info);
    for (int i = 0; i < xyz.getSeriesCount(); i++) {
        final int items = xyz.getItemCount(i);
        for (int j = 0; j < items; j++) {
            final double tmp = xyz.getZValue(i, j);
            if (tmp > this.threshholdCutOff) {
                //if(j%50==0)System.out.println("Value > threshold: "+tmp);
                final Paint p = ps.getPaint(tmp);
                //                    final Paint tp = ps.getPaint(this.threshholdCutOff);
                //                    if (!tp.equals(p)) {
                if (p instanceof Color) {
                    final Color c = (Color) p;
                    g2.setColor(c);
                    //                    xybr.drawItem(g2, xyrs, dataArea, info, this, domainAxis, rangeAxis, xyz, i, j, crosshairState, 0);
                    //                        if (this.getOrientation() == PlotOrientation.VERTICAL) {

                    g2.fillRect((int) xyz.getXValue(i, j), height - (int) xyz.getYValue(i, j), 1, 1);
                    //                            wr.setPixel(, , new int[]{c.getRed(),
                    //                                        c.getGreen(), c.getBlue(), c.getAlpha()});
                    //                        } else {
                    //                            wr.setPixel((int) xyz.getYValue(i, j), (int) xyz.getXValue(i, j), new int[]{c.getRed(),
                    //                                        c.getGreen(), c.getBlue(), c.getAlpha()});
                    //                        }
                    //                }
                    //                    }
                }
            }
        }
    }

    Logger.getLogger(getClass().getName()).log(Level.INFO, "Creating image and drawing items took {0}ms",
            (System.currentTimeMillis() - start));

    return bi;
}

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

/**
 * Returns the range of z-values in the specified dataset for the
 * data items belonging to the visible series and with x-values in the
 * given range.//from   www  .j  av a  2s .  c o m
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param visibleSeriesKeys  the visible series keys (<code>null</code> not
 *     permitted).
 * @param xRange  the x-range (<code>null</code> not permitted).
 * @param includeInterval  a flag that determines whether or not the
 *     z-interval for the dataset is included (this only applies if the
 *     dataset has an interval, which is currently not supported).
 *
 * @return The y-range (possibly <code>null</code>).
 */
public static Range iterateToFindZBounds(XYZDataset dataset, List visibleSeriesKeys, Range xRange,
        boolean includeInterval) {
    ParamChecks.nullNotPermitted(dataset, "dataset");
    ParamChecks.nullNotPermitted(visibleSeriesKeys, "visibleSeriesKeys");
    ParamChecks.nullNotPermitted(xRange, "xRange");

    double minimum = Double.POSITIVE_INFINITY;
    double maximum = Double.NEGATIVE_INFINITY;

    Iterator iterator = visibleSeriesKeys.iterator();
    while (iterator.hasNext()) {
        Comparable seriesKey = (Comparable) iterator.next();
        int series = dataset.indexOf(seriesKey);
        int itemCount = dataset.getItemCount(series);
        for (int item = 0; item < itemCount; item++) {
            double x = dataset.getXValue(series, item);
            double z = dataset.getZValue(series, item);
            if (xRange.contains(x)) {
                if (!Double.isNaN(z)) {
                    minimum = Math.min(minimum, z);
                    maximum = Math.max(maximum, z);
                }
            }
        }
    }

    if (minimum == Double.POSITIVE_INFINITY) {
        return null;
    } else {
        return new Range(minimum, maximum);
    }
}

From source file:com.peterbochs.instrument.InstrumentPanel.java

@Override
public void chartMouseClicked(ChartMouseEvent event) {
    try {//from   w ww  .  j  a  v  a 2 s  .c  o  m
        // System.out.println(event.getTrigger().getX());
        JFreeChart chart = event.getChart();
        XYPlot xyplot = chart.getXYPlot();
        MyXYBlockRenderer renderer = (MyXYBlockRenderer) xyplot.getRenderer();

        XYZDataset dataset = (XYZDataset) xyplot.getDataset();
        XYItemEntity entity = (XYItemEntity) event.getEntity();
        int series = entity.getSeriesIndex();
        int item = entity.getItem();

        int i = event.getTrigger().getX();
        int j = event.getTrigger().getY();
        Point2D point2d = jMemoryChartPanel.translateScreenToJava2D(new Point(i, j));
        ChartRenderingInfo chartrenderinginfo = jMemoryChartPanel.getChartRenderingInfo();
        Rectangle2D rectangle2d = chartrenderinginfo.getPlotInfo().getDataArea();
        double x = xyplot.getDomainAxis().java2DToValue(point2d.getX(), rectangle2d,
                xyplot.getDomainAxisEdge());
        double y = xyplot.getRangeAxis().java2DToValue(point2d.getY(), rectangle2d, xyplot.getRangeAxisEdge());
        int realX = (int) Math.round(x);
        int realY = (int) Math.round(y);
        renderer.setSelectedXY(realX, realY);
        long blockSize = CommonLib.convertFilesize((String) jBlockSizeComboBox.getSelectedItem());
        long columnCount = Data.getColumnCount(
                CommonLib.convertFilesize((String) jFromComboBox.getSelectedItem()),
                CommonLib.convertFilesize((String) jToComboBox.getSelectedItem()), blockSize);
        Long address = ((realY * columnCount) + realX) * blockSize;

        updateHotestTable(address, blockSize);

        this.jAddressLabel.setText("Address=0x" + Long.toHexString(address));
        this.jRWCountLabel.setText("R/W count=" + (int) dataset.getZValue(series, item));
    } catch (Exception ex) {

    }
}