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:org.sonar.server.charts.deprecated.BaseChart.java

protected void configureChart(JFreeChart chart, RectangleEdge legendPosition) {
    chart.setBackgroundPaint(new Color(255, 255, 255, 0));
    chart.setBackgroundImageAlpha(0.0f);
    chart.setBorderVisible(false);/*  w w w.j a v a 2  s.  c  o m*/
    chart.setAntiAlias(true);
    chart.setTextAntiAlias(true);

    chart.removeLegend();
    if (legendPosition != null) {
        LegendTitle legend = new LegendTitle(chart.getPlot());
        legend.setPosition(legendPosition);
        legend.setItemPaint(BASE_COLOR);
        chart.addSubtitle(legend);
    }
}

From source file:sernet.gs.ui.rcp.main.bsi.views.chart.ISRSpiderChart.java

protected JFreeChart createSpiderChart(Object dataset) {
    SpiderWebPlot plot = new SpiderWebPlot((CategoryDataset) dataset);
    plot.setToolTipGenerator(new StandardCategoryToolTipGenerator());

    plot.setSeriesPaint(0, new Color(0.0f, 1f, 0f, 1f)); // green
    plot.setSeriesPaint(1, new Color(1f, 1f, 0f, 1f)); // yellow
    plot.setSeriesPaint(2, new Color(1f, 0f, 0f, 1f)); // red
    plot.setSeriesPaint(3, new Color(0f, 0f, 0f, 1f)); // grey

    plot.setWebFilled(true);//from  w w  w.  j a  v  a2  s  .co  m
    JFreeChart chart = new JFreeChart(Messages.ISRSpiderChart_0, TextTitle.DEFAULT_FONT, plot, false);

    LegendTitle legend = new LegendTitle(plot);
    legend.setPosition(RectangleEdge.BOTTOM);
    chart.addSubtitle(legend);

    return chart;
}

From source file:com.js.quickestquail.ui.stats.YearStat.java

private JFreeChart generateChart() {
    JFreeChart lineChart = ChartFactory.createLineChart(
            java.util.ResourceBundle.getBundle("i18n/i18n").getString("stat.year.title"),
            java.util.ResourceBundle.getBundle("i18n/i18n").getString("stat.year.xaxis"),
            java.util.ResourceBundle.getBundle("i18n/i18n").getString("stat.year.yaxis"), generateDataset(),
            PlotOrientation.VERTICAL, true, true, false);
    lineChart.setBackgroundPaint(new Color(0xFF, 0xFF, 0xFF, 0));
    lineChart.getPlot().setBackgroundPaint(Color.WHITE);
    return lineChart;
}

From source file:com.uniteddev.Unity.Login.java

