Java Code Examples for org.jfree.chart.renderer.xy.XYBarRenderer#setShadowVisible()

The following examples show how to use org.jfree.chart.renderer.xy.XYBarRenderer#setShadowVisible() . 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: HistogramChartFactory.java    From mzmine2 with GNU General Public License v2.0 6 votes vote down vote up
public static JFreeChart createHistogramOld(double[] data, int bin, String yAxisLabel, double min,
    double max) {
  if (data != null && data.length > 0) {
    HistogramDataset dataset = new HistogramDataset();
    dataset.addSeries("histo", data, bin, min, max);

    JFreeChart chart = ChartFactory.createHistogram("", yAxisLabel, "n", dataset,
        PlotOrientation.VERTICAL, true, false, false);

    chart.setBackgroundPaint(new Color(230, 230, 230));
    chart.getLegend().setVisible(false);
    XYPlot xyplot = chart.getXYPlot();
    xyplot.setForegroundAlpha(0.7F);
    xyplot.setBackgroundPaint(Color.WHITE);
    xyplot.setDomainGridlinePaint(new Color(150, 150, 150));
    xyplot.setRangeGridlinePaint(new Color(150, 150, 150));
    xyplot.getDomainAxis().setVisible(true);
    xyplot.getRangeAxis().setVisible(yAxisLabel != null);
    XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer();
    xybarrenderer.setShadowVisible(false);
    xybarrenderer.setBarPainter(new StandardXYBarPainter());
    // xybarrenderer.setDrawBarOutline(false);
    return chart;
  } else
    return null;
}
 
Example 2
Source File: HistogramChartFactory.java    From old-mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
public static JFreeChart createHistogramOld(double[] data, int bin, String yAxisLabel, double min,
    double max) {
  if (data != null && data.length > 0) {
    HistogramDataset dataset = new HistogramDataset();
    dataset.addSeries("histo", data, bin, min, max);

    JFreeChart chart = ChartFactory.createHistogram("", yAxisLabel, "n", dataset,
        PlotOrientation.VERTICAL, true, false, false);

    chart.setBackgroundPaint(new Color(230, 230, 230));
    chart.getLegend().setVisible(false);
    XYPlot xyplot = chart.getXYPlot();
    xyplot.setForegroundAlpha(0.7F);
    xyplot.setBackgroundPaint(Color.WHITE);
    xyplot.setDomainGridlinePaint(new Color(150, 150, 150));
    xyplot.setRangeGridlinePaint(new Color(150, 150, 150));
    xyplot.getDomainAxis().setVisible(true);
    xyplot.getRangeAxis().setVisible(yAxisLabel != null);
    XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer();
    xybarrenderer.setShadowVisible(false);
    xybarrenderer.setBarPainter(new StandardXYBarPainter());
    // xybarrenderer.setDrawBarOutline(false);
    return chart;
  } else
    return null;
}
 
Example 3
Source File: HistogramChartFactory.java    From old-mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
public static JFreeChart createHistogram(XYSeries series, double barwidth, String yAxisLabel) {
  XYSeriesCollection xydata = new XYSeriesCollection(series);
  XYBarDataset dataset = new XYBarDataset(xydata, barwidth);
  JFreeChart chart = ChartFactory.createXYBarChart("", yAxisLabel, false, "n", dataset,
      PlotOrientation.VERTICAL, true, true, false);

  XYPlot xyplot = chart.getXYPlot();
  chart.setBackgroundPaint(new Color(230, 230, 230));
  chart.getLegend().setVisible(false);
  xyplot.setForegroundAlpha(0.7F);
  xyplot.setBackgroundPaint(Color.WHITE);
  xyplot.setDomainGridlinePaint(new Color(150, 150, 150));
  xyplot.setRangeGridlinePaint(new Color(150, 150, 150));
  xyplot.getDomainAxis().setVisible(true);
  xyplot.getRangeAxis().setVisible(yAxisLabel != null);
  XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer();
  xybarrenderer.setShadowVisible(false);
  xybarrenderer.setBarPainter(new StandardXYBarPainter());
  xybarrenderer.setDrawBarOutline(false);
  return chart;
}
 
Example 4
Source File: BeltTimeColumnStatisticsModel.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Creates the histogram chart.
 */
