Java 类org.jfree.data.time.ohlc.OHLCSeriesCollection 实例源码

项目:parabuild-ci    文件:OHLCSeriesCollectionTests.java   
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {
    OHLCSeriesCollection c1 = new OHLCSeriesCollection();
    OHLCSeriesCollection c2 = new OHLCSeriesCollection();
    assertEquals(c1, c2);

    // add a series
    OHLCSeries s1 = new OHLCSeries("Series");
    s1.add(new Year(2006), 1.0, 1.1, 1.2, 1.3);
    c1.addSeries(s1);
    assertFalse(c1.equals(c2));
    OHLCSeries s2 = new OHLCSeries("Series");
    s2.add(new Year(2006), 1.0, 1.1, 1.2, 1.3);
    c2.addSeries(s2);
    assertTrue(c1.equals(c2));

    // add an empty series
    c1.addSeries(new OHLCSeries("Empty Series"));
    assertFalse(c1.equals(c2));
    c2.addSeries(new OHLCSeries("Empty Series"));
    assertTrue(c1.equals(c2));
}
项目: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;
}
项目:nabs    文件:OHLCSeriesCollectionTests.java   
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {
    OHLCSeriesCollection c1 = new OHLCSeriesCollection();
    OHLCSeriesCollection c2 = new OHLCSeriesCollection();
    assertEquals(c1, c2);

    // add a series
    OHLCSeries s1 = new OHLCSeries("Series");
    s1.add(new Year(2006), 1.0, 1.1, 1.2, 1.3);
    c1.addSeries(s1);
    assertFalse(c1.equals(c2));
    OHLCSeries s2 = new OHLCSeries("Series");
    s2.add(new Year(2006), 1.0, 1.1, 1.2, 1.3);
    c2.addSeries(s2);
    assertTrue(c1.equals(c2));

    // add an empty series
    c1.addSeries(new OHLCSeries("Empty Series"));
    assertFalse(c1.equals(c2));
    c2.addSeries(new OHLCSeries("Empty Series"));
    assertTrue(c1.equals(c2));
}
项目:astor    文件:OHLCSeriesCollectionTests.java   
/**
 * Some checks for the {@link OHLCSeriesCollection#removeSeries(int)}
 * method.
 */
public void testRemoveSeries_int() {
    OHLCSeriesCollection c1 = new OHLCSeriesCollection();
    OHLCSeries s1 = new OHLCSeries("Series 1");
    OHLCSeries s2 = new OHLCSeries("Series 2");
    OHLCSeries s3 = new OHLCSeries("Series 3");
    OHLCSeries s4 = new OHLCSeries("Series 4");
    c1.addSeries(s1);
    c1.addSeries(s2);
    c1.addSeries(s3);
    c1.addSeries(s4);
    c1.removeSeries(2);
    assertTrue(c1.getSeries(2).equals(s4));
    c1.removeSeries(0);
    assertTrue(c1.getSeries(0).equals(s2));
    assertEquals(2, c1.getSeriesCount());
}
项目:astor    文件:OHLCSeriesCollectionTests.java   
/**
 * Some checks for the
 * {@link OHLCSeriesCollection#removeSeries(OHLCSeries)} method.
 */
public void testRemoveSeries() {
    OHLCSeriesCollection c1 = new OHLCSeriesCollection();
    OHLCSeries s1 = new OHLCSeries("Series 1");
    OHLCSeries s2 = new OHLCSeries("Series 2");
    OHLCSeries s3 = new OHLCSeries("Series 3");
    OHLCSeries s4 = new OHLCSeries("Series 4");
    c1.addSeries(s1);
    c1.addSeries(s2);
    c1.addSeries(s3);
    c1.addSeries(s4);
    c1.removeSeries(s3);
    assertTrue(c1.getSeries(2).equals(s4));
    c1.removeSeries(s1);
    assertTrue(c1.getSeries(0).equals(s2));
    assertEquals(2, c1.getSeriesCount());
}
项目:astor    文件:OHLCSeriesCollectionTests.java   
/**
 * A simple check for the removeAllSeries() method.
 */
public void testRemoveAllSeries() {
    OHLCSeriesCollection c1 = new OHLCSeriesCollection();
    c1.addChangeListener(this);

    // there should be no change event when clearing an empty series
    this.lastEvent = null;
    c1.removeAllSeries();
    assertNull(this.lastEvent);

    OHLCSeries s1 = new OHLCSeries("Series 1");
    OHLCSeries s2 = new OHLCSeries("Series 2");
    c1.addSeries(s1);
    c1.addSeries(s2);
    c1.removeAllSeries();
    assertEquals(0, c1.getSeriesCount());
    assertNotNull(this.lastEvent);
    this.lastEvent = null;  // clean up
}
项目:OTCAnalyser    文件:OHLCMaker.java   
public static OHLCSeriesCollection makeDataset(List<Trade> trade, String name, boolean sorted) {
  if (!sorted) { //not sorted by execution timestamps
    DateSorter.sortByExecutionTimestamp(trade);
  }
  OHLCSeriesCollection dataset = new OHLCSeriesCollection();
  dataset.addSeries(makeSeries(trade, name));
  return dataset;
}
项目:OTCAnalyser    文件:OHLCMaker.java   
public static boolean updateSeries(OHLCSeriesCollection dataset, int series, List<Trade> trade) {
  OHLCSeries ohlcs = dataset.getSeries(series);
  try {
    addToSeries(ohlcs, trade);
  } catch(SeriesException e) {
    // overlap with dates
    return false;
  }
  return true;
}
项目:astor    文件:OHLCSeriesCollectionTests.java   
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {
    OHLCSeriesCollection c1 = new OHLCSeriesCollection();
    OHLCSeriesCollection c2 = new OHLCSeriesCollection();
    assertEquals(c1, c2);

    // add a series
    OHLCSeries s1 = new OHLCSeries("Series");
    s1.add(new Year(2006), 1.0, 1.1, 1.2, 1.3);
    c1.addSeries(s1);
    assertFalse(c1.equals(c2));
    OHLCSeries s2 = new OHLCSeries("Series");
    s2.add(new Year(2006), 1.0, 1.1, 1.2, 1.3);
    c2.addSeries(s2);
    assertTrue(c1.equals(c2));

    // add an empty series
    c1.addSeries(new OHLCSeries("Empty Series"));
    assertFalse(c1.equals(c2));
    c2.addSeries(new OHLCSeries("Empty Series"));
    assertTrue(c1.equals(c2));

    c1.setXPosition(TimePeriodAnchor.END);
    assertFalse(c1.equals(c2));
    c2.setXPosition(TimePeriodAnchor.END);
    assertTrue(c1.equals(c2));

}
项目:astor    文件:OHLCSeriesCollectionTests.java   
/**
 * Two objects that are equal are required to return the same hashCode.
 */
public void testHashcode() {
    OHLCSeriesCollection c1 = new OHLCSeriesCollection();
    OHLCSeries s1 = new OHLCSeries("S");
    s1.add(new Year(2009), 1.0, 4.0, 0.5, 2.0);
    c1.addSeries(s1);
    OHLCSeriesCollection c2 = new OHLCSeriesCollection();
    OHLCSeries s2 = new OHLCSeries("S");
    s2.add(new Year(2009), 1.0, 4.0, 0.5, 2.0);
    c2.addSeries(s2);
    assertTrue(c1.equals(c2));
    int h1 = c1.hashCode();
    int h2 = c2.hashCode();
    assertEquals(h1, h2);
}