Example usage for java.awt Color gray

List of usage examples for java.awt Color gray

Introduction

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

Prototype

Color gray

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

Click Source Link

Document

The color gray.

Usage

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

private static JFreeChart createChart(ValueDataset valuedataset) {
    CompassPlot compassplot = new CompassPlot(valuedataset);
    compassplot.setSeriesNeedle(7);//from   w  w w .ja  v a2 s.c om
    compassplot.setSeriesPaint(0, Color.black);
    compassplot.setSeriesOutlinePaint(0, Color.black);
    compassplot.setRosePaint(Color.red);
    compassplot.setRoseHighlightPaint(Color.gray);
    compassplot.setRoseCenterPaint(Color.white);
    compassplot.setDrawBorder(false);
    JFreeChart jfreechart = new JFreeChart(compassplot);
    return jfreechart;
}

From source file:Main.java

public Main() {
    setSize(200, 150);//from   w  w w  . ja  v  a  2  s  .com
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    JLayeredPane lp = getLayeredPane();
    JButton top = new JButton();
    top.setBackground(Color.white);
    top.setBounds(20, 20, 50, 50);
    JButton middle = new JButton();
    middle.setBackground(Color.gray);
    middle.setBounds(40, 40, 50, 50);
    JButton bottom = new JButton();
    bottom.setBackground(Color.black);
    bottom.setBounds(60, 60, 50, 50);

    lp.add(middle, new Integer(2));
    lp.add(top, new Integer(3));
    lp.add(bottom, new Integer(1));

    setVisible(true);
}

From source file:MyCanvas.java

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

    //Draw the open arc 
    Arc2D.Float arc = new Arc2D.Float(Arc2D.OPEN);
    arc.setFrame(140, 100, 67, 46);//from w  w  w  . j  a  v  a2  s  .c o m
    arc.setAngleStart(45);
    arc.setAngleExtent(270);
    g2.setColor(Color.gray);
    g2.draw(arc);
    g2.setColor(Color.green);
    g2.fill(arc);
    g2.setColor(Color.black);
    g2.drawString("Arc2D.OPEN", 140, 90);
}

From source file:MyCanvas.java

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

    // Draw the pie chart
    Arc2D.Float arc = new Arc2D.Float(Arc2D.PIE);
    arc.setFrame(140, 200, 67, 46);/*from  ww w  .j a v a2 s .c  o m*/
    arc.setAngleStart(45);
    arc.setAngleExtent(270);
    g2.setColor(Color.gray);
    g2.draw(arc);
    g2.setColor(Color.red);
    g2.fill(arc);
    g2.setColor(Color.black);
    g2.drawString("Arc2D.PIE", 140, 190);
}

From source file:org.gumtree.vis.awt.DefaultChartTheme.java

public static Paint[] createDefaultPaintArray() {

    return new Paint[] { ChartColor.DARK_BLUE, ChartColor.DARK_GREEN, ChartColor.DARK_MAGENTA,
            ChartColor.DARK_CYAN, ChartColor.DARK_RED, ChartColor.DARK_YELLOW, Color.darkGray,
            new Color(0xFF, 0x55, 0x55), new Color(0x55, 0x55, 0xFF), new Color(0x00, 0x77, 0x00),
            new Color(0x77, 0x77, 0x00), new Color(0xCA, 0x00, 0xCA), new Color(0x00, 0x88, 0x88),
            //            Color.pink,
            Color.gray,
            //            ChartColor.LIGHT_RED,
            //            ChartColor.LIGHT_BLUE,
            //            ChartColor.LIGHT_GREEN,
            //            ChartColor.LIGHT_YELLOW,
            //            ChartColor.LIGHT_MAGENTA,
            //            ChartColor.LIGHT_CYAN,
            //            Color.lightGray,
            ChartColor.VERY_DARK_RED, ChartColor.VERY_DARK_BLUE, ChartColor.VERY_DARK_GREEN,
            ChartColor.VERY_DARK_YELLOW, ChartColor.VERY_DARK_MAGENTA, ChartColor.VERY_DARK_CYAN,
            ChartColor.VERY_LIGHT_RED, ChartColor.VERY_LIGHT_BLUE, ChartColor.VERY_LIGHT_GREEN,
            ChartColor.VERY_LIGHT_YELLOW, ChartColor.VERY_LIGHT_MAGENTA, ChartColor.VERY_LIGHT_CYAN };
}

