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:edu.ucla.stat.SOCR.chart.demo.LineChartDemo1.java

/**
 * Creates a sample chart.// w w  w .ja  v a2s.co  m
 * 
 * @param dataset  a dataset.
 * 
 * @return The chart.
 */
protected JFreeChart createChart(CategoryDataset dataset) {
    if (isDemo) {
        chartTitle = "Java Standard Class Library";
        domainLabel = "Release";
        rangeLabel = "Class Count";
    } else
        chartTitle = "Line Chart";

    // create the chart...
    JFreeChart chart = ChartFactory.createLineChart(chartTitle, // chart title
            domainLabel, // domain axis label
            rangeLabel, // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            !legendPanelOn, // include legend
            true, // tooltips
            false // urls
    );

    if (isDemo) {
        chart.addSubtitle(new TextTitle("Number of Classes By Release"));
        TextTitle source = new TextTitle(
                "Source: Java In A Nutshell (4th Edition) " + "by David Flanagan (O'Reilly)");
        source.setFont(new Font("SansSerif", Font.PLAIN, 10));
        source.setPosition(RectangleEdge.BOTTOM);
        source.setHorizontalAlignment(HorizontalAlignment.RIGHT);
        chart.addSubtitle(source);
    } else {
        chart.clearSubtitles();
    }

    chart.setBackgroundPaint(Color.white);

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.white);

    // customise the range axis...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // customise the renderer...
    LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setDrawOutlines(true);
    renderer.setUseFillPaint(true);
    renderer.setBaseFillPaint(Color.white);
    renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());

    setCategorySummary(dataset);
    return chart;
}

From source file:j2se.jfreechart.barchart.BarChartDemo8.java

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

    // create the chart...
    final JFreeChart chart = ChartFactory.createBarChart("Bar Chart Demo 8", // chart title
            "Category", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips?
            false // URLs?
    );

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

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    // set the range axis to display integers only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setUpperMargin(0.15);

    // disable bar outlines...
    final CategoryItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesItemLabelsVisible(0, Boolean.TRUE);

    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);

    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:net.imglib2.script.analysis.Histogram.java

static private final void setTheme(final JFreeChart chart) {
    XYPlot plot = (XYPlot) chart.getPlot();
    XYBarRenderer r = (XYBarRenderer) plot.getRenderer();
    StandardXYBarPainter bp = new StandardXYBarPainter();
    r.setBarPainter(bp);//  www .ja  va 2s  .  c o m
    r.setSeriesOutlinePaint(0, Color.lightGray);
    r.setShadowVisible(false);
    r.setDrawBarOutline(false);
    setBackgroundDefault(chart);
}

From source file:com.joey.software.memoryToolkit.MemoryUsagePanel.java

/**
 * Creates a new application./*from   w w  w  .  j  a v  a2  s .  c  o m*/
 * 
 * @param historyCount
 *            the history count (in milliseconds).
 */
public MemoryUsagePanel(int historyCount, int interval) {
    super(new BorderLayout());
    // create two series that automatically discard data more than 30
    // seconds old...
    this.total = new TimeSeries("Total Memory", Millisecond.class);
    this.total.setMaximumItemCount(historyCount);
    this.free = new TimeSeries("Free Memory", Millisecond.class);
    this.free.setMaximumItemCount(historyCount);
    this.used = new TimeSeries("Used Memory", Millisecond.class);
    this.used.setMaximumItemCount(historyCount);
    this.max = new TimeSeries("Used Memory", Millisecond.class);
    this.max.setMaximumItemCount(historyCount);
    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(this.total);
    dataset.addSeries(this.free);
    dataset.addSeries(this.used);
    dataset.addSeries(this.max);

    DateAxis domain = new DateAxis("Time");
    NumberAxis range = new NumberAxis("Memory");

    domain.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    range.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    domain.setLabelFont(new Font("SansSerif", Font.PLAIN, 14));

    range.setLabelFont(new Font("SansSerif", Font.PLAIN, 14));
    XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false);
    renderer.setSeriesPaint(0, Color.red);
    renderer.setSeriesPaint(1, Color.green);
    renderer.setSeriesPaint(2, Color.black);

    renderer.setStroke(new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
    XYPlot plot = new XYPlot(dataset, domain, range, renderer);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    domain.setAutoRange(true);
    domain.setLowerMargin(0.0);
    domain.setUpperMargin(0.0);
    domain.setTickLabelsVisible(true);
    range.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    JFreeChart chart = new JFreeChart("JVM Memory Usage", new Font("SansSerif", Font.BOLD, 24), plot, true);
    chart.setBackgroundPaint(Color.white);
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4),
            BorderFactory.createLineBorder(Color.black)));
    add(chartPanel);

    gen = new DataGenerator(interval);

}

From source file:de.naoth.xabsleditor.graphpanel.OptionVisualizer.java

