Search in sources :

Example 16 with IPlotArea

use of org.eclipse.swtchart.IPlotArea 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)

Example 17 with IPlotArea

use of org.eclipse.swtchart.IPlotArea in project swtchart by eclipse.

the class ScrollableChart method setPlotCenterMarker.

private void setPlotCenterMarker() {
    IPlotArea plotArea = (IPlotArea) baseChart.getPlotArea();
    IChartSettings chartSettings = baseChart.getChartSettings();
    // 
    if (plotCenterMarker != null) {
        plotArea.removeCustomPaintListener(plotCenterMarker);
    }
    // 
    plotCenterMarker = new PlotCenterMarker(baseChart);
    plotCenterMarker.setForegroundColor(chartSettings.getColorPlotCenterMarker());
    plotArea.addCustomPaintListener(plotCenterMarker);
    // 
    if (chartSettings.isShowPlotCenterMarker()) {
        plotCenterMarker.setDraw(true);
    } else {
        plotCenterMarker.setDraw(false);
    }
}
Also used : PlotCenterMarker(org.eclipse.swtchart.extensions.internal.marker.PlotCenterMarker) IPlotArea(org.eclipse.swtchart.IPlotArea)

Example 18 with IPlotArea

use of org.eclipse.swtchart.IPlotArea in project tracecompass by tracecompass.

the class BaseMouseProvider method deregister.

/**
 * Method to deregister the provider from chart viewer.
 */
protected void deregister() {
    IPlotArea plotArea = getChart().getPlotArea();
    if (plotArea == null) {
        return;
    }
    Control control = plotArea.getControl();
    if (!control.isDisposed()) {
        if (this instanceof MouseListener) {
            control.removeMouseListener((MouseListener) this);
        }
        if (this instanceof MouseMoveListener) {
            control.removeMouseMoveListener((MouseMoveListener) this);
        }
        if (this instanceof MouseWheelListener) {
            control.removeMouseWheelListener((MouseWheelListener) this);
        }
        if (this instanceof MouseTrackListener) {
            control.removeMouseTrackListener((MouseTrackListener) this);
        }
        if (this instanceof ICustomPaintListener) {
            plotArea.removeCustomPaintListener((ICustomPaintListener) this);
        } else if (this instanceof PaintListener) {
            control.removePaintListener((PaintListener) this);
        }
        TmfAbstractToolTipHandler tooltipHandler = getTooltipHandler();
        if (tooltipHandler != null) {
            tooltipHandler.deactivateHoverHelp(control);
        }
    }
}
Also used : MouseMoveListener(org.eclipse.swt.events.MouseMoveListener) Control(org.eclipse.swt.widgets.Control) ICustomPaintListener(org.eclipse.swtchart.ICustomPaintListener) MouseListener(org.eclipse.swt.events.MouseListener) PaintListener(org.eclipse.swt.events.PaintListener) ICustomPaintListener(org.eclipse.swtchart.ICustomPaintListener) TmfAbstractToolTipHandler(org.eclipse.tracecompass.tmf.ui.viewers.TmfAbstractToolTipHandler) MouseTrackListener(org.eclipse.swt.events.MouseTrackListener) IPlotArea(org.eclipse.swtchart.IPlotArea) MouseWheelListener(org.eclipse.swt.events.MouseWheelListener)

Example 19 with IPlotArea

use of org.eclipse.swtchart.IPlotArea in project tracecompass by tracecompass.

the class TmfBaseProvider method deregister.

/**
 * Method to deregister the provider from chart viewer.
 */
protected void deregister() {
    IPlotArea plotArea = getChart().getPlotArea();
    if (plotArea == null) {
        return;
    }
    Control control = plotArea.getControl();
    if (!control.isDisposed()) {
        if (this instanceof MouseListener) {
            control.removeMouseListener((MouseListener) this);
        }
        if (this instanceof MouseMoveListener) {
            control.removeMouseMoveListener((MouseMoveListener) this);
        }
        if (this instanceof MouseWheelListener) {
            control.removeMouseWheelListener((MouseWheelListener) this);
        }
        if (this instanceof MouseTrackListener) {
            control.removeMouseTrackListener((MouseTrackListener) this);
        }
        if (this instanceof ICustomPaintListener) {
            plotArea.removeCustomPaintListener((ICustomPaintListener) this);
        } else if (this instanceof PaintListener) {
            control.removePaintListener((PaintListener) this);
        }
        TmfAbstractToolTipHandler tooltipHandler = getTooltipHandler();
        if (tooltipHandler != null) {
            tooltipHandler.deactivateHoverHelp(control);
        }
    }
}
Also used : MouseMoveListener(org.eclipse.swt.events.MouseMoveListener) Control(org.eclipse.swt.widgets.Control) ICustomPaintListener(org.eclipse.swtchart.ICustomPaintListener) MouseListener(org.eclipse.swt.events.MouseListener) PaintListener(org.eclipse.swt.events.PaintListener) ICustomPaintListener(org.eclipse.swtchart.ICustomPaintListener) TmfAbstractToolTipHandler(org.eclipse.tracecompass.tmf.ui.viewers.TmfAbstractToolTipHandler) MouseTrackListener(org.eclipse.swt.events.MouseTrackListener) IPlotArea(org.eclipse.swtchart.IPlotArea) MouseWheelListener(org.eclipse.swt.events.MouseWheelListener)

Aggregations

IPlotArea (org.eclipse.swtchart.IPlotArea)19 ArrayList (java.util.ArrayList)6 MouseMoveListener (org.eclipse.swt.events.MouseMoveListener)5 ICustomPaintListener (org.eclipse.swtchart.ICustomPaintListener)5 IChartSettings (org.eclipse.swtchart.extensions.core.IChartSettings)5 ISeriesData (org.eclipse.swtchart.extensions.core.ISeriesData)5 LabelMarker (org.eclipse.swtchart.extensions.marker.LabelMarker)5 MouseListener (org.eclipse.swt.events.MouseListener)4 MouseTrackListener (org.eclipse.swt.events.MouseTrackListener)4 MouseWheelListener (org.eclipse.swt.events.MouseWheelListener)4 PaintListener (org.eclipse.swt.events.PaintListener)4 Control (org.eclipse.swt.widgets.Control)4 ILineSeriesData (org.eclipse.swtchart.extensions.linecharts.ILineSeriesData)4 ILineSeriesSettings (org.eclipse.swtchart.extensions.linecharts.ILineSeriesSettings)4 LineSeriesData (org.eclipse.swtchart.extensions.linecharts.LineSeriesData)4 TmfAbstractToolTipHandler (org.eclipse.tracecompass.tmf.ui.viewers.TmfAbstractToolTipHandler)4 HashMap (java.util.HashMap)1 List (java.util.List)1 MouseEvent (org.eclipse.swt.events.MouseEvent)1 PaintEvent (org.eclipse.swt.events.PaintEvent)1