Example usage for java.awt Color darkGray

List of usage examples for java.awt Color darkGray

Introduction

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

Prototype

Color darkGray

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

Click Source Link

Document

The color dark gray.

Usage

From source file:Main.java

public static void main(String[] args) {
    JLabel label = new JLabel("First Name");
    label.setForeground(Color.darkGray);

    JFrame frame = new JFrame();
    frame.add(label);//from   ww  w . ja va2 s .c o m
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setBounds(20, 20, 500, 500);
    frame.setVisible(true);
}

From source file:ComplexRenderingSample.java

public static void main(String args[]) {

    Object elements[][] = {/*from   w w  w . j av a2  s . c  om*/
            { new Font("Helvetica", Font.PLAIN, 20), Color.red, new DiamondIcon(Color.blue), "Help" },
            { new Font("TimesRoman", Font.BOLD, 14), Color.blue, new DiamondIcon(Color.green), "Me" },
            { new Font("Courier", Font.ITALIC, 18), Color.green, new DiamondIcon(Color.black), "I'm" },
            { new Font("Helvetica", Font.BOLD | Font.ITALIC, 12), Color.gray, new DiamondIcon(Color.magenta),
                    "Trapped" },
            { new Font("TimesRoman", Font.PLAIN, 32), Color.pink, new DiamondIcon(Color.yellow), "Inside" },
            { new Font("Courier", Font.BOLD, 16), Color.yellow, new DiamondIcon(Color.red), "This" },
            { new Font("Helvetica", Font.ITALIC, 8), Color.darkGray, new DiamondIcon(Color.pink),
                    "Computer" } };

    JFrame frame = new JFrame("Complex Renderer");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container contentPane = frame.getContentPane();

    JList jlist = new JList(elements);
    ListCellRenderer renderer = new ComplexCellRenderer();
    jlist.setCellRenderer(renderer);
    JScrollPane scrollPane = new JScrollPane(jlist);
    contentPane.add(scrollPane, BorderLayout.CENTER);

    JComboBox comboBox = new JComboBox(elements);
    comboBox.setRenderer(renderer);
    contentPane.add(comboBox, BorderLayout.NORTH);

    frame.setSize(300, 300);
    frame.setVisible(true);
}

From source file:ColorComboBox.java

public static void main(String args[]) {
    Color colors[] = { Color.black, Color.blue, Color.cyan, Color.darkGray, Color.gray, Color.green,
            Color.lightGray, Color.magenta, Color.orange, Color.pink, Color.red, Color.white, Color.yellow };
    JFrame frame = new JFrame("Color JComboBox");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container contentPane = frame.getContentPane();

    final JComboBox comboBox = new JComboBox(colors);
    comboBox.setMaximumRowCount(5);// w w w . j a va 2  s.c o  m
    comboBox.setEditable(true);
    comboBox.setRenderer(new ColorCellRenderer());
    Color color = (Color) comboBox.getSelectedItem();
    ComboBoxEditor editor = new ColorComboBoxEditor(color);
    comboBox.setEditor(editor);
    contentPane.add(comboBox, BorderLayout.NORTH);

    final JLabel label = new JLabel();
    label.setOpaque(true);
    label.setBackground((Color) comboBox.getSelectedItem());
    contentPane.add(label, BorderLayout.CENTER);

    ActionListener actionListener = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            Color selectedColor = (Color) comboBox.getSelectedItem();
            label.setBackground(selectedColor);
        }
    };
    comboBox.addActionListener(actionListener);

    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:com.oculusinfo.ml.spark.unsupervised.TestDPMeans.java

/**
 * @param args/*from   w  w  w.  ja v  a  2 s  . c  om*/
 */
