本文整理汇总了Java中org.jfree.data.general.SeriesException类的典型用法代码示例。如果您正苦于以下问题:Java SeriesException类的具体用法?Java SeriesException怎么用?Java SeriesException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SeriesException类属于org.jfree.data.general包,在下文中一共展示了SeriesException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: editSeriesExchangeData
import org.jfree.data.general.SeriesException; //导入依赖的package包/类
/**
* Edits the data series by exchanging data.
* @param series the series
* @param targetDataSeriesIndex the target data series index
*/
public void editSeriesExchangeData(DataSeries series, int targetDataSeriesIndex) throws NoSuchSeriesException {
if (targetDataSeriesIndex<=(this.getSeriesCount()-1)) {
org.jfree.data.time.TimeSeries exchangeSeries = (org.jfree.data.time.TimeSeries) this.getSeries(targetDataSeriesIndex);
List valuePairs = ((agentgui.ontology.TimeSeries)series).getTimeSeriesValuePairs();
for (int i = 0; i < valuePairs.size(); i++) {
TimeSeriesValuePair valuePair = (TimeSeriesValuePair) valuePairs.get(i);
Simple_Long simpleLong = valuePair.getTimestamp();
Simple_Float simpleFloat = valuePair.getValue();
Long timeStampLong = simpleLong.getLongValue();
Float floatValue = simpleFloat.getFloatValue();
if (timeStampLong!=null) {
try {
exchangeSeries.update(new FixedMillisecond(timeStampLong), floatValue);
} catch (SeriesException se) {
// --- Nothing to do here, just take the next value ---
}
}
}
} else {
throw new NoSuchSeriesException();
}
}
示例2: update
import org.jfree.data.general.SeriesException; //导入依赖的package包/类
/**
* Updates (changes) the value for a time period. Throws a {@link SeriesException} if
* the period does not exist.
*
* @param period the period (<code>null</code> not permitted).
* @param value the value (<code>null</code> permitted).
*/
public void update(RegularTimePeriod period, Number value) {
TimeSeriesDataItem temp = new TimeSeriesDataItem(period, value);
int index = Collections.binarySearch(this.data, temp);
if (index >= 0) {
TimeSeriesDataItem pair = (TimeSeriesDataItem) this.data.get(index);
pair.setValue(value);
fireSeriesChanged();
}
else {
throw new SeriesException(
"TimeSeries.update(TimePeriod, Number): period does not exist."
);
}
}
示例3: addAndOrUpdate
import org.jfree.data.general.SeriesException; //导入依赖的package包/类
/**
* Adds or updates data from one series to another. Returns another series
* containing the values that were overwritten.
*
* @param series the series to merge with this.
*
* @return A series containing the values that were overwritten.
*/
public TimeSeries addAndOrUpdate(TimeSeries series) {
TimeSeries overwritten = new TimeSeries("Overwritten values from: " + getName());
for (int i = 0; i < series.getItemCount(); i++) {
TimeSeriesDataItem pair = series.getDataItem(i);
TimeSeriesDataItem oldPair = addOrUpdate(pair.getPeriod(), pair.getValue());
if (oldPair != null) {
try {
overwritten.add(oldPair);
}
catch (SeriesException e) { // should not get here...
System.err.println(
"TimeSeries.addAndOrUpdate(series): "
+ "unable to add data to overwritten series."
);
}
}
}
return overwritten;
}
示例4: update
import org.jfree.data.general.SeriesException; //导入依赖的package包/类
/**
* Updates (changes) the value for a time period. Throws a
* {@link SeriesException} if the period does not exist.
*
* @param period the period (<code>null</code> not permitted).
* @param value the value (<code>null</code> permitted).
*/
public void update(RegularTimePeriod period, Number value) {
TimeSeriesDataItem temp = new TimeSeriesDataItem(period, value);
int index = Collections.binarySearch(this.data, temp);
if (index >= 0) {
TimeSeriesDataItem pair = (TimeSeriesDataItem) this.data.get(index);
pair.setValue(value);
fireSeriesChanged();
}
else {
throw new SeriesException(
"TimeSeries.update(TimePeriod, Number): period does not exist."
);
}
}
示例5: testAddOrUpdate3
import org.jfree.data.general.SeriesException; //导入依赖的package包/类
/**
* Test that the addOrUpdate() method won't allow multiple time period
* classes.
*/
@Test
public void testAddOrUpdate3() {
TimeSeries s1 = new TimeSeries("S1");
s1.addOrUpdate(new Year(2010), 1.1);
assertEquals(Year.class, s1.getTimePeriodClass());
boolean pass = false;
try {
s1.addOrUpdate(new Month(1, 2009), 0.0);
}
catch (SeriesException e) {
pass = true;
}
assertTrue(pass);
}
示例6: testUpdate
import org.jfree.data.general.SeriesException; //导入依赖的package包/类
/**
* Some checks for the update(Number, Number) method.
*/
@Test
public void testUpdate() {
XYSeries series = new XYSeries("S1");
series.add(new Integer(1), new Integer(2));
assertEquals(new Integer(2), series.getY(0));
series.update(new Integer(1), new Integer(3));
assertEquals(new Integer(3), series.getY(0));
try {
series.update(new Integer(2), new Integer(99));
assertTrue(false);
}
catch (SeriesException e) {
// got the required exception
}
}
示例7: add
import org.jfree.data.general.SeriesException; //导入依赖的package包/类
/**
* This method is the one that implements some different
* aspects to the XYSeries class.
*/
public void add(XYDataItem item, boolean notify)
{
if (checkValidity(item))
{
if (checkDataItem(item))
{
/* Check in discarded dataset. */
if (discardedItems.indexOf(item.getX()) >= 0)
{
throw new SeriesException("X-value already exists.");
}
super.add(item, notify);
}
else
{
/* Check in main dataset. */
if (super.indexOf(item.getX()) >= 0)
throw new SeriesException("X-value already exists.");
discardedItems.add(item);
}
}
}
示例8: update
import org.jfree.data.general.SeriesException; //导入依赖的package包/类
/**
* Updates (changes) the value for a time period. Throws a
* {@link SeriesException} if the period does not exist.
*
* @param period the period (<code>null</code> not permitted).
* @param value the value (<code>null</code> permitted).
*/
public void update(RegularTimePeriod period, Number value) {
TimeSeriesDataItem temp = new TimeSeriesDataItem(period, value);
int index = Collections.binarySearch(this.data, temp);
if (index >= 0) {
TimeSeriesDataItem pair = (TimeSeriesDataItem) this.data.get(index);
pair.setValue(value);
fireSeriesChanged();
}
else {
throw new SeriesException(
"TimeSeries.update(TimePeriod, Number): period does not exist."
);
}
}
示例9: addData
import org.jfree.data.general.SeriesException; //导入依赖的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;
}
示例10: testAddValue
import org.jfree.data.general.SeriesException; //导入依赖的package包/类
/**
* Add a value to series A for 1999. It should be added at index 0.
*/
public void testAddValue() {
final TimePeriodValues tpvs = new TimePeriodValues("Test");
try {
tpvs.add(new Year(1999), new Integer(1));
}
catch (SeriesException e) {
System.err.println("TimePeriodValuesTests.testAddValue: problem adding to series.");
}
final int value = tpvs.getValue(0).intValue();
assertEquals(1, value);
}
示例11: testAddValue
import org.jfree.data.general.SeriesException; //导入依赖的package包/类
/**
* Add a value to series A for 1999. It should be added at index 0.
*/
public void testAddValue() {
try {
this.seriesA.add(new Year(1999), new Integer(1));
}
catch (SeriesException e) {
System.err.println("TimeSeriesTests.testAddValue: problem adding to series.");
}
final int value = this.seriesA.getValue(0).intValue();
assertEquals(1, value);
}
示例12: testAddValue
import org.jfree.data.general.SeriesException; //导入依赖的package包/类
/**
* Add a value to series A for 1999. It should be added at index 0.
*/
public void testAddValue() {
TimePeriodValues tpvs = new TimePeriodValues("Test");
try {
tpvs.add(new Year(1999), new Integer(1));
}
catch (SeriesException e) {
System.err.println("Problem adding to series.");
}
int value = tpvs.getValue(0).intValue();
assertEquals(1, value);
}
示例13: testAddValue
import org.jfree.data.general.SeriesException; //导入依赖的package包/类
/**
* Add a value to series A for 1999. It should be added at index 0.
*/
public void testAddValue() {
try {
this.seriesA.add(new Year(1999), new Integer(1));
}
catch (SeriesException e) {
System.err.println("Problem adding to series.");
}
int value = this.seriesA.getValue(0).intValue();
assertEquals(1, value);
}
示例14: testAdditionOfDuplicatePeriod
import org.jfree.data.general.SeriesException; //导入依赖的package包/类
/**
* If you add a duplicate period, an exception should be thrown.
*/
public void testAdditionOfDuplicatePeriod() {
OHLCSeries s1 = new OHLCSeries("s1");
s1.add(new Year(2006), 1.0, 1.0, 1.0, 1.0);
boolean pass = false;
try {
s1.add(new Year(2006), 1.0, 1.0, 1.0, 1.0);
}
catch (SeriesException e) {
pass = true;
}
assertTrue(pass);
}
示例15: testUpdate
import org.jfree.data.general.SeriesException; //导入依赖的package包/类
/**
* Some checks for the update(Number, Number) method.
*/
public void testUpdate() {
XYSeries series = new XYSeries("S1");
series.add(new Integer(1), new Integer(2));
assertEquals(new Integer(2), series.getY(0));
series.update(new Integer(1), new Integer(3));
assertEquals(new Integer(3), series.getY(0));
try {
series.update(new Integer(2), new Integer(99));
assertTrue(false);
}
catch (SeriesException e) {
// got the required exception
}
}