Java Code Examples for org.jfree.chart.renderer.xy.CandlestickRenderer#setDrawVolume()

The following examples show how to use org.jfree.chart.renderer.xy.CandlestickRenderer#setDrawVolume() . 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: DefaultChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 *
 */
protected JFreeChart createCandlestickChart() throws JRException
{
	ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
	JFreeChart jfreeChart =
		ChartFactory.createCandlestickChart(
			evaluateTextExpression(getChart().getTitleExpression()),
			evaluateTextExpression(((JRCandlestickPlot)getPlot()).getTimeAxisLabelExpression()),
			evaluateTextExpression(((JRCandlestickPlot)getPlot()).getValueAxisLabelExpression()),
			(DefaultHighLowDataset)getDataset(),
			isShowLegend()
			);

	configureChart(jfreeChart);

	XYPlot xyPlot = (XYPlot) jfreeChart.getPlot();
	JRCandlestickPlot candlestickPlot = (JRCandlestickPlot)getPlot();
	CandlestickRenderer candlestickRenderer = (CandlestickRenderer) xyPlot.getRenderer();
	boolean isShowVolume = candlestickPlot.getShowVolume() == null ? true : candlestickPlot.getShowVolume();
	candlestickRenderer.setDrawVolume(isShowVolume);

	// Handle the axis formating for the category axis
	configureAxis(xyPlot.getDomainAxis(), candlestickPlot.getTimeAxisLabelFont(),
			candlestickPlot.getTimeAxisLabelColor(), candlestickPlot.getTimeAxisTickLabelFont(),
			candlestickPlot.getTimeAxisTickLabelColor(), candlestickPlot.getTimeAxisTickLabelMask(), candlestickPlot.getTimeAxisVerticalTickLabels(),
			candlestickPlot.getTimeAxisLineColor(), false,
			(Comparable<?>)evaluateExpression(candlestickPlot.getDomainAxisMinValueExpression()),
			(Comparable<?>)evaluateExpression(candlestickPlot.getDomainAxisMaxValueExpression()));

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

	return jfreeChart;
}
 
Example 2
Source File: GenericChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 *
 */
protected JFreeChart createCandlestickChart() throws JRException
{
	ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
	JFreeChart jfreeChart =
		ChartFactory.createCandlestickChart(
			evaluateTextExpression(getChart().getTitleExpression()),
			evaluateTextExpression(((JRCandlestickPlot)getPlot()).getTimeAxisLabelExpression()),
			evaluateTextExpression(((JRCandlestickPlot)getPlot()).getValueAxisLabelExpression()),
			(DefaultHighLowDataset)getDataset(),
			isShowLegend()
			);

	configureChart(jfreeChart, getPlot());

	XYPlot xyPlot = (XYPlot) jfreeChart.getPlot();
	JRCandlestickPlot candlestickPlot = (JRCandlestickPlot)getPlot();
	CandlestickRenderer candlestickRenderer = (CandlestickRenderer) xyPlot.getRenderer();
	boolean isShowVolume = candlestickPlot.getShowVolume() == null ? true : candlestickPlot.getShowVolume();
	candlestickRenderer.setDrawVolume(isShowVolume);

	// Handle the axis formating for the category axis
	configureAxis(xyPlot.getDomainAxis(), candlestickPlot.getTimeAxisLabelFont(),
			candlestickPlot.getTimeAxisLabelColor(), candlestickPlot.getTimeAxisTickLabelFont(),
			candlestickPlot.getTimeAxisTickLabelColor(), candlestickPlot.getTimeAxisTickLabelMask(), candlestickPlot.getTimeAxisVerticalTickLabels(),
			candlestickPlot.getOwnTimeAxisLineColor(), false,
			(Comparable<?>)evaluateExpression(candlestickPlot.getDomainAxisMinValueExpression()),
			(Comparable<?>)evaluateExpression(candlestickPlot.getDomainAxisMaxValueExpression()));

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

	return jfreeChart;
}
 
Example 3
Source File: SimpleChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 *
 */
protected JFreeChart createCandlestickChart() throws JRException
{
	ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
	JFreeChart jfreeChart =
		ChartFactory.createCandlestickChart(
			evaluateTextExpression(getChart().getTitleExpression()),
			evaluateTextExpression(((JRCandlestickPlot)getPlot()).getTimeAxisLabelExpression()),
			evaluateTextExpression(((JRCandlestickPlot)getPlot()).getValueAxisLabelExpression()),
			(DefaultHighLowDataset)getDataset(),
			isShowLegend()
			);

	configureChart(jfreeChart, getPlot());

	XYPlot xyPlot = (XYPlot) jfreeChart.getPlot();
	JRCandlestickPlot candlestickPlot = (JRCandlestickPlot)getPlot();
	CandlestickRenderer candlestickRenderer = (CandlestickRenderer) xyPlot.getRenderer();
	boolean isShowVolume = candlestickPlot.getShowVolume() == null ? true : candlestickPlot.getShowVolume();
	candlestickRenderer.setDrawVolume(isShowVolume);

	// Handle the axis formating for the category axis
	configureAxis(xyPlot.getDomainAxis(), candlestickPlot.getTimeAxisLabelFont(),
			candlestickPlot.getTimeAxisLabelColor(), candlestickPlot.getTimeAxisTickLabelFont(),
			candlestickPlot.getTimeAxisTickLabelColor(), candlestickPlot.getTimeAxisTickLabelMask(), candlestickPlot.getTimeAxisVerticalTickLabels(),
			candlestickPlot.getOwnTimeAxisLineColor(), getDomainAxisSettings(),
			(Comparable<?>)evaluateExpression(candlestickPlot.getDomainAxisMinValueExpression()), 
			(Comparable<?>)evaluateExpression(candlestickPlot.getDomainAxisMaxValueExpression())
			);


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

	return jfreeChart;
}
 