private JFreeChart createHistogramChart(final Table table) {
	JFreeChart chart = ChartFactory.createHistogram(null, null, null, createHistogramDataset(table),
			PlotOrientation.VERTICAL, false, false, false);
	setDefaultChartFonts(chart);
	chart.setBackgroundPaint(null);
	chart.setBackgroundImageAlpha(0.0f);

	XYPlot plot = (XYPlot) chart.getPlot();
	plot.setRangeGridlinesVisible(false);
	plot.setDomainGridlinesVisible(false);
	plot.setOutlineVisible(false);
	plot.setRangeZeroBaselineVisible(false);
	plot.setDomainZeroBaselineVisible(false);
	plot.getDomainAxis().setTickLabelsVisible(false);
	plot.setBackgroundPaint(COLOR_INVISIBLE);
	plot.setBackgroundImageAlpha(0.0f);

	XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
	renderer.setSeriesPaint(0, AttributeGuiTools.getColorForValueType(Ontology.DATE_TIME));
	renderer.setBarPainter(new StandardXYBarPainter());
	renderer.setDrawBarOutline(true);
	renderer.setShadowVisible(false);

	return chart;
}
 
Example 5
Source File: BeltNumericalColumnStatisticsModel.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Creates the histogram chart.
 */
private JFreeChart createHistogramChart(Table table) {
	JFreeChart chart = ChartFactory.createHistogram(null, null, null, createHistogramDataset(table),
			PlotOrientation.VERTICAL, false, false, false);
	AbstractAttributeStatisticsModel.setDefaultChartFonts(chart);
	chart.setBackgroundPaint(null);
	chart.setBackgroundImageAlpha(0.0f);

	XYPlot plot = (XYPlot) chart.getPlot();
	plot.setRangeGridlinesVisible(false);
	plot.setDomainGridlinesVisible(false);
	plot.setOutlineVisible(false);
	plot.setRangeZeroBaselineVisible(false);
	plot.setDomainZeroBaselineVisible(false);
	plot.setBackgroundPaint(COLOR_INVISIBLE);
	plot.setBackgroundImageAlpha(0.0f);

	XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
	renderer.setSeriesPaint(0, AttributeGuiTools.getColorForValueType(Ontology.NUMERICAL));
	renderer.setBarPainter(new StandardXYBarPainter());
	renderer.setDrawBarOutline(true);
	renderer.setShadowVisible(false);

	return chart;
}
 
Example 6
Source File: BeltDateTimeColumnStatisticsModel.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Creates the histogram chart.
 */
private JFreeChart createHistogramChart(final Table table) {
	JFreeChart chart = ChartFactory.createHistogram(null, null, null, createHistogramDataset(table),
			PlotOrientation.VERTICAL, false, false, false);
	setDefaultChartFonts(chart);
	chart.setBackgroundPaint(null);
	chart.setBackgroundImageAlpha(0.0f);

	XYPlot plot = (XYPlot) chart.getPlot();
	plot.setRangeGridlinesVisible(false);
	plot.setDomainGridlinesVisible(false);
	plot.setOutlineVisible(false);
	plot.setRangeZeroBaselineVisible(false);
	plot.setDomainZeroBaselineVisible(false);
	plot.getDomainAxis().setTickLabelsVisible(false);
	plot.setBackgroundPaint(COLOR_INVISIBLE);
	plot.setBackgroundImageAlpha(0.0f);

	XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
	renderer.setSeriesPaint(0, AttributeGuiTools.getColorForValueType(Ontology.DATE_TIME));
	renderer.setBarPainter(new StandardXYBarPainter());
	renderer.setDrawBarOutline(true);
	renderer.setShadowVisible(false);

	return chart;
}
 
Example 7
Source File: HistogramPanel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private void createUI() {
    dataset = new XIntervalSeriesCollection();
    chart = ChartFactory.createHistogram(
            CHART_TITLE,
            "Values",
            "Frequency in #pixels",
            dataset,
            PlotOrientation.VERTICAL,
            false,  // Legend?
            true,   // tooltips
            false   // url
    );
    final XYPlot xyPlot = chart.getXYPlot();
    xyPlot.setDomainZeroBaselineStroke(new BasicStroke(0.2f));

    final XYBarRenderer renderer = (XYBarRenderer) xyPlot.getRenderer();
    renderer.setDrawBarOutline(false);
    renderer.setShadowVisible(false);
    renderer.setShadowYOffset(-4.0);
    renderer.setBaseToolTipGenerator(new XYPlotToolTipGenerator());
    renderer.setBarPainter(new StandardXYBarPainter());
    renderer.setSeriesPaint(0, new Color(0, 0, 200));

    createUI(createChartPanel(chart), createOptionsPanel(), bindingContext);

    isInitialized = true;

    final Binding minBinding = xAxisRangeControl.getBindingContext().getBinding("min");
    final double min = (Double) minBinding.getPropertyValue();
    final Binding maxBinding = xAxisRangeControl.getBindingContext().getBinding("max");
    final double max = (Double) maxBinding.getPropertyValue();
    if (!histogramComputing && min > max) {
        minBinding.setPropertyValue(max);
        maxBinding.setPropertyValue(min);
    }
    updateXAxis();
}
 
