Example usage for org.jfree.chart.plot Plot setBackgroundImageAlpha

List of usage examples for org.jfree.chart.plot Plot setBackgroundImageAlpha

Introduction

In this page you can find the example usage for org.jfree.chart.plot Plot setBackgroundImageAlpha.

Prototype

public void setBackgroundImageAlpha(float alpha) 

Source Link

Document

Sets the alpha transparency used when drawing the background image.

Usage

From source file:org.operamasks.faces.render.graph.ChartRenderer.java

protected void setChartStyles(JFreeChart chart, UIChart comp) {
    Plot plot = chart.getPlot();

    RectangleInsets insets = plot.getInsets();
    Double tm = comp.getTopMargin();
    Double lm = comp.getLeftMargin();
    Double bm = comp.getBottomMargin();
    Double rm = comp.getRightMargin();
    if (tm == null || tm < 0)
        tm = insets.getTop();//from  ww  w  .j av a  2 s  .c  o  m
    if (lm == null || lm < 0)
        lm = insets.getLeft();
    if (bm == null || bm < 0)
        bm = insets.getBottom();
    if (rm == null || rm < 0)
        rm = insets.getRight();
    plot.setInsets(new RectangleInsets(tm, lm, bm, rm));

    Paint color = comp.getBackgroundColor();
    if (color != null) {
        chart.setBackgroundPaint(color);
    }

    Image image = loadImage(comp.getBackgroundImage());
    if (image != null) {
        chart.setBackgroundImage(image);
        chart.setBackgroundImageAlignment(getImageAlign(comp.getBackgroundImagePosition()));
        chart.setBackgroundImageAlpha(comp.getBackgroundImageAlpha());
    }

    color = comp.getPlotColor();
    if (color != null) {
        plot.setBackgroundPaint(color);
    }

    Float alpha;
    if ((alpha = comp.getBackgroundAlpha()) != null) {
        plot.setBackgroundAlpha(alpha);
    }
    if ((alpha = comp.getForegroundAlpha()) != null) {
        plot.setForegroundAlpha(alpha);
    }

    image = loadImage(comp.getPlotImage());
    if (image != null) {
        plot.setBackgroundImage(image);
        plot.setBackgroundImageAlignment(getImageAlign(comp.getPlotImagePosition()));
        plot.setBackgroundImageAlpha(comp.getBackgroundImageAlpha());
    }

    Paint[] colorPalette = comp.getColorPalette();
    if (colorPalette != null) {
        plot.setDrawingSupplier(new CustomDrawingSupplier(colorPalette));
    } else {
        plot.setDrawingSupplier(new CustomDrawingSupplier());
    }
}

From source file:net.sf.fspdfs.chartthemes.simple.SimpleChartTheme.java

protected void setPlotBackground(Plot plot, JRChartPlot jrPlot) {
    PlotSettings plotSettings = getPlotSettings();
    Paint backgroundPaint = jrPlot.getOwnBackcolor();
    if (backgroundPaint == null && plotSettings.getBackgroundPaint() != null) {
        backgroundPaint = plotSettings.getBackgroundPaint().getPaint();
    }/*from   w  w w  . ja v a2 s. c  o  m*/
    if (backgroundPaint == null) {
        backgroundPaint = ChartThemesConstants.TRANSPARENT_PAINT;
    }
    plot.setBackgroundPaint(backgroundPaint);

    Float backgroundAlpha = jrPlot.getBackgroundAlphaFloat();
    if (backgroundAlpha == null) {
        backgroundAlpha = plotSettings.getBackgroundAlpha();
    }
    if (backgroundAlpha != null)
        plot.setBackgroundAlpha(backgroundAlpha.floatValue());

    Float foregroundAlpha = jrPlot.getForegroundAlphaFloat();
    if (foregroundAlpha == null) {
        foregroundAlpha = plotSettings.getForegroundAlpha();
    }
    if (foregroundAlpha != null)
        plot.setForegroundAlpha(foregroundAlpha.floatValue());

    Image backgroundImage = plotSettings.getBackgroundImage() == null ? null
            : plotSettings.getBackgroundImage().getImage();
    if (backgroundImage != null) {
        plot.setBackgroundImage(backgroundImage);
        Integer backgroundImageAlignment = plotSettings.getBackgroundImageAlignment();
        if (backgroundImageAlignment != null) {
            plot.setBackgroundImageAlignment(backgroundImageAlignment.intValue());
        }
        Float backgroundImageAlpha = plotSettings.getBackgroundImageAlpha();
        if (backgroundImageAlpha != null) {
            plot.setBackgroundImageAlpha(backgroundImageAlpha.floatValue());
        }
    }
}

