use of net.sf.mzmine.chartbasics.gestures.ChartGesture in project mzmine2 by mzmine.
the class ChartGestureMouseAdapter method mouseMoved.
@Override
public void mouseMoved(MouseEvent e) {
if (gestureHandlers == null || gestureHandlers.isEmpty() || !listensFor(Event.MOVED))
return;
if (e.getComponent() instanceof ChartPanel) {
ChartPanel chartPanel = (ChartPanel) e.getComponent();
ChartEntity entity = findChartEntity(chartPanel, e);
ChartGesture.Entity gestureEntity = ChartGesture.getGestureEntity(entity);
Button button = Button.getButton(e.getButton());
// handle event
handleEvent(new ChartGestureEvent(chartPanel, e, entity, new ChartGesture(gestureEntity, Event.MOVED, button)));
}
}
use of net.sf.mzmine.chartbasics.gestures.ChartGesture in project mzmine2 by mzmine.
the class KovatsIndexExtractionDialog method updateChart.
private void updateChart() {
updateParameterSetFromComponents();
if (selectedDataFile == null)
return;
try {
// old charts axes ranges
org.jfree.data.Range domainZoom = chart == null ? null : chart.getChart().getXYPlot().getDomainAxis().getRange();
org.jfree.data.Range rangeZoom = chart == null ? null : chart.getChart().getXYPlot().getRangeAxis().getRange();
Range<Double> rangeMZ = parameterSet.getParameter(KovatsIndexExtractionParameters.mzRange).getValue();
Range<Double> rangeRT = parameterSet.getParameter(KovatsIndexExtractionParameters.rtRange).getValue();
if (rangeMZ == null) {
// set range to specific alkane fragment
rangeMZ = Range.closed(56.6, 57.5);
((MZRangeComponent) getComponentForParameter(KovatsIndexExtractionParameters.mzRange)).setValue(rangeMZ);
}
if (rangeRT == null) {
rangeRT = selectedDataFile[0].getDataRTRange();
((RTRangeComponent) getComponentForParameter(KovatsIndexExtractionParameters.rtRange)).setValue(rangeRT);
}
// create dataset
TICSumDataSet data = new TICSumDataSet(selectedDataFile, rangeRT, rangeMZ, null, TICPlotType.BASEPEAK);
chart = new TICPlot(this);
chart.addTICDataset(data);
if (domainZoom != null)
chart.getChart().getXYPlot().getDomainAxis().setRange(domainZoom);
if (rangeZoom != null)
chart.getChart().getXYPlot().getRangeAxis().setRange(rangeZoom);
// add control for markers
chart.getGestureAdapter().addGestureHandler(new ChartGestureDragDiffHandler(Entity.PLOT, Button.BUTTON1, new Key[] { Key.NONE }, e -> handleMarkerDrag(e)));
chart.getGestureAdapter().addGestureHandler(new ChartGestureHandler(new ChartGesture(Entity.PLOT, Event.RELEASED), e -> {
if (chart != null)
chart.setMouseZoomable(true);
if (currentlyDraggedMarker != null) {
// set value of current marker
logger.info("Marker dragging ended at " + currentlyDraggedMarker.getValue());
int index = markers.indexOf(currentlyDraggedMarker);
double value = e.getCoordinates().getX();
setValue(index, value);
//
currentlyDraggedMarker = null;
}
}));
kovatsValuesChanged();
pnChart.removeAll();
pnChart.add(chart, BorderLayout.CENTER);
revalidate();
repaint();
} catch (Exception e) {
logger.log(Level.WARNING, "Peak picking parameters incorrect");
}
}
use of net.sf.mzmine.chartbasics.gestures.ChartGesture in project mzmine2 by mzmine.
the class ChartGestureMouseAdapter method mousePressed.
@Override
public void mousePressed(MouseEvent e) {
if (gestureHandlers == null || gestureHandlers.isEmpty() || !listensFor(Event.PRESSED))
return;
if (e.getComponent() instanceof ChartPanel) {
ChartPanel chartPanel = (ChartPanel) e.getComponent();
ChartEntity entity = findChartEntity(chartPanel, e);
ChartGesture.Entity gestureEntity = ChartGesture.getGestureEntity(entity);
Button button = Button.getButton(e.getButton());
// handle event
lastDragEvent = new ChartGestureEvent(chartPanel, e, entity, new ChartGesture(gestureEntity, Event.PRESSED, button));
handleEvent(lastDragEvent);
}
}
use of net.sf.mzmine.chartbasics.gestures.ChartGesture in project mzmine2 by mzmine.
the class ChartGestureMouseAdapter method addGestureHandler.
/**
* Add a preset handler for specific gestures and ChartMouseGestureEvents
*
* @param g
* @param handler
*/
public void addGestureHandler(Handler handler, Entity entity, Event[] event, Button button, Key key, Object[] param) {
ChartGestureHandler h = ChartGestureHandler.createHandler(handler, new ChartGesture(entity, event, button, key), param);
addGestureHandler(h);
}
use of net.sf.mzmine.chartbasics.gestures.ChartGesture in project mzmine2 by mzmine.
the class ChartGestureMouseAdapterFX method handleMousePressed.
/**
* Handles a mouse pressed 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 handleMousePressed(ChartCanvas chartPanel, MouseEvent eOrig) {
if (gestureHandlers == null || gestureHandlers.isEmpty() || !listensFor(Event.PRESSED))
return;
MouseEventWrapper e = new MouseEventWrapper(eOrig);
ChartEntity entity = findChartEntity(e);
ChartGesture.Entity gestureEntity = ChartGesture.getGestureEntity(entity);
Button button = Button.getButton(e.getButton());
// handle event
lastDragEvent = new ChartGestureEvent(cw, e, entity, new ChartGesture(gestureEntity, Event.PRESSED, button));
handleEvent(lastDragEvent);
}
Aggregations