Example usage for org.jfree.chart.plot CategoryPlot getBackgroundPaint

List of usage examples for org.jfree.chart.plot CategoryPlot getBackgroundPaint

Introduction

In this page you can find the example usage for org.jfree.chart.plot CategoryPlot getBackgroundPaint.

Prototype

public Paint getBackgroundPaint() 

Source Link

Document

Returns the background color of the plot area.

Usage

From source file:com.controlj.addon.gwttree.server.OpaqueBarRenderer3D.java

@Override
public void drawBackground(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea) {

    float x0 = (float) dataArea.getX();
    float x1 = x0 + (float) Math.abs(getXOffset());
    float x3 = (float) dataArea.getMaxX();
    float x2 = x3 - (float) Math.abs(getXOffset());

    float y0 = (float) dataArea.getMaxY();
    float y1 = y0 - (float) Math.abs(getYOffset());
    float y3 = (float) dataArea.getMinY();
    float y2 = y3 + (float) Math.abs(getYOffset());

    GeneralPath clip = new GeneralPath();
    clip.moveTo(x0, y0);//  w  w w  .ja va 2 s .c o  m
    clip.lineTo(x0, y2);
    clip.lineTo(x1, y3);
    clip.lineTo(x3, y3);
    clip.lineTo(x3, y1);
    clip.lineTo(x2, y0);
    clip.closePath();

    Composite originalComposite = g2.getComposite();
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, plot.getBackgroundAlpha()));

    // fill background...
    Paint backgroundPaint = plot.getBackgroundPaint();
    if (backgroundPaint != null) {
        g2.setPaint(backgroundPaint);
        g2.fill(clip);
    }

    GeneralPath bottomWall = new GeneralPath();
    bottomWall.moveTo(x0, y0);
    bottomWall.lineTo(x1, y1);
    bottomWall.lineTo(x3, y1);
    bottomWall.lineTo(x2, y0);
    bottomWall.closePath();
    g2.setPaint(getWallPaint());
    g2.fill(bottomWall);

    // draw background image, if there is one...
    Image backgroundImage = plot.getBackgroundImage();
    if (backgroundImage != null) {
        Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX() + getXOffset(), dataArea.getY(),
                dataArea.getWidth() - getXOffset(), dataArea.getHeight() - getYOffset());
        plot.drawBackgroundImage(g2, adjusted);
    }

    g2.setComposite(originalComposite);

}

From source file:org.openfaces.component.chart.impl.renderers.LineFillRenderer.java

private void configureGradientAreaFill(Graphics2D g2, CategoryPlot plot, Paint itemPaint,
        PlotRenderingInfo info, GradientLineAreaFill gradientLineAreaFill) {
    double plotWidth = info.getPlotArea().getWidth();
    double plotHeight = info.getPlotArea().getHeight();
    Double mainColorTransparency = gradientLineAreaFill.getMaxValueTransparency();
    Double bgColorTransparency = gradientLineAreaFill.getMinValueTransparency();

    if (itemPaint instanceof Color) {
        Color itemColor = (Color) itemPaint;
        int red = itemColor.getRed();
        int green = itemColor.getGreen();
        int blue = itemColor.getBlue();
        int mainColorAlpha = (mainColorTransparency >= 0.0 && mainColorTransparency <= 1.0)
                ? Math.round(255 * mainColorTransparency.floatValue())
                : 150;/*from  ww w  .  j  a v  a 2s.c o m*/
        int bgColorAlpha = (bgColorTransparency >= 0.0 && bgColorTransparency <= 1.0)
                ? Math.round(255 * bgColorTransparency.floatValue())
                : 128;

        Color mainColor = new Color(red, green, blue, mainColorAlpha);
        Paint bgColor = getBackgroundPaint();
        if (bgColor == null) {
            bgColor = plot.getBackgroundPaint();
        }
        Color secondaryColor = getSecondaryColor(bgColorAlpha, bgColor);
        Paint areaPaint = getAreaFillPaint(plot, plotWidth, plotHeight, mainColor, secondaryColor);

        g2.setPaint(areaPaint);
    } else {
        g2.setPaint(itemPaint);
    }
}