Example usage for org.jfree.chart.renderer.xy XYBlockRenderer getPaintScale

List of usage examples for org.jfree.chart.renderer.xy XYBlockRenderer getPaintScale

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.xy XYBlockRenderer getPaintScale.

Prototype

public PaintScale getPaintScale() 

Source Link

Document

Returns the paint scale used by the renderer.

Usage

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

/**
 *
 * @param t//from   w  ww .  ja v a  2  s .  c o m
 */
public void setThresholdCutOff(int t) {
    this.threshholdCutOff = t;
    if (getRenderer() instanceof XYBlockRenderer) {
        XYBlockRenderer xybr = (XYBlockRenderer) getRenderer();
        PaintScale ps = xybr.getPaintScale();
        if (ps instanceof GradientPaintScale) {
            GradientPaintScale gps = (GradientPaintScale) ps;
            if (xybr instanceof XYNoBlockRenderer) {
                XYNoBlockRenderer xybrn = (XYNoBlockRenderer) xybr;
                xybrn.setEntityThreshold(gps.getValueForIndex(this.threshholdCutOff));
            }
        }
        resetDataImage();
    }
}

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

/**
 *
 * @param xyz//from w ww . j  a v  a 2s . c  om
 * @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;
}