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);
}
}
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);
}
}
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);
}
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;
}
});
}
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);
}
}
}
Aggregations