Example usage for org.jfree.data.xy XYDataItem XYDataItem

List of usage examples for org.jfree.data.xy XYDataItem XYDataItem

Introduction

In this page you can find the example usage for org.jfree.data.xy XYDataItem XYDataItem.

Prototype

public XYDataItem(double x, double y) 

Source Link

Document

Constructs a new data item.

Usage

From source file:org.jfree.data.xy.XYDataItemTest.java

/**
 * Confirm that the equals method can distinguish all the required fields.
 *//*from w w  w.j ava 2 s  . co m*/
@Test
public void testEquals() {
    XYDataItem i1 = new XYDataItem(1.0, 1.1);
    XYDataItem i2 = new XYDataItem(1.0, 1.1);
    assertTrue(i1.equals(i2));
    assertTrue(i2.equals(i1));

    i1.setY(new Double(9.9));
    assertFalse(i1.equals(i2));

    i2.setY(new Double(9.9));
    assertTrue(i1.equals(i2));
}

From source file:org.jfree.data.xy.XYDataItemTest.java

/**
 * Confirm that cloning works./*  w  ww.  j a  v a  2s. c  o m*/
 */
@Test
public void testCloning() {
    XYDataItem i1 = new XYDataItem(1.0, 1.1);
    XYDataItem i2 = (XYDataItem) i1.clone();
    assertTrue(i1 != i2);
    assertTrue(i1.getClass() == i2.getClass());
    assertTrue(i1.equals(i2));
}

From source file:org.jfree.data.xy.XYDataItemTest.java

/**
 * Serialize an instance, restore it, and check for equality.
 *///  w  w w  . ja v a  2s. c  o  m
@Test
public void testSerialization() {
    XYDataItem i1 = new XYDataItem(1.0, 1.1);
    XYDataItem i2 = (XYDataItem) TestUtilities.serialised(i1);
    assertEquals(i1, i2);
}

From source file:MSUmpire.DIA.RTAlignedPepIonMapping.java

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()));
        }//from   w w  w . j  a  v  a  2s .c o m
    }
    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);
}

From source file:MSUmpire.DIA.RTMappingExtLib.java

public void GenerateModel() throws IOException {

    XYPointCollection points = new XYPointCollection();
    XYSeries series = new XYSeries("Peptide ions");
    XYSeriesCollection xySeriesCollection = new XYSeriesCollection();

    FileWriter writer = new FileWriter(FilenameUtils.getFullPath(TargetLCMS.mzXMLFileName) + "/"
            + FilenameUtils.getBaseName(TargetLCMS.mzXMLFileName) + "_" + libManager.LibID
            + "_RTMapPoints.txt");

    for (String pepkey : libManager.PeptideFragmentLib.keySet()) {
        if (TargetLCMS.GetPepIonList().containsKey(pepkey)) {
            PepFragmentLib peplib = libManager.GetFragmentLib(pepkey);
            for (float rt : peplib.RetentionTime) {
                float y = TargetLCMS.GetPepIonList().get(pepkey).GetRT();
                points.AddPoint(rt, y);/*from w w  w .  j a  va  2s. c  o  m*/
                series.add(new XYDataItem(rt, y));
                writer.write(rt + "\t" + y + "\n");
            }
        }
    }
    writer.close();
    regression = new PiecewiseRegression(parameter.MaxCurveRTRange, parameter.MaxCurveRTRange);
    regression.SetData(points);
    float R2 = regression.GetR2();
    Logger.getRootLogger()
            .info("Retention time prediction model:(" + FilenameUtils.getBaseName(TargetLCMS.mzXMLFileName)
                    + "..R2=" + R2 + "(No. of commonly identified peptide ions=" + points.PointCount() + ")");

    GenerateRTMapPNG(xySeriesCollection, series, R2);
}

From source file:org.ujmp.jfreechart.XYSeriesWrapper.java