Example 8
Source File: StandardChartTheme.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Applies the settings of this theme to the specified renderer.
 *
 * @param renderer  the renderer (<code>null</code> not permitted).
 */
protected void applyToXYItemRenderer(XYItemRenderer renderer) {
    ParamChecks.nullNotPermitted(renderer, "renderer");
    if (renderer instanceof AbstractRenderer) {
        applyToAbstractRenderer((AbstractRenderer) renderer);
    }
    renderer.setBaseItemLabelFont(this.regularFont);
    renderer.setBaseItemLabelPaint(this.itemLabelPaint);
    if (renderer instanceof XYBarRenderer) {
        XYBarRenderer br = (XYBarRenderer) renderer;
        br.setBarPainter(this.xyBarPainter);
        br.setShadowVisible(this.shadowVisible);
    }
}
 
Example 9
Source File: StatisticsPanel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private static ChartPanel getHistogramPlotPanel(XIntervalSeriesCollection dataset, String xAxisLabel, String yAxisLabel, Color color) {
        JFreeChart chart = ChartFactory.createHistogram(
                null,
                xAxisLabel,
                yAxisLabel,
                dataset,
                PlotOrientation.VERTICAL,
                false,  // Legend?
                true,   // tooltips
                false   // url
        );
        final XYPlot xyPlot = chart.getXYPlot();
        //xyPlot.setForegroundAlpha(0.85f);
        xyPlot.setNoDataMessage("No data");
        xyPlot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));

        final XYBarRenderer renderer = (XYBarRenderer) xyPlot.getRenderer();
        renderer.setDrawBarOutline(false);
        renderer.setShadowVisible(false);
        renderer.setSeriesPaint(0, color);
        StandardXYBarPainter painter = new StandardXYBarPainter();
        renderer.setBarPainter(painter);

        ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setPreferredSize(new Dimension(300, 200));
//        chartPanel.getPopupMenu().add(createCopyDataToClipboardMenuItem());
        return chartPanel;
    }
 
Example 10
Source File: ChartRendererFactory.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
private static void configureXYBarRenderer(XYBarRenderer renderer, ValueSource valueSource, PlotInstance plotInstance) {
	StandardXYBarPainter barPainter = new StandardXYBarPainter();
	renderer.setBarPainter(barPainter);
	renderer.setGradientPaintTransformer(null);
	SeriesFormat seriesFormat = valueSource.getSeriesFormat();
	DimensionConfig domainConfig = valueSource.getDomainConfig();
	ValueSourceData valueSourceData = plotInstance.getPlotData().getValueSourceData(valueSource);
	int seriesCount;
	if (valueSourceData != null) {
		seriesCount = valueSourceData.getSeriesCount();
	} else {
		seriesCount = 0;
	}
	DimensionConfig colorDimensionConfig = plotInstance.getCurrentPlotConfigurationClone().getDimensionConfig(
			PlotDimension.COLOR);
	// don't need shapeDimensionConfig, since the shape can't be represented for bars.

	// Loop all series and set series format.
	// Format based on dimension configs will be set later on in initFormatDelegate().
	for (int seriesIdx = 0; seriesIdx < seriesCount; ++seriesIdx) {
		// configure series paint if necessary
		if (!SeriesFormat.calculateIndividualFormatForEachItem(domainConfig, colorDimensionConfig)) {
			renderer.setSeriesPaint(seriesIdx, seriesFormat.getAreaFillPaint());
		}

		// configure general style of the bars
		renderer.setShadowVisible(false);
		renderer.setSeriesOutlinePaint(seriesIdx, PlotConfiguration.DEFAULT_SERIES_OUTLINE_PAINT);
	}
	renderer.setDrawBarOutline(true);
}
 
Example 11
Source File: StandardChartTheme.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Applies the settings of this theme to the specified renderer.
 *
 * @param renderer  the renderer (<code>null</code> not permitted).
 */
protected void applyToXYItemRenderer(XYItemRenderer renderer) {
    ParamChecks.nullNotPermitted(renderer, "renderer");
    if (renderer instanceof AbstractRenderer) {
        applyToAbstractRenderer((AbstractRenderer) renderer);
    }
    renderer.setBaseItemLabelFont(this.regularFont);
    renderer.setBaseItemLabelPaint(this.itemLabelPaint);
    if (renderer instanceof XYBarRenderer) {
        XYBarRenderer br = (XYBarRenderer) renderer;
        br.setBarPainter(this.xyBarPainter);
        br.setShadowVisible(this.shadowVisible);
    }
}
 
