/** * Draws the chart with a null info object to make sure that no exceptions * are thrown. */ public void testDrawWithNullInfo() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(35.0, "S1", "C1"); dataset.addValue(45.0, "S1", "C2"); dataset.addValue(55.0, "S1", "C3"); dataset.addValue(15.0, "S1", "C4"); dataset.addValue(25.0, "S1", "C5"); SpiderWebPlot plot = new SpiderWebPlot(dataset); JFreeChart chart = new JFreeChart(plot); boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { success = false; } assertTrue(success); }
protected void resetRenderer(final IScope scope, final String serieid) { final SpiderWebPlot plot = (SpiderWebPlot) this.chart.getPlot(); final ChartDataSeries myserie = this.getChartdataset().getDataSeries(scope, serieid); if (!IdPosition.containsKey(serieid)) { // System.out.println("pb!!!"); } else { final int myrow = IdPosition.get(serieid); if (myserie.getMycolor() != null) { plot.setSeriesPaint(myrow, myserie.getMycolor()); } if (this.series_label_position.equals("onchart")) { //// newr.setBaseItemLabelGenerator(new LabelGenerator()); // ItemLabelPosition itemlabelposition = new //// ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, //// TextAnchor.BOTTOM_CENTER); // newr.setBasePositiveItemLabelPosition(itemlabelposition); // newr.setBaseNegativeItemLabelPosition(itemlabelposition); // newr.setBaseItemLabelsVisible(true); } } }
@Override protected void clearDataSet(final IScope scope) { // TODO Auto-generated method stub super.clearDataSet(scope); final SpiderWebPlot plot = (SpiderWebPlot) this.chart.getPlot(); for (int i = plot.getDataset().getRowCount() - 1; i >= 1; i--) { // plot.setDataset(i, null); // plot.setRenderer(i, null); } if (jfreedataset.size() > 0) ((DefaultCategoryDataset) jfreedataset.get(0)).clear(); jfreedataset.clear(); jfreedataset.add(0, new DefaultCategoryDataset()); plot.setDataset((DefaultCategoryDataset) jfreedataset.get(0)); IdPosition.clear(); nbseries = 0; }
private JFreeChart getRadarChart( BaseChart chart, CategoryDataset dataSet ) { SpiderWebPlot plot = new SpiderWebPlot( dataSet, TableOrder.BY_ROW ); plot.setLabelFont( LABEL_FONT ); JFreeChart radarChart = new JFreeChart( chart.getName(), TITLE_FONT, plot, !chart.isHideLegend() ); setBasicConfig( radarChart, chart ); return radarChart; }
@Override public void createChart(final IScope scope) { super.createChart(scope); final SpiderWebPlot plot = new SpiderWebPlot((CategoryDataset) createDataset(scope)); chart = new JFreeChart(getName(), null, plot, true); }
@Override protected void createNewSerie(final IScope scope, final String serieid) { // final ChartDataSeries dataserie = chartdataset.getDataSeries(scope, // serieid); // final XYIntervalSeries serie = new // XYIntervalSeries(dataserie.getSerieLegend(scope), false, true); final SpiderWebPlot plot = (SpiderWebPlot) this.chart.getPlot(); final DefaultCategoryDataset firstdataset = (DefaultCategoryDataset) plot.getDataset(); if (nbseries == 0) { plot.setDataset(firstdataset); } else { // DefaultCategoryDataset newdataset=new DefaultCategoryDataset(); // jfreedataset.add(newdataset); // plot.setDataset(jfreedataset.size()-1, newdataset); // plot.setDataset(nbseries, firstdataset); } nbseries++; // plot.setRenderer(nbseries-1, // (CategoryItemRenderer)getOrCreateRenderer(scope,serieid)); IdPosition.put(serieid, nbseries - 1); // System.out.println("new serie"+serieid+" at // "+IdPosition.get(serieid)+" fdsize "+plot.getCategories().size()+" // jfds "+jfreedataset.size()+" datasc "+plot.getDatasetCount()+" nbse // "+nbseries); // TODO Auto-generated method stub }
/** * Basic setup of a chart. * * @param dataset * dataset for the chart */ private JFreeChart setupChart(DefaultCategoryDataset dataset) { SpiderWebPlot plot = new SpiderWebPlot(dataset); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, drawLegend); return chart; }
/** * Applies the attributes of this theme to a plot. * * @param plot the plot (<code>null</code>). */ protected void applyToPlot(Plot plot) { ParamChecks.nullNotPermitted(plot, "plot"); if (plot.getDrawingSupplier() != null) { plot.setDrawingSupplier(getDrawingSupplier()); } if (plot.getBackgroundPaint() != null) { plot.setBackgroundPaint(this.plotBackgroundPaint); } plot.setOutlinePaint(this.plotOutlinePaint); // now handle specific plot types (and yes, I know this is some // really ugly code that has to be manually updated any time a new // plot type is added - I should have written something much cooler, // but I didn't and neither did anyone else). if (plot instanceof PiePlot) { applyToPiePlot((PiePlot) plot); } else if (plot instanceof MultiplePiePlot) { applyToMultiplePiePlot((MultiplePiePlot) plot); } else if (plot instanceof CategoryPlot) { applyToCategoryPlot((CategoryPlot) plot); } else if (plot instanceof XYPlot) { applyToXYPlot((XYPlot) plot); } else if (plot instanceof FastScatterPlot) { applyToFastScatterPlot((FastScatterPlot) plot); } else if (plot instanceof MeterPlot) { applyToMeterPlot((MeterPlot) plot); } else if (plot instanceof ThermometerPlot) { applyToThermometerPlot((ThermometerPlot) plot); } else if (plot instanceof SpiderWebPlot) { applyToSpiderWebPlot((SpiderWebPlot) plot); } else if (plot instanceof PolarPlot) { applyToPolarPlot((PolarPlot) plot); } }
/** * Applies the attributes of this theme to a {@link SpiderWebPlot}. * * @param plot the plot (<code>null</code> not permitted). */ protected void applyToSpiderWebPlot(SpiderWebPlot plot) { plot.setLabelFont(this.regularFont); plot.setLabelPaint(this.axisLabelPaint); plot.setAxisLinePaint(this.axisLabelPaint); }
/** * Applies the attributes of this theme to a plot. * * @param plot the plot ({@code null}). */ protected void applyToPlot(Plot plot) { Args.nullNotPermitted(plot, "plot"); if (plot.getDrawingSupplier() != null) { plot.setDrawingSupplier(getDrawingSupplier()); } if (plot.getBackgroundPaint() != null) { plot.setBackgroundPaint(this.plotBackgroundPaint); } plot.setOutlinePaint(this.plotOutlinePaint); // now handle specific plot types (and yes, I know this is some // really ugly code that has to be manually updated any time a new // plot type is added - I should have written something much cooler, // but I didn't and neither did anyone else). if (plot instanceof PiePlot) { applyToPiePlot((PiePlot) plot); } else if (plot instanceof MultiplePiePlot) { applyToMultiplePiePlot((MultiplePiePlot) plot); } else if (plot instanceof CategoryPlot) { applyToCategoryPlot((CategoryPlot) plot); } else if (plot instanceof XYPlot) { applyToXYPlot((XYPlot) plot); } else if (plot instanceof FastScatterPlot) { applyToFastScatterPlot((FastScatterPlot) plot); } else if (plot instanceof MeterPlot) { applyToMeterPlot((MeterPlot) plot); } else if (plot instanceof ThermometerPlot) { applyToThermometerPlot((ThermometerPlot) plot); } else if (plot instanceof SpiderWebPlot) { applyToSpiderWebPlot((SpiderWebPlot) plot); } else if (plot instanceof PolarPlot) { applyToPolarPlot((PolarPlot) plot); } }
/** * Applies the attributes of this theme to a {@link SpiderWebPlot}. * * @param plot the plot ({@code null} not permitted). */ protected void applyToSpiderWebPlot(SpiderWebPlot plot) { plot.setLabelFont(this.regularFont); plot.setLabelPaint(this.axisLabelPaint); plot.setAxisLinePaint(this.axisLabelPaint); }
/** * Applies the attributes of this theme to a plot. * * @param plot the plot (<code>null</code>). */ protected void applyToPlot(Plot plot) { if (plot == null) { throw new IllegalArgumentException("Null 'plot' argument."); } if (plot.getDrawingSupplier() != null) { plot.setDrawingSupplier(getDrawingSupplier()); } if (plot.getBackgroundPaint() != null) { plot.setBackgroundPaint(this.plotBackgroundPaint); } plot.setOutlinePaint(this.plotOutlinePaint); // now handle specific plot types (and yes, I know this is some // really ugly code that has to be manually updated any time a new // plot type is added - I should have written something much cooler, // but I didn't and neither did anyone else). if (plot instanceof PiePlot) { applyToPiePlot((PiePlot) plot); } else if (plot instanceof MultiplePiePlot) { applyToMultiplePiePlot((MultiplePiePlot) plot); } else if (plot instanceof CategoryPlot) { applyToCategoryPlot((CategoryPlot) plot); } else if (plot instanceof XYPlot) { applyToXYPlot((XYPlot) plot); } else if (plot instanceof FastScatterPlot) { applyToFastScatterPlot((FastScatterPlot) plot); } else if (plot instanceof MeterPlot) { applyToMeterPlot((MeterPlot) plot); } else if (plot instanceof ThermometerPlot) { applyToThermometerPlot((ThermometerPlot) plot); } else if (plot instanceof SpiderWebPlot) { applyToSpiderWebPlot((SpiderWebPlot) plot); } else if (plot instanceof PolarPlot) { applyToPolarPlot((PolarPlot) plot); } }
@Override public void initChart_post_data_init(final IScope scope) { // TODO Auto-generated method stub super.initChart_post_data_init(scope); final SpiderWebPlot pp = (SpiderWebPlot) chart.getPlot(); // final String sty = getStyle(); // this.useSubAxis=false; // switch (sty) { // default: { if (this.series_label_position.equals("default")) { 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.setAxisLinePaint(axesColor); pp.setLabelFont(getLabelFont()); if (textColor != null) { pp.setLabelPaint(textColor); } if (ylabel != null && ylabel != "") {} if (this.series_label_position.equals("yaxis")) { // pp.getRangeAxis().setLabel(this.getChartdataset().getDataSeriesIds(scope).iterator().next()); chart.getLegend().setVisible(false); } chart.getLegend().setVisible(true); if (xlabel != null && xlabel != "") { // pp.getDomainAxis().setLabel(xlabel); } if (this.series_label_position.equals("none")) pp.setLabelPaint(this.backgroundColor); }