Example usage for java.awt Color YELLOW

List of usage examples for java.awt Color YELLOW

Introduction

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

Prototype

Color YELLOW

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

Click Source Link

Document

The color yellow.

Usage

From source file:Main.java

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

    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    int cx = getSize().width / 2;
    int cy = getSize().height / 2;

    g2.translate(cx, cy);/*from   w  ww .j  a v a  2  s.  c  o  m*/
    g2.rotate(theta * Math.PI / 180);

    Shape oldClip = g2.getClip();
    Shape e = new Ellipse2D.Float(-cx, -cy, cx * 2, cy * 2);
    g2.clip(e);

    Shape c = new Ellipse2D.Float(-cx, -cy, cx * 3 / 4, cy * 2);
    g2.setPaint(new GradientPaint(40, 40, Color.blue, 60, 50, Color.white, true));
    g2.fill(c);

    g2.setPaint(Color.yellow);
    g2.fillOval(cx / 4, 0, cx, cy);

    g2.setClip(oldClip);

    g2.setFont(new Font("Times New Roman", Font.PLAIN, 64));
    g2.setPaint(new GradientPaint(-cx, 0, Color.red, cx, 0, Color.black, false));
    g2.drawString("Hello, 2D!", -cx * 3 / 4, cy / 4);

    AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float) .75);
    g2.setComposite(ac);

    Shape r = new RoundRectangle2D.Float(0, -cy * 3 / 4, cx * 3 / 4, cy * 3 / 4, 20, 20);
    g2.setStroke(new BasicStroke(4));
    g2.setPaint(Color.magenta);
    g2.fill(r);
    g2.setPaint(Color.green);
    g2.draw(r);

    g2.drawImage(image, -cx / 2, -cy / 2, this);
}

From source file:Main.java

public void drawImage() {
    Graphics2D g = img.createGraphics();
    RenderingHints hints = new RenderingHints(RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON);
    g.setRenderingHints(hints);/*from   w  w  w .j av  a 2 s.c o  m*/

    g.setStroke(new BasicStroke(4));
    for (Ellipse2D shape : shapes) {
        g.setColor(Color.blue);
        g.fill(shape);
        if (shape.contains(mouse)) {
            g.setColor(Color.RED);
        } else {
            g.setColor(Color.YELLOW);
        }
        g.draw(shape);
    }

    l.setIcon(new ImageIcon(img));

    g.dispose();
}

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

public static JPanel createDemoPanel() {
    JPanel jpanel = new JPanel(new GridLayout(2, 2));
    jpanel.setPreferredSize(new Dimension(800, 600));
    CategoryDataset categorydataset = createDataset();
    JFreeChart jfreechart = createChart("Type: VERTICAL", categorydataset);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer();
    barrenderer.setDrawBarOutline(false);
    barrenderer.setSeriesPaint(0, new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, Color.yellow));
    barrenderer.setSeriesPaint(1, new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, Color.green));
    barrenderer.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL));
    ChartPanel chartpanel = new ChartPanel(jfreechart);
    jpanel.add(chartpanel);//from   w w  w . j  a  v  a2s .c o  m
    JFreeChart jfreechart1 = createChart("Type: HORIZONTAL", categorydataset);
    CategoryPlot categoryplot1 = (CategoryPlot) jfreechart1.getPlot();
    BarRenderer barrenderer1 = (BarRenderer) categoryplot1.getRenderer();
    barrenderer1.setDrawBarOutline(false);
    barrenderer1.setSeriesPaint(0, new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, Color.yellow));
    barrenderer1.setSeriesPaint(1, new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, Color.green));
    barrenderer1.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL));
    ChartPanel chartpanel1 = new ChartPanel(jfreechart1);
    jpanel.add(chartpanel1);
    JFreeChart jfreechart2 = createChart("Type: CENTER_VERTICAL", categorydataset);
    CategoryPlot categoryplot2 = (CategoryPlot) jfreechart2.getPlot();
    BarRenderer barrenderer2 = (BarRenderer) categoryplot2.getRenderer();
    barrenderer2.setDrawBarOutline(false);
    barrenderer2.setSeriesPaint(0, new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, Color.yellow));
    barrenderer2.setSeriesPaint(1, new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, Color.green));
    barrenderer2.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL));
    ChartPanel chartpanel2 = new ChartPanel(jfreechart2);
    jpanel.add(chartpanel2);
    JFreeChart jfreechart3 = createChart("Type: CENTER_HORIZONTAL", categorydataset);
    CategoryPlot categoryplot3 = (CategoryPlot) jfreechart3.getPlot();
    BarRenderer barrenderer3 = (BarRenderer) categoryplot3.getRenderer();
    barrenderer3.setDrawBarOutline(false);
    barrenderer3.setSeriesPaint(0, new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, Color.yellow));
    barrenderer3.setSeriesPaint(1, new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, Color.green));
    barrenderer3.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_HORIZONTAL));
    ChartPanel chartpanel3 = new ChartPanel(jfreechart3);
    jpanel.add(chartpanel3);
    return jpanel;
}

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

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createBarChart("Bar Chart Demo 9", null, "Value", categorydataset,
            PlotOrientation.VERTICAL, false, true, false);
    TextTitle texttitle = jfreechart.getTitle();
    texttitle.setBorder(0.0D, 0.0D, 1.0D, 0.0D);
    texttitle.setBackgroundPaint(new GradientPaint(0.0F, 0.0F, Color.red, 350F, 0.0F, Color.white, true));
    texttitle.setExpandToFitSpace(true);
    jfreechart.setBackgroundPaint(new GradientPaint(0.0F, 0.0F, Color.yellow, 350F, 0.0F, Color.white, true));
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setNoDataMessage("NO DATA!");
    categoryplot.setBackgroundPaint(null);
    categoryplot.setInsets(new RectangleInsets(10D, 5D, 5D, 5D));
    categoryplot.setOutlinePaint(Color.black);
    categoryplot.setRangeGridlinePaint(Color.gray);
    categoryplot.setRangeGridlineStroke(new BasicStroke(1.0F));
    Paint apaint[] = createPaint();
    CustomBarRenderer custombarrenderer = new CustomBarRenderer(apaint);
    custombarrenderer.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_HORIZONTAL));
    categoryplot.setRenderer(custombarrenderer);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis.setRange(0.0D, 800D);/*from  w  w  w.j  ava  2s  .c o m*/
    numberaxis.setTickMarkPaint(Color.black);
    return jfreechart;
}