Example 12
Source File: StandardChartTheme.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Applies the settings of this theme to the specified renderer.
 *
 * @param renderer  the renderer (<code>null</code> not permitted).
 */
protected void applyToXYItemRenderer(XYItemRenderer renderer) {
    ParamChecks.nullNotPermitted(renderer, "renderer");
    if (renderer instanceof AbstractRenderer) {
        applyToAbstractRenderer((AbstractRenderer) renderer);
    }
    renderer.setBaseItemLabelFont(this.regularFont);
    renderer.setBaseItemLabelPaint(this.itemLabelPaint);
    if (renderer instanceof XYBarRenderer) {
        XYBarRenderer br = (XYBarRenderer) renderer;
        br.setBarPainter(this.xyBarPainter);
        br.setShadowVisible(this.shadowVisible);
    }
}
 
Example 13
Source File: StandardChartTheme.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Applies the settings of this theme to the specified renderer.
 *
 * @param renderer  the renderer (<code>null</code> not permitted).
 */
protected void applyToXYItemRenderer(XYItemRenderer renderer) {
    ParamChecks.nullNotPermitted(renderer, "renderer");
    if (renderer instanceof AbstractRenderer) {
        applyToAbstractRenderer((AbstractRenderer) renderer);
    }
    renderer.setBaseItemLabelFont(this.regularFont);
    renderer.setBaseItemLabelPaint(this.itemLabelPaint);
    if (renderer instanceof XYBarRenderer) {
        XYBarRenderer br = (XYBarRenderer) renderer;
        br.setBarPainter(this.xyBarPainter);
        br.setShadowVisible(this.shadowVisible);
    }
}
 
Example 14
Source File: SimpleChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
	 *
	 */
	protected JFreeChart createXYBarChart() throws JRException
	{
		IntervalXYDataset tmpDataset = (IntervalXYDataset)getDataset();

		boolean isDate = true;
		if ( getChart().getDataset().getDatasetType() == JRChartDataset.XY_DATASET ){
			isDate = false;
		}

		ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
		JFreeChart jfreeChart =
			ChartFactory.createXYBarChart(
				evaluateTextExpression(getChart().getTitleExpression()),
				evaluateTextExpression(((JRBarPlot)getPlot()).getCategoryAxisLabelExpression()),
				isDate,
				evaluateTextExpression(((JRBarPlot)getPlot()).getValueAxisLabelExpression()),
				tmpDataset,
				getPlot().getOrientationValue().getOrientation(),
				isShowLegend(),
				true,
				false
				);

		configureChart(jfreeChart, getPlot());

		XYPlot xyPlot = (XYPlot)jfreeChart.getPlot();
		//plot.setNoDataMessage("No data to display");
//		((XYPlot)plot.getDomainAxis()).setTickMarksVisible(
//			((JRBarPlot)getPlot()).isShowTickMarks()
//			);
//		((CategoryAxis)plot.getDomainAxis()).setTickLabelsVisible(
//				((JRBarPlot)getPlot()).isShowTickLabels()
//				);
//		((NumberAxis)plot.getRangeAxis()).setTickMarksVisible(
//				((JRBarPlot)getPlot()).isShowTickMarks()
//				);
//		((NumberAxis)plot.getRangeAxis()).setTickLabelsVisible(
//				((JRBarPlot)getPlot()).isShowTickLabels()
//				);


		XYBarRenderer itemRenderer = (XYBarRenderer)xyPlot.getRenderer();
		itemRenderer.setBaseItemLabelGenerator((XYItemLabelGenerator)getLabelGenerator());
		itemRenderer.setShadowVisible(false);

		JRBarPlot barPlot = (JRBarPlot)getPlot();
		boolean isShowLabels = barPlot.getShowLabels() == null ? false : barPlot.getShowLabels();
		
		itemRenderer.setBaseItemLabelsVisible( isShowLabels );

		// Handle the axis formating for the category axis
		configureAxis(xyPlot.getDomainAxis(), barPlot.getCategoryAxisLabelFont(),
				barPlot.getCategoryAxisLabelColor(), barPlot.getCategoryAxisTickLabelFont(),
				barPlot.getCategoryAxisTickLabelColor(), barPlot.getCategoryAxisTickLabelMask(), barPlot.getCategoryAxisVerticalTickLabels(),
				barPlot.getOwnCategoryAxisLineColor(), getDomainAxisSettings(), DateTickUnitType.DAY,
				(Comparable<?>)evaluateExpression(barPlot.getDomainAxisMinValueExpression()), 
				(Comparable<?>)evaluateExpression(barPlot.getDomainAxisMaxValueExpression())
				);


		// Handle the axis formating for the value axis
		configureAxis(xyPlot.getRangeAxis(), barPlot.getValueAxisLabelFont(),
				barPlot.getValueAxisLabelColor(), barPlot.getValueAxisTickLabelFont(),
				barPlot.getValueAxisTickLabelColor(), barPlot.getValueAxisTickLabelMask(), barPlot.getValueAxisVerticalTickLabels(),
				barPlot.getOwnValueAxisLineColor(), getRangeAxisSettings(), DateTickUnitType.DAY,
				(Comparable<?>)evaluateExpression(barPlot.getRangeAxisMinValueExpression()), 
				(Comparable<?>)evaluateExpression(barPlot.getRangeAxisMaxValueExpression())
				);

		return jfreeChart;
	}
 
