List of usage examples for org.jfree.chart.plot XYPlot getRenderer
public XYItemRenderer getRenderer()
From source file:sim.app.sugarscape.Charts.java
JFreeChart createEvolution() { JFreeChart chart = ChartFactory.createXYLineChart("Evolution of Mean Agent Vision and Metabolism", "Time", "Level", model.evolution_vision_coll, PlotOrientation.VERTICAL, true, true, false); model.evolution_chart = chart;//from w w w .j a v a2s. c o m NumberAxis rangeAxis1 = new NumberAxis("Time"); rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); org.jfree.chart.axis.NumberAxis domainAxis = new NumberAxis("Bins"); XYPlot plot = chart.getXYPlot(); ValueAxis xAxis = plot.getDomainAxis(); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.BLACK); plot.setDataset(1, model.evolution_metabolism_coll); renderer.setSeriesPaint(1, Color.BLUE); return chart; }
From source file:sim.app.sugarscape.Charts.java
JFreeChart createTradeChart() { JFreeChart chart = ChartFactory.createXYLineChart("Trading and Population over Time", "Time", "Level", model.agents_series_coll, PlotOrientation.VERTICAL, true, true, false); model.trade_chart = chart;//www . j a va 2s . co m NumberAxis rangeAxis1 = new NumberAxis("Time"); rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); org.jfree.chart.axis.NumberAxis domainAxis = new NumberAxis("Bins"); XYPlot plot = chart.getXYPlot(); ValueAxis xAxis = plot.getDomainAxis(); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.BLUE); plot.setDataset(1, model.trade_coll); XYItemRenderer rend2 = new StandardXYItemRenderer(); //if (rend2 != null) rend2.setSeriesPaint(1, Color.BLACK); plot.setRenderer(1, rend2); return chart; }
From source file:com.itemanalysis.jmetrik.graph.irt.IrtPlotPanel.java
private void createChart(String name, String title, String xLabel, String yLabel, double minScore, double maxScore) { XYSeriesCollection dataset = new XYSeriesCollection(); JFreeChart chart = ChartFactory.createXYLineChart(title, // chart title xLabel, // x axis label yLabel, // y axis label dataset, // data chartOrientation, // chart orientation showLegend, // include legend true, // tooltips false // urls );//from w ww .j a va2 s . co m // get a reference to the plot for further customisation... XYPlot plot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesFilled(false); renderer.setDrawOutlines(true); plot.setBackgroundPaint(Color.WHITE); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.getDomainAxis().setRange(minScore, maxScore); ChartPanel panel = new ChartPanel(chart); panel.getPopupMenu().addSeparator(); panel.setPreferredSize(new Dimension(width, height)); // this.addLocalEPSMenuItem(this, panel.getPopupMenu(), chart);//remove this line for public release versions chart.setPadding(new RectangleInsets(20.0, 5.0, 20.0, 5.0)); charts.put(name, chart); JPanel subPanel = new JPanel();//additional panel needed to prevent gridlayout from stretching graph subPanel.add(panel); // this.addJpgMenuItem(subPanel, panel.getPopupMenu()); subPanel.setBackground(Color.WHITE); this.add(subPanel); }
From source file:MSUmpire.DIA.RTMappingExtLib.java
private void GenerateRTMapPNG(XYSeriesCollection xySeriesCollection, XYSeries series, float R2) throws IOException { String pngfile = FilenameUtils.getFullPath(TargetLCMS.mzXMLFileName) + "/" + FilenameUtils.getBaseName(TargetLCMS.mzXMLFileName) + "_" + libManager.LibID + "_RTMap.png"; FileWriter writer = new FileWriter(FilenameUtils.getFullPath(TargetLCMS.mzXMLFileName) + "/" + FilenameUtils.getBaseName(TargetLCMS.mzXMLFileName) + "_" + libManager.LibID + "_RTMap.txt"); XYSeries smoothline = new XYSeries("RT fitting curve"); for (XYZData data : regression.PredictYList) { smoothline.add(data.getX(), data.getY()); writer.write(data.getX() + "\t" + data.getY() + "\n"); }/*from ww w .j av a2 s. c o m*/ writer.close(); xySeriesCollection.addSeries(smoothline); xySeriesCollection.addSeries(series); JFreeChart chart = ChartFactory.createScatterPlot("Retention time mapping: R2=" + R2, "Normalized RT (" + libManager.LibID + ")", "RT:" + FilenameUtils.getBaseName(TargetLCMS.mzXMLFileName), xySeriesCollection, PlotOrientation.VERTICAL, true, true, false); XYPlot xyPlot = (XYPlot) chart.getPlot(); xyPlot.setDomainCrosshairVisible(true); xyPlot.setRangeCrosshairVisible(true); XYItemRenderer renderer = xyPlot.getRenderer(); renderer.setSeriesPaint(1, Color.blue); renderer.setSeriesPaint(0, Color.BLACK); renderer.setSeriesShape(1, new Ellipse2D.Double(0, 0, 3, 3)); renderer.setSeriesStroke(1, new BasicStroke(3.0f)); renderer.setSeriesStroke(0, new BasicStroke(3.0f)); xyPlot.setBackgroundPaint(Color.white); ChartUtilities.saveChartAsPNG(new File(pngfile), chart, 1000, 600); }
From source file:com.itemanalysis.jmetrik.graph.irt.IrtPlotPanel.java
public void updateDataset(String name, XYSeriesCollection dataset, boolean showLegend) { JFreeChart chart = charts.get(name); if (!showLegend) chart.removeLegend();//from w w w.j av a 2 s. co m XYPlot plot = (XYPlot) chart.getPlot(); plot.setDataset(dataset); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); setXYPlotRenderer(plot); }
From source file:com.itemanalysis.jmetrik.graph.irt.IrtPlotPanel.java
/** * Same as updateDataset() but includes additional series for observed points. The dataset is twice * the size as the number of lines because there is a line and set of points for each category. * * @param name name of chart//from w w w .ja va 2s . com * @param dataset data set where the first half of the entries define the lines and the second half * of the series define the points. The series for lines and points are assumed to be * in the same order. * @param showLegend show legend. */ public void updateDatasetLinesAndPoints(String name, XYSeriesCollection dataset, boolean showLegend) { JFreeChart chart = charts.get(name); if (!showLegend) chart.removeLegend(); XYPlot plot = (XYPlot) chart.getPlot(); plot.setDataset(dataset); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); setXYPlotRendererWithPoints(plot); }
From source file:de.iteratec.visualizationmodel.jfreechart.ChartFactory.java
public JFreeChart createXYStepChart(XYDataset dataset) { XYToolTipGenerator toolTipGenerator = !showTooltips ? null : new StandardXYToolTipGenerator(); XYURLGenerator urlGenerator = !showUrls ? null : new StandardXYURLGenerator(); XYItemRenderer renderer = new XYStepRenderer(toolTipGenerator, urlGenerator); XYPlot plot = new XYPlot(dataset, (ValueAxis) xAxis, (ValueAxis) yAxis, null); plot.setRenderer(renderer);/* w w w . j a v a2 s . c o m*/ plot.setOrientation(orientation); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); plot.getRenderer().setSeriesStroke(0, new BasicStroke(5.0f)); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, showLegend); THEME.apply(chart); return chart; }
From source file:mls.FramePlot.java
private JFreeChart createChartVarianza(final XYDataset datasetVarianza) { final JFreeChart result = ChartFactory.createXYLineChart("Varianza campionaria", "n", "vc", datasetVarianza, PlotOrientation.VERTICAL, false, true, false); final XYPlot plot = result.getXYPlot(); ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true);//from w w w . ja v a2 s. c o m axis.setFixedAutoRange(1500); axis = plot.getRangeAxis(); axis.setAutoRange(true); axis.setRange(10, 100); plot.getRenderer().setSeriesPaint(0, Color.MAGENTA); return result; }
From source file:org.matsim.pt.analysis.RouteTimeDiagram.java
public void createGraph(final String filename, final TransitRoute route) { HashMap<Id, Integer> stopIndex = new HashMap<Id, Integer>(); int idx = 0;// ww w . ja va 2 s. c o m for (TransitRouteStop stop : route.getStops()) { stopIndex.put(stop.getStopFacility().getId(), idx); idx++; } HashSet<Id> vehicles = new HashSet<Id>(); for (Departure dep : route.getDepartures().values()) { vehicles.add(dep.getVehicleId()); } XYSeriesCollection dataset = new XYSeriesCollection(); int numSeries = 0; double earliestTime = Double.POSITIVE_INFINITY; double latestTime = Double.NEGATIVE_INFINITY; for (Map.Entry<Id, List<Tuple<Id, Double>>> entry : this.positions.entrySet()) { if (vehicles.contains(entry.getKey())) { XYSeries series = new XYSeries("t", false, true); for (Tuple<Id, Double> pos : entry.getValue()) { Integer stopIdx = stopIndex.get(pos.getFirst()); if (stopIdx != null) { double time = pos.getSecond().doubleValue(); series.add(stopIdx.intValue(), time); if (time < earliestTime) { earliestTime = time; } if (time > latestTime) { latestTime = time; } } } dataset.addSeries(series); numSeries++; } } JFreeChart c = ChartFactory.createXYLineChart("Route-Time Diagram, Route = " + route.getId(), "stops", "time", dataset, PlotOrientation.VERTICAL, false, // legend? false, // tooltips? false // URLs? ); c.setBackgroundPaint(new Color(1.0f, 1.0f, 1.0f, 1.0f)); XYPlot p = (XYPlot) c.getPlot(); p.getRangeAxis().setInverted(true); p.getRangeAxis().setRange(earliestTime, latestTime); XYItemRenderer renderer = p.getRenderer(); for (int i = 0; i < numSeries; i++) { renderer.setSeriesPaint(i, Color.black); } try { ChartUtilities.saveChartAsPNG(new File(filename), c, 1024, 768, null, true, 9); } catch (IOException e) { e.printStackTrace(); } }
From source file:task5.deneme.java
private ChartPanel createChartPanel() { dataset = new HistogramDataset(); final int w = img.getWidth(); final int h = img.getHeight(); JFreeChart chart = ChartFactory.createHistogram("Histogram", "Value", "Count", dataset, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = (XYPlot) chart.getPlot(); renderer = (XYBarRenderer) plot.getRenderer(); renderer.setBarPainter(new StandardXYBarPainter()); double redd[] = new double[red.size()]; for (int i = 0; i < red.size(); i++) { redd[i] = (int) r[i]; }//from w w w . j av a 2s . c o m dataset.addSeries("Red", redd, 256); double greenn[] = new double[green.size()]; for (int i = 0; i < green.size(); i++) { greenn[i] = (int) g[i]; } dataset.addSeries("Green", greenn, 256); double bluee[] = new double[blue.size()]; for (int i = 0; i < blue.size(); i++) { bluee[i] = (int) b[i]; } dataset.addSeries("Blue", bluee, 256); Paint[] paintArray = { new Color(0x80ff0000, true), new Color(0x8000ff00, true), new Color(0x800000ff, true) }; plot.setDrawingSupplier( new DefaultDrawingSupplier(paintArray, DefaultDrawingSupplier.DEFAULT_FILL_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE)); ChartPanel panel = new ChartPanel(chart); panel.setMouseWheelEnabled(true); return panel; }