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:Client.Gui.BarChart.java

/**
* Creates a sample chart.//from  w w w .  j  a  v  a2  s  .  c  o m
* 
* @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);
    final GradientPaint gp3 = new GradientPaint(0.0f, 0.0f, Color.magenta, 0.0f, 0.0f, Color.lightGray);
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);
    renderer.setSeriesPaint(3, gp3);
    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));

    return chart;

}

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

/**
 * Creates a sample chart./*from   ww w. j ava2 s  . co m*/
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
protected JFreeChart createChart(CategoryDataset dataset) {
    domainLabel = "Category";
    rangeLabel = "Value";
    // 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?
    );

    // 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 = 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...
    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);
    renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());

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

    /*Summary s = new Summary(dataset);
            
            
            
      LegendTitle legend = new LegendTitle(chart.getPlot());
              
      BlockContainer wrapper = new BlockContainer(new BorderArrangement());
      wrapper.setBorder(new BlockBorder(1.0, 1.0, 1.0, 1.0));
            
    LegendItemSource[] legendSource= legend.getSources();
    LegendItemCollection old_legendItems = legendSource[0].getLegendItems();
    LegendItemCollection new_legendItems = new LegendItemCollection();
            
    int legendCount  = old_legendItems.getItemCount();
    for (int i=0; i<legendCount; i++){
       LegendItem old_legendItem = old_legendItems.get(i);
            
       String legendLabel = old_legendItem.getLabel();
       System.out.println("legendLabel="+old_legendLabel);
       LegendItem new_legendItem = new LegendItem(
                                  old_legendItem.getLabel()+s.getSummary(i),
                                  old_legendItem.getDescription(),
                                  old_legendItem.getToolTipText(),
                                  old_legendItem.getURLText(),
                                  old_legendItem.isShapeVisible(),
                                  old_legendItem.getShape(),
                                  old_legendItem.isShapeFilled(),
                                  old_legendItem.getFillPaint(),
                                  old_legendItem.isShapeOutlineVisible(),
                                  old_legendItem.getOutlinePaint(),
                                  old_legendItem.getOutlineStroke(),
                                  old_legendItem.isLineVisible(),
                                  old_legendItem.getLine(),
                                  old_legendItem.getLineStroke(),
                                  old_legendItem.getlinePaint()
                                  );
       new_legendItems.add(new_legendItem);
       }
              
            
      // *** this is important - you need to add the item container to
      // the wrapper, otherwise the legend items won't be displayed when
      // the wrapper is drawn... ***
      BlockContainer items = legend.getItemContainer();
      items.setPadding(2, 10, 5, 2);
      wrapper.add(items);
      legend.setWrapper(wrapper);
              
      legend.setPosition(RectangleEdge.BOTTOM);
      legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
      chart.addSubtitle(legend);*/

    setCategorySummary(dataset);
    return chart;

}

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

/**
 * Creates a chart./*from w  w  w .  j av  a  2  s  .  c  o m*/
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
protected JFreeChart createChart(XYDataset dataset) {
    JFreeChart chart = ChartFactory.createTimeSeriesChart(chartTitle, domainLabel, rangeLabel, dataset,
            !legendPanelOn, // legend
            true, // tool tips
            false // URLs
    );
    chart.setBackgroundPaint(Color.white);

    XYPlot plot = chart.getXYPlot();
    plot.setRenderer(new XYDifferenceRenderer(Color.green, Color.red, false));
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));

    XYItemRenderer renderer = plot.getRenderer();
    renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());

    ValueAxis domainAxis = new DateAxis("Time");
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    plot.setDomainAxis(domainAxis);
    plot.setForegroundAlpha(0.5f);

    //setXSummary(dataset) X is time;          
    return chart;

}

From source file:reports.util.BarChart2Scriptlet.java

/**
 *
 *///from   w  w w  . ja v a 2  s .co m
