本文整理汇总了Java中org.jfree.data.xy.XYSeries.setKey方法的典型用法代码示例。如果您正苦于以下问题:Java XYSeries.setKey方法的具体用法?Java XYSeries.setKey怎么用?Java XYSeries.setKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.data.xy.XYSeries
的用法示例。
在下文中一共展示了XYSeries.setKey方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testEquals
import org.jfree.data.xy.XYSeries; //导入方法依赖的package包/类
/**
* Confirm that the equals method can distinguish all the required fields.
*/
public void testEquals() {
XYSeries s1 = new XYSeries("Series");
s1.add(1.0, 1.1);
XYSeries s2 = new XYSeries("Series");
s2.add(1.0, 1.1);
assertTrue(s1.equals(s2));
assertTrue(s2.equals(s1));
s1.setKey("Series X");
assertFalse(s1.equals(s2));
s2.setKey("Series X");
assertTrue(s1.equals(s2));
}
示例2: exchangeSeries
import org.jfree.data.xy.XYSeries; //导入方法依赖的package包/类
@Override
public void exchangeSeries(int seriesIndex, DataSeries series) throws NoSuchSeriesException {
if(seriesIndex < this.getSeriesCount()){
XyDataSeries xyDataSeries = (XyDataSeries) series;
XYSeries editSeries = this.getSeries(seriesIndex);
// --- Are there configuration changes ? --------------------------
if (xyDataSeries.getAutoSort()==editSeries.getAutoSort() && xyDataSeries.getAvoidDuplicateXValues()==(!editSeries.getAllowDuplicateXValues())) {
// --- No configuration changes -------------------------------
editSeries.clear();
if (series.getLabel()!=null) {
editSeries.setKey(series.getLabel());
}
List valuePairs = xyDataSeries.getXyValuePairs();
for (int i = 0; i < valuePairs.size(); i++) {
XyValuePair valuePair = (XyValuePair) valuePairs.get(i);
editSeries.add(valuePair.getXValue().getFloatValue(), valuePair.getYValue().getFloatValue());
}
} else {
// --- Configuration has changed ------------------------------
XYSeries newSeries = (XYSeries) this.getXYSeriesFromXyDataSeries(xyDataSeries);
// --- Replace the edit series with the new series ------------
Vector<XYSeries> currSerieses = new Vector<XYSeries>();
for (int i=0; i < this.getSeriesCount(); i++) {
currSerieses.add(this.getSeries(i));
}
currSerieses.set(seriesIndex, newSeries);
this.getXySeriesCollection().removeAllSeries();
for (int i = 0; i < currSerieses.size(); i++) {
this.getXySeriesCollection().addSeries(currSerieses.get(i));
}
}
}else{
throw new NoSuchSeriesException();
}
this.setChanged();
this.notifyObservers(ChartModel.EventType.SERIES_ADDED);
}
示例3: setSeriesLabel
import org.jfree.data.xy.XYSeries; //导入方法依赖的package包/类
@Override
public void setSeriesLabel(int seriesIndex, String newLabel) {
XYSeries series = this.getSeries(seriesIndex);
if(series != null){
series.setKey(newLabel);
}
this.setChanged();
this.notifyObservers(ChartModel.EventType.SERIES_RENAMED);
}