Search in sources :

Example 1 with EChartPanel

use of net.sf.mzmine.chartbasics.gui.swing.EChartPanel in project mzmine2 by mzmine.

the class ScanSelectPanel method applySelectionState.

private void applySelectionState() {
    boolean selected = btnToggleUse.isSelected();
    EChartPanel chart = getChart();
    if (chart != null) {
        chart.getChart().getXYPlot().setBackgroundPaint(selected ? Color.WHITE : errorColor);
    }
}
Also used : EChartPanel(net.sf.mzmine.chartbasics.gui.swing.EChartPanel)

Example 2 with EChartPanel

use of net.sf.mzmine.chartbasics.gui.swing.EChartPanel in project mzmine2 by mzmine.

the class IsotopePeakScannerSetupDialog method addDialogComponents.

@Override
protected void addDialogComponents() {
    super.addDialogComponents();
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    pnlChart = new EChartPanel(chart);
    pnlChart.setPreferredSize(new Dimension((int) (screenSize.getWidth() / 3), (int) (screenSize.getHeight() / 3)));
    pnlPreview.add(pnlChart, BorderLayout.CENTER);
    // get components
    cmpAutoCarbon = (OptionalModuleComponent) this.getComponentForParameter(IsotopePeakScannerParameters.autoCarbonOpt);
    cmpAutoCarbonCbx = (JCheckBox) cmpAutoCarbon.getComponent(0);
    cmpPreview = (JCheckBox) this.getComponentForParameter(IsotopePeakScannerParameters.showPreview);
    // i want to have the checkbox below the pattern settings
    cmpPreview.setSelected(false);
    // but it should be disabled by default. Thats why it's hardcoded here.
    // get parameters
    pElement = parameterSet.getParameter(IsotopePeakScannerParameters.element);
    pMinIntensity = parameterSet.getParameter(IsotopePeakScannerParameters.minPatternIntensity);
    pCharge = parameterSet.getParameter(IsotopePeakScannerParameters.charge);
    pMergeWidth = parameterSet.getParameter(IsotopePeakScannerParameters.mergeWidth);
    pAutoCarbon = parameterSet.getParameter(IsotopePeakScannerParameters.autoCarbonOpt);
    autoCarbonParameters = pAutoCarbon.getEmbeddedParameters();
    pMinC = autoCarbonParameters.getParameter(AutoCarbonParameters.minCarbon);
    pMaxC = autoCarbonParameters.getParameter(AutoCarbonParameters.maxCarbon);
    pMinSize = autoCarbonParameters.getParameter(AutoCarbonParameters.minPatternSize);
    // set up gui
    form = new NumberFormatter(NumberFormat.getInstance());
    form.setValueClass(Integer.class);
    form.setFormat(new DecimalFormat("0"));
    form.setAllowsInvalid(true);
    form.setMinimum(minC);
    form.setMaximum(maxC);
    btnPrevPattern = new JButton("Previous");
    btnPrevPattern.addActionListener(this);
    btnPrevPattern.setMinimumSize(btnPrevPattern.getPreferredSize());
    btnPrevPattern.setEnabled(cmpAutoCarbonCbx.isSelected());
    txtCurrentPatternIndex = new JFormattedTextField(form);
    txtCurrentPatternIndex.addActionListener(this);
    txtCurrentPatternIndex.setText(String.valueOf((minC + maxC) / 2));
    txtCurrentPatternIndex.setPreferredSize(new Dimension(50, 25));
    txtCurrentPatternIndex.setEditable(true);
    txtCurrentPatternIndex.setEnabled(cmpAutoCarbonCbx.isSelected());
    btnNextPattern = new JButton("Next");
    btnNextPattern.addActionListener(this);
    btnNextPattern.setPreferredSize(btnNextPattern.getMinimumSize());
    btnNextPattern.setEnabled(cmpAutoCarbonCbx.isSelected());
    chart = ChartFactory.createXYBarChart("Isotope pattern preview", "m/z", false, "Abundance", new XYSeriesCollection(new XYSeries("")));
    chart.getPlot().setBackgroundPaint(Color.WHITE);
    chart.getXYPlot().setDomainGridlinePaint(Color.GRAY);
    chart.getXYPlot().setRangeGridlinePaint(Color.GRAY);
    pnlPreviewButtons.add(btnPrevPattern);
    pnlPreviewButtons.add(txtCurrentPatternIndex);
    pnlPreviewButtons.add(btnNextPattern);
    pack();
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) EChartPanel(net.sf.mzmine.chartbasics.gui.swing.EChartPanel) DecimalFormat(java.text.DecimalFormat) JButton(javax.swing.JButton) JFormattedTextField(javax.swing.JFormattedTextField) Dimension(java.awt.Dimension) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection) NumberFormatter(javax.swing.text.NumberFormatter)

Example 3 with EChartPanel

