org.jfree.chart.plot.SpiderWebPlot Java Examples

The following examples show how to use org.jfree.chart.plot.SpiderWebPlot. 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: SpiderWebPlotTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #2
Source File: SpiderWebPlotTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #3
Source File: RadarChartExpressionTest.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testComputeChart() {
  System.out.println( "Start" );
  RadarChartExpression radarChart = new RadarChartExpression();
  TableModel tm = new AggregateTestDataTableModel();
  Map<String, Object> data = new HashMap<String, Object>();
  CollectorFunctionResult cfr = Mockito.mock( CollectorFunctionResult.class );
  Mockito.when( cfr.getDataSet() ).thenReturn(  Mockito.mock( org.jfree.data.general.Dataset.class ) );

  data.put( "name1", cfr );
  StaticDataRow dr = new StaticDataRow( data );
  ProcessingContext pc = new DefaultProcessingContext();
  DebugExpressionRuntime der = new DebugExpressionRuntime( dr, tm, 0, pc );
  radarChart.setRuntime( der );
  radarChart.setSeriesColor( new String[]{ "maroon", "#FDDF00" } );
  radarChart.setDataSource( "name1" );
  JFreeChartReportDrawable chart = (JFreeChartReportDrawable) radarChart.getValue();
  Assert.assertTrue( "first color is maroon : ", ( ( (SpiderWebPlot) chart.getChart().getPlot() ).getSeriesPaint( 0 ).equals( ColorHelper.lookupColor( "maroon" ) ) ) );
  Assert.assertTrue( "second color is #FDDF00 : ", ( ( (SpiderWebPlot) chart.getChart().getPlot() ).getSeriesPaint( 1 ).equals( Color.decode( "#FDDF00" ) ) ) );
  System.out.println( "Finish" );
}
 
Example #4
Source File: ChartJFreeChartOutputRadar.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
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)) {
		// DEBUG.LOG("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);
		}

	}

}
 
Example #5
Source File: ChartJFreeChartOutputRadar.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
@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;
}
 
Example #6
Source File: DefaultChartService.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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;
}
 
Example #7
Source File: ChartImageGenerator.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private JFreeChart getRadarChart( final Visualization visualization, CategoryDataset dataSet )
{
    SpiderWebPlot plot = new SpiderWebPlot( dataSet, TableOrder.BY_ROW );
    plot.setLabelFont( LABEL_FONT );

    JFreeChart radarChart = new JFreeChart( visualization.getName(), TITLE_FONT, plot, !visualization.isHideLegend() );

    setBasicConfig( radarChart, visualization );

    return radarChart;
}
 
Example #8
Source File: ChartJFreeChartOutputRadar.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
@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);
	if(!IdPosition.containsKey(serieid)) {

		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);
	}
	// DEBUG.LOG("new serie"+serieid+" at
	// "+IdPosition.get(serieid)+" fdsize "+plot.getCategories().size()+"
	// jfds "+jfreedataset.size()+" datasc "+plot.getDatasetCount()+" nbse
	// "+nbseries);
	// TODO Auto-generated method stub
}
 
Example #9
Source File: ChartJFreeChartOutputRadar.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
@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);

}
 
Example #10
Source File: RadarChartExpression.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected void configureChart( final JFreeChart chart ) {
  super.configureChart( chart );

  //Create the stroke for the primary (= real) data series...
  final Stroke thick = new BasicStroke( thicknessprimaryseries );

  //...and apply that stroke to the series
  final SpiderWebPlot webPlot = (SpiderWebPlot) chart.getPlot();
  webPlot.setLabelFont( Font.decode( getLabelFont() ) );

  if ( StringUtils.isEmpty( getTooltipFormula() ) == false ) {
    webPlot.setToolTipGenerator( new FormulaCategoryTooltipGenerator( getRuntime(), getTooltipFormula() ) );
  }
  if ( StringUtils.isEmpty( getUrlFormula() ) == false ) {
    webPlot.setURLGenerator( new FormulaCategoryURLGenerator( getRuntime(), getUrlFormula() ) );
  }


  final CategoryDataset categoryDataset = webPlot.getDataset();
  final int count = categoryDataset.getRowCount();

  for ( int t = 0; t < count; t++ ) {
    if ( categoryDataset.getRowKey( t ) instanceof GridCategoryItem ) {
      continue;
    }
    webPlot.setSeriesOutlineStroke( t, thick );
  }

  //Set the spiderweb filled (or not)
  webPlot.setWebFilled( radarwebfilled );
  //Set the size of the datapoints on the axis
  webPlot.setHeadPercent( headsize );

  //Set the color of the fake datasets (gridlines) to grey
  for ( int t = 0; t < count; t++ ) {
    if ( categoryDataset.getRowKey( t ) instanceof GridCategoryItem ) {
      webPlot.setSeriesPaint( t, Color.GRAY );
    }
  }

}
 
