List of usage examples for org.jfree.chart JFreeChart setBackgroundPaint
public void setBackgroundPaint(Paint paint)
From source file:WeeklyReport.Sections.Bookings.java
private JFreeChart bookingsByTradelaneChart() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); Map<Double, Map<String, String>> map = new CargoQuoteType().bookingsByTradeLane(); map.entrySet().stream().forEach((mapEntry) -> { Map<String, String> m1 = mapEntry.getValue(); m1.entrySet().stream().forEach((pair) -> { dataset.setValue(mapEntry.getKey(), pair.getKey(), pair.getValue()); });/*ww w . j a v a 2 s . c om*/ }); JFreeChart barChart = ChartFactory.createBarChart3D("Bookings by Trade Lane", "Company", "Cubic Meters", dataset, PlotOrientation.VERTICAL, true, true, false); barChart.setBackgroundPaint(Color.WHITE); CategoryPlot categoryPlot = barChart.getCategoryPlot(); CategoryAxis domainAxis = categoryPlot.getDomainAxis(); BarRenderer br = (BarRenderer) categoryPlot.getRenderer(); if (map.values().stream().mapToInt((list) -> list.size()).count() > 2) { domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); } categoryPlot.setBackgroundPaint(Color.WHITE); categoryPlot.setRangeGridlinePaint(Color.BLACK); return barChart; }
From source file:de.rbs90.fwdisp.settingsgui.gui.tabs.statistics.WeekDayStatisticsPanel.java
public WeekDayStatisticsPanel() { setName("Wochentag"); setLayout(new BorderLayout()); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); String weekDays[] = { "Mo", "Die", "Mi", "Do", "Fr", "Sa", "So" }; int alarmCount[] = new int[7]; try {//from w w w. java2 s.c o m ResultSet resultSet = Starter.getDatabase().getStatement().executeQuery( "SELECT STARTDATE_WEEKDAY, COUNT(*) AS COUNT FROM ALARMHISTORY GROUP BY STARTDATE_WEEKDAY"); while (resultSet.next()) { alarmCount[resultSet.getInt("STARTDATE_WEEKDAY") - 1] = resultSet.getInt("COUNT"); } } catch (SQLException e) { e.printStackTrace(); } for (int i = 0; i < 7; i++) { String dayName; int dayNumber; if (i != 6) { dayNumber = i + 1; dayName = weekDays[i]; } else { dayName = weekDays[6]; //Sunday dayNumber = 0; } dataset.addValue(alarmCount[dayNumber], "", dayName); } JFreeChart chart = ChartFactory.createBarChart3D("Wochentagsbersicht", "Wochentag", "Einstze", dataset, PlotOrientation.VERTICAL, false, false, false); chart.setBackgroundPaint(getBackground()); ChartPanel panel = new ChartPanel(chart); panel.setPopupMenu(null); add(panel, BorderLayout.CENTER); }
From source file:org.mili.jmibs.jfree.JFreeChartBarIterationObjectLoadBenchmarkSuiteResultRenderer.java
private JFreeChart createChart(String title, CategoryDataset dataset) { JFreeChart chart = ChartFactory.createBarChart(title, "Benchmark (Iteration/Object Loading)", "Time in ns", dataset, PlotOrientation.HORIZONTAL, true, true, false); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false);//w w w. j ava 2 s. com 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)); return chart; }
From source file:it.eng.spagobi.engines.kpi.bo.charttypes.dialcharts.Thermometer.java
/** * Creates a chart of type thermometer.//from ww w . j a v a2 s .c om * * @return A chart thermometer. */ public JFreeChart createChart() { logger.debug("IN"); if (dataset == null) { logger.debug("The dataset to be represented is null"); return null; } ThermometerPlot plot = new ThermometerPlot((ValueDataset) dataset); logger.debug("Created the new Thermometer Plot"); JFreeChart chart = new JFreeChart(name, JFreeChart.DEFAULT_TITLE_FONT, plot, true); logger.debug("Created the new Chart"); chart.setBackgroundPaint(color); logger.debug("Setted the background color of the chart"); TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); logger.debug("Setted the title of the chart"); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); logger.debug("Setted the subtitle of the chart"); } plot.setInsets(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setPadding(new RectangleInsets(10.0, 10.0, 10.0, 10.0)); plot.setThermometerStroke(new BasicStroke(2.0f)); plot.setThermometerPaint(Color.lightGray); plot.setGap(3); plot.setValueLocation(3); plot.setRange(lower, upper); plot.setUnits(ThermometerPlot.UNITS_NONE); logger.debug("Setted all the properties of the plot"); // set subranges for (Iterator iterator = intervals.iterator(); iterator.hasNext();) { KpiInterval subrange = (KpiInterval) iterator.next(); int range = 0; //For the thermometer the number of intervals is forced to 3 and they have to have as labels the following ones if (subrange.getLabel().equalsIgnoreCase("NORMAL")) range = (ThermometerPlot.NORMAL); else if (subrange.getLabel().equalsIgnoreCase("WARNING")) range = (ThermometerPlot.WARNING); else if (subrange.getLabel().equalsIgnoreCase("CRITICAL")) range = (ThermometerPlot.CRITICAL); plot.setSubrange(range, subrange.getMin(), subrange.getMax()); if (subrange.getColor() != null) { plot.setSubrangePaint(range, subrange.getColor()); } logger.debug("Setted new range of the plot"); } logger.debug("OUT"); return chart; }
From source file:ws.moor.bt.gui.charts.TotalBlocksPerPeer.java
private JFreeChart createChart() { JFreeChart chart = ChartFactory.createStackedBarChart("Top 20 Block Peers", "Remote IP", "Blocks", createDataset(), PlotOrientation.VERTICAL, true, false, false); chart.setBackgroundPaint(Color.white); CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2.0)); return chart; }
From source file:org.jfree.chart.demo.LayeredBarChartDemo1.java
/** * Creates a chart for the specified dataset. * //w w w. j av a 2 s. c om * @param dataset the dataset. * * @return a chart. */ private JFreeChart createChart(final CategoryDataset dataset) { final CategoryAxis categoryAxis = new CategoryAxis("Category"); //categoryAxis.setMaxCategoryLabelWidthRatio(10.0f); final ValueAxis valueAxis = new NumberAxis("Score (%)"); final CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, new LayeredBarRenderer()); plot.setOrientation(PlotOrientation.HORIZONTAL); final JFreeChart chart = new JFreeChart("Layered Bar Chart", JFreeChart.DEFAULT_TITLE_FONT, plot, true); // set the background color for the chart... chart.setBackgroundPaint(Color.lightGray); final LayeredBarRenderer renderer = (LayeredBarRenderer) plot.getRenderer(); // we can set each series bar width individually or let the renderer manage a standard view. // the width is set in percentage, where 1.0 is the maximum (100%). renderer.setSeriesBarWidth(0, 1.0); renderer.setSeriesBarWidth(1, 0.7); renderer.setSeriesBarWidth(2, 0.4); renderer.setItemMargin(0.01); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryMargin(0.25); domainAxis.setUpperMargin(0.05); domainAxis.setLowerMargin(0.05); return chart; }
From source file:org.jfree.chart.demo.TimeSeriesDemo12.java
/** * Creates a chart.//from w ww . j ava 2s . co m * * @param dataset a dataset. * * @return A chart. */ private JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createTimeSeriesChart("Sample Chart", "Date", "Value", dataset, true, true, false); chart.setBackgroundPaint(Color.white); // final StandardLegend sl = (StandardLegend) chart.getLegend(); // sl.setDisplaySeriesShapes(true); final XYPlot plot = chart.getXYPlot(); //plot.setOutlinePaint(null); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(false); final XYItemRenderer renderer = plot.getRenderer(); if (renderer instanceof StandardXYItemRenderer) { final StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer; rr.setPlotShapes(true); rr.setShapesFilled(true); renderer.setSeriesStroke(0, new BasicStroke(2.0f)); renderer.setSeriesStroke(1, new BasicStroke(2.0f)); } final DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("hh:mma")); return chart; }
From source file:Gui.Graficos.java
private void init(String titulo, String tituloX, String tituloY) { panel = new JPanel(); panel.setBackground(Color.WHITE); getContentPane().add(panel);/*from w w w . j a v a2 s . c o m*/ // Creando el Grafico JFreeChart chart = ChartFactory.createBarChart3D(titulo, tituloX, tituloY, dataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(new Color(225, 255, 228)); chart.getTitle().setPaint(Color.black); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.red); // Mostrar Grafico ChartPanel chartPanel = new ChartPanel(chart); panel.add(chartPanel); // panel.setLayout(new VerticalLayout()); panel.add(btAceptar); //panel. panel.setLayout(null); chartPanel.setBounds(100, 10, 1100, 600); btAceptar.setBounds(1065, 620, 130, 30); }
From source file:edu.cuny.cat.ui.ChargePlotPanel.java
public ChargePlotPanel() { registry = GameController.getInstance().getRegistry(); setTitledBorder("Charges"); dataset = new DefaultCategoryDataset(); final JFreeChart chart = ChartFactory.createBarChart("", "", "", dataset, PlotOrientation.HORIZONTAL, true, true, false);//from w ww .j a va 2s .c o m // chart.setAntiAlias(false); chart.setBackgroundPaint(getBackground()); categoryplot = (CategoryPlot) chart.getPlot(); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setRangeGridlinePaint(Color.white); final BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer(); UIUtils.setDefaultBarRendererStyle(barrenderer); barrenderer.setLegendItemToolTipGenerator(new StandardCategorySeriesLabelGenerator("Tooltip: {0}")); categoryplot.setRowRenderingOrder(SortOrder.DESCENDING); final ChartPanel chartPanel = new ChartPanel(chart); add(chartPanel, BorderLayout.CENTER); }
From source file:net.sf.mzmine.modules.peaklistmethods.peakpicking.adap3decompositionV1_5.EICPlot.java
public EICPlot(List<List<NavigableMap<Double, Double>>> clusters, List<Double> colors, List<List<String>> info, List<NavigableMap<Double, Double>> modelPeaks) { super(null, true); setBackground(Color.white);/* www.j av a 2s .c o m*/ setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); NumberAxis xAxis = new NumberAxis("Retention Time"); xAxis.setAutoRangeIncludesZero(false); xAxis.setUpperMargin(0); xAxis.setLowerMargin(0); NumberAxis yAxis = new NumberAxis("Intensity"); yAxis.setAutoRangeIncludesZero(false); yAxis.setUpperMargin(0); yAxis.setLowerMargin(0); xyDataset = new XYSeriesCollection(); colorDataset = new ArrayList<>(); toolTips = new ArrayList<>(); int seriesID = 0; for (int i = 0; i < clusters.size(); ++i) { List<NavigableMap<Double, Double>> cluster = clusters.get(i); double color = colors.get(i); for (int j = 0; j < cluster.size(); ++j) { XYSeries series = new XYSeries(seriesID++); for (Entry<Double, Double> e : cluster.get(j).entrySet()) series.add(e.getKey(), e.getValue()); xyDataset.addSeries(series); colorDataset.add(color); toolTips.add(info.get(i).get(j)); } } XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer() { @Override public Paint getItemPaint(int row, int col) { double c = colorDataset.get(row); return Color.getHSBColor((float) c, 1.0f, 1.0f); } }; renderer.setDefaultShapesVisible(false); renderer.setDefaultToolTipGenerator(new XYToolTipGenerator() { @Override public String generateToolTip(XYDataset dataset, int series, int item) { try { return toolTips.get(series); } catch (NullPointerException | IndexOutOfBoundsException e) { return ""; } } }); XYPlot plot = new XYPlot(xyDataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinesVisible(true); JFreeChart chart = new JFreeChart("", new Font("SansSerif", Font.BOLD, 12), plot, false); chart.setBackgroundPaint(Color.white); super.setChart(chart); }