public static void setup() throws IOException, InterruptedException, FontFormatException {
    //fonts//from  www .  ja  v  a2 s  .c o  m
    roboto_thin = Font.createFont(Font.TRUETYPE_FONT, Unity.class.getResourceAsStream("/res/Roboto-Thin.ttf"));
    roboto_regular = Font.createFont(Font.TRUETYPE_FONT,
            Unity.class.getResourceAsStream("/res/Roboto-Regular.ttf"));
    // main
    window = new Window(Unity.title, Unity.favicon, Unity.background, 791, 527);
    release = new Label(Unity.release, Color.WHITE, roboto_regular.deriveFont(Font.PLAIN, 12));
    server_lbl = new Label("Server:", Color.WHITE, roboto_regular.deriveFont(Font.PLAIN, 12));
    server_stat_lbl = new Label("Offline", Color.RED, roboto_regular.deriveFont(Font.PLAIN, 12));
    settingsButton = new Button();
    settingsButton.setImage("/res/gear.png");
    settingsButton.removeDecorations();
    settingsButton.addActionListener(new settingsButton_action());
    // splash screen
    update_lbl = new Label("Updating", Color.WHITE, roboto_thin.deriveFont(Font.PLAIN, 32));
    progress = new ProgressBar(new Color(255, 255, 255, 100), new Color(255, 255, 255, 255));
    progress.removeDecorations();
    progressText = new Label("Ready.", Color.WHITE, roboto_regular.deriveFont(Font.PLAIN, 14));
    // login screen
    username = new TextField(prefs.get("username", ""), Color.WHITE, roboto_regular.deriveFont(Font.PLAIN, 14));
    password = new PasswordField(Color.WHITE, roboto_regular.deriveFont(Font.PLAIN, 14));
    username_lbl = new Label("Username:", Color.WHITE, roboto_regular.deriveFont(Font.PLAIN, 14));
    password_lbl = new Label("Password:", Color.WHITE, roboto_regular.deriveFont(Font.PLAIN, 14));
    loginButton = new Button("Login", Color.WHITE, roboto_thin.deriveFont(Font.PLAIN, 28));
    loginButton.setBorder(BorderFactory.createLineBorder(Color.WHITE, 1));
    loginButton.center();
    loginButton.addActionListener(new loginButton_action());
    invalid_login_lbl = new Label("Invalid Login", Color.RED, roboto_regular.deriveFont(Font.PLAIN, 14));
    invalid_login_lbl.setVisible(false);
    // settings screen
    settings_lbl = new Label("Settings", Color.WHITE, roboto_thin.deriveFont(Font.PLAIN, 32));
    deleteButton = new Button();
    deleteButton.setImage("/res/recycle.png");
    deleteButton.removeDecorations();
    deleteButton.addActionListener(new deleteButton_action());
    ram_size = new TextField(prefs.get("ram_size", default_ram), Color.WHITE,
            roboto_regular.deriveFont(Font.PLAIN, 14));
    ram_lbl = new Label("RAM Usage (MB):", Color.WHITE, roboto_regular.deriveFont(Font.PLAIN, 14));
    invalid_ram_lbl = new Label(Color.RED, roboto_regular.deriveFont(Font.PLAIN, 14));
    invalid_ram_lbl.setVisible(false);
    saveButton = new Button("Save", Color.WHITE, roboto_thin.deriveFont(Font.PLAIN, 28));
    saveButton.setBorder(BorderFactory.createLineBorder(Color.WHITE, 1));
    saveButton.center();
    saveButton.addActionListener(new saveButton_action());
    // sizing and layout
    release.setBounds(5, window.getHeight() - 50, 140, 20);
    server_lbl.setBounds(5, window.getHeight() - 50, 140, 20);
    server_stat_lbl.setBounds(45, window.getHeight() - 50, 200, 20);
    update_lbl.setBounds(115, 20, 320, 50);
    progress.setBounds(20, 75, 320, 10);
    progressText.setBounds(20, 90, 320, 20);
    username.setBounds(155, 30, 115, 20);
    password.setBounds(155, 60, 115, 20);
    username_lbl.setBounds(80, 30, 115, 20);
    password_lbl.setBounds(79, 60, 115, 20);
    loginButton.setBounds(110, 110, 140, 40);
    invalid_login_lbl.setBounds(135, 165, 140, 20);
    settingsButton.setBounds(window.getWidth() - 45, window.getHeight() - 65, 32, 32);
    settings_lbl.setBounds(115, 5, 320, 50);
    deleteButton.setBounds(155, 50, 32, 32);
    ram_size.setBounds(175, 90, 115, 20);
    ram_lbl.setBounds(60, 90, 115, 20);
    saveButton.setBounds(110, 125, 140, 40);
    // setup screens
    login_window = new Label();
    login_window.setBounds(216, 180, 360, 200);
    login_window.add(update_lbl);
    login_window.add(progress);
    login_window.add(progressText);
    login_window.add(username);
    login_window.add(password);
    login_window.add(username_lbl);
    login_window.add(password_lbl);
    login_window.add(loginButton);
    login_window.add(invalid_login_lbl);
    login_window.add(settings_lbl);
    login_window.add(deleteButton);
    login_window.add(ram_size);
    login_window.add(invalid_ram_lbl);
    login_window.add(ram_lbl);
    login_window.add(saveButton);
    // setup and show window
    window.addComponent(release);
    window.addComponent(server_lbl);
    window.addComponent(server_stat_lbl);
    window.addComponent(login_window);
    window.addComponent(settingsButton);
    window.getRootPane().setDefaultButton(loginButton);
    window.setLocationRelativeTo(null);
    release.setVisible(false);
    window.setVisible(true);
    start();
}

From source file:ColorUtil.java

/**
 * Make a color lighter./*from  w w w  . j a  v  a 2 s  .c  om*/
 * 
 * @param color     Color to make lighter.
 * @param fraction  Darkness fraction.
 * @return          Lighter color.
 */
