Example usage for java.awt Color Color

List of usage examples for java.awt Color Color

Introduction

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

Prototype

public Color(float r, float g, float b, float a) 

Source Link

Document

Creates an sRGB color with the specified red, green, blue, and alpha values in the range (0.0 - 1.0).

Usage

From source file:de.ailis.xadrian.data.Race.java

/**
 * Return the color with the specified alpha value.
 *
 * @param alpha//from   ww w.  j  a  va2  s . c o  m
 *            The alpha value
 * @return The color
 */
public Color getColor(final int alpha) {
    return new Color(this.color.getRed(), this.color.getGreen(), this.color.getBlue(), alpha);
}

From source file:jamel.gui.charts.JamelChart.java

/**
 * Returns the standard chart theme./*  w w w.j  a v a2 s . co m*/
 * @return the standard chart theme.
 */
private static StandardChartTheme getNewChartTheme() {
    StandardChartTheme theme = new StandardChartTheme("Standard Chart Theme");
    float size = theme.getExtraLargeFont().getSize2D();
    Font titleFont = theme.getExtraLargeFont().deriveFont(size - 4);
    theme.setExtraLargeFont(titleFont);
    Font axisFont = theme.getRegularFont();
    theme.setLargeFont(axisFont);
    theme.setChartBackgroundPaint(new Color(0, 0, 0, 1));
    theme.setPlotBackgroundPaint(Color.WHITE);
    theme.setDomainGridlinePaint(Color.GRAY);
    theme.setRangeGridlinePaint(Color.GRAY);
    return theme;
}

From source file:SplashScreen.java

public void showSplash() {
    JPanel content = (JPanel) getContentPane();
    content.setBackground(Color.white);

    // Set the window's bounds, centering the window
    int width = 450;
    int height = 115;
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (screen.width - width) / 2;
    int y = (screen.height - height) / 2;
    setBounds(x, y, width, height);//  w  w  w  .  j  a va  2 s.c o m

    // Build the splash screen
    JLabel label = new JLabel(new ImageIcon("1.gif"));
    JLabel copyrt = new JLabel("Copyright 2002, O'Reilly & Associates", JLabel.CENTER);
    copyrt.setFont(new Font("Sans-Serif", Font.BOLD, 12));
    content.add(label, BorderLayout.CENTER);
    content.add(copyrt, BorderLayout.SOUTH);
    Color oraRed = new Color(156, 20, 20, 255);
    content.setBorder(BorderFactory.createLineBorder(oraRed, 10));

    // Display it
    setVisible(true);

    // Wait a little while, maybe while loading resources
    try {
        Thread.sleep(duration);
    } catch (Exception e) {
    }

    setVisible(false);
}

From source file:net.sourceforge.atunes.kernel.modules.state.ColorBean.java

/**
 * Returns original color object/*from  w ww .j a va2  s  .co  m*/
 * 
 * @return
 */
@Override
public Color getColor() {
    return new Color(this.red, this.green, this.blue, this.alpha);
}

From source file:grafix.graficos.indices.IndiceBollinger.java

@Override
public void plotar(final XYPlot plot, final JanelaGraficos janela, final int contador) {
    float[] color = getCor().getComponents(null);
    XYDifferenceRenderer r = new XYDifferenceRenderer(new Color(color[0], color[1], color[2], .1f), Color.red,
            false);//  ww w . ja  v  a  2  s. com
    r.setStroke(new BasicStroke(.75f));
    r.setPaint(getCor());
    plot.setRenderer(contador, r);
    plot.setDataset(contador, getDataSet(janela));
}

From source file:misc.GradientTranslucentWindowDemo.java

public GradientTranslucentWindowDemo() {
    super("GradientTranslucentWindow");

    setBackground(new Color(0, 0, 0, 0));
    setSize(new Dimension(300, 200));
    setLocationRelativeTo(null);//from ww  w.  ja v  a  2s .  c  o m
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel panel = new JPanel() {
        @Override
        protected void paintComponent(Graphics g) {
            if (g instanceof Graphics2D) {
                final int R = 240;
                final int G = 240;
                final int B = 240;

                Paint p = new GradientPaint(0.0f, 0.0f, new Color(R, G, B, 0), 0.0f, getHeight(),
                        new Color(R, G, B, 255), true);
                Graphics2D g2d = (Graphics2D) g;
                g2d.setPaint(p);
                g2d.fillRect(0, 0, getWidth(), getHeight());
            }
        }
    };
    setContentPane(panel);
    setLayout(new GridBagLayout());
    add(new JButton("I am a Button"));
}

From source file:chiliad.parser.pdf.model.MToken.java

public static Color rgbaToColor(String rgba) {
    String[] comp = split(substringsBetween(rgba, "rgba(", ")")[0], ",");
    int r = Integer.valueOf(trimToEmpty(comp[0]));
    int g = Integer.valueOf(trimToEmpty(comp[1]));
    int b = Integer.valueOf(trimToEmpty(comp[2]));
    int a = (int) (Double.valueOf(trimToEmpty(comp[3])) * 255);
    return new Color(r, g, b, a);
}

From source file:ColorUtil.java

public static Color copy(Color c) {
    return c == null ? null : new Color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha());
}

From source file:ColorUtil.java

/**
 * Make a color darker.//w ww .  j a va  2  s  . com
 * 
 * @param color     Color to make darker.
 * @param fraction  Darkness fraction.
 * @return          Darker color.
 */
public static Color darker(Color color, double fraction) {
    int red = (int) Math.round(color.getRed() * (1.0 - fraction));
    int green = (int) Math.round(color.getGreen() * (1.0 - fraction));
    int blue = (int) Math.round(color.getBlue() * (1.0 - fraction));

    if (red < 0)
        red = 0;
    else if (red > 255)
        red = 255;
    if (green < 0)
        green = 0;
    else if (green > 255)
        green = 255;
    if (blue < 0)
        blue = 0;
    else if (blue > 255)
        blue = 255;

    int alpha = color.getAlpha();

    return new Color(red, green, blue, alpha);
}

From source file:org.schreibubi.JCombinations.jfreechart.ArbitraryMarker.java

/**
 * Constructor//from   w  w  w .  ja  v  a2 s .c om
 * 
 * @param domainVal
 *            x-values of range
 * @param rangeLow
 *            lower y-values of range
 * @param rangeHigh
 *            upper y-values of range
 */
public ArbitraryMarker(ArrayList<Double> domainVal, ArrayList<Double> rangeLow, ArrayList<Double> rangeHigh) {
    this(domainVal, rangeLow, rangeHigh, new Color(222, 222, 255, 240), new BasicStroke(0.5f),
            new Color(222, 222, 255, 240), new BasicStroke(0.5f), 0.5f);
}