From source file:net.sf.jasperreports.chartthemes.simple.SimpleChartTheme.java

protected void setPlotBackground(Plot plot, JRChartPlot jrPlot) {
    PlotSettings plotSettings = getPlotSettings();
    Paint backgroundPaint = jrPlot.getOwnBackcolor();
    if (backgroundPaint == null && plotSettings.getBackgroundPaint() != null) {
        backgroundPaint = plotSettings.getBackgroundPaint().getPaint();
    }//from   w ww.  j a v  a 2 s  .c  o m
    if (backgroundPaint == null) {
        backgroundPaint = ChartThemesConstants.TRANSPARENT_PAINT;
    }
    plot.setBackgroundPaint(backgroundPaint);

    Float backgroundAlpha = jrPlot.getBackgroundAlphaFloat();
    if (backgroundAlpha == null) {
        backgroundAlpha = plotSettings.getBackgroundAlpha();
    }
    if (backgroundAlpha != null)
        plot.setBackgroundAlpha(backgroundAlpha);

    Float foregroundAlpha = jrPlot.getForegroundAlphaFloat();
    if (foregroundAlpha == null) {
        foregroundAlpha = plotSettings.getForegroundAlpha();
    }
    if (foregroundAlpha != null)
        plot.setForegroundAlpha(foregroundAlpha);

    Image backgroundImage = plotSettings.getBackgroundImage() == null ? null
            : plotSettings.getBackgroundImage().getImage(getChartContext().getJasperReportsContext());
    if (backgroundImage != null) {
        plot.setBackgroundImage(backgroundImage);
        Integer backgroundImageAlignment = plotSettings.getBackgroundImageAlignment();
        if (backgroundImageAlignment != null) {
            plot.setBackgroundImageAlignment(backgroundImageAlignment);
        }
        Float backgroundImageAlpha = plotSettings.getBackgroundImageAlpha();
        if (backgroundImageAlpha != null) {
            plot.setBackgroundImageAlpha(backgroundImageAlpha);
        }
    }
}

From source file:net.sf.fspdfs.chartthemes.spring.GenericChartTheme.java

