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.chart.demo.WaterfallChartDemo2.java

/**
 * Returns the chart.// w  w w  .  java  2 s . c om
 *
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
private JFreeChart createChart(final CategoryDataset dataset) {

    final CategoryAxis xAxis = new CategoryAxis("Category");
    final NumberAxis yAxis = new NumberAxis("$ in Thousands");
    yAxis.setLowerMargin(0.10);
    yAxis.setUpperMargin(0.10);

    // create a custom tick unit collection...
    final DecimalFormat formatter = new DecimalFormat("##,###");
    formatter.setNegativePrefix("(");
    formatter.setNegativeSuffix(")");
    final TickUnits standardUnits = new TickUnits();
    standardUnits.add(new NumberTickUnit(200, formatter));
    standardUnits.add(new NumberTickUnit(500, formatter));
    standardUnits.add(new NumberTickUnit(1000, formatter));
    standardUnits.add(new NumberTickUnit(2000, formatter));
    standardUnits.add(new NumberTickUnit(5000, formatter));

    yAxis.setStandardTickUnits(standardUnits);

    // ****************************************************************************
    // * JFREECHART DEVELOPER GUIDE                                               *
    // * The JFreeChart Developer Guide, written by David Gilbert, is available   *
    // * to purchase from Object Refinery Limited:                                *
    // *                                                                          *
    // * http://www.object-refinery.com/jfreechart/guide.html                     *
    // *                                                                          *
    // * Sales are used to provide funding for the JFreeChart project - please    * 
    // * support us so that we can continue developing free software.             *
    // ****************************************************************************

    final DecimalFormat labelFormatter = new DecimalFormat("##,###");
    labelFormatter.setNegativePrefix("(");
    labelFormatter.setNegativeSuffix(")");

    final WaterfallBarRenderer renderer = new WaterfallBarRenderer();
    //        renderer.setLabelGenerator(
    //          new StandardCategoryLabelGenerator("{2}", labelFormatter)
    //    );
    renderer.setItemLabelsVisible(Boolean.TRUE);

    final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.white);
    plot.setRangeGridlinesVisible(true);
    final ValueMarker baseline = new ValueMarker(0.0);
    baseline.setPaint(Color.blue);
    baseline.setStroke(new BasicStroke(1.1f));
    plot.addRangeMarker(baseline, Layer.FOREGROUND);

    final JFreeChart chart = new JFreeChart("OM WaterFall Chart", JFreeChart.DEFAULT_TITLE_FONT, plot, false);
    chart.setBackgroundPaint(Color.white);
    return chart;
}

From source file:org.ietr.preesm.mapper.ui.BestCostPlotter.java

/**
 * Creates a chart.// w w w  .j a  v  a  2s . co m
 * 
 * @return A chart.
 */
private JFreeChart createChart(String title) {

    final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new DateAxis("Time"));
    this.datasets = new TimeSeriesCollection[subplotCount];

    for (int i = 0; i < subplotCount; i++) {
        this.lastValue[i] = 100.0;
        final TimeSeries series = new TimeSeries("Real Time", Millisecond.class);
        this.datasets[i] = new TimeSeriesCollection(series);
        final NumberAxis rangeAxis = new NumberAxis("Schedule");
        rangeAxis.setAutoRangeIncludesZero(false);
        final XYPlot subplot = new XYPlot(this.datasets[i], null, rangeAxis, new XYLineAndShapeRenderer());

        subplot.setBackgroundPaint(Color.white);
        subplot.setDomainGridlinePaint(Color.lightGray);
        subplot.setRangeGridlinePaint(Color.lightGray);
        plot.add(subplot);
    }

    final JFreeChart chart = new JFreeChart(title, plot);

    chart.removeLegend();
    // chart.getLegend().setPosition(RectangleEdge.BOTTOM);

    chart.setBorderPaint(Color.lightGray);
    chart.setBorderVisible(true);

    Paint p = GanttPlotter.getBackgroundColorGradient();
    chart.setBackgroundPaint(p);

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

    final ValueAxis axis = plot.getDomainAxis();
    axis.setAutoRange(true);

    return chart;

}

From source file:oct.analysis.application.OCTSelection.java

