use of net.sf.mzmine.chartbasics.listener.AxesRangeChangedListener in project mzmine2 by mzmine.
the class EChartPanel method initChartPanel.
/**
* Init ChartPanel Mouse Listener For MouseDraggedOverAxis event For scrolling X-Axis und zooming
* Y-Axis0
*/
private void initChartPanel(boolean stickyZeroForRangeAxis) {
final EChartPanel chartPanel = this;
// remove old init
if (mouseAdapter != null) {
this.removeMouseListener(mouseAdapter);
this.removeMouseMotionListener(mouseAdapter);
this.removeMouseWheelListener(mouseAdapter);
}
if (chartPanel.getChart().getPlot() instanceof XYPlot) {
// set sticky zero
if (stickyZeroForRangeAxis) {
ValueAxis rangeAxis = chartPanel.getChart().getXYPlot().getRangeAxis();
if (rangeAxis instanceof NumberAxis) {
NumberAxis axis = (NumberAxis) rangeAxis;
axis.setAutoRangeIncludesZero(true);
axis.setAutoRange(true);
axis.setAutoRangeStickyZero(true);
axis.setRangeType(RangeType.POSITIVE);
}
}
Plot p = getChart().getPlot();
if (addZoomHistory && (p instanceof XYPlot) && !(p instanceof CombinedDomainXYPlot || p instanceof CombinedRangeXYPlot)) {
// zoom history
zoomHistory = new ZoomHistory(this, 20);
// axis range changed listener for zooming and more
ValueAxis rangeAxis = this.getChart().getXYPlot().getRangeAxis();
ValueAxis domainAxis = this.getChart().getXYPlot().getDomainAxis();
if (rangeAxis != null) {
rangeAxis.addChangeListener(new AxisRangeChangedListener(new ChartViewWrapper(this)) {
@Override
public void axisRangeChanged(ChartViewWrapper chart, ValueAxis axis, Range lastR, Range newR) {
// notify listeners of changed range
if (axesRangeListener != null)
for (AxesRangeChangedListener l : axesRangeListener) l.axesRangeChanged(chart, axis, lastR, newR);
}
});
}
if (domainAxis != null) {
domainAxis.addChangeListener(new AxisRangeChangedListener(new ChartViewWrapper(this)) {
@Override
public void axisRangeChanged(ChartViewWrapper chart, ValueAxis axis, Range lastR, Range newR) {
// notify listeners of changed range
if (axesRangeListener != null)
for (AxesRangeChangedListener l : axesRangeListener) l.axesRangeChanged(chart, axis, lastR, newR);
}
});
}
}
// mouse adapter for scrolling and zooming
mouseAdapter = new ChartGestureMouseAdapter();
// mouseAdapter.addDebugHandler();
this.addMouseListener(mouseAdapter);
this.addMouseMotionListener(mouseAdapter);
this.addMouseWheelListener(mouseAdapter);
// add gestures
if (standardGestures) {
addStandardGestures();
}
}
}
use of net.sf.mzmine.chartbasics.listener.AxesRangeChangedListener in project mzmine2 by mzmine.
the class EChartViewer method initChartPanel.
/**
* Init ChartPanel Mouse Listener For MouseDraggedOverAxis event For scrolling X-Axis und zooming
* Y-Axis0
*/
private void initChartPanel() {
final EChartViewer chartPanel = this;
// remove old init
if (mouseAdapter != null) {
this.getCanvas().removeMouseHandler(mouseAdapter);
}
if (chartPanel.getChart().getPlot() instanceof XYPlot) {
// set sticky zero
if (stickyZeroForRangeAxis) {
ValueAxis rangeAxis = chartPanel.getChart().getXYPlot().getRangeAxis();
if (rangeAxis instanceof NumberAxis) {
NumberAxis axis = (NumberAxis) rangeAxis;
axis.setAutoRangeIncludesZero(true);
axis.setAutoRange(true);
axis.setAutoRangeStickyZero(true);
axis.setRangeType(RangeType.POSITIVE);
}
}
Plot p = getChart().getPlot();
if (addZoomHistory && p instanceof XYPlot && !(p instanceof CombinedDomainXYPlot || p instanceof CombinedRangeXYPlot)) {
// zoom history
zoomHistory = new ZoomHistory(this, 20);
// axis range changed listener for zooming and more
ValueAxis rangeAxis = this.getChart().getXYPlot().getRangeAxis();
ValueAxis domainAxis = this.getChart().getXYPlot().getDomainAxis();
if (rangeAxis != null) {
rangeAxis.addChangeListener(new AxisRangeChangedListener(new ChartViewWrapper(this)) {
@Override
public void axisRangeChanged(ChartViewWrapper chart, ValueAxis axis, Range lastR, Range newR) {
// notify listeners of changed range
if (axesRangeListener != null)
for (AxesRangeChangedListener l : axesRangeListener) l.axesRangeChanged(chart, axis, lastR, newR);
}
});
}
if (domainAxis != null) {
domainAxis.addChangeListener(new AxisRangeChangedListener(new ChartViewWrapper(this)) {
@Override
public void axisRangeChanged(ChartViewWrapper chart, ValueAxis axis, Range lastR, Range newR) {
// notify listeners of changed range
if (axesRangeListener != null)
for (AxesRangeChangedListener l : axesRangeListener) l.axesRangeChanged(chart, axis, lastR, newR);
}
});
}
}
// mouse adapter for scrolling and zooming
mouseAdapter = new ChartGestureMouseAdapterFX("gestures", this);
addMouseHandler(mouseAdapter);
// add gestures
if (standardGestures) {
addStandardGestures();
}
// mouseAdapter.addDebugHandler();
}
}
Aggregations