Example usage for java.awt Color blue

List of usage examples for java.awt Color blue

Introduction

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

Prototype

Color blue

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

Click Source Link

Document

The color blue.

Usage

From source file:AntiAlias.java

/** Draw the example */
public void paint(Graphics g1) {
    Graphics2D g = (Graphics2D) g1;
    BufferedImage image = // Create an off-screen image
            new BufferedImage(65, 35, BufferedImage.TYPE_INT_RGB);
    Graphics2D ig = image.createGraphics(); // Get its Graphics for drawing

    // Set the background to a gradient fill. The varying color of
    // the background helps to demonstrate the anti-aliasing effect
    ig.setPaint(new GradientPaint(0, 0, Color.black, 65, 35, Color.white));
    ig.fillRect(0, 0, 65, 35);// w w  w. j  a v  a2s  . c om

    // Set drawing attributes for the foreground.
    // Most importantly, turn on anti-aliasing.
    ig.setStroke(new BasicStroke(2.0f)); // 2-pixel lines
    ig.setFont(new Font("Serif", Font.BOLD, 18)); // 18-point font
    ig.setRenderingHint(RenderingHints.KEY_ANTIALIASING, // Anti-alias!
            RenderingHints.VALUE_ANTIALIAS_ON);

    // Now draw pure blue text and a pure red oval
    ig.setColor(Color.blue);
    ig.drawString("Java", 9, 22);
    ig.setColor(Color.red);
    ig.drawOval(1, 1, 62, 32);

    // Finally, scale the image by a factor of 10 and display it
    // in the window. This will allow us to see the anti-aliased pixels
    g.drawImage(image, AffineTransform.getScaleInstance(10, 10), this);

    // Draw the image one more time at its original size, for comparison
    g.drawImage(image, 0, 0, this);
}

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

private static Paint[] createPaint() {
    Paint apaint[] = new Paint[5];
    apaint[0] = new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, Color.white);
    apaint[1] = new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, Color.white);
    apaint[2] = new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, Color.white);
    apaint[3] = new GradientPaint(0.0F, 0.0F, Color.orange, 0.0F, 0.0F, Color.white);
    apaint[4] = new GradientPaint(0.0F, 0.0F, Color.magenta, 0.0F, 0.0F, Color.white);
    return apaint;
}

From source file:ImageProcessing.RGBHistogram_GUI.java

public RGBHistogram_GUI(Component callerComponent) {
    //callerComponent is used only to determine the position of this
    //frame when called.
    initComponents();/*w  w  w.  j av a 2s . c o  m*/
    this.setLocationRelativeTo(callerComponent);

    //Determine the chart width & height for displaying.
    int chartLabelHeight = sourceImageGreenHistogram.getHeight();
    int chartLabelWidth = sourceImageGreenHistogram.getWidth();

    //Get values for each color component from source image.
    double[] sourceRedValues = ImageProcessing.extractRedColor(Main.getSourceImage());
    double[] sourceGreenValues = ImageProcessing.extractGreenColor(Main.getSourceImage());
    double[] sourceBlueValues = ImageProcessing.extractBlueColor(Main.getSourceImage());

    //Get values for each color component from processed image.
    double[] processedRedValues = ImageProcessing.extractRedColor(Main.getProcessedImage());
    double[] processedGreenValues = ImageProcessing.extractGreenColor(Main.getProcessedImage());
    double[] processedBlueValues = ImageProcessing.extractBlueColor(Main.getProcessedImage());

    //Create charts for each color component from source image.
    JFreeChart sourceRedChart = ImageProcessing.createHistogram(sourceRedValues, Color.RED);
    JFreeChart sourceGreenChart = ImageProcessing.createHistogram(sourceGreenValues, Color.GREEN);
    JFreeChart sourceBlueChart = ImageProcessing.createHistogram(sourceBlueValues, Color.BLUE);

    //Create charts for each color component from processed image.
    JFreeChart processedRedChart = ImageProcessing.createHistogram(processedRedValues, Color.RED);
    JFreeChart processedGreenChart = ImageProcessing.createHistogram(processedGreenValues, Color.GREEN);
    JFreeChart processedBlueChart = ImageProcessing.createHistogram(processedBlueValues, Color.BLUE);

    //Convert each source image charts to a BufferedImage.
    BufferedImage sourceRedChartImage = sourceRedChart.createBufferedImage(chartLabelWidth, chartLabelHeight);
    BufferedImage sourceGreenChartImage = sourceGreenChart.createBufferedImage(chartLabelWidth,
            chartLabelHeight);
    BufferedImage sourceBlueChartImage = sourceBlueChart.createBufferedImage(chartLabelWidth, chartLabelHeight);

    //Convert each processsed image charts to a BufferedImage.
    BufferedImage processedRedChartImage = processedRedChart.createBufferedImage(chartLabelWidth,
            chartLabelHeight);
    BufferedImage processedGreenChartImage = processedGreenChart.createBufferedImage(chartLabelWidth,
            chartLabelHeight);
    BufferedImage processedBlueChartImage = processedBlueChart.createBufferedImage(chartLabelWidth,
            chartLabelHeight);

    //Display each source image charts to GUI.
    sourceImageRedHistogram.setIcon(new ImageIcon(sourceRedChartImage));
    sourceImageGreenHistogram.setIcon(new ImageIcon(sourceGreenChartImage));
    sourceImageBlueHistogram.setIcon(new ImageIcon(sourceBlueChartImage));

    //Display each source image charts to GUI.
    processedImageRedHistogram.setIcon(new ImageIcon(processedRedChartImage));
    processedImageGreenHistogram.setIcon(new ImageIcon(processedGreenChartImage));
    processedImageBlueHistogram.setIcon(new ImageIcon(processedBlueChartImage));

}

