Example usage for java.awt Color lightGray

List of usage examples for java.awt Color lightGray

Introduction

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

Prototype

Color lightGray

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

Click Source Link

Document

The color light gray.

Usage

From source file:org.jfree.experimental.chart.demo.XYTitleAnnotationDemo1.java

/**
 * Creates a chart./*w ww.j a v a  2s  .  c  om*/
 * 
 * @param dataset  a dataset.
 * 
 * @return A chart.
 */
private static JFreeChart createChart(XYDataset dataset) {

    JFreeChart chart = ChartFactory.createTimeSeriesChart("Legal & General Unit Trust Prices", // title
            "Date", // x-axis label
            "Price Per Unit", // y-axis label
            dataset, // data
            false, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );

    chart.setBackgroundPaint(Color.white);

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

    LegendTitle lt = new LegendTitle(plot);
    lt.setItemFont(new Font("Dialog", Font.PLAIN, 9));
    lt.setBackgroundPaint(new Color(200, 200, 255, 100));
    lt.setFrame(new BlockBorder(Color.white));
    lt.setPosition(RectangleEdge.BOTTOM);
    XYTitleAnnotation ta = new XYTitleAnnotation(0.98, 0.02, lt, RectangleAnchor.BOTTOM_RIGHT);

    ta.setMaxWidth(0.48);
    plot.addAnnotation(ta);

    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);
    }

    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));

    ValueAxis yAxis = plot.getRangeAxis();
    yAxis.setLowerMargin(0.35);
    return chart;

}

From source file:org.jtotus.gui.graph.GraphPrinter.java

private JFreeChart createChart(String title) {

    // valueAxis.setAutoRangeMinimumSize(1);
    DateAxis domain = new DateAxis("Date");
    domain.setDateFormatOverride(new SimpleDateFormat("dd-MM-yyyy"));

    mainPlot = new CombinedDomainXYPlot(domain);
    mainPlot.setGap(4.0);/*from  ww w.ja v  a2s.c o  m*/
    //mainPlot.setOrientation(PlotOrientation.HORIZONTAL);
    mainPlot.setBackgroundPaint(Color.lightGray);
    mainPlot.setRangePannable(true);
    mainPlot.setDomainGridlinesVisible(true);
    mainPlot.setOutlineVisible(true);
    mainPlot.setDomainCrosshairVisible(true);
    mainPlot.setRangeMinorGridlinesVisible(true);

    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, mainPlot, true);

    chart.setBackgroundPaint(Color.white);

    return chart;

}

From source file:ws.moor.bt.gui.charts.ConnectionTypes.java

private JFreeChart createChart(XYDataset dataset) {
    JFreeChart chart = ChartFactory.createTimeSeriesChart("Connection Types", "Time", "Connections", dataset,
            true, false, false);/*from ww w .  j  a v  a2  s. c  o m*/
    chart.setBackgroundPaint(Color.white);

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

    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss"));

    return chart;
}

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

/**
 * Creates a new demo./*  w w  w . j a  va2  s.  co m*/
 *
 * @param title  the frame title.
 */
public ThermometerDemo2(final String title) {

    super(title);

    // create a dataset...
    final DefaultValueDataset dataset = new DefaultValueDataset(new Double(43.0));

    // create the chart...
    final ThermometerPlot plot = new ThermometerPlot(dataset);
    final JFreeChart chart = new JFreeChart("Thermometer Demo 2", // chart title
            JFreeChart.DEFAULT_TITLE_FONT, plot, // plot
            false); // include legend

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    //    plot.setInsets(new Insets(5, 5, 5, 5));
    //plot.setRangeInfo(ThermometerPlot.NORMAL, 0.0, 55.0, 0.0, 100.0);
    //plot.setRangeInfo(ThermometerPlot.WARNING, 55.0, 75.0, 0.0, 100.0);
    //plot.setRangeInfo(ThermometerPlot.CRITICAL, 75.0, 100.0, 0.0, 100.0);

    plot.setThermometerStroke(new BasicStroke(2.0f));
    plot.setThermometerPaint(Color.lightGray);
    // OPTIONAL CUSTOMISATION COMPLETED.

    // add the chart to a panel...
    final ChartPanel chartPanel = new ChartPanel(chart);
    setContentPane(chartPanel);

}

From source file:ui.FitnessGraph.java

/**
 * Creates a chart.//from   ww w.  j a va 2 s.  co  m
 *
 * @param dataset
 *            the data for the chart.
 *
 * @return a chart.
 */
