List of usage examples for org.jfree.chart.plot XYPlot setRenderer
public void setRenderer(XYItemRenderer renderer)
From source file:required.ChartPlotter.java
/** * Creates a chart.//www . j ava2 s. co 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:physical_network.OscilloscopePanel.java
public OscilloscopePanel() { super("Oscilloscope"); // Set initial (time, voltage) datapoint of (0.0, 0.0). voltages.add(0.0, 0.0);//from w w w. j av a2 s . c om XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(voltages); JFreeChart chart = ChartFactory.createXYLineChart("Oscilloscope", "Time (seconds)", "Voltage", dataset, PlotOrientation.VERTICAL, true, false, false); XYPlot plot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, true); NumberAxis domain = (NumberAxis) plot.getDomainAxis(); domain.setRange(0.0, 10.0); domain.setTickUnit(new NumberTickUnit(1.0)); domain.setVerticalTickLabels(true); NumberAxis range = (NumberAxis) plot.getRangeAxis(); range.setRange(-5.0, 5.0); range.setTickUnit(new NumberTickUnit(1.0)); plot.setRenderer(renderer); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 300)); setContentPane(chartPanel); }
From source file:pharoslabut.logger.CompassLoggerGUI.java
/** * Creates a chart./*from w w w . jav a2 s . 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("Proteus Robot Compass Measurements", // chart title "Time (s)", // x axis label "Angle (radians)", // y axis label dataset, // data PlotOrientation.VERTICAL, false, // 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 customization... 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); final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setRange(new Range(0, 140)); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); // change the auto tick unit selection to integer units only... // rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setRange(new Range(-Math.PI, Math.PI)); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:msi.gama.hpc.gui.perspective.chart.HeadlessChart.java
private JFreeChart createChart(final XYDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart("Line Chart from XML output file", // chart title "X", // x axis label "Y", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls );//from ww w.j av a2 s . co m // 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:Main.Chart.java
/** * Creates a chart.// ww w . j a v a 2 s . 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("Weather Forecast", // chart title "Time", // x axis label "Temperature", // 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:iDynoOptimizer.MOEAFramework26.src.org.moeaframework.analysis.diagnostics.ApproximationSetPlot.java
@Override protected void update() { XYSeriesCollection dataset = new XYSeriesCollection(); for (ResultKey key : frame.getSelectedResults()) { NondominatedPopulation population = new EpsilonBoxDominanceArchive(EPSILON); for (Accumulator accumulator : controller.get(key)) { if (!accumulator.keySet().contains(metric)) { continue; }//ww w .j av a2 s .c o m List<?> list = (List<?>) accumulator.get(metric, accumulator.size(metric) - 1); for (Object object : list) { population.add((Solution) object); } } if (!population.isEmpty()) { XYSeries series = new XYSeries(key, false, true); for (Solution solution : population) { if (solution.getNumberOfObjectives() == 1) { series.add(solution.getObjective(0), solution.getObjective(0)); } else if (solution.getNumberOfObjectives() > 1) { series.add(solution.getObjective(0), solution.getObjective(1)); } } dataset.addSeries(series); } } JFreeChart chart = ChartFactory.createScatterPlot(metric, localization.getString("text.objective", 1), localization.getString("text.objective", 2), dataset, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = chart.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true); for (int i = 0; i < dataset.getSeriesCount(); i++) { Paint paint = frame.getPaintHelper().get(dataset.getSeriesKey(i)); renderer.setSeriesStroke(i, new BasicStroke(3f, 1, 1)); renderer.setSeriesPaint(i, paint); renderer.setSeriesFillPaint(i, paint); } plot.setRenderer(renderer); //add overlay if (controller.getShowLastTrace() && (controller.getLastAccumulator() != null) && controller.getLastAccumulator().keySet().contains(metric)) { XYSeriesCollection dataset2 = new XYSeriesCollection(); NondominatedPopulation population = new EpsilonBoxDominanceArchive(EPSILON); if (controller.getLastAccumulator().keySet().contains(metric)) { List<?> list = (List<?>) controller.getLastAccumulator().get(metric, controller.getLastAccumulator().size(metric) - 1); for (Object object : list) { population.add((Solution) object); } } if (!population.isEmpty()) { XYSeries series = new XYSeries(localization.getString("text.last"), false, true); for (Solution solution : population) { series.add(solution.getObjective(0), solution.getObjective(1)); } dataset2.addSeries(series); } XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(false, true); renderer2.setSeriesPaint(0, Color.BLACK); plot.setDataset(1, dataset2); plot.setRenderer(1, renderer2); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); } removeAll(); add(new ChartPanel(chart), BorderLayout.CENTER); revalidate(); repaint(); }
From source file:fr.ens.transcriptome.corsen.gui.qt.ResultGraphs.java
/** * Create a scatter plot//from w w w. j a v a 2 s . c om * @param particles Particle data to use * @param title Title of the graph * @return a QImage */ public QImage createScatterPlot(final Particles3D particles, final String title, final String unit) { if (particles == null) return null; List<Particle3D> pars = particles.getParticles(); final int count = pars.size(); final double[][] data = new double[2][]; data[0] = new double[count]; data[1] = new double[count]; int i = 0; for (Particle3D p : pars) { data[0][i] = p.getIntensity(); data[1][i] = p.getVolume(); i++; } DefaultXYDataset xydataset = new DefaultXYDataset(); xydataset.addSeries("data", data); JFreeChart chart = ChartFactory.createScatterPlot(title, "Intensity", "Volume" + unitLegendCude(unit), xydataset, PlotOrientation.VERTICAL, false, true, false); addTransparency(chart); XYPlot xyplot = (XYPlot) chart.getPlot(); XYDotRenderer xydotrenderer = new XYDotRenderer(); xydotrenderer.setDotWidth(2); xydotrenderer.setDotHeight(2); xyplot.setRenderer(xydotrenderer); NumberAxis numberaxis = (NumberAxis) xyplot.getDomainAxis(); numberaxis.setAutoRangeIncludesZero(false); final BufferedImage image = chart.createBufferedImage(this.width, this.height, BufferedImage.TYPE_INT_ARGB, null); return new QImage(toByte(image.getData().getDataBuffer()), this.width, this.height, QImage.Format.Format_ARGB32); }
From source file:edu.utexas.ece.pharos.proteus3.sensors.CompassChartGUI.java
/** * Creates a chart./*from ww w . ja va 2 s . 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("Proteus III Compass Measurements", // chart title "Time (s)", // x axis label "Angle (degrees)", // y axis label dataset, // data PlotOrientation.VERTICAL, false, // 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 customization... 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); final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setRange(new Range(0, 140)); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); // change the auto tick unit selection to integer units only... // rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); //rangeAxis.setRange(new Range(-Math.PI, Math.PI)); rangeAxis.setRange(new Range(-180, 180)); return chart; }
From source file:de.tud.kom.p2psim.impl.skynet.visualization.MetricsPlot.java
private void createChartPanel(String title, long time) { YIntervalSeriesCollection dataset = new YIntervalSeriesCollection(); chart = ChartFactory.createTimeSeriesChart(title, X_AXIS_TITLE, "", dataset, true, true, true); XYPlot plot = (XYPlot) chart.getPlot(); DeviationRenderer errorRenderer = new DeviationRenderer(); errorRenderer.setShapesVisible(false); errorRenderer.setLinesVisible(true); errorRenderer.setAlpha(0.0f);// www. ja v a 2s . co m // errorRenderer.setDrawYError(false); // errorRenderer.setDrawXError(false); plot.setRenderer(errorRenderer); plot.setBackgroundPaint(Color.WHITE); plot.setRangeGridlinePaint(Color.DARK_GRAY); plot.setDomainGridlinePaint(Color.DARK_GRAY); upperDomainBound = (time / 1000) + ((interval - 1) * step / 1000); DateAxis domain = (DateAxis) plot.getDomainAxis(); domain.setAutoRange(false); domain.setRange((time / 1000), upperDomainBound); RelativeDateFormat rdf = new RelativeDateFormat(); rdf.setHourSuffix(":"); rdf.setMinuteSuffix(":"); rdf.setSecondSuffix(""); rdf.setSecondFormatter(new DecimalFormat("0")); domain.setDateFormatOverride(rdf); plot.setDomainAxis(domain); plotPanel = new ChartPanel(chart, true); setSizeOfComponent(plotPanel, new Dimension(plotWidth, plotHeight)); container.add(plotPanel, BorderLayout.CENTER); container.add(createRadioBoxes(visType == VisualizationType.Metric), BorderLayout.SOUTH); setSizeOfComponent(container, new Dimension(plotWidth, plotHeight + boxOffset)); }
From source file:model.LineChart.java
/** * Creates a chart.// ww w. j a v a 2 s . c o m * * @param dataset the data for the chart. * * @return a chart. */ private JFreeChart createChart(final XYDataset dataset, final int variableOption, final String machine) { String title = ""; switch (variableOption) { case 0: title = "Quantity"; break; case 1: title = "Size"; break; default: title = "Type"; break; } // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart(title + " Line Chart: " + machine, // chart title title, // x axis label "Time", // 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; }