Example usage for org.jfree.data.xy XYSeriesCollection getSeries

List of usage examples for org.jfree.data.xy XYSeriesCollection getSeries

Introduction

In this page you can find the example usage for org.jfree.data.xy XYSeriesCollection getSeries.

Prototype

public List getSeries() 

Source Link

Document

Returns a list of all the series in the collection.

Usage

From source file:org.fhcrc.cpl.viewer.mrm.Utils.java

public static double getWeightedAverageDaughtersTime(XYSeriesCollection daughterSet) {
    double retVal = 0.0;
    double yTot = 0.0;
    double xWeight = 0.0;
    for (Object xyso : daughterSet.getSeries()) {
        XYSeries xys = (XYSeries) xyso;//from   w  ww  . j  a va 2 s.  co  m
        for (Object xydio : xys.getItems()) {
            XYDataItem xydi = (XYDataItem) xydio;
            xWeight += (xydi.getX().doubleValue() * xydi.getY().doubleValue());
            yTot += xydi.getY().doubleValue();
        }
    }
    if (yTot > 0)
        retVal = xWeight / yTot;
    return retVal;
}

From source file:edu.fullerton.viewerplugin.PluginSupport.java

public static void getRangeLimits(XYSeriesCollection mtds, Double[] rng, int skip, float xmin, float xmax) {
    Double minx, miny, maxx, maxy;

    minx = miny = Double.MAX_VALUE;

    maxx = maxy = -Double.MAX_VALUE;
    for (Iterator it = mtds.getSeries().iterator(); it.hasNext();) {

        XYSeries ds = (XYSeries) it.next();
        for (int item = skip; item < ds.getItemCount() - skip; item++) {
            double x = ds.getX(item).doubleValue();
            double y = ds.getY(item).doubleValue();

            if (x >= xmin && x <= xmax) {
                minx = Math.min(minx, x);
                miny = Math.min(miny, y);
                maxx = Math.max(maxx, x);
                maxy = Math.max(maxy, y);
            }/*  w  w w.  j  a v  a 2 s  . co  m*/
        }
    }
    rng[0] = minx;
    rng[1] = miny;
    rng[2] = maxx;
    rng[3] = maxy;
}

From source file:sim.util.media.chart.TimeSeriesChartGenerator.java

public void moveSeries(int index, boolean up) {
    super.moveSeries(index, up);

    if ((index > 0 && up) || (index < getSeriesCount() - 1 && !up)) // it's not the first or the last given the move
    {//w w w.  j av  a 2  s  .com
        XYSeriesCollection xysc = (XYSeriesCollection) getSeriesDataset();
        // this requires removing everything from the dataset and resinserting, duh
        ArrayList items = new ArrayList(xysc.getSeries());
        xysc.removeAllSeries();

        int delta = up ? -1 : 1;
        // now rearrange
        items.add(index + delta, items.remove(index));

        // rebuild the dataset
        for (int i = 0; i < items.size(); i++)
            xysc.addSeries(((XYSeries) (items.get(i))));
    }
}

From source file:edu.gmu.cs.sim.util.media.chart.TimeSeriesChartGenerator.java

public void moveSeries(int index, boolean up) {
    super.moveSeries(index, up);

    if ((index > 0 && up) || (index < getSeriesCount() - 1 && !up)) // it's not the first or the last given the move
    {//from w w w  .j a v  a2s .co  m
        XYSeriesCollection xysc = (XYSeriesCollection) getSeriesDataset();
        // this requires removing everything from the dataset and resinserting, duh
        ArrayList items = new ArrayList(xysc.getSeries());
        xysc.removeAllSeries();

        int delta = up ? -1 : 1;
        // now rearrange
        items.add(index + delta, items.remove(index));

        // rebuild the dataset
        for (int i = 0; i < items.size(); i++) {
            xysc.addSeries(((XYSeries) (items.get(i))));
        }
    }
}

From source file:com.compomics.cell_coord.gui.controller.summary.VisualizeTracksController.java

/**
 * Given the number of columns to use, set the charts with the
 * xySeriesCollections generated./*  w  w w .jav a 2s  .c om*/
 *
 * @param nCols
 */