use of net.sf.mzmine.chartbasics.gui.swing.EChartPanel in project mzmine2 by mzmine.

the class SpectrumChartFactory method createMirrorChartPanel.

public static EChartPanel createMirrorChartPanel(String labelA, double precursorMZA, double rtA, DataPoint[] dpsA, String labelB, double precursorMZB, double rtB, DataPoint[] dpsB, boolean showTitle, boolean showLegend) {
    PseudoSpectrumDataSet data = dpsA == null ? null : createMSMSDataSet(precursorMZA, rtA, dpsA, labelA);
    PseudoSpectrumDataSet dataMirror = dpsB == null ? null : createMSMSDataSet(precursorMZB, rtB, dpsB, labelB);
    NumberFormat mzForm = MZmineCore.getConfiguration().getMZFormat();
    NumberFormat intensityFormat = new DecimalFormat("0.#");
    // set the X axis (retention time) properties
    NumberAxis xAxis = new NumberAxis("m/z");
    xAxis.setNumberFormatOverride(mzForm);
    xAxis.setUpperMargin(0.08);
    xAxis.setLowerMargin(0.00);
    xAxis.setTickLabelInsets(new RectangleInsets(0, 0, 20, 20));
    xAxis.setAutoRangeIncludesZero(false);
    xAxis.setMinorTickCount(5);
    PseudoSpectraRenderer renderer1 = new PseudoSpectraRenderer(Color.BLACK, false);
    PseudoSpectraRenderer renderer2 = new PseudoSpectraRenderer(Color.BLACK, false);
    // create subplot 1...
    final NumberAxis rangeAxis1 = new NumberAxis("rel. intensity [%]");
    final XYPlot subplot1 = new XYPlot(data, null, rangeAxis1, renderer1);
    subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    rangeAxis1.setNumberFormatOverride(intensityFormat);
    rangeAxis1.setAutoRangeIncludesZero(true);
    rangeAxis1.setAutoRangeStickyZero(true);
    // create subplot 2...
    final NumberAxis rangeAxis2 = new NumberAxis("rel. intensity [%]");
    rangeAxis2.setNumberFormatOverride(intensityFormat);
    rangeAxis2.setAutoRangeIncludesZero(true);
    rangeAxis2.setAutoRangeStickyZero(true);
    rangeAxis2.setInverted(true);
    final XYPlot subplot2 = new XYPlot(dataMirror, null, rangeAxis2, renderer2);
    subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);
    // parent plot...
    final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Domain"));
    plot.setGap(0);
    // add the subplots...
    plot.add(subplot1, 1);
    plot.add(subplot2, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);
    // set the plot properties
    plot.setBackgroundPaint(Color.white);
    plot.setAxisOffset(RectangleInsets.ZERO_INSETS);
    // set rendering order
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    // set crosshair (selection) properties
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);
    // return a new chart containing the overlaid plot...
    JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    chart.setBackgroundPaint(Color.white);
    chart.getTitle().setVisible(false);
    // chart.getXYPlot().setRangeZeroBaselineVisible(true);
    chart.getTitle().setVisible(showTitle);
    chart.getLegend().setVisible(showLegend);
    return new EChartPanel(chart);
}
Also used : PseudoSpectrumDataSet(net.sf.mzmine.modules.visualization.spectra.multimsms.pseudospectra.PseudoSpectrumDataSet) EChartPanel(net.sf.mzmine.chartbasics.gui.swing.EChartPanel) NumberAxis(org.jfree.chart.axis.NumberAxis) PseudoSpectraRenderer(net.sf.mzmine.modules.visualization.spectra.multimsms.pseudospectra.PseudoSpectraRenderer) XYPlot(org.jfree.chart.plot.XYPlot) CombinedDomainXYPlot(org.jfree.chart.plot.CombinedDomainXYPlot) DecimalFormat(java.text.DecimalFormat) RectangleInsets(org.jfree.chart.ui.RectangleInsets) CombinedDomainXYPlot(org.jfree.chart.plot.CombinedDomainXYPlot) JFreeChart(org.jfree.chart.JFreeChart) NumberFormat(java.text.NumberFormat)

Example 4 with EChartPanel

use of net.sf.mzmine.chartbasics.gui.swing.EChartPanel in project mzmine2 by mzmine.

the class IsotopePatternPreviewDialog method addDialogComponents.

