List of usage examples for org.jfree.chart.plot XYPlot getRenderer
public XYItemRenderer getRenderer()
From source file:mil.tatrc.physiology.utilities.csv.plots.ConvexHullPlotter.java
protected void formatConvexHullPlot(PlotJob job, JFreeChart chart, XYSeriesCollection dataSet1, XYSeriesCollection dataSet2) {//from ww w. j a v a 2s. com XYPlot plot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer1 = (XYLineAndShapeRenderer) plot.getRenderer(); BasicStroke wideLine = new BasicStroke(2.0f); //For Scientific notation NumberFormat formatter = new DecimalFormat("0.######E0"); for (int i = 0; i < plot.getDomainAxisCount(); i++) { plot.getDomainAxis(i).setLabelFont(new Font("SansSerif", Font.PLAIN, job.fontSize)); plot.getDomainAxis(i).setTickLabelFont(new Font("SansSerif", Font.PLAIN, 15)); plot.getDomainAxis(i).setLabelPaint(job.bgColor == Color.red ? Color.white : Color.black); plot.getDomainAxis(i).setTickLabelPaint(job.bgColor == Color.red ? Color.white : Color.black); } for (int i = 0; i < plot.getRangeAxisCount(); i++) { plot.getRangeAxis(i).setLabelFont(new Font("SansSerif", Font.PLAIN, job.fontSize)); plot.getRangeAxis(i).setTickLabelFont(new Font("SansSerif", Font.PLAIN, 15)); plot.getRangeAxis(i).setLabelPaint(job.bgColor == Color.red ? Color.white : Color.black); plot.getRangeAxis(i).setTickLabelPaint(job.bgColor == Color.red ? Color.white : Color.black); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(i); rangeAxis.setNumberFormatOverride(formatter); } //White background outside of plottable area chart.setBackgroundPaint(job.bgColor); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.black); plot.setRangeGridlinePaint(Color.black); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); chart.getLegend().setItemFont(new Font("SansSerif", Font.PLAIN, 15)); chart.getTitle().setFont(new Font("SansSerif", Font.PLAIN, job.fontSize)); chart.getTitle().setPaint(job.bgColor == Color.red ? Color.white : Color.black); //If there is only one Y axis, color all datasets red (so top, bottom, left, and right will be the same) if (job.Y2headers == null || job.Y2headers.isEmpty()) { for (int i = 0; i < dataSet1.getSeriesCount(); i++) { renderer1.setSeriesStroke(i, wideLine); renderer1.setBaseShapesVisible(false); renderer1.setSeriesFillPaint(i, Color.red); renderer1.setSeriesPaint(i, Color.red); if (dataSet1.getSeries(i).getKey() != null && dataSet1.getSeries(i).getKey().toString().equalsIgnoreCase("REMOVE")) renderer1.setSeriesVisibleInLegend(i, false); } } //If there are 2 Y axes, we should color the axes to correspond with the data so it isn't (as) confusing else { StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(); plot.setRenderer(1, renderer2); for (int i = 0; i < dataSet1.getSeriesCount(); i++) { renderer1.setSeriesStroke(i, wideLine); renderer1.setBaseShapesVisible(false); renderer1.setSeriesFillPaint(i, Color.red); renderer1.setSeriesPaint(i, Color.red); if (dataSet1.getSeries(i).getKey() != null && dataSet1.getSeries(i).getKey().toString().equalsIgnoreCase("REMOVE")) renderer1.setSeriesVisibleInLegend(i, false); } for (int i = 0; i < dataSet2.getSeriesCount(); i++) { renderer2.setSeriesStroke(i, wideLine); renderer2.setBaseShapesVisible(false); renderer2.setSeriesFillPaint(i, Color.blue); renderer2.setSeriesPaint(i, Color.blue); if (dataSet2.getSeries(i).getKey() != null && dataSet2.getSeries(i).getKey().toString().equalsIgnoreCase("REMOVE")) renderer2.setSeriesVisibleInLegend(i, false); } plot.getRangeAxis(0).setLabelPaint(Color.red); plot.getRangeAxis(0).setTickLabelPaint(Color.red); plot.getRangeAxis(1).setLabelPaint(Color.blue); plot.getRangeAxis(1).setTickLabelPaint(Color.blue); } }
From source file:de.dfki.owlsmx.gui.ResultVisualization.java
public JFreeChart createRPChart() { Query query;/* w w w .j a va 2s. c o m*/ Map.Entry me; MacroAvgRecallPrecision recall = new MacroAvgRecallPrecision(20); ArrayList retrievedServices = new ArrayList(); ArrayList relevantServices = new ArrayList(); for (Iterator iter = TestCollection.getInstance() .getMatchmakerAnswerset(GUIState.getInstance().getSorting()).entrySet().iterator(); iter .hasNext();) { me = (Map.Entry) (iter.next()); query = (Query) me.getKey(); retrievedServices = getURIasStringFromServiceSet((SortedSet) me.getValue()); relevantServices = getURIasStringFromURISet(TestCollection.getInstance().getAnswerset(query.getURI())); // owlsmx.io.ErrorLog.instanceOf().report(query.toString() + ":"); // owlsmx.io.ErrorLog.instanceOf().report(" " + retrievedServices.toString()); // owlsmx.io.ErrorLog.instanceOf().report(" " + relevantServices.toString()); if (relevantServices.size() <= 0) GUIState.displayWarning(this, "Error when computing recall/precision graph", "Relevance set is empty. Maybe forgotten to define?"); recall.processRecallPrecision(retrievedServices, relevantServices); } XYSeriesCollection data = new XYSeriesCollection(); data.addSeries(createRPSeries(recall, (retrievedServices.size() <= 0))); JFreeChart chart = ChartFactory.createXYLineChart("Recall/Precision", "Recall", "Precision", data, org.jfree.chart.plot.PlotOrientation.VERTICAL, true, true, false); chart.removeLegend(); XYPlot plot = chart.getXYPlot(); XYItemRenderer renderer = (XYItemRenderer) plot.getRenderer(); renderer.setSeriesPaint(0, Color.red); return chart; }
From source file:Demo.ScatterGraph.java
private JFreeChart CreateChart(int x, int y) { dataSet = new DefaultXYDataset(); AddDataSet(x, y);/*from w w w . j ava2 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:org.n52.oxf.render.sos.TimeSeriesChartRenderer.java
/** * //ww w .j ava2 s . c o m * @param dataset * @param width * @param height * @return */ private JFreeChart drawChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart(null, // title "Date", // x-axis label phenomenon, // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(2.0, 2.0, 2.0, 2.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); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat()); return chart; }
From source file:com.bt.aloha.sipstone.GenGraph.java
private JFreeChart createSingleChart() { XYDataset xydatasetArray[] = createDataset_CallsPerSecond_AvgResponseTime(); XYDataset xydataset = xydatasetArray[0]; final XYDataset percXydataset = xydatasetArray[1]; JFreeChart jfreechart = ChartFactory.createXYLineChart("SIPStone result", "Calls per second", "Avg response time", xydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); XYItemRenderer xyrenderer = (XYItemRenderer) xyplot.getRenderer(); xyrenderer.setBaseItemLabelGenerator(new MyXYItemLabelGenerator(percXydataset)); xyrenderer.setBaseItemLabelsVisible(true); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setAutoRangeIncludesZero(false); numberaxis.setAutoRange(true);/*from ww w . j av a 2 s. c o m*/ numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return jfreechart; }
From source file:org.ewhoxford.swt.bloodpressure.ui.MeasurePageTab.java
/** * Creates a chart.// ww w . ja v a 2 s . com * * @param dataset * a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset, XYPlot bpMeasureXYPlot) { JFreeChart chart = ChartFactory.createTimeSeriesChart("Blood Pressure Measure", // title "time(s)", // x-axis label "Pressure(mmHg)", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); bpMeasureXYPlot = (XYPlot) chart.getPlot(); bpMeasureXYPlot.setBackgroundPaint(Color.lightGray); bpMeasureXYPlot.setDomainGridlinePaint(Color.white); bpMeasureXYPlot.setRangeGridlinePaint(Color.white); // bpMeasureXYPlot.setAxisOffset(new RectangleInsets(300, 0, 0, // BOUNDARY_NUMBER_OF_POINTS)); // bpMeasureXYPlot.setDomainCrosshairVisible(true); // bpMeasureXYPlot.setRangeCrosshairVisible(true); XYItemRenderer r = bpMeasureXYPlot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); } ValueAxis axis = bpMeasureXYPlot.getDomainAxis(); // axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); // axis.setRange(0, 1000); axis.setAutoRange(true); axis = bpMeasureXYPlot.getRangeAxis(); axis.setRange(0, 300.0); // DateAxis axis = (DateAxis) plot.getDomainAxis(); // axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); // axis.setRange(0, 1000); return chart; }
From source file:org.atomserver.testutils.plot.PerfPlotter.java
/** *//* w w w. j a v a 2s .co m*/ private JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart(title, // title xAxisLabel, // x-axis label yAxisLabel, // y-axis label dataset, // data 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); if (useDataPointMarkers) { XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); } } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss")); return chart; }
From source file:org.jfree.chart.demo.ChartPanelSerializationTest.java
/** * Creates a chart./*from ww w .j a va 2 s. c o m*/ * * @param dataset a dataset. * * @return A chart. */ private JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createTimeSeriesChart("Legal & General Unit Trust Prices", "Date", "Price Per Unit", dataset, true, true, false); chart.setBackgroundPaint(Color.white); // final StandardLegend sl = (StandardLegend) chart.getLegend(); // sl.setDisplaySeriesShapes(true); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); final XYItemRenderer renderer = plot.getRenderer(); if (renderer instanceof StandardXYItemRenderer) { final StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer; rr.setPlotShapes(true); rr.setShapesFilled(true); rr.setItemLabelsVisible(true); } final DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); return chart; }
From source file:sim.app.sugarscape.Charts.java
JFreeChart createGiniChart() { JFreeChart chart3 = ChartFactory.createXYLineChart("Lorenz Curve", "Population Percentage", "Percentage of Total Wealth", new XYSeriesCollection(model.lorenz_curve), PlotOrientation.VERTICAL, true, true, false);//from w w w . j a va2s. c om XYPlot plot = chart3.getXYPlot(); ValueAxis yAxis = plot.getRangeAxis(); //xAxis.setFixedDimension(100); yAxis.setFixedDimension(1.0); //yAxis.setRange(0,1); ValueAxis xAxis = plot.getDomainAxis(); xAxis.setFixedDimension(50); //StandardXYItemRenderer XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.black); NumberAxis axis2 = new NumberAxis("Average Agent Vision"); //axis2.setAutoRangeIncludesZero(false); axis2.setRange(0, 12); plot.setRangeAxis(1, axis2); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); //XYSeriesCollection vision = new XYSeriesCollection(lorenz_agent_vision); //plot.setDataset(1, vision); return chart3; }
From source file:de.tsystems.mms.apm.performancesignature.PerfSigBuildActionResultsDisplay.java
private JFreeChart createTimeSeriesChart(final StaplerRequest req, final XYDataset dataset) throws UnsupportedEncodingException { String chartDashlet = req.getParameter(Messages.PerfSigBuildActionResultsDisplay_ReqParamChartDashlet()); String measure = req.getParameter(Messages.PerfSigBuildActionResultsDisplay_ReqParamMeasure()); String unit = req.getParameter(Messages.PerfSigBuildActionResultsDisplay_ReqParamUnit()); String color = req.getParameter(Messages.PerfSigBuildActionResultsDisplay_ReqParamColor()); if (StringUtils.isBlank(color)) color = Messages.PerfSigBuildActionResultsDisplay_DefaultColor(); else//from www.j a v a2 s. co m URLDecoder.decode(req.getParameter(Messages.PerfSigBuildActionResultsDisplay_ReqParamColor()), "UTF-8"); String[] timeUnits = { "ns", "ms", "s", "min", "h" }; JFreeChart chart; if (ArrayUtils.contains(timeUnits, unit)) { chart = ChartFactory.createTimeSeriesChart(PerfSigUtils.generateTitle(measure, chartDashlet), // title "time", // domain axis label unit, dataset, // data false, // include legend false, // tooltips false // urls ); } else { chart = ChartFactory.createXYBarChart(PerfSigUtils.generateTitle(measure, chartDashlet), // title "time", // domain axis label true, unit, (IntervalXYDataset) dataset, // data PlotOrientation.VERTICAL, // orientation false, // include legend false, // tooltips false // urls ); } XYPlot xyPlot = chart.getXYPlot(); xyPlot.setForegroundAlpha(0.8f); xyPlot.setRangeGridlinesVisible(true); xyPlot.setRangeGridlinePaint(Color.black); xyPlot.setOutlinePaint(null); XYItemRenderer xyitemrenderer = xyPlot.getRenderer(); if (xyitemrenderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer; xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseShapesFilled(true); } DateAxis dateAxis = (DateAxis) xyPlot.getDomainAxis(); dateAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); dateAxis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss")); xyitemrenderer.setSeriesPaint(0, Color.decode(color)); xyitemrenderer.setSeriesStroke(0, new BasicStroke(2)); chart.setBackgroundPaint(Color.white); return chart; }