/** (Re-) set to a new graph and display it */
private void doSetGraph(Graph<XabslNode, XabslEdge> g) {
    if (g == null) {
        return;//from  ww w. j a  va 2s. c o  m
    }

    lastX = 0.0;
    lastY = 0.0;
    nodeCounter = 0;

    final int w = Math.max(400, this.getSize().width);
    final int h = Math.max(400, this.getSize().height);

    KKLayout<XabslNode, XabslEdge> layout = new KKLayout<XabslNode, XabslEdge>(g);
    final double nodesPerRow = Math.sqrt(g.getVertexCount());

    layout.setMaxIterations(500);
    layout.setInitializer(new Transformer<XabslNode, Point2D>() {

        @Override
        public Point2D transform(XabslNode n) {
            lastX += (w / nodesPerRow);
            nodeCounter++;
            if (nodeCounter % ((int) nodesPerRow) == 0) {
                lastX = 0;
                lastY += (h / nodesPerRow);
            }
            return new Point2D.Double(lastX, lastY);
        }
    });

    layout.setSize(new Dimension(w, h));

    if (scrollPane != null) {
        remove(scrollPane);
        scrollPane = null;
    }

    vv = new VisualizationViewer<XabslNode, XabslEdge>(layout);

    // zooming and selecting
    DefaultModalGraphMouse<XabslNode, XabslEdge> mouse = new DefaultModalGraphMouse<XabslNode, XabslEdge>();
    vv.setGraphMouse(mouse);
    vv.addKeyListener(mouse.getModeKeyListener());

    // enable selecting the nodes
    mouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);

    // add external mouse listener
    if (externalMouseListener != null) {
        vv.addGraphMouseListener(externalMouseListener);
    }

    // determine the shape of the nodes
    vv.getRenderContext().setVertexShapeTransformer(new VertexTransformer());

    // white background for nodes
    vv.getRenderContext().setVertexFillPaintTransformer(new Transformer<XabslNode, Paint>() {

        @Override
        public Paint transform(XabslNode n) {
            if (n.getType() == XabslNode.Type.Option) {
                return Color.lightGray;
            } else {
                return Color.white;
            }
        }
    });

    // howto render the edges (depending whether commond decision or not)
    vv.getRenderContext().setEdgeStrokeTransformer(new Transformer<XabslEdge, Stroke>() {

        @Override
        public Stroke transform(XabslEdge e) {
            if (e.getType() == XabslEdge.Type.CommonDecision) {
                return vv.getRenderContext().DASHED;
            } else {
                return new BasicStroke();
            }
        }
    });
    vv.getRenderContext().setEdgeDrawPaintTransformer(new Transformer<XabslEdge, Paint>() {

        @Override
        public Paint transform(XabslEdge e) {
            if (e.getType() == XabslEdge.Type.CommonDecision || e.getType() == XabslEdge.Type.Outgoing) {
                return Color.gray;
            } else {
                return Color.black;
            }
        }
    });

    // use toString() to draw label and do some extra transformations (splitting at "_")
    vv.getRenderContext().setVertexLabelTransformer(new ChainedTransformer<XabslNode, String>(
            new Transformer[] { new ToStringLabeller<XabslNode>(), new Transformer<String, String>() {

                @Override
                public String transform(String s) {
                    return "<html><center>" + s.replaceAll("_", "_<br>") + "</center></html>";
                }
            } }));

    // label is placed in the center of the node
    vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);

    // add to a zoomable container
    scrollPane = new GraphZoomScrollPane(vv);
    scrollPane.setComponentPopupMenu(pmMain);
    vv.setComponentPopupMenu(pmMain);
    add(scrollPane, BorderLayout.CENTER);
    validate();
}

From source file:playground.dgrether.signalsystems.utils.DgSignalPlanChart.java

public JFreeChart createSignalPlanChart(String title, String xAxisTitle, String yAxisTitle) {
    JFreeChart chart = ChartFactory.createStackedBarChart(title, xAxisTitle, yAxisTitle, this.dataset,
            PlotOrientation.HORIZONTAL, false, false, false);
    DgDefaultAxisBuilder axis = new DgDefaultAxisBuilder();
    CategoryPlot plot = chart.getCategoryPlot();

    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.black);
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    CategoryAxis xAxis = axis.createCategoryAxis(xAxisTitle);
    plot.setDomainAxis(xAxis);//from   ww  w. j  a  v a2s  .  c  om
    ValueAxis yAxis = axis.createValueAxis(yAxisTitle);
    yAxis.setUpperBound(this.tMax);
    yAxis.setLowerBound(this.tMin);
    plot.setRangeAxis(yAxis);

    final BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.findRangeBounds(dataset);
    renderer.setShadowVisible(false);
    //      renderer.setItemMargin(10.005);
    renderer.setMaximumBarWidth(0.2);
    for (Entry<Integer, Color> ee : seriesColor.entrySet()) {
        renderer.setSeriesPaint(ee.getKey(), ee.getValue());
        //         renderer.setSeriesStroke(ee.getKey(), new BasicStroke(50));
    }
    plot.setRenderer(renderer);
    //      chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    //      chart.setBackgroundPaint(ChartColor.WHITE);
    //      chart.removeLegend();
    return chart;
}

