Example usage for org.jfree.chart.renderer PaintScale getLowerBound

List of usage examples for org.jfree.chart.renderer PaintScale getLowerBound

Introduction

In this page you can find the example usage for org.jfree.chart.renderer PaintScale getLowerBound.

Prototype

public double getLowerBound();

Source Link

Document

Returns the lower bound for the scale.

Usage

From source file:ch.zhaw.ias.dito.ui.util.BlockPlotPanel.java

public BlockPlotPanel(Matrix m, double lowerBound, double upperBound) {
    super(new BorderLayout());
    NumberAxis xAxis = new NumberAxis();
    xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    xAxis.setLowerMargin(1.0);/*from w  w w  .  j av  a  2s  . c om*/
    xAxis.setUpperMargin(0.0);
    NumberAxis yAxis = new NumberAxis();
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    yAxis.setLowerMargin(1.0);
    yAxis.setUpperMargin(0.0);
    XYBlockRenderer renderer = new XYBlockRenderer();
    renderer.setBaseToolTipGenerator(new XYToolTipGenerator() {
        @Override
        public String generateToolTip(XYDataset dataset, int series, int item) {
            XYZDataset xyzDataset = (XYZDataset) dataset;
            double x = xyzDataset.getXValue(series, item);
            double y = xyzDataset.getYValue(series, item);
            double z = xyzDataset.getZValue(series, item);
            return ("X=" + x + ", Y=" + y + ", Z=" + z);
        }
    });
    PaintScale scale = new ColorPaintScale(lowerBound, upperBound);
    renderer.setPaintScale(scale);
    ValueAxis axis = new NumberAxis();
    axis.setLowerBound(scale.getLowerBound());
    axis.setUpperBound(scale.getUpperBound());
    PaintScaleLegend legend = new PaintScaleLegend(scale, axis);
    legend.setMargin(new RectangleInsets(10, 10, 10, 10));
    legend.setPosition(RectangleEdge.RIGHT);

    MatrixXYDataset dataset = new MatrixXYDataset(m);
    plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    chart = new JFreeChart(plot);
    chart.removeLegend();
    chart.addSubtitle(legend);
    chart.setBackgroundPaint(Color.white);

    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setDisplayToolTips(true);
    this.add(chartPanel, BorderLayout.CENTER);
}

From source file:net.sf.maltcms.chromaui.chromatogram1Dviewer.ui.Chromatogram1DHeatmapViewTopComponent.java

private Chromatogram1DHeatmapViewerPanel createPanel(ADataset2D<IChromatogram1D, IScan> ds) {
    XYPlot p = createPlot(ds);/*  ww w  .jav  a 2 s . c  o m*/
    final PaintScale ps = ((XYBlockRenderer) p.getRenderer()).getPaintScale();
    p.setDomainGridlinesVisible(false);
    p.setRangeGridlinesVisible(false);
    JFreeChart jfc = new JFreeChart(p);
    final ChartPanel cp = new ChartPanel(jfc, true);
    cp.setZoomFillPaint(new Color(192, 192, 192, 96));
    cp.setZoomOutlinePaint(new Color(220, 220, 220, 192));
    cp.setFillZoomRectangle(false);
    cp.getChart().getLegend().setVisible(true);
    Chromatogram1DHeatmapViewerPanel panel = new Chromatogram1DHeatmapViewerPanel(content, getLookup(), ds);
    if (panel.getBackgroundColor() == null) {
        panel.setBackgroundColor((Color) ps.getPaint(ps.getLowerBound()));
    }
    cp.addKeyListener(panel);
    cp.setFocusable(true);
    cp.setDisplayToolTips(true);
    cp.setDismissDelay(3000);
    cp.setInitialDelay(0);
    cp.setReshowDelay(0);
    cp.setVisible(true);
    cp.setRefreshBuffer(true);
    cp.setMouseWheelEnabled(true);
    //FIXME fix peak overlay
    //      if (project != null) {
    //         for (Peak1DContainer peaks : project.getPeaks(chromatogram)) {
    //            Peak1DHeatmapOverlay overlay = new Peak1DHeatmapOverlay(chromatogram, peaks.getName(), peaks.getDisplayName(), peaks.getShortDescription(), true, peaks);
    //            cp.addOverlay(overlay);
    //            content.add(overlay);
    //         }
    //      }
    panel.setChartPanel(cp);
    if (ps != null) {
        panel.setPaintScale(ps);
    }
    panel.setPlot(p);
    return panel;
}

From source file:net.sf.maltcms.chromaui.chromatogram2Dviewer.ui.Chromatogram2DViewTopComponent.java

private Chromatogram2DViewerPanel createPanel(IChromatogramDescriptor chromatogram,
        ADataset2D<IChromatogram2D, IScan2D> ds, List<ChartOverlay> overlays) {
    IPaintScaleProvider ips = Lookup.getDefault().lookup(IPaintScaleProvider.class);
    ips.setMin(ds.getMinZ());// w  w  w  . j a  va  2s.c  o  m
    ips.setMax(ds.getMaxZ());
    PaintScale ps = ips.getPaintScales().get(0);
    XYPlot p = createPlot(chromatogram, ds, ps);
    p.setDomainGridlinesVisible(false);
    p.setRangeGridlinesVisible(false);
    JFreeChart jfc = new JFreeChart(p);
    final ContextAwareChartPanel cp = new ContextAwareChartPanel(jfc, true);
    cp.setZoomFillPaint(new Color(192, 192, 192, 96));
    cp.setZoomOutlinePaint(new Color(220, 220, 220, 192));
    cp.setFillZoomRectangle(false);
    cp.getChart().getLegend().setVisible(true);
    Chromatogram2DViewerPanel panel = new Chromatogram2DViewerPanel(content, getLookup(), ds, ps);
    if (panel.getBackgroundColor() == null) {
        panel.setBackgroundColor((Color) ps.getPaint(ps.getLowerBound()));
    }
    cp.addKeyListener(panel);
    cp.setFocusable(true);
    cp.setDisplayToolTips(true);
    cp.setDismissDelay(3000);
    cp.setInitialDelay(0);
    cp.setReshowDelay(0);
    cp.setVisible(true);
    cp.setRefreshBuffer(true);
    cp.setMouseWheelEnabled(true);
    if (project != null) {
        for (Peak1DContainer peaks : project.getPeaks(chromatogram)) {
            Peak2DOverlay overlay = new Peak2DOverlay(chromatogram, peaks.getName(), peaks.getDisplayName(),
                    peaks.getShortDescription(), true, peaks);
            cp.addOverlay(overlay);
            content.add(overlay);
            overlays.add(overlay);
        }
    }

    panel.setChartPanel(cp);
    panel.setPlot(p);
    return panel;
}

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

/**
 *
 * @param xyz/*from  www . j av 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;
}