public void afterReportInit() throws JRScriptletException {

    JFreeChart jfreechart = ChartFactory.createBarChart("Bar Chart Demo", // chart title
            "States", // X Label
            "Sell Amount", // Y Label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );

    jfreechart.setBackgroundPaint(Color.white);
    CategoryPlot categoryplot = jfreechart.getCategoryPlot();
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setDomainGridlinePaint(Color.white);
    categoryplot.setRangeGridlinePaint(Color.white);

    LegendTitle legendtitle = (LegendTitle) jfreechart.getSubtitle(0);
    legendtitle.setPosition(RectangleEdge.RIGHT);
    legendtitle.setMargin(new RectangleInsets(UnitType.ABSOLUTE, 0.0D, 4D, 0.0D, 4D));

    IntervalMarker intervalmarker = new IntervalMarker(200D, 250D);
    intervalmarker.setLabel("Target Range");
    intervalmarker.setLabelFont(new Font("SansSerif", 2, 11));
    intervalmarker.setLabelAnchor(RectangleAnchor.LEFT);
    intervalmarker.setLabelTextAnchor(TextAnchor.CENTER_LEFT);
    intervalmarker.setPaint(new Color(222, 222, 255, 128));
    categoryplot.addRangeMarker(intervalmarker, Layer.BACKGROUND);

    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer();
    barrenderer.setDrawBarOutline(false);
    barrenderer.setItemMargin(0.10000000000000001D);

    GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, new Color(0, 0, 64));
    GradientPaint gradientpaint1 = new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, new Color(0, 64, 0));
    GradientPaint gradientpaint2 = new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, new Color(64, 0, 0));

    barrenderer.setSeriesPaint(0, gradientpaint);
    barrenderer.setSeriesPaint(1, gradientpaint1);
    barrenderer.setSeriesPaint(2, gradientpaint2);

    barrenderer.setItemLabelGenerator(new LabelGenerator());
    barrenderer.setItemLabelsVisible(true);
    //ItemLabelPosition itemlabelposition = new ItemLabelPosition(ItemLabelAnchor.INSIDE12, TextAnchor.CENTER_RIGHT, TextAnchor.CENTER_RIGHT, -1.5707963267948966D);
    //barrenderer.setPositiveItemLabelPosition(itemlabelposition);

    ItemLabelPosition itemlabelposition1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12,
            TextAnchor.CENTER_LEFT, TextAnchor.CENTER_LEFT, -1.5707963267948966D);
    barrenderer.setPositiveItemLabelPositionFallback(itemlabelposition1);

    CategoryAxis categoryaxis = categoryplot.getDomainAxis();
    categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    /*   */
    this.setVariableValue("Chart", new JCommonDrawableRenderer(jfreechart));
}

From source file:PlotDriver.java

void penColor(int c) {
    switch (c) {//from  w  ww .j av  a  2 s  .  c  o  m
    case 0:
        g.setColor(Color.white);
        break;
    case 1:
        g.setColor(Color.black);
        break;
    case 2:
        g.setColor(Color.red);
        break;
    case 3:
        g.setColor(Color.green);
        break;
    case 4:
        g.setColor(Color.blue);
        break;
    default:
        g.setColor(new Color(c));
        break;
    }
}

From source file:BarChartDemo.java

/**
 * Creates a sample chart.//from w w  w .j  av 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("Bar Chart Demo", // chart title
            "Category", // domain axis label
            "Value", // 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 customization...
    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:cytoscape.render.immed.GraphGraphicsTest.java

private long drawCurrentFull(Random rand) {
    final float nodeSizeFactor = 50f;
    float size = (float) canvasSize;

    long begin = System.nanoTime();
    for (int i = 0; i < numNodes; i++) {
        float x = rand.nextFloat() * (rand.nextBoolean() ? size : -size);
        float y = rand.nextFloat() * (rand.nextBoolean() ? size : -size);
        currentGraphGraphics.drawNodeFull((byte) (i % (int) GraphGraphics.s_last_shape), x, y,
                (x + (rand.nextFloat() * nodeSizeFactor)), (y + (rand.nextFloat() * nodeSizeFactor)),
                Color.blue, 1.0f + (i % 10), Color.yellow);
    }// ww  w  .ja v a 2 s .  c  o m
    long end = System.nanoTime();
    long nodeDur = end - begin;

    BasicStroke edgeStroke = new BasicStroke(1f);

    begin = System.nanoTime();
    for (int i = 0; i < numEdges; i++) {
        currentGraphGraphics.drawEdgeFull((byte) ((i % 7) - 8), rand.nextFloat() * (20f), Color.red,
                (byte) ((i % 7) - 8), rand.nextFloat() * (20f), Color.orange,
                rand.nextFloat() * (rand.nextBoolean() ? size : -size),
                rand.nextFloat() * (rand.nextBoolean() ? size : -size), currentGraphGraphics.m_noAnchors,
                rand.nextFloat() * (rand.nextBoolean() ? size : -size),
                rand.nextFloat() * (rand.nextBoolean() ? size : -size), 1f, edgeStroke, Color.green);
    }
    end = System.nanoTime();
    long duration = (end - begin) + nodeDur;

    //      try {
    //         ImageIO.write(image,"PNG",new File("/tmp/homer-current-" + rand.nextInt(100) + ".png"));
    //      } catch (IOException ioe) { ioe.printStackTrace(); }
    return duration;
}

From source file:com.joey.software.plottingToolkit.PlotingToolkit.java

public static Color getPlotColor(int number) {
    switch (number) {
    case 0:/*  w ww. j av  a  2  s .c om*/
        return Color.RED;
    case 1:
        return Color.GREEN;
    case 2:
        return Color.BLUE;
    case 3:
        return Color.CYAN;
    case 4:
        return Color.PINK;
    case 5:
        return Color.magenta;
    default:
        return ImageOperations.getRandomColor();
    }
}

