Example usage for org.jfree.chart.plot XYPlot setDomainGridlinePaint

List of usage examples for org.jfree.chart.plot XYPlot setDomainGridlinePaint

Introduction

In this page you can find the example usage for org.jfree.chart.plot XYPlot setDomainGridlinePaint.

Prototype

public void setDomainGridlinePaint(Paint paint) 

Source Link

Document

Sets the paint for the grid lines plotted against the domain axis, and sends a PlotChangeEvent to all registered listeners.

Usage

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 w w  w.  ja  v  a2  s  . 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);

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

    return chart;
}

From source file:ws.moor.bt.grapher.ChartBuilder.java

public JFreeChart getChart() {
    JFreeChart chart = ChartFactory.createTimeSeriesChart(chartName, timeAxisLabel, valueAxisLabel, timeSeries,
            showLegend && (timeSeries.getSeriesCount() > 1), false, false);
    chart.setBackgroundPaint(Color.white);

    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    plot.getRenderer().setSeriesPaint(0, Color.black);
    plot.getRenderer().setSeriesStroke(0, new BasicStroke(1.0f));
    plot.getRenderer().setSeriesPaint(1, Color.black);
    plot.getRenderer().setSeriesStroke(1, new BasicStroke(2.0f));
    plot.getRenderer().setSeriesPaint(2, Color.black);
    plot.getRenderer().setSeriesStroke(2, new BasicStroke(0.1f));

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

    return chart;
}

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

private JFreeChart createChart(XYDataset dataset) {
    JFreeChart chart = ChartFactory.createTimeSeriesChart("Pieces", "Time", "Pieces", dataset, true, false,
            false);//from   w  w w  . j av a2  s.  com
    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:support.SystemMonitorGui.java

private XYPlot createChartFrame(XYSeries series) {
    XYSeriesCollection dataSet = new XYSeriesCollection();
    dataSet.addSeries(series);//from   ww w.  ja v a  2 s  .  c om
    JFreeChart chart = ChartFactory.createXYLineChart("Memory Allocation Rate", "Time (ms)",
            "Allocation Rate (MB/s)", dataSet, PlotOrientation.VERTICAL, true, true, false);
    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.DARK_GRAY);
    plot.setRangeGridlinePaint(Color.DARK_GRAY);
    plot.getRenderer().setSeriesPaint(0, Color.BLUE);

    JFrame frame = new JFrame();
    frame.setBackground(Color.WHITE);
    frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
    frame.setTitle("Hazelcast Jet Source Builder Sample");
    frame.setBounds(WINDOW_X, WINDOW_Y, WINDOW_WIDTH, WINDOW_HEIGHT);
    frame.setLayout(new BorderLayout());
    frame.add(new ChartPanel(chart));
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent windowEvent) {
            hzMap.removeEntryListener(entryListenerId);
        }
    });
    frame.setVisible(true);
    return plot;
}

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

