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:org.jfree.chart.demo.MouseOverDemo1.java

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createBarChart("Mouseover Demo 1", "Category", "Value",
            categorydataset, PlotOrientation.VERTICAL, true, true, false);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setDomainGridlinesVisible(true);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    MyBarRenderer mybarrenderer = new MyBarRenderer();
    mybarrenderer.setDrawBarOutline(true);
    categoryplot.setRenderer(mybarrenderer);
    ChartUtilities.applyCurrentTheme(jfreechart);
    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));
    mybarrenderer.setSeriesPaint(0, gradientpaint);
    mybarrenderer.setSeriesPaint(1, gradientpaint1);
    mybarrenderer.setSeriesPaint(2, gradientpaint2);
    return jfreechart;
}

From source file:components.CrayonPanel.java

public void actionPerformed(ActionEvent e) {
    Color newColor = null;/* ww w .j a v  a2  s .c  o  m*/
    String command = ((JToggleButton) e.getSource()).getActionCommand();
    if ("green".equals(command))
        newColor = Color.green;
    else if ("red".equals(command))
        newColor = Color.red;
    else if ("yellow".equals(command))
        newColor = Color.yellow;
    else if ("blue".equals(command))
        newColor = Color.blue;
    getColorSelectionModel().setSelectedColor(newColor);
}

From source file:charts.PieChart3D.java

/**
 * Creates a chart.// w  w w  .j  a v  a  2 s .c  o  m
 *
 * @param dataset
 *            the dataset.
 *
 * @return A chart.
 */
private static JFreeChart createChart(PieDataset dataset, PieChartModel model) {

    JFreeChart chart = ChartFactory.createPieChart(model.getTitle(), // chart
            // title
            dataset, // data
            false, // no legend
            true, // tooltips
            false // no URL generation
    );

    // set a custom background for the chart
    chart.setBackgroundPaint(
            new GradientPaint(new Point(0, 0), new Color(20, 20, 20), new Point(400, 200), Color.DARK_GRAY));

    // customise the title position and font
    TextTitle t = chart.getTitle();
    t.setHorizontalAlignment(HorizontalAlignment.LEFT);
    t.setPaint(new Color(240, 240, 240));
    t.setFont(new Font("Arial", Font.BOLD, 26));

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setBackgroundPaint(null);
    plot.setInteriorGap(0.04);
    plot.setOutlineVisible(false);

    // use gradients and white borders for the section colours
    plot.setSectionPaint("FCA", createGradientPaint(new Color(200, 200, 255), Color.BLUE));
    plot.setSectionPaint("FCH", createGradientPaint(new Color(255, 200, 200), Color.RED));
    plot.setSectionPaint("FCS", createGradientPaint(new Color(200, 255, 200), Color.GREEN));
    plot.setSectionPaint("FCG", createGradientPaint(new Color(200, 255, 200), Color.YELLOW));
    plot.setSectionPaint("FCJ", createGradientPaint(new Color(200, 255, 200), Color.BLACK));
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} {1} ({2}) "));
    plot.setBaseSectionOutlinePaint(Color.WHITE);
    plot.setSectionOutlinesVisible(true);
    plot.setBaseSectionOutlineStroke(new BasicStroke(2.0f));

    // customise the section label appearance
    plot.setLabelFont(new Font("Courier New", Font.BOLD, 20));
    plot.setLabelLinkPaint(Color.WHITE);
    plot.setLabelLinkStroke(new BasicStroke(2.0f));
    plot.setLabelOutlineStroke(null);
    plot.setLabelPaint(Color.WHITE);
    plot.setLabelBackgroundPaint(null);

    // add a subtitle giving the data source
    TextTitle source = new TextTitle(model.getSubTitle(), new Font("Courier New", Font.PLAIN, 12));
    source.setPaint(Color.WHITE);
    source.setPosition(RectangleEdge.BOTTOM);
    source.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    chart.addSubtitle(source);
    return chart;

}

From source file:common.AbstractGUI.java

protected void createLogPanel() {
    logPanel = new JPanel();
    logPanel.setLayout(new BoxLayout(logPanel, BoxLayout.Y_AXIS));

    logTextArea = new JTextArea(33, 30);
    logTextArea.setEditable(false);//from w w  w  .  ja  va 2s. c  o m
    logTextArea.setAutoscrolls(true);
    logTextArea.setFont(new Font("Courier New", Font.PLAIN, 11));
    logTextArea.setBackground(Color.DARK_GRAY);
    logTextArea.setForeground(Color.GREEN);
    logTextArea.addMouseListener(logTextAreaMouseListener);

    scrollPane = new JScrollPane(logTextArea);

    Box horizontalLayout = Box.createHorizontalBox();
    filterTxt = new JTextField();
    filterBtn = new JButton("Filter");
    filterBtn.addActionListener(filterActionListner);
    filterTxt.setMaximumSize(new Dimension(250, 30));
    horizontalLayout.add(filterTxt);
    horizontalLayout.add(filterBtn);
    logPanel.add(horizontalLayout);
    logPanel.add(scrollPane);
    tabbedPane.addTab("Log", logPanel);
}

From source file:org.openscience.cdk.applications.taverna.basicutilities.ChartTool.java