private void setChartsWithCollections(int nCols) {
    List<Sample> samples = loadTracksController.getSamples();
    int nPlots = xYSeriesCollections.size();
    for (int i = 0; i < nPlots; i++) {
        XYSeriesCollection collection = xYSeriesCollections.get(i);
        int numberTracks = collection.getSeries().size();
        String title = numberTracks + " tracks" + " - " + samples.get(i).getName();
        // create a chart for each plate condition
        JFreeChart coordinatesChart = ChartFactory.createXYLineChart(title, "x (m)", "y (m)", collection,
                PlotOrientation.VERTICAL, false, true, false);
        // and a new chart panel as well
        ChartPanel coordinatesChartPanel = new ChartPanel(null);
        coordinatesChartPanel.setOpaque(false);
        // compute the constraints
        GridBagConstraints specialGBC = getGridBagConstraints(nPlots, i, nCols);
        visualizeTracksPanel.getTracksGraphicsParentPanel().add(coordinatesChartPanel, specialGBC);
        if (visualizeTracksPanel.getScaleAxesRadioButton().isSelected()) {
            scaleAxes(coordinatesChart, visualizeTracksPanel.getRawCoordRadioButton().isSelected());
        }
        coordinatesChartPanel.setChart(coordinatesChart);
        // add the chart panels to the list
        tracksChartPanels.add(coordinatesChartPanel);
        visualizeTracksPanel.getTracksGraphicsParentPanel().revalidate();
        visualizeTracksPanel.getTracksGraphicsParentPanel().repaint();
    }
}

From source file:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.GlobalViewConditionController.java

/**
 * Iterate through the current track data holders and get the endpoints of
 * the correspondent tracks.//from   w ww .  j  a  v a  2 s  . c om
 *
 * @return: a List of Integers, each Integer being the endpoint for a track.
 */
private List<Integer> getEndPoints(XYSeriesCollection xYSeriesCollection) {
    List<Integer> endPoints = new ArrayList<>();
    for (int i = 0; i < xYSeriesCollection.getSeries().size(); i++) {
        endPoints.add(xYSeriesCollection.getSeries(i).getItemCount());
    }
    return endPoints;
}

From source file:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.GlobalViewConditionController.java

/**
 * Set all the charts with the generated XYSeriesCollections.
 *
 * @param nCols//from  ww w  .j a v  a2 s.  c om
 */
private void setChartsWithCollections(int nCols) {
    // plot logic
    boolean plotLines = plotSettingsMenuBar.getPlotLinesCheckBoxMenuItem().isSelected();
    boolean plotPoints = plotSettingsMenuBar.getPlotPointsCheckBoxMenuItem().isSelected();
    boolean showEndPoints = plotSettingsMenuBar.getShowEndPointsCheckBoxMenuItem().isSelected();
    Float lineWidth = plotSettingsMenuBar.getSelectedLineWidth();
    boolean useCellMissyColor = plotSettingsMenuBar.getUseCellMissyColors().isSelected();
    int nPlots = xYSeriesCollections.size();
    int length = GuiUtils.getAvailableColors().length;
    for (int i = 0; i < nPlots; i++) {
        XYSeriesCollection collection = xYSeriesCollections.get(i);
        int numberTracks = collection.getSeries().size();
        SingleCellConditionDataHolder conditionDataHolder = trackCoordinatesController
                .getConditionDataHolder(trackCoordinatesController.getCurrentCondition());
        String title = numberTracks + " tracks" + " - "
                + conditionDataHolder.getSingleCellWellDataHolders().get(i).getWell();
        // create a chart for each plate condition
        JFreeChart coordinatesChart = ChartFactory.createXYLineChart(title, "x (m)", "y (m)", collection,
                PlotOrientation.VERTICAL, false, true, false);
        // and a new chart panel as well
        ChartPanel coordinatesChartPanel = new ChartPanel(null);
        coordinatesChartPanel.setOpaque(false);

        // compute the constraints
        GridBagConstraints tempBagConstraints = GuiUtils.getTempBagConstraints(nPlots, i, nCols);
        trackCoordinatesController.getTrackCoordinatesPanel().getGlobalViewConditionParentPanel()
                .add(coordinatesChartPanel, tempBagConstraints);
        // see if exes need to be scaled
        if (plotOptionsPanel.getScaleAxesRadioButton().isSelected()) {
            trackCoordinatesController.scaleAxesToExperiment(coordinatesChart,
                    plotOptionsPanel.getUnshiftedCoordinatesRadioButton().isSelected());
        }
        JFreeChartUtils.setupTrackChart(coordinatesChart);
        TrackXYLineAndShapeRenderer trackXYLineAndShapeRenderer = new TrackXYLineAndShapeRenderer(plotLines,
                plotPoints, showEndPoints, getEndPoints(collection), -1, lineWidth, useCellMissyColor);
        trackXYLineAndShapeRenderer.setChosenColor(GuiUtils.getAvailableColors()[i % length]);
        coordinatesChart.getXYPlot().setRenderer(trackXYLineAndShapeRenderer);
        coordinatesChartPanel.setChart(coordinatesChart);

        // add the chart panels to the list
        coordinatesChartPanels.add(coordinatesChartPanel);
        trackCoordinatesController.getTrackCoordinatesPanel().getGlobalViewConditionParentPanel().revalidate();
        trackCoordinatesController.getTrackCoordinatesPanel().getGlobalViewConditionParentPanel().repaint();
    }
}

