List of usage examples for org.jfree.chart.plot XYPlot setBackgroundPaint
public void setBackgroundPaint(Paint paint)
From source file:com.view.TimeSeriesChartView.java
public JFreeChart getVendorTimeSeriesChart(Excel theExcel, String vendor) { int vendorCode = Integer.parseInt(vendor); ArrayList<Receiving> theReceiving = theExcel.getSheetReceiving(); // HashMap<Month, Integer> item1Map = new HashMap<>(); // HashMap<Month, Integer> item2Map = new HashMap<>(); // HashMap<Month, Integer> item3Map = new HashMap<>(); Set vendorItem = new HashSet(); for (int i = 0; i < theReceiving.size(); i++) { vendorItem.add(theReceiving.get(i).getItem()); }/*from www . j ava2 s . c om*/ TimeSeries data[] = new TimeSeries[vendorItem.size()]; HashMap<Month, Integer> itemMap[] = new HashMap[vendorItem.size()]; for (int i = 0; i < vendorItem.size(); i++) { String itemName = "item" + i; data[i] = new TimeSeries(itemName); itemMap[i] = new HashMap<>(); } Calendar cal = Calendar.getInstance(); for (int i = 0; i < theReceiving.size(); i++) { cal.setTime(theReceiving.get(i).getDate()); int month = cal.get(Calendar.MONTH) + 1; int year = cal.get(Calendar.YEAR); int quantity = 0; if (theReceiving.get(i).getVendor() == vendorCode) { quantity = theReceiving.get(i).getQuantity(); Month theMonth = new Month(month, year); int itemNum = theReceiving.get(i).getItem() - 1; itemMap[itemNum].put(theMonth, updateItemMap(itemMap[itemNum], theMonth, quantity)); } } TimeSeriesCollection my_data_series = new TimeSeriesCollection(); for (int i = 0; i < vendorItem.size(); i++) { for (Map.Entry<Month, Integer> entry : itemMap[i].entrySet()) { data[i].add(entry.getKey(), entry.getValue()); } my_data_series.addSeries(data[i]); } JFreeChart chart = ChartFactory.createTimeSeriesChart("Receiving", "Month", "Quantity", my_data_series, true, true, false); chart.setBackgroundPaint(Color.YELLOW); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.GREEN); plot.setRangeGridlinePaint(Color.orange); plot.setAxisOffset(new RectangleInsets(50, 0, 20, 5)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MM.yyyy")); return chart; }
From source file:edu.ucla.stat.SOCR.chart.demo.CrosshairDemo3.java
protected JFreeChart createChart(XYDataset dataset) { JFreeChart c = ChartFactory.createTimeSeriesChart(chartTitle, // "Legal & General Unit Trust Prices", domainLabel, rangeLabel, // "Date", "Price Per Unit", dataset, !legendPanelOn, true, false); c.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) c.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 renderer = plot.getRenderer(); if (renderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer rr = (XYLineAndShapeRenderer) renderer; rr.setBaseShapesVisible(true);//from w ww . j a v a 2 s. c om rr.setBaseShapesFilled(true); } renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); //setXSummary(dataset) X is time; return c; }
From source file:ruc.edu.window.DynamicDataDemo2.java
/** * Constructs a new demonstration application. * * @param title the frame title./*from w w w .j av a2s . c om*/ */ public DynamicDataDemo2(final String title) { super(title); this.series1 = new TimeSeries("Random 1"); this.series2 = new TimeSeries("Random 2"); final TimeSeriesCollection dataset1 = new TimeSeriesCollection(this.series1); final TimeSeriesCollection dataset2 = new TimeSeriesCollection(this.series2); final JFreeChart chart = ChartFactory.createTimeSeriesChart("Dynamic Data Demo 2", "Time", "Value", dataset1, true, true, false); chart.setBackgroundPaint(Color.white); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); plot.setDomainPannable(true); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 4, 4, 4, 4)); final ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); //axis.setAutoRangeMinimumSize(600000.0); axis.setFixedAutoRange(5000.0); // 60 seconds plot.setDataset(1, dataset2); //final NumberAxis rangeAxis2 = new NumberAxis("Range Axis 2"); /// rangeAxis2.setAutoRangeIncludesZero(false); plot.setRenderer(0, new DefaultXYItemRenderer()); plot.setRenderer(1, new DefaultXYItemRenderer()); //plot.setRangeAxis(1, rangeAxis2); plot.mapDatasetToRangeAxis(1, 0); plot.getRenderer().setSeriesPaint(0, new Color(91, 155, 213)); plot.getRenderer(1).setSeriesPaint(0, Color.BLUE); XYLineAndShapeRenderer render2 = new XYLineAndShapeRenderer() { Stroke soild = new BasicStroke(2.0f); Stroke dashed = new BasicStroke(10.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, new float[] { 10.0f }, 0.0f); @Override public Stroke getItemStroke(int row, int column) { return dashed; } }; plot.setRenderer(1, render2); final JPanel content = new JPanel(new BorderLayout()); final ChartPanel chartPanel = new ChartPanel(chart); content.add(chartPanel); final JButton button1 = new JButton("Add To Series 1"); button1.setActionCommand("ADD_DATA_1"); button1.addActionListener(this); final JButton button2 = new JButton("Add To Series 2"); button2.setActionCommand("ADD_DATA_2"); button2.addActionListener(this); final JButton button3 = new JButton("Add To Both"); button3.setActionCommand("ADD_BOTH"); button3.addActionListener(this); final JPanel buttonPanel = new JPanel(new FlowLayout()); buttonPanel.add(button1); buttonPanel.add(button2); buttonPanel.add(button3); content.add(buttonPanel, BorderLayout.SOUTH); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(content); }
From source file:daylightchart.sunchart.chart.SunChart.java
/** * Creates the daylight chart./*from ww w .ja va 2s .c om*/ */ private void createChart() { setBackgroundPaint(Color.white); final XYPlot plot = getXYPlot(); plot.setRenderer(new StandardXYItemRenderer()); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); createAzimuthAxis(plot); createAltitudeAxis(plot); createBandsInPlot(plot); }
From source file:serverrobot.DynamicGraph.java
public JFreeChart createChart(XYDataset dataset, String pos, double minRange, double maxRange) { final JFreeChart chart = ChartFactory.createTimeSeriesChart(pos, "Time (ms)", "Displacement", dataset, true, true, false);/*from w w w. j a va2 s .co m*/ final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(new Color(232, 232, 232)); plot.setDomainGridlinePaint(Color.BLACK); plot.setRangeGridlinePaint(Color.BLACK); plot.getRenderer().setSeriesPaint(0, Color.BLUE); plot.getRenderer().setSeriesPaint(1, Color.RED); ValueAxis axis = plot.getDomainAxis(); //axis.setAutoRange(true); axis.setFixedAutoRange(20000.0); // 60 seconds axis = plot.getRangeAxis(); axis.setRange(minRange, maxRange); chart.setBackgroundPaint(Color.white); return chart; }
From source file:com.intel.stl.ui.common.view.ComponentFactory.java
public static JFreeChart createHistogramChart(String xAxisLabel, String yAxisLabel, IntervalXYDataset dataset) { JFreeChart jfreechart = ChartFactory.createHistogram(null, xAxisLabel, yAxisLabel, dataset, PlotOrientation.VERTICAL, false, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(null); xyplot.setOutlinePaint(null);// ww w. j av a 2s . c o m xyplot.setRangeGridlinePaint(UIConstants.INTEL_DARK_GRAY); NumberAxis yAxis = (NumberAxis) xyplot.getRangeAxis(); yAxis.setRangeType(RangeType.POSITIVE); yAxis.setLabelFont(UIConstants.H5_FONT); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); xyplot.getDomainAxis().setLabelFont(UIConstants.H5_FONT); xyplot.getRangeAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); XYBarRenderer renderer = (XYBarRenderer) xyplot.getRenderer(); renderer.setShadowVisible(false); renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelFont(UIConstants.H5_FONT); renderer.setBarPainter(new StandardXYBarPainter()); renderer.setSeriesPaint(0, UIConstants.INTEL_BLUE); return jfreechart; }
From source file:org.infoglue.deliver.util.charts.TimeSeriesDiagram.java
/** * Creates a chart./*from ww w .j av a 2s . c om*/ * * @param dataset a dataset. * * @return A chart. */ private JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart(header, axisXHeader, axisYHeader, dataset, true, true, false); chart.setBackgroundPaint(Color.white); LegendTitle legend = chart.getLegend(); //legend.set .setDisplaySeriesShapes(true); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(UnitType.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYItemRenderer renderer = plot.getRenderer(); if (renderer instanceof StandardXYItemRenderer) { StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer; //rr.setPlotShapes(true); rr.setShapesFilled(true); } DateAxis axis = (DateAxis) plot.getDomainAxis(); if (this.timeGranulariry.equalsIgnoreCase("Week")) { DateTickUnit unit = new DateTickUnit(DateTickUnit.DAY, 7, new SimpleDateFormat(this.dateFormat)); axis.setTickUnit(unit); axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setDateFormatOverride(new SimpleDateFormat(this.dateFormat)); } else { axis.setDateFormatOverride(new SimpleDateFormat(this.dateFormat)); } /* DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat(this.dateFormat)); */ return chart; }
From source file:de.perdian.apps.dashboard.support.chart.ChartCreator.java
public JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createXYLineChart(this.getTitle(), null, null, dataset, PlotOrientation.VERTICAL, false, false, false); chart.setBackgroundPaint(null);//from w w w .j a v a2 s . c o m chart.setBackgroundImageAlpha(0.0f); if (chart.getTitle() != null) { chart.getTitle().setFont(new Font(this.getFontName(), Font.BOLD, 14)); } XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(null); plot.setBackgroundAlpha(0.0f); plot.setOutlinePaint(this.getColor()); plot.getDomainAxis().setVisible(false); plot.getDomainAxis().setAxisLineVisible(false); plot.getDomainAxis().setMinorTickCount(10); plot.getDomainAxis().setTickMarksVisible(false); if (this.getDomainTickUnits() != null) { plot.getDomainAxis().setStandardTickUnits(this.getDomainTickUnits()); } plot.getRangeAxis().setVisible(true); plot.getRangeAxis().setAxisLineVisible(false); plot.getRangeAxis().setTickLabelFont(new Font(this.getFontName(), Font.PLAIN, 10)); plot.getRangeAxis().setTickLabelPaint(this.getColor()); plot.getRangeAxis().setTickMarksVisible(false); if (this.getRangeTickUnits() != null) { plot.getRangeAxis().setStandardTickUnits(this.getRangeTickUnits()); } plot.getRangeAxis().setAttributedLabel(this.getRangeAxisLabel()); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); for (int i = 0; i < this.getStrokeDefinitions().size(); i++) { ChartStrokeDefinition strokeDefinition = this.getStrokeDefinitions().get(i); strokeDefinition.applyTo(renderer, i); } return chart; }
From source file:Demo.ScatterGraph.java
private JFreeChart CreateChart(int x, int y) { dataSet = new DefaultXYDataset(); AddDataSet(x, y);/*from w ww.j av a2 s .co m*/ JFreeChart jfreechart = ChartFactory.createScatterPlot("Scatter", paraType_list.get(x), paraType_list.get(y), dataSet, PlotOrientation.VERTICAL, true, false, false); XYPlot plot = (XYPlot) jfreechart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); plot.setDomainGridlinesVisible(true); plot.setNoDataMessage("no data"); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) plot.getRenderer(); xylineandshaperenderer.setSeriesOutlinePaint(0, Color.WHITE); xylineandshaperenderer.setUseOutlinePaint(true); xylineandshaperenderer.setSeriesPaint(0, Color.BLUE); return jfreechart; }
From source file:ec.ui.view.res.ResidualsView.java
@Override protected void onColorSchemeChange() { XYPlot plot = chartPanel.getChart().getXYPlot(); plot.setBackgroundPaint(themeSupport.getPlotColor()); plot.setDomainGridlinePaint(themeSupport.getGridColor()); plot.setRangeGridlinePaint(themeSupport.getGridColor()); chartPanel.getChart().setBackgroundPaint(themeSupport.getBackColor()); XYItemRenderer renderer = plot.getRenderer(); renderer.setBasePaint(themeSupport.getAreaColor(MAIN_COLOR)); renderer.setBaseOutlinePaint(themeSupport.getLineColor(MAIN_COLOR)); }