Example usage for org.jfree.eastwood GXYPlot setF0

List of usage examples for org.jfree.eastwood GXYPlot setF0

Introduction

In this page you can find the example usage for org.jfree.eastwood GXYPlot setF0.

Prototype

public void setF0(double f0) 

Source Link

Document

Sets the factor for the beginning of the background gradient.

Usage

From source file:org.jfree.eastwood.ChartEngine.java

/**
 * Process the string which contains an encoding for the chart background
 * fill, and apply it to the chart.//from  ww w  .  java2s . c o m
 *
 * @param spec  the fill specification.
 * @param chart  the chart.
 */
private static void processFillSpec(String spec, JFreeChart chart) {
    if (spec.startsWith("bg")) {
        // do the chart background
        spec = spec.substring(3);
        if (spec.startsWith("s")) {
            spec = spec.substring(2);
            Color c = parseColor(spec);
            chart.setBackgroundPaint(c);
        } else if (spec.startsWith("lg")) {
            spec = spec.substring(3);
            String[] args = breakString(spec, ',');
            int angle = Integer.parseInt(args[0]);
            Color c0 = parseColor(args[1]);
            float f0 = Float.parseFloat(args[2]);
            Color c1 = parseColor(args[3]);
            float f1 = Float.parseFloat(args[4]);
            if (chart.getPlot() instanceof GXYPlot) {
                GXYPlot gxyplot = (GXYPlot) chart.getPlot();
                gxyplot.setF0(f0);
                gxyplot.setF1(f1);
                gxyplot.setAngle(Math.PI / 180.0 * angle);
                gxyplot.setBackgroundPaint(new GradientPaint(0.0f, 0.0f, c0, 0.0f, 0.0f, c1));
            }
        }
    } else if (spec.startsWith("c")) {
        // do the plot background
        spec = spec.substring(2);
        if (spec.startsWith("s")) {
            spec = spec.substring(2);
            Color c = parseColor(spec);
            chart.getPlot().setBackgroundPaint(c);
        } else if (spec.startsWith("lg")) {
            spec = spec.substring(3);
            String[] args = breakString(spec, ',');
            int angle = Integer.parseInt(args[0]);
            Color c0 = parseColor(args[1]);
            float f0 = Float.parseFloat(args[2]);
            Color c1 = parseColor(args[3]);
            float f1 = Float.parseFloat(args[4]);
            if (chart.getPlot() instanceof GXYPlot) {
                GXYPlot gxyplot = (GXYPlot) chart.getPlot();
                gxyplot.setF0(f0);
                gxyplot.setF1(f1);
                gxyplot.setAngle(Math.PI / 180.0 * angle);
                gxyplot.setBackgroundPaint(new GradientPaint(0.0f, 0.0f, c0, 0.0f, 0.0f, c1));
            }
        } else {
            throw new RuntimeException("'c' background fill not implemented yet.");
        }
    } else {
        throw new RuntimeException("Bad fill specification: " + spec);
    }
}