use of net.sf.mzmine.chartbasics.gestures.ChartGesture in project mzmine2 by mzmine.
the class ChartGestureMouseAdapter method mouseClicked.
@Override
public void mouseClicked(MouseEvent e) {
if (gestureHandlers == null || gestureHandlers.isEmpty() || !(listensFor(Event.CLICK) || listensFor(Event.DOUBLE_CLICK)))
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());
if (!e.isConsumed()) {
// double clicked
if (e.getClickCount() == 2) {
// reset click count to handle double clicks quickly
e.consume();
// handle event
handleEvent(new ChartGestureEvent(chartPanel, e, entity, new ChartGesture(gestureEntity, Event.DOUBLE_CLICK, button)));
} else if (e.getClickCount() == 1) {
// handle event
handleEvent(new ChartGestureEvent(chartPanel, e, entity, new ChartGesture(gestureEntity, Event.CLICK, button)));
}
}
}
}
use of net.sf.mzmine.chartbasics.gestures.ChartGesture in project mzmine2 by mzmine.
the class ChartGestureMouseAdapterFX method handleScroll.
/**
* Handles a scroll 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 handleScroll(ChartCanvas chartPanel, ScrollEvent eOrig) {
if (gestureHandlers == null || gestureHandlers.isEmpty() || !listensFor(Event.MOUSE_WHEEL))
return;
MouseEventWrapper e = new MouseEventWrapper(eOrig);
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.MOUSE_WHEEL, button)));
}
use of net.sf.mzmine.chartbasics.gestures.ChartGesture in project mzmine2 by mzmine.
the class ChartGestureMouseAdapterFX method handleMouseDragged.
/**
* Handles a mouse dragged 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 handleMouseDragged(ChartCanvas chartPanel, MouseEvent eOrig) {
if (gestureHandlers == null || gestureHandlers.isEmpty() || !listensFor(Event.DRAGGED))
return;
MouseEventWrapper e = new MouseEventWrapper(eOrig);
// keep the same chartEntity
ChartEntity entity = lastDragEvent.getEntity();
ChartGesture.Entity gestureEntity = lastDragEvent.getGesture().getEntity();
Button button = lastDragEvent.getGesture().getButton();
// handle event
lastDragEvent = new ChartGestureEvent(cw, e, entity, new ChartGesture(gestureEntity, Event.DRAGGED, button));
handleEvent(lastDragEvent);
}
use of net.sf.mzmine.chartbasics.gestures.ChartGesture 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.gestures.ChartGesture in project mzmine2 by mzmine.
the class ChartGestureMouseAdapterFX method handleMouseClicked.
/**
* Handles a mouse clicked 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 handleMouseClicked(ChartCanvas chartPanel, MouseEvent eOrig) {
if (gestureHandlers == null || gestureHandlers.isEmpty() || !(listensFor(Event.CLICK) || listensFor(Event.DOUBLE_CLICK)))
return;
MouseEventWrapper e = new MouseEventWrapper(eOrig);
ChartEntity entity = findChartEntity(e);
ChartGesture.Entity gestureEntity = ChartGesture.getGestureEntity(entity);
Button button = Button.getButton(e.getButton());
if (!e.isConsumed()) {
// double clicked
if (e.getClickCount() == 2) {
// reset click count to handle double clicks quickly
e.consume();
// handle event
handleEvent(new ChartGestureEvent(cw, e, entity, new ChartGesture(gestureEntity, Event.DOUBLE_CLICK, button)));
} else if (e.getClickCount() == 1) {
// handle event
handleEvent(new ChartGestureEvent(cw, e, entity, new ChartGesture(gestureEntity, Event.CLICK, button)));
}
}
}
Aggregations