Java 类org.jfree.chart.renderer.xy.CandlestickRenderer 实例源码

项目:parabuild-ci    文件:ChartFactory.java   
/**
 * Creates and returns a default instance of a candlesticks chart.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param timeAxisLabel  a label for the time axis (<code>null</code> permitted).
 * @param valueAxisLabel  a label for the value axis (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 *
 * @return a candlestick chart.
 */
public static JFreeChart createCandlestickChart(String title,
                                                String timeAxisLabel,
                                                String valueAxisLabel,
                                                OHLCDataset dataset,
                                                boolean legend) {

    ValueAxis timeAxis = new DateAxis(timeAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);
    plot.setRenderer(new CandlestickRenderer());
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);

    return chart;

}
项目:parabuild-ci    文件:ChartFactory.java   
/**
 * Creates and returns a default instance of a candlesticks chart.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param timeAxisLabel  a label for the time axis (<code>null</code> 
 *                       permitted).
 * @param valueAxisLabel  a label for the value axis (<code>null</code> 
 *                        permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 *
 * @return A candlestick chart.
 */
public static JFreeChart createCandlestickChart(String title,
                                                String timeAxisLabel,
                                                String valueAxisLabel,
                                                OHLCDataset dataset,
                                                boolean legend) {

    ValueAxis timeAxis = new DateAxis(timeAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);
    plot.setRenderer(new CandlestickRenderer());
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    return chart;

}
项目:jasperreports    文件:EyeCandySixtiesChartTheme.java   
@Override
protected JFreeChart createCandlestickChart() throws JRException
{
    JFreeChart jfreeChart = super.createCandlestickChart();
    XYPlot xyPlot = (XYPlot) jfreeChart.getPlot();
    CandlestickRenderer renderer = (CandlestickRenderer)xyPlot.getRenderer();
    DefaultHighLowDataset dataset = (DefaultHighLowDataset)xyPlot.getDataset();
    if (dataset != null)
    {
        for (int i = 0; i < dataset.getSeriesCount(); i++)
        {
            renderer.setSeriesFillPaint(i, ChartThemesConstants.EYE_CANDY_SIXTIES_COLORS.get(i));
            renderer.setSeriesPaint(i, Color.DARK_GRAY);
        }
    }
    return jfreeChart;
}
项目:jasperreports    文件:AegeanChartTheme.java   
@Override
protected JFreeChart createCandlestickChart() throws JRException
{
    JFreeChart jfreeChart = super.createCandlestickChart();
    XYPlot xyPlot = (XYPlot) jfreeChart.getPlot();
    CandlestickRenderer renderer = (CandlestickRenderer)xyPlot.getRenderer();
    DefaultHighLowDataset dataset = (DefaultHighLowDataset)xyPlot.getDataset();
    @SuppressWarnings("unchecked")
    List<Paint> seriesPaints = (List<Paint>)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.SERIES_COLORS);

    for(int i = 0; i < dataset.getSeriesCount(); i++)
    {

        renderer.setSeriesFillPaint(i, seriesPaints.get(i));
        renderer.setSeriesPaint(i, Color.DARK_GRAY);
    }
    return jfreeChart;
}
项目:genotick    文件:GenoJFreeChart.java   
private JFreeChart createChartObject(String title, TimeChartDefinition definition) {
    boolean legend = true;
    OHLCSeriesCollection ohlcSeriesCollection = new OHLCSeriesCollection();
    TimeSeriesCollection timeSeriesCollection = new TimeSeriesCollection();
    definition.ohlcSeries.forEach((seriesTitle, series) -> ohlcSeriesCollection.addSeries(series));
    definition.timeSeries.forEach((seriesTitle, series) -> timeSeriesCollection.addSeries(series));
    JFreeChart chartObject = ChartFactory.createCandlestickChart(
            title, "time", "price", ohlcSeriesCollection, legend);
    XYPlot xyPlot = chartObject.getXYPlot();
    NumberAxis numberAxis = (NumberAxis)xyPlot.getRangeAxis();
    DateAxis dateAxis = (DateAxis)xyPlot.getDomainAxis();
    dateAxis.setDateFormatOverride(new SimpleDateFormat("dd-LLL-yy hh:mm", Locale.ENGLISH));
    CandlestickRenderer renderer = (CandlestickRenderer)xyPlot.getRenderer();
    renderer.setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_SMALLEST);
    for (int i = 0, size = definition.ohlcSeries.size(); i < size; ++i) {
        renderer.setSeriesPaint(i, Color.decode("#222222"));
    }
    numberAxis.setAutoRangeIncludesZero(false);
    addDatasetToPlot(xyPlot, timeSeriesCollection);
    return chartObject;
}
项目:HTML5_WebSite    文件:ChartFactory.java   
/**
 * Creates and returns a default instance of a candlesticks chart.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param timeAxisLabel  a label for the time axis (<code>null</code>
 *                       permitted).
 * @param valueAxisLabel  a label for the value axis (<code>null</code>
 *                        permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 *
 * @return A candlestick chart.
 */
