Search in sources :

Example 1 with ICustomPaintListener

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

the class TmfBaseProvider method register.

/**
 * Method to register the provider to chart viewer.
 */
protected void register() {
    IPlotArea plotArea = getChart().getPlotArea();
    Control control = plotArea.getControl();
    if (this instanceof MouseListener) {
        control.addMouseListener((MouseListener) this);
    }
    if (this instanceof MouseMoveListener) {
        control.addMouseMoveListener((MouseMoveListener) this);
    }
    if (this instanceof MouseWheelListener) {
        control.addMouseWheelListener((MouseWheelListener) this);
    }
    if (this instanceof MouseTrackListener) {
        control.addMouseTrackListener((MouseTrackListener) this);
    }
    if (this instanceof ICustomPaintListener) {
        plotArea.addCustomPaintListener((ICustomPaintListener) this);
    } else if (this instanceof PaintListener) {
        control.addPaintListener((PaintListener) this);
    }
    TmfAbstractToolTipHandler tooltipHandler = getTooltipHandler();
    if (tooltipHandler != null) {
        tooltipHandler.activateHoverHelp(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 2 with ICustomPaintListener

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

the class BaseMouseProvider method register.

/**
 * Method to register the provider to chart viewer.
 */
protected void register() {
    IPlotArea plotArea = getChart().getPlotArea();
    Control control = plotArea.getControl();
    if (this instanceof MouseListener) {
        control.addMouseListener((MouseListener) this);
    }
    if (this instanceof MouseMoveListener) {
        control.addMouseMoveListener((MouseMoveListener) this);
    }
    if (this instanceof MouseWheelListener) {
        control.addMouseWheelListener((MouseWheelListener) this);
    }
    if (this instanceof MouseTrackListener) {
        control.addMouseTrackListener((MouseTrackListener) this);
    }
    if (this instanceof ICustomPaintListener) {
        plotArea.addCustomPaintListener((ICustomPaintListener) this);
    } else if (this instanceof PaintListener) {
        control.addPaintListener((PaintListener) this);
    }
    TmfAbstractToolTipHandler tooltipHandler = getTooltipHandler();
    if (tooltipHandler != null) {
        tooltipHandler.activateHoverHelp(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 3 with ICustomPaintListener

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

the class PlotArea method paintControl.

/*
	 * @see PaintListener#paintControl(PaintEvent)
	 */
public void paintControl(PaintEvent e) {
    Point p = getSize();
    GC gc = e.gc;
    // draw the plot area background
    Color oldBackground = gc.getBackground();
    gc.setBackground(getBackground());
    gc.fillRectangle(0, 0, p.x, p.y);
    // draw grid
    for (IAxis axis : chart.getAxisSet().getAxes()) {
        ((Grid) axis.getGrid()).draw(gc, p.x, p.y);
    }
    // draw behind series
    for (ICustomPaintListener listener : paintListeners) {
        if (listener.drawBehindSeries()) {
            listener.paintControl(e);
        }
    }
    // draw series. The line series should be drawn on bar series.
    for (ISeries series : chart.getSeriesSet().getSeries()) {
        if (series instanceof IBarSeries) {
            ((Series) series).draw(gc, p.x, p.y);
        }
    }
    for (ISeries series : chart.getSeriesSet().getSeries()) {
        if (series instanceof ILineSeries) {
            ((Series) series).draw(gc, p.x, p.y);
        }
    }
    // draw over series
    for (ICustomPaintListener listener : paintListeners) {
        if (!listener.drawBehindSeries()) {
            listener.paintControl(e);
        }
    }
    e.gc.setBackground(oldBackground);
}
Also used : IBarSeries(org.eclipse.swtchart.IBarSeries) ILineSeries(org.eclipse.swtchart.ILineSeries) ISeries(org.eclipse.swtchart.ISeries) Series(org.eclipse.swtchart.internal.series.Series) ICustomPaintListener(org.eclipse.swtchart.ICustomPaintListener) IBarSeries(org.eclipse.swtchart.IBarSeries) Color(org.eclipse.swt.graphics.Color) ILineSeries(org.eclipse.swtchart.ILineSeries) Point(org.eclipse.swt.graphics.Point) GC(org.eclipse.swt.graphics.GC) ISeries(org.eclipse.swtchart.ISeries) IAxis(org.eclipse.swtchart.IAxis)

Example 4 with ICustomPaintListener

use of org.eclipse.swtchart.ICustomPaintListener 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 5 with ICustomPaintListener

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

Aggregations

ICustomPaintListener (org.eclipse.swtchart.ICustomPaintListener)6 IPlotArea (org.eclipse.swtchart.IPlotArea)5 MouseListener (org.eclipse.swt.events.MouseListener)4 MouseMoveListener (org.eclipse.swt.events.MouseMoveListener)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 TmfAbstractToolTipHandler (org.eclipse.tracecompass.tmf.ui.viewers.TmfAbstractToolTipHandler)4 ArrayList (java.util.ArrayList)1 List (java.util.List)1 PaintEvent (org.eclipse.swt.events.PaintEvent)1 Color (org.eclipse.swt.graphics.Color)1 GC (org.eclipse.swt.graphics.GC)1 Point (org.eclipse.swt.graphics.Point)1 IAxis (org.eclipse.swtchart.IAxis)1 IBarSeries (org.eclipse.swtchart.IBarSeries)1 ILineSeries (org.eclipse.swtchart.ILineSeries)1 ISeries (org.eclipse.swtchart.ISeries)1 BarSeriesIon (org.eclipse.swtchart.extensions.internal.support.BarSeriesIon)1