List of usage examples for org.jfree.chart.plot XYPlot setBackgroundPaint
public void setBackgroundPaint(Paint paint)
From source file:org.hxzon.demo.jfreechart.XYDatasetDemo2.java
private static JFreeChart createTimeSeriesChart(XYDataset dataset) { DateAxis timeAxis = new DateAxis(xAxisLabel); timeAxis.setLowerMargin(0.02); // reduce the default margins timeAxis.setUpperMargin(0.02);//from w ww. ja v a2 s.c o m NumberAxis valueAxis = new NumberAxis(yAxisLabel); valueAxis.setAutoRangeIncludesZero(false); // override default XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null); XYToolTipGenerator toolTipGenerator = null; if (tooltips) { toolTipGenerator = StandardXYToolTipGenerator.getTimeSeriesInstance(); } XYURLGenerator urlGenerator = null; if (urls) { urlGenerator = new StandardXYURLGenerator(); } XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); renderer.setBaseToolTipGenerator(toolTipGenerator); renderer.setURLGenerator(urlGenerator); plot.setRenderer(renderer); JFreeChart chart = new JFreeChart("TimeSeries Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); chart.setBackgroundPaint(Color.white); 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); // renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); timeAxis.setDateFormatOverride(new SimpleDateFormat("MM-yyyy")); return chart; }
From source file:org.hxzon.demo.jfreechart.XYDatasetDemo2.java
private static JFreeChart createTimeSeriesChart2(XYDataset dataset) { DateAxis timeAxis = new DateAxis(xAxisLabel); timeAxis.setLowerMargin(0.02); // reduce the default margins timeAxis.setUpperMargin(0.02);/*from w w w . ja v a 2 s . c o m*/ NumberAxis valueAxis = new NumberAxis(yAxisLabel); valueAxis.setAutoRangeIncludesZero(false); // override default XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null); XYToolTipGenerator toolTipGenerator = null; if (tooltips) { toolTipGenerator = StandardXYToolTipGenerator.getTimeSeriesInstance(); } XYURLGenerator urlGenerator = null; if (urls) { urlGenerator = new StandardXYURLGenerator(); } XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); renderer.setBaseToolTipGenerator(toolTipGenerator); renderer.setURLGenerator(urlGenerator); plot.setRenderer(renderer); JFreeChart chart = new JFreeChart("TimeSeries Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); chart.setBackgroundPaint(Color.white); 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); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); timeAxis.setDateFormatOverride(new SimpleDateFormat("MM-yyyy")); return chart; }
From source file:flexflux.analyses.result.TDRFBAResult.java
public void plot() { JPanel panel = new JPanel(); JScrollPane sp = new JScrollPane(panel); panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); // one chart by entity Color[] colors = new Color[] { Color.RED, Color.GREEN, Color.BLUE }; int index = 0; for (String s : entities) { XYSeriesCollection dataset = new XYSeriesCollection(); XYSeries series = new XYSeries(s); for (Double time : times) { series.add(time, resultMap.get(time).get(s)); }//from w w w.ja v a2s . c o m final JFreeChart chart = ChartFactory.createXYLineChart(s, // chart // title "Time (h)", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setRangeGridlinePaint(Color.GRAY); plot.setDomainGridlinePaint(Color.GRAY); plot.getRenderer().setSeriesPaint(0, colors[index % colors.length]); index++; ChartPanel chartPanel = new ChartPanel(chart); dataset.addSeries(series); panel.add(chartPanel); panel.add(new JSeparator()); } Dimension d = panel.getComponent(0).getPreferredSize(); d.height *= 2; sp.getViewport().setPreferredSize(d); JFrame frame = new JFrame("Time-dependant FBA results"); frame.add(sp); frame.pack(); RefineryUtilities.centerFrameOnScreen(frame); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
From source file:org.hxzon.demo.jfreechart.XYDatasetDemo2.java
private static JFreeChart createScatterChart(XYDataset dataset) { NumberAxis xAxis = new NumberAxis(xAxisLabel); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(yAxisLabel); yAxis.setAutoRangeIncludesZero(false); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); XYToolTipGenerator toolTipGenerator = null; if (tooltips) { toolTipGenerator = new StandardXYToolTipGenerator(); }//from w w w. j a va 2 s .c o m XYURLGenerator urlGenerator = null; if (urls) { urlGenerator = new StandardXYURLGenerator(); } XYItemRenderer renderer = new XYLineAndShapeRenderer(false, true); renderer.setBaseToolTipGenerator(toolTipGenerator); renderer.setURLGenerator(urlGenerator); plot.setRenderer(renderer); plot.setOrientation(orientation); JFreeChart chart = new JFreeChart("Scatter Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); chart.setBackgroundPaint(Color.white); 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); yAxis.setNumberFormatOverride(MyNumberFormat.getMyNumberFormat()); return chart; }
From source file:wattsup.jsdk.ui.LineChartPanelSupport.java
@Override public JFreeChart createChart() { this.timeSeries_ = new TimeSeriesCollection(); this.dataset_ = new TranslatingXYDataset(this.timeSeries_); JFreeChart chart = ChartFactory.createTimeSeriesChart(this.getTitle(), null, this.getAxisLabel(), this.dataset_, true, true, false); chart.setBackgroundPaint(getBackground()); XYPlot xyPlot = chart.getXYPlot(); xyPlot.setOrientation(PlotOrientation.VERTICAL); xyPlot.setBackgroundPaint(Color.WHITE); xyPlot.setDomainGridlinePaint(Color.BLACK.darker()); xyPlot.setRangeGridlinePaint(Color.BLACK.darker()); xyPlot.setAxisOffset(new RectangleInsets(5.0D, 5.0D, 5.0D, 5.0D)); xyPlot.setDomainCrosshairLockedOnData(true); xyPlot.setRangeCrosshairVisible(true); chart.setAntiAlias(true);//from w ww. j a va 2 s . co m return chart; }
From source file:arduinoserialread.SerialRead.java
private void initGUI() { // init the frame frame.setTitle("Arduino Serial Read"); frame.setBounds(100, 100, 600, 500); frame.setMinimumSize(new Dimension(600, 500)); frame.setLocationRelativeTo(null);/*from w w w. j a va 2s . c o m*/ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // init control panel JPanel ctrlPanel = new JPanel(); ctrlPanel.setLayout(new FlowLayout()); // init the serial connection panel serialCOM = new SerialConnectionPanel(); ctrlPanel.add(serialCOM); frame.getContentPane().add(ctrlPanel, BorderLayout.SOUTH); // init the connection status ConnectionStatus connectionStatus = new ConnectionStatus(); ctrlPanel.add(connectionStatus); // init connect and disconnect button connect = new JButton("connect"); ctrlPanel.add(connect); disconnect = new JButton("disconnect"); ctrlPanel.add(disconnect); // init real time chart TimeSeries series = new TimeSeries("DATA"); DateAxis timeAxis = new DateAxis("Time"); dataset = new TimeSeriesCollection(series); NumberAxis rangeAxis = new NumberAxis("Data"); rangeAxis.setAutoRangeIncludesZero(false); rangeAxis.setAutoRange(true); XYPlot plot = new XYPlot(dataset, timeAxis, rangeAxis, new StandardXYItemRenderer()); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.getRenderer().setSeriesPaint(0, new Color(0, 142, 192)); ValueAxis domainAxis = plot.getDomainAxis(); domainAxis.setAutoRange(true); domainAxis.setFixedAutoRange(30000.0); // 30 seconds // init the JFreeChart JFreeChart chart = new JFreeChart("Real-Time Data Chart", plot); chart.setBorderPaint(Color.lightGray); chart.setBorderVisible(true); chart.setBackgroundPaint(Color.white); chart.removeLegend(); // add real time chart to the frame ChartPanel chartPanel = new ChartPanel(chart); frame.getContentPane().add(chartPanel, BorderLayout.CENTER); }
From source file:networkmonitor.MainIBMApplicationForm.java
/** * Creates a chart.// w ww . j a va 2s . com * * @param dataset the data for the chart. * * @return a chart. */ private JFreeChart createChart(final XYDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart( // put a big space or it'll overlap with the statistics of data... :) "B/W Usage in KBps: ", // chart title "Seconds ", // x axis label " Usage", // y axis label dataset, // data PlotOrientation.VERTICAL, // Plot Orientation.. it means grap will show you statistics vertically true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // Background color of chart/outside plot........ chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); //plot background color inside the graph.... plot.setBackgroundPaint(Color.orange); //org.jfree.chart.plot.XYPlot; //Plot vertical inner graph line..... plot.setDomainGridlinePaint(Color.red); //plot horizontal inner graph line..... plot.setRangeGridlinePaint(Color.blue); //Sets the renderer for the PGraphics object that is used for drawing to... final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); // it used to show the up and down connecting line will show or not(RED LINE of graph) renderer.setSeriesLinesVisible(1, true); //renderer.setSeriesShapesVisible(1, false); plot.setRenderer(renderer);//it used to show the up and down block of data(RED Block Of GRAPH) //......................................... //..... change the auto tick unit selection to integer units only //LIMIT OF X and Y axis GRAPH SIDE DATA (usages/second) //.....if I unhide these then only integer number show in X axis,it avoid floating point /*final NumberAxis domainAxis = new NumberAxis("X-Axis"); domainAxis.setRange(0.00,1.00); domainAxis.setTickUnit(new NumberTickUnit(0.1)); final NumberAxis rangeAxis = new NumberAxis("Y-Axis"); rangeAxis.setRange(0.0,1.0); rangeAxis.setTickUnit(new NumberTickUnit(0.0));*/ //usases(X axis) integer data counting //final NumberAxis rangeAxis = (NumberAxis) //plot.getRangeAxis(); // rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. //.............................................. return chart; }
From source file:ac.kaist.ccs.presentation.CCSHubSelectionCost.java
/** * Creates a chart.//ww w.ja va 2 s. c o 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(title, // chart title "Number of Hubs", // x axis label "Cost for pipeline transportation \nfrom CO2 emission source node to hubs", // 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()); rangeAxis.setRange(minVal - (maxVal - minVal) * 0.05, maxVal + (maxVal - minVal) * 0.05); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:com.romraider.logger.ecu.ui.handler.graph.GraphUpdateHandler.java
private JFreeChart createXYLineChart(LoggerData loggerData, XYDataset dataset, boolean combined) { String title = combined ? "Combined Data" : loggerData.getName(); String rangeAxisTitle = combined ? "Data" : buildRangeAxisTitle(loggerData); JFreeChart chart = ChartFactory.createXYLineChart(title, "Time (sec)", rangeAxisTitle, dataset, VERTICAL, false, true, false);/* ww w .ja v a 2 s . co m*/ chart.setBackgroundPaint(BLACK); chart.getTitle().setPaint(WHITE); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(BLACK); plot.getDomainAxis().setLabelPaint(WHITE); plot.getRangeAxis().setLabelPaint(WHITE); plot.getDomainAxis().setTickLabelPaint(LIGHT_GREY); plot.getRangeAxis().setTickLabelPaint(LIGHT_GREY); plot.setDomainGridlinePaint(DARK_GREY); plot.setRangeGridlinePaint(DARK_GREY); plot.setOutlinePaint(DARK_GREY); return chart; }
From source file:edu.ucla.stat.SOCR.chart.demo.MultiIndexChart.java
/** * Creates a chart./*from w ww . j a v a 2 s .co m*/ * * @param dataset the data for the chart. * * @return a chart. */ protected JFreeChart createChart(XYDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title domainLabel, // x axis label rangeLabel, // y axis label dataset, // data PlotOrientation.VERTICAL, !legendPanelOn, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); // renderer.setSeriesShape(0, java.awt.Shape.round); renderer.setBaseShapesVisible(false); renderer.setBaseShapesFilled(false); renderer.setBaseLinesVisible(true); renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); //change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(false); rangeAxis.setUpperMargin(0.05); rangeAxis.setLowerMargin(0.05); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); domainAxis.setAutoRangeIncludesZero(false); // domainAxis.setTickLabelsVisible(false); // domainAxis.setTickMarksVisible(false); domainAxis.setUpperMargin(0.05); domainAxis.setLowerMargin(0.05); // OPTIONAL CUSTOMISATION COMPLETED. setYSummary(dataset); return chart; }