public static JFreeChart createCandlestickChart(String title,
                                                String timeAxisLabel,
                                                String valueAxisLabel,
                                                OHLCDataset dataset,
                                                boolean legend) {

    ValueAxis timeAxis = new DateAxis(timeAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);
    plot.setRenderer(new CandlestickRenderer());
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
项目:PI    文件:ChartFactory.java   
/**
 * Creates and returns a default instance of a candlesticks chart.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param timeAxisLabel  a label for the time axis (<code>null</code>
 *                       permitted).
 * @param valueAxisLabel  a label for the value axis (<code>null</code>
 *                        permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 *
 * @return A candlestick chart.
 */
public static JFreeChart createCandlestickChart(String title,
                                                String timeAxisLabel,
                                                String valueAxisLabel,
                                                OHLCDataset dataset,
                                                boolean legend) {

    ValueAxis timeAxis = new DateAxis(timeAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);
    plot.setRenderer(new CandlestickRenderer());
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
项目:nabs    文件:ChartFactory.java   
/**
 * Creates and returns a default instance of a candlesticks chart.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param timeAxisLabel  a label for the time axis (<code>null</code> 
 *                       permitted).
 * @param valueAxisLabel  a label for the value axis (<code>null</code> 
 *                        permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 *
 * @return A candlestick chart.
 */
public static JFreeChart createCandlestickChart(String title,
                                                String timeAxisLabel,
                                                String valueAxisLabel,
                                                OHLCDataset dataset,
                                                boolean legend) {

    ValueAxis timeAxis = new DateAxis(timeAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);
    plot.setRenderer(new CandlestickRenderer());
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    return chart;

}
项目:opensim-gui    文件:ChartFactory.java   
/**
 * Creates and returns a default instance of a candlesticks chart.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param timeAxisLabel  a label for the time axis (<code>null</code> 
 *                       permitted).
 * @param valueAxisLabel  a label for the value axis (<code>null</code> 
 *                        permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 *
 * @return A candlestick chart.
 */
public static JFreeChart createCandlestickChart(String title,
                                                String timeAxisLabel,
                                                String valueAxisLabel,
                                                OHLCDataset dataset,
                                                boolean legend) {

    ValueAxis timeAxis = new DateAxis(timeAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);
    plot.setRenderer(new CandlestickRenderer());
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    return chart;

}
项目:open-java-trade-manager    文件:ChartJDialog.java   
private JFreeChart createCandlestickChart(OHLCDataset priceOHLCDataset) {
    final String title = "Chart";

    final ValueAxis timeAxis = new DateAxis("Date");
    final NumberAxis valueAxis = new NumberAxis("Price");
    valueAxis.setAutoRangeIncludesZero(false);
    valueAxis.setUpperMargin(0.0);
    valueAxis.setLowerMargin(0.0);
    XYPlot plot = new XYPlot(priceOHLCDataset, timeAxis, valueAxis, null);

    final CandlestickRenderer candlestickRenderer = new CandlestickRenderer();
    plot.setRenderer(candlestickRenderer);
    //plot.getRangeAxis().setAutoRange(true);


    // Give good width when zoom in, but too slow in calculation.
    ((CandlestickRenderer)plot.getRenderer()).setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_SMALLEST);

    CombinedDomainXYPlot cplot = new CombinedDomainXYPlot(timeAxis);
    cplot.add(plot, 3);
    cplot.setGap(8.0);

    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, cplot, true);

    applyChartTheme(chart);

    // Handle zooming event.
    chart.addChangeListener(this.getChartChangeListner());

    return chart;        
}
项目:parabuild-ci    文件:CandlestickRendererTests.java   
/**
 * Two objects that are equal are required to return the same hashCode. 
 */
