List of usage examples for org.jfree.chart.plot XYPlot setRangeGridlinePaint
public void setRangeGridlinePaint(Paint paint)
From source file:org.jfree.chart.demo.DynamicDataDemo3.java
/** * Constructs a new demonstration application. * * @param title the frame title./*from w ww . j av a 2s .co m*/ */ public DynamicDataDemo3(final String title) { super(title); final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new DateAxis("Time")); this.datasets = new TimeSeriesCollection[SUBPLOT_COUNT]; for (int i = 0; i < SUBPLOT_COUNT; i++) { this.lastValue[i] = 100.0; final TimeSeries series = new TimeSeries("Random " + i, Millisecond.class); this.datasets[i] = new TimeSeriesCollection(series); final NumberAxis rangeAxis = new NumberAxis("Y" + i); rangeAxis.setAutoRangeIncludesZero(false); final XYPlot subplot = new XYPlot(this.datasets[i], null, rangeAxis, new StandardXYItemRenderer()); subplot.setBackgroundPaint(Color.lightGray); subplot.setDomainGridlinePaint(Color.white); subplot.setRangeGridlinePaint(Color.white); plot.add(subplot); } final JFreeChart chart = new JFreeChart("Dynamic Data Demo 3", plot); // chart.getLegend().setAnchor(Legend.EAST); 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 Spacer(Spacer.ABSOLUTE, 4, 4, 4, 4)); final ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); axis.setFixedAutoRange(60000.0); // 60 seconds final JPanel content = new JPanel(new BorderLayout()); final ChartPanel chartPanel = new ChartPanel(chart); content.add(chartPanel); final JPanel buttonPanel = new JPanel(new FlowLayout()); for (int i = 0; i < SUBPLOT_COUNT; i++) { final JButton button = new JButton("Series " + i); button.setActionCommand("ADD_DATA_" + i); button.addActionListener(this); buttonPanel.add(button); } final JButton buttonAll = new JButton("ALL"); buttonAll.setActionCommand("ADD_ALL"); buttonAll.addActionListener(this); buttonPanel.add(buttonAll); content.add(buttonPanel, BorderLayout.SOUTH); chartPanel.setPreferredSize(new java.awt.Dimension(500, 470)); chartPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); setContentPane(content); }
From source file:required.ChartPlotter.java
/** * Creates a chart.//from w w w .j ava 2s. 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("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; }
From source file:org.jfree.chart.demo.LineChartDemo2.java
/** * Creates a chart.//from www. j av a 2s . 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("Line Chart Demo 2", // chart title "X", // x axis label "Y", // y axis label dataset, // data PlotOrientation.HORIZONTAL, 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); plot.setDomainCrosshairLockedOnData(true); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairLockedOnData(true); plot.setRangeCrosshairVisible(true); final StandardXYItemRenderer renderer = (StandardXYItemRenderer) plot.getRenderer(); renderer.setPlotShapes(true); renderer.setShapesFilled(true); renderer.setItemLabelsVisible(true); final ItemLabelPosition p = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER, TextAnchor.CENTER, Math.PI / 4); renderer.setPositiveItemLabelPosition(p); // 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; }
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 .ja v a 2 s .co 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: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);/*w ww.j a v a 2 s . c om*/ 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);/*ww w. j a v a2 s . co 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:ec.ui.view.ARPView.java
@Override protected void onColorSchemeChange() { XYPlot plot = getPlot(); plot.setBackgroundPaint(themeSupport.getPlotColor()); plot.setDomainGridlinePaint(themeSupport.getGridColor()); plot.setRangeGridlinePaint(themeSupport.getGridColor()); chartPanel.getChart().setBackgroundPaint(themeSupport.getBackColor()); plot.getRenderer().setBasePaint(themeSupport.getLineColor(KnownColor.BROWN)); List<Marker> markers = new ArrayList<>(); Collection rm = plot.getRangeMarkers(Layer.FOREGROUND); if (rm != null) { markers.addAll(rm);// w ww . j a va2 s. com } Collection dm = plot.getDomainMarkers(Layer.FOREGROUND); if (dm != null) { markers.addAll(dm); } for (Marker o : markers) { if (o instanceof ExtValueMarker) { ((ExtValueMarker) o).applyColorScheme(themeSupport); } } }
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(); }//w w w .j a va 2s.c om 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:ec.nbdemetra.ui.chart3d.functions.Functions2DChart.java
@Override protected void onColorSchemeChange() { functionRenderer.setBasePaint(themeSupport.getLineColor(ColorScheme.KnownColor.BLUE)); optimumRenderer.setBasePaint(themeSupport.getLineColor(KnownColor.RED)); XYPlot mainPlot = chart.getXYPlot(); mainPlot.setBackgroundPaint(themeSupport.getPlotColor()); mainPlot.setDomainGridlinePaint(themeSupport.getGridColor()); mainPlot.setRangeGridlinePaint(themeSupport.getGridColor()); chart.setBackgroundPaint(themeSupport.getBackColor()); }
From source file:org.n52.io.img.ChartRenderer.java
private XYPlot createPlotArea(JFreeChart chart) { XYPlot xyPlot = chart.getXYPlot(); xyPlot.setBackgroundPaint(WHITE);//w w w . ja v a 2 s. c om xyPlot.setDomainGridlinePaint(LIGHT_GRAY); xyPlot.setRangeGridlinePaint(LIGHT_GRAY); xyPlot.setAxisOffset(new RectangleInsets(2.0, 2.0, 2.0, 2.0)); showCrosshairsOnAxes(xyPlot); configureDomainAxis(xyPlot); showGridlinesOnChart(xyPlot); configureTimeAxis(xyPlot); return xyPlot; }