Search in sources :

Example 1 with MouseEventWrapper

use of net.sf.mzmine.chartbasics.gui.wrapper.MouseEventWrapper 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)));
}
Also used : ChartGesture(net.sf.mzmine.chartbasics.gestures.ChartGesture) Button(net.sf.mzmine.chartbasics.gestures.ChartGesture.Button) ChartGestureEvent(net.sf.mzmine.chartbasics.gestures.ChartGestureEvent) MouseEventWrapper(net.sf.mzmine.chartbasics.gui.wrapper.MouseEventWrapper) Entity(net.sf.mzmine.chartbasics.gestures.ChartGesture.Entity) ChartEntity(org.jfree.chart.entity.ChartEntity)

Example 2 with MouseEventWrapper

use of net.sf.mzmine.chartbasics.gui.wrapper.MouseEventWrapper 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);
}
Also used : ChartGesture(net.sf.mzmine.chartbasics.gestures.ChartGesture) Button(net.sf.mzmine.chartbasics.gestures.ChartGesture.Button) ChartGestureEvent(net.sf.mzmine.chartbasics.gestures.ChartGestureEvent) MouseEventWrapper(net.sf.mzmine.chartbasics.gui.wrapper.MouseEventWrapper) Entity(net.sf.mzmine.chartbasics.gestures.ChartGesture.Entity) ChartEntity(org.jfree.chart.entity.ChartEntity)

Example 3 with MouseEventWrapper

use of net.sf.mzmine.chartbasics.gui.wrapper.MouseEventWrapper 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)));
}
Also used : ChartGesture(net.sf.mzmine.chartbasics.gestures.ChartGesture) ChartViewWrapper(net.sf.mzmine.chartbasics.gui.wrapper.ChartViewWrapper) Button(net.sf.mzmine.chartbasics.gestures.ChartGesture.Button) ChartGestureEvent(net.sf.mzmine.chartbasics.gestures.ChartGestureEvent) MouseEventWrapper(net.sf.mzmine.chartbasics.gui.wrapper.MouseEventWrapper) Entity(net.sf.mzmine.chartbasics.gestures.ChartGesture.Entity) ChartEntity(org.jfree.chart.entity.ChartEntity)

Example 4 with MouseEventWrapper

use of net.sf.mzmine.chartbasics.gui.wrapper.MouseEventWrapper 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)));
        }
    }
}
Also used : ChartGesture(net.sf.mzmine.chartbasics.gestures.ChartGesture) Button(net.sf.mzmine.chartbasics.gestures.ChartGesture.Button) ChartGestureEvent(net.sf.mzmine.chartbasics.gestures.ChartGestureEvent) MouseEventWrapper(net.sf.mzmine.chartbasics.gui.wrapper.MouseEventWrapper) Entity(net.sf.mzmine.chartbasics.gestures.ChartGesture.Entity) ChartEntity(org.jfree.chart.entity.ChartEntity)

Example 5 with MouseEventWrapper

use of net.sf.mzmine.chartbasics.gui.wrapper.MouseEventWrapper in project mzmine2 by mzmine.

the class ChartGestureMouseAdapterFX method handleMouseReleased.

/**
 * @param canvas the canvas ({@code null} not permitted).
 * @param e the event ({@code null} not permitted).
 */
@Override
public void handleMouseReleased(ChartCanvas chartPanel, MouseEvent eOrig) {
    if (gestureHandlers == null || gestureHandlers.isEmpty() || !listensFor(Event.RELEASED))
        return;
    MouseEventWrapper e = new MouseEventWrapper(eOrig);
    ChartEntity entity = findChartEntity(e);
    ChartGesture.Entity gestureEntity = ChartGesture.getGestureEntity(entity);
    Button button = Button.getButton(e.getButton());
    // last gesture was dragged? keep the same chartEntity
    if (lastDragEvent != null) {
        entity = lastDragEvent.getEntity();
        gestureEntity = lastDragEvent.getGesture().getEntity();
    }
    // handle event
    handleEvent(new ChartGestureEvent(cw, e, entity, new ChartGesture(gestureEntity, Event.RELEASED, button)));
    // reset drag
    lastDragEvent = null;
}
Also used : ChartGesture(net.sf.mzmine.chartbasics.gestures.ChartGesture) Button(net.sf.mzmine.chartbasics.gestures.ChartGesture.Button) ChartGestureEvent(net.sf.mzmine.chartbasics.gestures.ChartGestureEvent) MouseEventWrapper(net.sf.mzmine.chartbasics.gui.wrapper.MouseEventWrapper) Entity(net.sf.mzmine.chartbasics.gestures.ChartGesture.Entity) ChartEntity(org.jfree.chart.entity.ChartEntity)

Aggregations

MouseEventWrapper (net.sf.mzmine.chartbasics.gui.wrapper.MouseEventWrapper)8 ChartGesture (net.sf.mzmine.chartbasics.gestures.ChartGesture)6 Button (net.sf.mzmine.chartbasics.gestures.ChartGesture.Button)6 Entity (net.sf.mzmine.chartbasics.gestures.ChartGesture.Entity)6 ChartGestureEvent (net.sf.mzmine.chartbasics.gestures.ChartGestureEvent)6 ChartEntity (org.jfree.chart.entity.ChartEntity)6 Point2D (java.awt.geom.Point2D)2 ChartViewWrapper (net.sf.mzmine.chartbasics.gui.wrapper.ChartViewWrapper)2 Consumer (java.util.function.Consumer)1 ZoomHistory (net.sf.mzmine.chartbasics.listener.ZoomHistory)1 JFreeChart (org.jfree.chart.JFreeChart)1 ValueAxis (org.jfree.chart.axis.ValueAxis)1 TitleEntity (org.jfree.chart.entity.TitleEntity)1 Range (org.jfree.data.Range)1