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:diplomawork.model.JPEGSaver.java

public void saveChartToFile(JFreeChart chart, boolean trainFlag) {
    chart.setBackgroundPaint(Color.white);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.getDomainAxis().setVisible(false);
    plot.getRangeAxis().setVisible(false);
    plot.setBackgroundAlpha(0);/*from   w ww .  j  a  va2s  .c  o m*/
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setOutlinePaint(null);
    XYItemRenderer r = plot.getRenderer();

    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(false);
        renderer.setSeriesPaint(0, Color.BLACK);
    }
    plot.getRenderer().setSeriesStroke(0, new java.awt.BasicStroke(4f));
    File f = null;
    if (trainFlag) {
        nameOfJPGFile = "src/resorce/TranePlot" + trainCount++ + ".jpg";
        f = new File(nameOfJPGFile);
    } else {
        //            f = new File("src/resorce/Plot" + n++ + ".jpg");
        f = new File("src/resorce/Plot" + ".jpg");
    }

    try {
        ChartUtilities.saveChartAsJPEG(f, chart, 80, 80);
    } catch (IOException ex) {
        Logger.getLogger(JPEGSaver.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:de.fub.maps.project.plugins.tasks.eval.Barchart.java

public Barchart() {
    setLayout(new BorderLayout());
    plot = new CategoryPlot() {
        private static final long serialVersionUID = 1L;

        @Override/*w w  w  .  ja va2 s.c  o  m*/
        public LegendItemCollection getLegendItems() {

            CategoryItemRenderer renderer = getRenderer(0);
            return renderer.getLegendItems();
        }
    };
    plot.setRangeAxis(new NumberAxis());
    plot.setDomainAxis(new CategoryAxis());
    plot.getDomainAxis().setMaximumCategoryLabelLines(3);
    plot.getDomainAxis().setCategoryLabelPositionOffset(5);
    plot.setDataset(dataset);
    plot.setOrientation(PlotOrientation.VERTICAL);
    chart = new JFreeChart(null, null, plot, true);
    chart.setBackgroundPaint(Color.white);
    BarRenderer renderer = new BarRenderer();
    renderer.setBarPainter(new StandardBarPainter());
    renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    renderer.setAutoPopulateSeriesFillPaint(true);
    renderer.setAutoPopulateSeriesPaint(true);
    renderer.setShadowVisible(false);
    renderer.setSeriesToolTipGenerator(0, new StandardCategoryToolTipGenerator());
    plot.setRenderer(renderer);
    plot.setBackgroundPaint(Color.white);
    chartPanel = new ChartPanel(chart, false);
    chartPanel.setBackground(Color.white);
    add(chartPanel, BorderLayout.CENTER);
}

From source file:org.openmrs.module.vcttrac.web.view.chart.AbstractChartView.java

/**
 * @see org.springframework.web.servlet.view.AbstractView
 *//* w ww .j a v  a  2 s  .c  o m*/
@Override
@SuppressWarnings("unchecked")
protected void renderMergedOutputModel(Map model, HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    // Respond as a PNG image
    response.setContentType("image/png");

    // Disable caching
    response.setHeader("Pragma", "No-cache");
    response.setDateHeader("Expires", 0);
    response.setHeader("Cache-Control", "no-cache");

    int width = (request.getParameter("width") != null && request.getParameter("width").compareTo("") != 0)
            ? (Integer.valueOf(request.getParameter("width")))
            : 450;
    int height = (request.getParameter("height") != null && request.getParameter("height").compareTo("") != 0)
            ? (Integer.valueOf(request.getParameter("height")))
            : 350;

    JFreeChart chart = createChart(model, request);
    chart.setBackgroundPaint(Color.WHITE);
    chart.getPlot().setOutlineStroke(new BasicStroke(0));
    chart.getPlot().setOutlinePaint(getBackgroundColor());
    chart.getPlot().setBackgroundPaint(getBackgroundColor());

    chart.getPlot().setNoDataMessage(VCTTracUtil.getMessage("vcttrac.error.noDataAvailable", null));

    ChartUtilities.writeChartAsPNG(response.getOutputStream(), chart, width, height);
}

From source file:app.Histogram.java

public void histogramDesign(JFreeChart chart) {
    final CategoryPlot plot = chart.getCategoryPlot();
    final BarRenderer renderer = (BarRenderer) plot.getRenderer();

    renderer.setDrawBarOutline(false);/*from w  ww. ja v a 2 s  .c o  m*/
    renderer.setItemMargin(0.10);
    renderer.setShadowVisible(false);

    final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.black, 0.0f, 0.0f, Color.black);

    final org.jfree.chart.axis.CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setLowerMargin(0.02);
    domainAxis.setUpperMargin(0.02);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(1));

    renderer.setSeriesPaint(0, gp0);
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.black);
    plot.setRenderer(renderer);

    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(650, 500));

    JPanel panelJPanel = new JPanel();
    panelJPanel.removeAll();
    //panelJComboBox.removeAll();
    PlotWindow hist = new PlotWindow();
    hist.setVisible(true);
    // HistogtamWindow f = new HistogtamWindow();
    // HistogtamWindow f2 = f.getInstance();
    // f2.setVisible(true);
    // f2.getHistogramPanel().add(chartPanel);
    panelJPanel.add(chartPanel);
    hist.setContentPane(panelJPanel);
}

