Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [chemclipse-dev] Bug in org.eclipse.chemclipse.model.core.AbstractChromatogram.removeScans(int, int)

Hi Trig,

the method operates correctly. See why:

Let's assume you have 7 scans

[0, 1, 2, 3, 4, 5, 6] Index
[1, 2, 3, 4, 5, 6, 7] Scan#

Let us removeScans(4,6)

[0, 1, 2, 3, 4, 5, 6] Index
[1, 2, 3, 4, 5, 6, 7] Scan#

Remove Scan# 4, index to remove = 3

[0, 1, 2, 3, 4, 5] Index
[1, 2, 3, 5, 6, 7] Scan#

Remove Scan# 5, index to remove = 3

[0, 1, 2, 3, 4] Index
[1, 2, 3, 6, 7] Scan#

Remove Scan# 6, index to remove = 3

[0, 1, 2, 3] Index
[1, 2, 3, 7] Scan#

You are correct when saying Java style is "from" always included and "to" always exclued.
But have a look at the method definition:

    /**
     * Removes the scan range from the chromatogram.<br/>
     * The value from and to are included.<br/>
     * For example, if you want to remove 10 scans beginning from the scan 500
     * call:<br/>
     * removeScans(500, 509)<br/>
     * <br/>
     * If the retention times should be recalculated, call
     * chromatogram.recalculateRetentionTimes().<br/>
     * You can also remove several scans, and call
     * chromatogram.recalculateRetentionTimes() afterwards.
     *
     * @param from
     * @param to
     */


Best,
Philip


Am 30.06.2016 um 13:48 schrieb Trig Chen:
@Override
public void removeScans(int from, int to) {

int start;
int end;
if(from > to) {
start = to;
end = from;
} else {
start = from;
end = to;
}
for(int i = start; i <= end; i++) {
removeScan(start);     <====== Should be removeScan(i);
                                           // and in Java style, the "from" always included, the "to" always exclued.
}
/*
* Forces all listeners to be updated.
*/
// TODO Test updateChange
// fireUpdateChange(true);
}

Best regards,

Trig


_______________________________________________
chemclipse-dev mailing list
chemclipse-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/chemclipse-dev

-- 
~~~~~~~~~~~~~~~~~~~~~~~~
OpenChrom - the open source alternative for chromatography / mass spectrometry
Dr. Philip Wenig » Founder » philip.wenig@xxxxxxxxxxxxx » http://www.openchrom.net
~~~~~~~~~~~~~~~~~~~~~~~~

Back to the top