Example 15
Source File: XYBarChartExpression.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 );

  final XYPlot xypl = chart.getXYPlot();
  final XYItemRenderer renderer = xypl.getRenderer();
  final XYBarRenderer br = (XYBarRenderer) renderer;
  br.setDrawBarOutline( isChartSectionOutline() );
  if ( margin != null ) {
    br.setMargin( margin.doubleValue() );
  }

  br.setShadowVisible( shadowVisible );
  br.setShadowXOffset( shadowXOffset );
  br.setShadowYOffset( shadowYOffset );

  if ( ( isStacked() ) && renderPercentages && ( br instanceof StackedXYBarRenderer ) ) {
    final StackedXYBarRenderer sbr = (StackedXYBarRenderer) br;
    sbr.setRenderAsPercentages( true );

    final ValueAxis rangeAxis = xypl.getRangeAxis();
    final int level = getRuntime().getProcessingContext().getCompatibilityLevel();
    if ( ClassicEngineBoot.isEnforceCompatibilityFor( level, 3, 8 ) ) {
      if ( getRangeMinimum() != 0 ) {
        rangeAxis.setLowerBound( getRangeMinimum() );
      }
      if ( getRangeMaximum() != 1 ) {
        rangeAxis.setUpperBound( getRangeMaximum() );
      }
      if ( getRangeMinimum() == 0 && getRangeMaximum() == 0 ) {
        rangeAxis.setLowerBound( 0 );
        rangeAxis.setUpperBound( 1 );
        rangeAxis.setAutoRange( true );
      }
    } else {
      rangeAxis.setLowerBound( getRangeMinimum() );
      rangeAxis.setUpperBound( getRangeMaximum() );
      rangeAxis.setAutoRange( isRangeAxisAutoRange() );
    }
  }

}
 
Example 16
Source File: XYBarRendererTests.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Test that the equals() method distinguishes all fields.
 */