@Override
protected void addDialogComponents() {
    super.addDialogComponents();
    pFormula = parameterSet.getParameter(IsotopePatternPreviewParameters.formula);
    pMinIntensity = parameterSet.getParameter(IsotopePatternPreviewParameters.minIntensity);
    pMergeWidth = parameterSet.getParameter(IsotopePatternPreviewParameters.mergeWidth);
    pCharge = parameterSet.getParameter(IsotopePatternPreviewParameters.charge);
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    cmpMinIntensity = (PercentComponent) getComponentForParameter(IsotopePatternPreviewParameters.minIntensity);
    cmpMergeWidth = (DoubleComponent) getComponentForParameter(IsotopePatternPreviewParameters.mergeWidth);
    cmpCharge = (IntegerComponent) getComponentForParameter(IsotopePatternPreviewParameters.charge);
    cmpFormula = (StringComponent) getComponentForParameter(IsotopePatternPreviewParameters.formula);
    // panels
    newMainPanel = new JPanel(new BorderLayout());
    pnText = new JScrollPane();
    pnlChart = new EChartPanel(chart);
    pnSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, pnlChart, pnText);
    table = new JTable();
    pnlParameters = new JPanel(new FlowLayout());
    pnlControl = new JPanel(new BorderLayout());
    pnText.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    pnText.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    pnText.setMinimumSize(new Dimension(350, 300));
    pnlChart.setMinimumSize(new Dimension(350, 200));
    // TODO: can you do this cleaner?
    pnlChart.setPreferredSize(new Dimension((int) (screenSize.getWidth() / 3), (int) (screenSize.getHeight() / 3)));
    table.setMinimumSize(new Dimension(350, 300));
    table.setDefaultEditor(Object.class, null);
    // controls
    ttGen = new SpectraToolTipGenerator();
    theme = new EIsotopePatternChartTheme();
    theme.initialize();
    // reorganize
    getContentPane().remove(mainPanel);
    organizeParameterPanel();
    pnlControl.add(pnlParameters, BorderLayout.CENTER);
    pnlControl.add(pnlButtons, BorderLayout.SOUTH);
    newMainPanel.add(pnSplit, BorderLayout.CENTER);
    newMainPanel.add(pnlControl, BorderLayout.SOUTH);
    getContentPane().add(newMainPanel);
    pnlButtons.remove(super.btnCancel);
    chart = ChartFactory.createXYBarChart("Isotope pattern preview", "m/z", false, "Abundance", new XYSeriesCollection(new XYSeries("")));
    pnlChart.setChart(chart);
    pnText.setViewportView(table);
    updateMinimumSize();
    pack();
}
Also used : JScrollPane(javax.swing.JScrollPane) XYSeries(org.jfree.data.xy.XYSeries) JPanel(javax.swing.JPanel) EChartPanel(net.sf.mzmine.chartbasics.gui.swing.EChartPanel) FlowLayout(java.awt.FlowLayout) BorderLayout(java.awt.BorderLayout) JTable(javax.swing.JTable) Dimension(java.awt.Dimension) JSplitPane(javax.swing.JSplitPane) SpectraToolTipGenerator(net.sf.mzmine.modules.visualization.spectra.simplespectra.renderers.SpectraToolTipGenerator) EIsotopePatternChartTheme(net.sf.mzmine.chartbasics.chartthemes.EIsotopePatternChartTheme) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection)

Example 5 with EChartPanel

use of net.sf.mzmine.chartbasics.gui.swing.EChartPanel in project mzmine2 by mzmine.

the class GraphicsExportDialog method openDialogI.

protected void openDialogI(JFreeChart chart) {
    try {
        // create new chart to decouple from original chart
        JFreeChart copy = chart;
        try {
            copy = (JFreeChart) chart.clone();
        } catch (Exception e) {
            LOG.log(Level.WARNING, "Chart cannot be cloned", e);
        }
        addChartToPanel(new EChartPanel(copy), true);
        setVisible(true);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : EChartPanel(net.sf.mzmine.chartbasics.gui.swing.EChartPanel) JFreeChart(org.jfree.chart.JFreeChart)

Aggregations

EChartPanel (net.sf.mzmine.chartbasics.gui.swing.EChartPanel)11 JFreeChart (org.jfree.chart.JFreeChart)6 Dimension (java.awt.Dimension)3 BorderLayout (java.awt.BorderLayout)2 DecimalFormat (java.text.DecimalFormat)2 JButton (javax.swing.JButton)2 ChartGroup (net.sf.mzmine.chartbasics.chartgroups.ChartGroup)2 ChartViewWrapper (net.sf.mzmine.chartbasics.gui.wrapper.ChartViewWrapper)2 PeakListRow (net.sf.mzmine.datamodel.PeakListRow)2 Scan (net.sf.mzmine.datamodel.Scan)2 XYItemRenderer (org.jfree.chart.renderer.xy.XYItemRenderer)2 LegendTitle (org.jfree.chart.title.LegendTitle)2 TextTitle (org.jfree.chart.title.TextTitle)2 XYSeries (org.jfree.data.xy.XYSeries)2 XYSeriesCollection (org.jfree.data.xy.XYSeriesCollection)2 Color (java.awt.Color)1 FlowLayout (java.awt.FlowLayout)1 Font (java.awt.Font)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridLayout (java.awt.GridLayout)1