protected void drawSelectButton(Graphics g, int imageOffsetX, int imageOffsetY) {
    Polygon buttonOutline = getSelectionButtonShape();
    buttonOutline.translate(imageOffsetX, imageOffsetY);
    g.setColor(Color.lightGray);
    g.drawPolygon(buttonOutline);//from   ww w . j  a  v  a2s .c  om
    g.fillPolygon(buttonOutline);
    Polygon button = new Polygon();
    button.addPoint(imageOffsetX + xPositionOnOct - 5, imageOffsetY);
    button.addPoint(imageOffsetX + xPositionOnOct - 5, imageOffsetY + 15);
    button.addPoint(imageOffsetX + xPositionOnOct, imageOffsetY + 20);
    button.addPoint(imageOffsetX + xPositionOnOct + 5, imageOffsetY + 15);
    button.addPoint(imageOffsetX + xPositionOnOct + 5, imageOffsetY);
    g.setColor(Color.DARK_GRAY);
    g.drawPolygon(button);
}

From source file:edu.ucla.stat.SOCR.chart.demo.BarChartDemo4.java

protected JFreeChart createLegend(CategoryDataset dataset) {

    //  JFreeChart chart = ChartFactory.createAreaChart(
    JFreeChart chart = ChartFactory.createBarChart(chartTitle, // chart title
            domainLabel, // domain axis label
            rangeLabel, // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );/*  w  ww .j  a  v  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();
    GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.lightGray);
    GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.lightGray);

    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    // renderer.setDrawOutlines(true);
    // renderer.setUseFillPaint(true);
    // renderer.setFillPaint(Color.white);
    renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());
    return chart;

}

From source file:regression.gui.RegressionChart.java

/**
 * Creates a chart./*from  w  w w.  j  a v  a2  s.  c  o  m*/
 *
 * @param dataset the data for the chart.
 *
 * @return a chart.
 */
private JFreeChart createChart(final XYDataset dataset) {

    final JFreeChart chart = ChartFactory.createScatterPlot("Wykres funkcji regresji", // chart title
            "X", // x axis label
            "Y", // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );

    chart.setBackgroundPaint(Color.white);

    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesShape(0, ShapeUtilities.createRegularCross(3, 3));
    renderer.setSeriesShape(2, ShapeUtilities.createRegularCross(3, 3));
    renderer.setSeriesLinesVisible(0, false);

    renderer.setSeriesShapesVisible(1, false);
    renderer.setSeriesLinesVisible(2, false);
    plot.setRenderer(renderer);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    return chart;

}

From source file:org.micromanager.asidispim.Utils.PlotUtils.java

/**
 * Create a frame with a plot of the data given in XYSeries overwrite any
 * previously created frame with the same title
 *
        /*from  www  . j a v  a 2s . c  o  m*/
 * @param title shown in the top of the plot
 * @param data array with data series to be plotted
 * @param xTitle Title of the X axis
 * @param yTitle Title of the Y axis
 * @param showShapes whether or not to draw shapes at the data points
 * @param annotation to be shown in plot
 * @return Frame that displays the data
 */
public Frame plotDataN(String title, XYSeries[] data, String xTitle, String yTitle, boolean[] showShapes,
        String annotation) {

    // if we already have a plot open with this title, close it, but remember
    // its position
    Frame[] gfs = ChartFrame.getFrames();
    for (Frame f : gfs) {
        if (f.getTitle().equals(title)) {
            f.dispose();
        }
    }

    // JFreeChart code
    XYSeriesCollection dataset = new XYSeriesCollection();
    // calculate min and max to scale the graph
    double minX, minY, maxX, maxY;
    minX = data[0].getMinX();
    minY = data[0].getMinY();
    maxX = data[0].getMaxX();
    maxY = data[0].getMaxY();
    for (XYSeries d : data) {
        dataset.addSeries(d);
        if (d.getMinX() < minX) {
            minX = d.getMinX();
        }
        if (d.getMaxX() > maxX) {
            maxX = d.getMaxX();
        }
        if (d.getMinY() < minY) {
            minY = d.getMinY();
        }
        if (d.getMaxY() > maxY) {
            maxY = d.getMaxY();
        }
    }

    JFreeChart chart = ChartFactory.createScatterPlot(title, // Title
            xTitle, // x-axis Label
            yTitle, // y-axis Label
            dataset, // Dataset
            PlotOrientation.VERTICAL, // Plot Orientation
            false, // Show Legend
            true, // Use tooltips
            false // Configure chart to generate URLs?
    );
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.lightGray);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);

    for (int i = 0; i < data.length; i++) {
        renderer.setSeriesFillPaint(i, Color.white);
        renderer.setSeriesLinesVisible(i, true);
    }

    renderer.setSeriesPaint(0, Color.blue);
    Shape circle = new Ellipse2D.Float(-2.0f, -2.0f, 4.0f, 4.0f);
    renderer.setSeriesShape(0, circle, false);

    if (data.length > 1) {
        renderer.setSeriesPaint(1, Color.red);
        Shape square = new Rectangle2D.Float(-2.0f, -2.0f, 4.0f, 4.0f);
        renderer.setSeriesShape(1, square, false);
    }
    if (data.length > 2) {
        renderer.setSeriesPaint(2, Color.darkGray);
        Shape rect = new Rectangle2D.Float(-2.0f, -1.0f, 4.0f, 2.0f);
        renderer.setSeriesShape(2, rect, false);
    }
    if (data.length > 3) {
        renderer.setSeriesPaint(3, Color.magenta);
        Shape rect = new Rectangle2D.Float(-1.0f, -2.0f, 2.0f, 4.0f);
        renderer.setSeriesShape(3, rect, false);
    }

    for (int i = 0; i < data.length; i++) {
        if (showShapes.length > i && !showShapes[i]) {
            renderer.setSeriesShapesVisible(i, false);
        }
    }

    XYAnnotation an = new XYTextAnnotation(annotation, maxX - 0.01, maxY);
    plot.addAnnotation(an);

    renderer.setUseFillPaint(true);

    final MyChartFrame graphFrame = new MyChartFrame(title, chart);
    graphFrame.getChartPanel().setMouseWheelEnabled(true);
    graphFrame.pack();
    graphFrame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent arg0) {
            graphFrame.dispose();
        }
    });

    graphFrame.setVisible(true);

    return graphFrame;
}

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

