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(ColorSpace cspace, float[] components, float alpha) 

Source Link

Document

Creates a color in the specified ColorSpace with the color components specified in the float array and the specified alpha.

Usage

From source file:Ventanas.VentanaVerGrafico.java

private void initGUI() {
    try {/*from  w  w w. j a  va  2  s  .c o m*/
        this.setLayout(null);
        this.setIconImage(
                new ImageIcon(getClass().getClassLoader().getResource("Ventanas/is_a4af.gif")).getImage());
        this.setTitle("Grfica");
        this.setSize(705, 580);
        this.getContentPane().setBackground(new java.awt.Color(204, 230, 230));
        this.setLocationRelativeTo(null);
        this.setResizable(false);

        {
            CategoryDataset dataset = createCategoryDataset(((Vector) VentanaVerEstadisticas.datosEstadistica));
            JFreeChart chart = ChartFactory.createBarChart3D("Rendimiento de los operarios", "Operarios", "",
                    dataset, PlotOrientation.HORIZONTAL, true, true, false);
            chart.setBackgroundPaint(new Color(204, 230, 230));
            grafica = chart.createBufferedImage(700, 500);
            paint(grafica.getGraphics());
        }

    } catch (Exception e) {
        e.printStackTrace();
    }

}

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

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createBarChart3D("Student Grades", "Students", "Grade",
            categorydataset, PlotOrientation.VERTICAL, false, true, false);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    CustomBarRenderer3D custombarrenderer3d = new CustomBarRenderer3D();
    custombarrenderer3d.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    custombarrenderer3d.setBaseItemLabelsVisible(true);
    custombarrenderer3d.setItemLabelAnchorOffset(10D);
    custombarrenderer3d.setBasePositiveItemLabelPosition(
            new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
    categoryplot.setRenderer(custombarrenderer3d);
    ValueMarker valuemarker = new ValueMarker(0.69999999999999996D, new Color(200, 200, 255),
            new BasicStroke(1.0F), new Color(200, 200, 255), new BasicStroke(1.0F), 1.0F);
    categoryplot.addRangeMarker(valuemarker, Layer.BACKGROUND);
    custombarrenderer3d.setBaseItemLabelsVisible(true);
    custombarrenderer3d.setMaximumBarWidth(0.050000000000000003D);
    CategoryTextAnnotation categorytextannotation = new CategoryTextAnnotation("Minimum grade to pass",
            "Robert", 0.70999999999999996D);
    categorytextannotation.setCategoryAnchor(CategoryAnchor.START);
    categorytextannotation.setFont(new Font("SansSerif", 0, 12));
    categorytextannotation.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categoryplot.addAnnotation(categorytextannotation);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setNumberFormatOverride(NumberFormat.getPercentInstance());
    numberaxis.setUpperMargin(0.10000000000000001D);
    return jfreechart;
}

From source file:costumetrade.common.verify.ImageVerification.java

public Pair<String, BufferedImage> create() {
    int x = 0, fontHeight = 0, codeY = 0;
    int red = 0, green = 0, blue = 0;

    x = width / (codeCount + 2);//?
    fontHeight = height - 2;//
    codeY = height - 4;/*  w  ww .j a v  a  2 s .  c o  m*/

    // ?buffer
    BufferedImage buffImg = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
    Graphics2D g = buffImg.createGraphics();
    // ?
    g.setColor(Color.WHITE);
    g.fillRect(0, 0, width, height);
    // 
    g.setFont(new Font("Arial", Font.PLAIN, fontHeight));

    for (int i = 0; i < lineCount; i++) {

        int xs = RandomUtils.nextInt(0, width);
        int ys = RandomUtils.nextInt(0, height);
        int xe = xs + RandomUtils.nextInt(0, width / 8);
        int ye = ys + RandomUtils.nextInt(0, height / 8);
        red = RandomUtils.nextInt(0, 255);
        green = RandomUtils.nextInt(0, 255);
        blue = RandomUtils.nextInt(0, 255);
        g.setColor(new Color(red, green, blue));
        g.drawLine(xs, ys, xe, ye);
    }

    // randomCode???
    StringBuilder randomCode = new StringBuilder();
    // ?codeCount??
    for (int i = 0; i < codeCount; i++) {
        String strRand = String.valueOf(codeSequence[RandomUtils.nextInt(0, codeSequence.length)]);
        // ????
        red = RandomUtils.nextInt(0, 255);
        green = RandomUtils.nextInt(0, 255);
        blue = RandomUtils.nextInt(0, 255);
        g.setColor(new Color(red, green, blue));
        g.drawString(strRand, (i + 1) * x, codeY);
        // ??
        randomCode.append(strRand);
    }
    // ????Session
    return new Pair<String, BufferedImage>(randomCode.toString(), buffImg);
}