From source file:ColorBlocks.java

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

    Dimension d = getSize();//from w  ww .j  a v a  2  s .  c o m
    g2.translate(d.width / 2, d.height / 2);

    Color[] colors = { Color.white, Color.lightGray, Color.gray, Color.darkGray, Color.black, Color.red,
            Color.pink, Color.orange, Color.yellow, Color.green, Color.magenta, Color.cyan, Color.blue };

    float size = 25;
    float x = -size * colors.length / 2;
    float y = -size * 3 / 2;

    // Show all the predefined colors.
    for (int i = 0; i < colors.length; i++) {
        Rectangle2D r = new Rectangle2D.Float(x + size * (float) i, y, size, size);
        g2.setPaint(colors[i]);
        g2.fill(r);
    }

    //a linear gradient.
    y += size;
    Color c1 = Color.yellow;
    Color c2 = Color.blue;
    for (int i = 0; i < colors.length; i++) {
        float ratio = (float) i / (float) colors.length;
        int red = (int) (c2.getRed() * ratio + c1.getRed() * (1 - ratio));
        int green = (int) (c2.getGreen() * ratio + c1.getGreen() * (1 - ratio));
        int blue = (int) (c2.getBlue() * ratio + c1.getBlue() * (1 - ratio));
        Color c = new Color(red, green, blue);
        Rectangle2D r = new Rectangle2D.Float(x + size * (float) i, y, size, size);
        g2.setPaint(c);
        g2.fill(r);
    }

    // Show an alpha gradient.
    y += size;
    c1 = Color.red;
    for (int i = 0; i < colors.length; i++) {
        int alpha = (int) (255 * (float) i / (float) colors.length);
        Color c = new Color(c1.getRed(), c1.getGreen(), c1.getBlue(), alpha);
        Rectangle2D r = new Rectangle2D.Float(x + size * (float) i, y, size, size);
        g2.setPaint(c);
        g2.fill(r);
    }

    // Draw a frame around the whole thing.
    y -= size * 2;
    Rectangle2D frame = new Rectangle2D.Float(x, y, size * colors.length, size * 3);
    g2.setPaint(Color.black);
    g2.draw(frame);
}

From source file:PaintingAndStroking.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    double x = 15, y = 50, w = 70, h = 70;
    Ellipse2D e = new Ellipse2D.Double(x, y, w, h);
    GradientPaint gp = new GradientPaint(75, 75, Color.white, 95, 95, Color.gray, true);
    // Fill with a gradient.
    g2.setPaint(gp);//from w  ww.  j a v a 2 s . c  om
    g2.fill(e);
    // Stroke with a solid color.
    e.setFrame(x + 100, y, w, h);
    g2.setPaint(Color.black);
    g2.setStroke(new BasicStroke(8));
    g2.draw(e);
    // Stroke with a gradient.
    e.setFrame(x + 200, y, w, h);
    g2.setPaint(gp);
    g2.draw(e);
}

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

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createXYLineChart("XYLine3DRenderer Demo 1", "X", "Y", xydataset,
            PlotOrientation.VERTICAL, true, true, false);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    XYLine3DRenderer xyline3drenderer = new XYLine3DRenderer();
    xyline3drenderer.setWallPaint(Color.gray);
    xyline3drenderer.setXOffset(2D);/*from w  w  w  .  j a v  a  2 s.  c o  m*/
    xyline3drenderer.setYOffset(3D);
    xyline3drenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    xyline3drenderer.setDefaultEntityRadius(6);
    xyplot.setRenderer(xyline3drenderer);
    return jfreechart;
}

From source file:Main.java

public Main() {
    super("LayeredPane");
    setSize(200, 150);//from   w  w w.j av  a2s . com
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    JLayeredPane lp = getLayeredPane();

    // Create 3 buttons
    JButton top = new JButton();
    top.setBackground(Color.white);
    top.setBounds(20, 20, 50, 50);
    JButton middle = new JButton();
    middle.setBackground(Color.gray);
    middle.setBounds(40, 40, 50, 50);
    JButton bottom = new JButton();
    bottom.setBackground(Color.black);
    bottom.setBounds(60, 60, 50, 50);

    // Place the buttons in different layers
    lp.add(middle, new Integer(2));
    lp.add(top, new Integer(3));
    lp.add(bottom, new Integer(1));
}

From source file:RTFView.java

public RTFView() {
    setTitle("RTF Text Application");
    setSize(400, 240);//from w  ww.  ja  va  2  s.co  m
    setBackground(Color.gray);
    getContentPane().setLayout(new BorderLayout());

    JPanel topPanel = new JPanel();
    topPanel.setLayout(new BorderLayout());
    getContentPane().add(topPanel, BorderLayout.CENTER);

    // Create an RTF editor window
    RTFEditorKit rtf = new RTFEditorKit();
    JEditorPane editor = new JEditorPane();
    editor.setEditorKit(rtf);
    editor.setBackground(Color.white);

    // This text could be big so add a scroll pane
    JScrollPane scroller = new JScrollPane();
    scroller.getViewport().add(editor);
    topPanel.add(scroller, BorderLayout.CENTER);

    // Load an RTF file into the editor
    try {
        FileInputStream fi = new FileInputStream("test.rtf");
        rtf.read(fi, editor.getDocument(), 0);
    } catch (FileNotFoundException e) {
        System.out.println("File not found");
    } catch (IOException e) {
        System.out.println("I/O error");
    } catch (BadLocationException e) {
    }
}