Search in sources :

Example 96 with ValueAxis

use of org.jfree.chart.axis.ValueAxis in project mafscaling by vimsh.

the class MafRescale method createGraghPanel.

private void createGraghPanel(JPanel dataPanel) {
    JFreeChart chart = ChartFactory.createScatterPlot(null, null, null, null, PlotOrientation.VERTICAL, false, true, false);
    chart.setBorderVisible(true);
    mafChartPanel = new MafChartPanel(chart, this);
    GridBagConstraints gbl_chartPanel = new GridBagConstraints();
    gbl_chartPanel.anchor = GridBagConstraints.PAGE_START;
    gbl_chartPanel.insets = insets0;
    gbl_chartPanel.fill = GridBagConstraints.BOTH;
    gbl_chartPanel.weightx = 1.0;
    gbl_chartPanel.weighty = 1.0;
    gbl_chartPanel.gridx = 0;
    gbl_chartPanel.gridy = 2;
    dataPanel.add(mafChartPanel.getChartPanel(), gbl_chartPanel);
    XYSplineRenderer lineRenderer = new XYSplineRenderer(3);
    lineRenderer.setUseFillPaint(true);
    lineRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new DecimalFormat("0.00"), new DecimalFormat("0.00")));
    Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, null, 0.0f);
    lineRenderer.setSeriesStroke(0, stroke);
    lineRenderer.setSeriesStroke(1, stroke);
    lineRenderer.setSeriesPaint(0, new Color(201, 0, 0));
    lineRenderer.setSeriesPaint(1, new Color(0, 0, 255));
    lineRenderer.setSeriesShape(0, ShapeUtilities.createDiamond((float) 2.5));
    lineRenderer.setSeriesShape(1, ShapeUtilities.createUpTriangle((float) 2.5));
    ValueAxis mafvDomain = new NumberAxis(XAxisName);
    ValueAxis mafgsRange = new NumberAxis(YAxisName);
    XYSeriesCollection lineDataset = new XYSeriesCollection();
    lineDataset.addSeries(currMafData);
    lineDataset.addSeries(corrMafData);
    XYPlot plot = chart.getXYPlot();
    plot.setRangePannable(true);
    plot.setDomainPannable(true);
    plot.setDomainGridlinePaint(Color.DARK_GRAY);
    plot.setRangeGridlinePaint(Color.DARK_GRAY);
    plot.setBackgroundPaint(new Color(224, 224, 224));
    plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD);
    plot.setDataset(0, lineDataset);
    plot.setRenderer(0, lineRenderer);
    plot.setDomainAxis(0, mafvDomain);
    plot.setRangeAxis(0, mafgsRange);
    plot.mapDatasetToDomainAxis(0, 0);
    plot.mapDatasetToRangeAxis(0, 0);
    LegendTitle legend = new LegendTitle(plot.getRenderer());
    legend.setItemFont(new Font("Arial", 0, 10));
    legend.setPosition(RectangleEdge.TOP);
    chart.addLegend(legend);
}
Also used : BasicStroke(java.awt.BasicStroke) GridBagConstraints(java.awt.GridBagConstraints) Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) NumberAxis(org.jfree.chart.axis.NumberAxis) XYSplineRenderer(org.jfree.chart.renderer.xy.XYSplineRenderer) DecimalFormat(java.text.DecimalFormat) Color(java.awt.Color) LegendTitle(org.jfree.chart.title.LegendTitle) JFreeChart(org.jfree.chart.JFreeChart) Font(java.awt.Font) StandardXYToolTipGenerator(org.jfree.chart.labels.StandardXYToolTipGenerator) XYPlot(org.jfree.chart.plot.XYPlot) ValueAxis(org.jfree.chart.axis.ValueAxis) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection)

Example 97 with ValueAxis

use of org.jfree.chart.axis.ValueAxis in project mzmine2 by mzmine.

the class MSMSLibrarySubmissionWindow method setOnlyShowOneAxis.

public void setOnlyShowOneAxis(boolean onlyShowOneAxis) {
    int i = 0;
    forAllCharts(c -> {
        // show only the last domain axes
        ValueAxis axis = c.getXYPlot().getDomainAxis();
        axis.setVisible(!onlyShowOneAxis || i >= group.size());
    });
}
Also used : ValueAxis(org.jfree.chart.axis.ValueAxis) DataPoint(net.sf.mzmine.datamodel.DataPoint)

Example 98 with ValueAxis

use of org.jfree.chart.axis.ValueAxis in project mzmine2 by mzmine.

the class SpectralMatchPanel method rangeHasChanged.

/**
 * Apply changes to all other charts
 *
 * @param range
 */
