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:org.jax.maanova.plot.PlotUtil.java

/**
 * Create a simple XY renderer which can be used for scatter plots
 * @return  the renderer/*from   w  w w.  j  av a2 s .  co  m*/
 */
public static XYLineAndShapeRenderer createSimpleScatterPlotRenderer() {
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true);

    renderer.setAutoPopulateSeriesShape(false);
    renderer.setAutoPopulateSeriesOutlinePaint(false);
    renderer.setAutoPopulateSeriesOutlineStroke(false);
    renderer.setAutoPopulateSeriesPaint(false);

    renderer.setBaseShape(new Ellipse2D.Float(-PlotUtil.SCATTER_PLOT_DOT_SIZE_PIXELS / 2F,
            -PlotUtil.SCATTER_PLOT_DOT_SIZE_PIXELS / 2F, PlotUtil.SCATTER_PLOT_DOT_SIZE_PIXELS,
            PlotUtil.SCATTER_PLOT_DOT_SIZE_PIXELS));

    renderer.setUseOutlinePaint(true);
    renderer.setBaseOutlinePaint(Color.BLACK);
    renderer.setBaseOutlineStroke(new BasicStroke(0.25F));

    renderer.setSeriesPaint(0, new Color(0x55, 0x55, 0xFF)); // blue
    renderer.setSeriesPaint(1, new Color(0xFF, 0x55, 0x55)); // red

    return renderer;
}

From source file:pidev.presentation.Statistiques.java

/**
 * Creates new form Statistiques/*from  w  w  w .ja v a2  s. co m*/
 */
public Statistiques() {
    initComponents();
    this.getContentPane().setBackground(new Color(52, 152, 219));
    this.setLocationRelativeTo(null);
    this.pack();

    this.setSize(600, 400);

}

From source file:ColorBlocks.java

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

    Dimension d = getSize();/* w  w  w . jav a  2  s.  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:MainClass.java

public void onGenericTag(PdfWriter writer, Document document, Rectangle rect, String text) {
    if ("ellipse".equals(text)) {
        PdfContentByte cb = writer.getDirectContent();
        cb.setRGBColorStroke(0xFF, 0x00, 0x00);
        cb.ellipse(rect.left(), rect.bottom() - 5f, rect.right(), rect.top());
        cb.stroke();/*w  w  w.  j a  v a  2  s . c  o  m*/
        cb.resetRGBColorStroke();
    } else if ("box".equals(text)) {
        PdfContentByte cb = writer.getDirectContentUnder();
        rect.setBackgroundColor(new Color(0xa5, 0x2a, 0x2a));
        cb.rectangle(rect);
    }
}

From source file:SpiderChartCustomizer.java

@Override
public void customize(JFreeChart chart, ChartComponent chartComponent) {
    chart.getPlot().setOutlineVisible(true);
    chart.getPlot().setOutlinePaint(new Color(0, 0, 255));
    chart.getPlot().setOutlineStroke(new BasicStroke(1f));
}

From source file:Componentes.TermometroMin.java

@Override
public void pintar(javax.swing.JPanel p, int pos) {
    p.removeAll();/*from  w  w  w.j  a va 2 s  . co  m*/
    DefaultValueDataset data = new DefaultValueDataset(new Double(ventana.getGraphdata().getTmin()));

    ThermometerPlot plot = new ThermometerPlot(data);
    chart = new JFreeChart("Temperatura Mnima, \nMES: " + Calculos.get_mes(ventana.getMonthdata().getdata()), // chart title
            JFreeChart.DEFAULT_TITLE_FONT, plot, // plot
            false);
    Color Darkorange = new Color(255, 140, 0);
    Color Crimson = new Color(220, 20, 60);
    Color Aquamarine = new Color(127, 255, 212);
    Color Darkslategray = new Color(47, 79, 79);

    plot.setMercuryPaint(Aquamarine);
    plot.setSubrange(NORMAL, 0, 2.5);
    plot.setSubrange(WARNING, 2.6, 7.5);
    plot.setSubrange(CRITICAL, 7.6, 20);
    plot.setSubrangePaint(NORMAL, Aquamarine);
    plot.setSubrangePaint(WARNING, Darkorange);
    plot.setSubrangePaint(CRITICAL, Crimson);

    plot.setThermometerStroke(new BasicStroke(2.0f));
    plot.setThermometerPaint(Darkslategray);

    plot.setDisplayRange(2, Calculos.get_min(datos.getTmin()), Calculos.get_max(datos.getTmin()));
    plot.setRange(Calculos.get_min(datos.getTmin()), Calculos.get_max(datos.getTmin()));

    panel = new ChartPanel(chart);
    panel.setBounds(5, 5, 300, 300);
    panel.repaint();
    p.add(panel);
    // jPanel1.repaint();
    p.updateUI();
    // aoIndex=aoAux;
    ///aoAux = 0;
}

