List of usage examples for org.jfree.chart.renderer.xy XYLineAndShapeRenderer XYLineAndShapeRenderer
public XYLineAndShapeRenderer()
From source file:de.atomfrede.tools.evalutation.tools.plot.TimePlot.java
@Override protected JFreeChart createChart(XYDatasetWrapper... datasetWrappers) { XYDatasetWrapper mainDataset = datasetWrappers[0]; JFreeChart chart = ChartFactory.createTimeSeriesChart(mainDataset.getSeriesName(), "Time", mainDataset.getSeriesName(), mainDataset.getDataset(), true, true, false); XYPlot plot = (XYPlot) chart.getPlot(); // all adjustments for first/main dataset plot.getRangeAxis(0).setLowerBound(mainDataset.getMinimum()); plot.getRangeAxis(0).setUpperBound(mainDataset.getMaximum()); // some additional "design" stuff for the plot plot.getRenderer(0).setSeriesPaint(0, mainDataset.getSeriesColor()); plot.getRenderer(0).setSeriesStroke(0, new BasicStroke(mainDataset.getStroke())); for (int i = 1; i < datasetWrappers.length; i++) { XYDatasetWrapper wrapper = datasetWrappers[i]; plot.setDataset(i, wrapper.getDataset()); chart.setTitle(chart.getTitle().getText() + "/" + wrapper.getSeriesName()); NumberAxis axis = new NumberAxis(wrapper.getSeriesName()); plot.setRangeAxis(i, axis);/* w w w. jav a 2 s .c o m*/ plot.setRangeAxisLocation(i, AxisLocation.BOTTOM_OR_RIGHT); plot.getRangeAxis(i).setLowerBound(wrapper.getMinimum() - 15.0); plot.getRangeAxis(i).setUpperBound(wrapper.getMaximum() + 15.0); // map the second dataset to the second axis plot.mapDatasetToRangeAxis(i, i); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setBaseShapesVisible(false); renderer.setSeriesStroke(0, new BasicStroke(wrapper.getStroke())); plot.setRenderer(i, renderer); plot.getRenderer(i).setSeriesPaint(0, wrapper.getSeriesColor()); } // change the background and gridline colors plot.setBackgroundPaint(Color.white); plot.setDomainMinorGridlinePaint(Color.LIGHT_GRAY); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); // format the date axis DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("dd.MM HH:mm")); axis.setTickUnit(new DateTickUnit(DateTickUnitType.HOUR, 1)); axis.setVerticalTickLabels(true); return chart; }
From source file:com.android.ddmuilib.log.event.DisplaySync.java
/** * Resets the display.//from w ww .ja va 2s . com */ @Override void resetUI() { super.resetUI(); XYPlot xyPlot = mChart.getXYPlot(); XYBarRenderer br = new XYBarRenderer(); mDatasetsSync = new TimePeriodValues[NUM_AUTHS]; @SuppressWarnings("unchecked") List<String> mTooltipsSyncTmp[] = new List[NUM_AUTHS]; mTooltipsSync = mTooltipsSyncTmp; mTooltipGenerators = new CustomXYToolTipGenerator[NUM_AUTHS]; TimePeriodValuesCollection tpvc = new TimePeriodValuesCollection(); xyPlot.setDataset(tpvc); xyPlot.setRenderer(0, br); XYLineAndShapeRenderer ls = new XYLineAndShapeRenderer(); ls.setBaseLinesVisible(false); mDatasetsSyncTickle = new TimeSeries[NUM_AUTHS]; TimeSeriesCollection tsc = new TimeSeriesCollection(); xyPlot.setDataset(1, tsc); xyPlot.setRenderer(1, ls); mDatasetError = new TimeSeries("Errors", FixedMillisecond.class); xyPlot.setDataset(2, new TimeSeriesCollection(mDatasetError)); XYLineAndShapeRenderer errls = new XYLineAndShapeRenderer(); errls.setBaseLinesVisible(false); errls.setSeriesPaint(0, Color.RED); xyPlot.setRenderer(2, errls); for (int i = 0; i < NUM_AUTHS; i++) { br.setSeriesPaint(i, AUTH_COLORS[i]); ls.setSeriesPaint(i, AUTH_COLORS[i]); mDatasetsSync[i] = new TimePeriodValues(AUTH_NAMES[i]); tpvc.addSeries(mDatasetsSync[i]); mTooltipsSync[i] = new ArrayList<String>(); mTooltipGenerators[i] = new CustomXYToolTipGenerator(); br.setSeriesToolTipGenerator(i, mTooltipGenerators[i]); mTooltipGenerators[i].addToolTipSeries(mTooltipsSync[i]); mDatasetsSyncTickle[i] = new TimeSeries(AUTH_NAMES[i] + " tickle", FixedMillisecond.class); tsc.addSeries(mDatasetsSyncTickle[i]); ls.setSeriesShape(i, ShapeUtilities.createUpTriangle(2.5f)); } }
From source file:com.googlecode.logVisualizer.chart.LineChartBuilder.java
private JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createXYLineChart(getTitle(), xLable, yLable, dataset, PlotOrientation.VERTICAL, isIncludeLegend(), true, false); final XYPlot plot = (XYPlot) chart.getPlot(); double lastXValue = 0; if (dataset.getSeriesCount() > 0) lastXValue = dataset.getXValue(0, dataset.getItemCount(0) - 1); plot.setDomainAxis(new FixedZoomNumberAxis(lastXValue)); plot.getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.black); plot.setRangeGridlinePaint(Color.black); plot.setNoDataMessage("No data available"); if (dataset.getSeriesCount() > 0) ((NumberAxis) plot.getDomainAxis()).setUpperBound(lastXValue); ((NumberAxis) plot.getRangeAxis()).setStandardTickUnits(NumberAxis.createIntegerTickUnits()); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); for (int i = 0; i < dataset.getSeriesCount(); i++) { renderer.setSeriesShapesVisible(i, false); renderer.setSeriesStroke(i, new BasicStroke(2)); }/* w ww. ja va 2 s. com*/ renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(renderer); return chart; }
From source file:edu.cuny.cat.ui.SpecialistView.java
private void setupShoutPlots() { final JFreeChart chart = ChartFactory.createTimeSeriesChart("", "Time", "Price", dataset, true, true, false);/*from ww w . j a v a2 s . co m*/ chart.setAntiAlias(true); chart.setBackgroundPaint(getContentPane().getBackground()); xyplot = (XYPlot) chart.getPlot(); xyplot.setNoDataMessage("NO DATA"); xyplot.setRenderer(new XYLineAndShapeRenderer()); final NumberAxis numberaxis1 = (NumberAxis) xyplot.getRangeAxis(); numberaxis1.setTickMarkInsideLength(2.0F); numberaxis1.setTickMarkOutsideLength(0.0F); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setDomainZoomable(true); chartPanel.setRangeZoomable(true); chartPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(20, 5, 5, 20), BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Shouts"), BorderFactory.createEmptyBorder(5, 5, 5, 5)))); getContentPane().add(chartPanel, BorderLayout.CENTER); pack(); }
From source file:com.griddynamics.jagger.reporting.chart.ChartHelper.java
public static JFreeChart createXYChart(String title, XYDataset data, String xLabel, String yLabel, int pointRadius, int lineThickness, ColorTheme theme) { JFreeChart chart = ChartFactory.createXYLineChart(title, xLabel, yLabel, data, PlotOrientation.VERTICAL, true, false, false);//ww w. j a v a 2 s . com formatColorTheme(chart, theme); XYPlot plot = (XYPlot) chart.getPlot(); Shape icon = new Ellipse2D.Double(-pointRadius, -pointRadius, pointRadius * 2, pointRadius * 2); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); plot.setRenderer(renderer); Color[] colors = generateJetSpectrum(data.getSeriesCount()); for (int i = 0; i < data.getSeriesCount(); i++) { plot.getRenderer().setSeriesStroke(i, new BasicStroke(lineThickness)); plot.getRenderer().setSeriesShape(i, icon); ((XYLineAndShapeRenderer) plot.getRenderer()).setSeriesShapesVisible(i, true); ((XYLineAndShapeRenderer) plot.getRenderer()).setSeriesShapesFilled(i, true); plot.getRenderer().setSeriesPaint(i, colors[i]); } LegendTitle legend = chart.getLegend(); Font legendFont = legend.getItemFont(); float legendFontSize = legendFont.getSize(); Font newLegendFont = legendFont.deriveFont(legendFontSize * 0.6f); legend.setItemFont(newLegendFont); ValueAxis domainAxis = ((XYPlot) chart.getPlot()).getDomainAxis(); Font domainAxisLabelFont = domainAxis.getLabelFont(); float domainAxisLabelFontSize = domainAxisLabelFont.getSize(); domainAxis.setLabelFont(domainAxisLabelFont.deriveFont(domainAxisLabelFontSize * 0.6f)); Font domainAxisTickLabelFont = domainAxis.getTickLabelFont(); float domainAxisTickLabelFontSize = domainAxisTickLabelFont.getSize(); domainAxis.setTickLabelFont(domainAxisTickLabelFont.deriveFont(domainAxisTickLabelFontSize * 0.6f)); ValueAxis rangeAxis = ((XYPlot) chart.getPlot()).getRangeAxis(); Font rangeAxisLabelFont = rangeAxis.getLabelFont(); float rangeAxisLabelFontSize = rangeAxisLabelFont.getSize(); rangeAxis.setLabelFont(rangeAxisLabelFont.deriveFont(rangeAxisLabelFontSize * 0.6f)); Font rangeAxisTickLabelFont = rangeAxis.getTickLabelFont(); float rangeAxisTickLabelFontSize = rangeAxisTickLabelFont.getSize(); rangeAxis.setTickLabelFont(rangeAxisTickLabelFont.deriveFont(rangeAxisTickLabelFontSize * 0.6f)); return chart; }
From source file:loldmg.GUI.MainFrame.java
private JFreeChart createChart(final XYDataset dataset) { // create the chart... final JFreeChart newchart = ChartFactory.createXYLineChart("Auto Attack DPS", // chart title "Level", // x axis label "Damage", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls );// ww w . j a va2s .c o m // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... newchart.setBackgroundPaint(Color.GRAY); // get a reference to the plot for further customisation... final XYPlot plot = newchart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, true); 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 newchart; }
From source file:net.sf.mzmine.modules.peaklistmethods.peakpicking.adap3decompositionV1_5.EICPlot.java
public EICPlot(List<List<NavigableMap<Double, Double>>> clusters, List<Double> colors, List<List<String>> info, List<NavigableMap<Double, Double>> modelPeaks) { super(null, true); setBackground(Color.white);/*from ww w. j av a 2s .c o m*/ setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); NumberAxis xAxis = new NumberAxis("Retention Time"); xAxis.setAutoRangeIncludesZero(false); xAxis.setUpperMargin(0); xAxis.setLowerMargin(0); NumberAxis yAxis = new NumberAxis("Intensity"); yAxis.setAutoRangeIncludesZero(false); yAxis.setUpperMargin(0); yAxis.setLowerMargin(0); xyDataset = new XYSeriesCollection(); colorDataset = new ArrayList<>(); toolTips = new ArrayList<>(); int seriesID = 0; for (int i = 0; i < clusters.size(); ++i) { List<NavigableMap<Double, Double>> cluster = clusters.get(i); double color = colors.get(i); for (int j = 0; j < cluster.size(); ++j) { XYSeries series = new XYSeries(seriesID++); for (Entry<Double, Double> e : cluster.get(j).entrySet()) series.add(e.getKey(), e.getValue()); xyDataset.addSeries(series); colorDataset.add(color); toolTips.add(info.get(i).get(j)); } } XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer() { @Override public Paint getItemPaint(int row, int col) { double c = colorDataset.get(row); return Color.getHSBColor((float) c, 1.0f, 1.0f); } }; renderer.setDefaultShapesVisible(false); renderer.setDefaultToolTipGenerator(new XYToolTipGenerator() { @Override public String generateToolTip(XYDataset dataset, int series, int item) { try { return toolTips.get(series); } catch (NullPointerException | IndexOutOfBoundsException e) { return ""; } } }); XYPlot plot = new XYPlot(xyDataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinesVisible(true); JFreeChart chart = new JFreeChart("", new Font("SansSerif", Font.BOLD, 12), plot, false); chart.setBackgroundPaint(Color.white); super.setChart(chart); }
From source file:ejemplo.Ejemplo.java
private JFreeChart createChart(final XYDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart("Line Chart Demo 6", // chart title "X", // x axis label "Y", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls );/* w w w . ja v a 2 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:org.azrul.langmera.LineChart.java
/** * Creates a chart./*w ww. ja va2 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(this.getTitle(), // chart title "Number of messages", // x axis label "Value of actions", // 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(); for (int i = 0; i < dataset.getSeriesCount(); i++) { renderer.setSeriesStroke(i, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 10.0f, 6.0f }, 0.0f)); } return chart; }
From source file:org.optaplanner.benchmark.impl.statistic.calculatecount.CalculateCountProblemStatistic.java
@Override public void writeGraphFiles(BenchmarkReport benchmarkReport) { Locale locale = benchmarkReport.getLocale(); NumberAxis xAxis = new NumberAxis("Time spent"); xAxis.setNumberFormatOverride(new MillisecondsSpentNumberFormat(locale)); NumberAxis yAxis = new NumberAxis("Calculate count per second"); yAxis.setNumberFormatOverride(NumberFormat.getInstance(locale)); yAxis.setAutoRangeIncludesZero(false); XYPlot plot = new XYPlot(null, xAxis, yAxis, null); plot.setOrientation(PlotOrientation.VERTICAL); int seriesIndex = 0; for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) { XYSeries series = new XYSeries( singleBenchmarkResult.getSolverBenchmarkResult().getNameWithFavoriteSuffix()); XYItemRenderer renderer = new XYLineAndShapeRenderer(); if (singleBenchmarkResult.isSuccess()) { CalculateCountSingleStatistic singleStatistic = (CalculateCountSingleStatistic) singleBenchmarkResult .getSingleStatistic(problemStatisticType); for (CalculateCountStatisticPoint point : singleStatistic.getPointList()) { long timeMillisSpent = point.getTimeMillisSpent(); long calculateCountPerSecond = point.getCalculateCountPerSecond(); series.add(timeMillisSpent, calculateCountPerSecond); }/*from w ww .jav a 2 s. co m*/ } plot.setDataset(seriesIndex, new XYSeriesCollection(series)); if (singleBenchmarkResult.getSolverBenchmarkResult().isFavorite()) { // Make the favorite more obvious renderer.setSeriesStroke(0, new BasicStroke(2.0f)); } plot.setRenderer(seriesIndex, renderer); seriesIndex++; } JFreeChart chart = new JFreeChart(problemBenchmarkResult.getName() + " calculate count statistic", JFreeChart.DEFAULT_TITLE_FONT, plot, true); graphFile = writeChartToImageFile(chart, problemBenchmarkResult.getName() + "CalculateCountStatistic"); }