List of usage examples for org.jfree.chart JFreeChart getTitle
public TextTitle getTitle()
From source file:org.talend.dataprofiler.chart.util.TopChartFactory.java
private static void decorateCategoryPlot(JFreeChart chart) { XYPlot plot = chart.getXYPlot();// w w w .j a v a2 s. c o m XYItemRenderer render = plot.getRenderer(); ValueAxis domainAxis = plot.getDomainAxis(); ValueAxis valueAxis = plot.getRangeAxis(); Font font = new Font("Tahoma", Font.BOLD, BASE_ITEM_LABEL_SIZE); //$NON-NLS-1$ render.setBaseItemLabelFont(font); font = new Font("sans-serif", Font.BOLD, BASE_LABEL_SIZE); //$NON-NLS-1$ domainAxis.setLabelFont(font); font = new Font("sans-serif", Font.BOLD, BASE_LABEL_SIZE); //$NON-NLS-1$ valueAxis.setLabelFont(font); font = new Font("sans-serif", Font.PLAIN, BASE_TICK_LABEL_SIZE); //$NON-NLS-1$ domainAxis.setTickLabelFont(font); valueAxis.setTickLabelFont(font); font = new Font("Tahoma", Font.PLAIN, BASE_LEGEND_LABEL_SIZE); //$NON-NLS-1$ LegendTitle legend = chart.getLegend(); if (legend != null) { legend.setItemFont(font); } font = new Font("sans-serif", Font.BOLD, BASE_TITLE_LABEL_SIZE); //$NON-NLS-1$ TextTitle title = chart.getTitle(); if (title != null) { title.setFont(font); } font = null; if (render instanceof BarRenderer) { int rowCount = chart.getCategoryPlot().getDataset().getRowCount(); domainAxis.setUpperMargin(0.1); // domainAxis.setMaximumCategoryLabelLines(10); ((BarRenderer) render).setItemMargin(-0.40 * rowCount); } // set color int rowCount = chart.getXYPlot().getDataset().getSeriesCount(); for (int i = 0; i < rowCount; i++) { plot.getRenderer().setSeriesPaint(i, Color.RED); } }
From source file:org.limy.eclipse.qalab.task.DistanceGraphTask.java
/** * @param dataset /*from w ww. ja v a 2 s .c om*/ * @throws IOException * */ private void drawGraph(XYDataset dataset) throws IOException { JFreeChart chart = ChartFactory.createScatterPlot("Distance from the Main Sequence", "Instability", "Abstractness", dataset, PlotOrientation.VERTICAL, false, false, false); XYPlot plot = chart.getXYPlot(); plot.getRenderer().addAnnotation( new XYLineAnnotation(-0.1, 1.1, 1.1, -0.1, new BasicStroke(2), new Color(50, 220, 50)), Layer.BACKGROUND); plot.getRenderer().setShape(new Ellipse2D.Double(-4, -4, 8, 8)); plot.getRenderer().setPaint(new Color(0xec, 0x76, 0x37)); plot.getDomainAxis().setRangeWithMargins(0, 1); plot.getRangeAxis().setRangeWithMargins(0, 1); chart.getTitle().setPaint(Color.BLUE); plot.setDomainCrosshairVisible(true); plot.setDomainCrosshairPaint(Color.GRAY); plot.setRangeCrosshairVisible(true); plot.setRangeCrosshairPaint(Color.GRAY); LimyGraphUtils.writeImagePng(chart, out, 400, 380); }
From source file:fr.amap.lidar.amapvox.chart.VoxelsToChart.java
public JFreeChart createChart(String title, XYSeriesCollection dataset, String xAxisLabel, String yAxisLabel) { JFreeChart chart = ChartFactory.createXYLineChart(title, xAxisLabel, yAxisLabel, dataset, PlotOrientation.VERTICAL, true, true, false); String fontName = "Palatino"; chart.getTitle().setFont(new Font(fontName, Font.BOLD, 18)); XYPlot plot = (XYPlot) chart.getPlot(); plot.setDomainPannable(true);//w ww . j av a 2s.c o m 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().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); LegendTitle subtitle = (LegendTitle) chart.getSubtitles().get(0); subtitle.setHorizontalAlignment(HorizontalAlignment.LEFT); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); Ellipse2D.Float shape = new Ellipse2D.Float(-2.5f, -2.5f, 5.0f, 5.0f); for (int i = 0; i < voxelFiles.length; i++) { renderer.setSeriesShape(i, shape); renderer.setSeriesPaint(i, voxelFiles[i].getSeriesParameters().getColor()); renderer.setLegendTextPaint(i, voxelFiles[i].getSeriesParameters().getColor()); } } return chart; }
From source file:net.sf.fspdfs.chartthemes.spring.AegeanChartTheme.java
/** * *///from ww w . j a va2s . c o m protected void configureChart(JFreeChart jfreeChart, JRChartPlot jrPlot) throws JRException { super.configureChart(jfreeChart, jrPlot); TextTitle title = jfreeChart.getTitle(); if (title != null) { RectangleInsets padding = title.getPadding(); double bottomPadding = Math.max(padding.getBottom(), 15d); title.setPadding(padding.getTop(), padding.getLeft(), bottomPadding, padding.getRight()); } }
From source file:net.sourceforge.atunes.kernel.modules.statistics.StatsDialogController.java
/** * Puts image with chart in given label, with title and data provided * //from w w w.j ava 2 s . c o m * @param data * @param titleKey * @param chartLabel */ private void setChart(final List<?> data, final String titleKey, final JLabel chartLabel) { DefaultCategoryDataset dataset = getDataSet(data); JFreeChart chart = ChartFactory.createStackedBarChart3D(I18nUtils.getString(titleKey), null, null, dataset, PlotOrientation.HORIZONTAL, false, false, false); chart.setBackgroundPaint(Color.WHITE); chart.setPadding(new RectangleInsets(5, 0, 0, 0)); NumberAxis axis = new NumberAxis(); axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); chart.setBackgroundPaint(GuiUtils.getBackgroundColor()); chart.getTitle().setPaint(GuiUtils.getForegroundColor()); chart.getCategoryPlot().setRangeAxis(axis); chart.getCategoryPlot().setForegroundAlpha(1f); chart.getCategoryPlot().getRenderer().setSeriesPaint(0, Color.GREEN); chart.getCategoryPlot().getDomainAxis().setTickLabelPaint(GuiUtils.getForegroundColor()); chart.getCategoryPlot().getRangeAxis().setTickLabelPaint(GuiUtils.getForegroundColor()); chart.getPlot().setBackgroundPaint(GuiUtils.getBackgroundColor()); chartLabel.setIcon(new ImageIcon(chart.createBufferedImage(710, 250))); }
From source file:com.mxgraph.examples.swing.chart.TimeSeriesChartDemo1.java
/** * Creates a chart./* w w w.ja v a 2s . co m*/ * * @param dataset a dataset. * * @return A chart. */ public static JFreeChart createChart(XYDataset dataset, String name) { JFreeChart chart = ChartFactory.createTimeSeriesChart(name, // title "Date", // x-axis label "Value", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); renderer.setItemLabelGenerator(new StandardXYItemLabelGenerator()); renderer.setBaseItemLabelsVisible(true); // renderer.setItemLabelsVisible(true); // renderer.setBaseShapesVisible(true); // renderer.setBaseShapesFilled(true); // renderer.setLegendItemLabelGenerator(new StandardPieSectionLabelGenerator("{0}={1}({2})")); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss"/*"yyyy-MM-dd HH:mm:ss"*/)); chart.getTitle().setFont(new Font("", Font.BOLD, 15)); chart.getLegend().setItemFont(new Font("", Font.BOLD, 15)); // plot.getRangeAxis().setLabelFont(new Font("", Font.BOLD, 15)); // chart.getLegend().setItemFont(new Font("", Font.ITALIC, 15)); // plot.getDomainAxis().setTickLabelFont(new Font("", 1, 15)); // plot.getDomainAxis().setLabelFont(new Font("", 1, 12)); return chart; }
From source file:net.sf.jasperreports.chartthemes.spring.AegeanChartTheme.java
@Override protected void configureChart(JFreeChart jfreeChart, JRChartPlot jrPlot) throws JRException { super.configureChart(jfreeChart, jrPlot); TextTitle title = jfreeChart.getTitle(); if (title != null) { RectangleInsets padding = title.getPadding(); double bottomPadding = Math.max(padding.getBottom(), 15d); title.setPadding(padding.getTop(), padding.getLeft(), bottomPadding, padding.getRight()); }//from ww w . ja v a 2s . c o m }
From source file:com.polivoto.vistas.Charts.java
private JPanel hacerPiePanel(Pregunta pregunta, List<Opcion> opciones) { JPanel panel = new JPanel(new BorderLayout()); panel.setBackground(Color.white); DefaultPieDataset data = new DefaultPieDataset(); // Fuente de Datos for (Opcion opc : opciones) { data.setValue(opc.getNombre(), opc.getCantidad()); }// www .j a v a 2 s. co m // Creando el Grafico JFreeChart chart = ChartFactory.createPieChart("\n" + pregunta.getTitulo(), data, true, false, //TOOLTIPS false); chart.setBackgroundPaint(Color.white); chart.getTitle().setFont(new Font("Roboto", 0, 28)); // Crear el Panel del Grafico con ChartPanel ChartPanel chartPanel = new ChartPanel(chart); PiePlot plot = (PiePlot) chart.getPlot(); Rectangle bounds = panel.getBounds(); chartPanel.setBounds(bounds.x, bounds.y, bounds.height, bounds.height); panel.add(chartPanel); plot.setLabelGenerator(null); plot.setBackgroundPaint(Color.white); plot.setOutlineVisible(false); //StandardPieSectionLabelGenerator labels = new StandardPieSectionLabelGenerator("{0} = {1}"); //plot.setLabelGenerator(labels); plot.setBaseSectionOutlinePaint(Color.white); plot.setShadowXOffset(0); plot.setShadowYOffset(0); //#7cb5ec,#f45b5b,#90ed7d,#434348, //#f7a35c,#8085e9,#f15c80,#e4d354, //#2b908f,#91e8e1 Color[] colors = { new Color(124, 181, 236), new Color(244, 91, 91), new Color(144, 237, 125), new Color(67, 67, 72), new Color(247, 163, 92), new Color(128, 133, 233), new Color(241, 92, 128), new Color(228, 211, 84), new Color(43, 144, 143), new Color(145, 232, 225) }; PieRenderer renderer = new PieRenderer(colors); renderer.setColor(plot, data); LegendTitle legend = chart.getLegend(); legend.setPosition(RectangleEdge.RIGHT); Font nwfont = new Font("Roboto", 0, 18); legend.setItemFont(nwfont); legend.setFrame(new BlockBorder(0, 0, 0, 90, Color.white)); legend.setBackgroundPaint(Color.WHITE); legend.setItemLabelPadding(new RectangleInsets(8, 8, 8, 0)); //RectangleInsets padding = new RectangleInsets(5, 5, 5, 5); //legend.setItemLabelPadding(padding); plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{1} {0}")); plot.setLegendItemShape(new Rectangle(25, 25)); return panel; }
From source file:guineu.modules.visualization.intensityboxplot.IntensityBoxPlotFrame.java
public IntensityBoxPlotFrame(ParameterSet parameters) { super("", true, true, true, true); String title = "Intensity box plot [" + GuineuCore.getDesktop().getSelectedDataFiles()[0].getDatasetName() + "]"; String xAxisLabel = parameters.getParameter(IntensityBoxPlotParameters.xAxisValueSource).getValue() .toString();// www .j a v a2s . co m this.xAxisValueSource = parameters.getParameter(IntensityBoxPlotParameters.xAxisValueSource).getValue(); // create dataset this.selectedFiles = parameters.getParameter(IntensityBoxPlotParameters.dataFiles).getValue(); this.selectedRows = parameters.getParameter(IntensityBoxPlotParameters.selectedRows).getValue(); this.dataset = this.createSampleDataset(); // create new JFreeChart logger.finest("Creating new chart instance"); // chart = ChartFactory.createLineChart(title, xAxisLabel, "Intensity", // dataset, PlotOrientation.VERTICAL, true, true, false); // CategoryPlot plot = (CategoryPlot) chart.getPlot(); // set renderer BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setFillBox(true); // set tooltip generator renderer.setBaseToolTipGenerator(new BoxAndWhiskerToolTipGenerator()); // plot.setRenderer(renderer); // plot.setBackgroundPaint(Color.white); // CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis(); // xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); // set y axis properties final CategoryAxis xAxis = new CategoryAxis("Type"); final NumberAxis yAxis = new NumberAxis("Value"); NumberFormat yAxisFormat = new DecimalFormat("0.0E0"); yAxis.setNumberFormatOverride(yAxisFormat); final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); final JFreeChart chart = new JFreeChart("Intensity Box plot", new Font("SansSerif", Font.BOLD, 14), plot, true); chart.setBackgroundPaint(Color.white); // create chart JPanel ChartPanel chartPanel = new ChartPanel(chart); add(chartPanel, BorderLayout.CENTER); // IntensityBoxPlotToolBar toolBar = new IntensityBoxPlotToolBar(this); // add(toolBar, BorderLayout.EAST); // disable maximum size (we don't want scaling) chartPanel.setMaximumDrawWidth(Integer.MAX_VALUE); chartPanel.setMaximumDrawHeight(Integer.MAX_VALUE); // set title properties TextTitle chartTitle = chart.getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); LegendTitle legend = chart.getLegend(); legend.setItemFont(legendFont); legend.setBorder(0, 0, 0, 0); // set shape provider IntensityBoxPlotDrawingSupplier shapeSupplier = new IntensityBoxPlotDrawingSupplier(); plot.setDrawingSupplier(shapeSupplier); setTitle(title); setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE); setBackground(Color.white); pack(); }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.piecharts.LinkablePie.java
public JFreeChart createChart(DatasetMap datasets) { Dataset dataset = (Dataset) datasets.getDatasets().get("1"); boolean document_composition = false; if (mode.equalsIgnoreCase(SpagoBIConstants.DOCUMENT_COMPOSITION)) document_composition = true;// w ww .j a v a2s . com JFreeChart chart = null; if (!threeD) { chart = ChartFactory.createPieChart(name, (PieDataset) dataset, // data legend, // include legend true, false); chart.setBackgroundPaint(color); TextTitle title = chart.getTitle(); title.setToolTipText("A title tooltip!"); PiePlot plot = (PiePlot) chart.getPlot(); plot.setLabelFont(new Font(defaultLabelsStyle.getFontName(), Font.PLAIN, defaultLabelsStyle.getSize())); plot.setCircular(false); plot.setLabelGap(0.02); plot.setNoDataMessage("No data available"); if (percentage == false) { plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({1})")); } else { plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({2})")); } MyPieUrlGenerator pieUrl = new MyPieUrlGenerator(rootUrl); pieUrl.setDocument_composition(document_composition); pieUrl.setCategoryUrlLabel(categoryUrlName); pieUrl.setDrillDocTitle(drillDocTitle); pieUrl.setTarget(target); plot.setURLGenerator(pieUrl); } else { chart = ChartFactory.createPieChart3D(name, (PieDataset) dataset, // data true, // include legend true, false); chart.setBackgroundPaint(color); TextTitle title = chart.getTitle(); title.setToolTipText("A title tooltip!"); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setDarkerSides(true); plot.setStartAngle(290); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(1.0f); plot.setDepthFactor(0.2); plot.setLabelFont(new Font(defaultLabelsStyle.getFontName(), Font.PLAIN, defaultLabelsStyle.getSize())); plot.setCircular(false); plot.setLabelGap(0.02); plot.setNoDataMessage("No data available"); //org.jfree.chart.renderer.category.BarRenderer renderer = new org.jfree.chart.renderer.category.AreaRenderer); MyPieUrlGenerator pieUrl = new MyPieUrlGenerator(rootUrl); pieUrl.setDocument_composition(document_composition); pieUrl.setCategoryUrlLabel(categoryUrlName); pieUrl.setDrillDocTitle(drillDocTitle); pieUrl.setTarget(target); plot.setURLGenerator(pieUrl); if (percentage == false) { plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({1})")); } else { plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({2})")); } } TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); } return chart; }