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:Pear.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    Dimension d = getSize();/*from   ww w.j  a v a2  s  .c om*/
    int w = d.width;
    int h = d.height;
    double ew = w / 2;
    double eh = h / 2;

    g2.setColor(Color.green);

    // Creates the first leaf by filling the intersection of two Area objects
    // created from an ellipse.
    leaf.setFrame(ew - 16, eh - 29, 15.0, 15.0);
    leaf1 = new Area(leaf);
    leaf.setFrame(ew - 14, eh - 47, 30.0, 30.0);
    leaf2 = new Area(leaf);
    leaf1.intersect(leaf2);
    g2.fill(leaf1);

    // Creates the second leaf.
    leaf.setFrame(ew + 1, eh - 29, 15.0, 15.0);
    leaf1 = new Area(leaf);
    leaf2.intersect(leaf1);
    g2.fill(leaf2);

    g2.setColor(Color.black);

    // Creates the stem by filling the Area resulting from the subtraction of
    // two Area objects created from an ellipse.
    stem.setFrame(ew, eh - 42, 40.0, 40.0);
    st1 = new Area(stem);
    stem.setFrame(ew + 3, eh - 47, 50.0, 50.0);
    st2 = new Area(stem);
    st1.subtract(st2);
    g2.fill(st1);

    g2.setColor(Color.yellow);

    // Creates the pear itself by filling the Area resulting from the union of
    // two Area objects created by two different ellipses.
    circle.setFrame(ew - 25, eh, 50.0, 50.0);
    oval.setFrame(ew - 19, eh - 20, 40.0, 70.0);
    circ = new Area(circle);
    ov = new Area(oval);
    circ.add(ov);
    g2.fill(circ);
}

From source file:es.bsc.autonomic.powermodeller.graphics.TotalPowerAndPredictionDifference.java

private static JFreeChart createChart() {
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart(NAME, "Power (Watts)", "Power (Watts)", data,
            true, true, false);//w  w w  .j  a  v a  2s.com
    jfreechart.setBackgroundPaint(Color.white);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    XYDifferenceRenderer xydifferencerenderer = new XYDifferenceRenderer(Color.green, Color.yellow, false);
    xydifferencerenderer.setRoundXCoordinates(true);
    xyplot.setDomainCrosshairLockedOnData(true);
    xyplot.setRangeCrosshairLockedOnData(true);
    xyplot.setDomainCrosshairVisible(true);
    xyplot.setRangeCrosshairVisible(true);
    xyplot.setRenderer(xydifferencerenderer);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    DateAxis dateaxis = new DateAxis("Samples");
    dateaxis.setTickLabelsVisible(false);
    dateaxis.setLowerMargin(0.0D);
    dateaxis.setUpperMargin(0.0D);
    xyplot.setDomainAxis(dateaxis);
    xyplot.setForegroundAlpha(0.5F);
    return jfreechart;
}

From source file:com.github.nbyl.xfdcontrol.plugins.notification.blink1.Blink1NotificationPlugin.java

@VisibleForTesting
Color mapStatusToColor(JobStatus.Status status) {
    switch (status) {
    case SUCCESS:
        return Color.green;
    case TESTS_FAILING:
        return Color.YELLOW;
    case FAILED:/*from   w  w  w  .j  a v  a 2 s .c o  m*/
        return Color.RED;
    }

    return Color.ORANGE;
}

From source file:ClipArea.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    int w = getSize().width;
    int h = getSize().height;

    if (clip) {/*from   w w w.j  a  v a  2s .com*/
        Ellipse2D e = new Ellipse2D.Float(w / 4.0f, h / 4.0f, w / 2.0f, h / 2.0f);
        g2.setClip(e);

        g2.setColor(Color.yellow);
        g2.fillRect(0, 0, w, h);
    }

    if (clipFurther) {
        Rectangle r = new Rectangle(w / 2, h / 2, w / 2, h / 2);
        g2.clip(r);

        g2.setColor(Color.green);
        g2.fillRect(0, 0, w, h);
    }
}

From source file:net.sf.dynamicreports.test.jasper.chart.ChartSeriesColorsByNameTest.java

