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:com.github.pemapmodder.pocketminegui.gui.server.ConsolePanel.java

public ConsolePanel(ServerMainActivity activity) {
    this.activity = activity;
    setLayout(new GridBagLayout());
    setBorder(BorderFactory.createEmptyBorder(20, 10, 20, 10));
    title = new JLabel("PocketMine-MP");
    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.CENTER;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weighty = 0.1;/*  w ww. j av  a  2  s .com*/
    add(title, c);
    stdout = new JEditorPane();
    stdout.setContentType("text/html");
    stdout.setText("<html><body style='font-family: monospace; color: #FFFFFF;'><p id='p'></p></body></html>");
    doc = (HTMLDocument) stdout.getDocument();
    para = doc.getElement("p");
    //      stdout.setEditable(false);
    // People NEED to see this to feel happy
    stdout.setForeground(Color.WHITE);
    stdout.setBackground(Color.BLACK);
    Style style = doc.getStyleSheet().addStyle(null, null);
    //      style.addAttribute(StyleConstants.Foreground, Color.WHITE);
    //      style.addAttribute(StyleConstants.Background, Color.RED);
    doc.setParagraphAttributes(para.getStartOffset(), 1, style, true);
    stdout.setBorder(BorderFactory.createDashedBorder(new Color(0x80, 0x80, 0x80)));
    c.gridy = 1;
    c.weightx = 0.9;
    c.weighty = 0.9;
    c.weighty = 0.6;
    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.NORTH;
    add(stdout, c);
    Timer timer = new Timer(50, e -> updateConsole());
    timer.start();
}

From source file:cachitodelivery.Estadisticas.java

public void colorHeader(int j) {
    Header h = new Header(new Color(53, 95, 123), new Color(255, 255, 255));
    for (int i = 0; i < j; i++) {
        jTable1.getColumnModel().getColumn(i).setHeaderRenderer(h);
    }//  www  .  j a va2s.co m
}

From source file:demo.BarChartDemo11.java

/**
 * Creates a sample chart./*w w  w.j a  va2s . c  o  m*/
 *
 * @param dataset  the dataset.
 *
 * @return The chart.
 */
private static JFreeChart createChart(CategoryDataset dataset) {

    // create the chart...
    JFreeChart chart = ChartFactory.createBarChart("Open Source Projects By License", "License", "Percent",
            dataset);
    chart.removeLegend();

    TextTitle source = new TextTitle(
            "Source: http://www.blackducksoftware.com/resources/data/top-20-licenses (as at 30 Aug 2013)",
            new Font("Dialog", Font.PLAIN, 9));
    source.setPosition(RectangleEdge.BOTTOM);
    chart.addSubtitle(source);

    // get a reference to the plot for further customisation...
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setOrientation(PlotOrientation.HORIZONTAL);
    plot.setDomainGridlinesVisible(true);

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

    // disable bar outlines...
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);

    StandardCategoryToolTipGenerator tt = new StandardCategoryToolTipGenerator("{1}: {2} percent",
            new DecimalFormat("0"));
    renderer.setBaseToolTipGenerator(tt);

    // set up gradient paints for series...
    GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.BLUE, 0.0f, 0.0f, new Color(0, 0, 64));
    renderer.setSeriesPaint(0, gp0);

    return chart;

}

From source file:ColorChooserMenu.java

public ColorMenu(String name) {
    super(name);//from   w w w.  jav  a  2  s . c o  m
    unselectedBorder = new CompoundBorder(new MatteBorder(1, 1, 1, 1, getBackground()),
            new BevelBorder(BevelBorder.LOWERED, Color.white, Color.gray));
    selectedBorder = new CompoundBorder(new MatteBorder(1, 1, 1, 1, Color.red),
            new MatteBorder(1, 1, 1, 1, getBackground()));
    activeBorder = new CompoundBorder(new MatteBorder(1, 1, 1, 1, Color.blue),
            new MatteBorder(1, 1, 1, 1, getBackground()));

    JPanel p = new JPanel();
    p.setBorder(new EmptyBorder(5, 5, 5, 5));
    p.setLayout(new GridLayout(8, 8));
    paneTable = new Hashtable();

    int[] values = new int[] { 0, 128, 192, 255 };

    for (int r = 0; r < values.length; r++) {
        for (int g = 0; g < values.length; g++) {
            for (int b = 0; b < values.length; b++) {
                Color c = new Color(values[r], values[g], values[b]);
                ColorPane pn = new ColorPane(c);
                p.add(pn);
                paneTable.put(c, pn);
            }
        }
    }
    add(p);
}

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

