Search in sources :

Example 11 with ChartGesture

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

Example 12 with ChartGesture

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");
    }
}
Also used : Color(java.awt.Color) StringComponent(net.sf.mzmine.parameters.parametertypes.StringComponent) Arrays(java.util.Arrays) FileAndPathUtil(net.sf.mzmine.util.files.FileAndPathUtil) ChartGestureHandler(net.sf.mzmine.chartbasics.gestures.ChartGestureHandler) ValueMarker(org.jfree.chart.plot.ValueMarker) MultiChoiceComponent(net.sf.mzmine.parameters.parametertypes.MultiChoiceComponent) ParameterSet(net.sf.mzmine.parameters.ParameterSet) Event(net.sf.mzmine.chartbasics.gestures.ChartGesture.Event) JFileChooser(javax.swing.JFileChooser) BorderLayout(java.awt.BorderLayout) JComboBox(javax.swing.JComboBox) Image(java.awt.Image) Key(net.sf.mzmine.chartbasics.gestures.ChartGesture.Key) Font(java.awt.Font) Range(com.google.common.collect.Range) MZRangeComponent(net.sf.mzmine.parameters.parametertypes.ranges.MZRangeComponent) Icon(javax.swing.Icon) Logger(java.util.logging.Logger) StandardCharsets(java.nio.charset.StandardCharsets) Box(javax.swing.Box) ChartGestureDragDiffEvent(net.sf.mzmine.chartbasics.gestures.ChartGestureDragDiffEvent) Dimension(java.awt.Dimension) List(java.util.List) Stream(java.util.stream.Stream) XYDataset(org.jfree.data.xy.XYDataset) Entry(java.util.Map.Entry) JCheckBox(javax.swing.JCheckBox) Entity(net.sf.mzmine.chartbasics.gestures.ChartGesture.Entity) RTRangeComponent(net.sf.mzmine.parameters.parametertypes.ranges.RTRangeComponent) BasicStroke(java.awt.BasicStroke) JPanel(javax.swing.JPanel) MZmineCore(net.sf.mzmine.main.MZmineCore) ColorPalettes(net.sf.mzmine.util.ColorPalettes) JTextField(javax.swing.JTextField) FileNameExtensionFilter(javax.swing.filechooser.FileNameExtensionFilter) MzRangeFormulaCalculatorModule(net.sf.mzmine.modules.tools.mzrangecalculator.MzRangeFormulaCalculatorModule) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) ArrayUtils(org.apache.commons.lang3.ArrayUtils) NumberFormat(java.text.NumberFormat) Button(net.sf.mzmine.chartbasics.gestures.ChartGesture.Button) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) GridLayout(java.awt.GridLayout) IntegerComponent(net.sf.mzmine.parameters.parametertypes.IntegerComponent) FileNameComponent(net.sf.mzmine.parameters.parametertypes.filenames.FileNameComponent) DelayedDocumentListener(net.sf.mzmine.framework.listener.DelayedDocumentListener) Files(com.google.common.io.Files) ChartGesture(net.sf.mzmine.chartbasics.gestures.ChartGesture) TxtWriter(net.sf.mzmine.util.io.TxtWriter) ImageIcon(javax.swing.ImageIcon) TICPlot(net.sf.mzmine.modules.visualization.tic.TICPlot) ParameterSetupDialog(net.sf.mzmine.parameters.dialogs.ParameterSetupDialog) BoxLayout(javax.swing.BoxLayout) Stroke(java.awt.Stroke) FlowLayout(java.awt.FlowLayout) MZTolerance(net.sf.mzmine.parameters.parametertypes.tolerances.MZTolerance) JButton(javax.swing.JButton) KovatsIndex(net.sf.mzmine.modules.tools.kovats.KovatsValues.KovatsIndex) TICPlotType(net.sf.mzmine.modules.visualization.tic.TICPlotType) MigLayout(net.miginfocom.swing.MigLayout) Window(java.awt.Window) DecimalFormat(java.text.DecimalFormat) RawDataFilesSelection(net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesSelection) TICSumDataSet(net.sf.mzmine.modules.visualization.tic.TICSumDataSet) IOException(java.io.IOException) IonizationType(net.sf.mzmine.datamodel.IonizationType) File(java.io.File) Consumer(java.util.function.Consumer) RectangleInsets(org.jfree.chart.ui.RectangleInsets) TreeMap(java.util.TreeMap) ChartGestureDragDiffHandler(net.sf.mzmine.chartbasics.gestures.ChartGestureDragDiffHandler) JLabel(javax.swing.JLabel) RawDataFilesSelectionType(net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesSelectionType) DialogLoggerUtil(net.sf.mzmine.util.DialogLoggerUtil) DoubleComponent(net.sf.mzmine.parameters.parametertypes.DoubleComponent) MZRangeComponent(net.sf.mzmine.parameters.parametertypes.ranges.MZRangeComponent) TICSumDataSet(net.sf.mzmine.modules.visualization.tic.TICSumDataSet) IOException(java.io.IOException) ChartGesture(net.sf.mzmine.chartbasics.gestures.ChartGesture) RTRangeComponent(net.sf.mzmine.parameters.parametertypes.ranges.RTRangeComponent) TICPlot(net.sf.mzmine.modules.visualization.tic.TICPlot) ChartGestureDragDiffHandler(net.sf.mzmine.chartbasics.gestures.ChartGestureDragDiffHandler) Key(net.sf.mzmine.chartbasics.gestures.ChartGesture.Key) ChartGestureHandler(net.sf.mzmine.chartbasics.gestures.ChartGestureHandler)

Example 13 with ChartGesture

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

Example 14 with ChartGesture

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);
}
Also used : ChartGesture(net.sf.mzmine.chartbasics.gestures.ChartGesture) ChartGestureHandler(net.sf.mzmine.chartbasics.gestures.ChartGestureHandler)

Example 15 with ChartGesture

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);
}
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

ChartGesture (net.sf.mzmine.chartbasics.gestures.ChartGesture)17 Button (net.sf.mzmine.chartbasics.gestures.ChartGesture.Button)15 Entity (net.sf.mzmine.chartbasics.gestures.ChartGesture.Entity)15 ChartGestureEvent (net.sf.mzmine.chartbasics.gestures.ChartGestureEvent)14 ChartEntity (org.jfree.chart.entity.ChartEntity)14 ChartPanel (org.jfree.chart.ChartPanel)8 MouseEventWrapper (net.sf.mzmine.chartbasics.gui.wrapper.MouseEventWrapper)6 ChartGestureHandler (net.sf.mzmine.chartbasics.gestures.ChartGestureHandler)3 Range (com.google.common.collect.Range)1 Files (com.google.common.io.Files)1 BasicStroke (java.awt.BasicStroke)1 BorderLayout (java.awt.BorderLayout)1 Color (java.awt.Color)1 Dimension (java.awt.Dimension)1 FlowLayout (java.awt.FlowLayout)1 Font (java.awt.Font)1 GridLayout (java.awt.GridLayout)1 Image (java.awt.Image)1 Stroke (java.awt.Stroke)1 Window (java.awt.Window)1