protected void setPlotBackground(Plot p, JRChartPlot jrPlot) {
    Paint defaultBackgroundPaint = (Paint) getDefaultValue(defaultPlotPropertiesMap,
            ChartThemesConstants.PLOT_BACKGROUND_PAINT);
    Float defaultBackgroundAlpha = (Float) getDefaultValue(defaultPlotPropertiesMap,
            ChartThemesConstants.PLOT_BACKGROUND_ALPHA);
    Float defaultForegroundAlpha = (Float) getDefaultValue(defaultPlotPropertiesMap,
            ChartThemesConstants.PLOT_FOREGROUND_ALPHA);

    Image defaultBackgroundImage = (Image) getDefaultValue(defaultPlotPropertiesMap,
            ChartThemesConstants.PLOT_BACKGROUND_IMAGE);
    Integer defaultBackgroundImageAlignment = (Integer) getDefaultValue(defaultPlotPropertiesMap,
            ChartThemesConstants.PLOT_BACKGROUND_IMAGE_ALIGNMENT);
    Float defaultBackgroundImageAlpha = (Float) getDefaultValue(defaultPlotPropertiesMap,
            ChartThemesConstants.PLOT_BACKGROUND_IMAGE_ALPHA);

    Paint backgroundPaint = jrPlot.getOwnBackcolor() != null ? jrPlot.getOwnBackcolor()
            : defaultBackgroundPaint;/*from  ww w.  j  av a  2  s.  com*/
    if (backgroundPaint != null) {
        p.setBackgroundPaint(backgroundPaint);
    }

    Float backgroundAlpha = jrPlot.getBackgroundAlphaFloat() != null ? jrPlot.getBackgroundAlphaFloat()
            : defaultBackgroundAlpha;
    if (backgroundAlpha != null)
        p.setBackgroundAlpha(backgroundAlpha.floatValue());

    Float foregroundAlpha = jrPlot.getForegroundAlphaFloat() != null ? jrPlot.getForegroundAlphaFloat()
            : defaultForegroundAlpha;
    if (foregroundAlpha != null)
        p.setForegroundAlpha(foregroundAlpha.floatValue());

    if (defaultBackgroundImage != null) {
        p.setBackgroundImage(defaultBackgroundImage);
        if (defaultBackgroundImageAlignment != null) {
            p.setBackgroundImageAlignment(defaultBackgroundImageAlignment.intValue());
        }
        if (defaultBackgroundImageAlpha != null) {
            p.setBackgroundImageAlpha(defaultBackgroundImageAlpha.floatValue());
        }
    }

}

From source file:net.sf.jasperreports.chartthemes.spring.GenericChartTheme.java

protected void setPlotBackground(Plot p, JRChartPlot jrPlot) {
    Paint defaultBackgroundPaint = (Paint) getDefaultValue(defaultPlotPropertiesMap,
            ChartThemesConstants.PLOT_BACKGROUND_PAINT);
    Float defaultBackgroundAlpha = (Float) getDefaultValue(defaultPlotPropertiesMap,
            ChartThemesConstants.PLOT_BACKGROUND_ALPHA);
    Float defaultForegroundAlpha = (Float) getDefaultValue(defaultPlotPropertiesMap,
            ChartThemesConstants.PLOT_FOREGROUND_ALPHA);

    Image defaultBackgroundImage = (Image) getDefaultValue(defaultPlotPropertiesMap,
            ChartThemesConstants.PLOT_BACKGROUND_IMAGE);
    Integer defaultBackgroundImageAlignment = (Integer) getDefaultValue(defaultPlotPropertiesMap,
            ChartThemesConstants.PLOT_BACKGROUND_IMAGE_ALIGNMENT);
    Float defaultBackgroundImageAlpha = (Float) getDefaultValue(defaultPlotPropertiesMap,
            ChartThemesConstants.PLOT_BACKGROUND_IMAGE_ALPHA);

    Paint backgroundPaint = jrPlot.getOwnBackcolor() != null ? jrPlot.getOwnBackcolor()
            : defaultBackgroundPaint;/*from  ww w.j a va 2  s. c om*/
    if (backgroundPaint != null) {
        p.setBackgroundPaint(backgroundPaint);
    }

    Float backgroundAlpha = jrPlot.getBackgroundAlphaFloat() != null ? jrPlot.getBackgroundAlphaFloat()
            : defaultBackgroundAlpha;
    if (backgroundAlpha != null)
        p.setBackgroundAlpha(backgroundAlpha);

    Float foregroundAlpha = jrPlot.getForegroundAlphaFloat() != null ? jrPlot.getForegroundAlphaFloat()
            : defaultForegroundAlpha;
    if (foregroundAlpha != null)
        p.setForegroundAlpha(foregroundAlpha);

    if (defaultBackgroundImage != null) {
        p.setBackgroundImage(defaultBackgroundImage);
        if (defaultBackgroundImageAlignment != null) {
            p.setBackgroundImageAlignment(defaultBackgroundImageAlignment);
        }
        if (defaultBackgroundImageAlpha != null) {
            p.setBackgroundImageAlpha(defaultBackgroundImageAlpha);
        }
    }

}