Search in sources :

Example 1 with BarSeriesIon

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;
}
Also used : ArrayList(java.util.ArrayList) BarSeriesIon(org.eclipse.swtchart.extensions.internal.support.BarSeriesIon) Point(org.eclipse.swt.graphics.Point) ISeries(org.eclipse.swtchart.ISeries) Point(org.eclipse.swt.graphics.Point)

Example 2 with BarSeriesIon

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;
        }
    });
}
Also used : ICustomPaintListener(org.eclipse.swtchart.ICustomPaintListener) PaintEvent(org.eclipse.swt.events.PaintEvent) IPlotArea(org.eclipse.swtchart.IPlotArea) BarSeriesIon(org.eclipse.swtchart.extensions.internal.support.BarSeriesIon) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ArrayList (java.util.ArrayList)2 BarSeriesIon (org.eclipse.swtchart.extensions.internal.support.BarSeriesIon)2 List (java.util.List)1 PaintEvent (org.eclipse.swt.events.PaintEvent)1 Point (org.eclipse.swt.graphics.Point)1 ICustomPaintListener (org.eclipse.swtchart.ICustomPaintListener)1 IPlotArea (org.eclipse.swtchart.IPlotArea)1 ISeries (org.eclipse.swtchart.ISeries)1