Example usage for java.awt Color WHITE

List of usage examples for java.awt Color WHITE

Introduction

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

Prototype

Color WHITE

To view the source code for java.awt Color WHITE.

Click Source Link

Document

The color white.

Usage

From source file:graficarordenamiento.Graficador.java

public void crearGrafico() {
    // Creando el Grafico
    chart = ChartFactory.createBarChart("Grfico de barras", null, null, dataset, PlotOrientation.VERTICAL,
            false, false, false);/*from  w  w  w .  j a  v a 2s  .c  o m*/

    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.WHITE, 700, 0, Color.BLACK.brighter(), false));
    chart.setBackgroundImageAlpha(0.5f);
    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setNoDataMessage("NO DATA!");
    plot.setRangeGridlinePaint(Color.red);
    plot.setBackgroundPaint(new GradientPaint(0, 0, Color.LIGHT_GRAY, 0, 100, Color.darkGray));
    plot.setBackgroundImageAlpha(0.5f);
    //plot.setDomainGridlinesVisible(true);

    BarRenderer rend = (BarRenderer) plot.getRenderer();

    final ItemLabelPosition e = new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER,
            TextAnchor.CENTER, 45.0);

    GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64));
    GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0));
    GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0));

    rend.setSeriesPaint(0, gp0);
    rend.setSeriesPaint(1, gp1);
    rend.setSeriesPaint(2, gp2);
    plot.setRenderer(rend);

    // change the margin at the top of the range axis...
    final ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setLowerMargin(0.15);
    rangeAxis.setUpperMargin(0.15);

    // set up gradient paints for series...

}

From source file:edu.emory.library.tast.database.graphs.GraphTypeBar.java

public JFreeChart createChart(Object[] data) {

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    JFreeChart chart = ChartFactory.createBarChart(null, getSelectedIndependentVariable().getLabel(),
            TastResource.getText("components_charts_barvalue"), dataset, PlotOrientation.VERTICAL, true, true,
            false);// ww w. j a va  2s  .  c  o m

    CategoryPlot plot = chart.getCategoryPlot();
    plot.getDomainAxis().setMaximumCategoryLabelLines(5);
    plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.DOWN_90);
    chart.setBackgroundPaint(Color.white);

    Format formatter = getSelectedIndependentVariable().getFormat();

    List allDataSeries = getDataSeries();
    for (int j = 0; j < allDataSeries.size(); j++) {

        DataSeries dataSearies = (DataSeries) allDataSeries.get(j);
        String dataSeriesLabel = dataSearies.formatForDisplay();

        for (int i = 0; i < data.length; i++) {
            Object[] row = (Object[]) data[i];

            String cat = formatter == null ? row[0].toString() : formatter.format(row[0]);

            dataset.addValue((Number) row[j + 1], dataSeriesLabel, cat);
        }
    }

    LegendItemCollection legendItems = chart.getPlot().getLegendItems();
    for (int i = 0; i < legendItems.getItemCount(); i++) {
        LegendItem legendItem = legendItems.get(i);
        DataSeries dataSearies = (DataSeries) allDataSeries.get(i);
        if (legendItem.getFillPaint() instanceof Color) {
            dataSearies.setColor(((Color) legendItem.getFillPaint()));
        }
    }

    return chart;

}

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

/**
 * Creates a sample chart.//from  w  w  w.jav a  2  s. co m
 *
 * @param dataset the dataset.
 *
 * @return The chart.
 */
private JFreeChart createChart(final CategoryDataset dataset) {
    JFreeChart chart = ChartFactory.createBarChart(mainTitle, xTitle, yTitle, dataset);
    chart.addSubtitle(new TextTitle(subTitle));
    chart.setBackgroundPaint(Color.white);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);
    chart.getLegend().setFrame(BlockBorder.NONE);
    return chart;
}

From source file:juicebox.tools.utils.juicer.apa.APAPlotter.java