private void rangeHasChanged(Range range) {
    if (setCoupleZoomY) {
        ValueAxis axis = libraryPlot.getRangeAxis();
        if (!axis.getRange().equals(range))
            axis.setRange(range);
        ValueAxis axisQuery = queryPlot.getRangeAxis();
        if (!axisQuery.getRange().equals(range))
            axisQuery.setRange(range);
    }
}
Also used : ValueAxis(org.jfree.chart.axis.ValueAxis)

Example 99 with ValueAxis

use of org.jfree.chart.axis.ValueAxis in project mzmine2 by mzmine.

the class SpectralMatchPanel method coupleZoomYListener.

private void coupleZoomYListener() {
    CombinedDomainXYPlot domainPlot = (CombinedDomainXYPlot) mirrorChart.getChart().getXYPlot();
    NumberAxis axis = (NumberAxis) domainPlot.getDomainAxis();
    axis.setLabel("m/z");
    queryPlot = (XYPlot) domainPlot.getSubplots().get(0);
    libraryPlot = (XYPlot) domainPlot.getSubplots().get(1);
    queryPlot.getRangeAxis().addChangeListener(new AxisRangeChangedListener(null) {

        @Override
        public void axisRangeChanged(ChartViewWrapper chart, ValueAxis axis, Range lastR, Range newR) {
            rangeHasChanged(newR);
        }
    });
    libraryPlot.getRangeAxis().addChangeListener(new AxisRangeChangedListener(null) {

        @Override
        public void axisRangeChanged(ChartViewWrapper chart, ValueAxis axis, Range lastR, Range newR) {
            rangeHasChanged(newR);
        }
    });
}
Also used : ChartViewWrapper(net.sf.mzmine.chartbasics.gui.wrapper.ChartViewWrapper) NumberAxis(org.jfree.chart.axis.NumberAxis) AxisRangeChangedListener(net.sf.mzmine.chartbasics.listener.AxisRangeChangedListener) ValueAxis(org.jfree.chart.axis.ValueAxis) Range(org.jfree.data.Range) CombinedDomainXYPlot(org.jfree.chart.plot.CombinedDomainXYPlot)

Example 100 with ValueAxis

use of org.jfree.chart.axis.ValueAxis in project mzmine2 by mzmine.

the class MultiMSMSWindow method renewCharts.

/**
 * @param group
 */
public void renewCharts(ChartGroup group) {
    pnCharts.removeAll();
    if (group != null && group.size() > 0) {
        realCol = autoCol ? (int) Math.floor(Math.sqrt(group.size())) - 1 : col;
        if (realCol < 1)
            realCol = 1;
        GridLayout layout = new GridLayout(0, realCol);
        pnCharts.setLayout(layout);
        // add to layout
        int i = 0;
        for (ChartViewWrapper cp : group.getList()) {
            // show only the last domain axes
            ValueAxis axis = cp.getChart().getXYPlot().getDomainAxis();
            axis.setVisible(!onlyShowOneAxis || i >= group.size() - realCol);
            pnCharts.add(cp.getChartSwing());
            i++;
        }
    }
    pnCharts.revalidate();
    pnCharts.repaint();
}
Also used : GridLayout(java.awt.GridLayout) ChartViewWrapper(net.sf.mzmine.chartbasics.gui.wrapper.ChartViewWrapper) ValueAxis(org.jfree.chart.axis.ValueAxis)

Aggregations

ValueAxis (org.jfree.chart.axis.ValueAxis)216 XYPlot (org.jfree.chart.plot.XYPlot)77 NumberAxis (org.jfree.chart.axis.NumberAxis)50 Range (org.jfree.data.Range)40 JFreeChart (org.jfree.chart.JFreeChart)39 CategoryPlot (org.jfree.chart.plot.CategoryPlot)35 Paint (java.awt.Paint)31 CategoryAxis (org.jfree.chart.axis.CategoryAxis)30 Rectangle2D (java.awt.geom.Rectangle2D)28 CombinedDomainXYPlot (org.jfree.chart.plot.CombinedDomainXYPlot)25 Test (org.junit.Test)24 CombinedRangeXYPlot (org.jfree.chart.plot.CombinedRangeXYPlot)22 XYDataset (org.jfree.data.xy.XYDataset)22 Iterator (java.util.Iterator)20 XYItemRenderer (org.jfree.chart.renderer.xy.XYItemRenderer)18 CategoryDataset (org.jfree.data.category.CategoryDataset)17 RectangleEdge (org.jfree.ui.RectangleEdge)16 Font (java.awt.Font)14 XYSeries (org.jfree.data.xy.XYSeries)14 XYSeriesCollection (org.jfree.data.xy.XYSeriesCollection)14