本文整理汇总了Java中org.jfree.data.xy.XYDataItem类的典型用法代码示例。如果您正苦于以下问题:Java XYDataItem类的具体用法?Java XYDataItem怎么用?Java XYDataItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XYDataItem类属于org.jfree.data.xy包,在下文中一共展示了XYDataItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testAddOrUpdate
import org.jfree.data.xy.XYDataItem; //导入依赖的package包/类
/**
* Some checks for the addOrUpdate() method.
*/
public void testAddOrUpdate() {
XYSeries series = new XYSeries("S1");
XYDataItem old = series.addOrUpdate(new Long(1), new Long(2));
assertTrue(old == null);
assertEquals(1, series.getItemCount());
assertEquals(new Long(2), series.getY(0));
old = series.addOrUpdate(new Long(2), new Long(3));
assertTrue(old == null);
assertEquals(2, series.getItemCount());
assertEquals(new Long(3), series.getY(1));
old = series.addOrUpdate(new Long(1), new Long(99));
assertEquals(new XYDataItem(new Long(1), new Long(2)), old);
assertEquals(2, series.getItemCount());
assertEquals(new Long(99), series.getY(0));
assertEquals(new Long(3), series.getY(1));
}
示例2: DatasetSpectrum
import org.jfree.data.xy.XYDataItem; //导入依赖的package包/类
/**
* Inits
* @param fftBinSizeHz
* @param freqStartMHz
* @param freqStopMHz
* @param spectrumInitPower
* @param peaks enable calculation of peaks
* @param peakFallThreshold
* @param peakFalloutMillis
*/
public DatasetSpectrum(float fftBinSizeHz, int freqStartMHz, int freqStopMHz, float spectrumInitPower)
{
this.fftBinSizeHz = fftBinSizeHz;
this.freqStartMHz = freqStartMHz;
this.freqStartHz = freqStartMHz * 1000000l;
this.freqStopMHz = freqStopMHz;
this.spectrumInitPower = spectrumInitPower;
int datapoints = (int) (Math.ceil(freqStopMHz - freqStartMHz) * 1000000d / fftBinSizeHz);
spectrum = new float[datapoints];
Arrays.fill(spectrum, spectrumInitPower);
for (int j = 0; j < 5; j++) {
ArrayList<XYDataItem> list = new ArrayList<>();
for (int i = 0; i < datapoints; i++) {
double freq = (freqStartHz + fftBinSizeHz * i) / 1000000;
list.add(new XYDataItem(freq, 0));
}
cachedDataItems.add(list);
}
}
示例3: fillToXYSeriesPriv
import org.jfree.data.xy.XYDataItem; //导入依赖的package包/类
protected void fillToXYSeriesPriv(XYSeries series, float[] spectrum){
series.clear();
/**
* caching decreases GC usage
*/
boolean useCached = false;
if (!useCached){
for (int i = 0; i < spectrum.length; i++)
{
double freq = (freqStartHz + fftBinSizeHz * i) / 1000000;
series.add(freq, spectrum[i]);
}
}
else{
ArrayList<XYDataItem> items = cachedDataItems.get(cachedDataItemsIndex);
for (int i = 0; i < spectrum.length; i++)
{
XYDataItem item = items.get(i);
item.setY(spectrum[i]);
series.add(item);
}
cachedDataItemsIndex = (cachedDataItemsIndex+1)%cachedDataItems.size();
}
}
示例4: GenerateModel
import org.jfree.data.xy.XYDataItem; //导入依赖的package包/类
public void GenerateModel() throws IOException {
XYPointCollection points = new XYPointCollection();
XYSeries series = new XYSeries("Peptide ions");
XYSeriesCollection xySeriesCollection = new XYSeriesCollection();
for (PepIonID pepA : LCMSA.GetPepIonList().values()) {
if (LCMSB.GetPepIonList().containsKey(pepA.GetKey())) {
PepIonID pepB = LCMSB.GetPepIonList().get(pepA.GetKey());
points.AddPoint(pepA.GetRT(), pepB.GetRT());
series.add(new XYDataItem(pepA.GetRT(), pepB.GetRT()));
}
}
regression = new PiecewiseRegression(parameter.MaxCurveRTRange, parameter.MaxCurveRTRange);
regression.SetData(points);
float R2 = regression.GetR2();
Logger.getRootLogger().info("Retention time prediction model:(" + FilenameUtils.getBaseName(LCMSA.mzXMLFileName) + "-" + FilenameUtils.getBaseName(LCMSB.mzXMLFileName) + ")..R2=" + R2 + "(No. of commonly identified peptide ions=" + points.PointCount() + ")");
GenerateRTMapPNG(xySeriesCollection, series, R2);
}
示例5: setEnglishUnits
import org.jfree.data.xy.XYDataItem; //导入依赖的package包/类
public void setEnglishUnits( boolean englishUnits ) {
if ( englishUnits != _englishUnits ) {
_englishUnits = englishUnits;
// change labels and ranges
updateYAxis();
// convert existing data to new units
int itemCount = _series.getItemCount();
for ( int i = 0; i < itemCount; i++ ) {
XYDataItem item = (XYDataItem) _series.getDataItem( i );
if ( _englishUnits ) {
item.setY( UnitsConverter.metersToFeet( item.getY().doubleValue() ) );
}
else {
item.setY( UnitsConverter.feetToMeters( item.getY().doubleValue() ) );
}
}
}
}
示例6: doBestFit
import org.jfree.data.xy.XYDataItem; //导入依赖的package包/类
private void doBestFit() {
XYSeries dataset = betaChart.getMeanDataSet();
final ArrayList dataCopy = new ArrayList();
for ( int i = 0; i < dataset.getItemCount(); i++ ) {
XYDataItem x = dataset.getDataItem( i );
dataCopy.add( new Point2D.Double( x.getX().doubleValue(), x.getY().doubleValue() ) );
}
LinearRegression.Result result = LinearRegression.main( new LinearRegression.Input() {
public boolean isEmpty() {
return dataCopy.isEmpty();
}
public Point2D readPoint() {
return (Point2D) dataCopy.remove( 0 );
}
} );
double x0 = getMinX( dataset );
double x1 = getMaxX( dataset );
Point2D lhs = new Point2D.Double( x0, result.evaluate( x0 ) );
Point2D rhs = new Point2D.Double( x1, result.evaluate( x1 ) );
betaChart.showLine( lhs, rhs );
DecimalFormat decimalFormat = new DecimalFormat( "0.00" );
betaText.setText( "Critical Exponent = " + decimalFormat.format( result.getSlope() ) );
}
示例7: updateLines
import org.jfree.data.xy.XYDataItem; //导入依赖的package包/类
private void updateLines() {
MyMultiMap multiMap = new MyMultiMap();
for ( int i = 0; i < meanSeries.getItemCount(); i++ ) {
XYDataItem item = meanSeries.getDataItem( i );
multiMap.add( item.getX(), item.getY() );
}
Set keySet = multiMap.keySet();
ArrayList lits = new ArrayList( keySet );
Collections.sort( lits, new Comparator() {
public int compare( Object o1, Object o2 ) {
Number a = (Number) o1;
Number b = (Number) o2;
return Double.compare( a.doubleValue(), b.doubleValue() );
}
} );
lineSeries.clear();
for ( int i = 0; i < lits.size(); i++ ) {
Number key = (Number) lits.get( i );
int numValues = multiMap.numValues( key );
if ( numValues > 14 ) {
lineSeries.add( key.doubleValue(), average( multiMap.getList( key ) ) );
}
}
}
示例8: add
import org.jfree.data.xy.XYDataItem; //导入依赖的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);
}
}
}
示例9: updateByIndex
import org.jfree.data.xy.XYDataItem; //导入依赖的package包/类
@Override
public void updateByIndex(int index, Number y) {
XYDataItem existing = getDataItem(index);
XYDataItem item = new XYDataItem(existing.getX(), y);
if (checkValidity(item))
{
if (checkDataItem(item))
super.update(index, y);
else
{
super.remove(index);
discardedItems.add(item);
}
}
}
示例10: getItems
import org.jfree.data.xy.XYDataItem; //导入依赖的package包/类
@Override
public List getItems()
{
List items = new LinkedList();
for (int i = 0; i < getItemCount(); i++)
{
XYDataItem item = super.getDataItem(i);
if (this.logYAxis && item.getY().doubleValue() <= 0)
items.add(new XYDataItem(item.getX(), Double.NaN));
else
items.add(new XYDataItem(item.getX(), item.getY()));
}
return items;
}
示例11: remove
import org.jfree.data.xy.XYDataItem; //导入依赖的package包/类
@Override
public XYDataItem remove(Number x)
{
XYDataItem result = null;
int indexD = discardedItems.indexOf(x);
int indexS = super.indexOf(x);
/* If in discarded items, then remove and return this. */
if (indexD >= 0)
{
result = discardedItems.remove(indexD);
}
/* If in main items, then remove and return this. (Should not be both in discarded and main items) */
if (indexS >= 0)
{
result = super.remove(indexS);
}
return result;
}
示例12: calculateAvg
import org.jfree.data.xy.XYDataItem; //导入依赖的package包/类
/**
* Calculate avg.
*/
// calculating an avg value that is used for identifying the top series
void calculateAvg() {
long sum = 0;
int count = 1;
synchronized (stats) {
boolean useMovingAvg = getMovingAvgFrame() > 0 && getMovingAvgFrame() < stats.size();
for (ListIterator<XYDataItem> it = stats.listIterator(); it.hasNext();) {
XYDataItem xy = it.next();
sum += xy.getY().longValue();
if (useMovingAvg && count % getMovingAvgFrame() == 0 || !it.hasNext()) {
double thisAvg = (double) sum / count;
if (thisAvg > avg) {
avg = thisAvg;
}
sum = 0;
count = 1;
} else {
count++;
}
}
}
}
示例13: populate
import org.jfree.data.xy.XYDataItem; //导入依赖的package包/类
@Override
public void populate(DefaultTableXYDataset dataset, StatsCollection statsCollection,
HttpServletRequest request) {
String seriesParam = ServletRequestUtils.getStringParameter(request, "sp", null);
for (int i = 0; i < statNames.size(); i++) {
String statName = statNames.get(i);
if (seriesParam != null) {
statName = MessageFormat.format(statName, seriesParam);
}
List<XYDataItem> stats = statsCollection.getStats(statName);
if (stats != null) {
String series =
ServletRequestUtils.getStringParameter(request, "s" + (i + 1) + "l", "series" + i);
dataset.addSeries(toSeries(series, stats));
}
}
}
示例14: populate
import org.jfree.data.xy.XYDataItem; //导入依赖的package包/类
@Override
public void populate(DefaultTableXYDataset dataset, StatsCollection statsCollection,
HttpServletRequest request) {
// get Connector name from the request
String connectorName = ServletRequestUtils.getStringParameter(request, "cn", null);
// type of statistic to be displayed
String statType = ServletRequestUtils.getStringParameter(request, "st", null);
// Series legend
String series1Legend = ServletRequestUtils.getStringParameter(request, "sl", "");
if (connectorName != null && statType != null) {
List<XYDataItem> stats =
statsCollection.getStats("stat.connector." + connectorName + "." + statType);
if (stats != null) {
dataset.addSeries(toSeries(series1Legend, stats));
}
}
}
示例15: buildAbsoluteStats
import org.jfree.data.xy.XYDataItem; //导入依赖的package包/类
/**
* Builds the absolute stats.
*
* @param name the name
* @param value the value
* @param time the time
* @throws InterruptedException the interrupted exception
*/
protected void buildAbsoluteStats(String name, long value, long time)
throws InterruptedException {
List<XYDataItem> stats = statsCollection.getStats(name);
if (stats == null) {
statsCollection.newStats(name, maxSeries);
} else {
XYDataItem data = new XYDataItem(time, value);
statsCollection.lockForUpdate();
try {
stats.add(data);
houseKeepStats(stats);
} finally {
statsCollection.releaseLock();
}
if (listeners != null) {
StatsCollectionEvent event = new StatsCollectionEvent(name, data);
for (StatsCollectionListener listener : listeners) {
if (listener.isEnabled()) {
listener.statsCollected(event);
}
}
}
}
}