private JFreeChart createLineChart(String title, String xLabel, String yLabel, XYDataset dataset,
        String other) {//  w  w  w  . j  a v  a2s. c  o m

    // create the chart...
    JFreeChart chart = ChartFactory.createXYLineChart(title, // chart title
            xLabel, // domain axis label
            yLabel, // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips
            false // urls
    );

    chart.setBackgroundPaint(Color.white);

    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.white);
    plot.setDomainGridlinePaint(Color.white);
    //plot.setNoDataMessage("No data available");

    // customise the range axis...

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    //rangeAxis.setAutoRange(false);   
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    // domainAxis.setAutoRange(false);   
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // customise the renderer...
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setBaseLinesVisible(false);
    renderer.setDrawOutlines(true);
    renderer.setBaseShapesFilled(true);
    renderer.setUseFillPaint(true);
    //renderer.setFillPaint(Color.white);

    if (other.toLowerCase().indexOf("noshape") != -1) {
        renderer.setBaseShapesVisible(false);
        renderer.setBaseLinesVisible(true);
    }

    if (other.toLowerCase().indexOf("excludeszero") != -1) {
        rangeAxis.setAutoRangeIncludesZero(false);
        domainAxis.setAutoRangeIncludesZero(false);
    }

    return chart;
}

From source file:de.citec.csra.allocation.vis.MovingChart.java

/**
 * Creates a sample chart.//from ww w .  j a  va  2s . co m
 *
 * @param dataset the dataset.
 *
 * @return A sample chart.
 */
private JFreeChart createChart(final XYDataset dataset) {
    final JFreeChart result = ChartFactory.createTimeSeriesChart(null, "Time", "Resource", dataset, false, true,
            false);

    final XYPlot plot = result.getXYPlot();

    plot.addDomainMarker(this.marker);
    plot.setBackgroundPaint(new Color(0xf8f8ed));
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.lightGray);

    ValueAxis xaxis = plot.getDomainAxis();
    xaxis.setAutoRange(true);
    xaxis.setTickLabelsVisible(false);
    //Domain axis would show data of 60 seconds for a time
    xaxis.setFixedAutoRange(this.past + this.future); // 60 seconds
    xaxis.setVerticalTickLabels(true);
    ValueAxis yaxis = plot.getRangeAxis();
    yaxis.setAutoRangeMinimumSize(1.8);
    yaxis.setAutoRange(true);

    NumberAxis range = (NumberAxis) plot.getRangeAxis();
    range.setTickUnit(new NumberTickUnit(1));
    range.setNumberFormatOverride(new NumberFormat() {
        @Override
        public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) {
            return format((long) number, toAppendTo, pos);
        }

        private String getID(long number) {
            return values.entrySet().stream().filter(e -> e.equals(number)).findFirst().get().getKey();
        }

        @Override
        public StringBuffer format(long number, StringBuffer ap, FieldPosition pos) {
            String id = "N/A";
            if (number == 0) {
                id = "(Time)";
            }
            if (values.containsValue(number)) {
                for (Map.Entry<String, Long> entry : values.entrySet()) {
                    if (entry.getValue() == number) {
                        id = entry.getKey();
                        break;
                    }
                }
            }
            id = id.replaceFirst("/$", "");
            ap.append(id);
            if (id.length() > 32) {
                ap.replace(15, ap.length() - 15, "..");
            }
            return ap;
        }

        @Override
        public Number parse(String source, ParsePosition parsePosition) {
            return null;
        }
    });

    //      this.chart.getXYPlot().getRenderer(1).set
    //      XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) this.chart.getXYPlot().getRendererForDataset(dataset);
    return result;
}