From source file:MainClass.java

public MainClass() {
    Container cp = new Box(BoxLayout.X_AXIS);
    setContentPane(cp);//w  w  w  . j  a v  a2  s . c o  m
    JPanel firstPanel = new JPanel();
    propertyComboBox = new JComboBox();
    propertyComboBox.addItem("text");
    propertyComboBox.addItem("font");
    propertyComboBox.addItem("background");
    propertyComboBox.addItem("foreground");
    firstPanel.add(propertyComboBox);
    cp.add(firstPanel);
    cp.add(Box.createGlue());

    tf = new JTextField("Hello");
    tf.setForeground(Color.RED);
    tf.setDragEnabled(true);
    cp.add(tf);

    cp.add(Box.createGlue());

    l = new JLabel("Hello");
    l.setBackground(Color.YELLOW);
    cp.add(l);

    cp.add(Box.createGlue());

    JSlider stryder = new JSlider(SwingConstants.VERTICAL);
    stryder.setMinimum(10);
    stryder.setValue(14);
    stryder.setMaximum(72);
    stryder.setMajorTickSpacing(10);
    stryder.setPaintTicks(true);

    cp.add(stryder);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(500, 300);

    setMyTransferHandlers((String) propertyComboBox.getSelectedItem());

    MouseListener myDragListener = new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            JComponent c = (JComponent) e.getSource();
            TransferHandler handler = c.getTransferHandler();
            handler.exportAsDrag(c, e, TransferHandler.COPY);
        }
    };
    l.addMouseListener(myDragListener);

    propertyComboBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ce) {
            JComboBox bx = (JComboBox) ce.getSource();
            String prop = (String) bx.getSelectedItem();
            setMyTransferHandlers(prop);
        }
    });

    tf.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            JTextField jtf = (JTextField) evt.getSource();
            String fontName = jtf.getText();
            Font font = new Font(fontName, Font.BOLD, 18);
            tf.setFont(font);
        }
    });

    stryder.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent evt) {
            JSlider sl = (JSlider) evt.getSource();
            Font oldf = tf.getFont();
            Font newf = oldf.deriveFont((float) sl.getValue());
            tf.setFont(newf);
        }
    });
}

From source file:IHM.NewClass.java

/**
 *
 * @param title//from w w w .  j ava2s .c  om
 */
