Example usage for java.awt Color green

List of usage examples for java.awt Color green

Introduction

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

Prototype

Color green

To view the source code for java.awt Color green.

Click Source Link

Document

The color green.

Usage

From source file:financepro.XYLineChartExample.java

License:asdf

private JPanel createChartPanel() {
    // creates a line chart object
    // returns the chart panel
    String chartTitle = "Various Financial Ratios";
    String xAxisLabel = "Years";
    String yAxisLabel = "Ratio Values";

    XYDataset dataset = createDataset();

    JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, xAxisLabel, yAxisLabel, dataset);

    XYPlot plot = chart.getXYPlot();//w w w  .j  a va 2s  .  c o  m
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    plot.setRenderer(renderer);

    renderer.setSeriesPaint(0, Color.RED);
    renderer.setSeriesPaint(1, Color.GREEN);
    renderer.setSeriesPaint(2, Color.YELLOW);
    renderer.setSeriesPaint(3, Color.CYAN);
    renderer.setSeriesPaint(4, Color.BLACK);

    renderer.setSeriesStroke(0, new BasicStroke(4.0f));
    renderer.setSeriesStroke(1, new BasicStroke(4.0f));
    renderer.setSeriesStroke(2, new BasicStroke(4.0f));
    renderer.setSeriesStroke(3, new BasicStroke(4.0f));
    renderer.setSeriesStroke(4, new BasicStroke(4.0f));

    plot.setRenderer(renderer);
    plot.setOutlinePaint(Color.BLUE);
    plot.setOutlineStroke(new BasicStroke(4.0f));
    plot.setBackgroundPaint(Color.DARK_GRAY);

    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.BLACK);

    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.BLACK);

    return new ChartPanel(chart);
}

From source file:com.voterData.graph.Graph.java

public static JFreeChart getGenderDistChart(Map<String, Double> dataMap) {
    DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset();
    for (String key : dataMap.keySet()) {
        if (key.equals("Male_Dem_2008")) {
            defaultcategorydataset.addValue(dataMap.get(key), "DEM", "Male_2008");
        } else if (key.equals("Male_Rep_2008")) {
            defaultcategorydataset.addValue(dataMap.get(key), "REP", "Male_2008");
        } else if (key.equals("Male_Una_2008")) {
            defaultcategorydataset.addValue(dataMap.get(key), "UNA", "Male_2008");
        } else if (key.equals("Female_Dem_2008")) {
            defaultcategorydataset.addValue(dataMap.get(key), "DEM", "Female_2008");
        } else if (key.equals("Female_Rep_2008")) {
            defaultcategorydataset.addValue(dataMap.get(key), "REP", "Female_2008");
        } else if (key.equals("Female_Una_2008")) {
            defaultcategorydataset.addValue(dataMap.get(key), "UNA", "Female_2008");
        } else if (key.equals("Male_Dem_2012")) {
            defaultcategorydataset.addValue(dataMap.get(key), "DEM", "Male_2012");
        } else if (key.equals("Male_Rep_2012")) {
            defaultcategorydataset.addValue(dataMap.get(key), "REP", "Male_2012");
        } else if (key.equals("Male_Una_2012")) {
            defaultcategorydataset.addValue(dataMap.get(key), "UNA", "Male_2012");
        } else if (key.equals("Female_Dem_2012")) {
            defaultcategorydataset.addValue(dataMap.get(key), "DEM", "Female_2012");
        } else if (key.equals("Female_Rep_2012")) {
            defaultcategorydataset.addValue(dataMap.get(key), "REP", "Female_2012");
        } else if (key.equals("Female_Una_2012")) {
            defaultcategorydataset.addValue(dataMap.get(key), "UNA", "Female_2012");
        }/*from   www  .  j av a2 s  .co  m*/
    }
    JFreeChart jfreechart = ChartFactory.createStackedBarChart("Gender based Distribution", "Gender_Year",
            "% of Votes", defaultcategorydataset, PlotOrientation.VERTICAL, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setRangeGridlinePaint(Color.white);
    StackedBarRenderer stackedbarrenderer = (StackedBarRenderer) categoryplot.getRenderer();
    stackedbarrenderer.setDrawBarOutline(false);
    stackedbarrenderer.setItemLabelsVisible(true);
    stackedbarrenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    stackedbarrenderer.setSeriesItemLabelGenerator(0, new StandardCategoryItemLabelGenerator());
    stackedbarrenderer.setSeriesPaint(0, Color.blue);
    stackedbarrenderer.setSeriesPaint(1, Color.red);
    stackedbarrenderer.setSeriesPaint(2, Color.green);
    return jfreechart;

}

From source file:grafici.StatisticheBarChart.java

/**
 * Creates a sample chart.//ww w .  j  ava2 s . c om
 * 
 * @param dataset
 *            the dataset.
 * 
 * @return The chart.
 */
private static JFreeChart createChart(CategoryDataset dataset, Table results, int variabile, int valore) {

    // create the chart...
    JFreeChart chart = ChartFactory.createBarChart(titolo, // chart
            // title
            "", // domain axis label
            results.getColumn(valore).getText().toUpperCase(), // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    CategoryPlot plot = (CategoryPlot) chart.getPlot();

    // ******************************************************************
    // More than 150 demo applications are included with the JFreeChart
    // Developer Guide...for more information, see:
    //
    // > http://www.object-refinery.com/jfreechart/guide.html
    //
    // ******************************************************************

    // set the range axis to display integers only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // disable bar outlines...
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);

    // set up gradient paints for series...
    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));
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 12.0));
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:edu.ucla.stat.SOCR.chart.demo.BarChartDemo4.java

