List of usage examples for org.jfree.chart ChartUtilities applyCurrentTheme
public static void applyCurrentTheme(JFreeChart chart)
From source file:net.nosleep.superanalyzer.analysis.views.EncodingKindView.java
private void createChart() { _chart = ChartFactory.createPieChart3D(Misc.getString("KINDS_OF_MUSIC_FILES"), _dataset, false, true, false);/*from w w w .j ava 2s . c o m*/ PiePlot3D plot = (PiePlot3D) _chart.getPlot(); plot.setDarkerSides(true); plot.setStartAngle(PieRotator.angle); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); plot.setNoDataMessage("No data to display"); plot.setInsets(new RectangleInsets(10, 10, 10, 10)); plot.setOutlineVisible(false); plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({2})")); _chart.addSubtitle(HomePanel.createSubtitle(Misc.getString("KINDS_OF_MUSIC_FILES_SUBTITLE"))); ChartUtilities.applyCurrentTheme(_chart); plot.setBackgroundPaint(Color.white); _chart.setBorderVisible(false); plot.setIgnoreZeroValues(true); // plot.setAutoPopulateSectionPaint(false); // Misc.formatChart(plot); }
From source file:sas.BarChart.java
public static JFreeChart createChart(CategoryDataset categorydataset, String name, String type, String t) { JFreeChart jfreechart = ChartFactory.createLineChart(name, null, type, categorydataset, PlotOrientation.VERTICAL, false, true, false); jfreechart.addSubtitle(new TextTitle(t)); TextTitle texttitle = new TextTitle(""); texttitle.setFont(new Font("SansSerif", 0, 10)); texttitle.setPosition(RectangleEdge.BOTTOM); texttitle.setHorizontalAlignment(HorizontalAlignment.CENTER); jfreechart.addSubtitle(texttitle);//from w w w . ja v a 2 s . c o m CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setRangePannable(true); categoryplot.setRangeGridlinesVisible(false); java.net.URL url = (BarChart.class).getClassLoader().getResource("line_Chart_example.png"); if (url != null) { ImageIcon imageicon = new ImageIcon(url); jfreechart.setBackgroundImage(imageicon.getImage()); categoryplot.setBackgroundPaint(null); } NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); ChartUtilities.applyCurrentTheme(jfreechart); LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer(); lineandshaperenderer.setBaseShapesVisible(true); lineandshaperenderer.setDrawOutlines(true); lineandshaperenderer.setUseFillPaint(true); lineandshaperenderer.setBaseFillPaint(Color.white); lineandshaperenderer.setSeriesStroke(0, new BasicStroke(3F)); lineandshaperenderer.setSeriesOutlineStroke(0, new BasicStroke(2.0F)); lineandshaperenderer.setSeriesShape(0, new java.awt.geom.Ellipse2D.Double(-5D, -5D, 10D, 10D)); return jfreechart; }
From source file:org.jfree.chart.demo.HighLowChartDemo3.java
private static JFreeChart createChart(OHLCDataset ohlcdataset) { JFreeChart jfreechart = ChartFactory.createHighLowChart("OHLC Demo 3", "Time", "Price", ohlcdataset, true); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); HighLowRenderer highlowrenderer = (HighLowRenderer) xyplot.getRenderer(); highlowrenderer.setBaseStroke(new BasicStroke(2.0F)); highlowrenderer.setSeriesPaint(0, Color.blue); DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setAutoRangeIncludesZero(false); NumberAxis numberaxis1 = new NumberAxis("Price 2"); numberaxis1.setAutoRangeIncludesZero(false); xyplot.setRangeAxis(1, numberaxis1); xyplot.setDataset(1, createDataset2()); xyplot.setRenderer(1, new CandlestickRenderer(10D)); xyplot.mapDatasetToRangeAxis(1, 1);//from w ww . j av a 2 s. com ChartUtilities.applyCurrentTheme(jfreechart); return jfreechart; }
From source file:net.nosleep.superanalyzer.analysis.views.PlayCountView.java
private void createChart() { _chart = ChartFactory.createXYBarChart(Misc.getString("PLAY_COUNT"), Misc.getString("PLAY_COUNT"), false, Misc.getString("NUMBER_OF_SONGS"), _dataset, PlotOrientation.VERTICAL, false, true, false); _chart.addSubtitle(HomePanel.createSubtitle(Misc.getString("PLAY_COUNT_SUBTITLE"))); // then customise it a little... XYPlot plot = (XYPlot) _chart.getPlot(); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer(); plot.setForegroundAlpha(0.75f);/*from w ww. j ava 2s. c om*/ ChartUtilities.applyCurrentTheme(_chart); renderer.setBarPainter(new StandardXYBarPainter()); renderer.setShadowVisible(false); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); domainAxis.setLowerMargin(0); domainAxis.setUpperMargin(0); // domainAxis.setLowerBound(0); // domainAxis.setAutoRangeIncludesZero(true); // domainAxis.setAutoRangeStickyZero(true); Misc.formatChart(plot); renderer.setSeriesPaint(0, Theme.getColorSet()[1]); }
From source file:net.nosleep.superanalyzer.analysis.views.MostPlayedDGView.java
public JFreeChart createChart(String title, String domainLabel, DefaultCategoryDataset dataset) { JFreeChart chart = ChartFactory.createBarChart3D(title, // chart title domainLabel, // domain axis label Misc.getString("SONG_COUNT"), // range axis label dataset, // data PlotOrientation.HORIZONTAL, // orientation false, // include legend true, // tooltips? false // URLs? );// w w w.jav a2 s . c o m // _artistChart.addSubtitle(HomePanel // .createSubtitle("How many songs you have in each genre")); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); ChartUtilities.applyCurrentTheme(chart); Misc.formatChart(plot); plot.getDomainAxis().setMaximumCategoryLabelWidthRatio(0.5f); CategoryItemRenderer renderer = plot.getRenderer(); BarRenderer3D barRenderer = (BarRenderer3D) renderer; barRenderer.setWallPaint(Color.white); barRenderer.setSeriesPaint(0, Theme.getColorSet()[1]); return chart; }
From source file:org.jfree.chart.demo.MouseOverDemo1.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createBarChart("Mouseover Demo 1", "Category", "Value", categorydataset, PlotOrientation.VERTICAL, true, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setDomainGridlinesVisible(true); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); MyBarRenderer mybarrenderer = new MyBarRenderer(); mybarrenderer.setDrawBarOutline(true); categoryplot.setRenderer(mybarrenderer); ChartUtilities.applyCurrentTheme(jfreechart); GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, new Color(0, 0, 64)); GradientPaint gradientpaint1 = new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, new Color(0, 64, 0)); GradientPaint gradientpaint2 = new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, new Color(64, 0, 0)); mybarrenderer.setSeriesPaint(0, gradientpaint); mybarrenderer.setSeriesPaint(1, gradientpaint1); mybarrenderer.setSeriesPaint(2, gradientpaint2); return jfreechart; }
From source file:net.nosleep.superanalyzer.analysis.views.MostPlayedAAView.java
public JFreeChart createChart(String title, String domainLabel, DefaultCategoryDataset dataset) { JFreeChart chart = ChartFactory.createBarChart3D(title, // chart title domainLabel, // domain axis label Misc.getString("SONG_COUNT"), // range axis label dataset, // data PlotOrientation.HORIZONTAL, // orientation false, // include legend true, // tooltips? false // URLs? );//from ww w . j a v a 2s .com // _artistChart.addSubtitle(HomePanel // .createSubtitle("How many songs you have in each genre")); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); ChartUtilities.applyCurrentTheme(chart); Misc.formatChart(plot); plot.getDomainAxis().setMaximumCategoryLabelWidthRatio(0.5f); CategoryItemRenderer renderer = plot.getRenderer(); BarRenderer3D barRenderer = (BarRenderer3D) renderer; barRenderer.setWallPaint(Color.white); barRenderer.setSeriesPaint(0, Theme.getColorSet()[1]); return chart; }
From source file:net.nosleep.superanalyzer.analysis.views.RatingView.java
private void createChart() { _chart = ChartFactory.createPieChart3D(Misc.getString("SONG_RATINGS"), _dataset, false, true, false); PiePlot3D plot = (PiePlot3D) _chart.getPlot(); plot.setDarkerSides(true);// w w w. j av a2 s. co m plot.setStartAngle(PieRotator.angle); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); plot.setNoDataMessage(Misc.getString("NO_DATA_TO_DISPLAY")); plot.setInsets(new RectangleInsets(10, 10, 10, 10)); plot.setOutlineVisible(false); plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({2})")); _chart.addSubtitle(HomePanel.createSubtitle(Misc.getString("SONG_RATINGS_SUBTITLE"))); ChartUtilities.applyCurrentTheme(_chart); plot.setBackgroundPaint(Color.white); _chart.setBorderVisible(false); }
From source file:pwm.visualizer.MDPPolicyPanel.java
private JFreeChart createChart() { NumberAxis nutritionAxis = new NumberAxis("Calories/Day"); nutritionAxis.setLowerBound(0);//w w w .j av a2 s. c o m nutritionAxis.setUpperBound(5000); nutritionAxis.setAutoRange(false); // CategoryPlot categoryplot = new CategoryPlot(nutritionDataSet, new CategoryAxis("Weight(KG)"), nutritionAxis, new BarRenderer()); CategoryAxis xaxis = categoryplot.getDomainAxis(); xaxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); LegendItemCollection legend = new LegendItemCollection(); LegendItem nutritionLegend = new LegendItem("Calories/Day"); LegendItem exerciseLegend = new LegendItem("Physical Activity Level"); nutritionLegend.setFillPaint(Color.BLUE); exerciseLegend.setFillPaint(Color.RED); legend.add(nutritionLegend); legend.add(exerciseLegend); categoryplot.setFixedLegendItems(legend); JFreeChart jfreechart = new JFreeChart("Policy Visualizer", categoryplot); categoryplot.setDataset(1, exerciseDataSet); categoryplot.mapDatasetToRangeAxis(1, 1); NumberAxis exerciseAxis = new NumberAxis("Physical Activity Level"); exerciseAxis.setLowerBound(0); exerciseAxis.setUpperBound(3.0); exerciseAxis.setAutoRange(false); categoryplot.setRangeAxis(1, exerciseAxis); BarRenderer barrenderer1 = new BarRenderer(); categoryplot.setRenderer(1, barrenderer1); // BarRenderer stackedbarrenderer = (BarRenderer)categoryplot.getRenderer(); // stackedbarrenderer.setDrawBarOutline(true); // stackedbarrenderer.setBaseItemLabelsVisible(false); // stackedbarrenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); ChartUtilities.applyCurrentTheme(jfreechart); return jfreechart; }
From source file:net.nosleep.superanalyzer.analysis.views.GenreView.java
public void createChart() { _chart = ChartFactory.createBarChart3D(Misc.getString("GENRES"), // chart // title Misc.getString("GENRE"), // domain axis label Misc.getString("SONG_COUNT"), // range axis label _dataset, // data PlotOrientation.HORIZONTAL, // orientation false, // include legend true, // tooltips? false // URLs? );//from w w w . j av a 2s. c o m _chart.addSubtitle(HomePanel.createSubtitle(Misc.getString("GENRES_SUBTITLE"))); CategoryPlot plot = (CategoryPlot) _chart.getPlot(); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); ChartUtilities.applyCurrentTheme(_chart); Misc.formatChart(plot); CategoryItemRenderer renderer = plot.getRenderer(); BarRenderer3D barRenderer = (BarRenderer3D) renderer; barRenderer.setWallPaint(Color.white); barRenderer.setSeriesPaint(0, Theme.getColorSet()[1]); }