From source file:com.leonarduk.finance.analysis.CashFlowToChart.java

/**
 * Adds the cash flow axis to the plot.//from w  ww  .  ja  va 2  s . c  o  m
 *
 * @param plot
 *            the plot
 * @param dataset
 *            the cash flow dataset
 */
private static void addCashFlowAxis(final XYPlot plot, final TimeSeriesCollection dataset) {
    final NumberAxis cashAxis = new NumberAxis("Cash Flow Ratio");
    cashAxis.setAutoRangeIncludesZero(false);
    plot.setRangeAxis(1, cashAxis);
    plot.setDataset(1, dataset);
    plot.mapDatasetToRangeAxis(1, 1);
    final StandardXYItemRenderer cashFlowRenderer = new StandardXYItemRenderer();
    cashFlowRenderer.setSeriesPaint(0, Color.blue);
    plot.setRenderer(1, cashFlowRenderer);
}

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

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createBarChart("Bar Chart Demo", "Category", "Value", categorydataset,
            PlotOrientation.VERTICAL, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setDomainGridlinePaint(Color.white);
    categoryplot.setDomainGridlinesVisible(true);
    categoryplot.setRangeGridlinePaint(Color.white);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer();
    barrenderer.setDrawBarOutline(false);
    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);
    CategoryAxis categoryaxis = categoryplot.getDomainAxis();
    categoryaxis.setCategoryLabelPositions(
            CategoryLabelPositions.createUpRotationLabelPositions(0.52359877559829882D));
    return jfreechart;
}

From source file:com.spotify.heroic.http.render.RenderUtils.java

public static JFreeChart createChart(final List<ShardedResultGroup> groups, final String title,
        Map<String, String> highlight, Double threshold, int height) {
    final XYLineAndShapeRenderer lineAndShapeRenderer = new XYLineAndShapeRenderer(true, true);
    final DeviationRenderer intervalRenderer = new DeviationRenderer();

    final XYSeriesCollection regularData = new XYSeriesCollection();
    final YIntervalSeriesCollection intervalData = new YIntervalSeriesCollection();

    int lineAndShapeCount = 0;
    int intervalCount = 0;

    for (final ShardedResultGroup resultGroup : groups) {
        final MetricCollection group = resultGroup.getMetrics();

        if (group.getType() == MetricType.POINT) {
            final XYSeries series = new XYSeries(resultGroup.getMetrics().toString());

            final List<Point> data = group.getDataAs(Point.class);

            for (final Point d : data) {
                series.add(d.getTimestamp(), d.getValue());
            }//from  ww w.ja  v a2s  .c o m

            lineAndShapeRenderer.setSeriesPaint(lineAndShapeCount, Color.BLUE);
            lineAndShapeRenderer.setSeriesShapesVisible(lineAndShapeCount, false);
            lineAndShapeRenderer.setSeriesStroke(lineAndShapeCount, new BasicStroke(2.0f));
            regularData.addSeries(series);
            ++lineAndShapeCount;
        }

        if (group.getType() == MetricType.SPREAD) {
            final YIntervalSeries series = new YIntervalSeries(resultGroup.getMetrics().toString());

            final List<Spread> data = group.getDataAs(Spread.class);

            for (final Spread d : data) {
                series.add(d.getTimestamp(), d.getSum() / d.getCount(), d.getMin(), d.getMax());
            }

            intervalRenderer.setSeriesPaint(intervalCount, Color.GREEN);
            intervalRenderer.setSeriesStroke(intervalCount, new BasicStroke(2.0f));
            intervalRenderer.setSeriesFillPaint(intervalCount, new Color(200, 255, 200));
            intervalRenderer.setSeriesShapesVisible(intervalCount, false);
            intervalData.addSeries(series);
            ++intervalCount;
        }
    }

    final JFreeChart chart = buildChart(title, regularData, intervalData, lineAndShapeRenderer,
            intervalRenderer);

    chart.setAntiAlias(true);
    chart.setBackgroundPaint(Color.WHITE);

    final XYPlot plot = chart.getXYPlot();

    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.BLACK);
    plot.setRangeGridlinePaint(Color.BLACK);

    if (threshold != null) {
        final ValueMarker marker = new ValueMarker(threshold, Color.RED,
                new BasicStroke(Math.max(Math.min(height / 20, 6), 1)), Color.RED, null, 0.5f);
        plot.addRangeMarker(marker);
    }

    plot.setRenderer(lineAndShapeRenderer);

    // final DateAxis rangeAxis = (DateAxis) plot.getRangeAxis();
    // rangeAxis.setStandardTickUnits(DateAxis.createStandardDateTickUnits());

    return chart;
}

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