public XYDataItem getDataItem(int index) {
    // int id = start + index * stepsize;
    // if (id >= variable.getVariable().getMatrixCount()) {
    // return new XYDataItem(id, 0.0);
    // }//from   w  ww . j av a  2  s  .c  o m
    //
    // Matrix matrix = variable.getVariable().getMatrix(id);
    // double value = 0.0;
    // try {
    // value = matrix.getAsDouble(number % matrix.getRowCount(), number
    // / matrix.getRowCount());
    // } catch (MatrixException e) {
    // // TODO Auto-generated catch block
    // e.printStackTrace();
    // }
    //
    // XYDataItem xyDataItem = values.get(id);
    // if (xyDataItem == null) {
    // xyDataItem = new XYDataItem(id, value);
    // values.put(id, xyDataItem);
    // } else {
    // xyDataItem.setY(value);
    // }
    //
    // return xyDataItem;

    double row = index;
    try {
        row = Double.parseDouble(matrix.getMatrix().getRowLabel(index));
    } catch (Exception e) {
    }

    return new XYDataItem(row, matrix.getMatrix().getAsDouble(index, seriesId));
}

From source file:com.orange.atk.graphAnalyser.PerformanceGraph.java

public final synchronized void addDatasetValue(long xval, double yval) {
    double y_scaled = yval / scale;
    XYDataItem item = new XYDataItem(xval, y_scaled);
    data.add(item);/*from w  ww .j a v a  2  s . c o m*/
    /*if((numberaxis.getLabel().toLowerCase().contains(cpuLabel))&&active){
       Double maxRange;
       Double minRange;
       if(rangeCPU!=null)
    maxRange = rangeCPU.getUpperBound();
       else
    maxRange = numberaxis.getRange().getUpperBound();
       if(rangeCPU!=null)
    minRange = rangeCPU.getLowerBound();
       else
    minRange = numberaxis.getRange().getUpperBound();
            
       Double diff = 0.0;
            
       if(y_scaled>maxRange){
    maxRange = y_scaled;
    diff = (maxRange-minRange)*0.02;
       }
       if(y_scaled<minRange){
    minRange = y_scaled;
    diff = (maxRange-minRange)*0.02;
       }
       if((maxRange-minRange)<1){
    diff = maxRange * 0.0002;
       }
               
       rangeCPU = new Range((double)minRange-diff,(double)maxRange+diff);
       if (rangeCPU.getLength()==0) rangeCPU = Range.expand(new Range(0.0, 0.5),0.03,0.0);
       numberaxis.setRange(rangeCPU);
    }
            
    if((numberaxis.getLabel().toLowerCase().contains(memoryLabel))&&active){
       Double maxRange;
       Double minRange;
       if(rangeMEM!=null)
    maxRange = rangeMEM.getUpperBound();
       else
    maxRange = numberaxis.getRange().getUpperBound();
       if(rangeMEM!=null)
    minRange = rangeMEM.getLowerBound();
       else
    minRange = numberaxis.getRange().getUpperBound();
               
       Double diff = 0.0;
            
       if(y_scaled>maxRange){
    maxRange = y_scaled;
    diff = (maxRange-minRange)*0.02;
       }
       if(y_scaled<minRange){
    minRange = y_scaled;
    diff = (maxRange-minRange)*0.02;
       }
       if((maxRange-minRange)<1){
    diff = maxRange * 0.0002;
       }
               
       rangeMEM = new Range((double)minRange-diff,(double)maxRange+diff);
       if (rangeMEM.getLength()==0) rangeMEM = Range.expand(new Range(0.0, 0.5),0.03,0.0);
       numberaxis.setRange(rangeMEM);
    }*/

}

From source file:com.bwc.ora.models.Lrp.java