From source file:com.wattzap.view.graphs.GenericScatterGraph.java

public GenericScatterGraph(XYSeries series, String xAxis, String yAxis) {
    super();/*from   w  w w .ja  v  a2s .  c o m*/

    XYDataset xyDataset = new XYSeriesCollection(series);

    JFreeChart chart = ChartFactory.createScatterPlot("", // chart title
            xAxis, // x axis label
            yAxis, // y axis label
            null, PlotOrientation.VERTICAL, false, // include legend
            true, // tooltips
            false // urls
    );

    chart.setBackgroundPaint(Color.darkGray);
    plot = chart.getXYPlot();
    plot.setDataset(0, xyDataset);
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);

    // Shape cross = ShapeUtilities.createDiamond(0.5f);
    Shape cross = ShapeUtilities.createDiagonalCross(0.5f, 0.5f);
    XYItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesPaint(0, new Color(252, 141, 89));
    renderer.setSeriesShape(0, cross);

    ValueAxis domainAxis = plot.getDomainAxis();
    domainAxis.setTickLabelPaint(Color.white);
    domainAxis.setLabelPaint(Color.white);

    ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setTickLabelPaint(Color.white);
    rangeAxis.setLabelPaint(Color.white);

    chartPanel = new ChartPanel(chart);
    chartPanel.setSize(100, 800);

    setLayout(new BorderLayout());
    add(chartPanel, BorderLayout.CENTER);
    setBackground(Color.black);

    chartPanel.revalidate();
    setVisible(true);
}

From source file:jmbench.plots.MemoryRelativeBarPlot.java

private void plot() {
    CategoryPlot plot = chart.getCategoryPlot();
    //        plot.setDomainGridlinesVisible(true);
    //        plot.setRangeCrosshairVisible(true);
    //        plot.setRangeCrosshairPaint(Color.blue);

    plot.setRangeGridlinePaint(Color.BLACK);

    // set the range axis to display integers only...
    //        NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    //        rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    //        CategoryAxis domainAxis = (CategoryAxis) plot.getDomainAxis();
    //        domainAxis.setTickMarkPaint(Color.BLACK);

    plot.setBackgroundPaint(new Color(230, 230, 230));

    // disable bar outlines...
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(true);//from w w  w  .j a  v a  2 s  . com
    renderer.setShadowVisible(false);
    renderer.setBaseOutlinePaint(Color.BLACK);
    //        renderer.setBaseOutlineStroke(new BasicStroke(2));

    //        CategoryAxis domainAxis = plot.getDomainAxis();
    //        domainAxis.setCategoryLabelPositions(
    //                CategoryLabelPositions.createUpRotationLabelPositions(
    //                        Math.PI / 6.0));
}

From source file:com.eviware.soapui.support.editor.inspectors.auth.ExpirationTimeChooser.java