protected JFreeChart createLegend(CategoryDataset dataset) {

    //  JFreeChart chart = ChartFactory.createAreaChart(
    JFreeChart chart = ChartFactory.createBarChart(chartTitle, // chart title
            domainLabel, // domain axis label
            rangeLabel, // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );/* w  w w.j  a va  2s.  co  m*/

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white);
    CategoryPlot plot = chart.getCategoryPlot();

    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.lightGray);
    GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.lightGray);

    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    // renderer.setDrawOutlines(true);
    // renderer.setUseFillPaint(true);
    // renderer.setFillPaint(Color.white);
    renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());
    return chart;

}

From source file:Client.Gui.TeamBarChart.java

/**
 * Creates a sample chart.//from   w w  w  .  jav  a  2 s. c om
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
private JFreeChart createChart(final CategoryDataset dataset) {

    // create the chart...
    final JFreeChart chart = ChartFactory.createBarChart("Distribution of Trainging", // chart title
            "", // domain axis label
            "", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    // set the range axis to display integers only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // disable bar outlines...
    final BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);

    // set up gradient paints for series...
    final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.lightGray);
    final GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.lightGray);
    final GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, Color.lightGray);
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);

    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));

    return chart;

}

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

private static JFreeChart createBarChart(CategoryDataset dataset) {

    JFreeChart chart = ChartFactory.createBarChart("Bar Chart Demo 1", // chart title
            "Category", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.HORIZONTAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );/*from   w w w .  j a v a 2 s  .c om*/

    chart.setBackgroundPaint(Color.white);

    CategoryPlot plot = (CategoryPlot) chart.getPlot();

    // set the range axis to display integers only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // disable bar outlines...
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);

    // set up gradient paints for series...
    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));
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));

    return chart;

}

From source file:joshua.ui.hypergraph_visualizer.HyperGraphViewer.java

private Transformer<Vertex, Paint> vertexPainter() {
    return new Transformer<Vertex, Paint>() {
        private Color[] colors = { Color.blue, Color.red, Color.yellow, Color.green, Color.cyan };

        public Paint transform(Vertex v) {
            return colors[v.getColor() % colors.length];
        }/*from w  w w .  j  a  v  a 2  s  .  com*/
    };
}