From source file:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.GlobalViewExperimentController.java

/**
 * Set all the charts with the generated XYSeriesCollections.
 *
 * @param nCols/*from  w  w w .  ja v a2  s .com*/
 */
private void setChartsWithCollections(int nCols) {
    // plot logic
    boolean plotLines = plotSettingsMenuBar.getPlotLinesCheckBoxMenuItem().isSelected();
    boolean plotPoints = plotSettingsMenuBar.getPlotPointsCheckBoxMenuItem().isSelected();
    boolean showEndPoints = plotSettingsMenuBar.getShowEndPointsCheckBoxMenuItem().isSelected();
    Float lineWidth = plotSettingsMenuBar.getSelectedLineWidth();
    boolean useCellMissyColor = plotSettingsMenuBar.getUseCellMissyColors().isSelected();
    int nPlots = xYSeriesCollections.size();
    int length = GuiUtils.getAvailableColors().length;
    List<PlateCondition> plateConditionList = trackCoordinatesController.getPlateConditionList();
    for (int i = 0; i < nPlots; i++) {
        XYSeriesCollection collection = xYSeriesCollections.get(i);
        int numberTracks = collection.getSeries().size();
        String title = numberTracks + " tracks" + " - " + plateConditionList.get(i);
        // create a chart for each plate condition
        JFreeChart coordinatesChart = ChartFactory.createXYLineChart(title, "x (m)", "y (m)", collection,
                PlotOrientation.VERTICAL, false, true, false);
        // and a new chart panel as well
        ChartPanel coordinatesChartPanel = new ChartPanel(null);
        coordinatesChartPanel.setOpaque(false);

        // compute the constraints
        GridBagConstraints tempBagConstraints = GuiUtils.getTempBagConstraints(nPlots, i, nCols);
        trackCoordinatesController.getTrackCoordinatesPanel().getGlobalViewExpParentPanel()
                .add(coordinatesChartPanel, tempBagConstraints);
        // see if exes need to be scaled
        if (plotOptionsPanel.getScaleAxesRadioButton().isSelected()) {
            trackCoordinatesController.scaleAxesToExperiment(coordinatesChart,
                    plotOptionsPanel.getUnshiftedCoordinatesRadioButton().isSelected());
        }
        JFreeChartUtils.setupTrackChart(coordinatesChart);
        TrackXYLineAndShapeRenderer trackXYLineAndShapeRenderer = new TrackXYLineAndShapeRenderer(plotLines,
                plotPoints, showEndPoints, getEndPoints(collection), -1, lineWidth, useCellMissyColor);
        trackXYLineAndShapeRenderer.setChosenColor(GuiUtils.getAvailableColors()[i % length]);
        coordinatesChart.getXYPlot().setRenderer(trackXYLineAndShapeRenderer);
        coordinatesChartPanel.setChart(coordinatesChart);

        // add the chart panels to the list
        coordinatesChartPanels.add(coordinatesChartPanel);
        trackCoordinatesController.getTrackCoordinatesPanel().getGlobalViewExpParentPanel().revalidate();
        trackCoordinatesController.getTrackCoordinatesPanel().getGlobalViewExpParentPanel().repaint();
    }
}