public NewClass(String title /*,*JInternalFrame jp*/) {
    super(title);
    // jp = new JInternalFrame("courbes");

    JFreeChart chart = createChart(createDataset());
    ChartPanel panel = new ChartPanel(chart);
    panel.setPreferredSize(new Dimension(500, 300));
    setContentPane(panel);
    //  jp.add(panel, BorderLayout.EAST);
    //  jp.setVisible(true);
    panel.setVisible(true);
    XYPlot plot = chart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    plot.setRenderer(renderer);
    renderer.setSeriesPaint(0, Color.RED);
    renderer.setSeriesPaint(1, Color.GREEN);
    renderer.setSeriesPaint(2, Color.YELLOW);
    // sets thickness for series (using strokes)
    renderer.setSeriesStroke(0, new BasicStroke(4.0f));
    renderer.setSeriesStroke(1, new BasicStroke(3.0f));
    renderer.setSeriesStroke(2, new BasicStroke(2.0f));
    plot.setRenderer(renderer);
    plot.setOutlinePaint(Color.BLUE);
    plot.setOutlineStroke(new BasicStroke(2.0f));
    plot.setBackgroundPaint(Color.DARK_GRAY);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.BLACK);
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.BLACK);

}

From source file:nz.ac.waikato.modeljunit.gui.visualisaton.VertexPaintTransformer.java

@Override
public Paint transform(V v) {
    try {/*www .j  av  a 2 s  .  com*/
        if (v instanceof Graph) {
            if (pi.isPicked(v)) {
                return Color.YELLOW;
            }
            return new Color(45, 155, 32);
        }
        if (v instanceof VertexInfo) {
            if (pi.isPicked(vertecies_.get(vertecies_.indexOf(v)))) {
                return Color.YELLOW;
            } else {
                if (vertecies_.contains(v)) {

                    VertexInfo vert = (VertexInfo) vertecies_.get(vertecies_.indexOf(v));
                    if (vert.getIsDisplayed()) {
                        return new Color(205, 92, 92);
                    } else if (vert.getIsVisited()) {
                        return new Color(255, 192, 203);
                    }
                }
            }
        }
        return new Color(255, 222, 173);

    } catch (Exception e) {
        return new Color(255, 222, 173);
    }
}

From source file:com.bwc.ora.views.render.HighlightXYRenderer.java

/**
 * Return a special color for the highlighted item.
 *
 * @param seriesIndex the series index.//from w w  w . j  av a  2 s  .  c  om
 * @param itemIndex the item index.
 *
 * @return The outline paint.
 */
@Override
public Paint getItemOutlinePaint(int seriesIndex, int itemIndex) {
    //        System.out.println("Looking for (" + seriesIndex + "," + itemIndex + ")");
    if (seriesIndex == highlightSeries && itemIndex == highlightItem) {
        return Color.yellow;
    }
    return super.getItemOutlinePaint(seriesIndex, itemIndex);
}

From source file:RendererSample.java

public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
        int row, int column) {
    Component renderer = DEFAULT_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row,
            column);//from  ww  w. j  ava2 s .c  om
    ((JLabel) renderer).setOpaque(true);
    Color foreground, background;
    if (isSelected) {
        foreground = Color.yellow;
        background = Color.green;
    } else {
        if (row % 2 == 0) {
            foreground = Color.blue;
            background = Color.white;
        } else {
            foreground = Color.white;
            background = Color.blue;
        }
    }
    renderer.setForeground(foreground);
    renderer.setBackground(background);
    return renderer;
}

From source file:chart.XYChart.java

public XYChart(String applicationTitle, String chartTitle, double[] xData, double[] YDataAnalitic,
        double[] YDataNumerical1, double[] YDataNumerical2) {

    super(applicationTitle);

    JFreeChart xylineChart = ChartFactory.createXYLineChart(chartTitle, "", "",
            createDatasetForThree(xData, YDataAnalitic, YDataNumerical1, YDataNumerical2),
            PlotOrientation.VERTICAL, true, true, false);
    ChartPanel chartPanel = new ChartPanel(xylineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
    final XYPlot plot = xylineChart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(0, Color.RED);
    renderer.setSeriesPaint(1, Color.GREEN);
    renderer.setSeriesPaint(2, Color.YELLOW);
    renderer.setSeriesPaint(3, Color.BLUE);
    renderer.setSeriesStroke(0, new BasicStroke(1.0f));
    renderer.setSeriesStroke(1, new BasicStroke(1.0f));
    renderer.setSeriesStroke(2, new BasicStroke(1.0f));
    renderer.setSeriesStroke(3, new BasicStroke(1.0f));
    plot.setRenderer(renderer);//  ww w  .  ja  v  a  2s .c  o  m
    setContentPane(chartPanel);

    // panel.removeAll();
    //  panel.add(chartPanel);
    //  panel.validate();

}