From source file:edu.ucla.stat.SOCR.chart.demo.LayeredBarChartDemo1.java

/**
 * Creates a sample chart.//from  w  ww . ja  v a 2  s .c  o  m
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
protected JFreeChart createChart(CategoryDataset dataset) {

    // create the chart...
    JFreeChart chart = ChartFactory.createBarChart(chartTitle, // chart title
            domainLabel, // domain axis label
            rangeLabel, // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            !legendPanelOn, // include legend
            true, // tooltips?
            false // URLs?
    );

    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    // set the range axis to display integers only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // disable bar outlines...
    LayeredBarRenderer renderer = new LayeredBarRenderer();
    renderer.setDrawBarOutline(false);
    plot.setRenderer(renderer);

    // for this renderer, we need to draw the first series last...
    plot.setRowRenderingOrder(SortOrder.DESCENDING);

    // set up gradient paints for series...
    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));
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);
    renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());
    setCategorySummary(dataset);
    return chart;

}

From source file:edu.ucla.stat.SOCR.chart.demo.LayeredBarChartDemo2.java

/**
 * Creates a sample chart./*from   ww  w. j a va  2  s.  co m*/
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
protected JFreeChart createChart(CategoryDataset dataset) {

    // create the chart...
    JFreeChart chart = ChartFactory.createBarChart(chartTitle, // chart title
            domainLabel, // domain axis label
            rangeLabel, // range axis label
            dataset, // data
            PlotOrientation.HORIZONTAL, // orientation
            !legendPanelOn, // include legend
            true, // tooltips?
            false // URLs?
    );

    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    // set the range axis to display integers only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // disable bar outlines...
    LayeredBarRenderer renderer = new LayeredBarRenderer();
    renderer.setDrawBarOutline(false);
    plot.setRenderer(renderer);

    // for this renderer, we need to draw the first series last...
    plot.setRowRenderingOrder(SortOrder.DESCENDING);

    // set up gradient paints for series...
    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));
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);
    renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());
    setCategorySummary(dataset);
    return chart;

}

From source file:edu.ucla.stat.SOCR.applications.demo.StockSimulationApplication.java

void updateGraph() {
    //System.out.println("UpdateGraph get called")
    calculate();/*w w  w.  j a  va2 s.c  o  m*/

    XYSeriesCollection ds = createDataset();

    JFreeChart chart = ChartFactory.createXYLineChart(title, // chart title
            xAxis, // x axis label
            yAxis, // y axis label
            ds, // data
            PlotOrientation.VERTICAL, false, // include legend
            true, // tooltips
            false // urls
    );
    chart.setBackgroundPaint(Color.white);
    XYPlot subplot1 = (XYPlot) chart.getPlot();
    XYLineAndShapeRenderer renderer1 = (XYLineAndShapeRenderer) subplot1.getRenderer();

    renderer1.setSeriesPaint(0, Color.red);
    renderer1.setSeriesPaint(1, Color.blue);
    renderer1.setSeriesPaint(2, Color.green);
    renderer1.setSeriesPaint(3, Color.gray);

    /* Shape shape = renderer1.getBaseShape();
     renderer1.setSeriesShape(2, shape);
     renderer1.setSeriesShape(3, shape);*/
    renderer1.setBaseLinesVisible(true);
    renderer1.setBaseShapesVisible(true);
    renderer1.setBaseShapesFilled(true);

    chartPanel = new ChartPanel(chart, false);
    chartPanel.setPreferredSize(new Dimension(CHART_SIZE_X, CHART_SIZE_Y));

    upContainer = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(leftPanel),
            new JScrollPane(chartPanel));

    this.getMainPanel().removeAll();
    this.getMainPanel().add(new JScrollPane(upContainer), BorderLayout.CENTER);
    this.getMainPanel().validate();
    //  getRecordTable().setText("Any Explaination goes here.");

    //
}