List of usage examples for org.jfree.chart.title TextTitle setPaint
public void setPaint(Paint paint)
From source file:edu.gmu.cs.sim.util.media.chart.PieChartGenerator.java
protected void buildChart() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); chart = ChartFactory.createMultiplePieChart("Untitled Chart", dataset, org.jfree.util.TableOrder.BY_COLUMN, false, true, false);/* w w w .j av a 2 s. co m*/ chart.setAntiAlias(true); //chartPanel = new ScrollableChartPanel(chart, true); chartPanel = buildChartPanel(chart); //chartHolder.getViewport().setView(chartPanel); setChartPanel(chartPanel); JFreeChart baseChart = (JFreeChart) ((MultiplePiePlot) (chart.getPlot())).getPieChart(); PiePlot base = (PiePlot) (baseChart.getPlot()); base.setIgnoreZeroValues(true); base.setLabelOutlinePaint(java.awt.Color.WHITE); base.setLabelShadowPaint(java.awt.Color.WHITE); base.setMaximumLabelWidth(0.25); // allow bigger labels by a bit (this will make the chart smaller) base.setInteriorGap(0.000); // allow stretch to compensate for the bigger label width base.setLabelBackgroundPaint(java.awt.Color.WHITE); base.setOutlinePaint(null); base.setBackgroundPaint(null); base.setShadowPaint(null); base.setSimpleLabels(false); // I think they're false anyway // change the look of the series title to be smaller StandardChartTheme theme = new StandardChartTheme("Hi"); TextTitle title = new TextTitle("Whatever", theme.getLargeFont()); title.setPaint(theme.getAxisLabelPaint()); title.setPosition(RectangleEdge.BOTTOM); baseChart.setTitle(title); // this must come last because the chart must exist for us to set its dataset setSeriesDataset(dataset); }
From source file:org.knime.knip.core.ui.imgviewer.panels.HistogramBC.java
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); // Background of Histogram inside border //plot.setBackgroundPaint(new Color(235,235,235)); plot.setBackgroundPaint(Color.white); // change from white to gray plot.setRangeGridlinePaint(Color.gray); plot.setDomainGridlinePaint(Color.gray); // set lines invisible plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); plot.setOutlineVisible(true);//from w w w. j av a2 s . com 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); } }
From source file:org.psystems.dicom.browser.server.stat.StatDailyLoadChartServlet2.java
private JFreeChart getChart(CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createStackedBarChart("Stacked Bar Chart Demo 4", // chart title "Category", // domain axis label "", // range axis label dataset, // data PlotOrientation.VERTICAL, // the plot orientation true, // legend true, // tooltips false // urls );/* w w w.j a va2 s. com*/ TextTitle title = new TextTitle(" ()", labelFont); title.setPaint(new Color(68, 99, 156)); chart.setTitle(title); GroupedStackedBarRenderer renderer = new GroupedStackedBarRenderer(); KeyToGroupMap map = new KeyToGroupMap("G1"); map.mapKeyToGroup("product 1 (US)", "G1"); map.mapKeyToGroup("product 1 (Europe)", "G1"); renderer.setSeriesToGroupMap(map); BarPainter b = new StandardBarPainter(); // BarPainter b = new GradientBarPainter(0,0.9,0.9); renderer.setBarPainter(b); renderer.setSeriesPaint(0, color1); renderer.setSeriesPaint(1, color2); SubCategoryAxis domainAxis = new SubCategoryAxis("DCM / JPG "); domainAxis.setCategoryMargin(0.05); domainAxis.setTickLabelFont(dateFont); // domainAxis.addSubCategory("Product 1"); // domainAxis.addSubCategory("Product 2"); // domainAxis.addSubCategory("Product 3"); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setDomainAxis(domainAxis); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.red); plot.setRangeGridlinePaint(Color.lightGray); ValueAxis v = plot.getRangeAxis(); v.setTickLabelFont(dateFont); // plot.setRangeAxis(ValueAxis); //plot.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT); plot.setRenderer(renderer); plot.setFixedLegendItems(createLegendItems()); return chart; }
From source file:org.openfaces.component.chart.impl.plots.MultiplePiePlotAdapter.java
private TextTitle getSeriesTitle(Chart chart) { StyleObjectModel cssChartViewModel = chart.getChartView().getStyleObjectModel(); TextTitle seriesTitle; Font f = CSSUtil.getFont(cssChartViewModel); if (f != null) { seriesTitle = new TextTitle("Series Title", f); } else {/*from w w w. j av a 2 s . co m*/ seriesTitle = new TextTitle("Series Title", new Font("SansSerif", Font.BOLD, 12)); } if (cssChartViewModel.getColor() != null) { seriesTitle.setPaint(cssChartViewModel.getColor()); } seriesTitle.setPosition(RectangleEdge.BOTTOM); return seriesTitle; }
From source file:org.psystems.dicom.browser.server.stat.StatDailyLoadChartServlet.java
public JFreeChart getChart(CategoryDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createBarChart3D(" ", // chart title "", // domain axis label " (.)", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? );/*from w w w . j av a 2 s .co m*/ // #44639C; TextTitle title = new TextTitle(" ", labelFont); // Paint paint = title.getPaint(); title.setPaint(new Color(68, 99, 156)); chart.setTitle(title); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // set the background color for the chart... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); // final IntervalMarker target = new IntervalMarker(2000000, 3000000); // target.setLabel(" "); // target.setLabelFont(new Font("SansSerif", Font.ITALIC, 11)); // target.setLabelAnchor(RectangleAnchor.LEFT); // target.setLabelTextAnchor(TextAnchor.CENTER_LEFT); // target.setPaint(new Color(222, 222, 255, 128)); // plot.addRangeMarker(target, Layer.BACKGROUND); // set the range axis to display integers only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setTickLabelFont(labelFont); // disable bar outlines... final BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); renderer.setItemMargin(0.10); // set up gradient paints for series... final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.blue); final GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.lightGray); final GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, Color.lightGray); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setSeriesPaint(2, gp2); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 4.0) // CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0) ); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:org.psystems.dicom.browser.server.stat.StatClientRequestsChartServlet2.java
private JFreeChart getChart(CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createStackedBarChart("Stacked Bar Chart Demo 4", // chart title "Category", // domain axis label "", // range axis label dataset, // data PlotOrientation.VERTICAL, // the plot orientation true, // legend true, // tooltips false // urls );//w w w.ja v a 2 s. c o m TextTitle title = new TextTitle("? ? ? (.)", labelFont); title.setPaint(new Color(68, 99, 156)); chart.setTitle(title); GroupedStackedBarRenderer renderer = new GroupedStackedBarRenderer(); KeyToGroupMap map = new KeyToGroupMap("G1"); map.mapKeyToGroup("product 1 (US)", "G1"); map.mapKeyToGroup("product 1 (Europe)", "G1"); renderer.setSeriesToGroupMap(map); BarPainter b = new StandardBarPainter(); // BarPainter b = new GradientBarPainter(0,0.9,0.9); renderer.setBarPainter(b); renderer.setSeriesPaint(0, color1); renderer.setSeriesPaint(1, color2); SubCategoryAxis domainAxis = new SubCategoryAxis(" / "); domainAxis.setCategoryMargin(0.05); domainAxis.setTickLabelFont(dateFont); // domainAxis.addSubCategory("Product 1"); // domainAxis.addSubCategory("Product 2"); // domainAxis.addSubCategory("Product 3"); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setDomainAxis(domainAxis); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.red); plot.setRangeGridlinePaint(Color.lightGray); ValueAxis v = plot.getRangeAxis(); v.setTickLabelFont(dateFont); // plot.setRangeAxis(ValueAxis); //plot.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT); plot.setRenderer(renderer); plot.setFixedLegendItems(createLegendItems()); return chart; }
From source file:org.n52.io.measurement.img.ChartIoHandler.java
private void addNotice(JFreeChart chart) { TextTitle notice = new TextTitle(); String msg = i18n.get("msg.io.chart.notice"); if (msg != null && !msg.isEmpty()) { notice.setText(msg);//from w w w . j a v a2 s.c om notice.setPaint(BLACK); notice.setFont(FONT_LABEL_SMALL); notice.setPosition(RectangleEdge.BOTTOM); notice.setHorizontalAlignment(HorizontalAlignment.RIGHT); notice.setVerticalAlignment(VerticalAlignment.BOTTOM); notice.setPadding(new RectangleInsets(0, 0, 20, 20)); chart.addSubtitle(notice); } }
From source file:ch.zhaw.simulation.diagram.charteditor.DefaultTitleEditor.java
/** * Sets the properties of the specified title to match the properties * defined on this panel./*from ww w . ja v a2 s.c om*/ * * @param chart * the chart whose title is to be modified. */ public void setTitleProperties(JFreeChart chart) { TextTitle title = chart.getTitle(); if (title == null) { title = new TextTitle(); chart.setTitle(title); } title.setText(getTitleText()); title.setFont(getTitleFont()); title.setPaint(getTitlePaint()); title.setVisible(this.showTitle); }
From source file:org.n52.io.type.quantity.handler.img.ChartIoHandler.java
private void addNotice(JFreeChart chart) { TextTitle notice = new TextTitle(); String msg = i18n.get("msg.io.chart.notice"); if (msg != null && !msg.isEmpty()) { notice.setText(msg);//from ww w . j a v a 2 s . co m notice.setPaint(Color.BLACK); notice.setFont(LabelConstants.FONT_LABEL_SMALL); notice.setPosition(RectangleEdge.BOTTOM); notice.setHorizontalAlignment(HorizontalAlignment.RIGHT); notice.setVerticalAlignment(VerticalAlignment.BOTTOM); notice.setPadding(new RectangleInsets(0, 0, 20, 20)); chart.addSubtitle(notice); } }
From source file:com.rcp.wbw.demo.editor.SWTTitleEditor.java
/** * Sets the properties of the specified title to match the properties * defined on this panel./*from ww w . j a v a 2s . c o m*/ * * @param chart * the chart whose title is to be modified. */ public void setTitleProperties(JFreeChart chart) { if (this.showTitle) { TextTitle title = chart.getTitle(); if (title == null) { title = new TextTitle(); chart.setTitle(title); } title.setText(getTitleText()); title.setFont(SWTUtils.toAwtFont(getDisplay(), getTitleFont(), true)); title.setPaint(SWTUtils.toAwtColor(getTitleColor())); } else { chart.setTitle((TextTitle) null); } }