Java Code Examples for org.jfree.chart.plot.CategoryPlot#setDomainGridlinePaint()
The following examples show how to use
org.jfree.chart.plot.CategoryPlot#setDomainGridlinePaint() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChartViewerUtil.java From cst with GNU Lesser General Public License v3.0 | 6 votes |
public static synchronized ChartPanel createChart(DefaultCategoryDataset dataset, String title, String categoryAxisLabel, String valueAxisLabel, PlotOrientation chartType) { final JFreeChart chart = ChartFactory.createBarChart( title, categoryAxisLabel, valueAxisLabel, dataset, chartType, true, true, false ); final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); chart.setBackgroundPaint(Color.lightGray); ChartPanel localChartPanel = new ChartPanel(chart); localChartPanel.setVisible(true); localChartPanel.setDomainZoomable(true); return localChartPanel; }
Example 2
Source File: SimpleBox.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
public JFreeChart createChart(DatasetMap datasetMap) { BoxAndWhiskerCategoryDataset dataset=(BoxAndWhiskerCategoryDataset)datasetMap.getDatasets().get("1"); JFreeChart chart = ChartFactory.createBoxAndWhiskerChart( name, categoryLabel, valueLabel, dataset, false); TextTitle title =setStyleTitle(name, styleTitle); chart.setTitle(title); if(subName!= null && !subName.equals("")){ TextTitle subTitle =setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); } CategoryPlot plot = (CategoryPlot) chart.getPlot(); BoxAndWhiskerRenderer renderer=(BoxAndWhiskerRenderer)plot.getRenderer(); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(new Color(Integer.decode("#c0c0c0").intValue())); plot.setDomainGridlinePaint(Color.WHITE); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); renderer.setFillBox(true); renderer.setArtifactPaint(Color.BLACK); renderer.setSeriesPaint(0,new Color(Integer.decode("#0000FF").intValue())); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setRange(min, max); return chart; }
Example 3
Source File: ServerWideReportManagerImpl.java From sakai with Educational Community License v2.0 | 5 votes |
private byte[] generateBoxAndWhiskerChart (BoxAndWhiskerCategoryDataset dataset, int width, int height) { JFreeChart chart = ChartFactory.createBoxAndWhiskerChart (null, null, null, dataset, false); // set background chart.setBackgroundPaint (parseColor (statsManager.getChartBackgroundColor ())); // set chart border chart.setPadding (new RectangleInsets (10, 5, 5, 5)); chart.setBorderVisible (true); chart.setBorderPaint (parseColor ("#cccccc")); // set anti alias chart.setAntiAlias (true); CategoryPlot plot = (CategoryPlot) chart.getPlot (); plot.setDomainGridlinePaint (Color.white); plot.setDomainGridlinesVisible (true); plot.setRangeGridlinePaint (Color.white); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis (); rangeAxis.setStandardTickUnits (NumberAxis.createIntegerTickUnits ()); CategoryAxis domainAxis = (CategoryAxis) plot.getDomainAxis (); domainAxis.setLowerMargin (0.0); domainAxis.setUpperMargin (0.0); BufferedImage img = chart.createBufferedImage (width, height); final ByteArrayOutputStream out = new ByteArrayOutputStream(); try{ ImageIO.write(img, "png", out); }catch(IOException e){ log.warn("Error occurred while generating SiteStats chart image data", e); } return out.toByteArray(); }
Example 4
Source File: TransitionBarChart.java From osmo with GNU Lesser General Public License v2.1 | 5 votes |
private JFreeChart createChart(String title) { JFreeChart chart = ChartFactory.createBarChart(title, "test", "transitions", data, PlotOrientation.VERTICAL, true, true, false); CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); return chart; }
Example 5
Source File: ServerWideReportManagerImpl.java From sakai with Educational Community License v2.0 | 5 votes |
private byte[] generateBoxAndWhiskerChart (BoxAndWhiskerCategoryDataset dataset, int width, int height) { JFreeChart chart = ChartFactory.createBoxAndWhiskerChart (null, null, null, dataset, false); // set background chart.setBackgroundPaint (parseColor (statsManager.getChartBackgroundColor ())); // set chart border chart.setPadding (new RectangleInsets (10, 5, 5, 5)); chart.setBorderVisible (true); chart.setBorderPaint (parseColor ("#cccccc")); // set anti alias chart.setAntiAlias (true); CategoryPlot plot = (CategoryPlot) chart.getPlot (); plot.setDomainGridlinePaint (Color.white); plot.setDomainGridlinesVisible (true); plot.setRangeGridlinePaint (Color.white); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis (); rangeAxis.setStandardTickUnits (NumberAxis.createIntegerTickUnits ()); CategoryAxis domainAxis = (CategoryAxis) plot.getDomainAxis (); domainAxis.setLowerMargin (0.0); domainAxis.setUpperMargin (0.0); BufferedImage img = chart.createBufferedImage (width, height); final ByteArrayOutputStream out = new ByteArrayOutputStream(); try{ ImageIO.write(img, "png", out); }catch(IOException e){ log.warn("Error occurred while generating SiteStats chart image data", e); } return out.toByteArray(); }
Example 6
Source File: ChartFormatter.java From nmonvisualizer with Apache License 2.0 | 4 votes |
void formatChart(JFreeChart chart) { chart.getTitle().setFont(TITLE_FONT); ((TextTitle) chart.getSubtitle(0)).setFont(SUBTITLE_FONT); ((TextTitle) chart.getSubtitle(0)).setPadding(new RectangleInsets(0, 0, 0, 0)); chart.getTitle().setPaint(textColor); ((TextTitle) chart.getSubtitle(0)).setPaint(textColor); Plot plot = chart.getPlot(); // chart has no outline but a little padding plot.setOutlineStroke(null); chart.setPadding(new RectangleInsets(5, 5, 5, 5)); chart.getPlot().setDrawingSupplier(new DefaultDrawingSupplier(seriesColors, DefaultDrawingSupplier.DEFAULT_FILL_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE)); chart.setBackgroundPaint(background); chart.getPlot().setBackgroundPaint(plotBackground); if (plot instanceof XYPlot) { XYPlot xyPlot = (XYPlot) plot; for (int i = 0; i < xyPlot.getRangeAxisCount(); i++) { formatAxis(xyPlot.getRangeAxis(i)); } formatAxis(xyPlot.getDomainAxis()); xyPlot.setRangeGridlinePaint(gridLineColor); xyPlot.setDomainGridlinePaint(gridLineColor); xyPlot.setRangeGridlineStroke(GRID_LINES); } else if (plot instanceof CategoryPlot) { CategoryPlot categoryPlot = (CategoryPlot) plot; for (int i = 0; i < categoryPlot.getRangeAxisCount(); i++) { formatAxis(categoryPlot.getRangeAxis(i)); } formatAxis(categoryPlot.getDomainAxis()); categoryPlot.setRangeGridlinePaint(gridLineColor); categoryPlot.setDomainGridlinePaint(gridLineColor); categoryPlot.setRangeGridlineStroke(GRID_LINES); } }
Example 7
Source File: UserChartController.java From airsonic-advanced with GNU General Public License v3.0 | 4 votes |
private JFreeChart createChart(CategoryDataset dataset, HttpServletRequest request) { JFreeChart chart = ChartFactory.createBarChart(null, null, null, dataset, PlotOrientation.HORIZONTAL, false, false, false); CategoryPlot plot = chart.getCategoryPlot(); Paint background = new GradientPaint(0, 0, Color.lightGray, 0, IMAGE_MIN_HEIGHT, Color.white); plot.setBackgroundPaint(background); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); LogarithmicAxis rangeAxis = new LogarithmicAxis(null); rangeAxis.setStrictValuesFlag(false); rangeAxis.setAllowNegativesFlag(true); plot.setRangeAxis(rangeAxis); // Disable bar outlines. BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); // Set up gradient paint for series. GradientPaint gp0 = new GradientPaint( 0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64) ); renderer.setSeriesPaint(0, gp0); // Rotate labels. CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); // Set theme-specific colors. Color bgColor = getBackground(request); Color fgColor = getForeground(request); chart.setBackgroundPaint(bgColor); domainAxis.setTickLabelPaint(fgColor); domainAxis.setTickMarkPaint(fgColor); domainAxis.setAxisLinePaint(fgColor); rangeAxis.setTickLabelPaint(fgColor); rangeAxis.setTickMarkPaint(fgColor); rangeAxis.setAxisLinePaint(fgColor); return chart; }
Example 8
Source File: ServerWideReportManagerImpl.java From sakai with Educational Community License v2.0 | 4 votes |
private byte[] generateStackedAreaChart (CategoryDataset dataset, int width, int height) { JFreeChart chart = ChartFactory.createStackedAreaChart (null, // chart title null, // domain axis label null, // range axis label dataset, // data PlotOrientation.VERTICAL, // the plot orientation true, // legend true, // tooltips false // urls ); // set background chart.setBackgroundPaint (parseColor (statsManager.getChartBackgroundColor ())); // set chart border chart.setPadding (new RectangleInsets (10, 5, 5, 5)); chart.setBorderVisible (true); chart.setBorderPaint (parseColor ("#cccccc")); // set anti alias chart.setAntiAlias (true); CategoryPlot plot = (CategoryPlot) chart.getPlot (); // set transparency plot.setForegroundAlpha (0.7f); plot.setAxisOffset (new RectangleInsets (5.0, 5.0, 5.0, 5.0)); plot.setBackgroundPaint (Color.lightGray); plot.setDomainGridlinesVisible (true); plot.setDomainGridlinePaint (Color.white); plot.setRangeGridlinesVisible (true); plot.setRangeGridlinePaint (Color.white); // set colour of regular users using Karate belt colour: white, green, blue, brown, black/gold CategoryItemRenderer renderer = plot.getRenderer (); renderer.setSeriesPaint (0, new Color (205, 173, 0)); // gold users renderer.setSeriesPaint (1, new Color (139, 69, 19)); renderer.setSeriesPaint (2, Color.BLUE); renderer.setSeriesPaint (3, Color.GREEN); renderer.setSeriesPaint (4, Color.WHITE); // set the range axis to display integers only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis (); rangeAxis.setStandardTickUnits (NumberAxis.createIntegerTickUnits ()); CategoryAxis domainAxis = (CategoryAxis) plot.getDomainAxis (); domainAxis.setCategoryLabelPositions (CategoryLabelPositions.DOWN_45); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); BufferedImage img = chart.createBufferedImage (width, height); final ByteArrayOutputStream out = new ByteArrayOutputStream(); try{ ImageIO.write(img, "png", out); }catch(IOException e){ log.warn("Error occurred while generating SiteStats chart image data", e); } return out.toByteArray(); }
Example 9
Source File: BarChartDemo1.java From opensim-gui with Apache License 2.0 | 4 votes |
/** * Creates a sample chart. * * @param dataset the dataset. * * @return The chart. */ private static JFreeChart createChart(CategoryDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createBarChart( "Bar Chart Demo 1", // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); // 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... CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); // ****************************************************************** // More than 150 demo applications are included with the JFreeChart // Developer Guide...for more information, see: // // > http://www.object-refinery.com/jfreechart/guide.html // // ****************************************************************** // set the range axis to display integers only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // disable bar outlines... BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); // set up gradient paints for series... 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)); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setSeriesPaint(2, gp2); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions( Math.PI / 6.0)); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
Example 10
Source File: BarChartDemo1.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Creates a sample chart. * * @param dataset the dataset. * * @return The chart. */ private static JFreeChart createChart(CategoryDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createBarChart( "Bar Chart Demo 1", // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); // 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... CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); // ****************************************************************** // More than 150 demo applications are included with the JFreeChart // Developer Guide...for more information, see: // // > http://www.object-refinery.com/jfreechart/guide.html // // ****************************************************************** // set the range axis to display integers only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // disable bar outlines... BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); // set up gradient paints for series... 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)); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setSeriesPaint(2, gp2); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions( Math.PI / 6.0)); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
Example 11
Source File: SWTBarChartDemo1.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Creates a sample chart. * * @param dataset the dataset. * * @return The chart. */ private static JFreeChart createChart(CategoryDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createBarChart( "Bar Chart Demo", // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); // 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... CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); // set the range axis to display integers only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // disable bar outlines... BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0) ); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
Example 12
Source File: ChartJFreeChartOutputHistogram.java From gama with GNU General Public License v3.0 | 4 votes |
@Override public void initChart_post_data_init(final IScope scope) { // TODO Auto-generated method stub super.initChart_post_data_init(scope); final CategoryPlot pp = (CategoryPlot) chart.getPlot(); final String sty = getStyle(); this.useSubAxis = false; switch (sty) { case IKeyword.STACK: { if (this.series_label_position.equals("xaxis")) { this.series_label_position = "default"; } if (this.series_label_position.equals("default")) { this.series_label_position = "legend"; } break; } default: { if (this.series_label_position.equals("default")) { if (this.getChartdataset().getSources().size() > 0) { final ChartDataSource onesource = this.getChartdataset().getSources().get(0); if (onesource.isCumulative) { this.series_label_position = "legend"; } else { this.series_label_position = "xaxis"; useMainAxisLabel = false; } } else { this.series_label_position = "legend"; } } break; } } if (this.series_label_position.equals("xaxis")) { this.useSubAxis = true; } if (!this.series_label_position.equals("legend")) { chart.getLegend().setVisible(false); // legend is useless, but I find it nice anyway... Could put back... } this.resetDomainAxis(scope); pp.setDomainGridlinePaint(axesColor); pp.setRangeGridlinePaint(axesColor); if (!this.getXTickLineVisible(scope)) { pp.setDomainGridlinesVisible(false); } if (!this.getYTickLineVisible(scope)) { pp.setRangeGridlinesVisible(false); } pp.setRangeCrosshairVisible(true); pp.getRangeAxis().setAxisLinePaint(axesColor); pp.getRangeAxis().setLabelFont(getLabelFont()); pp.getRangeAxis().setTickLabelFont(getTickFont()); if (textColor != null) { pp.getRangeAxis().setLabelPaint(textColor); pp.getRangeAxis().setTickLabelPaint(textColor); } if (ytickunit > 0) { ((NumberAxis) pp.getRangeAxis()).setTickUnit(new NumberTickUnit(ytickunit)); } if (ylabel != null && !ylabel.isEmpty()) { pp.getRangeAxis().setLabel(ylabel); } if (this.series_label_position.equals("yaxis")) { pp.getRangeAxis().setLabel(this.getChartdataset().getDataSeriesIds(scope).iterator().next()); chart.getLegend().setVisible(false); } if (xlabel != null && !xlabel.isEmpty()) { pp.getDomainAxis().setLabel(xlabel); } if (textColor != null) { pp.getDomainAxis().setLabelPaint(textColor); pp.getDomainAxis().setTickLabelPaint(textColor); if (this.series_label_position.equals("xaxis")) { ((SubCategoryAxis)pp.getDomainAxis()).setSubLabelPaint(textColor); } } }
Example 13
Source File: ChartJFreeChartOutputHistogram.java From gama with GNU General Public License v3.0 | 4 votes |
@Override public void resetAxes(final IScope scope) { final CategoryPlot pp = (CategoryPlot) this.chart.getPlot(); NumberAxis rangeAxis = (NumberAxis) ((CategoryPlot) this.chart.getPlot()).getRangeAxis(); if (getY_LogScale(scope)) { final LogarithmicAxis logAxis = new LogarithmicAxis(rangeAxis.getLabel()); logAxis.setAllowNegativesFlag(true); ((CategoryPlot) this.chart.getPlot()).setRangeAxis(logAxis); rangeAxis = logAxis; } if (!useyrangeinterval && !useyrangeminmax) { rangeAxis.setAutoRange(true); } if (this.useyrangeinterval) { rangeAxis.setFixedAutoRange(yrangeinterval); rangeAxis.setAutoRangeMinimumSize(yrangeinterval); rangeAxis.setAutoRange(true); } if (this.useyrangeminmax) { rangeAxis.setRange(yrangemin, yrangemax); } resetDomainAxis(scope); final CategoryAxis domainAxis = ((CategoryPlot) this.chart.getPlot()).getDomainAxis(); pp.setDomainGridlinePaint(axesColor); pp.setRangeGridlinePaint(axesColor); pp.setRangeCrosshairVisible(true); pp.getRangeAxis().setAxisLinePaint(axesColor); pp.getRangeAxis().setLabelFont(getLabelFont()); pp.getRangeAxis().setTickLabelFont(getTickFont()); if (textColor != null) { pp.getRangeAxis().setLabelPaint(textColor); pp.getRangeAxis().setTickLabelPaint(textColor); } if (getYTickUnit(scope) > 0) { ((NumberAxis) pp.getRangeAxis()).setTickUnit(new NumberTickUnit(getYTickUnit(scope))); } if (getYLabel(scope) != null && !getYLabel(scope).isEmpty()) { pp.getRangeAxis().setLabel(getYLabel(scope)); } if (this.series_label_position.equals("yaxis")) { pp.getRangeAxis().setLabel(this.getChartdataset().getDataSeriesIds(scope).iterator().next()); chart.getLegend().setVisible(false); } if (getXLabel(scope) != null && !getXLabel(scope).isEmpty()) { pp.getDomainAxis().setLabel(getXLabel(scope)); } if (this.useSubAxis) { for (final String serieid : chartdataset.getDataSeriesIds(scope)) { ((SubCategoryAxis) domainAxis).addSubCategory(serieid); } } if (!this.getYTickLineVisible(scope)) { pp.setDomainGridlinesVisible(false); } if (!this.getYTickLineVisible(scope)) { pp.setRangeCrosshairVisible(false); } if (!this.getYTickValueVisible(scope)) { pp.getRangeAxis().setTickMarksVisible(false); pp.getRangeAxis().setTickLabelsVisible(false); } }
Example 14
Source File: MotivationalViewer.java From cst with GNU Lesser General Public License v3.0 | 4 votes |
@Override public synchronized void run() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); final JFreeChart chart = ChartFactory.createBarChart( getTitle(), getEntity(), "Value", dataset, PlotOrientation.VERTICAL, true, true, false ); final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); chart.setBackgroundPaint(Color.lightGray); ChartFrame frame= new ChartFrame(getTitle(), chart); frame.pack(); frame.setVisible(true); while (true) { ArrayList<Codelet> tempCodeletsList = new ArrayList<Codelet>(); tempCodeletsList.addAll(this.getListOfMotivationalEntities()); synchronized (tempCodeletsList) { for (Codelet co : tempCodeletsList) { dataset.addValue(co.getActivation(), co.getName(), "activation"); } try { Thread.currentThread().sleep(getRefreshPeriod()); } catch (InterruptedException e) { e.printStackTrace(); } } } }
Example 15
Source File: ServerWideReportManagerImpl.java From sakai with Educational Community License v2.0 | 4 votes |
private byte[] generateStackedAreaChart (CategoryDataset dataset, int width, int height) { JFreeChart chart = ChartFactory.createStackedAreaChart (null, // chart title null, // domain axis label null, // range axis label dataset, // data PlotOrientation.VERTICAL, // the plot orientation true, // legend true, // tooltips false // urls ); // set background chart.setBackgroundPaint (parseColor (statsManager.getChartBackgroundColor ())); // set chart border chart.setPadding (new RectangleInsets (10, 5, 5, 5)); chart.setBorderVisible (true); chart.setBorderPaint (parseColor ("#cccccc")); // set anti alias chart.setAntiAlias (true); CategoryPlot plot = (CategoryPlot) chart.getPlot (); // set transparency plot.setForegroundAlpha (0.7f); plot.setAxisOffset (new RectangleInsets (5.0, 5.0, 5.0, 5.0)); plot.setBackgroundPaint (Color.lightGray); plot.setDomainGridlinesVisible (true); plot.setDomainGridlinePaint (Color.white); plot.setRangeGridlinesVisible (true); plot.setRangeGridlinePaint (Color.white); // set colour of regular users using Karate belt colour: white, green, blue, brown, black/gold CategoryItemRenderer renderer = plot.getRenderer (); renderer.setSeriesPaint (0, new Color (205, 173, 0)); // gold users renderer.setSeriesPaint (1, new Color (139, 69, 19)); renderer.setSeriesPaint (2, Color.BLUE); renderer.setSeriesPaint (3, Color.GREEN); renderer.setSeriesPaint (4, Color.WHITE); // set the range axis to display integers only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis (); rangeAxis.setStandardTickUnits (NumberAxis.createIntegerTickUnits ()); CategoryAxis domainAxis = (CategoryAxis) plot.getDomainAxis (); domainAxis.setCategoryLabelPositions (CategoryLabelPositions.DOWN_45); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); BufferedImage img = chart.createBufferedImage (width, height); final ByteArrayOutputStream out = new ByteArrayOutputStream(); try{ ImageIO.write(img, "png", out); }catch(IOException e){ log.warn("Error occurred while generating SiteStats chart image data", e); } return out.toByteArray(); }
Example 16
Source File: UserChartController.java From subsonic with GNU General Public License v3.0 | 4 votes |
private JFreeChart createChart(CategoryDataset dataset, HttpServletRequest request) { JFreeChart chart = ChartFactory.createBarChart(null, null, null, dataset, PlotOrientation.HORIZONTAL, false, false, false); CategoryPlot plot = chart.getCategoryPlot(); Paint background = new GradientPaint(0, 0, Color.lightGray, 0, IMAGE_MIN_HEIGHT, Color.white); plot.setBackgroundPaint(background); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); LogarithmicAxis rangeAxis = new LogarithmicAxis(null); rangeAxis.setStrictValuesFlag(false); rangeAxis.setAllowNegativesFlag(true); plot.setRangeAxis(rangeAxis); // Disable bar outlines. BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); // Set up gradient paint for series. GradientPaint gp0 = new GradientPaint( 0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64) ); renderer.setSeriesPaint(0, gp0); // Rotate labels. CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); // Set theme-specific colors. Color bgColor = getBackground(request); Color fgColor = getForeground(request); chart.setBackgroundPaint(bgColor); domainAxis.setTickLabelPaint(fgColor); domainAxis.setTickMarkPaint(fgColor); domainAxis.setAxisLinePaint(fgColor); rangeAxis.setTickLabelPaint(fgColor); rangeAxis.setTickMarkPaint(fgColor); rangeAxis.setAxisLinePaint(fgColor); return chart; }
Example 17
Source File: AegeanChartTheme.java From jasperreports with GNU Lesser General Public License v3.0 | 4 votes |
@Override protected JFreeChart createGanttChart() throws JRException { JFreeChart jfreeChart = super.createGanttChart(); CategoryPlot categoryPlot = (CategoryPlot)jfreeChart.getPlot(); categoryPlot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.STANDARD); categoryPlot.setDomainGridlinesVisible(true); categoryPlot.setDomainGridlinePosition(CategoryAnchor.END); categoryPlot.setDomainGridlineStroke(new BasicStroke( 0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 50, new float[] {1}, 0 ) ); categoryPlot.setDomainGridlinePaint(ChartThemesConstants.GRAY_PAINT_217); categoryPlot.setRangeGridlinesVisible(true); categoryPlot.setRangeGridlineStroke(new BasicStroke( 0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 50, new float[] {1}, 0 ) ); categoryPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_217); // JRBarPlot barPlot = (BarPlot)categoryPlot; // categoryPlot.getDomainAxis().setTickLabelsVisible( // categoryPlot.getShowTickLabels() == null ? true : barPlot.getShowTickLabels(). // true // ); CategoryItemRenderer categoryRenderer = categoryPlot.getRenderer(); categoryRenderer.setBaseItemLabelsVisible(true); BarRenderer barRenderer = (BarRenderer)categoryRenderer; @SuppressWarnings("unchecked") List<Paint> seriesPaints = (List<Paint>)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.SERIES_COLORS); barRenderer.setSeriesPaint(0, seriesPaints.get(3)); barRenderer.setSeriesPaint(1, seriesPaints.get(0)); CategoryDataset categoryDataset = categoryPlot.getDataset(); if(categoryDataset != null) { for(int i = 0; i < categoryDataset.getRowCount(); i++) { barRenderer.setSeriesItemLabelFont(i, categoryPlot.getDomainAxis().getTickLabelFont()); barRenderer.setSeriesItemLabelsVisible(i, true); // barRenderer.setSeriesPaint(i, GRADIENT_PAINTS[i]); // CategoryMarker categoryMarker = new CategoryMarker(categoryDataset.getColumnKey(i),MARKER_COLOR, new BasicStroke(1f)); // categoryMarker.setAlpha(0.5f); // categoryPlot.addDomainMarker(categoryMarker, Layer.BACKGROUND); } } categoryPlot.setOutlinePaint(Color.DARK_GRAY); categoryPlot.setOutlineStroke(new BasicStroke(1.5f)); categoryPlot.setOutlineVisible(true); return jfreeChart; }
Example 18
Source File: EyeCandySixtiesChartTheme.java From jasperreports with GNU Lesser General Public License v3.0 | 4 votes |
@Override protected JFreeChart createGanttChart() throws JRException { JFreeChart jfreeChart = super.createGanttChart(); CategoryPlot categoryPlot = (CategoryPlot)jfreeChart.getPlot(); categoryPlot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.STANDARD); categoryPlot.setDomainGridlinesVisible(true); categoryPlot.setDomainGridlinePosition(CategoryAnchor.END); categoryPlot.setDomainGridlineStroke(new BasicStroke( 0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 50, new float[] {1}, 0 ) ); categoryPlot.setDomainGridlinePaint(ChartThemesConstants.GRAY_PAINT_134); categoryPlot.setRangeGridlinesVisible(true); categoryPlot.setRangeGridlineStroke(new BasicStroke( 0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 50, new float[] {1}, 0 ) ); categoryPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_134); categoryPlot.getDomainAxis().setTickLabelsVisible( //barPlot.isShowTickLabels() true ); CategoryItemRenderer categoryRenderer = categoryPlot.getRenderer(); categoryRenderer.setBaseItemLabelsVisible(true); BarRenderer barRenderer = (BarRenderer)categoryRenderer; barRenderer.setSeriesPaint(0, ChartThemesConstants.EYE_CANDY_SIXTIES_COLORS.get(3)); barRenderer.setSeriesPaint(1, ChartThemesConstants.EYE_CANDY_SIXTIES_COLORS.get(0)); CategoryDataset categoryDataset = categoryPlot.getDataset(); if (categoryDataset != null) { for (int i = 0; i < categoryDataset.getRowCount(); i++) { barRenderer.setSeriesItemLabelFont(i, categoryPlot.getDomainAxis().getTickLabelFont()); barRenderer.setSeriesItemLabelsVisible(i, true); } } categoryPlot.setOutlinePaint(Color.DARK_GRAY); categoryPlot.setOutlineStroke(new BasicStroke(1.5f)); categoryPlot.setOutlineVisible(true); return jfreeChart; }
Example 19
Source File: UserChartController.java From airsonic with GNU General Public License v3.0 | 4 votes |
private JFreeChart createChart(CategoryDataset dataset, HttpServletRequest request) { JFreeChart chart = ChartFactory.createBarChart(null, null, null, dataset, PlotOrientation.HORIZONTAL, false, false, false); CategoryPlot plot = chart.getCategoryPlot(); Paint background = new GradientPaint(0, 0, Color.lightGray, 0, IMAGE_MIN_HEIGHT, Color.white); plot.setBackgroundPaint(background); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); LogarithmicAxis rangeAxis = new LogarithmicAxis(null); rangeAxis.setStrictValuesFlag(false); rangeAxis.setAllowNegativesFlag(true); plot.setRangeAxis(rangeAxis); // Disable bar outlines. BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); // Set up gradient paint for series. GradientPaint gp0 = new GradientPaint( 0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64) ); renderer.setSeriesPaint(0, gp0); // Rotate labels. CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); // Set theme-specific colors. Color bgColor = getBackground(request); Color fgColor = getForeground(request); chart.setBackgroundPaint(bgColor); domainAxis.setTickLabelPaint(fgColor); domainAxis.setTickMarkPaint(fgColor); domainAxis.setAxisLinePaint(fgColor); rangeAxis.setTickLabelPaint(fgColor); rangeAxis.setTickMarkPaint(fgColor); rangeAxis.setAxisLinePaint(fgColor); return chart; }