/** * Builds and returns JFreeChart. * * @return */ public JFreeChart build() { XYSeriesCollection collection = new XYSeriesCollection(); for (XYSeries s : seriesMap.values()) { collection.addSeries(s); } JFreeChart chart = ChartFactory.createXYLineChart(chartName, xDomain, yDomain, collection, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); return chart; }
/** * Updates the general properties of a plot. * * @param aPlot * Plot to be updated. * @param aGeneral * General visual settings to be applied. */ private static void updateGeneral(XYPlot aPlot, GeneralVisSettings aGeneral) { aPlot.setBackgroundPaint(aGeneral.getBgColor()); }
private XYPlot createPlot(final XYSeriesCollection problem, XYSeriesCollection shipments, XYSeriesCollection solution) { XYPlot plot = new XYPlot(); plot.setBackgroundPaint(Color.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); XYLineAndShapeRenderer problemRenderer = getProblemRenderer(problem); plot.setDataset(0, problem); plot.setRenderer(0, problemRenderer); XYItemRenderer shipmentsRenderer = getShipmentRenderer(shipments); plot.setDataset(1, shipments); plot.setRenderer(1, shipmentsRenderer); if (solution != null) { XYItemRenderer solutionRenderer = getRouteRenderer(solution); plot.setDataset(2, solution); plot.setRenderer(2, solutionRenderer); } NumberAxis xAxis = new NumberAxis(); NumberAxis yAxis = new NumberAxis(); if (boundingBox == null) { xAxis.setRangeWithMargins(getDomainRange(problem)); yAxis.setRangeWithMargins(getRange(problem)); } else { xAxis.setRangeWithMargins(new Range(boundingBox.minX, boundingBox.maxX)); yAxis.setRangeWithMargins(new Range(boundingBox.minY, boundingBox.maxY)); } plot.setDomainAxis(xAxis); plot.setRangeAxis(yAxis); return plot; }
public XYChartBuilder(final JFreeChart chart) { this.chart = chart; plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); plot.setOutlineVisible(false); }
private JFreeChart createChart() { final XYDataset dataset = this.createDataset(series); final JFreeChart result = ChartFactory.createTimeSeriesChart("Dynamic Line And TimeSeries Chart", "Time", "Value", dataset, true, true, false); final XYPlot plot = result.getXYPlot(); plot.setBackgroundPaint(new Color(0xffffe0)); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); // first time series this.firstTimeSeries(plot); // second time series this.secondTimeSeries(plot); // third time series this.thirdTimeSeries(plot); return result; }
public OperationsVersusSizePlot( String title, String ylabel) { chart = ChartFactory.createXYLineChart(title, "Matrix Size", ylabel, null, PlotOrientation.VERTICAL, true , false , false ); // chart.removeLegend(); plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); // final NumberAxis rangeAxis = new LogarithmicAxis(ylabel); // plot.setRangeAxis(rangeAxis); // one of the numbers is getting cropped. this will make it fully visible chart.setPadding(new RectangleInsets(5,0,0,5)); }
/** * Builds and returns JFreeChart. * * @return */ public JFreeChart build() { XYSeriesCollection collection = new XYSeriesCollection(); for (XYSeries s : seriesMap.values()) { collection.addSeries(s); } JFreeChart chart = ChartFactory.createXYLineChart(chartName, xDomain, yDomain, collection, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); return chart; }
public static void decorateChart(JFreeChart chart) { XYPlot plot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(0, true); renderer.setSeriesShape(0, new java.awt.geom.Ellipse2D.Double(0, 0, 2, 2)); plot.setBackgroundPaint(java.awt.Color.WHITE); plot.setDomainGridlinePaint(java.awt.Color.GRAY); plot.setRangeGridlinePaint(java.awt.Color.GRAY); plot.setRenderer(renderer); }
public void drawChart(String filename, int width, int height) throws IOException { // Create plot NumberAxis xAxis = new NumberAxis(xAxisLabel); NumberAxis yAxis = new NumberAxis(yAxisLabel); XYSplineRenderer renderer = new XYSplineRenderer(); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(4, 4, 4, 4)); // Create chart JFreeChart chart = new JFreeChart(chartTitle, JFreeChart.DEFAULT_TITLE_FONT, plot, true); ChartUtilities.applyCurrentTheme(chart); ChartPanel chartPanel = new ChartPanel(chart, false); // Draw png BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR); Graphics graphics = bi.getGraphics(); chartPanel.setBounds(0, 0, width, height); chartPanel.paint(graphics); ImageIO.write(bi, "png", new File(filename)); }
public void drawChart(String filename, int width, int height) throws IOException { // Create plot NumberAxis xAxis = new NumberAxis(xAxisLabel); NumberAxis yAxis = new NumberAxis(yAxisLabel); XYSplineRenderer renderer = new XYSplineRenderer(); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(4, 4, 4, 4)); // Create chart JFreeChart chart = new JFreeChart(chartTitle, JFreeChart.DEFAULT_TITLE_FONT, plot, true); ChartUtilities.applyCurrentTheme(chart); ChartPanel chartPanel = new ChartPanel(chart, false); // Draw png BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR); Graphics graphics = bi.getGraphics(); chartPanel.setBounds(0, 0, width, height); chartPanel.paint(graphics); ImageIO.write(bi, "png", new File(filename)); }
public static void setupPlot(XYPlot plot) { plot.setBackgroundPaint(ChartDefaults.transparent); plot.setOutlinePaint(ChartDefaults.transparent); plot.setRangeGridlinePaint(ChartDefaults.gridLineColor); plot.setRangeGridlineStroke(new BasicStroke(0.5f)); plot.setRangeGridlinesVisible(true); plot.setRangeAxisLocation(ChartDefaults.rangeAxisLocation); plot.setDomainGridlinesVisible(true); ChartUtil.setupRangeAxis(plot.getRangeAxis()); ChartUtil.setupDomainAxis(plot.getDomainAxis()); }
public static void setupPlot(XYPlot plot) { plot.setBackgroundPaint(ChartDefaults.transparent); plot.setOutlinePaint(ChartDefaults.transparent); plot.setRangeGridlinePaint(ChartDefaults.gridLineColor); plot.setRangeGridlineStroke(new BasicStroke(0.5f)); plot.setRangeGridlinesVisible(true); plot.setRangeAxisLocation(ChartDefaults.rangeAxisLocation); plot.setDomainGridlinesVisible(true); ChartUtil.setupRangeAxis(plot.getRangeAxis()); ChartUtil.setupDomainAxis(plot.getDomainAxis()); }
private void initPlot() { final ValueAxis domainAxis = timeSeriesPlot.getDomainAxis(); domainAxis.setAutoRange(true); XYLineAndShapeRenderer xyRenderer = new XYLineAndShapeRenderer(true, true); xyRenderer.setBaseLegendTextPaint(DEFAULT_FOREGROUND_COLOR); timeSeriesPlot.setRenderer(xyRenderer); timeSeriesPlot.setBackgroundPaint(DEFAULT_BACKGROUND_COLOR); timeSeriesPlot.setNoDataMessage(NO_DATA_MESSAGE); timeSeriesPlot.setDrawingSupplier(null); }
private static TimeSeriesCollection addSubPlot(CombinedDomainXYPlot plot, String label) { final TimeSeriesCollection seriesCollection = new TimeSeriesCollection(new TimeSeries(label, Millisecond.class)); NumberAxis rangeAxis = new NumberAxis(); rangeAxis.setAutoRangeIncludesZero(false); XYPlot subplot = new XYPlot(seriesCollection, null, rangeAxis, new StandardXYItemRenderer()); subplot.setBackgroundPaint(Color.lightGray); subplot.setDomainGridlinePaint(Color.white); subplot.setRangeGridlinePaint(Color.white); plot.add(subplot); return seriesCollection; }
private static TimeSeriesCollection addSubPlot(CombinedDomainXYPlot plot, String label) { final TimeSeriesCollection seriesCollection = new TimeSeriesCollection(new TimeSeries(label, Millisecond.class)); NumberAxis rangeAxis = new NumberAxis(); rangeAxis.setAutoRangeIncludesZero(false); XYPlot subplot = new XYPlot(seriesCollection, null, rangeAxis, new StandardXYItemRenderer()); subplot.setBackgroundPaint(Color.lightGray); subplot.setDomainGridlinePaint(Color.white); subplot.setRangeGridlinePaint(Color.white); plot.add(subplot); return seriesCollection; }
/** * Creates a chart. * * @param dataset * a dataset. * * @return A chart. */ private JFreeChart createChart(SimpleHistogramDataset dataset) { chart = ChartFactory.createHistogram(null, engl("Value"), engl("Histogram"), dataset, PlotOrientation.VERTICAL, false, true, false); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.getRenderer().setSeriesPaint(0, new Color(0x7f9f51)); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); return chart; }
private XYPlot createPlotArea(JFreeChart chart) { XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(WHITE); plot.setDomainGridlinePaint(LIGHT_GRAY); plot.setRangeGridlinePaint(LIGHT_GRAY); plot.setAxisOffset(new RectangleInsets(2.0, 2.0, 2.0, 2.0)); showCrosshairsOnAxes(plot); configureDomainAxis(plot); showGridlinesOnChart(plot); configureTimeAxis(plot); configureTitle(chart); addNotice(chart); return plot; }
private XYPlot createPlotArea(JFreeChart chart) { XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); plot.setAxisOffset(new RectangleInsets(2.0, 2.0, 2.0, 2.0)); showCrosshairsOnAxes(plot); configureDomainAxis(plot); showGridlinesOnChart(plot); configureTimeAxis(plot); configureTitle(chart); addNotice(chart); return plot; }
static private final void setBackgroundDefault(final JFreeChart chart) { BasicStroke gridStroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[]{2.0f, 1.0f}, 0.0f); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRangeGridlineStroke(gridStroke); plot.setDomainGridlineStroke(gridStroke); plot.setBackgroundPaint(new Color(235, 235, 235)); plot.setRangeGridlinePaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setOutlineVisible(false); plot.getDomainAxis().setAxisLineVisible(false); plot.getRangeAxis().setAxisLineVisible(false); plot.getDomainAxis().setLabelPaint(Color.gray); plot.getRangeAxis().setLabelPaint(Color.gray); plot.getDomainAxis().setTickLabelPaint(Color.gray); plot.getRangeAxis().setTickLabelPaint(Color.gray); chart.getTitle().setPaint(Color.gray); } }
private final void setBackgroundDefault(final JFreeChart chart) { final BasicStroke gridStroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 2.0f, 1.0f }, 0.0f); final XYPlot plot = (XYPlot) chart.getPlot(); plot.setRangeGridlineStroke(gridStroke); plot.setDomainGridlineStroke(gridStroke); plot.setBackgroundPaint(new Color(235, 235, 235)); plot.setRangeGridlinePaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setOutlineVisible(false); plot.getDomainAxis().setAxisLineVisible(false); plot.getRangeAxis().setAxisLineVisible(false); plot.getDomainAxis().setLabelPaint(Color.gray); plot.getRangeAxis().setLabelPaint(Color.gray); plot.getDomainAxis().setTickLabelPaint(Color.gray); plot.getRangeAxis().setTickLabelPaint(Color.gray); final TextTitle title = chart.getTitle(); if (title != null) title.setPaint(Color.black); }