/** * Sets the value in the rendering hints table for * {@link RenderingHints#KEY_TEXT_ANTIALIASING} to either * {@link RenderingHints#VALUE_TEXT_ANTIALIAS_ON} or * {@link RenderingHints#VALUE_TEXT_ANTIALIAS_OFF}, then sends a * {@link ChartChangeEvent} to all registered listeners. * * @param flag the new value of the flag. * * @since 1.0.5 * * @see #getTextAntiAlias() * @see #setTextAntiAlias(Object) */ public void setTextAntiAlias(boolean flag) { if (flag) { setTextAntiAlias(RenderingHints.VALUE_TEXT_ANTIALIAS_ON); } else { setTextAntiAlias(RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); } }
/** * Sets the value in the rendering hints table for * {@link RenderingHints#KEY_TEXT_ANTIALIASING} to either * {@link RenderingHints#VALUE_TEXT_ANTIALIAS_ON} or * {@link RenderingHints#VALUE_TEXT_ANTIALIAS_OFF}, then sends a * {@link ChartChangeEvent} to all registered listeners. * * @param flag the new value of the flag. * * @since 1.0.5 * * @see #getTextAntiAlias() * @see #setTextAntiAlias(Object) */ public void setTextAntiAlias(boolean flag) { if (flag) { setTextAntiAlias(RenderingHints.VALUE_TEXT_ANTIALIAS_ON); } else { setTextAntiAlias(RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); } }
private void improveChart(JFreeChart jfrechart, ChartParameters params) { Color background = Color.decode("#" + params.getValue(ChartParameters.PARAM_BACKGROUND_COLOR, "FFFFFF", false)); jfrechart.setBackgroundPaint(background); jfrechart.setBorderVisible(false); jfrechart.setAntiAlias(true); jfrechart.setTextAntiAlias(true); jfrechart.removeLegend(); }
private BufferedImage createImage() { IoParameters parameters = getParameters(); int width = parameters.getWidth(); int height = parameters.getHeight(); BufferedImage chartImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics2D chartGraphics = chartImage.createGraphics(); chartGraphics.fillRect(0, 0, width, height); chartGraphics.setColor(Color.WHITE); jFreeChart.setTextAntiAlias(true); jFreeChart.setAntiAlias(true); if (jFreeChart.getLegend() != null) { jFreeChart.getLegend() .setFrame(BlockBorder.NONE); } jFreeChart.draw(chartGraphics, new Rectangle2D.Float(0, 0, width, height)); return chartImage; }
private BufferedImage drawChartToImage() { int width = getChartStyleDefinitions().getWidth(); int height = getChartStyleDefinitions().getHeight(); BufferedImage chartImage = new BufferedImage(width, height, TYPE_INT_RGB); Graphics2D chartGraphics = chartImage.createGraphics(); chartGraphics.fillRect(0, 0, width, height); chartGraphics.setColor(WHITE); chart.setTextAntiAlias(true); chart.setAntiAlias(true); if (chart.getLegend() != null) { chart.getLegend() .setFrame(BlockBorder.NONE); } chart.draw(chartGraphics, new Rectangle2D.Float(0, 0, width, height)); return chartImage; }
renderer6.setSeriesPaint(0, ChartCategories.getColor(0)); chart.setTextAntiAlias(false); return chart;
String fontName = "Lucida Sans"; JFreeChart chart = ChartFactory.createBarChart(null, "", "", dataset, PlotOrientation.VERTICAL, false, true, false ); StandardChartTheme theme = (StandardChartTheme)org.jfree.chart.StandardChartTheme.createJFreeTheme(); theme.setTitlePaint( Color.decode( "#4572a7" ) ); theme.setExtraLargeFont( new Font(fontName,Font.PLAIN, 16) ); //title theme.setLargeFont( new Font(fontName,Font.BOLD, 15)); //axis-title theme.setRegularFont( new Font(fontName,Font.PLAIN, 11)); theme.setRangeGridlinePaint( Color.decode("#C0C0C0")); theme.setPlotBackgroundPaint( Color.white ); theme.setChartBackgroundPaint( Color.white ); theme.setGridBandPaint( Color.red ); theme.setAxisOffset( new RectangleInsets(0,0,0,0) ); theme.setBarPainter(new StandardBarPainter()); theme.setAxisLabelPaint( Color.decode("#666666") ); theme.apply( chart ); chart.getCategoryPlot().setOutlineVisible( false ); chart.getCategoryPlot().getRangeAxis().setAxisLineVisible( false ); chart.getCategoryPlot().getRangeAxis().setTickMarksVisible( false ); chart.getCategoryPlot().setRangeGridlineStroke( new BasicStroke() ); chart.getCategoryPlot().getRangeAxis().setTickLabelPaint( Color.decode("#666666") ); chart.getCategoryPlot().getDomainAxis().setTickLabelPaint( Color.decode("#666666") ); chart.setTextAntiAlias( true ); chart.setAntiAlias( true ); chart.getCategoryPlot().getRenderer().setSeriesPaint( 0, Color.decode( "#4572a7" )); BarRenderer rend = (BarRenderer) chart.getCategoryPlot().getRenderer(); rend.setShadowVisible( true ); rend.setShadowXOffset( 2 ); rend.setShadowYOffset( 0 ); rend.setShadowPaint( Color.decode( "#C0C0C0")); rend.setMaximumBarWidth( 0.1);
chart.setTextAntiAlias(false); return chart;
public JFreeChart createStackedBarChart(String title, XYDataset dataset) { DateAxis domainAxis = new DateAxis("Date"); domainAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); domainAxis.setLowerMargin(0.01); domainAxis.setUpperMargin(0.01); NumberAxis rangeAxis = new NumberAxis("Hours"); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setUpperMargin(0.10); // leave some space for item labels StackedXYBarRenderer renderer = new StackedXYBarRenderer(0.15); // StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2(); renderer.setDrawBarOutline(false); renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator()); renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER)); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0} : {1} = {2}", new SimpleDateFormat("yyyy"), new DecimalFormat("0"))); XYPlot plot = new XYPlot(dataset, domainAxis, rangeAxis, renderer); JFreeChart chart = new JFreeChart(title, plot); chart.removeLegend(); chart.setTextAntiAlias(RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT); LegendTitle legend = new LegendTitle(plot); legend.setBackgroundPaint(Color.white); legend.setFrame(new BlockBorder()); legend.setPosition(RectangleEdge.BOTTOM); chart.addSubtitle(legend); return chart; }
yAxis.setAutoRange(true); xAxis.setRange(leftValue(0), rightValue(numberOfCategories - 1)); chart.setTextAntiAlias(false); return chart;
public JFreeChart createStackedAreaChart(String title, TableXYDataset dataset) { DateAxis domainAxis = new DateAxis("Date"); domainAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); domainAxis.setLowerMargin(0.01); domainAxis.setUpperMargin(0.01); NumberAxis rangeAxis = new NumberAxis("Minutes"); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setUpperMargin(0.10); StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2(); renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator()); renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER)); renderer.setSeriesPaint(0, Color.lightGray); XYPlot plot = new XYPlot(dataset, domainAxis, rangeAxis, renderer); plot.setRenderer(0, renderer); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); LegendTitle legend = new LegendTitle(plot); legend.setBackgroundPaint(Color.white); legend.setFrame(new BlockBorder()); legend.setPosition(RectangleEdge.BOTTOM); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true); chart.removeLegend(); chart.setTextAntiAlias(RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT); chart.addSubtitle(legend); return chart; }