public static void main(String[] args) {
    int k = 5;

    try {
        FileUtils.deleteDirectory(new File("output/clusters"));
        FileUtils.deleteDirectory(new File("output/centroids"));
    } catch (IOException e1) {
        /* ignore (*/ }

    genTestData(k);

    JavaSparkContext sc = new JavaSparkContext("local", "OculusML");
    SparkDataSet ds = new SparkDataSet(sc);
    ds.load("test.txt", new InstanceParser());

    DPMeansClusterer clusterer = new DPMeansClusterer(80, 10, 0.001);
    clusterer.setOutputPaths("output/centroids", "output/clusters");

    clusterer.registerFeatureType("point", MeanNumericVectorCentroid.class, new EuclideanDistance(1.0));

    clusterer.doCluster(ds);

    try {
        final List<double[]> instances = readInstances();

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

        TestDPMeans t = new TestDPMeans();
        t.add(new JComponent() {
            private static final long serialVersionUID = 7920802321066846416L;

            public void paintComponent(Graphics g) {
                Graphics2D g2 = (Graphics2D) g;
                g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

                for (double[] inst : instances) {
                    int color = (int) inst[0];
                    g.setColor(colors[color]);

                    Ellipse2D l = new Ellipse2D.Double(inst[1], inst[2], 5, 5);
                    g2.draw(l);
                }
            }
        });

        t.setDefaultCloseOperation(EXIT_ON_CLOSE);
        t.setSize(400, 400);
        t.setVisible(true);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

From source file:com.oculusinfo.ml.spark.unsupervised.TestThresholdClusterer.java

/**
 * @param args//from  ww w. j  a  va 2  s.  c  o  m
 */
public static void main(String[] args) {
    int k = 5;

    try {
        FileUtils.deleteDirectory(new File("output/clusters"));
        FileUtils.deleteDirectory(new File("output/centroids"));
    } catch (IOException e1) {
        /* ignore (*/ }

    genTestData(k);

    JavaSparkContext sc = new JavaSparkContext("local", "OculusML");
    SparkDataSet ds = new SparkDataSet(sc);
    ds.load("test.txt", new InstanceParser());

    ThresholdClusterer clusterer = new ThresholdClusterer(80);
    clusterer.setOutputPaths("output/centroids", "output/clusters");

    clusterer.registerFeatureType("point", MeanNumericVectorCentroid.class, new EuclideanDistance(1.0));

    clusterer.doCluster(ds);

    try {
        final List<double[]> instances = readInstances();

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

        TestThresholdClusterer t = new TestThresholdClusterer();
        t.add(new JComponent() {
            private static final long serialVersionUID = -5597119848880912541L;

            public void paintComponent(Graphics g) {
                Graphics2D g2 = (Graphics2D) g;
                g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

                for (double[] inst : instances) {
                    int color = (int) inst[0];
                    g.setColor(colors[color]);

                    Ellipse2D l = new Ellipse2D.Double(inst[1], inst[2], 5, 5);
                    g2.draw(l);
                }
            }
        });

        t.setDefaultCloseOperation(EXIT_ON_CLOSE);
        t.setSize(400, 400);
        t.setVisible(true);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

From source file:com.oculusinfo.ml.spark.unsupervised.TestKMeans.java

/**
 * @param args//from  www.  ja v a2 s.c o  m
 */
public static void main(String[] args) {
    int k = 5;

    try {
        FileUtils.deleteDirectory(new File("output/clusters"));
        FileUtils.deleteDirectory(new File("output/centroids"));
    } catch (IOException e1) {
        /* ignore (*/ }

    genTestData(k);

    JavaSparkContext sc = new JavaSparkContext("local", "OculusML");
    SparkDataSet ds = new SparkDataSet(sc);
    ds.load("test.txt", new SparkInstanceParser() {
        private static final long serialVersionUID = 1L;

        @Override
        public Tuple2<String, Instance> call(String line) throws Exception {
            Instance inst = new Instance();

            String tokens[] = line.split(",");

            NumericVectorFeature v = new NumericVectorFeature("point");

            double x = Double.parseDouble(tokens[0]);
            double y = Double.parseDouble(tokens[1]);
            v.setValue(new double[] { x, y });

            inst.addFeature(v);

            return new Tuple2<String, Instance>(inst.getId(), inst);
        }
    });

    KMeansClusterer clusterer = new KMeansClusterer(k, 10, 0.001, "output/centroids", "output/clusters");

    clusterer.registerFeatureType("point", MeanNumericVectorCentroid.class, new EuclideanDistance(1.0));

    clusterer.doCluster(ds);

    try {
        final List<double[]> instances = readInstances();

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

        TestKMeans t = new TestKMeans();
        t.add(new JComponent() {
            private static final long serialVersionUID = 2059497051387104848L;

            public void paintComponent(Graphics g) {
                Graphics2D g2 = (Graphics2D) g;
                g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

                for (double[] inst : instances) {
                    int color = (int) inst[0];
                    g.setColor(colors[color]);

                    Ellipse2D l = new Ellipse2D.Double(inst[1], inst[2], 5, 5);
                    g2.draw(l);
                }
            }
        });

        t.setDefaultCloseOperation(EXIT_ON_CLOSE);
        t.setSize(400, 400);
        t.setVisible(true);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

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,/*from  ww w .  j a v a  2 s. c  om*/
            //            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();//w  w  w.  j  a v  a 2s.  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:org.jfree.chart.demo.MeterChartDemo1.java

private static JFreeChart createChart(ValueDataset valuedataset) {
    MeterPlot meterplot = new MeterPlot(valuedataset);
    meterplot.setRange(new Range(0.0D, 60D));
    meterplot.addInterval(new MeterInterval("Normal", new Range(0.0D, 35D), Color.lightGray,
            new BasicStroke(2.0F), new Color(0, 255, 0, 64)));
    meterplot.addInterval(new MeterInterval("Warning", new Range(35D, 50D), Color.lightGray,
            new BasicStroke(2.0F), new Color(255, 255, 0, 64)));
    meterplot.addInterval(new MeterInterval("Critical", new Range(50D, 60D), Color.lightGray,
            new BasicStroke(2.0F), new Color(255, 0, 0, 128)));
    meterplot.setNeedlePaint(Color.darkGray);
    meterplot.setDialBackgroundPaint(Color.white);
    meterplot.setDialOutlinePaint(Color.gray);
    meterplot.setDialShape(DialShape.CHORD);
    meterplot.setMeterAngle(260);/*from   www .  j av a2 s  .  c  om*/
    meterplot.setTickLabelsVisible(true);
    meterplot.setTickLabelFont(new Font("Dialog", 1, 10));
    meterplot.setTickLabelPaint(Color.darkGray);
    meterplot.setTickSize(5D);
    meterplot.setTickPaint(Color.lightGray);
    meterplot.setValuePaint(Color.black);
    meterplot.setValueFont(new Font("Dialog", 1, 14));
    JFreeChart jfreechart = new JFreeChart("Meter Chart 1", JFreeChart.DEFAULT_TITLE_FONT, meterplot, true);
    return jfreechart;
}

From source file:MainClass.java

public MainClass() {
    super(true);/* w ww  .jav  a  2  s . c o  m*/

    JSlider mySlider = new JSlider();
    mySlider.setMajorTickSpacing(20);
    mySlider.setMinorTickSpacing(10);
    mySlider.setPaintTicks(true);
    mySlider.setPaintLabels(true);

    CurvedBorder border = new CurvedBorder(10, Color.darkGray);
    mySlider.setBorder(border);

    add(mySlider);
}