Example usage for org.jfree.chart JFreeChart setBackgroundImageAlignment

List of usage examples for org.jfree.chart JFreeChart setBackgroundImageAlignment

Introduction

In this page you can find the example usage for org.jfree.chart JFreeChart setBackgroundImageAlignment.

Prototype

public void setBackgroundImageAlignment(int alignment) 

Source Link

Document

Sets the background alignment.

Usage

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

protected void setChartStyles(JFreeChart chart, UIChart comp) {
    Plot plot = chart.getPlot();//from w w  w  .  jav  a2s  .c om

    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();
    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.spring.GenericChartTheme.java

protected void setChartBackgroundImage(JFreeChart jfreeChart, Image defaultBackgroundImage,
        Integer defaultBackgroundImageAlignment, Float defaultBackgroundImageAlpha)

{

    if (defaultBackgroundImage != null) {
        jfreeChart.setBackgroundImage(defaultBackgroundImage);
        if (defaultBackgroundImageAlignment != null) {
            jfreeChart.setBackgroundImageAlignment(defaultBackgroundImageAlignment.intValue());
        }//ww w. j  av  a2s  . c o m
        if (defaultBackgroundImageAlpha != null) {
            jfreeChart.setBackgroundImageAlpha(defaultBackgroundImageAlpha.floatValue());
        }
    }
}

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

protected void setChartBackgroundImage(JFreeChart jfreeChart, Image defaultBackgroundImage,
        Integer defaultBackgroundImageAlignment, Float defaultBackgroundImageAlpha)

{

    if (defaultBackgroundImage != null) {
        jfreeChart.setBackgroundImage(defaultBackgroundImage);
        if (defaultBackgroundImageAlignment != null) {
            jfreeChart.setBackgroundImageAlignment(defaultBackgroundImageAlignment);
        }/*from   w w w  .ja  v  a  2 s .  c om*/
        if (defaultBackgroundImageAlpha != null) {
            jfreeChart.setBackgroundImageAlpha(defaultBackgroundImageAlpha);
        }
    }
}

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

protected void setChartBackgroundImage(JFreeChart jfreeChart) {
    ChartSettings chartSettings = getChartSettings();
    Image backgroundImage = chartSettings.getBackgroundImage() == null ? null
            : chartSettings.getBackgroundImage().getImage();
    if (backgroundImage != null) {
        jfreeChart.setBackgroundImage(backgroundImage);

        Integer backgroundImageAlignment = chartSettings.getBackgroundImageAlignment();
        if (backgroundImageAlignment != null) {
            jfreeChart.setBackgroundImageAlignment(backgroundImageAlignment.intValue());
        }/*  w  w w  .java 2  s. c om*/
        Float backgroundImageAlpha = chartSettings.getBackgroundImageAlpha();
        //         if(getChart().getOwnMode() != null && getChart().getOwnMode().byteValue() == ModeEnum.TRANSPARENT)
        //         {
        //            backgroundImageAlpha = new Float(0);
        //         }
        if (backgroundImageAlpha != null) {
            jfreeChart.setBackgroundImageAlpha(backgroundImageAlpha.floatValue());
        }
    }
}

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

protected void setChartBackgroundImage(JFreeChart jfreeChart) {
    ChartSettings chartSettings = getChartSettings();
    Image backgroundImage = chartSettings.getBackgroundImage() == null ? null
            : chartSettings.getBackgroundImage().getImage(getChartContext().getJasperReportsContext());
    if (backgroundImage != null) {
        jfreeChart.setBackgroundImage(backgroundImage);

        Integer backgroundImageAlignment = chartSettings.getBackgroundImageAlignment();
        if (backgroundImageAlignment != null) {
            jfreeChart.setBackgroundImageAlignment(backgroundImageAlignment);
        }/*from w w w  .j  a va  2s . c o  m*/
        Float backgroundImageAlpha = chartSettings.getBackgroundImageAlpha();
        //         if (getChart().getOwnMode() != null && getChart().getOwnMode() == ModeEnum.TRANSPARENT)
        //         {
        //            backgroundImageAlpha = 0f;
        //         }
        if (backgroundImageAlpha != null) {
            jfreeChart.setBackgroundImageAlpha(backgroundImageAlpha);
        }
    }
}