Example usage for java.awt GradientPaint GradientPaint

List of usage examples for java.awt GradientPaint GradientPaint

Introduction

In this page you can find the example usage for java.awt GradientPaint GradientPaint.

Prototype

public GradientPaint(float x1, float y1, Color color1, float x2, float y2, Color color2) 

Source Link

Document

Constructs a simple acyclic GradientPaint object.

Usage

From source file:org.jfree.chart.demo.JFreeChartDemoBase.java

/**
 * Creates a candlestick chart.//  w w  w.ja v  a  2s  . c om
 *
 * @return a candlestick chart.
 */
public JFreeChart createCandlestickChart() {

    // create a default chart based on some sample data...
    final String title = this.resources.getString("timeseries.candlestick.title");
    final String domain = this.resources.getString("timeseries.candlestick.domain");
    final String range = this.resources.getString("timeseries.candlestick.range");
    final String subtitleStr = this.resources.getString("timeseries.candlestick.subtitle");
    final DefaultHighLowDataset data = DemoDatasetFactory.createHighLowDataset();
    final JFreeChart chart = ChartFactory.createCandlestickChart(title, domain, range, data, false);

    // then customise it a little...
    final TextTitle subtitle = new TextTitle(subtitleStr, new Font("SansSerif", Font.BOLD, 12));
    chart.addSubtitle(subtitle);
    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.green));
    return chart;

}

From source file:org.hxzon.demo.jfreechart.CategoryDatasetDemo2.java

private static JFreeChart createMultiplePieChart3D(CategoryDataset dataset) {

    MultiplePiePlot plot = new MultiplePiePlot(dataset);
    plot.setDataExtractOrder(TableOrder.BY_COLUMN);
    plot.setBackgroundPaint(null);/*w ww  .j  av  a 2s  . c o m*/
    plot.setOutlineStroke(null);

    JFreeChart pieChart = new JFreeChart(new PiePlot3D(null));
    TextTitle seriesTitle = new TextTitle("Series Title", new Font("SansSerif", Font.BOLD, 12));
    seriesTitle.setPosition(RectangleEdge.BOTTOM);
    pieChart.setTitle(seriesTitle);
    pieChart.removeLegend();
    pieChart.setBackgroundPaint(null);
    plot.setPieChart(pieChart);

    if (tooltips) {
        PieToolTipGenerator tooltipGenerator = new StandardPieToolTipGenerator();
        PiePlot pp = (PiePlot) plot.getPieChart().getPlot();
        pp.setToolTipGenerator(tooltipGenerator);
    }

    if (urls) {
        PieURLGenerator urlGenerator = new StandardPieURLGenerator();
        PiePlot pp = (PiePlot) plot.getPieChart().getPlot();
        pp.setURLGenerator(urlGenerator);
    }

    JFreeChart chart = new JFreeChart("MultiplePie Chart 3D Demo 1", JFreeChart.DEFAULT_TITLE_FONT, plot,
            legend);
    chart.setBackgroundPaint(Color.white);

    PiePlot piePlot = (PiePlot) pieChart.getPlot();

    GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64));
    GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0));
    GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0));
    piePlot.setSectionPaint("First", gp0);
    piePlot.setSectionPaint("Second", gp1);
    piePlot.setSectionPaint("Third", gp2);

    return chart;

}

From source file:org.jfree.chart.demo.JFreeChartDemoBase.java

/**
 * Creates and returns a sample signal chart.
 *
 * @return a sample chart.//  w w  w  .  j  av  a  2  s. co m
 */
public JFreeChart createSignalChart() {

    // create a default chart based on some sample data...
    final String title = this.resources.getString("timeseries.signal.title");
    final String domain = this.resources.getString("timeseries.signal.domain");
    final String range = this.resources.getString("timeseries.signal.range");
    final String subtitleStr = this.resources.getString("timeseries.signal.subtitle");
    final SignalsDataset data = DemoDatasetFactory.createSampleSignalDataset();
    final JFreeChart chart = ChartFactory.createSignalChart(title, domain, range, data, true);

    // then customise it a little...
    final TextTitle subtitle = new TextTitle(subtitleStr, new Font("SansSerif", Font.BOLD, 12));
    chart.addSubtitle(subtitle);
    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue));
    return chart;

}

From source file:org.gridchem.client.gui.panels.myccg.resource.HPCChartPanel.java

private void renderStackedBarChart(JFreeChart chart) {
    CategoryPlot plot = (CategoryPlot) chart.getPlot();

    // set the range axis to display integers only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setUpperBound(100);/*from   w  ww.  ja v  a2  s  .  co m*/

    StackedBarRenderer renderer = (StackedBarRenderer) plot.getRenderer();
    renderer.setItemLabelsVisible(true);
    renderer.setMaximumBarWidth(1.0);

    // set up gradient paints for series...
    final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.black);
    final GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.black);
    final GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, Color.black);
    final GradientPaint gp3 = new GradientPaint(0.0f, 0.0f, Color.orange, 0.0f, 0.0f, Color.black);

    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);
    renderer.setSeriesPaint(3, gp3);

}

