List of usage examples for org.jfree.chart.title TextTitle setPosition
public void setPosition(RectangleEdge position)
From source file:net.sf.jasperreports.components.spiderchart.SpiderChartDesignEvaluator.java
/** * //from w w w .ja v a2 s . c o m */ public static JRRenderable evaluateRenderer(ReportConverter reportConverter, JRComponentElement element) { SpiderChartComponent chartComponent = (SpiderChartComponent) element.getComponent(); ChartSettings chartSettings = chartComponent.getChartSettings(); SpiderPlot plot = chartComponent.getPlot(); SpiderWebPlot spiderWebPlot = new SpiderWebPlot(getSampleDataset()); if (plot.getAxisLineColor() != null) { spiderWebPlot.setAxisLinePaint(plot.getAxisLineColor()); } if (plot.getAxisLineWidth() != null) { spiderWebPlot.setAxisLineStroke(new BasicStroke(plot.getAxisLineWidth())); } if (plot.getBackcolor() != null) { spiderWebPlot.setBackgroundPaint(plot.getBackcolor()); } if (plot.getBackgroundAlpha() != null) { spiderWebPlot.setBackgroundAlpha(plot.getBackgroundAlpha()); } if (plot.getForegroundAlpha() != null) { spiderWebPlot.setForegroundAlpha(plot.getForegroundAlpha()); } if (plot.getHeadPercent() != null) { spiderWebPlot.setHeadPercent(plot.getHeadPercent()); } if (plot.getInteriorGap() != null) { spiderWebPlot.setInteriorGap(plot.getInteriorGap()); } if (plot.getLabelColor() != null) { spiderWebPlot.setLabelPaint(plot.getLabelColor()); } if (plot.getLabelFont() != null) { spiderWebPlot.setLabelFont(JRFontUtil.getAwtFont(plot.getLabelFont(), Locale.getDefault())); } if (plot.getLabelGap() != null) { spiderWebPlot.setAxisLabelGap(plot.getLabelGap()); } spiderWebPlot.setMaxValue(MAX_VALUE); if (plot.getRotation() != null) { spiderWebPlot.setDirection(plot.getRotation().getRotation()); } if (plot.getStartAngle() != null) { spiderWebPlot.setStartAngle(plot.getStartAngle()); } if (plot.getTableOrder() != null) { spiderWebPlot.setDataExtractOrder(plot.getTableOrder().getOrder()); } if (plot.getWebFilled() != null) { spiderWebPlot.setWebFilled(plot.getWebFilled()); } spiderWebPlot.setToolTipGenerator(new StandardCategoryToolTipGenerator()); spiderWebPlot.setLabelGenerator(new StandardCategoryItemLabelGenerator()); String titleText = JRExpressionUtil.getExpressionText(chartSettings.getTitleExpression()); Font titleFont = chartSettings.getTitleFont() != null ? JRFontUtil.getAwtFont(chartSettings.getTitleFont(), Locale.getDefault()) : TextTitle.DEFAULT_FONT; JFreeChart jfreechart = new JFreeChart(titleText, titleFont, spiderWebPlot, true); if (chartSettings.getBackcolor() != null) { jfreechart.setBackgroundPaint(chartSettings.getBackcolor()); } RectangleEdge titleEdge = getEdge(chartSettings.getTitlePosition(), RectangleEdge.TOP); if (titleText != null) { TextTitle title = jfreechart.getTitle(); title.setText(titleText); if (chartSettings.getTitleColor() != null) { title.setPaint(chartSettings.getTitleColor()); } title.setFont(titleFont); title.setPosition(titleEdge); jfreechart.setTitle(title); } String subtitleText = JRExpressionUtil.getExpressionText(chartSettings.getSubtitleExpression()); if (subtitleText != null) { TextTitle subtitle = new TextTitle(subtitleText); subtitle.setText(subtitleText); if (chartSettings.getSubtitleColor() != null) { subtitle.setPaint(chartSettings.getSubtitleColor()); } if (chartSettings.getSubtitleColor() != null) { Font subtitleFont = chartSettings.getSubtitleFont() != null ? JRFontUtil.getAwtFont(chartSettings.getSubtitleFont(), Locale.getDefault()) : TextTitle.DEFAULT_FONT; subtitle.setFont(subtitleFont); } subtitle.setPosition(titleEdge); jfreechart.addSubtitle(subtitle); } // Apply all of the legend formatting options LegendTitle legend = jfreechart.getLegend(); if (legend != null) { legend.setVisible((chartSettings.getShowLegend() == null || chartSettings.getShowLegend())); if (legend.isVisible()) { if (chartSettings.getLegendColor() != null) { legend.setItemPaint(chartSettings.getLegendColor()); } if (chartSettings.getLegendBackgroundColor() != null) { legend.setBackgroundPaint(chartSettings.getLegendBackgroundColor()); } if (chartSettings.getLegendFont() != null) { legend.setItemFont(JRFontUtil.getAwtFont(chartSettings.getLegendFont(), Locale.getDefault())); } legend.setPosition(getEdge(chartSettings.getLegendPosition(), RectangleEdge.BOTTOM)); } } Rectangle2D rectangle = new Rectangle2D.Double(0, 0, element.getWidth(), element.getHeight()); String renderType = chartSettings.getRenderType(); if (renderType == null) { renderType = JRProperties.getProperty(reportConverter.getReport(), JRChart.PROPERTY_CHART_RENDER_TYPE); } return ChartUtil.getChartRendererFactory(renderType).getRenderer(jfreechart, null, rectangle); }
From source file:mt.LengthDistribution.java
public static void GetLengthDistributionArray(ArrayList<File> AllMovies, double[] calibration) { ArrayList<Double> maxlist = new ArrayList<Double>(); for (int i = 0; i < AllMovies.size(); ++i) { double maxlength = LengthDistribution.Lengthdistro(AllMovies.get(i)); if (maxlength != Double.NaN && maxlength > 0) maxlist.add(maxlength);/*ww w. j a va2 s. com*/ } Collections.sort(maxlist); int min = 0; int max = (int) Math.round(maxlist.get(maxlist.size() - 1)) + 1; XYSeries counterseries = new XYSeries("MT length distribution"); XYSeries Logcounterseries = new XYSeries("MT Log length distribution"); final ArrayList<Point> points = new ArrayList<Point>(); for (int length = 0; length < max; ++length) { HashMap<Integer, Integer> frameseed = new HashMap<Integer, Integer>(); int count = 0; for (int i = 0; i < AllMovies.size(); ++i) { File file = AllMovies.get(i); double currentlength = LengthDistribution.Lengthdistro(file); ArrayList<FLSobject> currentobject = Tracking.loadMTStat(file); if (currentlength > length) { for (int index = 0; index < currentobject.size(); ++index) { ArrayList<Integer> seedlist = new ArrayList<Integer>(); if (currentobject.get(index).length >= length) { seedlist.add(currentobject.get(index).seedID); if (frameseed.get(currentobject.get(index).Framenumber) != null && frameseed.get(currentobject.get(index).Framenumber) != Double.NaN) { int currentcount = frameseed.get(currentobject.get(index).Framenumber); frameseed.put(currentobject.get(index).Framenumber, seedlist.size() + currentcount); } else if (currentobject.get(index) != null) frameseed.put(currentobject.get(index).Framenumber, seedlist.size()); } } } } // Get maxima length, count int maxvalue = Integer.MIN_VALUE; for (int key : frameseed.keySet()) { int Count = frameseed.get(key); if (Count >= maxvalue) maxvalue = Count; } if (maxvalue != Integer.MIN_VALUE) { counterseries.add(length, maxvalue); if (maxvalue > 0) { Logcounterseries.add((length), Math.log(maxvalue)); points.add(new Point(new double[] { length, Math.log(maxvalue) })); } } } final XYSeriesCollection dataset = new XYSeriesCollection(); final XYSeriesCollection nofitdataset = new XYSeriesCollection(); dataset.addSeries(counterseries); nofitdataset.addSeries(counterseries); final XYSeriesCollection Logdataset = new XYSeriesCollection(); Logdataset.addSeries(Logcounterseries); final JFreeChart chart = ChartFactory.createScatterPlot("MT length distribution", "Number of MT", "Length (micrometer)", dataset); final JFreeChart nofitchart = ChartFactory.createScatterPlot("MT length distribution", "Number of MT", "Length (micrometer)", nofitdataset); // Fitting line to log of the length distribution interpolation.Polynomial poly = new interpolation.Polynomial(1); try { poly.fitFunction(points); } catch (NotEnoughDataPointsException e) { // TODO Auto-generated catch block e.printStackTrace(); } DisplayPoints.display(nofitchart, new Dimension(800, 500)); dataset.addSeries(Tracking.drawexpFunction(poly, counterseries.getMinX(), counterseries.getMaxX(), 0.5, "Exponential fit")); NumberFormat nf = NumberFormat.getInstance(Locale.ENGLISH); nf.setMaximumFractionDigits(3); TextTitle legendText = new TextTitle("Mean Length" + " : " + nf.format(-1.0 / poly.getCoefficients(1)) + " " + "Standard Deviation" + " : " + nf.format(poly.SSE)); legendText.setPosition(RectangleEdge.RIGHT); DisplayPoints.display(chart, new Dimension(800, 500)); chart.addSubtitle(legendText); final JFreeChart logchart = ChartFactory.createScatterPlot("MT Log length distribution", "Number of MT", "Length (micrometer)", Logdataset); // DisplayPoints.display(logchart, new Dimension(800, 500)); for (int i = 1; i >= 0; --i) System.out.println(poly.getCoefficients(i) + " " + "x" + " X to the power of " + i); // Logdataset.addSeries(Tracking.drawFunction(poly, counterseries.getMinX(), counterseries.getMaxX(), 0.5, "Straight line fit")); WriteLengthdistroFile(AllMovies, counterseries, 0); }
From source file:mt.LengthDistribution.java
public static void GetLengthDistributionArrayatTime(ArrayList<File> AllMovies, double[] calibration, final int framenumber) { ArrayList<Double> maxlist = new ArrayList<Double>(); for (int i = 0; i < AllMovies.size(); ++i) { ArrayList<Pair<Integer, Double>> lengthlist = LengthDistribution.LengthdistroatTime(AllMovies.get(i), framenumber);/*from w ww. j a v a 2s . c om*/ for (int index = 0; index < lengthlist.size(); ++index) { if (lengthlist.get(index).getB() != Double.NaN && lengthlist.get(index).getB() > 0) maxlist.add(lengthlist.get(index).getB()); } } Collections.sort(maxlist); int min = 0; int max = 0; if (maxlist.size() > 0) max = (int) Math.round(maxlist.get(maxlist.size() - 1)) + 1; XYSeries counterseries = new XYSeries("MT length distribution"); XYSeries Logcounterseries = new XYSeries("MT Log length distribution"); final ArrayList<Point> points = new ArrayList<Point>(); for (int length = 0; length < max; ++length) { HashMap<Integer, Integer> frameseed = new HashMap<Integer, Integer>(); int count = 0; for (int i = 0; i < AllMovies.size(); ++i) { File file = AllMovies.get(i); ArrayList<FLSobject> currentobject = Tracking.loadMTStat(file); if (currentobject != null) for (int index = 0; index < currentobject.size(); ++index) { ArrayList<Integer> seedlist = new ArrayList<Integer>(); if (currentobject.get(index).length >= length && currentobject.get(index).Framenumber == framenumber) { seedlist.add(currentobject.get(index).seedID); if (frameseed.get(currentobject.get(index).Framenumber) != null && frameseed.get(currentobject.get(index).Framenumber) != Double.NaN) { int currentcount = frameseed.get(currentobject.get(index).Framenumber); frameseed.put(currentobject.get(index).Framenumber, seedlist.size() + currentcount); } else if (currentobject.get(index) != null) frameseed.put(currentobject.get(index).Framenumber, seedlist.size()); } } } // Get maxima length, count int maxvalue = Integer.MIN_VALUE; for (int key : frameseed.keySet()) { int Count = frameseed.get(key); if (Count >= maxvalue) maxvalue = Count; } if (maxvalue != Integer.MIN_VALUE) { counterseries.add(length, maxvalue); if (maxvalue > 0) { System.out.println("Max " + maxvalue); Logcounterseries.add((length), Math.log(maxvalue)); points.add(new Point(new double[] { length, Math.log(maxvalue) })); } } } final XYSeriesCollection dataset = new XYSeriesCollection(); final XYSeriesCollection nofitdataset = new XYSeriesCollection(); dataset.addSeries(counterseries); nofitdataset.addSeries(counterseries); final XYSeriesCollection Logdataset = new XYSeriesCollection(); Logdataset.addSeries(Logcounterseries); final JFreeChart chart = ChartFactory.createScatterPlot("MT length distribution", "Number of MT", "Length (micrometer)", dataset); final JFreeChart nofitchart = ChartFactory.createScatterPlot("MT length distribution", "Number of MT", "Length (micrometer)", nofitdataset); // Fitting line to log of the length distribution interpolation.Polynomial poly = new interpolation.Polynomial(1); try { poly.fitFunction(points); } catch (NotEnoughDataPointsException e) { } DisplayPoints.display(nofitchart, new Dimension(800, 500)); dataset.addSeries(Tracking.drawexpFunction(poly, counterseries.getMinX(), counterseries.getMaxX(), 0.5, "Exponential fit")); NumberFormat nf = NumberFormat.getInstance(Locale.ENGLISH); nf.setMaximumFractionDigits(3); TextTitle legendText = new TextTitle("Mean Length" + " : " + nf.format(-1.0 / poly.getCoefficients(1)) + " " + "Standard Deviation" + " : " + nf.format(poly.SSE)); legendText.setPosition(RectangleEdge.RIGHT); DisplayPoints.display(chart, new Dimension(800, 500)); chart.addSubtitle(legendText); System.out.println("Series count" + dataset.getSeriesCount()); final JFreeChart logchart = ChartFactory.createScatterPlot("MT Log length distribution", "Length (micrometer)", "Number of MT", Logdataset); // DisplayPoints.display(logchart, new Dimension(800, 500)); for (int i = 1; i >= 0; --i) System.out.println(poly.getCoefficients(i) + " " + "x" + " X to the power of " + i); // Logdataset.addSeries(Tracking.drawFunction(poly, counterseries.getMinX(), counterseries.getMaxX(), 0.5, "Straight line fit")); WriteLengthdistroFile(AllMovies, counterseries, framenumber); }
From source file:ca.sqlpower.wabit.swingui.chart.ChartSwingUtil.java
/** * Creates a chart that displays multiple 3D pie plots that have a GradientPaintTransformer. * The chart object returned by this method uses a {@link MultiplePiePlot} instance as the plot. * * @param title the chart title (<code>null</code> permitted). * @param dataset the dataset (<code>null</code> permitted). * @param order the order that the data is extracted (by row or by column) * (<code>null</code> not permitted). * @param legend include a legend?// w w w . j a v a 2 s . com * @param tooltips generate tooltips? * @param urls generate URLs? * * @return A chart. */ private static JFreeChart createPieChart(String title, CategoryDataset dataset, TableOrder order, boolean legend, boolean tooltips, boolean urls) { if (order == null) { throw new IllegalArgumentException("Null 'order' argument."); } MultiplePiePlot plot = new MultiplePiePlot(dataset); plot.setDataExtractOrder(order); plot.setBackgroundPaint(null); plot.setOutlineStroke(null); JFreeChart pieChart = new JFreeChart(new PiePlot3DGradient(null)); TextTitle seriesTitle = new TextTitle("Series Title", new Font("SansSerif", Font.BOLD, 10)); seriesTitle.setPosition(RectangleEdge.BOTTOM); pieChart.setTitle(seriesTitle); pieChart.getTitle().setPadding(0, 0, 0, 0); pieChart.removeLegend(); pieChart.setBackgroundPaint(null); pieChart.setPadding(new RectangleInsets(0, 0, 0, 0)); pieChart.getPlot().setInsets(new RectangleInsets(0, 0, 0, 0)); plot.setPieChart(pieChart); if (tooltips) { PieToolTipGenerator tooltipGenerator = new StandardPieToolTipGenerator(); PiePlot pp = (PiePlot) plot.getPieChart().getPlot(); pp.setToolTipGenerator(tooltipGenerator); } if (urls) { PieURLGenerator urlGenerator = new StandardPieURLGenerator(); PiePlot pp = (PiePlot) plot.getPieChart().getPlot(); pp.setURLGenerator(urlGenerator); } JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); return chart; }
From source file:net.sf.jasperreports.components.spiderchart.SpiderChartRendererEvaluator.java
/** * //from w w w. j a v a 2 s . com */ public static Renderable evaluateRenderable(JasperReportsContext jasperReportsContext, JRComponentElement element, SpiderChartSharedBean spiderchartBean, ChartCustomizer chartCustomizer, String defaultRenderType, String datasetType) { SpiderChartComponent chartComponent = (SpiderChartComponent) element.getComponent(); ChartSettings chartSettings = chartComponent.getChartSettings(); SpiderPlot plot = (SpiderPlot) chartComponent.getPlot(); DefaultCategoryDataset dataset = null; StandardCategoryItemLabelGenerator labelGenerator = null; if (FILL_DATASET.equals(datasetType)) { dataset = ((FillSpiderDataset) spiderchartBean.getDataset()).getCustomDataset(); labelGenerator = ((FillSpiderDataset) spiderchartBean.getDataset()).getLabelGenerator(); } else { dataset = getSampleDataset(); labelGenerator = new StandardCategoryItemLabelGenerator(); } SpiderWebPlot spiderWebPlot = new SpiderWebPlot(dataset); if (plot.getAxisLineColor() != null) { spiderWebPlot.setAxisLinePaint(plot.getAxisLineColor()); } if (plot.getAxisLineWidth() != null) { spiderWebPlot.setAxisLineStroke(new BasicStroke(plot.getAxisLineWidth())); } if (plot.getBackcolor() != null) { spiderWebPlot.setBackgroundPaint(plot.getBackcolor()); } if (plot.getBackgroundAlpha() != null) { spiderWebPlot.setBackgroundAlpha(plot.getBackgroundAlpha()); } if (plot.getForegroundAlpha() != null) { spiderWebPlot.setForegroundAlpha(plot.getForegroundAlpha()); } if (plot.getHeadPercent() != null) { spiderWebPlot.setHeadPercent(plot.getHeadPercent()); } if (plot.getInteriorGap() != null) { spiderWebPlot.setInteriorGap(plot.getInteriorGap()); } if (plot.getLabelColor() != null) { spiderWebPlot.setLabelPaint(plot.getLabelColor()); } if (plot.getLabelFont() != null) { spiderWebPlot.setLabelFont(FontUtil.getInstance(jasperReportsContext).getAwtFont(plot.getLabelFont(), Locale.getDefault())); } if (plot.getLabelGap() != null) { spiderWebPlot.setAxisLabelGap(plot.getLabelGap()); } if (spiderchartBean.getMaxValue() != null) { spiderWebPlot.setMaxValue(spiderchartBean.getMaxValue()); } if (plot.getRotation() != null) { spiderWebPlot.setDirection(plot.getRotation().getRotation()); } if (plot.getStartAngle() != null) { spiderWebPlot.setStartAngle(plot.getStartAngle()); } if (plot.getTableOrder() != null) { spiderWebPlot.setDataExtractOrder(plot.getTableOrder().getOrder()); } if (plot.getWebFilled() != null) { spiderWebPlot.setWebFilled(plot.getWebFilled()); } spiderWebPlot.setToolTipGenerator(new StandardCategoryToolTipGenerator()); spiderWebPlot.setLabelGenerator(labelGenerator); Font titleFont = chartSettings.getTitleFont() != null ? FontUtil.getInstance(jasperReportsContext) .getAwtFont(chartSettings.getTitleFont(), Locale.getDefault()) : TextTitle.DEFAULT_FONT; String titleText = spiderchartBean.getTitleText(); JFreeChart jfreechart = new JFreeChart(titleText, titleFont, spiderWebPlot, true); Color backcolor = chartSettings.getBackcolor() != null ? chartSettings.getBackcolor() : element.getBackcolor(); if (backcolor != null) { jfreechart.setBackgroundPaint(backcolor); } RectangleEdge titleEdge = getEdge(chartSettings.getTitlePosition(), RectangleEdge.TOP); if (titleText != null) { TextTitle title = jfreechart.getTitle(); title.setText(titleText); if (chartSettings.getTitleColor() != null) { title.setPaint(chartSettings.getTitleColor()); } title.setFont(titleFont); title.setPosition(titleEdge); jfreechart.setTitle(title); } String subtitleText = spiderchartBean.getSubtitleText(); if (subtitleText != null) { TextTitle subtitle = new TextTitle(subtitleText); subtitle.setText(subtitleText); if (chartSettings.getSubtitleColor() != null) { subtitle.setPaint(chartSettings.getSubtitleColor()); } if (chartSettings.getSubtitleColor() != null) { Font subtitleFont = chartSettings.getSubtitleFont() != null ? FontUtil.getInstance(jasperReportsContext).getAwtFont(chartSettings.getSubtitleFont(), Locale.getDefault()) : TextTitle.DEFAULT_FONT; subtitle.setFont(subtitleFont); } subtitle.setPosition(titleEdge); jfreechart.addSubtitle(subtitle); } // Apply all of the legend formatting options LegendTitle legend = jfreechart.getLegend(); if (legend != null) { legend.setVisible((chartSettings.getShowLegend() == null || chartSettings.getShowLegend())); if (legend.isVisible()) { if (chartSettings.getLegendColor() != null) { legend.setItemPaint(chartSettings.getLegendColor()); } if (chartSettings.getLegendBackgroundColor() != null) { legend.setBackgroundPaint(chartSettings.getLegendBackgroundColor()); } if (chartSettings.getLegendFont() != null) { legend.setItemFont(FontUtil.getInstance(jasperReportsContext) .getAwtFont(chartSettings.getLegendFont(), Locale.getDefault())); } legend.setPosition(getEdge(chartSettings.getLegendPosition(), RectangleEdge.BOTTOM)); } } String renderType = chartSettings.getRenderType() == null ? defaultRenderType : chartSettings.getRenderType(); Rectangle2D rectangle = new Rectangle2D.Double(0, 0, element.getWidth(), element.getHeight()); if (chartCustomizer != null) { chartCustomizer.customize(jfreechart, chartComponent); } return ChartUtil.getInstance(jasperReportsContext).getChartRenderableFactory(renderType) .getRenderable(jasperReportsContext, jfreechart, spiderchartBean.getHyperlinkProvider(), rectangle); }
From source file:org.hxzon.demo.jfreechart.CategoryDatasetDemo2.java
private static JFreeChart createMultiplePieChart3D_2(CategoryDataset dataset) { MultiplePiePlot plot = new MultiplePiePlot(dataset); plot.setDataExtractOrder(TableOrder.BY_ROW); plot.setBackgroundPaint(null);//from w ww .j ava 2 s . c o m plot.setOutlineStroke(null); JFreeChart pieChart = new JFreeChart(new PiePlot3D(null)); TextTitle seriesTitle = new TextTitle("Series Title", new Font("SansSerif", Font.BOLD, 12)); seriesTitle.setPosition(RectangleEdge.BOTTOM); pieChart.setTitle(seriesTitle); pieChart.removeLegend(); pieChart.setBackgroundPaint(null); plot.setPieChart(pieChart); if (tooltips) { PieToolTipGenerator tooltipGenerator = new StandardPieToolTipGenerator(); PiePlot pp = (PiePlot) plot.getPieChart().getPlot(); pp.setToolTipGenerator(tooltipGenerator); } if (urls) { PieURLGenerator urlGenerator = new StandardPieURLGenerator(); PiePlot pp = (PiePlot) plot.getPieChart().getPlot(); pp.setURLGenerator(urlGenerator); } JFreeChart chart = new JFreeChart("MultiplePie Chart 3D Demo 2", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); chart.setBackgroundPaint(Color.white); return chart; }
From source file:org.hxzon.demo.jfreechart.CategoryDatasetDemo2.java
private static JFreeChart createMultiplePieChart3D(CategoryDataset dataset) { MultiplePiePlot plot = new MultiplePiePlot(dataset); plot.setDataExtractOrder(TableOrder.BY_COLUMN); plot.setBackgroundPaint(null);/*from w w w . j a va 2 s.c o m*/ plot.setOutlineStroke(null); JFreeChart pieChart = new JFreeChart(new PiePlot3D(null)); TextTitle seriesTitle = new TextTitle("Series Title", new Font("SansSerif", Font.BOLD, 12)); seriesTitle.setPosition(RectangleEdge.BOTTOM); pieChart.setTitle(seriesTitle); pieChart.removeLegend(); pieChart.setBackgroundPaint(null); plot.setPieChart(pieChart); if (tooltips) { PieToolTipGenerator tooltipGenerator = new StandardPieToolTipGenerator(); PiePlot pp = (PiePlot) plot.getPieChart().getPlot(); pp.setToolTipGenerator(tooltipGenerator); } if (urls) { PieURLGenerator urlGenerator = new StandardPieURLGenerator(); PiePlot pp = (PiePlot) plot.getPieChart().getPlot(); pp.setURLGenerator(urlGenerator); } JFreeChart chart = new JFreeChart("MultiplePie Chart 3D Demo 1", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); chart.setBackgroundPaint(Color.white); PiePlot piePlot = (PiePlot) pieChart.getPlot(); GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64)); GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0)); GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0)); piePlot.setSectionPaint("First", gp0); piePlot.setSectionPaint("Second", gp1); piePlot.setSectionPaint("Third", gp2); return chart; }
From source file:com.xpn.xwiki.plugin.charts.ChartCustomizer.java
public static void customizeTitle(TextTitle title, ChartParams params, String prefix) { if (params.get(prefix + ChartParams.TITLE_FONT_SUFFIX) != null) { title.setFont(params.getFont(prefix + ChartParams.TITLE_FONT_SUFFIX)); } else {//www .java2 s . c o m title.setFont(JFreeChart.DEFAULT_TITLE_FONT); } if (params.get(prefix + ChartParams.TITLE_POSITION_SUFFIX) != null) { title.setPosition(params.getRectangleEdge(prefix + ChartParams.TITLE_POSITION_SUFFIX)); } if (params.get(prefix + ChartParams.TITLE_HORIZONTAL_ALIGNMENT_SUFFIX) != null) { title.setHorizontalAlignment( params.getHorizontalAlignment(prefix + ChartParams.TITLE_HORIZONTAL_ALIGNMENT_SUFFIX)); } if (params.get(prefix + ChartParams.TITLE_VERTICAL_ALIGNMENT_SUFFIX) != null) { title.setVerticalAlignment( params.getVerticalAlignment(prefix + ChartParams.TITLE_VERTICAL_ALIGNMENT_SUFFIX)); } if (params.get(prefix + ChartParams.TITLE_COLOR_SUFFIX) != null) { title.setPaint(params.getColor(prefix + ChartParams.TITLE_COLOR_SUFFIX)); } if (params.get(prefix + ChartParams.TITLE_BACKGROUND_COLOR_SUFFIX) != null) { title.setBackgroundPaint(params.getColor(prefix + ChartParams.TITLE_BACKGROUND_COLOR_SUFFIX)); } if (params.get(prefix + ChartParams.TITLE_PADDING_SUFFIX) != null) { title.setPadding(params.getRectangleInsets(prefix + ChartParams.TITLE_PADDING_SUFFIX)); } if (params.get(prefix + ChartParams.TITLE_URL_SUFFIX) != null) { title.setURLText(params.getString(prefix + ChartParams.TITLE_URL_SUFFIX)); } }
From source file:org.jfree.chart.demo.WaferMapChartDemo.java
/** * Creates a new demo./*from w ww .ja v a 2s . co m*/ * * @param title the frame title. */ public WaferMapChartDemo(final String title) { super(title); final WaferMapDataset dataset = DemoDatasetFactory.createRandomWaferMapDataset(5); final JFreeChart chart = ChartFactory.createWaferMapChart("Wafer Map Demo", // title dataset, // wafermapdataset PlotOrientation.VERTICAL, // vertical = notchdown true, // legend false, // tooltips false); // final Legend legend = chart.getLegend(); // legend.setAnchor(Legend.EAST); chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue)); final TextTitle copyright = new TextTitle("JFreeChart WaferMapPlot", new Font("SansSerif", Font.PLAIN, 9)); copyright.setPosition(RectangleEdge.BOTTOM); copyright.setHorizontalAlignment(HorizontalAlignment.RIGHT); chart.addSubtitle(copyright); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 400)); setContentPane(chartPanel); }
From source file:net.sf.statcvs.output.xml.chart.AbstractChart.java
/** * create chart with titles and credit information */// w ww.java 2s .c o m public void placeTitle() { Font font = new Font("SansSerif", Font.PLAIN, 12); Font creditInformationFont = new Font("SansSerif", Font.PLAIN, 9); TextTitle title = new TextTitle(this.title, font); title.setSpacer(new Spacer(Spacer.RELATIVE, 0.05, 0.05, 0.05, 0.0)); chart.addSubtitle(title); if (Settings.getShowCreditInformation()) { TextTitle copyright = new TextTitle("generated by statcvs-xml", creditInformationFont); copyright.setPosition(RectangleEdge.BOTTOM); copyright.setHorizontalAlignment(HorizontalAlignment.RIGHT); chart.addSubtitle(copyright); } chart.setBackgroundPaint(Color.white); }