ExpirationTimeChooser(OAuth2Profile profile) {
    this.profile = profile;
    setLayout(new BorderLayout(0, 0));
    initializeRadioButtons();//w w  w . j  a  va 2 s  .  c o m
    JPanel timeSelectionPanel = createTimeSelectionPanel();
    JPanel northPanel = new JPanel(new GridLayout(3, 1, 0, 0));
    northPanel.add(serverExpirationTimeOption);
    northPanel.add(manualExpirationTimeOption);
    northPanel.add(timeSelectionPanel);
    add(northPanel, BorderLayout.NORTH);

    JPanel centerPanel = new JPanel(new BorderLayout(0, 0));
    JLabel label = new JLabel(
            "<html>Here you can set an expiry time if the OAuth 2 server doesn't,<br/>so that the token retrieval can be automated.</html>");
    label.setForeground(new Color(143, 143, 143));
    centerPanel.add(label, BorderLayout.NORTH);
    add(centerPanel, BorderLayout.CENTER);

    //      JLabel helpLink = UISupport.createLabelLink( "http://www.soapui.org", "Learn how to use the token expiration time " );
    //      add( helpLink, BorderLayout.SOUTH );
}

From source file:de.fub.maps.project.detector.model.inference.ui.charts.AttributeSelectionBarChart.java

/**
 * Creates new form AttributeSelectionBarChart
 *//*w  w w  .  j av  a2 s  .co m*/
public AttributeSelectionBarChart() {
    initComponents();
    barChart = ChartFactory.createBarChart(
            NbBundle.getMessage(AttributeSelectionBarChart.class, "AttributeSelectionBarChart.CLT_Chart_Title"),
            NbBundle.getMessage(AttributeSelectionBarChart.class,
                    "AttributeSelectionBarChart.CLT_Domain_Axis_Name"),
            NbBundle.getMessage(AttributeSelectionBarChart.class,
                    "AttributeSelectionBarChart.CLT_Value_Axis_Name"),
            dataset, PlotOrientation.VERTICAL, true, true, true);
    plot = barChart.getCategoryPlot();
    Font font = new JLabel().getFont().deriveFont(Font.BOLD, 14);

    barChart.getTitle().setFont(font);
    barChart.getTitle().setPaint(new Color(153, 153, 153));

    plot.setRangeAxisLocation(0, AxisLocation.TOP_OR_LEFT);

    plot.setBackgroundPaint(Color.white);
    plot.getRangeAxis().setAutoRange(true);
    plot.getRangeAxis().setUpperMargin(.1);

    BarRenderer barRenderer = new BarRenderer();
    barRenderer.setBarPainter(new StandardBarPainter());
    barRenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    barRenderer.setBaseFillPaint(Color.BLUE);
    barRenderer.setBasePaint(Color.BLUE);
    barRenderer.setAutoPopulateSeriesFillPaint(false);
    barRenderer.setAutoPopulateSeriesPaint(false);
    barRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator(
            StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING, new CustomNumberFormat()));
    barRenderer.setBaseItemLabelsVisible(true);

    plot.setRenderer(barRenderer);
    chartPanel = new ChartPanel(barChart, false);
    chartPanel.setVerticalAxisTrace(false);
    add(chartPanel, BorderLayout.CENTER);
}

From source file:com.polivoto.logica.RecibirVotos.java