/**
 * Sets the color scale.//w ww  .j  av  a2  s  .  c o m
 * @param lowerBound the lower bound.
 * @param upperBound the upper bound.
 */
private void setColorScale(double lowerBound, double upperBound) {
    if (upperBound == lowerBound)
        upperBound++;
    GrayPaintScale colorPaintScale = new GrayPaintScale(lowerBound, upperBound) {
        public Paint getPaint(double value) {
            double v = Math.max(value, this.getLowerBound());
            v = Math.min(v, this.getUpperBound());
            int g = 255 - (int) ((v - this.getLowerBound()) * 2 / (this.getUpperBound() - this.getLowerBound())
                    * 255.0);
            if (g >= 0)
                return new Color(255, 255 - g, 0);
            return new Color(255 + g, 255, 0);
        }
    };
    XYShapeRenderer renderer = (XYShapeRenderer) this.getXYPlot().getRenderer(1);
    renderer.setPaintScale(colorPaintScale);
}

From source file:MouseEventDemo.java

public MouseEventDemo() {
    super(new GridBagLayout());
    GridBagLayout gridbag = (GridBagLayout) getLayout();
    GridBagConstraints c = new GridBagConstraints();

    c.fill = GridBagConstraints.BOTH;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1.0;//from   w ww  . j a v  a  2 s . c om
    c.weighty = 1.0;

    c.insets = new Insets(1, 1, 1, 1);
    blankArea = new BlankArea(new Color(0.98f, 0.97f, 0.85f));
    gridbag.setConstraints(blankArea, c);
    add(blankArea);

    c.insets = new Insets(0, 0, 0, 0);
    textArea = new JTextArea();
    textArea.setEditable(false);
    JScrollPane scrollPane = new JScrollPane(textArea);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPane.setPreferredSize(new Dimension(200, 75));
    gridbag.setConstraints(scrollPane, c);
    add(scrollPane);

    //Register for mouse events on blankArea and the panel.
    blankArea.addMouseListener(this);
    addMouseListener(this);

    setPreferredSize(new Dimension(450, 450));
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}

From source file:it.eng.spagobi.engines.kpi.bo.charttypes.dialcharts.SimpleDial.java

/**
 * Creates the chart .//ww  w  . j  a  va 2  s  .  c  om
 * 
 * @return A Simple Dial chart .
 */
public JFreeChart createChart() {
    logger.debug("IN");

    if (dataset == null) {
        logger.debug("The dataset to be represented is null");
        return null;
    }

    DialPlot plot = new DialPlot();
    plot.setDataset((ValueDataset) dataset);
    logger.debug("Created the new Dial Plot");

    ArcDialFrame dialFrame = null;
    plot.setView(0.21, 0.0, 0.58, 0.30);
    dialFrame = new ArcDialFrame(60.0, 60.0);
    dialFrame.setInnerRadius(0.65);
    dialFrame.setOuterRadius(0.90);
    dialFrame.setForegroundPaint(Color.darkGray);
    dialFrame.setStroke(new BasicStroke(3.0f));
    plot.setDialFrame(dialFrame);

    GradientPaint gp = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(),
            new Color(240, 240, 240));
    DialBackground sdb = new DialBackground(gp);

    GradientPaintTransformType gradientPaintTransformType = GradientPaintTransformType.HORIZONTAL;

    sdb.setGradientPaintTransformer(new StandardGradientPaintTransformer(gradientPaintTransformType));
    plot.addLayer(sdb);

    increment = (upper - lower) / 4;
    StandardDialScale scale = null;
    scale = new StandardDialScale(lower, upper, 115.0, -50.0, increment, minorTickCount);

    // sets intervals
    for (Iterator iterator = intervals.iterator(); iterator.hasNext();) {
        KpiInterval interval = (KpiInterval) iterator.next();
        StandardDialRange range = new StandardDialRange(interval.getMin(), interval.getMax(),
                interval.getColor());
        range.setInnerRadius(0.70);
        range.setOuterRadius(0.75);
        plot.addLayer(range);

    }

    scale.setTickRadius(0.88);
    scale.setTickLabelOffset(0.07);
    Font f = new Font("Arial", Font.PLAIN, 11);
    scale.setTickLabelFont(f);
    //scale.setMajorTickIncrement(25.0);
    plot.addScale(0, scale);

    DialPointer needle = new DialPointer.Pin();
    needle.setRadius(0.82);
    plot.addLayer(needle);

    JFreeChart chart1 = new JFreeChart(plot);
    logger.debug("Created the chart");
    chart1.setBackgroundPaint(color);
    logger.debug("Setted background color of the chart");

    TextTitle title = setStyleTitle(name, styleTitle);
    chart1.setTitle(title);
    logger.debug("Setted the title of the chart");
    if (subName != null && !subName.equals("")) {
        TextTitle subTitle = setStyleTitle(subName, styleSubTitle);
        chart1.addSubtitle(subTitle);
        logger.debug("Setted the subtitle of the chart");
    }

    logger.debug("OUT");
    return chart1;
}