From source file:com.griddynamics.jagger.diagnostics.visualization.GraphVisualizationHelper.java

public static <V, E> Image renderGraph(Graph<V, E> graph, int width, int height, GraphLayout graphLayout,
        final ColorTheme colorTheme, final Map<V, Paint> customNodeColors) {

    Layout<V, E> layout;//  www.  j  av a 2s . co  m
    switch (graphLayout) {
    case CIRCLE:
        layout = new CircleLayout<V, E>(graph);
        break;
    case ISOM:
        layout = new ISOMLayout<V, E>(graph);
        break;
    case FR:
        layout = new FRLayout<V, E>(graph);
        break;
    case KK:
        layout = new KKLayout<V, E>(graph);
        break;
    default:
        throw new RuntimeException("Unknown Graph Layout : [" + graphLayout + "]");
    }

    layout.setSize(new Dimension((int) (width * (1 - IMAGE_HORIZONTAL_MARGIN)),
            (int) (height * (1 - IMAGE_VERTICAL_MARGIN))));

    VisualizationImageServer<V, E> server = new VisualizationImageServer<V, E>(displacementLayout(layout,
            (int) (width * IMAGE_HORIZONTAL_MARGIN / 2), (int) (height * IMAGE_VERTICAL_MARGIN / 2)),
            new Dimension(width, height));

    final Color edgeColor;
    switch (colorTheme) {
    case LIGHT:
        server.setBackground(Color.WHITE);
        edgeColor = Color.BLACK;
        break;
    case DARK:
        server.setBackground(Color.BLACK);
        edgeColor = Color.LIGHT_GRAY;
        break;
    default:
        throw new RuntimeException("Unknown Color Theme : [" + colorTheme + "]");
    }

    Transformer<V, Paint> vertexPaint = new Transformer<V, Paint>() {
        public Paint transform(V v) {
            Paint paint = customNodeColors.get(v);
            if (paint == null) {
                paint = Color.LIGHT_GRAY;
            }
            return paint;
        }
    };

    Transformer<V, Paint> vertexBorderPaint = new Transformer<V, Paint>() {
        public Paint transform(V v) {
            return Color.DARK_GRAY;
        }
    };

    Transformer<E, Paint> edgePaint = new Transformer<E, Paint>() {
        public Paint transform(E e) {
            return edgeColor;
        }
    };

    server.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
    server.getRenderContext().setEdgeDrawPaintTransformer(edgePaint);
    server.getRenderContext().setArrowDrawPaintTransformer(edgePaint);
    server.getRenderContext().setArrowFillPaintTransformer(edgePaint);

    server.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<V>());
    server.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller<E>());
    server.getRenderContext().setVertexDrawPaintTransformer(vertexBorderPaint);

    server.getRenderContext().setVertexLabelTransformer(new ChainedTransformer<V, String>(
            new Transformer[] { new ToStringLabeller<V>(), new Transformer<String, String>() {
                public String transform(String input) {
                    return "<html><center><p>" + formatLabel(input, MAX_LABEL_LENGTH);
                }
            } }));
    VertexLabelAsShapeRenderer<V, E> vlasr = new VertexLabelAsShapeRenderer<V, E>(server.getRenderContext());
    server.getRenderContext().setVertexShapeTransformer(vlasr);
    server.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);

    return server.getImage(new Point(0, 0), new Dimension(width, height));
}

From source file:it.alus.GPSreceiver.instruments.Variometer.java

