本文整理汇总了Java中org.jfree.data.time.TimeSeries.setMaximumItemAge方法的典型用法代码示例。如果您正苦于以下问题:Java TimeSeries.setMaximumItemAge方法的具体用法?Java TimeSeries.setMaximumItemAge怎么用?Java TimeSeries.setMaximumItemAge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.data.time.TimeSeries
的用法示例。
在下文中一共展示了TimeSeries.setMaximumItemAge方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addData
import org.jfree.data.time.TimeSeries; //导入方法依赖的package包/类
/**
* This method adds the specified stream elements to the timeSeries of the
* appropriate plot.
*
* @param streamElement
*/
public synchronized void addData ( StreamElement streamElement ) {
for ( int i = 0 ; i < streamElement.getFieldNames( ).length ; i++ ) {
TimeSeries timeSeries = dataForTheChart.get( streamElement.getFieldNames( )[ i ] );
if ( timeSeries == null ) {
dataForTheChart.put( streamElement.getFieldNames( )[ i ] , timeSeries = new TimeSeries( streamElement.getFieldNames( )[ i ] , org.jfree.data.time.FixedMillisecond.class ) );
if(isTimeBased){
timeSeries.setMaximumItemAge(historySize);
}else{
timeSeries.setMaximumItemCount(historySize);
}
dataCollectionForTheChart.addSeries( timeSeries );
}
try {
timeSeries.addOrUpdate( new FixedMillisecond( new Date( streamElement.getTimeStamp( ) ) ) , Double.parseDouble( streamElement.getData( )[ i ].toString( ) ) );
} catch ( SeriesException e ) {
logger.warn( e.getMessage( ) , e );
}
}
changed = true;
}
示例2: testEquals
import org.jfree.data.time.TimeSeries; //导入方法依赖的package包/类
/**
* Tests the equals method.
*/
public void testEquals() {
TimeSeries s1 = new TimeSeries("Time Series 1");
TimeSeries s2 = new TimeSeries("Time Series 2");
boolean b1 = s1.equals(s2);
assertFalse("b1", b1);
s2.setKey("Time Series 1");
boolean b2 = s1.equals(s2);
assertTrue("b2", b2);
RegularTimePeriod p1 = new Day();
RegularTimePeriod p2 = p1.next();
s1.add(p1, 100.0);
s1.add(p2, 200.0);
boolean b3 = s1.equals(s2);
assertFalse("b3", b3);
s2.add(p1, 100.0);
s2.add(p2, 200.0);
boolean b4 = s1.equals(s2);
assertTrue("b4", b4);
s1.setMaximumItemCount(100);
boolean b5 = s1.equals(s2);
assertFalse("b5", b5);
s2.setMaximumItemCount(100);
boolean b6 = s1.equals(s2);
assertTrue("b6", b6);
s1.setMaximumItemAge(100);
boolean b7 = s1.equals(s2);
assertFalse("b7", b7);
s2.setMaximumItemAge(100);
boolean b8 = s1.equals(s2);
assertTrue("b8", b8);
}
示例3: testRemoveAgedItems
import org.jfree.data.time.TimeSeries; //导入方法依赖的package包/类
/**
* Some checks for the removeAgedItems() method.
*/
public void testRemoveAgedItems() {
TimeSeries series = new TimeSeries("Test Series", Year.class);
series.addChangeListener(this);
assertEquals(Long.MAX_VALUE, series.getMaximumItemAge());
assertEquals(Integer.MAX_VALUE, series.getMaximumItemCount());
this.gotSeriesChangeEvent = false;
// test empty series
series.removeAgedItems(true);
assertEquals(0, series.getItemCount());
assertFalse(this.gotSeriesChangeEvent);
// test series with one item
series.add(new Year(1999), 1.0);
series.setMaximumItemAge(0);
this.gotSeriesChangeEvent = false;
series.removeAgedItems(true);
assertEquals(1, series.getItemCount());
assertFalse(this.gotSeriesChangeEvent);
// test series with two items
series.setMaximumItemAge(10);
series.add(new Year(2001), 2.0);
this.gotSeriesChangeEvent = false;
series.setMaximumItemAge(2);
assertEquals(2, series.getItemCount());
assertEquals(0, series.getIndex(new Year(1999)));
assertFalse(this.gotSeriesChangeEvent);
series.setMaximumItemAge(1);
assertEquals(1, series.getItemCount());
assertEquals(0, series.getIndex(new Year(2001)));
assertTrue(this.gotSeriesChangeEvent);
}
示例4: testRemoveAgedItems2
import org.jfree.data.time.TimeSeries; //导入方法依赖的package包/类
/**
* Some checks for the removeAgedItems(long, boolean) method.
*/
public void testRemoveAgedItems2() {
long y2006 = 1157087372534L; // milliseconds somewhere in 2006
TimeSeries series = new TimeSeries("Test Series", Year.class);
series.addChangeListener(this);
assertEquals(Long.MAX_VALUE, series.getMaximumItemAge());
assertEquals(Integer.MAX_VALUE, series.getMaximumItemCount());
this.gotSeriesChangeEvent = false;
// test empty series
series.removeAgedItems(y2006, true);
assertEquals(0, series.getItemCount());
assertFalse(this.gotSeriesChangeEvent);
// test a series with 1 item
series.add(new Year(2004), 1.0);
series.setMaximumItemAge(1);
this.gotSeriesChangeEvent = false;
series.removeAgedItems(new Year(2005).getMiddleMillisecond(), true);
assertEquals(1, series.getItemCount());
assertFalse(this.gotSeriesChangeEvent);
series.removeAgedItems(y2006, true);
assertEquals(0, series.getItemCount());
assertTrue(this.gotSeriesChangeEvent);
// test a series with two items
series.setMaximumItemAge(2);
series.add(new Year(2003), 1.0);
series.add(new Year(2005), 2.0);
assertEquals(2, series.getItemCount());
this.gotSeriesChangeEvent = false;
assertEquals(2, series.getItemCount());
series.removeAgedItems(new Year(2005).getMiddleMillisecond(), true);
assertEquals(2, series.getItemCount());
assertFalse(this.gotSeriesChangeEvent);
series.removeAgedItems(y2006, true);
assertEquals(1, series.getItemCount());
assertTrue(this.gotSeriesChangeEvent);
}
示例5: TimeSeriesViewObserver
import org.jfree.data.time.TimeSeries; //导入方法依赖的package包/类
/**
* 构造分时图的全部元素
*/
public TimeSeriesViewObserver() {
timeSeriesPrice = new TimeSeries("分时图", Hour.class);
timeSeriesPrice.add(new Hour(count++, day), StockSubject.OPENING_PRICE);
timeSeriesPrice.setMaximumItemAge(MAXIMUM_ITEM_AGE);
TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
timeseriescollection.addSeries(timeSeriesPrice);
DateAxis dateaxis = new DateAxis("时间");
NumberAxis numberaxis = new NumberAxis("股票价格");
dateaxis.setTickLabelFont(new Font("微软雅黑", 0, 12));
numberaxis.setTickLabelFont(new Font("微软雅黑", 0, 12));
dateaxis.setLabelFont(new Font("微软雅黑", 0, 12));
numberaxis.setLabelFont(new Font("微软雅黑", 0, 12));
XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(true, false);
xylineandshaperenderer.setSeriesPaint(0, Color.red);
xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(1F, 0, 1));
XYPlot xyplot = new XYPlot(timeseriescollection, dateaxis, numberaxis, xylineandshaperenderer);
xyplot.setAxisOffset(new RectangleInsets(0D, 0D, 0D, 0D));
dateaxis.setAutoRange(true);
dateaxis.setLowerMargin(0.0D);
dateaxis.setUpperMargin(0.0D);
dateaxis.setTickLabelsVisible(true);
numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
JFreeChart chart = new JFreeChart("中国铁通股票", new Font("微软雅黑", 1, 12), xyplot, true);
chartPanel = new ChartPanel(chart);
}
示例6: slGraphTimeStateChanged
import org.jfree.data.time.TimeSeries; //导入方法依赖的package包/类
private void slGraphTimeStateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_slGraphTimeStateChanged
{//GEN-HEADEREND:event_slGraphTimeStateChanged
TimeSeries ts;
lblHistTime.setText(String.valueOf(slGraphTime.getValue()) + " min");
if (!slGraphTime.getValueIsAdjusting())
{
Iterator<TimeSeries> it = selPids.values().iterator();
while (it.hasNext())
{
ts = it.next();
ts.setMaximumItemAge(slGraphTime.getValue() * 60);
}
}
}
示例7: testRemoveAgedItems
import org.jfree.data.time.TimeSeries; //导入方法依赖的package包/类
/**
* Some checks for the removeAgedItems() method.
*/
public void testRemoveAgedItems() {
TimeSeries series = new TimeSeries("Test Series");
series.addChangeListener(this);
assertEquals(Long.MAX_VALUE, series.getMaximumItemAge());
assertEquals(Integer.MAX_VALUE, series.getMaximumItemCount());
this.gotSeriesChangeEvent = false;
// test empty series
series.removeAgedItems(true);
assertEquals(0, series.getItemCount());
assertFalse(this.gotSeriesChangeEvent);
// test series with one item
series.add(new Year(1999), 1.0);
series.setMaximumItemAge(0);
this.gotSeriesChangeEvent = false;
series.removeAgedItems(true);
assertEquals(1, series.getItemCount());
assertFalse(this.gotSeriesChangeEvent);
// test series with two items
series.setMaximumItemAge(10);
series.add(new Year(2001), 2.0);
this.gotSeriesChangeEvent = false;
series.setMaximumItemAge(2);
assertEquals(2, series.getItemCount());
assertEquals(0, series.getIndex(new Year(1999)));
assertFalse(this.gotSeriesChangeEvent);
series.setMaximumItemAge(1);
assertEquals(1, series.getItemCount());
assertEquals(0, series.getIndex(new Year(2001)));
assertTrue(this.gotSeriesChangeEvent);
}
示例8: testRemoveAgedItems2
import org.jfree.data.time.TimeSeries; //导入方法依赖的package包/类
/**
* Some checks for the removeAgedItems(long, boolean) method.
*/
public void testRemoveAgedItems2() {
long y2006 = 1157087372534L; // milliseconds somewhere in 2006
TimeSeries series = new TimeSeries("Test Series");
series.addChangeListener(this);
assertEquals(Long.MAX_VALUE, series.getMaximumItemAge());
assertEquals(Integer.MAX_VALUE, series.getMaximumItemCount());
this.gotSeriesChangeEvent = false;
// test empty series
series.removeAgedItems(y2006, true);
assertEquals(0, series.getItemCount());
assertFalse(this.gotSeriesChangeEvent);
// test a series with 1 item
series.add(new Year(2004), 1.0);
series.setMaximumItemAge(1);
this.gotSeriesChangeEvent = false;
series.removeAgedItems(new Year(2005).getMiddleMillisecond(), true);
assertEquals(1, series.getItemCount());
assertFalse(this.gotSeriesChangeEvent);
series.removeAgedItems(y2006, true);
assertEquals(0, series.getItemCount());
assertTrue(this.gotSeriesChangeEvent);
// test a series with two items
series.setMaximumItemAge(2);
series.add(new Year(2003), 1.0);
series.add(new Year(2005), 2.0);
assertEquals(2, series.getItemCount());
this.gotSeriesChangeEvent = false;
assertEquals(2, series.getItemCount());
series.removeAgedItems(new Year(2005).getMiddleMillisecond(), true);
assertEquals(2, series.getItemCount());
assertFalse(this.gotSeriesChangeEvent);
series.removeAgedItems(y2006, true);
assertEquals(1, series.getItemCount());
assertTrue(this.gotSeriesChangeEvent);
}
示例9: testRemoveAgedItems4
import org.jfree.data.time.TimeSeries; //导入方法依赖的package包/类
/**
* Check that the item bounds are determined correctly when there is a
* maximum item count.
*/
public void testRemoveAgedItems4() {
TimeSeries s1 = new TimeSeries("S1");
s1.setMaximumItemAge(2);
s1.add(new Year(2010), 1.1);
s1.add(new Year(2011), 2.2);
s1.add(new Year(2012), 3.3);
s1.add(new Year(2013), 2.5);
assertEquals(3, s1.getItemCount());
assertEquals(2.2, s1.getMinY(), EPSILON);
assertEquals(3.3, s1.getMaxY(), EPSILON);
}
示例10: testRemoveAgedItems5
import org.jfree.data.time.TimeSeries; //导入方法依赖的package包/类
/**
* Check that the item bounds are determined correctly after a call to
* removeAgedItems().
*/
public void testRemoveAgedItems5() {
TimeSeries s1 = new TimeSeries("S1");
s1.setMaximumItemAge(4);
s1.add(new Year(2010), 1.1);
s1.add(new Year(2011), 2.2);
s1.add(new Year(2012), 3.3);
s1.add(new Year(2013), 2.5);
s1.removeAgedItems(new Year(2015).getMiddleMillisecond(), true);
assertEquals(3, s1.getItemCount());
assertEquals(2.2, s1.getMinY(), EPSILON);
assertEquals(3.3, s1.getMaxY(), EPSILON);
}