From source file:com.github.dougkelly88.FLIMPlateReaderGUI.FLIMClasses.Classes.FindMaxpoint.java

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

    //http://www.java2s.com/Code/Java/Chart/JFreeChartDualAxisDemo2.htm
    String xlabel = "Delay (ps)";
    String ylabel = "Signal (DN)";

    // create the chart with findmaxpoint results
    final JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title
            xlabel, // x axis label
            ylabel, // y axis label
            findMaxpointData_, // data
            PlotOrientation.VERTICAL, false, // include legend
            true, // tooltips
            false // urls
    );

    final XYPlot plot = chart.getXYPlot();
    // deal with axes and add second dataset
    final NumberAxis yaxis1 = (NumberAxis) plot.getRangeAxis();
    yaxis1.setTickLabelFont(new Font("Dialog", Font.PLAIN, 10));
    yaxis1.setLabelFont(new Font("Dialog", Font.PLAIN, 10));
    final NumberAxis yaxis2 = new NumberAxis(null);
    final NumberAxis xaxis = (NumberAxis) plot.getDomainAxis();
    xaxis.setTickLabelFont(new Font("Dialog", Font.PLAIN, 10));
    xaxis.setLabelFont(new Font("Dialog", Font.PLAIN, 10));
    plot.setRangeAxis(1, yaxis2);
    plot.setDataset(1, gatePositionData_);
    plot.mapDatasetToRangeAxis(1, 1);
    yaxis1.setRange(0, 5000);
    yaxis2.setRange(-1, 1);
    yaxis2.setTickLabelsVisible(false);
    xaxis.setRange(0, 16666);

    // deal with visuals

    final XYLineAndShapeRenderer renderer1 = new XYLineAndShapeRenderer(true, true);
    renderer1.setSeriesPaint(0, Color.RED);
    renderer1.setSeriesStroke(0, new BasicStroke(3));

    //        renderer1.setBaseShapesVisible(true);
    //        renderer1.setSeriesShape(0, ShapeUtilities.createDiagonalCross(4,1));

    plot.setRenderer(0, renderer1);

    //        final StandardXYItemRenderer renderer2 = new StandardXYItemRenderer();
    final XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(false, true);
    renderer2.setSeriesPaint(0, Color.CYAN);
    renderer2.setSeriesShapesFilled(0, Boolean.TRUE);
    renderer2.setBaseShapesVisible(true);
    renderer2.setShape(new Rectangle(-2, -100, 4, 200));
    renderer2.setOutlineStroke(new BasicStroke(1));
    renderer2.setOutlinePaint(Color.GRAY);
    renderer2.setUseOutlinePaint(true);
    plot.setRenderer(1, renderer2);

    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);
    //                
    return chart;

}

From source file:org.hxzon.demo.jfreechart.XYDatasetDemo.java

private static JFreeChart createTimeSeriesChart(XYDataset dataset) {

    JFreeChart chart = ChartFactory.createTimeSeriesChart("Legal & General Unit Trust Prices", // title
            "Date", // x-axis label
            "Price Per Unit", // y-axis label
            dataset, // data
            true, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );//w  w w. j  a v a  2s .  co 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);

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

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

    return chart;
}

From source file:edu.ucsf.valelab.spotintensityanalysis.plot.PlotUtils.java

/**
 * Create a frame with a plot of the data given in XYSeries overwrite any
 * previously created frame with the same title
 *
        //from  ww w.  j a v  a 2 s .co  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) {

    // 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
            true, // 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);
        }
    }

    // place annotation at 80 % of max X, maxY
    XYAnnotation an = new XYTextAnnotation(annotation, maxX - 0.2 * (maxX - minX), maxY);
    plot.addAnnotation(an);

    renderer.setUseFillPaint(true);

    if (graphFrame_ == null)
        graphFrame_ = new MyChartFrame(title, chart);
    else
        graphFrame_.getChartPanel().setChart(chart);
    graphFrame_.getChartPanel().setMouseWheelEnabled(true);
    graphFrame_.pack();
    final MyChartFrame privateFrame = graphFrame_;
    graphFrame_.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent arg0) {
            privateFrame.dispose();
        }
    });

    graphFrame_.setVisible(true);

    return graphFrame_;
}

From source file:required.ChartPlotter.java

/**
 * Creates a chart./*  w  w  w . java 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.createXYLineChart("Zipf's LAW", // chart title
            "frequency", // x axis label
            "words", // 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);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesShapesVisible(1, false);
    plot.setRenderer(renderer);

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

    return chart;

}