/**
 * Method for plotting apa data//from   w  ww  .  j a v a 2s .c o  m
 *
 * @param data       for heat map
 * @param axesRange  initial values and increments to annotate axes [x0, dx, y0, dy]
 * @param outputFile where image will saved
 */
public static void plot(RealMatrix data, int[] axesRange, File outputFile, String title) {

    APARegionStatistics apaStats = new APARegionStatistics(data);
    DecimalFormat df = new DecimalFormat("0.000");
    title += ", P2LL = " + df.format(apaStats.getPeak2LL());

    // initialize heat map
    HeatChart map = new HeatChart(data.getData());
    map.setLowValueColour(Color.WHITE);
    map.setHighValueColour(Color.RED);
    map.setXValues(axesRange[0], axesRange[1]);
    map.setYValues(axesRange[2], axesRange[3]);
    map.setTitle(title);

    try {
        // calculate dimensions for plot wrapper
        initializeSizes(map);

        // create blank white image
        BufferedImage apaImage = new BufferedImage(fullWidth, fullHeight, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g2 = apaImage.createGraphics();
        g2.setBackground(Color.WHITE);
        g2.fillRect(0, 0, fullWidth, fullHeight);

        // plot in heat map, color bar, etc
        g2.drawImage(map.getChartImage(), 0, 0, heatmapWidth, fullHeight, null);
        drawHeatMapBorder(g2, map);
        plotColorScaleBar(g2);
        plotColorScaleValues(g2, map);

        // top left, top right, bottom left, bottom right values (from apa)

        drawCornerRegions(g2, map, new Dimension(APA.regionWidth, APA.regionWidth),
                apaStats.getRegionCornerValues());

        // save data
        ImageIO.write(apaImage, "png", outputFile);

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

From source file:com.sciaps.utils.Util.java

public static int validateOneOrGreater(JTextField txtField) {

    Pattern pattern = Pattern.compile(POSITIVE_INT);
    if (pattern.matcher(txtField.getText()).matches()) {
        int val = getStringToInt(txtField.getText());
        if (val > 0) {
            txtField.setBackground(Color.white);
            return val;
        }/* w  w w  . j  av  a  2  s .  c om*/
    }

    txtField.setBackground(Color.red);
    return -1;
}

From source file:com.eviware.soapui.support.components.JDebugPropertiesTable.java

public JDebugPropertiesTable(T propertyObject) {

    tableModel = new PropertiesTableModel<T>(propertyObject);
    table = new PTable(tableModel);

    table.getColumnModel().getColumn(0).setHeaderValue("Property");
    table.getColumnModel().getColumn(1).setHeaderValue("Value");
    table.getColumnModel().getColumn(0).setCellRenderer(new PropertiesTableCellRenderer());
    table.getColumnModel().getColumn(1).setCellRenderer(new PropertiesTableCellRenderer());

    table.setBackground(Color.WHITE);
}

From source file:be.ac.ua.comp.scarletnebula.gui.AllGraphsPanel.java

/**
 * Constructor./*  www  .j a v a2  s  . co  m*/
 * 
 * @param server
 *            The server whose statistics to display.
 */
public AllGraphsPanel(final Server server) {
    super(new GridBagLayout());
    this.server = server;
    statisticsManager = server.getServerStatistics();
    statisticsManager.addNewDatastreamListener(this);
    statisticsManager.addDeleteDatastreamListener(this);

    setOpaque(true);
    setBackground(Color.WHITE);
    setBorder(BorderFactory.createEtchedBorder());

    placeComponents();

}

From source file:Pear.java

public void init() {
    circle = new Ellipse2D.Double();
    oval = new Ellipse2D.Double();
    leaf = new Ellipse2D.Double();
    stem = new Ellipse2D.Double();
    circ = new Area(circle);
    ov = new Area(oval);
    leaf1 = new Area(leaf);
    leaf2 = new Area(leaf);
    st1 = new Area(stem);
    st2 = new Area(stem);

    setBackground(Color.white);
}

From source file:org.codehaus.mojo.dashboard.report.plugin.chart.BarChartRenderer.java

public void createChart() {
    CategoryDataset categorydataset = (CategoryDataset) this.datasetStrategy.getDataset();
    report = ChartFactory.createBarChart(this.datasetStrategy.getTitle(), this.datasetStrategy.getYAxisLabel(),
            this.datasetStrategy.getXAxisLabel(), categorydataset, PlotOrientation.HORIZONTAL, true, true,
            false);/*from ww w .j  a v  a 2s .c  o m*/
    // report.setBackgroundPaint( Color.lightGray );
    report.setPadding(new RectangleInsets(5.0d, 5.0d, 5.0d, 5.0d));
    CategoryPlot categoryplot = (CategoryPlot) report.getPlot();
    categoryplot.setBackgroundPaint(Color.white);
    categoryplot.setRangeGridlinePaint(Color.lightGray);
    categoryplot.setDomainGridlinePaint(Color.lightGray);
    categoryplot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    if (datasetStrategy instanceof CoberturaBarChartStrategy
            || datasetStrategy instanceof CloverBarChartStrategy
            || datasetStrategy instanceof MultiCloverBarChartStrategy) {
        numberaxis.setRange(0.0D, BarChartRenderer.NUMBER_AXIS_RANGE);
        numberaxis.setNumberFormatOverride(NumberFormat.getPercentInstance());
    } else {
        numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    }
    numberaxis.setLowerMargin(0.0D);
    CategoryAxis axis = categoryplot.getDomainAxis();
    axis.setLowerMargin(0.02); // two percent
    axis.setCategoryMargin(0.10); // ten percent
    axis.setUpperMargin(0.02); // two percent
    BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer();
    barrenderer.setItemMargin(0.10);
    barrenderer.setDrawBarOutline(false);
    barrenderer.setBaseItemLabelsVisible(true);
    if (datasetStrategy instanceof CoberturaBarChartStrategy
            || datasetStrategy instanceof CloverBarChartStrategy
            || datasetStrategy instanceof MultiCloverBarChartStrategy) {
        barrenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}",
                NumberFormat.getPercentInstance(Locale.getDefault())));
    } else {
        barrenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    }

    int height = (categorydataset.getColumnCount() * ChartUtils.STANDARD_BARCHART_ENTRY_HEIGHT
            * categorydataset.getRowCount());
    if (height > ChartUtils.MINIMUM_HEIGHT) {
        super.setHeight(height);
    } else {
        super.setHeight(ChartUtils.MINIMUM_HEIGHT);
    }

    Paint[] paints = this.datasetStrategy.getPaintColor();

    for (int i = 0; i < categorydataset.getRowCount() && i < paints.length; i++) {
        barrenderer.setSeriesPaint(i, paints[i]);
    }

}

From source file:com.globalsight.util.JfreeCharUtil.java

public static void drawPieChart3D(String title, Map<String, Double> datas, File OutFile) {
    PieDataset dataset = buildDatas(datas);
    JFreeChart chart = ChartFactory.createPieChart3D(title, dataset, true, true, false);
    PiePlot3D plot = (PiePlot3D) chart.getPlot();
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}={1}({2})",
            NumberFormat.getNumberInstance(), new DecimalFormat("0.00%")));
    plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0}={1}({2})"));
    chart.setBackgroundPaint(Color.white);
    plot.setForegroundAlpha(0.7f);/*from  ww w  .j av  a 2  s .c  o m*/
    plot.setCircular(true);
    TextTitle textTitle = new TextTitle(title);
    Font font = new Font(textTitle.getFont().getName(), Font.CENTER_BASELINE, 20);
    textTitle.setFont(font);
    chart.setTitle(textTitle);
    FileOutputStream fos_jpg = null;

    try {
        fos_jpg = new FileOutputStream(OutFile);
        ChartUtilities.writeChartAsJPEG(fos_jpg, 1, chart, 640, 480, null);
        fos_jpg.close();
    } catch (Exception e) {
        s_logger.error(e.getMessage(), e);
    }
}