use of net.sf.mzmine.chartbasics.gui.wrapper.ChartViewWrapper in project mzmine2 by mzmine.
the class ChartGestureMouseAdapterFX method handleMouseMoved.
/**
* Handles a mouse moved event. This implementation does nothing, override the method if required.
*
* @param canvas the canvas ({@code null} not permitted).
* @param e the event ({@code null} not permitted).
*/
@Override
public void handleMouseMoved(ChartCanvas chartPanel, MouseEvent eOrig) {
if (gestureHandlers == null || gestureHandlers.isEmpty() || !listensFor(Event.MOVED))
return;
MouseEventWrapper e = new MouseEventWrapper(eOrig);
ChartViewWrapper cw = new ChartViewWrapper(chartViewer);
ChartEntity entity = findChartEntity(e);
ChartGesture.Entity gestureEntity = ChartGesture.getGestureEntity(entity);
Button button = Button.getButton(e.getButton());
// handle event
handleEvent(new ChartGestureEvent(cw, e, entity, new ChartGesture(gestureEntity, Event.MOVED, button)));
}
use of net.sf.mzmine.chartbasics.gui.wrapper.ChartViewWrapper in project mzmine2 by mzmine.
the class SpectralMatchPanel method coupleZoomYListener.
private void coupleZoomYListener() {
CombinedDomainXYPlot domainPlot = (CombinedDomainXYPlot) mirrorChart.getChart().getXYPlot();
NumberAxis axis = (NumberAxis) domainPlot.getDomainAxis();
axis.setLabel("m/z");
queryPlot = (XYPlot) domainPlot.getSubplots().get(0);
libraryPlot = (XYPlot) domainPlot.getSubplots().get(1);
queryPlot.getRangeAxis().addChangeListener(new AxisRangeChangedListener(null) {
@Override
public void axisRangeChanged(ChartViewWrapper chart, ValueAxis axis, Range lastR, Range newR) {
rangeHasChanged(newR);
}
});
libraryPlot.getRangeAxis().addChangeListener(new AxisRangeChangedListener(null) {
@Override
public void axisRangeChanged(ChartViewWrapper chart, ValueAxis axis, Range lastR, Range newR) {
rangeHasChanged(newR);
}
});
}
use of net.sf.mzmine.chartbasics.gui.wrapper.ChartViewWrapper in project mzmine2 by mzmine.
the class MultiMSMSWindow method renewCharts.
/**
* @param group
*/
public void renewCharts(ChartGroup group) {
pnCharts.removeAll();
if (group != null && group.size() > 0) {
realCol = autoCol ? (int) Math.floor(Math.sqrt(group.size())) - 1 : col;
if (realCol < 1)
realCol = 1;
GridLayout layout = new GridLayout(0, realCol);
pnCharts.setLayout(layout);
// add to layout
int i = 0;
for (ChartViewWrapper cp : group.getList()) {
// show only the last domain axes
ValueAxis axis = cp.getChart().getXYPlot().getDomainAxis();
axis.setVisible(!onlyShowOneAxis || i >= group.size() - realCol);
pnCharts.add(cp.getChartSwing());
i++;
}
}
pnCharts.revalidate();
pnCharts.repaint();
}
use of net.sf.mzmine.chartbasics.gui.wrapper.ChartViewWrapper in project mzmine2 by mzmine.
the class ChartGroup method combineAxes.
/**
* Combines the zoom of axes of all charts
*
* @param chart
*/
private void combineAxes(JFreeChart chart) {
try {
if (combineDomainAxes && hasDomainAxis(chart)) {
if (domainListener == null)
domainListener = new ArrayList<>();
AxisRangeChangedListener listener = new AxisRangeChangedListener(null) {
@Override
public void axisRangeChanged(ChartViewWrapper chart, ValueAxis axis, Range lastR, Range newR) {
domainHasChanged(newR);
}
};
domainListener.add(listener);
chart.getXYPlot().getDomainAxis().addChangeListener(listener);
}
if (combineRangeAxes && hasRangeAxis(chart)) {
if (rangeListener == null)
rangeListener = new ArrayList<>();
AxisRangeChangedListener listener = new AxisRangeChangedListener(null) {
@Override
public void axisRangeChanged(ChartViewWrapper chart, ValueAxis axis, Range lastR, Range newR) {
rangeHasChanged(newR);
}
};
rangeListener.add(listener);
chart.getXYPlot().getRangeAxis().addChangeListener(listener);
}
} catch (Exception e) {
}
}
use of net.sf.mzmine.chartbasics.gui.wrapper.ChartViewWrapper in project mzmine2 by mzmine.
the class ChartGestureDragDiffHandler method createConsumer.
/**
* Handle PRESSED, DRAGGED, RELEASED events to generate drag diff events
*
* @return
*/
private Consumer<ChartGestureEvent> createConsumer() {
return new Consumer<ChartGestureEvent>() {
// variables
boolean wasMouseZoomable = false;
Point2D last = null, first = null;
ChartGestureEvent startEvent = null, lastEvent = null;
@Override
public void accept(ChartGestureEvent event) {
ChartViewWrapper chartPanel = event.getChartWrapper();
JFreeChart chart = chartPanel.getChart();
MouseEventWrapper e = event.getMouseEvent();
// released?
if (event.checkEvent(Event.RELEASED)) {
chartPanel.setMouseZoomable(wasMouseZoomable);
last = null;
} else if (event.checkEvent(Event.PRESSED)) {
// get data space coordinates
last = chartPanel.mouseXYToPlotXY(e.getX(), e.getY());
first = last;
startEvent = event;
lastEvent = event;
if (last != null) {
wasMouseZoomable = chartPanel.isMouseZoomable();
chartPanel.setMouseZoomable(false);
}
} else if (event.checkEvent(Event.DRAGGED)) {
if (last != null) {
// get data space coordinates
Point2D released = chartPanel.mouseXYToPlotXY(e.getX(), e.getY());
if (released != null) {
double offset = 0;
double start = 0;
// scroll x
if (getOrientation(event).equals(Orientation.HORIZONTAL)) {
offset = -(released.getX() - last.getX());
start = first.getX();
} else // scroll y
{
offset = -(released.getY() - last.getY());
start = first.getY();
}
// new dragdiff event
ChartGestureDragDiffEvent dragEvent = new ChartGestureDragDiffEvent(startEvent, lastEvent, event, start, offset, orient);
// choose handler by key filter
for (int i = 0; i < dragDiffHandler.length; i++) if (key[i].filter(event.getMouseEvent()))
dragDiffHandler[i].accept(dragEvent);
// set last event
lastEvent = event;
// save updated last
last = chartPanel.mouseXYToPlotXY(e.getX(), e.getY());
}
}
}
}
};
}
Aggregations