From source file:org.jfree.chart.demo.JFreeChartDemoBase.java

/**
 * Creates and returns a sample thermometer chart.
 *
 * @return a sample thermometer chart./*from  w  w  w . ja  v a 2 s .  c o  m*/
 */
public JFreeChart createThermometerChart() {

    // create a default chart based on some sample data...
    final String title = this.resources.getString("meter.thermo.title");
    final String subtitleStr = this.resources.getString("meter.thermo.subtitle");
    final String units = this.resources.getString("meter.thermo.units");

    final DefaultValueDataset data = new DefaultValueDataset(new Double(34.0));
    final ThermometerPlot plot = new ThermometerPlot(data);
    plot.setUnits(units);
    final JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false);

    // then customise it a little...
    final TextTitle subtitle = new TextTitle(subtitleStr, new Font("SansSerif", Font.BOLD, 12));
    chart.addSubtitle(subtitle);
    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue));
    return chart;

}

From source file:org.jfree.chart.demo.JFreeChartDemoBase.java

/**
 * Creates and returns a sample meter chart.
 *
 * @return a meter chart./* www. j a  v a 2  s  . c om*/
 */
public JFreeChart createMeterChartCircle() {

    // create a default chart based on some sample data...
    final String title = this.resources.getString("meter.meter.title");
    final String subtitleStr = this.resources.getString("meter.meter.subtitle");
    //String units = resources.getString("meter.meter.units");
    //DefaultMeterDataset data = DemoDatasetFactory.createMeterDataset();
    final DefaultValueDataset data = new DefaultValueDataset(50.0);
    //data.setUnits(units);
    final MeterPlot plot = new MeterPlot(data);
    plot.setMeterAngle(270);
    plot.setDialShape(DialShape.CIRCLE);
    final JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false);

    // then customise it a little...
    final TextTitle subtitle = new TextTitle(subtitleStr, new Font("SansSerif", Font.BOLD, 12));
    chart.addSubtitle(subtitle);
    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue));
    return chart;
}

From source file:org.jfree.chart.demo.JFreeChartDemoBase.java

/**
 * Creates and returns a sample meter chart.
 *
 * @return a meter chart./*www  . ja v a2  s .  c o  m*/
 */
public JFreeChart createMeterChartPie() {

    // create a default chart based on some sample data...
    final String title = this.resources.getString("meter.meter.title");
    final String subtitleStr = this.resources.getString("meter.meter.subtitle");
    //String units = resources.getString("meter.meter.units");
    //DefaultMeterDataset data = DemoDatasetFactory.createMeterDataset();
    final DefaultValueDataset data = new DefaultValueDataset(50.0);
    //data.setUnits(units);
    final MeterPlot plot = new MeterPlot(data);
    plot.setMeterAngle(270);
    plot.setDialShape(DialShape.PIE);
    final JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false);

    // then customise it a little...
    final TextTitle subtitle = new TextTitle(subtitleStr, new Font("SansSerif", Font.BOLD, 12));
    chart.addSubtitle(subtitle);
    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue));
    return chart;
}

From source file:org.jfree.chart.demo.JFreeChartDemoBase.java

/**
 * Creates and returns a sample meter chart.
 *
 * @return the meter chart.//from   w  w  w .j av a 2s. c  o m
 */
public JFreeChart createMeterChartChord() {

    // create a default chart based on some sample data...
    final String title = this.resources.getString("meter.meter.title");
    final String subtitleStr = this.resources.getString("meter.meter.subtitle");
    //String units = resources.getString("meter.meter.units");
    //DefaultMeterDataset data = DemoDatasetFactory.createMeterDataset();
    final DefaultValueDataset data = new DefaultValueDataset(45.0);
    //data.setUnits(units);
    final MeterPlot plot = new MeterPlot(data);
    plot.setMeterAngle(270);
    plot.setDialShape(DialShape.CHORD);
    final JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false);

    // then customise it a little...
    final TextTitle subtitle = new TextTitle(subtitleStr, new Font("SansSerif", Font.BOLD, 12));
    chart.addSubtitle(subtitle);
    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue));
    return chart;
}

From source file:org.jfree.chart.demo.JFreeChartDemoBase.java

/**
 * Creates a compass chart./*from  ww  w  . ja  v  a  2 s.  c om*/
 *
 * @return a compass chart.
 */
public JFreeChart createCompassChart() {

    // create a default chart based on some sample data...
    final String title = this.resources.getString("meter.compass.title");
    final String subtitleStr = this.resources.getString("meter.compass.subtitle");
    final DefaultValueDataset data = new DefaultValueDataset(new Double(45.0));

    final Plot plot = new CompassPlot(data);
    final JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false);

    // then customise it a little...
    final TextTitle subtitle = new TextTitle(subtitleStr, new Font("SansSerif", Font.BOLD, 12));
    chart.addSubtitle(subtitle);
    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue));
    return chart;
}