public static XYSeries findMaximums(XYSeries lrpSeries, String title) {
    XYSeries lrpMaxPoints = new XYSeries(title);
    XYDataItem leftPeakPoint = new XYDataItem(0, 0);
    int leftPeakPointIndex = 0;
    XYDataItem rightPeakPoint = new XYDataItem(0, 0);
    boolean first = true;
    int index = -1;
    List<XYDataItem> pointList = (List<XYDataItem>) lrpSeries.getItems();
    for (XYDataItem point : pointList) {
        index++;/*from  w  ww  . j a va 2s  .  com*/
        if (first) {
            leftPeakPoint = point;
            leftPeakPointIndex = index;
            first = false;
            continue;
        }
        if (leftPeakPoint.getYValue() < point.getYValue()) {
            leftPeakPoint = point;
            leftPeakPointIndex = index;
            rightPeakPoint = point;
        } else if (leftPeakPoint.getYValue() == point.getYValue()) {
            rightPeakPoint = point;
        } else {
            //determine if we are coming down off of a peak by looking two points behind the current point
            if (leftPeakPointIndex > 0) {
                XYDataItem prev = pointList.get(leftPeakPointIndex - 1);
                //if two points back has a Y value that is less than or equal to the left peak point
                //then we have found the end of the peak and we can process as such
                if (prev.getYValue() <= leftPeakPoint.getYValue()) {
                    double peakx = rightPeakPoint.getXValue()
                            - ((rightPeakPoint.getXValue() - leftPeakPoint.getXValue()) / 2D);
                    lrpMaxPoints.add(peakx, leftPeakPoint.getY());
                }
            }
            leftPeakPoint = point;
            leftPeakPointIndex = index;
            rightPeakPoint = point;
        }
    }

    return lrpMaxPoints;
}

From source file:com.googlecode.psiprobe.model.stats.StatsCollection.java

private Map deserialize(File f) {
    Map stats = null;// www  .  j  av a2 s .c  o m
    if (f.exists() && f.canRead()) {
        long t = System.currentTimeMillis();
        try {
            FileInputStream fis = new FileInputStream(f);
            try {
                stats = (Map) (new XStream().fromXML(fis));

                if (stats != null) {
                    // adjust stats data so that charts look realistic.
                    // we do that by ending the previous stats group with 0 value
                    // and starting the current stats group also with 0
                    // thus giving the chart nice plunge to zero indicating downtime
                    //
                    // and lets not bother about rotating stats;
                    // regular stats collection cycle will do it

                    for (Iterator it = stats.keySet().iterator(); it.hasNext();) {
                        List l = (List) stats.get(it.next());
                        if (l.size() > 0) {
                            XYDataItem xy = (XYDataItem) l.get(l.size() - 1);
                            l.add(new XYDataItem(xy.getX().longValue() + 1, 0));
                            l.add(new XYDataItem(System.currentTimeMillis(), 0));
                        }
                    }
                }
            } finally {
                fis.close();
            }
            logger.debug("stats data read in " + (System.currentTimeMillis() - t) + "ms.");
        } catch (Throwable e) {
            logger.error("Could not read stats data from " + f.getAbsolutePath(), e);
            //
            // make sure we always re-throw ThreadDeath
            //
            if (e instanceof ThreadDeath) {
                throw (ThreadDeath) e;
            }
        }
    }

    return stats;
}

From source file:psiprobe.model.stats.StatsCollection.java

/**
 * Deserialize.//from   w  w w  . jav  a2 s. c  o  m
 *
 * @param file the file
 * @return the map
 */
private Map<String, List<XYDataItem>> deserialize(File file) {
    Map<String, List<XYDataItem>> stats = null;
    if (file.exists() && file.canRead()) {
        long start = System.currentTimeMillis();
        try {
            try (FileInputStream fis = new FileInputStream(file)) {
                stats = (Map<String, List<XYDataItem>>) (new XStream().fromXML(fis));

                if (stats != null) {
                    // adjust stats data so that charts look realistic.
                    // we do that by ending the previous stats group with 0 value
                    // and starting the current stats group also with 0
                    // thus giving the chart nice plunge to zero indicating downtime
                    // and lets not bother about rotating stats;
                    // regular stats collection cycle will do it

                    for (String key : stats.keySet()) {
                        List<XYDataItem> list = stats.get(key);
                        if (!list.isEmpty()) {
                            XYDataItem xy = list.get(list.size() - 1);
                            list.add(new XYDataItem(xy.getX().longValue() + 1, 0));
                            list.add(new XYDataItem(System.currentTimeMillis(), 0));
                        }
                    }
                }
            }
            logger.debug("stats data read in {}ms", (System.currentTimeMillis() - start));
        } catch (Exception e) {
            logger.error("Could not read stats data from '{}'", file.getAbsolutePath(), e);
        }
    }

    return stats;
}