List of usage examples for org.jfree.chart JFreeChart getTitle
public TextTitle getTitle()
From source file:net.sourceforge.atunes.kernel.controllers.stats.StatsDialogController.java
private void setAlbumsChart() { DefaultCategoryDataset dataset = getDataSet(HandlerProxy.getRepositoryHandler().getMostPlayedAlbums(10)); JFreeChart chart = ChartFactory.createStackedBarChart3D(LanguageTool.getString("ALBUM_MOST_PLAYED"), null, null, dataset, PlotOrientation.HORIZONTAL, false, false, false); chart.getTitle().setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); chart.setBackgroundPaint(new GradientPaint(0, 0, ColorDefinitions.GENERAL_NON_PANEL_TOP_GRADIENT_COLOR, 0, 200, ColorDefinitions.GENERAL_NON_PANEL_BOTTOM_GRADIENT_COLOR)); chart.setPadding(new RectangleInsets(5, 0, 0, 0)); NumberAxis axis = new NumberAxis(); axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); axis.setTickLabelFont(new Font(Font.SANS_SERIF, Font.PLAIN, 10)); chart.getCategoryPlot().setRangeAxis(axis); chart.getCategoryPlot().setForegroundAlpha(0.6f); chart.getCategoryPlot().getRenderer().setPaint(Color.GREEN); ((StatsDialog) frameControlled).getAlbumsChart() .setIcon(new ImageIcon(chart.createBufferedImage(710, 250))); }
From source file:net.sourceforge.atunes.kernel.controllers.stats.StatsDialogController.java
private void setArtistsChart() { DefaultCategoryDataset dataset = getDataSet(HandlerProxy.getRepositoryHandler().getMostPlayedArtists(10)); JFreeChart chart = ChartFactory.createStackedBarChart3D(LanguageTool.getString("ARTIST_MOST_PLAYED"), null, null, dataset, PlotOrientation.HORIZONTAL, false, false, false); chart.getTitle().setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); chart.setBackgroundPaint(new GradientPaint(0, 0, ColorDefinitions.GENERAL_NON_PANEL_TOP_GRADIENT_COLOR, 0, 200, ColorDefinitions.GENERAL_NON_PANEL_BOTTOM_GRADIENT_COLOR)); chart.setPadding(new RectangleInsets(5, 0, 0, 0)); NumberAxis axis = new NumberAxis(); axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); axis.setTickLabelFont(new Font(Font.SANS_SERIF, Font.PLAIN, 10)); chart.getCategoryPlot().setRangeAxis(axis); chart.getCategoryPlot().setForegroundAlpha(0.6f); chart.getCategoryPlot().getRenderer().setPaint(Color.GREEN); ((StatsDialog) frameControlled).getArtistsChart() .setIcon(new ImageIcon(chart.createBufferedImage(710, 250))); }
From source file:playground.thibautd.analysis.joinabletripsidentifier.DataPloter.java
private void formatChart(final JFreeChart chart) { TextTitle title = chart.getTitle(); Font font = title.getFont();//from w w w . jav a2s . c o m title.setFont(font.deriveFont(TITLE_FONT_SIZE)); chart.getPlot().setBackgroundPaint(new Color(1.0f, 1.0f, 1.0f, 1.0f)); }
From source file:UserInterface.CustomerRole.ViewProfileJPanel.java
private void purchasingBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_purchasingBtnActionPerformed DefaultCategoryDataset dataset = new DefaultCategoryDataset(); String series1 = "Purchases"; for (Order o : network.getMasterOrderCatalog().getOrderCatalog()) { if (o.getBuyer().equals(account)) { for (OrderItem oi : o.getOrderItemList()) { dataset.addValue(oi.getQuantity(), series1, o.getDate()); }//from w w w . ja va 2 s . c o m } } String chartTitle = "Purchase History"; String categoryAxisLabel = "TimeStamp"; String valueAxisLabel = "Values"; JFreeChart chart = ChartFactory.createLineChart(chartTitle, categoryAxisLabel, valueAxisLabel, dataset); chart.setBackgroundPaint(Color.white); chart.getTitle().setPaint(Color.BLACK); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.BLUE); ChartFrame frame = new ChartFrame("Graph of Purchase Habit", chart); frame.setVisible(true); frame.setSize(450, 350); }
From source file:com.romraider.logger.ecu.ui.handler.graph.GraphUpdateHandler.java
private JFreeChart createXYLineChart(LoggerData loggerData, XYDataset dataset, boolean combined) { String title = combined ? "Combined Data" : loggerData.getName(); String rangeAxisTitle = combined ? "Data" : buildRangeAxisTitle(loggerData); JFreeChart chart = ChartFactory.createXYLineChart(title, "Time (sec)", rangeAxisTitle, dataset, VERTICAL, false, true, false);/* www.j a v a2 s. c o m*/ chart.setBackgroundPaint(BLACK); chart.getTitle().setPaint(WHITE); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(BLACK); plot.getDomainAxis().setLabelPaint(WHITE); plot.getRangeAxis().setLabelPaint(WHITE); plot.getDomainAxis().setTickLabelPaint(LIGHT_GREY); plot.getRangeAxis().setTickLabelPaint(LIGHT_GREY); plot.setDomainGridlinePaint(DARK_GREY); plot.setRangeGridlinePaint(DARK_GREY); plot.setOutlinePaint(DARK_GREY); return chart; }
From source file:de.perdian.apps.dashboard.support.chart.ChartCreator.java
public JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createXYLineChart(this.getTitle(), null, null, dataset, PlotOrientation.VERTICAL, false, false, false); chart.setBackgroundPaint(null);// www . ja v a 2 s.com chart.setBackgroundImageAlpha(0.0f); if (chart.getTitle() != null) { chart.getTitle().setFont(new Font(this.getFontName(), Font.BOLD, 14)); } XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(null); plot.setBackgroundAlpha(0.0f); plot.setOutlinePaint(this.getColor()); plot.getDomainAxis().setVisible(false); plot.getDomainAxis().setAxisLineVisible(false); plot.getDomainAxis().setMinorTickCount(10); plot.getDomainAxis().setTickMarksVisible(false); if (this.getDomainTickUnits() != null) { plot.getDomainAxis().setStandardTickUnits(this.getDomainTickUnits()); } plot.getRangeAxis().setVisible(true); plot.getRangeAxis().setAxisLineVisible(false); plot.getRangeAxis().setTickLabelFont(new Font(this.getFontName(), Font.PLAIN, 10)); plot.getRangeAxis().setTickLabelPaint(this.getColor()); plot.getRangeAxis().setTickMarksVisible(false); if (this.getRangeTickUnits() != null) { plot.getRangeAxis().setStandardTickUnits(this.getRangeTickUnits()); } plot.getRangeAxis().setAttributedLabel(this.getRangeAxisLabel()); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); for (int i = 0; i < this.getStrokeDefinitions().size(); i++) { ChartStrokeDefinition strokeDefinition = this.getStrokeDefinitions().get(i); strokeDefinition.applyTo(renderer, i); } return chart; }
From source file:com.bdaum.zoom.report.internal.wizards.ReportComponent.java
private static void applyProperties(JFreeChart chart, Map<String, Object> properties) { if (properties != null) { String text = (String) properties.get(TITLE); if (text != null) { TextTitle title = chart.getTitle(); if (title == null) { title = new TextTitle(); chart.setTitle(title);/* ww w . j av a2 s . co m*/ } title.setText(text); Font titleFont = (Font) properties.get(TITLEFONT); if (titleFont != null) title.setFont(titleFont); Paint paint = (Paint) properties.get(TITLECOLOR); if (paint != null) title.setPaint(paint); } else chart.setTitle((TextTitle) null); Plot plot = chart.getPlot(); Paint paint = (Paint) properties.get(BGCOLOR); if (paint != null) plot.setBackgroundPaint(paint); paint = (Color) properties.get(OUTLINEPAINT); if (paint != null) plot.setOutlinePaint(paint); Stroke stroke = (Stroke) properties.get(OUTLINESTROKE); if (stroke != null) plot.setOutlineStroke(stroke); PlotOrientation orientation = (PlotOrientation) properties.get(ORIENTATION); Axis domainAxis = null; Axis rangeAxis = null; if (plot instanceof CategoryPlot) { CategoryPlot p = (CategoryPlot) plot; domainAxis = p.getDomainAxis(); rangeAxis = p.getRangeAxis(); if (orientation != null) p.setOrientation(orientation); } else if (plot instanceof XYPlot) { XYPlot p = (XYPlot) plot; domainAxis = p.getDomainAxis(); rangeAxis = p.getRangeAxis(); if (orientation != null) p.setOrientation(orientation); } if (domainAxis != null) applyAxisProperties(domainAxis, "x", properties); //$NON-NLS-1$ if (rangeAxis != null) applyAxisProperties(rangeAxis, "y", properties); //$NON-NLS-1$ Boolean anti = (Boolean) properties.get(ANTIALIAS); if (anti != null) chart.setAntiAlias(anti); paint = (Paint) properties.get(CANVASPAINT); if (paint != null) chart.setBackgroundPaint(paint); } }
From source file:ch.bfh.lca._15h.server.exporter.ExportHandler.java
/** * Saves the Chart to a JPG on a specific Filename * @param chart JFreeChart Chart.//from www . j a v a2 s . c om * @param fileName Full Path of File * @param width Width of image * @param height height of image * @return * @throws IOException */ private String saveChartToJPG(final JFreeChart chart, String fileName, final int width, final int height) throws IOException { String result = null; if (chart != null) { if (fileName == null) { final String chartTitle = chart.getTitle().getText(); if (chartTitle != null) { fileName = chartTitle; } else { fileName = "chart"; } } result = fileName + ".jpg"; ChartUtilities.saveChartAsJPEG(new File(result), chart, width, height); } //else: input unavailable return result; }
From source file:jmbench.plots.SummaryWhiskerPlot.java
public JFreeChart createChart() { JFreeChart chart = ChartFactory.createBoxAndWhiskerChart(title, "Matrix Libraries", "Relative Performance", dataSet, true);// www. j av a2 s . c o m CategoryPlot plot = chart.getCategoryPlot(); plot.setDomainGridlinesVisible(true); plot.setBackgroundPaint(new Color(230, 230, 230)); plot.setDomainGridlinePaint(new Color(50, 50, 50, 50)); plot.setDomainGridlineStroke(new BasicStroke(78f)); chart.getTitle().setFont(new Font("Times New Roman", Font.BOLD, 24)); String foo = "( Higher is Better )"; if (subtitle != null) foo += " ( " + subtitle + " )"; chart.addSubtitle(new TextTitle(foo, new Font("SansSerif", Font.ITALIC, 12))); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }
From source file:com.esofthead.mycollab.community.ui.chart.PieChartWrapper.java
@Override protected JFreeChart createChart() { // create the chart... pieDataSet = createDataset();// www. java 2s.c o m final JFreeChart chart = ChartFactory.createPieChart3D("", // chart // title pieDataSet, // data false, // include legend true, // tooltips? false // URLs? ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.getTitle().setPaint(new Color(0x5E5E5E)); chart.setBorderVisible(false); // set the background color for the chart... final PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setOutlineVisible(false); plot.setInsets(RectangleInsets.ZERO_INSETS); plot.setStartAngle(290); plot.setBackgroundPaint(Color.white); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); plot.setNoDataMessage("No data to display"); plot.setLabelGenerator(new JFreeChartLabelCustom()); final List keys = pieDataSet.getKeys(); for (int i = 0; i < keys.size(); i++) { final Comparable key = (Comparable) keys.get(i); plot.setSectionPaint(key, Color.decode( "0x" + GenericChartWrapper.CHART_COLOR_STR[i % GenericChartWrapper.CHART_COLOR_STR.length])); } // OPTIONAL CUSTOMISATION COMPLETED. return chart; }