public static Color lighter(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:de.tor.tribes.ui.views.DSWorkbenchRankFrame.java

@Override
public void actionPerformed(ActionEvent e) {
    RankTableTab activeTab = getActiveTab();
    if (e.getActionCommand() != null && activeTab != null) {
        if (e.getActionCommand().equals("Find")) {
            BufferedImage back = ImageUtils.createCompatibleBufferedImage(3, 3, BufferedImage.TRANSLUCENT);
            Graphics g = back.getGraphics();
            g.setColor(new Color(120, 120, 120, 120));
            g.fillRect(0, 0, back.getWidth(), back.getHeight());
            g.setColor(new Color(120, 120, 120));
            g.drawLine(0, 0, 3, 3);/* w w  w . j  a va  2s .  c om*/
            g.dispose();
            TexturePaint paint = new TexturePaint(back,
                    new Rectangle2D.Double(0, 0, back.getWidth(), back.getHeight()));
            jxSearchPane.setBackgroundPainter(new MattePainter(paint));
            DefaultListModel model = new DefaultListModel();

            for (int i = 0; i < activeTab.getRankTable().getColumnCount(); i++) {
                TableColumnExt col = activeTab.getRankTable().getColumnExt(i);
                if (col.isVisible()) {
                    if (col.getTitle().equals("Name") || col.getTitle().equals("Tag")
                            || col.getTitle().equals("Stamm")) {
                        model.addElement(col.getTitle());
                    }

                }
            }
            jXColumnList.setModel(model);
            jXColumnList.setSelectedIndex(0);
            jxSearchPane.setVisible(true);
        }
    }

}

From source file:com.pureinfo.srm.reports.impl.PieChartBuilder.java

/**
 * @throws PureException/*from   w  w  w . j  a  v a  2s. c o  m*/
 * @see com.pureinfo.srm.reports.IChartBuilder#draw(java.util.List, int)
 */
public JFreeChart buildChart() {
    Iterator result = m_datas.iterator();
    DefaultPieDataset ds = getDataset(result);

    JFreeChart jfreechart = ChartFactory.createPieChart3D(null, ds, false, false, false);
    jfreechart.setBackgroundPaint(Color.WHITE);

    PiePlot3D pieplot3d = (PiePlot3D) jfreechart.getPlot();
    pieplot3d.setOutlinePaint(Color.GRAY);
    pieplot3d.setOutlineStroke(new BasicStroke(1));
    pieplot3d.setStartAngle(30D);
    pieplot3d.setDepthFactor(0.04);
    pieplot3d.setDrawingSupplier(new DefaultDrawingSupplier(MyPaintMgr.getPaints(),
            DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE));

    pieplot3d.setCircular(false);
    pieplot3d.setDirection(Rotation.CLOCKWISE);
    pieplot3d.setOutlinePaint(Color.WHITE);
    pieplot3d.setInteriorGap(.15);
    Color color = new Color(0xaa, 0xaa, 0xaa, 255);
    pieplot3d.setBaseSectionOutlinePaint(color);
    pieplot3d.setBaseSectionOutlineStroke(new BasicStroke(0));
    pieplot3d.setForegroundAlpha(0.6f);
    pieplot3d.setLabelLinkStroke(new BasicStroke(1));
    pieplot3d.setLabelOutlinePaint(new Color(0x777777));
    pieplot3d.setLabelBackgroundPaint(new Color(0xf1f1f7));
    pieplot3d.setLabelLinkPaint(new Color(0xaa, 0xaa, 0xaa, 60));
    pieplot3d.setNoDataMessage("No data to display");
    pieplot3d.setLabelShadowPaint(new Color(0xdddddd));
    pieplot3d.setLabelFont(new Font("", Font.PLAIN, 10));
    if (m_nType == TYPE_PERCENT) {

        pieplot3d.setLabelGenerator(new StandardPieItemLabelGenerator("{0} = {2}",
                NumberFormat.getNumberInstance(), PERCENT_NUMBER_FORMAT));
    }

    fillChartInfo(ds);
    return jfreechart;
}

From source file:com.js.quickestquail.ui.stats.RatingStat.java

private JFreeChart generateChart() {
    JFreeChart lineChart = ChartFactory.createLineChart(
            java.util.ResourceBundle.getBundle("i18n/i18n").getString("stat.rating.title"),
            java.util.ResourceBundle.getBundle("i18n/i18n").getString("stat.rating.xaxis"),
            java.util.ResourceBundle.getBundle("i18n/i18n").getString("stat.rating.yaxis"), generateDataset(),
            PlotOrientation.VERTICAL, true, true, false);
    lineChart.setBackgroundPaint(new Color(0xFF, 0xFF, 0xFF, 0));
    lineChart.getPlot().setBackgroundPaint(Color.WHITE);
    return lineChart;
}

From source file:edu.gmu.cs.sim.util.media.chart.SeriesAttributes.java

/** Given an opaque color and a desired opacity (from 0.0 to 1.0), returns a new color of the same tint but with
 the given opacity. *///from ww  w  . ja  v  a 2s  .  c o  m
public Color reviseColor(Color c, double opacity) {
    return new Color(c.getRed(), c.getGreen(), c.getBlue(), (int) (opacity * 255));
}

From source file:HighlightedButton.java

/**
 * Creates a new instance of HighlightedButton
 *///from  w w w.j a  v  a2s  .  com
public HighlightedButton(String label) {
    super(label);

    // Get the Graphics for the image
    Graphics2D g2d = highlight.createGraphics();

    // Erase the image with a transparent background
    g2d.setComposite(AlphaComposite.Clear);
    g2d.fillRect(0, 0, HIGHLIGHT_SIZE, HIGHLIGHT_SIZE);
    g2d.setComposite(AlphaComposite.SrcOver);

    // Draw the highlight
    Point2D center = new Point2D.Float((float) HIGHLIGHT_SIZE / 2.0f, (float) HIGHLIGHT_SIZE / 2.0f);
    float radius = (float) HIGHLIGHT_SIZE / 2.0f;
    float[] dist = { 0.0f, .85f };
    Color[] colors = { Color.white, new Color(255, 255, 255, 0) };
    RadialGradientPaint paint = new RadialGradientPaint(center, radius, dist, colors);
    g2d.setPaint(paint);
    g2d.fillOval(0, 0, HIGHLIGHT_SIZE, HIGHLIGHT_SIZE);
    g2d.dispose();
}