From source file:com.opendoorlogistics.components.geocode.postcodes.impl.SummaryPanel.java

public SummaryPanel() {
    setLayout(new BorderLayout());
    text.setEditable(false);/*w w w .  jav  a  2 s  . co  m*/
    JScrollPane scrollpane = new JScrollPane(text);
    scrollpane.setViewportView(text);
    add(scrollpane, BorderLayout.CENTER);
    Dimension size = new Dimension(350, 100);
    scrollpane.setMinimumSize(new Dimension(1, (int) size.getHeight()));
    scrollpane.setPreferredSize(size);
    scrollpane.setMaximumSize(new Dimension(2000, (int) size.getHeight()));
    text.setBackground(new Color(220, 220, 220));
    text.setOpaque(true);

}

From source file:D20140128.ApacheXMLGraphicsTest.EPSExample1.java

/**
 * Creates an EPS file. The contents are painted using a Graphics2D
 * implementation that generates an EPS file.
 *
 * @param outputFile the target file/*from  ww  w .j  a v a2 s .c  o m*/
 * @throws IOException In case of an I/O error
 */
public static void generateEPSusingJava2D(File outputFile) throws IOException {
    OutputStream out = new java.io.FileOutputStream(outputFile);
    out = new java.io.BufferedOutputStream(out);
    try {
        //Instantiate the EPSDocumentGraphics2D instance
        EPSDocumentGraphics2D g2d = new EPSDocumentGraphics2D(false);
        g2d.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());

        //Set up the document size
        g2d.setupDocument(out, 400, 200); //400pt x 200pt

        //Paint a bounding box
        g2d.drawRect(0, 0, 400, 200);

        //A few rectangles rotated and with different color
        Graphics2D copy = (Graphics2D) g2d.create();
        int c = 12;
        for (int i = 0; i < c; i++) {
            float f = ((i + 1) / (float) c);
            Color col = new Color(0.0f, 1 - f, 0.0f);
            copy.setColor(col);
            copy.fillRect(70, 90, 50, 50);
            copy.rotate(-2 * Math.PI / (double) c, 70, 90);
        }
        copy.dispose();

        //Some text
        g2d.rotate(-0.25);
        g2d.setColor(Color.RED);
        g2d.setFont(new Font("sans-serif", Font.PLAIN, 36));
        g2d.drawString("Hello world!", 140, 140);
        g2d.setColor(Color.RED.darker());
        g2d.setFont(new Font("serif", Font.PLAIN, 36));
        g2d.drawString("Hello world!", 140, 180);

        //Cleanup
        g2d.finish();
    } finally {
        IOUtils.closeQuietly(out);
    }
}

From source file:Reportes.BarChart.java

public ChartPanel reporteEmpleados(DefaultCategoryDataset data) {
    JFreeChart JFchart = ChartFactory.createBarChart("Reporte de empleados", "Sedes", "Cantidad", data,
            PlotOrientation.VERTICAL, true, true, true);
    /*// www. j a v a 2  s.  c  om
    CategoryPlot plot = new CategoryPlot();
            
    ChartFrame chartFrame = new ChartFrame("Reporte de empleadoos", JFchart, false);
    chartFrame.setSize(300, 300);
    chartFrame.setVisible(true);
    */

    CategoryPlot categoryP = JFchart.getCategoryPlot();
    BarRenderer renderer = (BarRenderer) categoryP.getRenderer();
    renderer.setMaximumBarWidth(0.35);
    Color color = new Color(67, 165, 208);
    renderer.setSeriesPaint(0, color);

    ChartPanel panel = new ChartPanel(JFchart, true, true, true, false, false);

    panel.setSize(ancho, alto);

    return panel;
}

From source file:net.sf.jasperreports.samples.spiderchartcomponent.SpiderChartCustomizer.java

public void customize(JFreeChart chart, ChartComponent chartComponent) {
    chart.getPlot().setOutlineVisible(true);
    chart.getPlot().setOutlinePaint(new Color(0, 0, 255));
    chart.getPlot().setOutlineStroke(new BasicStroke(1f));
}