From source file:org.lmn.fc.frameworks.starbase.plugins.observatory.ui.tabs.charts.GpsScatterPlotUIComponent.java

/***********************************************************************************************
 * Update the existing Chart referenced by the DAO, by applying the specified datasets.
 * No Channel selection or DatasetDomain adjustment is allowed,
 * so just re-apply the original dataset.
 * This Chart does not use secondary datasets (yet).
 *
 * @param dao//from   ww w. j  a  v  a  2s  . c o  m
 * @param datasettype
 * @param primarydataset
 * @param secondarydatasets
 * @param displaylimit
 * @param domainstartpoint
 * @param domainendpoint
 * @param channelselector
 * @param debug
 */

public void updateChartForSelection(final ObservatoryInstrumentDAOInterface dao, final DatasetType datasettype,
        final XYDataset primarydataset, final List<XYDataset> secondarydatasets, final int displaylimit,
        final int domainstartpoint, final int domainendpoint,
        final ChannelSelectorUIComponentInterface channelselector, final boolean debug) {
    final String SOURCE = "GpsScatterPlotUIComponent.updateChartForSelection() ";

    LOGGER.debug(debug, SOURCE);

    if ((dao != null) && (dao.getChartUI() != null) && (dao.getChartUI().getChartPanel() != null)
            && (dao.getChartUI().getChartPanel().getChart() != null)
            && (dao.getChartUI().getChartPanel().getChart().getXYPlot() != null) && (datasettype != null)
            && (primarydataset != null)) {
        // Confirm the DatasetType
        if ((datasettype.getName().equals(DatasetType.XY.getName()))
                && (primarydataset instanceof XYSeriesCollection)) {
            final XYSeriesCollection collectionPrimary;

            // There should be a collection of <channelcount> XYSeries in the Primary Dataset
            collectionPrimary = (XYSeriesCollection) primarydataset;

            if ((collectionPrimary.getSeriesCount() > 0) && (collectionPrimary.getSeries() != null)) {
                LOGGER.debug(debug, SOURCE + "Update the data shown on existing Chart");

                // No Channel selection or DatasetDomain adjustment is allowed,
                // so just re-apply the original dataset
                // This Chart does not use secondary datasets (yet)
                dao.getChartUI().getChartPanel().getChart().getXYPlot().setDataset(INDEX_DATA,
                        collectionPrimary);
                updateCentroidCrosshairs();
            } else {
                LOGGER.error(SOURCE + " The XYSeriesCollection does not have any XYSeries");
            }
        } else {
            LOGGER.error(SOURCE + " The Dataset is of an invalid type");
        }
    } else {
        LOGGER.debug(debug, SOURCE + " Unable to change the Chart - invalid parameters");
    }
}

From source file:userinterface.graph.PrismErrorRenderer.java

/**
 * This method is needed for displaying the graph in the correct range (not too zoomed out or in)
 * @param dataset the dataset which needs to be plotted
 * @author Muhammad Omer Saeed//from w  w  w  .  j  a  v  a 2s  . c  o  m
 */

public Range findRangeBounds(XYDataset dataset) {

    if (dataset != null) {

        XYSeriesCollection collection = (XYSeriesCollection) dataset;
        List<XYSeries> series = collection.getSeries();
        double max = Double.MIN_VALUE, min = Double.MAX_VALUE;

        for (XYSeries s : series) {
            for (int i = 0; i < s.getItemCount(); i++) {
                PrismXYDataItem item = (PrismXYDataItem) s.getDataItem(i);

                if ((item.getYValue() - item.getError()) < min) {
                    min = (item.getYValue() - item.getError());
                }

                if ((item.getYValue() + item.getError()) > max) {
                    max = (item.getYValue() + item.getError());
                }
            }
        }

        if (max == Double.MIN_VALUE && min == Double.MAX_VALUE) {
            return null;
        } else
            return new Range(min, max);
    } else {
        return null;
    }
}