use of org.eclipse.swtchart.extensions.internal.support.BarSeriesIon in project swtchart by eclipse.
the class MassSpectrumChart method getBarSeriesIonList.
private List<BarSeriesIon> getBarSeriesIonList() {
List<BarSeriesIon> barSeriesIons = new ArrayList<BarSeriesIon>();
//
int widthPlotArea = getBaseChart().getPlotArea().getBounds().width;
ISeries[] series = getBaseChart().getSeriesSet().getSeries();
for (ISeries barSeries : series) {
if (barSeries != null) {
//
double[] xSeries = barSeries.getXSeries();
double[] ySeries = barSeries.getYSeries();
int size = barSeries.getXSeries().length;
//
for (int i = 0; i < size; i++) {
Point point = barSeries.getPixelCoordinates(i);
if (point.x >= 0 && point.x <= widthPlotArea) {
barSeriesIons.add(new BarSeriesIon(xSeries[i], ySeries[i], point));
}
}
}
}
return barSeriesIons;
}
use of org.eclipse.swtchart.extensions.internal.support.BarSeriesIon in project swtchart by eclipse.
the class MassSpectrumChart method addSeriesLabelMarker.
private void addSeriesLabelMarker() {
/*
* Plot the series name above the entry.
*/
IPlotArea plotArea = (IPlotArea) getBaseChart().getPlotArea();
plotArea.addCustomPaintListener(new ICustomPaintListener() {
@Override
public void paintControl(PaintEvent e) {
List<BarSeriesIon> barSeriesIons = getBarSeriesIonList();
Collections.sort(barSeriesIons, barSeriesIonComparator);
int barSeriesSize = barSeriesIons.size();
int limit;
/*
* Positive
*/
limit = numberOfHighestIntensitiesToLabel;
for (int i = 0; i < limit; i++) {
if (i < barSeriesSize) {
BarSeriesIon barSeriesIon = barSeriesIons.get(i);
printLabel(barSeriesIon, e);
}
}
/*
* Negative
*/
limit = barSeriesIons.size() - numberOfHighestIntensitiesToLabel;
limit = (limit < 0) ? 0 : limit;
for (int i = barSeriesIons.size() - 1; i >= limit; i--) {
BarSeriesIon barSeriesIon = barSeriesIons.get(i);
if (barSeriesIon.getIntensity() < 0) {
printLabel(barSeriesIon, e);
}
}
}
@Override
public boolean drawBehindSeries() {
return false;
}
});
}
Aggregations