List of usage examples for org.jfree.chart StandardChartTheme setLargeFont
public void setLargeFont(Font font)
From source file:uk.ac.ed.epcc.webapp.charts.jfreechart.JFreeSetup.java
public static void setup() { StandardChartTheme theme = new StandardChartTheme("webapp"); theme.setSmallFont(new Font("Arial", Font.PLAIN, 10)); theme.setRegularFont(new Font("Arial", Font.PLAIN, 12)); theme.setLargeFont(new Font("Arial", Font.PLAIN, 14)); theme.setExtraLargeFont(new Font("Arial", Font.PLAIN, 20)); ChartFactory.setChartTheme(theme);/* www . ja va 2s . co m*/ }
From source file:com.uttesh.pdfngreport.util.chart.ChartStyle.java
/** * this method will set the style theme for pie chart. * * @see org.jfree.chart.StandardChartTheme * @param chart/*from w ww. ja va 2 s .c om*/ */ public static void theme(JFreeChart chart) { String fontName = "Lucida Sans"; 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.setTextAntiAlias(true); chart.setAntiAlias(true); }
From source file:com.ouc.cpss.view.EmpSaleChartBuilder.java
private static JFreeChart createJFreeChart(CategoryDataset dataset) { /**/*www . java 2s . c om*/ * JFreeChart */ //? StandardChartTheme standardChartTheme = new StandardChartTheme("CN"); // standardChartTheme.setExtraLargeFont(new Font("", Font.BOLD, 20)); // standardChartTheme.setRegularFont(new Font("", Font.PLAIN, 15)); //? standardChartTheme.setLargeFont(new Font("", Font.PLAIN, 15)); //? ChartFactory.setChartTheme(standardChartTheme); //? JFreeChart jfreeChart = ChartFactory.createBarChart3D("", "", "?", dataset, PlotOrientation.VERTICAL, true, false, false); /** * JFreeChart */ jfreeChart.setTitle(new TextTitle("", new Font("", Font.BOLD + Font.ITALIC, 20))); CategoryPlot plot = (CategoryPlot) jfreeChart.getPlot(); CategoryAxis categoryAxis = plot.getDomainAxis(); categoryAxis.setLabelFont(new Font("", Font.ROMAN_BASELINE, 12)); return jfreeChart; }
From source file:com.ouc.cpss.view.ChartProBuilder.java
private static JFreeChart createJFreeChart(CategoryDataset dataset) { /**/*w ww . jav a 2s. c o m*/ * JFreeChart */ //? StandardChartTheme standardChartTheme = new StandardChartTheme("CN"); // standardChartTheme.setExtraLargeFont(new Font("", Font.BOLD, 20)); // standardChartTheme.setRegularFont(new Font("", Font.PLAIN, 15)); //? standardChartTheme.setLargeFont(new Font("", Font.PLAIN, 15)); //? ChartFactory.setChartTheme(standardChartTheme); //? // ? JFreeChart jfreeChart = null; if (choice == 1) { jfreeChart = ChartFactory.createBarChart3D("? -- ?TOP10", "", "?", dataset, PlotOrientation.VERTICAL, true, false, false); /** * JFreeChart */ jfreeChart.setTitle(new TextTitle("? -- ?TOP10", new Font("", Font.BOLD + Font.ITALIC, 20))); CategoryPlot plot = (CategoryPlot) jfreeChart.getPlot(); CategoryAxis categoryAxis = plot.getDomainAxis(); categoryAxis.setLabelFont(new Font("", Font.ROMAN_BASELINE, 12)); } else { jfreeChart = ChartFactory.createBarChart3D("? -- ?TOP10", "", "?", dataset, PlotOrientation.VERTICAL, true, false, false); jfreeChart.setTitle(new TextTitle("? -- ?TOP10", new Font("", Font.BOLD + Font.ITALIC, 20))); CategoryPlot plot = (CategoryPlot) jfreeChart.getPlot(); CategoryAxis categoryAxis = plot.getDomainAxis(); categoryAxis.setLabelFont(new Font("", Font.ROMAN_BASELINE, 12)); } return jfreeChart; }
From source file:jamel.gui.charts.JamelChart.java
/** * Returns the standard chart theme.// ww w. j a va 2s. c o m * @return the standard chart theme. */ private static StandardChartTheme getNewChartTheme() { StandardChartTheme theme = new StandardChartTheme("Standard Chart Theme"); float size = theme.getExtraLargeFont().getSize2D(); Font titleFont = theme.getExtraLargeFont().deriveFont(size - 4); theme.setExtraLargeFont(titleFont); Font axisFont = theme.getRegularFont(); theme.setLargeFont(axisFont); theme.setChartBackgroundPaint(new Color(0, 0, 0, 1)); theme.setPlotBackgroundPaint(Color.WHITE); theme.setDomainGridlinePaint(Color.GRAY); theme.setRangeGridlinePaint(Color.GRAY); return theme; }
From source file:com.ouc.cpss.view.SupTradeChartBuilder.java
private static JFreeChart createJFreeChart(PieDataset dataset) { /**//from w w w .j a va 2 s. c o m * JFreeChart */ //? StandardChartTheme standardChartTheme = new StandardChartTheme("CN"); // standardChartTheme.setExtraLargeFont(new Font("", Font.BOLD, 20)); // standardChartTheme.setRegularFont(new Font("", Font.PLAIN, 15)); //? standardChartTheme.setLargeFont(new Font("", Font.PLAIN, 15)); //? ChartFactory.setChartTheme(standardChartTheme); //?? //createPieChart 2D; createPieChart3D 3D JFreeChart chart = ChartFactory.createPieChart("", dataset, true, true, false); //,? chart.setTitle(new TextTitle("", new Font("", Font.ITALIC, 22))); //? LegendTitle legend = chart.getLegend(0); //,ture,? legend.setItemFont(new Font("", Font.BOLD, 20)); //?(??) PiePlot plot = (PiePlot) chart.getPlot(); //?==? plot.setLabelFont(new Font("", Font.BOLD, 22)); // plot.setBaseSectionOutlinePaint(Color.BLUE); // plot.setBaseSectionOutlineStroke(new BasicStroke(0.5f)); //?,??,?? plot.setDirection(Rotation.CLOCKWISE);//,Rotation.CLOCKWISE //() plot.setStartAngle(70); //??? //plot.setExplodePercent(1, 0.5D); //plot.setExplodePercent("One", 0.5D); //,3D? plot.setExplodePercent(dataset.getKey(0), 0.1d); // plot.setLabelLinkPaint(Color.BLUE); // plot.setLabelOutlinePaint(Color.black); // plot.setLabelShadowPaint(Color.RED); // plot.setSectionPaint(1, Color.BLACK); // :,{0},{1},{2}?,??? plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}:{1}\r\n{2}", NumberFormat.getNumberInstance(), new DecimalFormat("0.00%"))); // plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0}={2}")); //:(true),(false) plot.setCircular(true); //? plot.setNoDataMessage("??..."); //??? plot.setToolTipGenerator(new StandardPieToolTipGenerator()); // //plot.setURLGenerator(new StandardPieURLGenerator("detail.jsp")); return chart; }
From source file:com.glaf.chart.util.ChartUtils.java
public static void setChartTheme(Chart chartModel) { // ?//from www . j a v a 2 s. c om StandardChartTheme standardChartTheme = new StandardChartTheme("cn"); // if (chartModel.getChartTitleFont() != null && chartModel.getChartTitleFontSize() != null && chartModel.getChartTitleFontSize() > 0) { standardChartTheme.setExtraLargeFont( new Font(chartModel.getChartTitleFont(), Font.BOLD, chartModel.getChartTitleFontSize())); } else { standardChartTheme.setExtraLargeFont(new Font("", Font.BOLD, 18)); } if (chartModel.getChartFont() != null && chartModel.getChartFontSize() > 0) { // standardChartTheme .setRegularFont(new Font(chartModel.getChartFont(), Font.PLAIN, chartModel.getChartFontSize())); // ? standardChartTheme .setLargeFont(new Font(chartModel.getChartFont(), Font.PLAIN, chartModel.getChartFontSize())); } else { // standardChartTheme.setRegularFont(new Font("", Font.PLAIN, 14)); // ? standardChartTheme.setLargeFont(new Font("", Font.PLAIN, 14)); } // ? ChartFactory.setChartTheme(standardChartTheme); }
From source file:com.rapidminer.gui.viewer.metadata.model.AbstractAttributeStatisticsModel.java
/** * Changes the font of {@link JFreeChart}s to Sans Serif. This method uses a * {@link StandardChartTheme} to do so, so any changes to the look of the chart must be done * after calling this method.//www . j ava 2s. c om * * @param chart * the chart to change fonts for */ protected static void setDefaultChartFonts(JFreeChart chart) { final ChartTheme chartTheme = StandardChartTheme.createJFreeTheme(); if (StandardChartTheme.class.isAssignableFrom(chartTheme.getClass())) { StandardChartTheme standardTheme = (StandardChartTheme) chartTheme; // The default font used by JFreeChart cannot render japanese etc symbols final Font oldExtraLargeFont = standardTheme.getExtraLargeFont(); final Font oldLargeFont = standardTheme.getLargeFont(); final Font oldRegularFont = standardTheme.getRegularFont(); final Font oldSmallFont = standardTheme.getSmallFont(); final Font extraLargeFont = new Font(Font.SANS_SERIF, oldExtraLargeFont.getStyle(), oldExtraLargeFont.getSize()); final Font largeFont = new Font(Font.SANS_SERIF, oldLargeFont.getStyle(), oldLargeFont.getSize()); final Font regularFont = new Font(Font.SANS_SERIF, oldRegularFont.getStyle(), oldRegularFont.getSize()); final Font smallFont = new Font(Font.SANS_SERIF, oldSmallFont.getStyle(), oldSmallFont.getSize()); standardTheme.setExtraLargeFont(extraLargeFont); standardTheme.setLargeFont(largeFont); standardTheme.setRegularFont(regularFont); standardTheme.setSmallFont(smallFont); standardTheme.apply(chart); } }
From source file:virgil.meanback.HistoryInfo.java
public void printChart(Stock stock, List<String[]> list, int days) throws Exception { //?/*from w w w . ja v a2 s . co m*/ StandardChartTheme standardChartTheme = new StandardChartTheme("CN"); // standardChartTheme.setExtraLargeFont(new Font("", Font.BOLD, 20)); // standardChartTheme.setRegularFont(new Font("", Font.BOLD, 12)); //? standardChartTheme.setLargeFont(new Font("", Font.BOLD, 18)); //? ChartFactory.setChartTheme(standardChartTheme); DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); for (int i = list.size() - 1; i >= 0; i--) { String[] s = (String[]) list.get(i); dataSet.addValue(Double.parseDouble(s[1]), days + "", s[0]); dataSet.addValue(Double.parseDouble(stock.getList().get(i).getClose()), "", s[0]); float sub = Float.parseFloat(s[2]); float error = Float.parseFloat(s[3]); if (sub > error * 2) { dataSet.addValue(Double.parseDouble(stock.getList().get(i).getClose()), "??", s[0]); } } //?????Legend //???? //??URL JFreeChart chart = ChartFactory.createLineChart( stock.getName() + "(" + stock.getCode() + ") ", "", "", dataSet, PlotOrientation.VERTICAL, true, true, false); CategoryPlot cp = chart.getCategoryPlot(); cp.setBackgroundPaint(ChartColor.WHITE); // CategoryAxis categoryAxis = cp.getDomainAxis(); // Lable 90 Font labelFont = new Font("SansSerif", Font.TRUETYPE_FONT, 10); categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); categoryAxis.setTickLabelFont(labelFont);//X?? ValueAxis yAxis = cp.getRangeAxis(); yAxis.setAutoRange(true); double[] d = getAxiasThresold(stock, list); yAxis.setLowerBound(d[0] - 0.15); yAxis.setUpperBound(d[1] + 0.15); LineAndShapeRenderer lasp = (LineAndShapeRenderer) cp.getRenderer(); lasp.setBaseFillPaint(ChartColor.RED); lasp.setDrawOutlines(true); lasp.setSeriesShape(0, new java.awt.geom.Ellipse2D.Double(-5D, -5D, 10D, 10D)); LineAndShapeRenderer renderer = (LineAndShapeRenderer) cp.getRenderer(1);//? DecimalFormat decimalformat1 = new DecimalFormat("##.##");//??? renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}", decimalformat1)); //???? renderer.setItemLabelsVisible(true);// renderer.setBaseItemLabelsVisible(true);// //????? renderer.setShapesFilled(Boolean.TRUE);//?? renderer.setShapesVisible(true);//? ChartFrame chartFrame = new ChartFrame("??", chart, true); //chart?JavaChartFramejavaJframe???? chartFrame.pack(); //?? chartFrame.setVisible(true);//??? }
From source file:org.yccheok.jstock.charting.Utils.java
/** * Applying chart theme based on given JFreeChart. * * @param chart the JFreeChart//from www. j ava 2 s . c o m */ public static void applyChartThemeEx(JFreeChart chart) { final StandardChartTheme chartTheme; final JStockOptions.ChartTheme theme = JStock.instance().getJStockOptions().getChartTheme(); if (theme == JStockOptions.ChartTheme.Light) { applyChartTheme(chart); return; } else { assert (theme == JStockOptions.ChartTheme.Dark); chartTheme = (StandardChartTheme) org.jfree.chart.StandardChartTheme.createDarknessTheme(); } // The default font used by JFreeChart unable to render Chinese properly. // We need to provide font which is able to support Chinese rendering. final Locale defaultLocale = Locale.getDefault(); if (org.yccheok.jstock.gui.Utils.isSimplifiedChinese(defaultLocale) || org.yccheok.jstock.gui.Utils.isTraditionalChinese(defaultLocale)) { final Font oldExtraLargeFont = chartTheme.getExtraLargeFont(); final Font oldLargeFont = chartTheme.getLargeFont(); final Font oldRegularFont = chartTheme.getRegularFont(); final Font oldSmallFont = chartTheme.getSmallFont(); final Font extraLargeFont = new Font("Sans-serif", oldExtraLargeFont.getStyle(), oldExtraLargeFont.getSize()); final Font largeFont = new Font("Sans-serif", oldLargeFont.getStyle(), oldLargeFont.getSize()); final Font regularFont = new Font("Sans-serif", oldRegularFont.getStyle(), oldRegularFont.getSize()); final Font smallFont = new Font("Sans-serif", oldSmallFont.getStyle(), oldSmallFont.getSize()); chartTheme.setExtraLargeFont(extraLargeFont); chartTheme.setLargeFont(largeFont); chartTheme.setRegularFont(regularFont); chartTheme.setSmallFont(smallFont); } // Apply and return early. chartTheme.apply(chart); }