public void testHashcode() {
    CandlestickRenderer r1 = new CandlestickRenderer();
    CandlestickRenderer r2 = new CandlestickRenderer();
    assertTrue(r1.equals(r2));
    int h1 = r1.hashCode();
    int h2 = r2.hashCode();
    assertEquals(h1, h2);
}
项目:parabuild-ci    文件:CandlestickRendererTests.java   
/**
 * Two objects that are equal are required to return the same hashCode. 
 */
public void testHashcode() {
    CandlestickRenderer r1 = new CandlestickRenderer();
    CandlestickRenderer r2 = new CandlestickRenderer();
    assertTrue(r1.equals(r2));
    int h1 = r1.hashCode();
    int h2 = r2.hashCode();
    assertEquals(h1, h2);
}
项目:ccu-historian    文件:ChartFactory.java   
/**
 * Creates and returns a default instance of a candlesticks chart.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param timeAxisLabel  a label for the time axis (<code>null</code>
 *                       permitted).
 * @param valueAxisLabel  a label for the value axis (<code>null</code>
 *                        permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 *
 * @return A candlestick chart.
 */
public static JFreeChart createCandlestickChart(String title,
        String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset,
        boolean legend) {

    ValueAxis timeAxis = new DateAxis(timeAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);
    plot.setRenderer(new CandlestickRenderer());
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
项目:jfreechart    文件:ChartFactory.java   
/**
 * Creates and returns a default instance of a candlesticks chart.
 *
 * @param title  the chart title ({@code null} permitted).
 * @param timeAxisLabel  a label for the time axis ({@code null}
 *                       permitted).
 * @param valueAxisLabel  a label for the value axis ({@code null}
 *                        permitted).
 * @param dataset  the dataset for the chart ({@code null} permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 *
 * @return A candlestick chart.
 */
public static JFreeChart createCandlestickChart(String title,
        String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset,
        boolean legend) {

    ValueAxis timeAxis = new DateAxis(timeAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);
    plot.setRenderer(new CandlestickRenderer());
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
项目:jasperreports    文件:GenericChartTheme.java   
/**
 *
 * @param evaluation
 * @throws net.sf.jasperreports.engine.JRException
 */
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().booleanValue();
    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;
}
项目:jasperreports    文件:DefaultChartTheme.java   
/**
 *
 */
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().booleanValue();
    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;
}
项目:aya-lang    文件:ChartFactory.java   
/**
 * Creates and returns a default instance of a candlesticks chart.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param timeAxisLabel  a label for the time axis (<code>null</code>
 *                       permitted).
 * @param valueAxisLabel  a label for the value axis (<code>null</code>
 *                        permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 *
 * @return A candlestick chart.
 */