public void testEquals() {

    // default instances
    XYBarRenderer r1 = new XYBarRenderer();
    XYBarRenderer r2 = new XYBarRenderer();
    assertTrue(r1.equals(r2));
    assertTrue(r2.equals(r1));

    // setBase()
    r1.setBase(1.0);
    assertFalse(r1.equals(r2));
    r2.setBase(1.0);
    assertTrue(r1.equals(r2));

    // setUseYInterval
    r1.setUseYInterval(!r1.getUseYInterval());
    assertFalse(r1.equals(r2));
    r2.setUseYInterval(!r2.getUseYInterval());
    assertTrue(r1.equals(r2));

    // setMargin()
    r1.setMargin(0.10);
    assertFalse(r1.equals(r2));
    r2.setMargin(0.10);
    assertTrue(r1.equals(r2));

    // setDrawBarOutline()
    r1.setDrawBarOutline(!r1.isDrawBarOutline());
    assertFalse(r1.equals(r2));
    r2.setDrawBarOutline(!r2.isDrawBarOutline());
    assertTrue(r1.equals(r2));

    // setGradientPaintTransformer()
    r1.setGradientPaintTransformer(new StandardGradientPaintTransformer(
            GradientPaintTransformType.CENTER_HORIZONTAL));
    assertFalse(r1.equals(r2));
    r2.setGradientPaintTransformer(new StandardGradientPaintTransformer(
            GradientPaintTransformType.CENTER_HORIZONTAL));
    assertTrue(r1.equals(r2));

    // legendBar
    r1.setLegendBar(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
    assertFalse(r1.equals(r2));
    r2.setLegendBar(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
    assertTrue(r1.equals(r2));

    // positiveItemLabelFallbackPosition
    r1.setPositiveItemLabelPositionFallback(new ItemLabelPosition());
    assertFalse(r1.equals(r2));
    r2.setPositiveItemLabelPositionFallback(new ItemLabelPosition());
    assertTrue(r1.equals(r2));

    // negativeItemLabelFallbackPosition
    r1.setNegativeItemLabelPositionFallback(new ItemLabelPosition());
    assertFalse(r1.equals(r2));
    r2.setNegativeItemLabelPositionFallback(new ItemLabelPosition());
    assertTrue(r1.equals(r2));

    // barPainter
    r1.setBarPainter(new GradientXYBarPainter(0.11, 0.22, 0.33));
    assertFalse(r1.equals(r2));
    r2.setBarPainter(new GradientXYBarPainter(0.11, 0.22, 0.33));
    assertTrue(r1.equals(r2));

    // shadowsVisible
    r1.setShadowVisible(false);
    assertFalse(r1.equals(r2));
    r2.setShadowVisible(false);
    assertTrue(r1.equals(r2));

    // shadowXOffset
    r1.setShadowXOffset(3.3);
    assertFalse(r1.equals(r2));
    r2.setShadowXOffset(3.3);
    assertTrue(r1.equals(r2));

    // shadowYOffset
    r1.setShadowYOffset(3.3);
    assertFalse(r1.equals(r2));
    r2.setShadowYOffset(3.3);
    assertTrue(r1.equals(r2));

}
 
Example 17
Source File: MsSpectrumPlotWindowController.java    From old-mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
private void configureRenderer(MsSpectrumDataSet dataset, int datasetIndex) {

    final MsSpectrumType renderingType = dataset.getRenderingType();
    final XYPlot plot = chartNode.getChart().getXYPlot();

    // Set renderer
    AbstractXYItemRenderer newRenderer;
    switch (renderingType) {
      case PROFILE:
      case THRESHOLDED:
        XYLineAndShapeRenderer newLineRenderer = new XYLineAndShapeRenderer();
        final int lineThickness = dataset.getLineThickness();
        newLineRenderer.setBaseShape(new Ellipse2D.Double(-2 * lineThickness, -2 * lineThickness,
            4 * lineThickness + 1, 4 * lineThickness + 1));
        newLineRenderer.setBaseShapesFilled(true);
        newLineRenderer.setBaseShapesVisible(dataset.getShowDataPoints());
        newLineRenderer.setDrawOutlines(false);

        Stroke baseStroke = new BasicStroke(lineThickness);
        newLineRenderer.setBaseStroke(baseStroke);
        newRenderer = newLineRenderer;
        break;
      case CENTROIDED:
      default:
        XYBarRenderer newBarRenderer = new XYBarRenderer();
        // Avoid gradients
        newBarRenderer.setBarPainter(new StandardXYBarPainter());
        newBarRenderer.setShadowVisible(false);
        newRenderer = newBarRenderer;
        break;
    }

    // Set tooltips for legend
    newRenderer.setLegendItemToolTipGenerator((ds, series) -> {
      if (ds instanceof MsSpectrumDataSet) {
        return ((MsSpectrumDataSet) ds).getDescription();
      } else
        return null;
    });

    // Set color
    Color baseColor = dataset.getColor();
    newRenderer.setBasePaint(JavaFXUtil.convertColorToAWT(baseColor));

    // Set label generator
    XYItemLabelGenerator intelligentLabelGenerator =
        new IntelligentItemLabelGenerator(chartNode, 100, dataset);
    newRenderer.setBaseItemLabelGenerator(intelligentLabelGenerator);
    newRenderer.setBaseItemLabelPaint(JavaFXUtil.convertColorToAWT(labelsColor));
    newRenderer.setBaseItemLabelsVisible(itemLabelsVisible.get());

    // Set tooltip generator
    newRenderer.setBaseToolTipGenerator(dataset);

    plot.setRenderer(datasetIndex, newRenderer);

  }
 
Example 18
Source File: GenericChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
	 *
	 */
	protected JFreeChart createXYBarChart() throws JRException
	{
		IntervalXYDataset tmpDataset = (IntervalXYDataset)getDataset();

		boolean isDate = true;
		if ( getChart().getDataset().getDatasetType() == JRChartDataset.XY_DATASET ){
			isDate = false;
		}

		ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
		JFreeChart jfreeChart =
			ChartFactory.createXYBarChart(
				evaluateTextExpression(getChart().getTitleExpression()),
				evaluateTextExpression(((JRBarPlot)getPlot()).getCategoryAxisLabelExpression()),
				isDate,
				evaluateTextExpression(((JRBarPlot)getPlot()).getValueAxisLabelExpression()),
				tmpDataset,
				getPlot().getOrientationValue().getOrientation(),
				isShowLegend(),
				true,
				false
				);

		configureChart(jfreeChart, getPlot());

		XYPlot xyPlot = (XYPlot)jfreeChart.getPlot();
		//plot.setNoDataMessage("No data to display");
//		((XYPlot)plot.getDomainAxis()).setTickMarksVisible(
//			((JRBarPlot)getPlot()).isShowTickMarks()
//			);
//		((CategoryAxis)plot.getDomainAxis()).setTickLabelsVisible(
//				((JRBarPlot)getPlot()).isShowTickLabels()
//				);
//		((NumberAxis)plot.getRangeAxis()).setTickMarksVisible(
//				((JRBarPlot)getPlot()).isShowTickMarks()
//				);
//		((NumberAxis)plot.getRangeAxis()).setTickLabelsVisible(
//				((JRBarPlot)getPlot()).isShowTickLabels()
//				);


		XYBarRenderer itemRenderer = (XYBarRenderer)xyPlot.getRenderer();
		itemRenderer.setBaseItemLabelGenerator((XYItemLabelGenerator)getLabelGenerator());
		itemRenderer.setShadowVisible(false);

		JRBarPlot barPlot = (JRBarPlot)getPlot();
		boolean isShowLabels = barPlot.getShowLabels() == null ? false : barPlot.getShowLabels();
		
		itemRenderer.setBaseItemLabelsVisible( isShowLabels );

		// Handle the axis formating for the category axis
		configureAxis(xyPlot.getDomainAxis(), barPlot.getCategoryAxisLabelFont(),
				barPlot.getCategoryAxisLabelColor(), barPlot.getCategoryAxisTickLabelFont(),
				barPlot.getCategoryAxisTickLabelColor(), barPlot.getCategoryAxisTickLabelMask(), barPlot.getCategoryAxisVerticalTickLabels(),
				barPlot.getOwnCategoryAxisLineColor(), false,
				(Comparable<?>)evaluateExpression(barPlot.getDomainAxisMinValueExpression()),
				(Comparable<?>)evaluateExpression(barPlot.getDomainAxisMaxValueExpression()));

		// Handle the axis formating for the value axis
		configureAxis(xyPlot.getRangeAxis(), barPlot.getValueAxisLabelFont(),
				barPlot.getValueAxisLabelColor(), barPlot.getValueAxisTickLabelFont(),
				barPlot.getValueAxisTickLabelColor(), barPlot.getValueAxisTickLabelMask(), barPlot.getValueAxisVerticalTickLabels(),
				barPlot.getOwnValueAxisLineColor(), true,
				(Comparable<?>)evaluateExpression(barPlot.getRangeAxisMinValueExpression()),
				(Comparable<?>)evaluateExpression(barPlot.getRangeAxisMaxValueExpression()));

		return jfreeChart;
	}
 
Example 19
Source File: DefaultChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
	 *
	 */
	protected JFreeChart createXYBarChart() throws JRException
	{
		IntervalXYDataset tmpDataset = (IntervalXYDataset)getDataset();

		boolean isDate = true;
		if ( getChart().getDataset().getDatasetType() == JRChartDataset.XY_DATASET )
		{
			isDate = false;
		}

		ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
		JFreeChart jfreeChart =
			ChartFactory.createXYBarChart(
				evaluateTextExpression(getChart().getTitleExpression()),
				evaluateTextExpression(((JRBarPlot)getPlot()).getCategoryAxisLabelExpression()),
				isDate,
				evaluateTextExpression(((JRBarPlot)getPlot()).getValueAxisLabelExpression()),
				tmpDataset,
				getPlot().getOrientationValue().getOrientation(),
				isShowLegend(),
				true,
				false
				);

		configureChart(jfreeChart);

		XYPlot xyPlot = (XYPlot)jfreeChart.getPlot();
		//plot.setNoDataMessage("No data to display");
//		((XYPlot)plot.getDomainAxis()).setTickMarksVisible(
//			((JRFillBarPlot)getPlot()).isShowTickMarks()
//			);
//		((CategoryAxis)plot.getDomainAxis()).setTickLabelsVisible(
//				((JRFillBarPlot)getPlot()).isShowTickLabels()
//				);
//		((NumberAxis)plot.getRangeAxis()).setTickMarksVisible(
//				((JRFillBarPlot)getPlot()).isShowTickMarks()
//				);
//		((NumberAxis)plot.getRangeAxis()).setTickLabelsVisible(
//				((JRFillBarPlot)getPlot()).isShowTickLabels()
//				);


		XYBarRenderer itemRenderer = (XYBarRenderer)xyPlot.getRenderer();
		itemRenderer.setBaseItemLabelGenerator((XYItemLabelGenerator)getLabelGenerator() );
		itemRenderer.setShadowVisible(false);
		

		JRBarPlot barPlot = (JRBarPlot)getPlot();
		boolean isShowLabels = barPlot.getShowLabels() == null ? false : barPlot.getShowLabels();
		
		itemRenderer.setBaseItemLabelsVisible( isShowLabels );

		// Handle the axis formating for the category axis
		configureAxis(xyPlot.getDomainAxis(), barPlot.getCategoryAxisLabelFont(),
				barPlot.getCategoryAxisLabelColor(), barPlot.getCategoryAxisTickLabelFont(),
				barPlot.getCategoryAxisTickLabelColor(), barPlot.getCategoryAxisTickLabelMask(), barPlot.getCategoryAxisVerticalTickLabels(),
				barPlot.getCategoryAxisLineColor(), false,
				(Comparable<?>)evaluateExpression(barPlot.getDomainAxisMinValueExpression()),
				(Comparable<?>)evaluateExpression(barPlot.getDomainAxisMaxValueExpression()));

		// Handle the axis formating for the value axis
		configureAxis(xyPlot.getRangeAxis(), barPlot.getValueAxisLabelFont(),
				barPlot.getValueAxisLabelColor(), barPlot.getValueAxisTickLabelFont(),
				barPlot.getValueAxisTickLabelColor(), barPlot.getValueAxisTickLabelMask(), barPlot.getValueAxisVerticalTickLabels(),
				barPlot.getValueAxisLineColor(), true,
				(Comparable<?>)evaluateExpression(barPlot.getRangeAxisMinValueExpression()),
				(Comparable<?>)evaluateExpression(barPlot.getRangeAxisMaxValueExpression()));

		return jfreeChart;
	}
 
Example 20
Source File: LiquidityChartBuilder.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @param forecast
 * @param settings (next days)
 * @return
 */
public JFreeChart createBarChart(final LiquidityForecast forecast, final LiquidityForecastSettings settings)
{
  Validate.isTrue(settings.getNextDays() > 0 && settings.getNextDays() < 500);
  final LiquidityForecastCashFlow cashFlow = new LiquidityForecastCashFlow(forecast, settings.getNextDays());
  final TimeSeries accumulatedSeriesExpected = new TimeSeries(I18n.getString("plugins.liquidityplanning.forecast.expected"));
  final TimeSeries creditSeries = new TimeSeries(I18n.getString("plugins.liquidityplanning.common.credit"));
  final TimeSeries debitSeries = new TimeSeries(I18n.getString("plugins.liquidityplanning.common.debit"));
  double accumulatedExpected = settings.getStartAmount().doubleValue();

  final DayHolder dh = new DayHolder();
  final Date lower = dh.getDate();
  for (int i = 0; i < settings.getNextDays(); i++) {
    final Day day = new Day(dh.getDayOfMonth(), dh.getMonth() + 1, dh.getYear());
    if (i > 0) {
      accumulatedExpected += cashFlow.getDebitsExpected()[i - 1].doubleValue() + cashFlow.getCreditsExpected()[i - 1].doubleValue();
    }
    accumulatedSeriesExpected.add(day, accumulatedExpected);
    creditSeries.add(day, cashFlow.getCreditsExpected()[i].doubleValue());
    debitSeries.add(day, cashFlow.getDebitsExpected()[i].doubleValue());
    dh.add(Calendar.DATE, 1);
  }
  dh.add(Calendar.DATE, -1);
  final XYChartBuilder cb = new XYChartBuilder(ChartFactory.createXYBarChart(null, null, false, null, null, PlotOrientation.VERTICAL,
      false, false, false));
  int counter = 0;

  final TimeSeriesCollection xyDataSeries = new TimeSeriesCollection();
  xyDataSeries.addSeries(accumulatedSeriesExpected);
  final XYLineAndShapeRenderer lineRenderer = new XYLineAndShapeRenderer(true, true);
  lineRenderer.setSeriesPaint(0, cb.getRedMarker());
  lineRenderer.setSeriesVisibleInLegend(0, true);
  cb.setRenderer(counter, lineRenderer).setDataset(counter++, xyDataSeries)
  .setStrongStyle(lineRenderer, false, accumulatedSeriesExpected);

  final TimeSeriesCollection cashflowSet = new TimeSeriesCollection();
  cashflowSet.addSeries(debitSeries);
  cashflowSet.addSeries(creditSeries);
  final XYBarRenderer barRenderer = new XYBarRenderer(.2);
  barRenderer.setSeriesPaint(0, cb.getGreenFill());
  barRenderer.setSeriesPaint(1, cb.getRedFill());
  barRenderer.setShadowVisible(false);
  cb.setRenderer(counter, barRenderer).setDataset(counter++, cashflowSet);

  cb.setDateXAxis(true).setDateXAxisRange(lower, dh.getDate()).setYAxis(true, null);
  return cb.getChart();
}