private static JFreeChart createChart(CategoryDataset dataset) {
    JFreeChart chart = ChartFactory.createBarChart("SubCategoryAxis Demo 1", "Category", "Value", dataset,
            PlotOrientation.VERTICAL, false, true, false);
    chart.setBackgroundPaint(Color.white);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    SubCategoryAxis subCategoryAxis = new SubCategoryAxis(null);
    subCategoryAxis.addSubCategory("S1");
    subCategoryAxis.addSubCategory("S2");
    subCategoryAxis.addSubCategory("S3");
    plot.setDomainAxis(subCategoryAxis);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);
    NumberAxis valueAxis = (NumberAxis) plot.getRangeAxis();
    valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);/* w  ww  . j  av  a2s.  co  m*/
    GradientPaint gradientpaint0 = 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));
    renderer.setSeriesPaint(0, gradientpaint0);
    renderer.setSeriesPaint(1, gradientpaint1);
    renderer.setSeriesPaint(2, gradientpaint2);
    return chart;
}

From source file:PopUpColorMenu.java

public void actionPerformed(ActionEvent e) {
    String color = e.getActionCommand();
    if (color.equals("Red"))
        selectedComponent.setBackground(Color.red);
    else if (color.equals("Green"))
        selectedComponent.setBackground(Color.green);
    else if (color.equals("Blue"))
        selectedComponent.setBackground(Color.blue);
}

From source file:com.pureinfo.srm.common.ImageHelper.java

private static Color getColor() {
    Color[] names = new Color[] { Color.WHITE, Color.RED, Color.GREEN, Color.BLUE, Color.CYAN,
            Color.DARK_GRAY };/*w  w w  .j ava2 s  . c  o m*/
    return names[Math.abs(random.nextInt()) % names.length];
}

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

public static JPanel createDemoPanel() {
    JPanel jpanel = new JPanel(new GridLayout(2, 2));
    jpanel.setPreferredSize(new Dimension(800, 600));
    IntervalXYDataset intervalxydataset = createDataset();
    JFreeChart jfreechart = createChart("Vertical", intervalxydataset);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer();
    xybarrenderer.setDrawBarOutline(false);
    xybarrenderer.setSeriesPaint(0, new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, Color.yellow));
    xybarrenderer.setSeriesPaint(1, new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, Color.green));
    xybarrenderer.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL));
    ChartPanel chartpanel = new ChartPanel(jfreechart);
    jpanel.add(chartpanel);/*from w w  w  .ja  v  a2 s . com*/
    JFreeChart jfreechart1 = createChart("Vertical / Inverted Axis", intervalxydataset);
    XYPlot xyplot1 = (XYPlot) jfreechart1.getPlot();
    XYBarRenderer xybarrenderer1 = (XYBarRenderer) xyplot1.getRenderer();
    xybarrenderer1.setDrawBarOutline(false);
    xybarrenderer1.setSeriesPaint(0, new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, Color.yellow));
    xybarrenderer1.setSeriesPaint(1, new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, Color.green));
    xybarrenderer1.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL));
    xyplot1.getDomainAxis().setInverted(true);
    ChartPanel chartpanel1 = new ChartPanel(jfreechart1);
    jpanel.add(chartpanel1);
    JFreeChart jfreechart2 = createChart("Horizontal", intervalxydataset);
    XYPlot xyplot2 = (XYPlot) jfreechart2.getPlot();
    xyplot2.setOrientation(PlotOrientation.HORIZONTAL);
    XYBarRenderer xybarrenderer2 = (XYBarRenderer) xyplot2.getRenderer();
    xybarrenderer2.setDrawBarOutline(false);
    xybarrenderer2.setSeriesPaint(0, new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, Color.yellow));
    xybarrenderer2.setSeriesPaint(1, new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, Color.green));
    xybarrenderer2.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL));
    ChartPanel chartpanel2 = new ChartPanel(jfreechart2);
    jpanel.add(chartpanel2);
    JFreeChart jfreechart3 = createChart("Horizontal / Inverted Axis", intervalxydataset);
    XYPlot xyplot3 = (XYPlot) jfreechart3.getPlot();
    xyplot3.setOrientation(PlotOrientation.HORIZONTAL);
    XYBarRenderer xybarrenderer3 = (XYBarRenderer) xyplot3.getRenderer();
    xybarrenderer3.setDrawBarOutline(false);
    xybarrenderer3.setSeriesPaint(0, new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, Color.yellow));
    xybarrenderer3.setSeriesPaint(1, new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, Color.green));
    xybarrenderer3.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_HORIZONTAL));
    xyplot3.getDomainAxis().setInverted(true);
    ChartPanel chartpanel3 = new ChartPanel(jfreechart3);
    jpanel.add(chartpanel3);
    return jpanel;
}