public static JFreeChart createCandlestickChart(String title,
        String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset,
        boolean legend) {

    ValueAxis timeAxis = new DateAxis(timeAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);
    plot.setRenderer(new CandlestickRenderer());
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
项目:populus    文件:ChartFactory.java   
/**
 * Creates and returns a default instance of a candlesticks chart.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param timeAxisLabel  a label for the time axis (<code>null</code>
 *                       permitted).
 * @param valueAxisLabel  a label for the value axis (<code>null</code>
 *                        permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 *
 * @return A candlestick chart.
 */
public static JFreeChart createCandlestickChart(String title,
        String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset,
        boolean legend) {

    ValueAxis timeAxis = new DateAxis(timeAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);
    plot.setRenderer(new CandlestickRenderer());
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
项目:OTCAnalyser    文件:OHLCMaker.java   
public static JFreeChart makeChart(String name, OHLCDataset dataset) {
  JFreeChart chart = ChartFactory.createCandlestickChart(name, "Execution Date", "Price",
      dataset, false);

  //appearance tweaks
  XYPlot plot = (XYPlot) chart.getPlot();
  CandlestickRenderer csr = (CandlestickRenderer) plot.getRenderer();
  csr.setUseOutlinePaint(true);
  //set up paint to white and down paint to dark gray
  csr.setUpPaint(Color.WHITE); //for when close > open
  csr.setDownPaint(Color.DARK_GRAY); //for when open > close

  //date formatting
  DateAxis axis = (DateAxis) plot.getDomainAxis();
  Calendar max = Calendar.getInstance();
  Calendar min = Calendar.getInstance();
  max.setTime(axis.getMaximumDate());
  min.setTime(axis.getMinimumDate());
  if (max.get(Calendar.MONTH) > min.get(Calendar.MONTH) ||
      max.get(Calendar.YEAR) > max.get(Calendar.YEAR)){
    axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
  } else {
    axis.setDateFormatOverride(new SimpleDateFormat("dd-MMM-yyyy"));
  }

  return chart;
}
项目:nabs    文件:CandlestickRendererTests.java   
/**
 * Two objects that are equal are required to return the same hashCode. 
 */
public void testHashcode() {
    CandlestickRenderer r1 = new CandlestickRenderer();
    CandlestickRenderer r2 = new CandlestickRenderer();
    assertTrue(r1.equals(r2));
    int h1 = r1.hashCode();
    int h2 = r2.hashCode();
    assertEquals(h1, h2);
}
项目:ECG-Viewer    文件:ChartFactory.java   
/**
 * Creates and returns a default instance of a candlesticks chart.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param timeAxisLabel  a label for the time axis (<code>null</code>
 *                       permitted).
 * @param valueAxisLabel  a label for the value axis (<code>null</code>
 *                        permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 *
 * @return A candlestick chart.
 */
public static JFreeChart createCandlestickChart(String title,
        String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset,
        boolean legend) {

    ValueAxis timeAxis = new DateAxis(timeAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);
    plot.setRenderer(new CandlestickRenderer());
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
项目:astor    文件:CandlestickRendererTests.java   
/**
 * Some checks for the constructor.
 */
public void testConstructor() {
    CandlestickRenderer r1 = new CandlestickRenderer();

    // check defaults
    assertEquals(Color.green, r1.getUpPaint());
    assertEquals(Color.red, r1.getDownPaint());
    assertFalse(r1.getUseOutlinePaint());
    assertTrue(r1.getDrawVolume());
    assertEquals(Color.gray, r1.getVolumePaint());
    assertEquals(-1.0, r1.getCandleWidth(), EPSILON);
}
项目:astor    文件:CandlestickRendererTests.java   
/**
 * Two objects that are equal are required to return the same hashCode.
 */
public void testHashcode() {
    CandlestickRenderer r1 = new CandlestickRenderer();
    CandlestickRenderer r2 = new CandlestickRenderer();
    assertTrue(r1.equals(r2));
    int h1 = r1.hashCode();
    int h2 = r2.hashCode();
    assertEquals(h1, h2);
}
项目:astor    文件:ChartFactory.java   
/**
 * Creates and returns a default instance of a candlesticks chart.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param timeAxisLabel  a label for the time axis (<code>null</code>
 *                       permitted).
 * @param valueAxisLabel  a label for the value axis (<code>null</code>
 *                        permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 *
 * @return A candlestick chart.
 */
public static JFreeChart createCandlestickChart(String title,
        String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset,
        boolean legend) {

    ValueAxis timeAxis = new DateAxis(timeAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);
    plot.setRenderer(new CandlestickRenderer());
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
项目:group-five    文件:ChartFactory.java   
/**
 * Creates and returns a default instance of a candlesticks chart.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param timeAxisLabel  a label for the time axis (<code>null</code>
 *                       permitted).
 * @param valueAxisLabel  a label for the value axis (<code>null</code>
 *                        permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 *
 * @return A candlestick chart.
 */
public static JFreeChart createCandlestickChart(String title,
        String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset,
        boolean legend) {

    ValueAxis timeAxis = new DateAxis(timeAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);
    plot.setRenderer(new CandlestickRenderer());
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
项目:manydesigns.cn    文件:ChartFactory.java   
/**
 * Creates and returns a default instance of a candlesticks chart.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param timeAxisLabel  a label for the time axis (<code>null</code>
 *                       permitted).
 * @param valueAxisLabel  a label for the value axis (<code>null</code>
 *                        permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 *
 * @return A candlestick chart.
 */
public static JFreeChart createCandlestickChart(String title,
        String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset,
        boolean legend) {

    ValueAxis timeAxis = new DateAxis(timeAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);
    plot.setRenderer(new CandlestickRenderer());
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
项目:buffer_bci    文件:ChartFactory.java   
/**
 * Creates and returns a default instance of a candlesticks chart.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param timeAxisLabel  a label for the time axis (<code>null</code>
 *                       permitted).
 * @param valueAxisLabel  a label for the value axis (<code>null</code>
 *                        permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 *
 * @return A candlestick chart.
 */
public static JFreeChart createCandlestickChart(String title,
        String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset,
        boolean legend) {

    ValueAxis timeAxis = new DateAxis(timeAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);
    plot.setRenderer(new CandlestickRenderer());
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
项目:buffer_bci    文件:ChartFactory.java   
/**
 * Creates and returns a default instance of a candlesticks chart.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param timeAxisLabel  a label for the time axis (<code>null</code>
 *                       permitted).
 * @param valueAxisLabel  a label for the value axis (<code>null</code>
 *                        permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 *
 * @return A candlestick chart.
 */
public static JFreeChart createCandlestickChart(String title,
        String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset,
        boolean legend) {

    ValueAxis timeAxis = new DateAxis(timeAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);
    plot.setRenderer(new CandlestickRenderer());
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
项目:proyecto-teoria-control-utn-frro    文件:ChartFactory.java   
/**
 * Creates and returns a default instance of a candlesticks chart.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param timeAxisLabel  a label for the time axis (<code>null</code>
 *                       permitted).
 * @param valueAxisLabel  a label for the value axis (<code>null</code>
 *                        permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 *
 * @return A candlestick chart.
 */
public static JFreeChart createCandlestickChart(String title,
        String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset,
        boolean legend) {

    ValueAxis timeAxis = new DateAxis(timeAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);
    plot.setRenderer(new CandlestickRenderer());
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
项目:dynamicreports-jasper    文件:CandlestickChartTest.java   
@Override
public void test() {
    super.test();

    numberOfPagesTest(1);

    JFreeChart chart = getChart("summary.chart1", 0);
    XYItemRenderer renderer = chart.getXYPlot().getRenderer();
    Assert.assertEquals("renderer", CandlestickRenderer.class, renderer.getClass());
    Assert.assertEquals("show volume", false, ((CandlestickRenderer) renderer).getDrawVolume());
    highLowChartDataTest(chart, 0, new Object[][] {
            {"serie", date1, 50d, 35d, 40d, 47d, 70d}, {"serie", date2, 55d, 40d, 50d, 45d, 120d}, {"serie", date3, 48d, 41d, 42d, 47d, 90d}});

    chart = getChart("summary.chart2", 0);
    Axis axis = chart.getXYPlot().getDomainAxis();
    Assert.assertEquals("category label", "time", axis.getLabel());
    Assert.assertEquals("category label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("category label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
    Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
    Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());
    Assert.assertTrue("vertical tick labels", ((ValueAxis) axis).isVerticalTickLabels());

    chart = getChart("summary.chart3", 0);
    axis = chart.getXYPlot().getRangeAxis();
    Assert.assertEquals("value label", "value", axis.getLabel());
    Assert.assertEquals("value label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("value label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
    Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
    Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
    Assert.assertEquals("tick label mask", "10.00", ((NumberAxis) axis).getNumberFormatOverride().format(10));
    //Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());
    Assert.assertEquals("range min value", 1d, ((ValueAxis) axis).getLowerBound());
    Assert.assertEquals("range max value", 15d, ((ValueAxis) axis).getUpperBound());
    Assert.assertTrue("vertical tick labels", ((ValueAxis) axis).isVerticalTickLabels());
}
项目:Memetic-Algorithm-for-TSP    文件:ChartFactory.java   
/**
 * Creates and returns a default instance of a candlesticks chart.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param timeAxisLabel  a label for the time axis (<code>null</code>
 *                       permitted).
 * @param valueAxisLabel  a label for the value axis (<code>null</code>
 *                        permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 *
 * @return A candlestick chart.
 */
public static JFreeChart createCandlestickChart(String title,
        String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset,
        boolean legend) {

    ValueAxis timeAxis = new DateAxis(timeAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);
    plot.setRenderer(new CandlestickRenderer());
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
项目:ta4j    文件:CandlestickChart.java   
public static void main(String[] args) {
    /**
     * Getting time series
     */
    TimeSeries series = CsvTradesLoader.loadBitstampSeries();

    /**
     * Creating the OHLC dataset
     */
    OHLCDataset ohlcDataset = createOHLCDataset(series);

    /**
     * Creating the additional dataset
     */
    TimeSeriesCollection xyDataset = createAdditionalDataset(series);

    /**
     * Creating the chart
     */
    JFreeChart chart = ChartFactory.createCandlestickChart(
            "Bitstamp BTC price",
            "Time",
            "USD",
            ohlcDataset,
            true);
    // Candlestick rendering
    CandlestickRenderer renderer = new CandlestickRenderer();
    renderer.setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_SMALLEST);
    XYPlot plot = chart.getXYPlot();
    plot.setRenderer(renderer);
    // Additional dataset
    int index = 1;
    plot.setDataset(index, xyDataset);
    plot.mapDatasetToRangeAxis(index, 0);
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(true, false);
    renderer2.setSeriesPaint(index, Color.blue);
    plot.setRenderer(index, renderer2);
    // Misc
    plot.setRangeGridlinePaint(Color.lightGray);
    plot.setBackgroundPaint(Color.white);
    NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis();
    numberAxis.setAutoRangeIncludesZero(false);
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    /**
     * Displaying the chart
     */
    displayChart(chart);
}
项目:parabuild-ci    文件:CandlestickRendererTests.java   
/**
 * Problem that the equals(...) method distinguishes all fields.
 */
public void testEquals() {
    CandlestickRenderer r1 = new CandlestickRenderer();
    CandlestickRenderer r2 = new CandlestickRenderer();
    assertEquals(r1, r2);
}
项目:parabuild-ci    文件:CandlestickRendererTests.java   
/**
 * 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));
}
项目:jasperreports    文件:SimpleChartTheme.java   
/**
 *
 * @param evaluation
 * @throws net.sf.jasperreports.engine.JRException
 */
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().booleanValue();
    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;
}
项目:nabs    文件:CandlestickRendererTests.java   
/**
 * 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));
}
项目:astor    文件:CandlestickRendererTests.java   
/**
 * 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));
}
项目:astor    文件:CandlestickRendererTests.java   
/**
 * Verify that this class implements {@link PublicCloneable}.
 */
public void testPublicCloneable() {
    CandlestickRenderer r1 = new CandlestickRenderer();
    assertTrue(r1 instanceof PublicCloneable);
}
项目:ta4j-origins    文件:CandlestickChart.java   
public static void main(String[] args) {
    /**
     * Getting time series
     */
    TimeSeries series = CsvTradesLoader.loadBitstampSeries();

    /**
     * Creating the OHLC dataset
     */
    OHLCDataset ohlcDataset = createOHLCDataset(series);

    /**
     * Creating the additional dataset
     */
    TimeSeriesCollection xyDataset = createAdditionalDataset(series);

    /**
     * Creating the chart
     */
    JFreeChart chart = ChartFactory.createCandlestickChart(
            "Bitstamp BTC price",
            "Time",
            "USD",
            ohlcDataset,
            true);
    // Candlestick rendering
    CandlestickRenderer renderer = new CandlestickRenderer();
    renderer.setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_SMALLEST);
    XYPlot plot = chart.getXYPlot();
    plot.setRenderer(renderer);
    // Additional dataset
    int index = 1;
    plot.setDataset(index, xyDataset);
    plot.mapDatasetToRangeAxis(index, 0);
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(true, false);
    renderer2.setSeriesPaint(index, Color.blue);
    plot.setRenderer(index, renderer2);
    // Misc
    plot.setRangeGridlinePaint(Color.lightGray);
    plot.setBackgroundPaint(Color.white);
    NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis();
    numberAxis.setAutoRangeIncludesZero(false);
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    /**
     * Displaying the chart
     */
    displayChart(chart);
}