@Override
protected void configureReport(JasperReportBuilder rb) {
    TextColumnBuilder<String> column1;
    TextColumnBuilder<String> column2;
    TextColumnBuilder<Integer> column3;
    TextColumnBuilder<String> column4;
    TextColumnBuilder<Integer> column5;

    colors = new HashMap<String, Color>();
    colors.put("a", Color.BLUE);
    colors.put("b", Color.YELLOW);
    colors.put("c", Color.GREEN);
    colors.put("d", Color.MAGENTA);

    rb.columns(column1 = col.column("Column1", "field1", String.class),
            column2 = col.column("Column2", "field2", String.class),
            column3 = col.column("Column3", "field3", Integer.class),
            column4 = col.column("Column4", "field4", String.class),
            column5 = col.column("Column5", "field5", Integer.class))
            .summary(/*  w  w  w .j a v  a 2 s  .c  o  m*/
                    cmp.horizontalList(
                            cht.barChart().seriesColorsByName(colors).setCategory(column1)
                                    .series(cht.serie(column3).setSeries(column2)),
                            cht.groupedStackedBarChart().seriesColorsByName(colors).setCategory(column1)
                                    .series(cht.groupedSerie(column3).setSeries(column2).setGroup(column4))),
                    cmp.horizontalList(
                            cht.pieChart().seriesColorsByName(colors).setKey(column2).series(cht
                                    .serie(column3)),
                            cht.xyBarChart().seriesColorsByName(colors).setXValue(column5)
                                    .series(cht.xySerie(column3).setSeries(column2))),
                    cmp.horizontalList(
                            cht.barChart()
                                    .setDataSource(
                                            new DRDataSource("field1", "field2", "field3", "field4", "field5"))
                                    .seriesColorsByName(colors).setCategory(column1)
                                    .series(cht.serie(column3).setSeries(column2)),
                            cht.pieChart()
                                    .setDataSource(
                                            new DRDataSource("field1", "field2", "field3", "field4", "field5"))
                                    .seriesColorsByName(colors).setKey(column2).series(cht.serie(column3)),
                            cht.xyBarChart()
                                    .setDataSource(
                                            new DRDataSource("field1", "field2", "field3", "field4", "field5"))
                                    .seriesColorsByName(colors).setXValue(column5)
                                    .series(cht.xySerie(column3).setSeries(column2))));
}

From source file:org.talend.dataprofiler.chart.preview.HideSeriesGanttRenderer.java

/**
 * Creates a new renderer.//from  w  w w .  j a v  a2 s. co  m
 */
public HideSeriesGanttRenderer() {
    super();
    setIncludeBaseInRange(false);
    this.completePaint = Color.green;
    this.incompletePaint = Color.red;
    this.startPercent = 0.35;
    this.endPercent = 0.65;
}

From source file:net.sf.profiler4j.console.AllocDiffPanel.java

public AllocDiffPanel(int maxAgeMillis) {
    super(new BorderLayout());

    totalSeries = new TimeSeries("Allocs/Sec", Millisecond.class);
    totalSeries.setMaximumItemAge(maxAgeMillis);

    TimeSeriesCollection seriesCollection = new TimeSeriesCollection();
    seriesCollection.addSeries(totalSeries);

    NumberAxis numberAxis = new NumberAxis("Allocs/Sec");
    numberAxis.setLabelFont(new Font("SansSerif", 0, 14));
    numberAxis.setTickLabelFont(new Font("SansSerif", 0, 12));
    numberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    DateAxis dateAxis = new DateAxis("Time");
    dateAxis.setTickLabelFont(new Font("SansSerif", 0, 12));
    dateAxis.setLabelFont(new Font("SansSerif", 0, 14));
    dateAxis.setAutoRange(true);/*from   ww  w  .ja  v a2 s . co  m*/
    dateAxis.setLowerMargin(0);
    dateAxis.setUpperMargin(0);
    dateAxis.setTickLabelsVisible(true);
    dateAxis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss"));

    XYLineAndShapeRenderer lineRenderer = new XYLineAndShapeRenderer(true, false);
    lineRenderer.setSeriesPaint(0, Color.RED);
    lineRenderer.setSeriesPaint(1, Color.GREEN.darker());
    lineRenderer.setStroke(new BasicStroke(2F, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));

    XYPlot xyplot = new XYPlot(seriesCollection, dateAxis, numberAxis, lineRenderer);
    xyplot.setBackgroundPaint(Color.WHITE);
    xyplot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    xyplot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));

    JFreeChart chart = new JFreeChart("Object Allocactions in Remote JVM",
            new Font("SansSerif", Font.PLAIN, 18), xyplot, true);
    chart.setBackgroundPaint(Color.white);

    ChartPanel panel = new ChartPanel(chart);
    panel.setBorder(createCompoundBorder(createEmptyBorder(8, 8, 8, 8), createLineBorder(Color.LIGHT_GRAY)));
    add(panel);
    setBorder(createEmptyBorder(8, 8, 8, 8));
}

From source file:org.jfree.graphics2d.demo.ImageTest.java

private static void drawArcTest(Graphics2D g2) {
    g2.setPaint(Color.GREEN);
    g2.drawRect(0, 20, 70, 50);/*w w  w  . jav a 2  s.  c  o  m*/
    g2.setPaint(Color.RED);
    Path2D path1 = new Path2D.Double();
    double[] pts = calculateReferenceArc(90);
    path1.moveTo(pts[0], pts[1]);
    path1.curveTo(pts[2], pts[3], pts[4], pts[5], pts[6], pts[7]);
    AffineTransform t = new AffineTransform();
    t.translate(35, 45);
    t.scale(35, 25);
    t.rotate(Math.PI / 4);
    path1.transform(t);
    g2.draw(path1);

    Path2D path2 = new Path2D.Double();
    path2.moveTo(pts[0], pts[1]);
    path2.curveTo(pts[2], pts[3], pts[4], pts[5], pts[6], pts[7]);
    AffineTransform t2 = new AffineTransform();
    t2.rotate(3 * Math.PI / 4);
    t2.scale(35, 25);
    t2.translate(35, 35);
    path2.transform(t2);
    //g2.draw(path2);
    Path2D arc = new Path2D.Double();
    arc.append(path1, false);
    arc.append(path2, false);
    //g2.draw(arc);
    //g2.draw(path1);
    //g2.transform(t);
    g2.setPaint(Color.BLUE);
    g2.drawArc(0, 20, 70, 50, 0, -270);
    //Arc2D arc2d = new Arc2D.Double(0d, 20d, 70d, 50d, 0d, 90, Arc2D.OPEN);
    //g2.draw(arc2d);
}