private JFreeChart createChart(XYDataset dataset) {
    JFreeChart chart = ChartFactory.createTimeSeriesChart("Open Connections", "Time", "Connections", dataset,
            true, false, false);/*  w w  w  .j av a  2 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:com.waitwha.nessus.trendanalyzer.gui.TimeChartPanel.java

/**
 * Constructor//  w  w  w .jav a2s . c  om
 *
 * @param title            String title of the chart.
 * @param xaxisLabel   String x-axis label of the chart.
 * @param yaxisLabel   String y-axis label of the chart (time).
 * @param dataset         XYDataset to use within the chart.
 */
public TimeChartPanel(String title, String xaxisLabel, String yaxisLabel, XYDataset dataset) {
    super(new BorderLayout());
    JFreeChart chart = ChartFactory.createTimeSeriesChart(title, xaxisLabel, yaxisLabel, dataset, true, // 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);

    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("yyyy-MM-dd HH:mm"));

    ChartPanel panel = new ChartPanel(chart);
    panel.setMouseWheelEnabled(true);
    this.add(panel, BorderLayout.CENTER);
    this.validate();
}

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

private JFreeChart createChart(XYDataset dataset) {
    JFreeChart chart = ChartFactory.createTimeSeriesChart("Downloaded Blocks", "Time", "Blocks", dataset, true,
            false, false);/*w  w  w . j a  v  a 2 s  .c  om*/
    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:osh.comdriver.simulation.cruisecontrol.ScheduleDrawer.java

/**
 * Creates a chart./*from w  w  w  . j a v a 2 s . c  om*/
 *
 * @param dataset1  a dataset.
 * @return A chart.
 */
private static JFreeChart createChart(XYDataset dataset1, //power
        XYDataset dataset2, //costs
        XYDataset dataset3, long time) {

    JFreeChart chart = ChartFactory.createTimeSeriesChart("schedule", // title
            "time", // x-axis label
            "power", // y-axis label
            dataset1, // data
            true, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );

    chart.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) chart.getPlot();

    NumberAxis axis1 = new NumberAxis("power");
    NumberAxis axis2 = new NumberAxis("costs");
    axis1.setAutoRangeIncludesZero(true);
    axis1.setUpperBound(5000);
    axis1.setLowerBound(-5000);
    axis2.setAutoRangeIncludesZero(true);
    axis2.setUpperBound(50);
    axis2.setLowerBound(0);
    plot.setRangeAxis(0, axis1);
    plot.setRangeAxis(1, axis2);

    plot.setDataset(1, dataset2);
    plot.mapDatasetToRangeAxis(1, 1);

    plot.setDataset(2, dataset3);
    plot.mapDatasetToRangeAxis(2, 0);

    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);
    //TODO: SHADOWS OFF

    final StandardXYItemRenderer r1 = new StandardXYItemRenderer();
    final StandardXYItemRenderer r2 = new StandardXYItemRenderer();
    final StandardXYItemRenderer r3 = new StandardXYItemRenderer();
    final StandardXYItemRenderer r4 = new StandardXYItemRenderer();
    plot.setRenderer(0, r1);
    plot.setRenderer(1, r2);
    plot.setRenderer(2, r3);
    plot.setRenderer(3, r4);

    int numberOfSeries = 0;
    numberOfSeries += dataset1.getSeriesCount();
    numberOfSeries += dataset2.getSeriesCount();
    numberOfSeries += dataset3.getSeriesCount();

    Color[] color = new Color[numberOfSeries];

    for (int i = 0; i < numberOfSeries / 2; i++) {
        color[i] = Color.getHSBColor(i * 1.0f / (numberOfSeries / 2), 1.0f, 1.0f);
    }

    int i = 0;

    for (int j = 0; j < dataset1.getSeriesCount() / 2; j++) {
        float[] rgbcolor = Color.RGBtoHSB(color[i].getRed(), color[i].getGreen(), color[i].getBlue(), null);
        plot.getRendererForDataset(dataset1).setSeriesPaint(2 * j, Color.getHSBColor(rgbcolor[0], 1.0f, 1.0f));
        plot.getRendererForDataset(dataset1).setSeriesPaint(2 * j + 1,
                Color.getHSBColor(rgbcolor[0], 1.0f, 0.6f));
        i++;
    }
    for (int j = 0; j < dataset2.getSeriesCount() / 2; j++) {
        float[] rgbcolor = Color.RGBtoHSB(color[i].getRed(), color[i].getGreen(), color[i].getBlue(), null);
        plot.getRendererForDataset(dataset2).setSeriesPaint(2 * j, Color.getHSBColor(rgbcolor[0], 1.0f, 1.0f));
        plot.getRendererForDataset(dataset2).setSeriesPaint(2 * j + 1,
                Color.getHSBColor(rgbcolor[0], 1.0f, 0.6f));
        i++;
    }
    for (int j = 0; j < dataset3.getSeriesCount() / 2; j++) {
        float[] rgbcolor = Color.RGBtoHSB(color[i].getRed(), color[i].getGreen(), color[i].getBlue(), null);
        plot.getRendererForDataset(dataset3).setSeriesPaint(2 * j, Color.getHSBColor(rgbcolor[0], 1.0f, 1.0f));
        plot.getRendererForDataset(dataset3).setSeriesPaint(2 * j + 1,
                Color.getHSBColor(rgbcolor[0], 1.0f, 0.6f));
        i++;
    }

    // NOW line
    double upperBound = plot.getRangeAxis(1).getUpperBound();
    double lowerBound = plot.getRangeAxis(1).getLowerBound();

    XYSeries nowLine = new XYSeries("now");
    nowLine.add(time * 1000, lowerBound);
    nowLine.add(time * 1000, upperBound);
    XYSeriesCollection nowColl = new XYSeriesCollection(); //power axis
    nowColl.addSeries(nowLine);
    XYDataset nowSet = nowColl;

    plot.setDataset(3, nowSet);
    plot.mapDatasetToRangeAxis(3, 1);

    plot.getRendererForDataset(nowSet).setSeriesPaint(0, Color.DARK_GRAY);
    plot.getRendererForDataset(nowSet).setSeriesStroke(0, (Stroke) new BasicStroke(2.0f, BasicStroke.CAP_ROUND,
            BasicStroke.JOIN_ROUND, 1.0f, new float[] { 6.0f, 6.0f }, 0.0f));

    plot.setDomainAxis(new DateAxis());
    plot.getDomainAxis().setAutoRange(false);

    long begin = (time / 86400) * 86400 * 1000; //beginning of day
    long end = begin + 86400 * 2 * 1000;

    plot.getDomainAxis().setRange(begin, end);

    return chart;

}

From source file:edu.cmu.sv.modelinference.eventtool.charting.DataChart.java

private JFreeChart createChart(String yLabel) {
    //Create the chart
    final JFreeChart chart = ChartFactory.createXYLineChart("Chart", "Time", yLabel, null);

    chart.setBackgroundPaint(Color.white);

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

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    plot.setRenderer(renderer);/*from   w w  w .j a v a  2  s  .c om*/

    // change the auto tick unit selection to integer units only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    return chart;
}

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

/**
 * @see Graph/*from  w w w  . jav  a 2 s  .c om*/
 */
@Override
public ChartPanel getChartPanel() {
    final XYPlot plot = new XYPlot(dataset, domain, range, renderer);
    plot.setBackgroundPaint(Color.darkGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setInsets(new RectangleInsets(0, 0, 0, 0));
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinesVisible(true);

    final JFreeChart chart = new JFreeChart(null, new Font("SansSerif", Font.BOLD, 24), plot, true);
    chart.setBackgroundPaint(Color.white);
    chart.removeLegend();
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));

    return chartPanel;
}