Example 4
Source File: CandlestickRendererTests.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Check that the equals() method distinguishes all fields.
 */
public void testEquals() {
    CandlestickRenderer r1 = new CandlestickRenderer();
    CandlestickRenderer r2 = new CandlestickRenderer();
    assertEquals(r1, r2);

    // upPaint
    r1.setUpPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f,
            Color.white));
    assertFalse(r1.equals(r2));
    r2.setUpPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f,
            Color.white));
    assertTrue(r1.equals(r2));

    // downPaint
    r1.setDownPaint(new GradientPaint(5.0f, 6.0f, Color.green, 7.0f, 8.0f,
            Color.yellow));
    assertFalse(r1.equals(r2));
    r2.setDownPaint(new GradientPaint(5.0f, 6.0f, Color.green, 7.0f, 8.0f,
            Color.yellow));
    assertTrue(r1.equals(r2));

    // drawVolume
    r1.setDrawVolume(false);
    assertFalse(r1.equals(r2));
    r2.setDrawVolume(false);
    assertTrue(r1.equals(r2));

    // candleWidth
    r1.setCandleWidth(3.3);
    assertFalse(r1.equals(r2));
    r2.setCandleWidth(3.3);
    assertTrue(r1.equals(r2));

    // maxCandleWidthInMilliseconds
    r1.setMaxCandleWidthInMilliseconds(123);
    assertFalse(r1.equals(r2));
    r2.setMaxCandleWidthInMilliseconds(123);
    assertTrue(r1.equals(r2));

    // autoWidthMethod
    r1.setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_SMALLEST);
    assertFalse(r1.equals(r2));
    r2.setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_SMALLEST);
    assertTrue(r1.equals(r2));

    // autoWidthFactor
    r1.setAutoWidthFactor(0.22);
    assertFalse(r1.equals(r2));
    r2.setAutoWidthFactor(0.22);
    assertTrue(r1.equals(r2));

    // autoWidthGap
    r1.setAutoWidthGap(1.1);
    assertFalse(r1.equals(r2));
    r2.setAutoWidthGap(1.1);
    assertTrue(r1.equals(r2));

    r1.setUseOutlinePaint(true);
    assertFalse(r1.equals(r2));
    r2.setUseOutlinePaint(true);
    assertTrue(r1.equals(r2));

    r1.setVolumePaint(Color.blue);
    assertFalse(r1.equals(r2));
    r2.setVolumePaint(Color.blue);
    assertTrue(r1.equals(r2));
}
 
Example 5
Source File: CandlestickRendererTests.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Check that the equals() method distinguishes all fields.
 */
public void testEquals() {
    CandlestickRenderer r1 = new CandlestickRenderer();
    CandlestickRenderer r2 = new CandlestickRenderer();
    assertEquals(r1, r2);
    
    // upPaint
    r1.setUpPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, 
            Color.white));
    assertFalse(r1.equals(r2));
    r2.setUpPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, 
            Color.white));
    assertTrue(r1.equals(r2));
    
    // downPaint
    r1.setDownPaint(new GradientPaint(5.0f, 6.0f, Color.green, 7.0f, 8.0f, 
            Color.yellow));
    assertFalse(r1.equals(r2));
    r2.setDownPaint(new GradientPaint(5.0f, 6.0f, Color.green, 7.0f, 8.0f, 
            Color.yellow));
    assertTrue(r1.equals(r2));
    
    // drawVolume
    r1.setDrawVolume(false);
    assertFalse(r1.equals(r2));
    r2.setDrawVolume(false);
    assertTrue(r1.equals(r2));
    
    // candleWidth
    r1.setCandleWidth(3.3);
    assertFalse(r1.equals(r2));
    r2.setCandleWidth(3.3);
    assertTrue(r1.equals(r2));
    
    // maxCandleWidthInMilliseconds
    r1.setMaxCandleWidthInMilliseconds(123);
    assertFalse(r1.equals(r2));
    r2.setMaxCandleWidthInMilliseconds(123);
    assertTrue(r1.equals(r2));
    
    // autoWidthMethod
    r1.setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_SMALLEST);
    assertFalse(r1.equals(r2));
    r2.setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_SMALLEST);
    assertTrue(r1.equals(r2));
    
    // autoWidthFactor
    r1.setAutoWidthFactor(0.22);
    assertFalse(r1.equals(r2));
    r2.setAutoWidthFactor(0.22);
    assertTrue(r1.equals(r2));
    
    // autoWidthGap
    r1.setAutoWidthGap(1.1);
    assertFalse(r1.equals(r2));
    r2.setAutoWidthGap(1.1);
    assertTrue(r1.equals(r2));
    
    r1.setUseOutlinePaint(true);
    assertFalse(r1.equals(r2));
    r2.setUseOutlinePaint(true);
    assertTrue(r1.equals(r2));
    
    r1.setVolumePaint(Color.blue);
    assertFalse(r1.equals(r2));
    r2.setVolumePaint(Color.blue);
    assertTrue(r1.equals(r2));
}