List of usage examples for org.jfree.chart JFreeChart removeLegend
public void removeLegend()
From source file:Visuals.PieChart.java
public ChartPanel drawPieChart() { DefaultPieDataset piedataset = new DefaultPieDataset(); if (riskCount == 0) { title = ""; piedataset.setValue(noVulnerabilities, new Integer(1)); } else {//from w w w .j a v a 2s . com piedataset.setValue(lowValue, new Integer(low)); piedataset.setValue(mediumValue, new Integer(medium)); piedataset.setValue(highValue, new Integer(high)); piedataset.setValue(criticalValue, new Integer(critical)); } JFreeChart piechart = ChartFactory.createPieChart(title, // Title piedataset, // Dataset true, // Show legend true, // Use tooltips false // Generate URLs ); PiePlot plot = (PiePlot) piechart.getPlot(); //plot.setSimpleLabels(true); if (riskCount == 0) { plot.setSectionPaint(noVulnerabilities, new Color(47, 196, 6)); plot.setLabelLinksVisible(false); plot.setLabelGenerator(null); piechart.removeLegend(); } else { plot.setSectionPaint(criticalValue, new Color(230, 27, 27)); plot.setSectionPaint(highValue, new Color(230, 90, 27)); plot.setSectionPaint(mediumValue, new Color(85, 144, 176)); plot.setSectionPaint(lowValue, new Color(230, 219, 27)); } if (isMain) { piechart.removeLegend(); } plot.setBackgroundPaint(new Color(210, 234, 243)); ChartPanel chartPanel = new ChartPanel(piechart); chartPanel.setEnabled(false); return chartPanel; }
From source file:org.csa.rstb.dat.toolviews.HaAlphaPlotPanel.java
private void createUI() { plot = new XYImagePlot(); plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5)); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); domainAxis.setAutoRangeIncludesZero(false); rangeAxis.setAutoRangeIncludesZero(false); domainAxis.setUpperMargin(0);/* ww w .j a v a2 s. c om*/ domainAxis.setLowerMargin(0); rangeAxis.setUpperMargin(0); rangeAxis.setLowerMargin(0); plot.setNoDataMessage(NO_DATA_MESSAGE); plot.getRenderer().setBaseToolTipGenerator(new XYPlotToolTipGenerator()); JFreeChart chart = new JFreeChart(CHART_TITLE, plot); ChartFactory.getChartTheme().apply(chart); chart.removeLegend(); createUI(createChartPanel(chart), createOptionsPanel(), bindingContext); updateUIState(); }
From source file:com.graphhopper.jsprit.analysis.toolbox.Plotter.java
private void plot(VehicleRoutingProblem vrp, final Collection<VehicleRoute> routes, String pngFile, String title) {// w w w . ja va2s .c o m log.info("plot to {}", pngFile); XYSeriesCollection problem; XYSeriesCollection solution = null; final XYSeriesCollection shipments; try { retrieveActivities(vrp); problem = new XYSeriesCollection(activities); shipments = makeShipmentSeries(vrp.getJobs().values()); if (routes != null) solution = makeSolutionSeries(vrp, routes); } catch (NoLocationFoundException e) { log.warn("cannot plot vrp, since coord is missing"); return; } final XYPlot plot = createPlot(problem, shipments, solution); JFreeChart chart = new JFreeChart(title, plot); LegendTitle legend = createLegend(routes, shipments, plot); chart.removeLegend(); chart.addLegend(legend); save(chart, pngFile); }
From source file:com.opendoorlogistics.components.barchart.BarchartPanel.java
@Override protected JFreeChart createChart(ODLTableReadOnly table, int[] rowFilter) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); if (rowFilter != null) { for (int row : rowFilter) { createRowData(table, dataset, row); }//from w w w. ja va2 s. c o m } else { int n = table.getRowCount(); for (int row = 0; row < n; row++) { createRowData(table, dataset, row); } } // create the chart... JFreeChart chart = ChartFactory.createBarChart( Strings.isEmpty(config.getTitle()) ? null : config.getTitle(), // chart title config.getXLabel(), // domain axis label config.getYLabel(), // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); // set the background color for the chart... chart.setBackgroundPaint(Color.WHITE); // don't show legend for just one series if (((BarchartConfig) config).getSeriesNames().size() <= 1) { chart.removeLegend(); } return chart; }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.XYCharts.BlockChart.java
/** * Creates a chart for the specified dataset. * //from w ww. java2 s . c o m * @param dataset the dataset. * * @return A chart instance. */ public JFreeChart createChart(DatasetMap datasets) { XYZDataset dataset = (XYZDataset) datasets.getDatasets().get("1"); //Creates the xAxis with its label and style NumberAxis xAxis = new NumberAxis(xLabel); xAxis.setLowerMargin(0.0); xAxis.setUpperMargin(0.0); xAxis.setLabel(xLabel); if (addLabelsStyle != null && addLabelsStyle.getFont() != null) { xAxis.setLabelFont(addLabelsStyle.getFont()); xAxis.setLabelPaint(addLabelsStyle.getColor()); } //Creates the yAxis with its label and style NumberAxis yAxis = new NumberAxis(yLabel); yAxis.setAutoRangeIncludesZero(false); yAxis.setInverted(false); yAxis.setLowerMargin(0.0); yAxis.setUpperMargin(0.0); yAxis.setTickLabelsVisible(true); yAxis.setLabel(yLabel); if (addLabelsStyle != null && addLabelsStyle.getFont() != null) { yAxis.setLabelFont(addLabelsStyle.getFont()); yAxis.setLabelPaint(addLabelsStyle.getColor()); } yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); Color outboundCol = new Color(Integer.decode(outboundColor).intValue()); //Sets the graph paint scale and the legend paintscale LookupPaintScale paintScale = new LookupPaintScale(zvalues[0], (new Double(zrangeMax)).doubleValue(), outboundCol); LookupPaintScale legendPaintScale = new LookupPaintScale(0.5, 0.5 + zvalues.length, outboundCol); for (int ke = 0; ke <= (zvalues.length - 1); ke++) { Double key = (new Double(zvalues[ke])); Color temp = (Color) colorRangeMap.get(key); paintScale.add(zvalues[ke], temp); legendPaintScale.add(0.5 + ke, temp); } //Configures the renderer XYBlockRenderer renderer = new XYBlockRenderer(); renderer.setPaintScale(paintScale); double blockHeight = (new Double(blockH)).doubleValue(); double blockWidth = (new Double(blockW)).doubleValue(); renderer.setBlockWidth(blockWidth); renderer.setBlockHeight(blockHeight); //configures the plot with title, subtitle, axis ecc. XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.black); plot.setRangeGridlinePaint(Color.black); plot.setDomainCrosshairPaint(Color.black); plot.setForegroundAlpha(0.66f); plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5)); JFreeChart chart = new JFreeChart(plot); TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); } chart.removeLegend(); chart.setBackgroundPaint(Color.white); //Sets legend labels SymbolAxis scaleAxis = new SymbolAxis(null, legendLabels); scaleAxis.setRange(0.5, 0.5 + zvalues.length); scaleAxis.setPlot(new PiePlot()); scaleAxis.setGridBandsVisible(false); scaleAxis.setLabel(zLabel); //scaleAxis.setLabelAngle(3.14/2); scaleAxis.setLabelFont(addLabelsStyle.getFont()); scaleAxis.setLabelPaint(addLabelsStyle.getColor()); //draws legend as chart subtitle PaintScaleLegend psl = new PaintScaleLegend(legendPaintScale, scaleAxis); psl.setAxisOffset(2.0); psl.setPosition(RectangleEdge.RIGHT); psl.setMargin(new RectangleInsets(5, 1, 5, 1)); chart.addSubtitle(psl); if (yLabels != null) { //Sets y legend labels LookupPaintScale legendPaintScale2 = new LookupPaintScale(0, (yLabels.length - 1), Color.white); for (int ke = 0; ke < yLabels.length; ke++) { Color temp = Color.white; legendPaintScale2.add(1 + ke, temp); } SymbolAxis scaleAxis2 = new SymbolAxis(null, yLabels); scaleAxis2.setRange(0, (yLabels.length - 1)); scaleAxis2.setPlot(new PiePlot()); scaleAxis2.setGridBandsVisible(false); //draws legend as chart subtitle PaintScaleLegend psl2 = new PaintScaleLegend(legendPaintScale2, scaleAxis2); psl2.setAxisOffset(5.0); psl2.setPosition(RectangleEdge.LEFT); psl2.setMargin(new RectangleInsets(8, 1, 40, 1)); psl2.setStripWidth(0); psl2.setStripOutlineVisible(false); chart.addSubtitle(psl2); } return chart; }
From source file:jspritTest.util.Plotter.java
private void plot(VehicleRoutingProblem vrp, final Collection<VehicleRoute> routes, String pngFile, String title) {// w w w.jav a2s . com log.info("plot to {}", pngFile); XYSeriesCollection problem; XYSeriesCollection solution = null; final XYSeriesCollection shipments; try { retrieveActivities(vrp); //this is where the activities are set if (activities == null) log.info("activities is null"); problem = new XYSeriesCollection(activities); shipments = makeShipmentSeries(vrp.getJobs().values()); if (routes != null) solution = makeSolutionSeries(vrp, routes); } catch (NoLocationFoundException e) { log.warn("cannot plot vrp, since coord is missing"); return; } final XYPlot plot = createPlot(problem, shipments, solution); JFreeChart chart = new JFreeChart(title, plot); LegendTitle legend = createLegend(routes, shipments, plot); chart.removeLegend(); chart.addLegend(legend); save(chart, pngFile); }
From source file:de.dekarlab.moneybuilder.view.AnalyticsView.java
/** * Create pie chart.//from w w w . ja v a 2 s .co m * * @param dataset * @param title * @return */ protected JFreeChart createPieChart(final PieDataset dataset, final String title) { final JFreeChart chart = ChartFactory.createPieChart(title, dataset, true, true, false); final PiePlot plot = (PiePlot) chart.getPlot(); plot.setNoDataMessage(App.getGuiProp("report.nodata.msg")); plot.setCircular(true); // plot.set plot.setLabelGap(0.02); plot.setBackgroundPaint(Color.white); chart.removeLegend(); plot.setBackgroundPaint(Color.white); Iterator<?> it = dataset.getKeys().iterator(); int color = 0; while (it.hasNext()) { plot.setSectionPaint((String) it.next(), COLORS[color]); color++; if (COLORS.length == color) { color = 0; } } plot.setLabelBackgroundPaint(Color.white); StandardPieSectionLabelGenerator slbl = new StandardPieSectionLabelGenerator("{0} {2} ({1})", new DecimalFormat("#,##0"), new DecimalFormat("0%")); plot.setLabelGenerator(slbl); plot.setLabelFont(new Font("Helvetica", Font.PLAIN, 14)); plot.setLabelOutlinePaint(Color.white); plot.setLabelShadowPaint(Color.white); plot.setShadowPaint(Color.white); plot.setIgnoreZeroValues(true); return chart; }
From source file:org.objectweb.proactive.extensions.timitspmd.util.charts.MatrixChart.java
private void buildLegendChart(int nbValues) { this.legendValues = new int[nbValues + 1]; this.legendValues[0] = 0; int offset = 255 / nbValues; int step = offset; if (this.scaleMode == Chart.Scale.LOGARITHMIC) { double logStep = (Math.log(this.maxValue) / Math.log(2)) / nbValues; for (int i = 1; i < (nbValues + 1); i++) { this.legendValues[i] = (int) Math.pow(2, logStep * i); }// w w w. j a v a 2s. co m } else { // Linear scale mode for (int i = 1; i < (nbValues + 1); i++) { this.legendValues[i] = (step * this.maxValue) / 255; step += offset; } } final MatrixSeriesCollection dataset = new MatrixSeriesCollection(this.createLegendDataSet()); final JFreeChart chart = ChartFactory.createBubbleChart("", "", "", dataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.WHITE)); chart.removeLegend(); // Perform customizations starts here ... final XYPlot plot1 = chart.getXYPlot(); plot1.setDomainGridlinesVisible(false); plot1.setRangeGridlinesVisible(false); plot1.setForegroundAlpha(0.5f); plot1.setDomainAxis(new CustomAxis(plot1.getDomainAxis().getLabel())); plot1.setRangeAxis(new CustomAxis(plot1.getRangeAxis().getLabel())); // Custumize the domain axis ( x ) final NumberAxis domainAxis = (NumberAxis) plot1.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); domainAxis.setRange(-1, 1); domainAxis.setVisible(false); // Custumize the range axis ( y ) final NumberAxis rangeAxis = (NumberAxis) plot1.getRangeAxis(); rangeAxis.setTickUnit(new CustomTickUnit(rangeAxis.getTickUnit().getSize())); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setRange(-1, this.legendValues.length); rangeAxis.setTickLabelsVisible(true); rangeAxis.setTickMarkInsideLength(4); // Create custom renderer StandardXYItemRenderer ren = new CustomRenderer(true); ren.setSeriesItemLabelPaint(0, Color.BLUE); plot1.setRenderer(ren); plot1.setRangeAxisLocation(AxisLocation.TOP_OR_RIGHT); this.legendChart = chart; }
From source file:de.dfki.owlsmx.gui.ResultVisualization.java
private JFreeChart createMemoryChart() { XYSeriesCollection data = new XYSeriesCollection(); Map memory = MemoryContainer.getInstance().getStoredValues(); // System.err.println("Memory consumption: " + memory); data.addSeries(createSeriesFromDataMap(memory)); JFreeChart chart = ChartFactory.createXYLineChart("Memoryconsumption", "Services", "Memory (KByte)", data, org.jfree.chart.plot.PlotOrientation.VERTICAL, true, true, false); XYPlot plot = chart.getXYPlot();//from w w w.j av a2 s . co m XYItemRenderer renderer = (XYItemRenderer) plot.getRenderer(); renderer.setSeriesPaint(0, Color.red); chart.removeLegend(); return chart; }
From source file:org.gephi.statistics.plugin.Modularity.java
public String getReport() { //Distribution series Map<Integer, Integer> sizeDist = new HashMap<Integer, Integer>(); for (Node n : structure.graph.getNodes()) { Integer v = (Integer) n.getNodeData().getAttributes().getValue(MODULARITY_CLASS); if (!sizeDist.containsKey(v)) { sizeDist.put(v, 0);/*from w ww . j av a 2 s. c om*/ } sizeDist.put(v, sizeDist.get(v) + 1); } XYSeries dSeries = ChartUtils.createXYSeries(sizeDist, "Size Distribution"); XYSeriesCollection dataset1 = new XYSeriesCollection(); dataset1.addSeries(dSeries); JFreeChart chart = ChartFactory.createXYLineChart("Size Distribution", "Modularity Class", "Size (number of nodes)", dataset1, PlotOrientation.VERTICAL, true, false, false); chart.removeLegend(); ChartUtils.decorateChart(chart); ChartUtils.scaleChart(chart, dSeries, false); String imageFile = ChartUtils.renderChart(chart, "communities-size-distribution.png"); NumberFormat f = new DecimalFormat("#0.000"); String report = "<HTML> <BODY> <h1>Modularity Report </h1> " + "<hr>" + "<h2> Parameters: </h2>" + "Randomize: " + (isRandomized ? "On" : "Off") + "<br>" + "Use edge weights: " + (useWeight ? "On" : "Off") + "<br>" + "Resolution: " + (resolution) + "<br>" + "<br> <h2> Results: </h2>" + "Modularity: " + f.format(modularity) + "<br>" + "Modularity with resolution: " + f.format(modularityResolution) + "<br>" + "Number of Communities: " + structure.communities.size() + "<br /><br />" + imageFile + "<br /><br />" + "<h2> Algorithm: </h2>" + "Vincent D Blondel, Jean-Loup Guillaume, Renaud Lambiotte, Etienne Lefebvre, <i>Fast unfolding of communities in large networks</i>, in Journal of Statistical Mechanics: Theory and Experiment 2008 (10), P1000<br />" + "<br /><br />" + "<h2> Resolution: </h2>" + "R. Lambiotte, J.-C. Delvenne, M. Barahona <i>Laplacian Dynamics and Multiscale Modular Structure in Networks 2009<br />" + "</BODY> </HTML>"; return report; }