List of usage examples for org.jfree.chart.block BlockBorder NONE
BlockBorder NONE
To view the source code for org.jfree.chart.block BlockBorder NONE.
Click Source Link
From source file:DataCharts.LineGraph.java
public static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart("Customers by Month", "Months", "Customers", dataset); String fontName = "SansSerif"; chart.getTitle().setFont(new Font(fontName, Font.BOLD, 18)); chart.addSubtitle(new TextTitle(" ", new Font(fontName, Font.PLAIN, 14))); XYPlot plot = (XYPlot) chart.getPlot(); plot.setDomainPannable(false);//from w w w. ja v a 2 s . co m plot.setRangePannable(false); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.getDomainAxis().setLowerMargin(0.0); plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); chart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14)); chart.getLegend().setFrame(BlockBorder.NONE); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setDrawSeriesLineAsPath(false); // set the default stroke for all series renderer.setAutoPopulateSeriesStroke(false); } return chart; }
From source file:utils.Graphs.java
public static File generate(File baseFolder, String titles[], int[] values, Color backgroundColor) { DefaultPieDataset dataset = new DefaultPieDataset(); // add our data values int i = -1;// w ww . jav a 2 s.com for (String title : titles) { i++; dataset.setValue(title, values[i]); } final JFreeChart chart = // ChartFactory.createPieChart("", dataset, true, true, false); ChartFactory.createPieChart("", // chart title dataset, // data true, // include legend true, false); PiePlot plot = (PiePlot) chart.getPlot(); //PiePlot3D plot = (PiePlot3D) chart.getPlot(); //plot.setStartAngle(290); plot.setStartAngle(45); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); // final PiePlot plot = (PiePlot) chart.getPlot(); plot.setBackgroundPaint(backgroundColor); // plot.setLegendLabelGenerator( // new StandardPieSectionLabelGenerator("{0} {2}")); chart.setBorderVisible(false); chart.getPlot().setOutlineVisible(false); chart.getLegend().setFrame(BlockBorder.NONE); // get the same background chart.setBackgroundPaint(backgroundColor); chart.getLegend().setBackgroundPaint(backgroundColor); // hide the shadow effects plot.setShadowXOffset(0); plot.setShadowYOffset(0); //chart.getLegend().setVisible(false); plot.setCircular(true); //plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} {2}", NumberFormat.getNumberInstance(), NumberFormat plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{2}", NumberFormat.getNumberInstance(), NumberFormat.getPercentInstance())); plot.setNoDataMessage("No data found."); Color greenColor = new Color(0x8FBC0C); Color redColor = new Color(0xFF0000); //Color redColor = new Color(0xDA6022); plot.setSectionPaint(0, greenColor); plot.setSectionPaint(1, redColor); plot.setSectionOutlinesVisible(true); final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); final File file = new File(baseFolder, "chart.png"); try { ChartUtilities.saveChartAsPNG(file, chart, 200, 160, info); } catch (IOException ex) { Logger.getLogger(Graphs.class.getName()).log(Level.SEVERE, null, ex); } // //// final ChartPanel chartPanel = new ChartPanel(chart, true); // final ChartPanel chartPanel = new ChartPanel(chart, true); // chartPanel.setMinimumDrawWidth(0); // chartPanel.setMaximumDrawWidth(Integer.MAX_VALUE); // chartPanel.setMinimumDrawHeight(0); // chartPanel.setMaximumDrawHeight(Integer.MAX_VALUE); // JDialog dialog = new JDialog(); // dialog.add(chartPanel); // dialog.setLayout(new GridLayout(1, 1)); // dialog.setSize(400, 200); // dialog.setVisible(true); return file; }
From source file:de.hs.mannheim.modUro.controller.diagram.DiagramController.java
/** * Creates JFreeChart. XYLineDiagram.//from w w w . j av a2 s. co m * * @param dataset * @return */ protected JFreeChart createChart(XYDataset dataset, String metricTypeName) { String title = metricTypeName; JFreeChart xyLineChart = ChartFactory.createXYLineChart(title, // title "t", // x-axis label "f", // y-axis label dataset); String fontName = "Palatino"; xyLineChart.getTitle().setFont(new Font(fontName, Font.BOLD, 18)); XYPlot plot = (XYPlot) xyLineChart.getPlot(); plot.setDomainPannable(true); plot.setRangePannable(true); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.getDomainAxis().setLowerMargin(0.0); plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); plot.getRangeAxis().setLowerMargin(0.0); plot.getRangeAxis().setRange(0.0, 1.01); plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); xyLineChart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14)); xyLineChart.getLegend().setFrame(BlockBorder.NONE); xyLineChart.getLegend().setHorizontalAlignment(HorizontalAlignment.CENTER); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(false); renderer.setDrawSeriesLineAsPath(true); // set the default stroke for all series renderer.setAutoPopulateSeriesStroke(false); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, new Color(24, 123, 58)); renderer.setSeriesPaint(2, new Color(149, 201, 136)); renderer.setSeriesPaint(3, new Color(1, 62, 29)); renderer.setSeriesPaint(4, new Color(81, 176, 86)); renderer.setSeriesPaint(5, new Color(0, 55, 122)); renderer.setSeriesPaint(6, new Color(0, 92, 165)); } return xyLineChart; }
From source file:de.hs.mannheim.modUro.diagram.JCellCountDiagram.java
protected JFreeChart createChart(XYDataset dataset, String name) { String title = name;//from w ww . j av a 2 s .c o m JFreeChart xyLineChart = ChartFactory.createXYLineChart(title, // title "t", // x-axis label "n", // y-axis label dataset); String fontName = "Palatino"; xyLineChart.getTitle().setFont(new Font(fontName, Font.BOLD, 18)); XYPlot plot = (XYPlot) xyLineChart.getPlot(); plot.setDomainPannable(true); plot.setRangePannable(true); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.getDomainAxis().setLowerMargin(0.0); plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); plot.getRangeAxis().setLowerMargin(0.0); // plot.getRangeAxis().setRange(0.0, 1.01); plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.gray); xyLineChart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14)); xyLineChart.getLegend().setFrame(BlockBorder.NONE); xyLineChart.getLegend().setHorizontalAlignment(HorizontalAlignment.CENTER); XYItemRenderer r = plot.getRenderer(); // set the default stroke for all series int i = 0; for (String celltype : getTimeSeries().getDataSeriesNames()) { r.setSeriesPaint(i, CellTypeColor.getColor(celltype)); i++; } r.setSeriesPaint(i, Color.BLACK); return xyLineChart; }
From source file:edu.cudenver.bios.chartsvc.representation.LegendImageRepresentation.java
/** * Called internally by Restlet library to write the image as the HTTP * response.// w ww.ja v a 2 s . c o m * @param out output stream */ @Override public void write(OutputStream out) throws IOException { // build the legend from the plot, and write it to a jpeg image if (plot != null) { LegendTitle legend = new LegendTitle(plot, new ColumnArrangement(), new ColumnArrangement()); legend.setFrame(BlockBorder.NONE); //legend.setMargin(new RectangleInsets(2.0, 2.0, 2.0, 2.0)); legend.setBackgroundPaint(Color.white); legend.setPosition(RectangleEdge.BOTTOM); BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics2D g = image.createGraphics(); Rectangle2D.Double legendArea = new Rectangle2D.Double(0, 0, width, height); g.clip(legendArea); legend.arrange(g, new RectangleConstraint(width, height)); legend.draw(g, legendArea); g.dispose(); EncoderUtil.writeBufferedImage(image, ImageFormat.JPEG, out); } }
From source file:uom.research.thalassemia.util.BarChartCreator.java
/** * Creates a sample chart./*from w w w. ja v a 2 s.co m*/ * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final CategoryDataset dataset) { JFreeChart chart = ChartFactory.createBarChart(mainTitle, xTitle, yTitle, dataset); chart.addSubtitle(new TextTitle(subTitle)); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); chart.getLegend().setFrame(BlockBorder.NONE); return chart; }
From source file:com.pasi.pdfbox.Main.java
private static JFreeChart createBarChart() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(7445, "JFreeSVG", "Warm-up"); dataset.addValue(24448, "Batik", "Warm-up"); dataset.addValue(4297, "JFreeSVG", "Test"); dataset.addValue(21022, "Batik", "Test"); JFreeChart chart = ChartFactory.createBarChart("Performance: JFreeSVG vs Batik", null /* x-axis label*/, "Milliseconds" /* y-axis label */, dataset); chart.addSubtitle(//from w w w .ja v a 2 s.c o m new TextTitle("Time to generate 1000 charts in SVG " + "format (lower bars = better performance)")); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); chart.getLegend().setFrame(BlockBorder.NONE); return chart; }
From source file:com.orsonpdf.demo.PDFTimeSeriesChartDemo1.java
/** * Creates a chart./*from w w w.j av a2s.c o m*/ * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart("International Coffee Organisation : Coffee Prices", null, "US cents/lb", dataset, true, false, false); String fontName = "Palatino"; chart.getTitle().setFont(new Font(fontName, Font.BOLD, 18)); chart.addSubtitle(new TextTitle("Source: http://www.ico.org/historical/2010-19/PDF/HIST-PRICES.pdf", new Font(fontName, Font.PLAIN, 14))); XYPlot plot = (XYPlot) chart.getPlot(); plot.setDomainPannable(true); plot.setRangePannable(false); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.getDomainAxis().setLowerMargin(0.0); plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); plot.setRangeGridlinePaint(Color.red); plot.setDomainGridlinePaint(Color.red); chart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14)); chart.getLegend().setFrame(BlockBorder.NONE); chart.getLegend().setHorizontalAlignment(HorizontalAlignment.CENTER); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(false); renderer.setDrawSeriesLineAsPath(true); // set the default stroke for all series renderer.setAutoPopulateSeriesStroke(false); renderer.setBaseStroke(new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL), false); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, new Color(24, 123, 58)); renderer.setSeriesPaint(2, new Color(149, 201, 136)); renderer.setSeriesPaint(3, new Color(1, 62, 29)); renderer.setSeriesPaint(4, new Color(81, 176, 86)); renderer.setSeriesPaint(5, new Color(0, 55, 122)); renderer.setSeriesPaint(6, new Color(0, 92, 165)); } return chart; }
From source file:org.jfree.graphics2d.demo.SVGTimeSeriesChartDemo1.java
/** * Creates a chart./* w w w . jav a 2s. c o m*/ * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart("International Coffee Organisation : Coffee Prices", null, "US cents/lb", dataset); String fontName = "Palatino"; chart.getTitle().setFont(new Font(fontName, Font.BOLD, 18)); chart.addSubtitle(new TextTitle("Source: http://www.ico.org/historical/2010-19/PDF/HIST-PRICES.pdf", new Font(fontName, Font.PLAIN, 14))); XYPlot plot = (XYPlot) chart.getPlot(); plot.setDomainPannable(true); plot.setRangePannable(false); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.getDomainAxis().setLowerMargin(0.0); plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); plot.setRangeGridlinePaint(Color.GRAY); plot.setDomainGridlinePaint(Color.GRAY); chart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14)); chart.getLegend().setFrame(BlockBorder.NONE); chart.getLegend().setHorizontalAlignment(HorizontalAlignment.CENTER); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(false); renderer.setDrawSeriesLineAsPath(true); // set the default stroke for all series renderer.setAutoPopulateSeriesStroke(false); renderer.setDefaultStroke(new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL), false); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, new Color(24, 123, 58)); renderer.setSeriesPaint(2, new Color(149, 201, 136)); renderer.setSeriesPaint(3, new Color(1, 62, 29)); renderer.setSeriesPaint(4, new Color(81, 176, 86)); renderer.setSeriesPaint(5, new Color(0, 55, 122)); renderer.setSeriesPaint(6, new Color(0, 92, 165)); } return chart; }
From source file:net.sf.mzmine.modules.visualization.histogram.HistogramChart.java
public HistogramChart() { super(null, true); // initialize the chart by default time series chart from factory chart = ChartFactory.createHistogram("", // title "", // x-axis label "", // y-axis label null, // data set PlotOrientation.VERTICAL, // orientation true, // create legend false, // generate tooltips false // generate URLs );/*w w w. j a v a2 s . c om*/ // title chartTitle = chart.getTitle(); chartTitle.setFont(titleFont); chartTitle.setMargin(5, 0, 0, 0); chartSubTitle = new TextTitle(); chartSubTitle.setFont(subTitleFont); chartSubTitle.setMargin(5, 0, 0, 0); chart.addSubtitle(chartSubTitle); // legend constructed by ChartFactory LegendTitle legend = chart.getLegend(); legend.setItemFont(legendFont); legend.setFrame(BlockBorder.NONE); chart.setBackgroundPaint(Color.white); setChart(chart); // disable maximum size (we don't want scaling) setMaximumDrawWidth(Integer.MAX_VALUE); setMaximumDrawHeight(Integer.MAX_VALUE); // set the plot properties plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE); plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD); // set grid properties plot.setDomainGridlinePaint(gridColor); plot.setRangeGridlinePaint(gridColor); // set crosshair (selection) properties plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(true); // set the logarithmic axis NumberAxis axisDomain = new HistogramDomainAxis(); axisDomain.setMinorTickCount(1); axisDomain.setAutoRange(true); NumberAxis axisRange = new NumberAxis(); axisRange.setMinorTickCount(1); axisRange.setAutoRange(true); plot.setDomainAxis(axisDomain); plot.setRangeAxis(axisRange); ClusteredXYBarRenderer renderer = new ClusteredXYBarRenderer(); renderer.setMargin(marginSize); renderer.setShadowVisible(false); plot.setRenderer(renderer); this.setMinimumSize(new Dimension(400, 400)); this.setDismissDelay(Integer.MAX_VALUE); this.setInitialDelay(0); }