From source file:de.berlios.statcvs.xml.chart.AbstractTimeSeriesChart.java

/**
 * @param filename/*from  w  w  w.j ava  2 s . c  om*/
 * @param title
 */
public AbstractTimeSeriesChart(ReportSettings settings, String filename, String title, String rangeLabel) {
    super(settings, filename, title);

    tsc = new TimeSeriesCollection();

    setChart(ChartFactory.createTimeSeriesChart(settings.getProjectName(), I18n.tr("Date"), rangeLabel, tsc,
            true, true, false));

    //Paint[] colors = new Paint[1];
    //colors[0] = Color.blue;
    //getChart().getPlot().setSeriesPaint(colors);

    // setup axis
    XYPlot plot = getChart().getXYPlot();
    ValueAxis axis = plot.getDomainAxis();
    axis.setVerticalTickLabels(true);
    plot.setRenderer(new XYStepRenderer());

    // the 4th color is yellow which has almost no contrast to the white 
    // background color, therefore we use a different color
    plot.getRenderer().setSeriesPaint(0, Color.red);
    plot.getRenderer().setSeriesPaint(1, Color.blue);
    plot.getRenderer().setSeriesPaint(2, Color.green);
    plot.getRenderer().setSeriesPaint(3, Color.magenta);
    plot.getRenderer().setSeriesPaint(4, Color.orange);
    plot.getRenderer().setSeriesPaint(5, Color.cyan);
    plot.getRenderer().setSeriesPaint(6, Color.pink);
}

From source file:trendgraph.XYLineChart_AWT.java

public XYLineChart_AWT(int yearStart, int yearEnd, String[] creditUnionName, String columnName)
        throws SQLException {
    super("Graph");
    super.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    this.yearStart = yearStart;
    this.yearEnd = yearEnd;
    this.creditUnionName = creditUnionName;
    this.columnName = columnName;
    saveGraphButton = new JButton("Save Graph");
    saveGraphButton.setBorderPainted(false);
    saveGraphButton.setFocusPainted(false);

    JFreeChart xylineChart = ChartFactory.createXYLineChart("CU Report", "Year (YYYY)", //X-axis
            columnName, //Y-axis (replace with columnName
            createDataset(), PlotOrientation.VERTICAL, true, true, false);

    ChartPanel chartPanel = new ChartPanel(xylineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(1000, 800)); //(x, y)
    final XYPlot plot = xylineChart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();

    renderer.setSeriesPaint(0, Color.RED); //can be GREEN, YELLOW, ETC.

    renderer.setSeriesStroke(0, new BasicStroke(3.0f)); //Font size

    renderer.setSeriesPaint(1, Color.BLUE); //can be GREEN, YELLOW, ETC.

    renderer.setSeriesStroke(1, new BasicStroke(3.0f)); //Font size

    renderer.setSeriesPaint(2, Color.GREEN); //can be GREEN, YELLOW, ETC.

    renderer.setSeriesStroke(2, new BasicStroke(3.0f)); //Font size

    renderer.setSeriesPaint(3, Color.yellow); //can be GREEN, YELLOW, ETC.

    renderer.setSeriesStroke(3, new BasicStroke(3.0f)); //Font size

    plot.setRenderer(renderer);//from w  ww. ja  v a2  s .  c  om
    chartPanel.setLayout(new FlowLayout(FlowLayout.TRAILING));
    chartPanel.add(saveGraphButton);
    setContentPane(chartPanel);
    pack();
    RefineryUtilities.centerFrameOnScreen(this);
    setVisible(true);

    saveGraphButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Rectangle rect = chartPanel.getBounds();
            FileChooser chooser = new FileChooser();

            //get chosen path and save the variable
            String path = chooser.getPath();
            path = path.replace("\\", "/");

            String format = "png";
            String fileName = path + "." + format;
            BufferedImage captureImage = new BufferedImage(rect.width, rect.height,
                    BufferedImage.TYPE_INT_ARGB);
            chartPanel.paint(captureImage.getGraphics());

            File file = new File(fileName);

            try {
                ImageIO.write(captureImage, format, file);

                //write data to file
            } catch (IOException ex) {
                Logger.getLogger(XYLineChart_AWT.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    });
}