public Variometer() {
    super(null);/*  ww  w  .j  a va  2s  .co m*/
    dataset = new DefaultValueDataset(0.0);
    DialPlot plot = new DialPlot();
    plot.setView(0.0, 0.0, 1.0, 1.0);
    plot.setDataset(0, dataset);
    StandardDialFrame dialFrame = new StandardDialFrame();
    dialFrame.setBackgroundPaint(Color.lightGray);
    dialFrame.setForegroundPaint(Color.gray);
    DialTextAnnotation titleLabel = new DialTextAnnotation("Vertical speed");
    titleLabel.setFont(new Font("Arial", 1, 18));
    titleLabel.setRadius(0.45D);
    titleLabel.setAngle(90);
    titleLabel.setPaint(Color.lightGray);
    plot.addLayer(titleLabel);
    DialTextAnnotation unitLabel = new DialTextAnnotation("100 Ft/min");
    unitLabel.setFont(new Font("Arial", 1, 18));
    unitLabel.setRadius(0.3D);
    unitLabel.setAngle(90);
    unitLabel.setPaint(Color.white);
    plot.addLayer(unitLabel);
    DialValueIndicator valueindicator = new DialValueIndicator(0);
    plot.addLayer(valueindicator);
    DialTextAnnotation annotation = new DialTextAnnotation("Ft/min");
    annotation.setFont(new Font("Arial", 1, 14));
    annotation.setRadius(0.4D);
    annotation.setPaint(Color.lightGray);
    plot.addLayer(annotation);
    plot.setDialFrame(dialFrame);
    StandardDialScale realScale = new StandardDialScale(-3000, 3000, -10, -340, 100, 10);
    realScale.setVisible(false);
    plot.addScale(0, realScale);
    StandardDialScale dispScale = new StandardDialScale(-30, 30, -10, -340, 5, 10);
    dispScale.setMajorTickPaint(Color.white);
    dispScale.setMinorTickPaint(Color.lightGray);
    dispScale.setFirstTickLabelVisible(true);
    dispScale.setTickRadius(0.88);
    dispScale.setTickLabelOffset(0.15);
    NumberFormat formatter = new DecimalFormat("#");
    dispScale.setTickLabelFormatter(formatter);
    dispScale.setTickLabelFont(new Font("Arial", Font.BOLD, 24));
    dispScale.setTickLabelPaint(Color.white);
    plot.addScale(1, dispScale);
    plot.setBackground(new DialBackground(Color.black));
    Pointer needle = new Pointer(0);
    needle.setFillPaint(Color.white);
    plot.addLayer(needle);
    plot.mapDatasetToScale(1, 1);
    DialCap cap = new DialCap();
    cap.setRadius(0.10);
    cap.setFillPaint(Color.gray);
    plot.setCap(cap);
    jChart = new JFreeChart(plot);
    super.setChart(jChart);
    super.setPreferredSize(new Dimension(400, 400));
}

From source file:grafix.graficos.ConstrutorGrafico.java

private void configurarGrafico(JFreeChart chart) {
    chart.removeLegend();
    chart.setBackgroundPaint(Color.white);
}

From source file:edu.ucla.stat.SOCR.chart.SuperCategoryChart_Bar.java

protected JFreeChart createLegend(CategoryDataset dataset) {

    //  JFreeChart chart = ChartFactory.createAreaChart(
    JFreeChart chart = ChartFactory.createBarChart(chartTitle, // chart title
            domainLabel, //"Category",               // domain axis label
            rangeLabel, //"Value",                  // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );//from  w w  w  .  jav a2  s  .c  o  m

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white);
    CategoryPlot plot = chart.getCategoryPlot();

    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    // renderer.setDrawOutlines(true);
    // renderer.setUseFillPaint(true);
    // renderer.setFillPaint(Color.white);
    renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());
    return chart;

}

From source file:Utils.GeneradorDeGraficas.java

public JFreeChart graficarCostos(DeterministaGeneral general, String unidad) {
    XYDataset dataset;/*ww w  .ja  v  a  2  s  .  co  m*/

    dataset = createDatasetCosto(general, unidad);

    JFreeChart chart = ChartFactory.createXYLineChart("Anlisis de Costo de Inventario por " + unidad,
            "Cantidad de pedido", "Costo", dataset, PlotOrientation.VERTICAL, true, true, false);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setSeriesPaint(4, black, true);
    renderer.setSeriesPaint(3, black, true);

    /* renderer.setShapesFilled(true);
     renderer.setShapesVisible(true);*/

    XYPlot plot2 = chart.getXYPlot();
    NumberAxis rangeAxis = (NumberAxis) plot2.getRangeAxis();
    rangeAxis.setAutoRange(false);

    rangeAxis.setUpperBound(general.calcularCostoGrafica(general.calcularCantidadOptimaOrdenar()) * 2);

    return chart;
}

From source file:es.bsc.autonomic.powermodeller.graphics.TotalPowerAndPredictionDifference.java

private static JFreeChart createChart() {
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart(NAME, "Power (Watts)", "Power (Watts)", data,
            true, true, false);//from  w w  w.j a  v  a  2s.  c o  m
    jfreechart.setBackgroundPaint(Color.white);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    XYDifferenceRenderer xydifferencerenderer = new XYDifferenceRenderer(Color.green, Color.yellow, false);
    xydifferencerenderer.setRoundXCoordinates(true);
    xyplot.setDomainCrosshairLockedOnData(true);
    xyplot.setRangeCrosshairLockedOnData(true);
    xyplot.setDomainCrosshairVisible(true);
    xyplot.setRangeCrosshairVisible(true);
    xyplot.setRenderer(xydifferencerenderer);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    DateAxis dateaxis = new DateAxis("Samples");
    dateaxis.setTickLabelsVisible(false);
    dateaxis.setLowerMargin(0.0D);
    dateaxis.setUpperMargin(0.0D);
    xyplot.setDomainAxis(dateaxis);
    xyplot.setForegroundAlpha(0.5F);
    return jfreechart;
}