From source file:com.seniorproject.augmentedreality.test.AreaChartDemo.java

/**
 * Creates a chart./*  w  ww .  j a  v  a2  s  . co m*/
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
private JFreeChart createChart(final CategoryDataset dataset) {

    final JFreeChart chart = ChartFactory.createAreaChart("Area Chart", // chart title
            "Category", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

    // set the background color for the chart...
    //        final StandardLegend legend = (StandardLegend) chart.getLegend();
    //      legend.setAnchor(StandardLegend.SOUTH);

    chart.setBackgroundPaint(Color.white);
    final TextTitle subtitle = new TextTitle("An area chart demonstration.  We use this "
            + "subtitle as an example of what happens when you get a really long title or " + "subtitle.");
    subtitle.setFont(new Font("SansSerif", Font.PLAIN, 12));
    subtitle.setPosition(RectangleEdge.TOP);
    //        subtitle.setSpacer(new Spacer(Spacer.RELATIVE, 0.05, 0.05, 0.05, 0.05));
    subtitle.setVerticalAlignment(VerticalAlignment.BOTTOM);
    chart.addSubtitle(subtitle);

    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setForegroundAlpha(0.5f);

    //      plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    domainAxis.addCategoryLabelToolTip("Type 1", "The first type.");
    domainAxis.addCategoryLabelToolTip("Type 2", "The second type.");
    domainAxis.addCategoryLabelToolTip("Type 3", "The third type.");

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setLabelAngle(0 * Math.PI / 2.0);
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:org.esa.beam.visat.toolviews.diag.TileCacheMonitor.java

/**
 * Creates a new monitor panel.//from w  w  w.j  av a2s.com
 *
 * @return the monitor panel
 */
public JPanel createPanel() {

    JPanel mainPanel = new JPanel(new BorderLayout());
    CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new DateAxis("Time"));
    this.datasets = new TimeSeriesCollection[4];
    this.datasets[0] = addSubPlot(plot, "#Tiles");
    this.datasets[1] = addSubPlot(plot, "#Hits");
    this.datasets[2] = addSubPlot(plot, "#Misses");
    this.datasets[3] = addSubPlot(plot, "Mem (kB)");

    JFreeChart chart = new JFreeChart(plot);
    LegendTitle legend = (LegendTitle) chart.getSubtitle(0);
    legend.setPosition(RectangleEdge.RIGHT);
    legend.setMargin(new RectangleInsets(UnitType.ABSOLUTE, 0, 4, 0, 4));
    chart.setBorderPaint(Color.black);
    chart.setBorderVisible(true);
    chart.setBackgroundPaint(Color.white);

    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(4, 4, 4, 4));
    ValueAxis axis = plot.getDomainAxis();
    axis.setAutoRange(true);
    axis.setFixedAutoRange(60000.0); // 60 seconds

    textarea = new JTextArea();
    tableModel = new TileCacheTableModel();
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 470));
    chartPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    tabbedPane = new JTabbedPane();
    tabbedPane.add(CACHE_INFO_TAB, new JScrollPane(textarea));
    tabbedPane.add(CACHE_CHART_TAB, chartPanel);
    tabbedPane.add(IMAGES_TAB, new JScrollPane(new JTable(tableModel)));
    tabbedPane.setSelectedIndex(0);

    mainPanel.add(tabbedPane);

    return mainPanel;
}