Example #11
Source File: StandardChartTheme.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
    }
}
 
Example #12
Source File: StandardChartTheme.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example #13
Source File: ChartJFreeChartOutputRadar.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
@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);
	}

}
 
Example #14
Source File: StandardChartTheme.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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);
    }
}
 
Example #15
Source File: StandardChartTheme.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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);
}
 
Example #16
Source File: StandardChartTheme.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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);
    }
}
 
Example #17
Source File: StandardChartTheme.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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);
}
 
Example #18
Source File: StandardChartTheme.java    From ECG-Viewer with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example #19
Source File: StandardChartTheme.java    From ECG-Viewer with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
    }
}
 
Example #20
Source File: StandardChartTheme.java    From openstock with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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);
    }
}
 
Example #21
Source File: WebPlotter.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void updatePlotter() {
	final int categoryCount = prepareData();

	SwingUtilities.invokeLater(new Runnable() {

		@Override
		public void run() {
			scrollablePlotterPanel.remove(viewScrollBar);
		}
	});

	if (categoryCount > MAX_CATEGORY_VIEW_COUNT && showScrollbar) {
		SwingUtilities.invokeLater(new Runnable() {

			@Override
			public void run() {
				viewScrollBar.setOrientation(Adjustable.HORIZONTAL);
				scrollablePlotterPanel.add(viewScrollBar, BorderLayout.SOUTH);
			}
		});

		this.slidingCategoryDataSet = new SlidingCategoryDataset(categoryDataSet, 0, MAX_CATEGORY_VIEW_COUNT);
		viewScrollBar.setMaximum(categoryCount);
		viewScrollBar.setValue(0);

	} else {
		this.slidingCategoryDataSet = null;
	}

	if (categoryCount <= MAX_CATEGORIES) {

		SpiderWebPlot plot = new SpiderWebPlot(categoryDataSet);

		plot.setAxisLinePaint(Color.LIGHT_GRAY);
		plot.setOutlinePaint(Color.WHITE);

		plot.setLabelGenerator(new StandardCategoryItemLabelGenerator());

		JFreeChart chart = new JFreeChart("", TextTitle.DEFAULT_FONT, plot, true);

		double[] colorValues = null;
		if (groupByColumn >= 0 && this.dataTable.isNominal(groupByColumn)) {
			colorValues = new double[this.dataTable.getNumberOfValues(groupByColumn)];
		} else {
			colorValues = new double[categoryDataSet.getColumnCount()];
		}
		for (int i = 0; i < colorValues.length; i++) {
			colorValues[i] = i;
		}

		if (panel != null) {
			panel.setChart(chart);
		} else {
			panel = new AbstractChartPanel(chart, getWidth(), getHeight() - MARGIN);
			scrollablePlotterPanel.add(panel, BorderLayout.CENTER);
			final ChartPanelShiftController controller = new ChartPanelShiftController(panel);
			panel.addMouseListener(controller);
			panel.addMouseMotionListener(controller);
		}

		// set the background color for the chart...
		chart.setBackgroundPaint(Color.white);

		// legend settings
		LegendTitle legend = chart.getLegend();
		if (legend != null) {
			legend.setPosition(RectangleEdge.TOP);
			legend.setFrame(BlockBorder.NONE);
			legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
			legend.setItemFont(LABEL_FONT);
		}
		if (groupByColumn < 0) {
			// no legend is needed when there is no group-by selection
			chart.removeLegend();
		}
		// ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!!
		panel.getChartRenderingInfo().setEntityCollection(null);
	} else {
		LogService.getRoot().log(Level.INFO, "com.rapidminer.gui.plotter.charts.BarChartPlotter.too_many_columns",
				new Object[] { categoryCount, MAX_CATEGORIES });
	}
}
 
Example #22
Source File: StandardChartTheme.java    From SIMVA-SoS with Apache License 2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example #23
Source File: StandardChartTheme.java    From SIMVA-SoS with Apache License 2.0 4 votes vote down vote up
/**
 * 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);
    }
}
 
Example #24
Source File: StandardChartTheme.java    From ccu-historian with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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);
}
 
Example #25
Source File: StandardChartTheme.java    From ccu-historian with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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);
    }
}
 
Example #26
Source File: StandardChartTheme.java    From openstock with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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);
}