List of usage examples for org.jfree.chart JFreeChart removeLegend
public void removeLegend()
From source file:gui.TraitViewerDialog.java
@SuppressWarnings("rawtypes") private ChartPanel getChart(int selectedRow) { ArrayList<Float> data = new ArrayList<Float>(); for (float[] row : tFile.getRows()) { if (row[selectedRow + 1] != (float) -99.0) { data.add(row[selectedRow + 1]); }/*from w w w .j a v a2 s .co m*/ } BoxAndWhiskerItem a = BoxAndWhiskerCalculator.calculateBoxAndWhiskerStatistics(data); java.util.List l = new ArrayList(0); a = new BoxAndWhiskerItem(a.getMean(), a.getMedian(), a.getQ1(), a.getQ3(), a.getMinRegularValue(), a.getMaxRegularValue(), a.getMinRegularValue(), a.getMaxRegularValue(), l); traitstats.setText(showBoxAndWhiskerItem(a)); DefaultBoxAndWhiskerCategoryDataset ds2 = new DefaultBoxAndWhiskerCategoryDataset(); ds2.add(a, (Comparable) 1, (Comparable) 1); JFreeChart chart = ChartFactory.createBoxAndWhiskerChart(null, null, null, ds2, false); chart.removeLegend(); // XYPlot plot = chart.getXYPlot(); CategoryPlot plot = chart.getCategoryPlot(); plot.getDomainAxis().setVisible(false); BoxAndWhiskerRenderer b = (BoxAndWhiskerRenderer) plot.getRenderer(); // b.setFillBox(false); b.setSeriesPaint(0, new Color(236, 55, 169)); b.setSeriesOutlinePaint(1, new Color(131, 79, 112)); b.setBaseOutlineStroke(new BasicStroke(1.0f)); // b.get b.setWhiskerWidth(0.8); b.setBaseOutlinePaint(new Color(84, 144, 201)); b.setDefaultEntityRadius(2); b.setMaximumBarWidth(0.18); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPopupMenu(null); return chartPanel; }
From source file:gov.nih.nci.caintegrator.application.geneexpression.GeneExpressionPlotServiceImpl.java
private StatisticalBarRenderer cusomtizeStatisticalBarChart(JFreeChart chart) { customizeAxisMargin(chart);// www.jav a 2s.c o m StatisticalBarRenderer renderer = new StatisticalBarRenderer(); renderer.setItemMargin(ITEM_MARGIN); renderer.setDrawBarOutline(true); chart.removeLegend(); return renderer; }
From source file:gov.nih.nci.caintegrator.application.geneexpression.GeneExpressionPlotServiceImpl.java
private void cusomtizeBarChart(JFreeChart chart) { customizeAxisMargin(chart);//from w ww . j a v a 2 s. co m BarRenderer renderer = (BarRenderer) chart.getCategoryPlot().getRenderer(); renderer.setItemMargin(ITEM_MARGIN); renderer.setDrawBarOutline(true); chart.removeLegend(); }
From source file:netplot.GenericPlotPanel.java
void genericConfig(JFreeChart chart, XYPlot plot, int plotIndex) { if (!enableLegend) { chart.removeLegend(); }//www . j av a 2 s . c o m XYItemRenderer xyItemRenderer = plot.getRenderer(); //May also be XYBarRenderer if (xyItemRenderer instanceof XYLineAndShapeRenderer) { XYToolTipGenerator xyToolTipGenerator = xyItemRenderer.getBaseToolTipGenerator(); //If currently an XYLineAndShapeRenderer replace it so that we inc the colour for every plotIndex XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(linesEnabled, shapesEnabled); //Ensure we don't loose the tool tips on the new renderer renderer.setBaseToolTipGenerator(xyToolTipGenerator); renderer.setBasePaint(getPlotColour(plotIndex)); renderer.setSeriesStroke(0, new BasicStroke(lineWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL), true); plot.setRenderer(plotIndex, renderer); } //If we have a new y axis then we need a new data set if (yAxisName != null && yAxisName.length() > 0) { if (logYAxis) { LogAxis yAxis = new LogAxis(yAxisName); yAxis.setAutoRange(false); yAxis.setNumberFormatOverride(new LogFormat(10, "10", true)); yAxis.setRange(minScaleValue, maxScaleValue); yAxis.setLowerBound(minScaleValue); yAxis.setUpperBound(maxScaleValue); plot.setRangeAxis(yAxisIndex, yAxis); plot.setRangeAxisLocation(yAxisIndex, AxisLocation.BOTTOM_OR_LEFT); } else { NumberAxis axis = new NumberAxis(yAxisName); axis.setAutoRangeIncludesZero(zeroOnYScale); if (autoScaleEnabled) { axis.setAutoRange(true); } else { Range range = new Range(minScaleValue, maxScaleValue); axis.setRangeWithMargins(range, true, true); } if (yAxisTickCount > 0) { NumberTickUnit tick = new NumberTickUnit(yAxisTickCount); axis.setTickUnit(tick); } plot.setRangeAxis(yAxisIndex, axis); plot.setRangeAxisLocation(yAxisIndex, AxisLocation.BOTTOM_OR_LEFT); } yAxisIndex++; } plot.mapDatasetToRangeAxis(plotIndex, yAxisIndex - 1); ValueAxis a = plot.getDomainAxis(); if (xAxisName.length() > 0) { a.setLabel(xAxisName); } //We can enable/disable zero on the axis if we have a NumberAxis if (a instanceof NumberAxis) { ((NumberAxis) a).setAutoRangeIncludesZero(zeroOnXScale); } }
From source file:signalviewer.SignalViewer.java
private void getPlot() { update_data();/*from w ww. j ava2 s . c om*/ // ChartPanel[] panels = new ChartPanel[max_plots]; for (int j = 0; j < max_plots; j++) { XYSeries series = new XYSeries("Planned"); for (int i = 0; i < max_bins; i++) { series.add((double) i, D[j][i]); } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series); JFreeChart chart = ChartFactory.createXYLineChart("Line Chart Demo", "X", "Y", dataset); chart.setTitle(""); chart.removeLegend(); XYPlot plot = (XYPlot) chart.getPlot(); // draw a horizontal line across the chart at y == 0 // plot.addRangeMarker(new Marker(0, Color.red, new BasicStroke(1), Color.red, 1f)); // ChartPanel panel = new ChartPanel(chart); if (panels[j] == null) { panels[j] = new ChartPanel(chart); } else { panels[j].setChart(chart); // panels[j].setMaximumDrawHeight(200); panels[j].revalidate(); panels[j].repaint(); } // panels[j] = panel; } // return panels; }
From source file:org.ietr.preesm.mapper.ui.BestCostPlotter.java
/** * Creates a chart./*from w ww .jav a2 s . c om*/ * * @return A chart. */ private JFreeChart createChart(String title) { final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new DateAxis("Time")); this.datasets = new TimeSeriesCollection[subplotCount]; for (int i = 0; i < subplotCount; i++) { this.lastValue[i] = 100.0; final TimeSeries series = new TimeSeries("Real Time", Millisecond.class); this.datasets[i] = new TimeSeriesCollection(series); final NumberAxis rangeAxis = new NumberAxis("Schedule"); rangeAxis.setAutoRangeIncludesZero(false); final XYPlot subplot = new XYPlot(this.datasets[i], null, rangeAxis, new XYLineAndShapeRenderer()); subplot.setBackgroundPaint(Color.white); subplot.setDomainGridlinePaint(Color.lightGray); subplot.setRangeGridlinePaint(Color.lightGray); plot.add(subplot); } final JFreeChart chart = new JFreeChart(title, plot); chart.removeLegend(); // chart.getLegend().setPosition(RectangleEdge.BOTTOM); chart.setBorderPaint(Color.lightGray); chart.setBorderVisible(true); Paint p = GanttPlotter.getBackgroundColorGradient(); chart.setBackgroundPaint(p); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.black); final ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); return chart; }
From source file:unalcol.termites.boxplots.ECALMessages.java
private LegendTitle modifyLegend(JFreeChart chart, CategoryPlot plot) { LegendTitle legend = chart.getLegend(); chart.removeLegend(); LegendItemSource[] items = legend.getSources(); for (LegendItemSource item : items) { //LegendItemCollection collection = items[i].getLegendItems(); LegendItemCollection collection = plot.getLegendItems(); for (Iterator iter = collection.iterator(); iter.hasNext();) { LegendItem element = (LegendItem) iter.next(); System.out.println(" ## #" + element.getLabel()); }//from www. ja v a 2 s. c o m } return legend; }
From source file:org.sonar.server.charts.deprecated.BaseChart.java
protected void configureChart(JFreeChart chart, RectangleEdge legendPosition) { chart.setBackgroundPaint(new Color(255, 255, 255, 0)); chart.setBackgroundImageAlpha(0.0f); chart.setBorderVisible(false);//from w ww . j a v a 2 s. c o m chart.setAntiAlias(true); chart.setTextAntiAlias(true); chart.removeLegend(); if (legendPosition != null) { LegendTitle legend = new LegendTitle(chart.getPlot()); legend.setPosition(legendPosition); legend.setItemPaint(BASE_COLOR); chart.addSubtitle(legend); } }
From source file:org.xwiki.chart.internal.VisibilityChartCustomizer.java
@Override public void customize(JFreeChart jfchart, Map<String, String> parameters) { if (parameters.get(PLOT_BORDER_VISIBLE) != null) { jfchart.getPlot().setOutlineVisible(Boolean.parseBoolean(parameters.get(PLOT_BORDER_VISIBLE))); }/*from w w w . ja va2 s. c o m*/ if (parameters.get(LEGEND_VISIBLE) != null && !Boolean.parseBoolean(parameters.get(LEGEND_VISIBLE))) { jfchart.removeLegend(); } }
From source file:lectorarchivos.MostrarGraficaCSV.java
/** * Creates new form MostrarGraficaCSV// w w w. j av a 2 s .c o m */ public MostrarGraficaCSV(JTable jTableInfoCSV) { initComponents(); this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); panel = new JPanel(); getContentPane().add(panel); //Fuente de datos DefaultCategoryDataset dataset = new DefaultCategoryDataset(); //Recorremos la columna del consumo de la tabla for (int i = jTableInfoCSV.getRowCount() - 1; i >= 0; i--) { if (Double.parseDouble(jTableInfoCSV.getValueAt(i, 4).toString()) > 0) dataset.setValue(Double.parseDouble(jTableInfoCSV.getValueAt(i, 4).toString()), "Consumo", jTableInfoCSV.getValueAt(i, 0).toString()); } //Creando el grfico JFreeChart chart = ChartFactory.createBarChart3D("Consumo", "Fecha", "Consumo", dataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.cyan); chart.getTitle().setPaint(Color.black); chart.setBackgroundPaint(Color.white); chart.removeLegend(); //Cambiar color de barras CategoryPlot plot = (CategoryPlot) chart.getPlot(); BarRenderer barRenderer = (BarRenderer) plot.getRenderer(); barRenderer.setSeriesPaint(0, Color.decode("#5882FA")); // Mostrar Grafico ChartFrame frame = new ChartFrame("CONSUMO", chart); frame.pack(); frame.getChartPanel().setMouseZoomable(false); frame.setVisible(true); panel.add(frame); }