private JFreeChart createChart(final XYDataset dataset) {

    // create the chart...
    final JFreeChart chart = ChartFactory.createScatterPlot("Fitness v generation", // chart title
            "X", // x axis label
            "Y", // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );

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

    // final StandardLegend legend = (StandardLegend) chart.getLegend();
    // legend.setDisplaySeriesShapes(true);
    // get a reference to the plot for further customisation...
    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    // renderer.setSeriesShape(0, new Ellipse2D.Float(1.0f, 1.0f, 1.0f,
    // 1.0f));
    renderer.setSeriesPaint(0, Color.RED);
    renderer.setSeriesLinesVisible(0, true);
    renderer.setSeriesShapesVisible(0, false);
    // renderer.setSeriesStroke(1, new BasicStroke(0.01f));
    plot.setRenderer(renderer);

    // change the auto tick unit selection to integer units only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    // rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setAutoRange(true);
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:agentlogfileanalyzer.gui.ComparisonFrame.java

/**
 * Creates a chart frame for comparing a selected classifier to a set of
 * other classifiers.//from   w  ww  .  ja  va  2  s .c  o m
 * 
 * @param firstTitle
 *            the first line of the chart title
 * @param secondTitle
 *            the second line of the chart title
 * @param compDataForColumns
 *            the data the will be displayed in the chart
 */
public ComparisonFrame(String firstTitle, String secondTitle, Vector<ComparisonDataSet> compDataForColumns) {

    super("Classifier comparison");

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (int i = 0; i < compDataForColumns.size(); i++) {
        ComparisonDataSet mms = compDataForColumns.get(i);
        dataset.addValue(mms.getMax(), "max", mms.getColumnName());
        dataset.addValue(mms.getMin(), "min", mms.getColumnName());
        dataset.addValue(mms.getSelected(), "selected", mms.getColumnName());
    }

    JFreeChart jfreechart = ChartFactory.createBarChart("", // title
            "", // x-axis title
            "", // y-axis title
            dataset, PlotOrientation.VERTICAL, true, true, false);
    TextTitle subtitle1 = new TextTitle(firstTitle, new Font("SansSerif", Font.BOLD, 12));
    TextTitle subtitle2 = new TextTitle(secondTitle, new Font("SansSerif", Font.BOLD, 12));
    jfreechart.addSubtitle(0, subtitle1);
    jfreechart.addSubtitle(1, subtitle2);
    jfreechart.setBackgroundPaint(Color.white);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setRangeGridlinePaint(Color.white);
    MinMaxCategoryRenderer minmaxcategoryrenderer = new MinMaxCategoryRenderer();
    categoryplot.setRenderer(minmaxcategoryrenderer);
    ChartPanel chartpanel = new ChartPanel(jfreechart);
    chartpanel.setPreferredSize(new Dimension(500, 270));
    setContentPane(chartpanel);
}

From source file:Demo.LineGraph.java

private void InitChart() {
    JFreeChart chart = ChartFactory.createLineChart("Yield", "sample NB", "Probability", dataSet,
            PlotOrientation.VERTICAL, false, false, false);

    CategoryPlot plot = chart.getCategoryPlot();

    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);

    plot.setDomainGridlinesVisible(true);
    plot.setNoDataMessage("no data");

    LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();

    renderer.setBaseItemLabelsVisible(true);
    renderer.setSeriesPaint(0, Color.BLUE);

    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);//from www.j  a  v a  2s.  com

    renderer.setBaseItemLabelsVisible(true);
    renderer.setBasePositiveItemLabelPosition(
            new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    renderer.setBaseItemLabelFont(new Font("Times New Romain", 0, 10));
    plot.setRenderer(renderer);

    CategoryAxis axis = plot.getDomainAxis();
    axis.setCategoryLabelPositions(CategoryLabelPositions.createDownRotationLabelPositions(Math.PI / 6.0));

    chartPane = new ChartPanel(chart);
}

From source file:gavisualizer.LineChart.java

@Override
public void generate() {
    // Creates Line Chart from variables
    JFreeChart chart = ChartFactory.createLineChart(_title, // chart title
            _axisLabelDomain, // domain axis label
            _axisLabelRange, // range axis label
            _dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            false, // tooltips
            false // urls
    );//from w  ww .  j a v a2 s  . c  om

    // Set the Plot to certain colors
    final CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.lightGray);
    plot.setOutlinePaint(Color.white);

    // Set Legend to the right of the chart
    final LegendTitle lt = (LegendTitle) chart.getLegend();
    lt.setPosition(RectangleEdge.RIGHT);

    // Set paints for lines in the chart
    LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    DefaultDrawingSupplier dw = new DefaultDrawingSupplier(PAINTS,
            DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE);
    plot.setDrawingSupplier(dw);

    // Customize stroke width of the series
    ((AbstractRenderer) renderer).setAutoPopulateSeriesStroke(false);
    renderer.setBaseStroke(STROKE_WIDTH);
    renderer.setBaseShapesVisible(false);

    // Include dashed lines if necessary
    List<String> rows = _dataset.getRowKeys();

    // See if the title includes Downloads (Dashed lines are for Download lines)
    if (rows.get(rows.size() - 1).endsWith("Downloads")) {
        // Set the start to half the rows
        int start = _dataset.getRowCount() / 2;

        // Create an initial value
        int init = 0;

        // Iterate through the Download lines
        while (start < _dataset.getRowCount()) {
            // Make sure series and legend have dashes
            renderer.setSeriesStroke(start, DASHED_STROKE);
            LegendItemCollection legend = renderer.getLegendItems();
            LegendItem li = legend.get(start - 1);
            li.setLineStroke(DASHED_STROKE);

            // Make sure the color matches the undashed year
            renderer.setSeriesPaint(start, renderer.getItemPaint(init, 0));
            init++;
            start++;
        }
    }

    // Customise the range axis...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setAutoRangeIncludesZero(true);

    _chart = chart;
}