From source file:it.marcoberri.mbmeteo.action.chart.GetLastUDial.java

/**
 * Processes requests for both HTTP//  w w w .  java2  s.  c  o  m
 * <code>GET</code> and
 * <code>POST</code> methods.
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    log.debug("start : " + this.getClass().getName());

    final HashMap<String, String> params = getParams(request.getParameterMap());
    final Integer dimy = Default.toInteger(params.get("dimy"), 600);
    final Integer dimx = Default.toInteger(params.get("dimx"), 800);

    Meteolog meteolog = ds.find(Meteolog.class).order("-time").limit(1).get();

    DefaultValueDataset dataset = new DefaultValueDataset(meteolog.getOutdoorHumidity());

    // get data for diagrams
    DialPlot plot = new DialPlot();
    plot.setInsets(RectangleInsets.ZERO_INSETS);
    //plot.setView(0.1, 0.1, 0.9, 0.9);
    // plot.set
    plot.setDataset(0, dataset);

    GradientPaint gp = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(),
            new Color(170, 170, 220));

    DialBackground db = new DialBackground(gp);
    db.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_HORIZONTAL));
    plot.setBackground(db);

    StandardDialScale scale = new StandardDialScale();
    scale.setLowerBound(0);
    scale.setUpperBound(100);
    scale.setTickLabelOffset(0.14);
    scale.setTickLabelFont(new Font("Dialog", Font.PLAIN, 10));
    plot.addScale(0, scale);
    plot.setInsets(RectangleInsets.ZERO_INSETS);

    DialPointer needle = new DialPointer.Pointer(0);

    plot.addLayer(needle);

    JFreeChart chart1 = new JFreeChart(plot);
    chart1.setTitle("Humidity %");

    final File f = File.createTempFile("mbmeteo", ".jpg");
    ChartUtilities.saveChartAsJPEG(f, chart1, dimx, dimy);

    response.setContentType("image/jpeg");
    response.setHeader("Content-Length", "" + f.length());
    response.setHeader("Content-Disposition", "inline; filename=\"" + f.getName() + "\"");
    final OutputStream out = response.getOutputStream();
    final FileInputStream in = new FileInputStream(f.toString());
    final int size = in.available();
    final byte[] content = new byte[size];
    in.read(content);
    out.write(content);
    in.close();
    out.close();
}

From source file:ar.com.fdvs.dj.test.ConditionalStylesReportTest.java

public DynamicReport buildReport() throws Exception {

    Style detailStyle = new Style();
    Style headerStyle = new Style();
    headerStyle.setFont(Font.ARIAL_BIG_BOLD);
    headerStyle.setBorderBottom(Border.PEN_2_POINT);
    headerStyle.setHorizontalAlign(HorizontalAlign.CENTER);
    headerStyle.setVerticalAlign(VerticalAlign.MIDDLE);
    headerStyle.setBackgroundColor(Color.LIGHT_GRAY);
    headerStyle.setTextColor(Color.WHITE);
    headerStyle.setTransparency(Transparency.OPAQUE);

    Style titleStyle = new Style();
    titleStyle.setFont(new Font(18, Font._FONT_VERDANA, true));
    Style amountStyle = new Style();
    amountStyle.setHorizontalAlign(HorizontalAlign.RIGHT);
    Style oddRowStyle = new Style();
    oddRowStyle.setBorder(Border.NO_BORDER);
    Color veryLightGrey = new Color(230, 230, 230);
    oddRowStyle.setBackgroundColor(veryLightGrey);
    oddRowStyle.setTransparency(Transparency.OPAQUE);

    DynamicReportBuilder drb = new DynamicReportBuilder();
    Integer margin = new Integer(20);
    drb.setTitle("November 2006 sales report")
            .setSubtitle("The items in this report correspond "
                    + "to the main products: DVDs, Books, Foods and Magazines")
            .setTitleStyle(titleStyle).setTitleHeight(new Integer(30)).setSubtitleHeight(new Integer(20))
            .setDetailHeight(new Integer(15)).setLeftMargin(margin).setRightMargin(margin).setTopMargin(margin)
            .setBottomMargin(margin).setPrintBackgroundOnOddRows(true).setOddRowBackgroundStyle(oddRowStyle)
            .setColumnsPerPage(new Integer(1)).setColumnSpace(new Integer(5));

    AbstractColumn columnState = ColumnBuilder.getNew().setColumnProperty("state", String.class.getName())
            .setTitle("State").setWidth(new Integer(85)).setStyle(detailStyle).setHeaderStyle(headerStyle)
            .build();//from   w  ww. j a v a 2 s . c  om

    AbstractColumn columnBranch = ColumnBuilder.getNew().setColumnProperty("branch", String.class.getName())
            .setTitle("Branch").setWidth(new Integer(85)).setStyle(detailStyle).setHeaderStyle(headerStyle)
            .build();

    AbstractColumn columnaProductLine = ColumnBuilder.getNew()
            .setColumnProperty("productLine", String.class.getName()).setTitle("Product Line")
            .setWidth(new Integer(85)).setStyle(detailStyle).setHeaderStyle(headerStyle).build();

    AbstractColumn columnaItem = ColumnBuilder.getNew().setColumnProperty("item", String.class.getName())
            .setTitle("Item").setWidth(new Integer(85)).setStyle(detailStyle).setHeaderStyle(headerStyle)
            .build();

    AbstractColumn columnCode = ColumnBuilder.getNew().setColumnProperty("id", Long.class.getName())
            .setTitle("ID").setWidth(new Integer(40)).setStyle(amountStyle).setHeaderStyle(headerStyle).build();

    AbstractColumn columnaCantidad = ColumnBuilder.getNew().setColumnProperty("quantity", Long.class.getName())
            .setTitle("Quantity").setWidth(new Integer(80)).setStyle(amountStyle).setHeaderStyle(headerStyle)
            .build();

    //Define Conditional Styles

    ArrayList conditionalStyles = createConditionalStyles(amountStyle);

    AbstractColumn columnAmount = ColumnBuilder.getNew().setColumnProperty("amount", Float.class.getName())
            .setTitle("Amount").setWidth(new Integer(90)).setPattern("$ 0.00")
            .addConditionalStyles(conditionalStyles).setStyle(amountStyle).setHeaderStyle(headerStyle).build();

    drb.addColumn(columnState);
    drb.addColumn(columnBranch);
    drb.addColumn(columnaProductLine);
    drb.addColumn(columnaItem);
    drb.addColumn(columnCode);
    drb.addColumn(columnaCantidad);
    drb.addColumn(columnAmount);

    drb.setUseFullPageWidth(true);

    DynamicReport dr = drb.build();
    return dr;
}

From source file:datavis.BarGraph.java

public JFreeChart getChartPanel() {
    JFreeChart chart = ChartFactory.createBarChart(getBarGraphName(), getIntervalTypeName(),
            getNumberTypeName(), getBarGraph(), PlotOrientation.VERTICAL, true, true, false);
    chart.setBackgroundPaint(Color.white);

    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.darkGray);
    plot.setDomainGridlinePaint(new Color(240, 180, 180));
    plot.setRangeGridlinePaint(new Color(240, 180, 180));

    final BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setBarPainter(new StandardBarPainter());

    final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, new Color(170, 240, 240), 0.0f, 0.0f,
            new Color(170, 240, 240));

    renderer.setSeriesPaint(0, gp0);//from   w w w.j  a v  a 2 s.c  om

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

    return chart;
}