/**
 * Creates an area chart.//  w ww  .j  a va 2s . co  m
 * 
 * @param title
 * @param categoryAxisLabel
 *            (X-Axis label)
 * @param valueAxisLabel
 *            (Y-Axis label)
 * @param dataset
 * @return JfreeChart instance.
 */
public JFreeChart createAreaChart(String title, String categoryAxisLabel, String valueAxisLabel,
        CategoryDataset dataset) {
    JFreeChart chart = ChartFactory.createAreaChart(title, categoryAxisLabel, valueAxisLabel, dataset,
            this.orientation, this.drawLegend, false, false);
    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);
    chart.setAntiAlias(true);
    CategoryPlot plot = chart.getCategoryPlot();
    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setLowerMargin(0);
    domainAxis.setUpperMargin(0);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90);
    AreaRenderer renderer = (AreaRenderer) plot.getRenderer();
    renderer.setSeriesPaint(0, Color.blue);
    renderer.setSeriesPaint(1, Color.red);
    renderer.setSeriesPaint(2, Color.green);
    renderer.setSeriesPaint(3, Color.darkGray);
    renderer.setSeriesPaint(4, Color.yellow);
    return chart;
}

From source file:de.tor.tribes.ui.windows.ClockFrame.java

protected void updateTime(String time, int millis) {
    if (isVisible()) {
        jLabel1.setText(time);/*from  w  ww  .ja  va2 s.co m*/
        double markerMin = 0;
        double markerMax = 1000;
        double diff = markerMax - markerMin;
        float ratio = 0;
        if (diff > 0) {
            ratio = (float) ((millis - markerMin) / (markerMax - markerMin));
        }

        Color c1 = Color.GREEN;
        if (millis >= 500) {
            c1 = Color.YELLOW;
        }
        Color c2 = Color.RED;
        if (millis < 500) {
            c2 = Color.YELLOW;
            ratio += .5f;
        } else {
            ratio -= .5f;
        }
        int red = (int) Math.rint(c2.getRed() * ratio + c1.getRed() * (1f - ratio));
        int green = (int) Math.rint(c2.getGreen() * ratio + c1.getGreen() * (1f - ratio));
        int blue = (int) Math.rint(c2.getBlue() * ratio + c1.getBlue() * (1f - ratio));

        red = (red < 0) ? 0 : red;
        green = (green < 0) ? 0 : green;
        blue = (blue < 0) ? 0 : blue;
        red = (red > 255) ? 255 : red;
        green = (green > 255) ? 255 : green;
        blue = (blue > 255) ? 255 : blue;
        cp.setForeground(new Color(red, green, blue));
        cp.setValue(millis);
    }

    for (final TimerPanel p : timers.toArray(new TimerPanel[timers.size()])) {
        if (p.isExpired()) {
            SystrayHelper.showInfoMessage("Timer  '" + p.getName() + "' ist abgelaufen");
            //moved playing the sound to a new Thread because of graphic problems
            new Thread(new Runnable() {
                @Override
                public void run() {
                    playSound(p.getSound());
                }
            }).start();
            removeTimer(p);
        } else {
            p.update();
        }
    }
}

From source file:graphs.ResultsGraphs.java

/**
 * Creates a sample chart./*from  w  ww.jav 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("Mashup Language Sentiment Algorithm Performance ", // chart title
            "Performance Metric", // domain axis label
            "Value", // 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...
    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));
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:org.jfree.expdemo.SelectionDemo5Category.java

private static JFreeChart createChart(CategoryDataset dataset, DatasetSelectionExtension ext) {

    // create the chart...
    JFreeChart chart = ChartFactory.createBarChart("Bar Chart Demo 1", // chart title
            "Category", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );/*from  w ww . jav a  2 s  .co m*/

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setDomainGridlinesVisible(true);
    plot.setRangeCrosshairVisible(true);
    plot.setRangeCrosshairPaint(Color.blue);

    // 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.setLegendItemToolTipGenerator(new StandardCategorySeriesLabelGenerator("Tooltip: {0}"));

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

    //add selection specific rendering
    IRSUtilities.setSelectedItemPaint(renderer, ext, Color.WHITE);

    //register plot as selection change listener
    ext.addSelectionChangeListener(plot);

    return chart;

}

From source file:fitmon.Chart.java

/**
 * Creates a sample chart./* ww 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("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?
    );

    // 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...
    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));
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:GUI.PlotCreator.java

private ChartPanel createWindIntensityByTimePanel() {
    JFreeChart jfreechart = ChartFactory.createScatterPlot(title, "Time(Hours)", "Wind Instensity",
            createWindIntensityByTime(), PlotOrientation.VERTICAL, true, true, false);
    XYPlot xyPlot = (XYPlot) jfreechart.getPlot();
    xyPlot.setDomainCrosshairVisible(true);
    xyPlot.setRangeCrosshairVisible(true);
    XYItemRenderer renderer = xyPlot.getRenderer();
    renderer.setSeriesPaint(0, Color.GREEN);
    NumberAxis domain = (NumberAxis) xyPlot.getDomainAxis();
    //domain.setRange(0,24);
    domain.setTickUnit(new NumberTickUnit(1.0));
    domain.setVerticalTickLabels(true);/* ww w .ja  va 2  s.co  m*/

    return new ChartPanel(jfreechart);
}