Example usage for org.jfree.chart ChartPanel isOpaque

List of usage examples for org.jfree.chart ChartPanel isOpaque

Introduction

In this page you can find the example usage for org.jfree.chart ChartPanel isOpaque.

Prototype

public boolean isOpaque() 

Source Link

Document

Returns true if this component is completely opaque.

Usage

From source file:script.imglib.analysis.ChartUtils.java

public static final Image<RGBALegacyType> asImage(final JFreeChart chart, int width, int height) {
    ChartPanel panel = new ChartPanel(chart);
    Dimension d = panel.getPreferredSize();
    if (-1 == width && -1 == height) {
        width = d.width;/*  www  . j a  v  a 2s.com*/
        height = d.height;
        panel.setSize(d);
    } else {
        panel.setSize(width, height);
    }
    layoutComponent(panel);
    BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g = bi.createGraphics();
    if (!panel.isOpaque()) {
        g.setColor(panel.getBackground());
        g.fillRect(0, 0, width, height);
    }
    panel.paint(g);
    int[] pixels = new int[width * height];
    PixelGrabber pg = new PixelGrabber(bi, 0, 0, width, height, pixels, 0, width);
    try {
        pg.grabPixels();
    } catch (InterruptedException e) {
    }
    g.dispose();

    Array<RGBALegacyType, IntAccess> a = new Array<RGBALegacyType, IntAccess>(new ArrayContainerFactory(),
            new IntArray(pixels), new int[] { width, height }, 1);
    // create a Type that is linked to the container
    final RGBALegacyType linkedType = new RGBALegacyType(a);
    // pass it to the DirectAccessContainer
    a.setLinkedType(linkedType);

    return new Image<RGBALegacyType>(a, new RGBALegacyType());
}

From source file:net.imglib2.script.analysis.ChartUtils.java

public static final Img<ARGBType> asImage(final JFreeChart chart, int width, int height) {
    final ChartPanel panel = new ChartPanel(chart);
    final Dimension d = panel.getPreferredSize();
    if (-1 == width && -1 == height) {
        width = d.width;//from  w w  w  .  j ava 2s  . c  o m
        height = d.height;
        panel.setSize(d);
    } else {
        panel.setSize(width, height);
    }
    layoutComponent(panel);
    final BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    final Graphics2D g = bi.createGraphics();
    if (!panel.isOpaque()) {
        g.setColor(panel.getBackground());
        g.fillRect(0, 0, width, height);
    }
    panel.paint(g);
    final int[] pixels = new int[width * height];
    final PixelGrabber pg = new PixelGrabber(bi, 0, 0, width, height, pixels, 0, width);
    try {
        pg.grabPixels();
    } catch (final InterruptedException e) {
    }
    g.dispose();

    final ArrayImg<ARGBType, IntArray> a = new ArrayImg<ARGBType, IntArray>(new IntArray(pixels),
            new long[] { width, height }, 1);

    // create a Type that is linked to the container
    final ARGBType linkedType = new ARGBType(a);
    // pass it to the DirectAccessContainer
    a.setLinkedType(linkedType);

    return a;
}

From source file:techtonic.Techtonic.java

private void btnSetPropertiesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSetPropertiesActionPerformed

    XYPlot plot = (XYPlot) chart.getPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(0, foreColor);
    renderer.setSeriesShapesVisible(0, false);

    plot.setRenderer(renderer);/*from   w  w  w. j  a v  a 2 s.c  o  m*/
    ChartPanel cp = new ChartPanel(chart);
    System.out.println("opacity: " + cp.isOpaque());
    cp.setBackground(bgColor);
    setFreeChart(chart);
    setDisplayArea(cp);

}