List of usage examples for org.jfree.chart.plot XYPlot getRenderer
public XYItemRenderer getRenderer()
From source file:org.jfree.chart.demo.XYPolygonAnnotationDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createScatterPlot("XYPolygonAnnotationDemo1", "X", "Y", xydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); XYPolygonAnnotation xypolygonannotation = new XYPolygonAnnotation( new double[] { 2D, 5D, 2.5D, 8D, 3D, 5D, 2.5D, 2D }, null, null, new Color(200, 200, 255, 100)); xypolygonannotation.setToolTipText("Target Zone"); xylineandshaperenderer.addAnnotation(xypolygonannotation, Layer.BACKGROUND); return jfreechart; }
From source file:org.physionet.wfdb.examples.PlotECGQRSDemo2.java
private static JFreeChart createChart(XYDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createXYLineChart("Plot ECG Demo1 ", // chart title "Time (seconds)", // x axis label "mV", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls );/* w w w.j a v a 2s . c o m*/ XYPlot plot = (XYPlot) chart.getPlot(); plot.getDomainAxis().setLowerMargin(0.0); plot.getDomainAxis().setUpperMargin(0.0); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setSeriesLinesVisible(1, false); renderer.setSeriesShapesVisible(1, true); renderer.setSeriesShapesFilled(1, true); } return chart; }
From source file:cn.InstFS.wkr.NetworkMining.UIs.TimeSeriesChart2.java
public static JFreeChart createChart(DataItems nor, DataItems abnor, String title, String protocol1, String protocol2) {//from w ww. j a v a 2 s . c o m // ? XYDataset xydataset1 = TimeSeriesChart1.createNormalDataset(nor, protocol1); JFreeChart jfreechart = ChartFactory.createScatterPlot(title, "", "", xydataset1); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); XYLineAndShapeRenderer xylineandshaperenderer1 = (XYLineAndShapeRenderer) xyplot.getRenderer(); // ??1?1 NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setAutoRangeIncludesZero(false); java.awt.geom.Ellipse2D.Double double1 = new java.awt.geom.Ellipse2D.Double(-4D, -4D, 6D, 6D); // ??? // ?? xylineandshaperenderer1.setSeriesLinesVisible(0, true); xylineandshaperenderer1.setBaseShapesVisible(false); xylineandshaperenderer1.setSeriesShape(0, double1); xylineandshaperenderer1.setSeriesPaint(0, Color.blue); xylineandshaperenderer1.setSeriesFillPaint(0, Color.blue); xylineandshaperenderer1.setSeriesOutlinePaint(0, Color.blue); xylineandshaperenderer1.setSeriesStroke(0, new BasicStroke(0.5F)); // ? XYDataset xydataset2 = TimeSeriesChart1.createNormalDataset(abnor, protocol2); /* XYTextAnnotation localXYTextAnnotation = new XYTextAnnotation("aa",10, Double.parseDouble(abnor.getElementAt(10).getData())); xyplot.addAnnotation(localXYTextAnnotation);*/ XYLineAndShapeRenderer xylineandshaperenderer2 = new XYLineAndShapeRenderer(); int datasetcount = xyplot.getDatasetCount(); xyplot.setDataset(datasetcount, xydataset2); xyplot.setRenderer(datasetcount, xylineandshaperenderer2); /* System.out.println("DatasetCount="+xyplot.getDatasetCount()); for(int c=0;c<xyplot.getDatasetCount();c++){ System.out.println("DatasetSeriesCount="+xyplot.getDataset(c).getSeriesCount()); System.out.println("Dataset["+c+"]="+xyplot.getDataset(c).getSeriesKey(0)); }*/ /* // ??? xylineandshaperenderer2.setBaseShapesVisible(false); // ?? xylineandshaperenderer2.setSeriesLinesVisible(0, true); xylineandshaperenderer2.setSeriesShape(0, double1); // xylineandshaperenderer2.setSeriesPaint(0, Color.green); xylineandshaperenderer2.setSeriesFillPaint(0, Color.green); xylineandshaperenderer2.setSeriesOutlinePaint(0, Color.green); xylineandshaperenderer2.setUseFillPaint(true); xylineandshaperenderer2 .setBaseItemLabelGenerator(new StandardXYItemLabelGenerator()); xylineandshaperenderer2.setSeriesStroke(0, new BasicStroke(0.5F)); */ xylineandshaperenderer2.setSeriesLinesVisible(0, true); xylineandshaperenderer2.setBaseShapesVisible(false); xylineandshaperenderer2.setSeriesShape(0, double1); xylineandshaperenderer2.setSeriesPaint(0, Color.GREEN); xylineandshaperenderer2.setSeriesFillPaint(0, Color.GREEN); xylineandshaperenderer2.setSeriesOutlinePaint(0, Color.green); xylineandshaperenderer2.setSeriesStroke(0, new BasicStroke(0.5F)); jfreechart.getLegend().setVisible(true); return jfreechart; }
From source file:org.jfree.chart.demo.XYPointerAnnotationDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createScatterPlot("XYPointerAnnotationDemo1", "X", "Y", xydataset, PlotOrientation.HORIZONTAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); XYPointerAnnotation xypointerannotation = new XYPointerAnnotation("Special point", 2.2000000000000002D, 6D, 3.9269908169872414D);// ww w .j a v a 2 s.c om xypointerannotation.setTextAnchor(TextAnchor.BOTTOM_RIGHT); xypointerannotation.setToolTipText("The pointer has a tool tip!"); xylineandshaperenderer.addAnnotation(xypointerannotation, Layer.BACKGROUND); return jfreechart; }
From source file:org.jfree.chart.demo.StackedXYAreaChartDemo3.java
private static JFreeChart createChart(TableXYDataset tablexydataset) { JFreeChart jfreechart = ChartFactory.createStackedXYAreaChart("Stacked XY Area Chart Demo 3", "X Value", "Y Value", tablexydataset, PlotOrientation.VERTICAL, true, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); DateAxis dateaxis = new DateAxis("Date"); xyplot.setDomainAxis(dateaxis);//from w w w . ja v a2 s .c om dateaxis.setLowerMargin(0.0D); dateaxis.setUpperMargin(0.0D); StackedXYAreaRenderer2 stackedxyarearenderer2 = (StackedXYAreaRenderer2) xyplot.getRenderer(); stackedxyarearenderer2.setRoundXCoordinates(true); return jfreechart; }
From source file:net.sf.maltcms.chromaui.charts.tools.ChartTools.java
/** * * @param plot// www . j a v a2 s . co m * @return */ public static XYPlot getPlot3(XYPlot plot) { XYPlot p = new XYPlot(plot.getDataset(), new NumberAxis(plot.getRangeAxis().getLabel()), new NumberAxis(plot.getDomainAxis().getLabel()), plot.getRenderer()); p.setOrientation(PlotOrientation.HORIZONTAL); p.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT); Logger.getLogger(ChartTools.class.getName()).log(Level.INFO, "fixed auto range: {0}", plot.getRangeAxis().getRange().getUpperBound()); p.getDomainAxis().setFixedAutoRange(500); return p; }
From source file:com.imaging100x.tracker.TrackerUtils.java
/** * Create a frame with a plot of the data given in XYSeries *//*from w w w . j av a 2s. co m*/ public static void plotData(String title, final XYSeries data, String xTitle, String yTitle, int xLocation, int yLocation) { // JFreeChart code XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(data); JFreeChart chart = ChartFactory.createScatterPlot(title, // Title xTitle, // x-axis Label yTitle, // y-axis Label dataset, // Dataset PlotOrientation.VERTICAL, // Plot Orientation false, // Show Legend true, // Use tooltips false // Configure chart to generate URLs? ); final XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.lightGray); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setSeriesPaint(0, Color.black); renderer.setSeriesFillPaint(0, Color.white); renderer.setSeriesLinesVisible(0, true); Shape circle = new Ellipse2D.Float(-2.0f, -2.0f, 4.0f, 4.0f); renderer.setSeriesShape(0, circle, false); renderer.setUseFillPaint(true); ChartFrame graphFrame = new ChartFrame(title, chart); graphFrame.getChartPanel().setMouseWheelEnabled(true); graphFrame.setPreferredSize(new Dimension(SIZE, SIZE)); graphFrame.setResizable(true); graphFrame.pack(); graphFrame.setLocation(xLocation, yLocation); graphFrame.setVisible(true); dataset.addChangeListener(new DatasetChangeListener() { public void datasetChanged(DatasetChangeEvent dce) { double xRange = data.getMaxX() - data.getMinX(); double yRange = data.getMaxY() - data.getMinY(); double xAvg = (data.getMaxX() + data.getMinX()) / 2; double yAvg = (data.getMaxY() + data.getMinY()) / 2; double range = xRange; if (yRange > range) { range = yRange; } double offset = 0.55 * range; plot.getDomainAxis().setRange(xAvg - offset, xAvg + offset); plot.getRangeAxis().setRange(yAvg - offset, yAvg + offset); } }); }
From source file:org.gaixie.micrite.jfreechart.style.LineStyle.java
public static void styleOne(JFreeChart chart) { XYPlot xyplot = (XYPlot) chart.getPlot(); XYDataset xyd = xyplot.getDataset(); //?//from w w w .j av a2 s . c o m LineStyle.setBackground(chart); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); if (xyd != null) { //? xylineandshaperenderer.setBaseShapesVisible(true); // xylineandshaperenderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator()); xylineandshaperenderer.setBaseItemLabelsVisible(true); xyplot.setRenderer(xylineandshaperenderer); //tooltip // xyplot.getRenderer().setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0}: ({1}, {2})",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"),new DecimalFormat())); //? for (int i = 0; i < xyd.getSeriesCount(); i++) { int colorIdx = i % colors.length; xylineandshaperenderer.setSeriesPaint(i, colors[colorIdx]); } } else { xyplot.setNoDataMessage("NO DATA"); } }
From source file:org.matsim.analysis.LegHistogramChart.java
static JFreeChart getGraphic(final LegHistogram.DataFrame dataFrame, final String mode, int iteration) { final XYSeriesCollection xyData = new XYSeriesCollection(); final XYSeries departuresSerie = new XYSeries("departures", false, true); final XYSeries arrivalsSerie = new XYSeries("arrivals", false, true); final XYSeries onRouteSerie = new XYSeries("en route", false, true); int onRoute = 0; for (int i = 0; i < dataFrame.countsDep.length; i++) { onRoute = onRoute + dataFrame.countsDep[i] - dataFrame.countsArr[i] - dataFrame.countsStuck[i]; double hour = i * dataFrame.binSize / 60.0 / 60.0; departuresSerie.add(hour, dataFrame.countsDep[i]); arrivalsSerie.add(hour, dataFrame.countsArr[i]); onRouteSerie.add(hour, onRoute); }/*w w w . ja va 2s.c o m*/ xyData.addSeries(departuresSerie); xyData.addSeries(arrivalsSerie); xyData.addSeries(onRouteSerie); final JFreeChart chart = ChartFactory.createXYStepChart("Leg Histogram, " + mode + ", it." + iteration, "time", "# persons", xyData, PlotOrientation.VERTICAL, true, // legend false, // tooltips false // urls ); XYPlot plot = chart.getXYPlot(); final CategoryAxis axis1 = new CategoryAxis("hour"); axis1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 7)); plot.setDomainAxis(new NumberAxis("time")); plot.getRenderer().setSeriesStroke(0, new BasicStroke(2.0f)); plot.getRenderer().setSeriesStroke(1, new BasicStroke(2.0f)); plot.getRenderer().setSeriesStroke(2, new BasicStroke(2.0f)); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.gray); plot.setDomainGridlinePaint(Color.gray); return chart; }
From source file:beadAnalyzer.DrawPoints.java
public static void setColor(final JFreeChart chart, final int seriesIndex, final Color col) { final XYPlot plot = chart.getXYPlot(); final XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(seriesIndex, col); }