public void actualizarConteo(int personasQueHanVotado) {
    /*/*from ww w  . ja va 2 s .  co m*/
    * Porcentaje
    */
    if (votos >= poblacion)
        poblacion = votos = personasQueHanVotado;
    else
        votos = personasQueHanVotado;
    lblvotos_totales.setText(String.valueOf(personasQueHanVotado));
    porcentaje = (votos * 100) / (poblacion == 0 ? 1 : poblacion);
    if (porcentaje >= 100.0 || (porcentaje % 1) == 0)
        decimales = new DecimalFormat("0");
    else
        decimales = new DecimalFormat("0.00");
    lblporcentaje.setText("" + decimales.format(porcentaje) + "%");

    // Fuente de Datos
    data = new DefaultPieDataset();
    data.setValue("SI", votos);
    data.setValue("NO", poblacion - votos);
    // Creando el Grafico
    chart = ChartFactory.createPieChart("", data, false, false, false);
    chart.setBackgroundPaint(Color.white);

    plot = (PiePlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setLabelGenerator(null);
    plot.setOutlineVisible(false);
    plot.setSectionPaint("SI", new Color(0, 204, 0));
    plot.setSectionPaint("NO", new Color(218, 24, 24));

    // Crear el Panel del Grafico con ChartPanel
    chartPanel = new ChartPanel(chart, 161, 131, 161, 131, 161, 131, false, false, false, false, false, false);
    chartPanel.setEnabled(false);
    pnlgrafica.setLayout(new java.awt.BorderLayout());
    pnlgrafica.removeAll();
    pnlgrafica.add(chartPanel, BorderLayout.CENTER);
    pnlgrafica.validate();
}

From source file:com.googlecode.logVisualizer.chart.StatDevelopmentLineChart.java

@Override
protected ChartPanel createChartPanel() {
    final ChartPanel panel = super.createChartPanel();
    final XYPlot plot = (XYPlot) panel.getChart().getPlot();

    for (final DayChange dc : getLogData().getDayChanges()) {
        final ValueMarker day = new ValueMarker(dc.getTurnNumber());
        day.setLabel("Day " + dc.getDayNumber());
        day.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
        day.setLabelTextAnchor(TextAnchor.TOP_LEFT);
        day.setStroke(new BasicStroke(2));
        day.setPaint(new Color(175, 175, 255));
        plot.addDomainMarker(day);//from ww w .j a  v a2s.  c o  m
    }

    return panel;
}

From source file:uom.research.thalassemia.util.PieChartCreator.java

/**
 * Creates a chart./*from   w w w .  j  a  v a 2 s  . c  o m*/
 *
 * @param dataset the dataset.
 *
 * @return A chart.
 */
private JFreeChart createChart(PieDataset dataset) {

    JFreeChart chart = ChartFactory.createPieChart(title, // chart title
            dataset, // data
            true, // no legend
            true, // tooltips
            false // no URL generation
    );

    // set a custom background for the chart
    chart.setBackgroundPaint(
            new GradientPaint(new Point(0, 0), new Color(20, 20, 20), new Point(400, 200), Color.DARK_GRAY));

    // customise the title position and font
    TextTitle t = chart.getTitle();
    t.setHorizontalAlignment(HorizontalAlignment.LEFT);
    t.setPaint(new Color(240, 240, 240));
    t.setFont(new Font("Arial", Font.BOLD, 26));

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setBackgroundPaint(null);
    plot.setInteriorGap(0.04);
    plot.setOutlineVisible(false);

    // use gradients and white borders for the section colours
    int itemIndex = 0;
    for (Object col : pieDataset.getKeys()) {
        plot.setSectionPaint(col.toString(), gradientPaints[itemIndex]);
        if (itemIndex == pieDataset.getItemCount() - 1) {
            itemIndex = 0;
        }
        itemIndex++;
    }

    plot.setBaseSectionOutlinePaint(Color.WHITE);
    plot.setSectionOutlinesVisible(true);
    plot.setBaseSectionOutlineStroke(new BasicStroke(2.0f));

    // customise the section label appearance
    plot.setLabelFont(new Font("Courier New", Font.BOLD, 20));
    plot.setLabelLinkPaint(Color.WHITE);
    plot.setLabelLinkStroke(new BasicStroke(2.0f));
    plot.setLabelOutlineStroke(null);
    plot.setLabelPaint(Color.WHITE);
    plot.setLabelBackgroundPaint(null);

    // add a subtitle giving the data source
    TextTitle source = new TextTitle("Source: http://www.bbc.co.uk/news/business-15489523",
            new Font("Courier New", Font.PLAIN, 12));
    source.setPaint(Color.WHITE);
    source.setPosition(RectangleEdge.BOTTOM);
    source.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    chart.addSubtitle(source);
    return chart;

}