From source file:eu.choreos.vv.chart.XYChart.java

private static JFreeChart createChart(XYDataset dataset, String chartTitle, String xLabel, String yLabel) {

    // create the chart...
    JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title
            xLabel, // domain axis label
            yLabel, // range axis label
            dataset, // initial series
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );//from  ww w . j ava 2 s. com

    // set chart background
    chart.setBackgroundPaint(Color.white);

    // set a few custom plot features
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(new Color(0xffffe0));
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);

    // set the plot's axes to display integers
    TickUnitSource ticks = NumberAxis.createIntegerTickUnits();
    NumberAxis domain = (NumberAxis) plot.getDomainAxis();
    domain.setStandardTickUnits(ticks);
    domain.resizeRange(1.1);
    domain.setLowerBound(0.5);

    NumberAxis range = (NumberAxis) plot.getRangeAxis();
    range.setStandardTickUnits(ticks);
    range.setUpperBound(range.getUpperBound() * 1.1);

    // render shapes and lines
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, true);
    plot.setRenderer(renderer);
    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);

    // set the renderer's stroke
    Stroke stroke = new BasicStroke(3f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL);
    renderer.setBaseOutlineStroke(stroke);

    // label the points
    NumberFormat format = NumberFormat.getNumberInstance();
    format.setMaximumFractionDigits(2);
    XYItemLabelGenerator generator = new StandardXYItemLabelGenerator(
            StandardXYItemLabelGenerator.DEFAULT_ITEM_LABEL_FORMAT, format, format);
    renderer.setBaseItemLabelGenerator(generator);
    renderer.setBaseItemLabelsVisible(true);

    return chart;
}

From source file:com.bitplan.vzjava.Plot.java

/**
 * Creates a chart.//from  ww w.  jav  a2  s  .  c o  m
 * 
 * @param dataset
 *          a dataset.
 * 
 * @return A chart.
 */
private JFreeChart createChart(final ColoredDataSet cdataset) {

    final JFreeChart chart = ChartFactory.createTimeSeriesChart(title, "Time", "Power", cdataset.dataSet, true,
            true, false);

    chart.setBackgroundPaint(Color.white);

    // final StandardLegend sl = (StandardLegend) chart.getLegend();
    // sl.setDisplaySeriesShapes(true);

    final XYPlot plot = chart.getXYPlot();
    // plot.setOutlinePaint(null);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(false);

    final XYItemRenderer renderer = plot.getRenderer();
    if (renderer instanceof StandardXYItemRenderer) {
        renderer.setSeriesStroke(0, new BasicStroke(3.0f));
        renderer.setSeriesStroke(1, new BasicStroke(3.0f));
    }

    final DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("HH:mm"));

    // http://www.jfree.org/jfreechart/api/gjdoc/org/jfree/chart/plot/DefaultDrawingSupplier-source.html
    DrawingSupplier supplier = new DefaultDrawingSupplier(cdataset.paintSequence,
            DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE);
    chart.getPlot().setDrawingSupplier(supplier);
    return chart;
}