From source file:com.fiveamsolutions.nci.commons.kmplot.KMPlotServiceTest.java

private KMPlot getPlot() {
    KMPlotConfiguration configuration = new KMPlotConfiguration();
    configuration.setTitle("title");
    configuration.setDurationLabel("duration");
    configuration.setProbabilityLabel("probability");
    configuration.getGroups().add(createGroup("group 1", 2, Color.RED));
    configuration.getGroups().add(createGroup("group 2", 5, Color.GREEN));
    configuration.getGroups().add(createGroup("group 3", 2, Color.BLUE));
    configuration.getGroups().add(createGroup("group 4", 1, Color.BLACK));
    configuration.getGroups().add(createGroup("group 5", 1, Color.GRAY));
    KMPlot plot = new KMPlotServiceImpl().generatePlot(configuration);
    assertNotNull(plot);// w  w  w . j a  v  a2 s . c om
    assertNotNull(plot.getConfiguration());
    assertNotNull(plot.getConfiguration().getGroups());
    assertEquals(5, plot.getConfiguration().getGroups().size());
    verifyGroup(plot, 0, "group 1", 2, Color.RED);
    verifyGroup(plot, 1, "group 2", 5, Color.GREEN);
    verifyGroup(plot, 2, "group 3", 2, Color.BLUE);
    verifyGroup(plot, 3, "group 4", 1, Color.BLACK);
    verifyGroup(plot, 4, "group 5", 1, Color.GRAY);
    return plot;
}

From source file:org.geopublishing.atlasStyler.classification.FeatureClassification.java

@Override
public BufferedImage createHistogramImage(boolean showMean, boolean showSd, int histogramBins,
        String label_xachsis) throws InterruptedException, IOException {
    HistogramDataset hds = new HistogramDataset();
    DoubleArrayList valuesAL;/*  w w w  .ja  va 2 s  . c o m*/
    valuesAL = getStatistics().elements();
    // new double[] {0.4,3,4,2,5.,22.,4.,2.,33.,12.}
    double[] elements = Arrays.copyOf(valuesAL.elements(), getStatistics().size());
    hds.addSeries(1, elements, histogramBins);

    /** Statically label the Y Axis **/
    String label_yachsis = ASUtil.R("QuantitiesClassificationGUI.Histogram.YAxisLabel");

    JFreeChart chart = org.jfree.chart.ChartFactory.createHistogram(null, label_xachsis, label_yachsis, hds,
            PlotOrientation.VERTICAL, false, true, true);

    /***********************************************************************
     * Paint the classes into the JFreeChart
     */
    int countLimits = 0;
    for (Double cLimit : getClassLimits()) {
        ValueMarker marker = new ValueMarker(cLimit);
        XYPlot plot = chart.getXYPlot();
        marker.setPaint(Color.orange);
        marker.setLabel(String.valueOf(countLimits));
        marker.setLabelAnchor(RectangleAnchor.TOP_LEFT);
        marker.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
        plot.addDomainMarker(marker);

        countLimits++;
    }

    /***********************************************************************
     * Optionally painting SD and MEAN into the histogram
     */
    try {
        if (showSd) {
            ValueMarker marker;
            marker = new ValueMarker(getStatistics().standardDeviation(), Color.green.brighter(),
                    new BasicStroke(1.5f));
            XYPlot plot = chart.getXYPlot();
            marker.setLabel(ASUtil.R("QuantitiesClassificationGUI.Histogram.SD.ShortLabel"));
            marker.setLabelAnchor(RectangleAnchor.BOTTOM_LEFT);
            marker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
            plot.addDomainMarker(marker);
        }

        if (showMean) {
            ValueMarker marker;
            marker = new ValueMarker(getStatistics().mean(), Color.green.darker(), new BasicStroke(1.5f));
            XYPlot plot = chart.getXYPlot();
            marker.setLabel(ASUtil.R("QuantitiesClassificationGUI.Histogram.Mean.ShortLabel"));
            marker.setLabelAnchor(RectangleAnchor.BOTTOM_LEFT);
            marker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
            plot.addDomainMarker(marker);
        }

    } catch (Exception e) {
        LOGGER.error("Painting SD and MEAN into the histogram", e);
    }

    /***********************************************************************
     * Render the Chart
     */
    BufferedImage image = chart.createBufferedImage(400, 200);

    return image;
}