Example usage for org.jfree.data XYSeries XYSeries

List of usage examples for org.jfree.data XYSeries XYSeries

Introduction

In this page you can find the example usage for org.jfree.data XYSeries XYSeries.

Prototype

public XYSeries(final String name) 

Source Link

Document

Creates a new empty series.

Usage

From source file:de.berlios.statcvs.xml.report.CommitActivityChart.java

private XYSeries createXYSeries(String title, Iterator it) {
    XYSeries series = new XYSeries(title);

    while (it.hasNext()) {
        CvsRevision rev = (CvsRevision) it.next();

        Calendar cal = Calendar.getInstance();
        cal.setTime(rev.getDate());// w  w  w.  j a va 2s.co m
        double hour = cal.get(Calendar.HOUR_OF_DAY);
        double minutes = cal.get(Calendar.MINUTE);

        // clear time info
        cal.clear(Calendar.HOUR);
        cal.clear(Calendar.HOUR_OF_DAY);
        cal.clear(Calendar.MINUTE);
        cal.clear(Calendar.SECOND);
        cal.clear(Calendar.MILLISECOND);

        series.add(cal.getTime().getTime(), hour + (minutes / 60));
    }

    return series;
}

From source file:edu.caltechUcla.sselCassel.projects.jMarkets.shared.interfaces.PriceChart.java

public void addSecurity(String name) {
    XYSeries security = new XYSeries(name);
    lines.put(name, security);
}

From source file:edu.caltechUcla.sselCassel.projects.jMarkets.shared.interfaces.PriceChart.java

public void addSecurity(String name, float[][] points) {
    XYSeries security = new XYSeries(name);
    for (int i = 0; i < points.length; i++)
        security.add(points[i][0], points[i][1], true);
    lines.put(name, security);/* ww w  .j  a v a  2  s  . co  m*/
}

From source file:ucar.unidata.idv.control.chart.ScatterPlotChartWrapper.java

/**
 * Create the chart//from   ww w. j a va2 s.c o  m
 */
private void createChart() {
    if (chartPanel != null) {
        return;
    }
    // create a dataset...
    XYSeries series1 = new XYSeries("Series 1");
    dataset = new XYSeriesCollection(series1);

    String name = getName();
    if (name == null) {
        name = "Scatter Plot";
    }
    // create the chart...
    chart = createScatterPlot(name, "Domain", "Range", PlotOrientation.VERTICAL, true, false, false);

    initXYPlot(plot);
    plot.setRenderer(new MyRenderer(LineState.SHAPE_POINT));
    doMakeChartPanel(chart);
}

From source file:simMPLS.scenario.TReceiverStats.java

/**
 * Este mtodo reinicia los atributos de la clase, dejando las instancia como si
 * acabase de ser creada por el constructor.
 * @since 1.0/*  w w  w  .ja va 2 s. com*/
 */
public void reset() {
    paquetesEntrantes = new XYSeriesCollection();
    entrantesIPv4 = new XYSeries(TStats.IPV4);
    entrantesIPv4_GOS1 = new XYSeries(TStats.IPV4_GOS1);
    entrantesIPv4_GOS2 = new XYSeries(TStats.IPV4_GOS2);
    entrantesIPv4_GOS3 = new XYSeries(TStats.IPV4_GOS3);
    entrantesMPLS = new XYSeries(TStats.MPLS);
    entrantesMPLS_GOS1 = new XYSeries(TStats.MPLS_GOS1);
    entrantesMPLS_GOS2 = new XYSeries(TStats.MPLS_GOS2);
    entrantesMPLS_GOS3 = new XYSeries(TStats.MPLS_GOS3);
    entrantesGPSRP = new XYSeries(TStats.GPSRP);
    tEIPV4 = 0;
    tEIPV4_GOS1 = 0;
    tEIPV4_GOS2 = 0;
    tEIPV4_GOS3 = 0;
    tEMPLS = 0;
    tEMPLS_GOS1 = 0;
    tEMPLS_GOS2 = 0;
    tEMPLS_GOS3 = 0;
    tEGPSRP = 0;
}

From source file:simMPLS.scenario.TLSRStats.java

/**
 * Este mtodo reinicia los atributos de la clase, dejando la instancia como si
 * acabase de ser creada por el constructor.
 * @since 1.0/*from   w  w  w  .j a v  a  2s.com*/
 */
public void reset() {
    paquetesEntrantes = new XYSeriesCollection();
    paquetesSalientes = new XYSeriesCollection();
    paquetesDescartados = new XYSeriesCollection();
    salientesMPLS = new XYSeries(TStats.MPLS);
    salientesMPLS_GOS1 = new XYSeries(TStats.MPLS_GOS1);
    salientesMPLS_GOS2 = new XYSeries(TStats.MPLS_GOS2);
    salientesMPLS_GOS3 = new XYSeries(TStats.MPLS_GOS3);
    salientesTLDP = new XYSeries(TStats.TLDP);
    salientesGPSRP = new XYSeries(TStats.GPSRP);
    entrantesMPLS = new XYSeries(TStats.MPLS);
    entrantesMPLS_GOS1 = new XYSeries(TStats.MPLS_GOS1);
    entrantesMPLS_GOS2 = new XYSeries(TStats.MPLS_GOS2);
    entrantesMPLS_GOS3 = new XYSeries(TStats.MPLS_GOS3);
    entrantesTLDP = new XYSeries(TStats.TLDP);
    entrantesGPSRP = new XYSeries(TStats.GPSRP);
    descartadosMPLS = new XYSeries(TStats.MPLS);
    descartadosMPLS_GOS1 = new XYSeries(TStats.MPLS_GOS1);
    descartadosMPLS_GOS2 = new XYSeries(TStats.MPLS_GOS2);
    descartadosMPLS_GOS3 = new XYSeries(TStats.MPLS_GOS3);
    descartadosTLDP = new XYSeries(TStats.TLDP);
    descartadosGPSRP = new XYSeries(TStats.GPSRP);
    tEMPLS = 0;
    tEMPLS_GOS1 = 0;
    tEMPLS_GOS2 = 0;
    tEMPLS_GOS3 = 0;
    tETLDP = 0;
    tEGPSRP = 0;
    tSMPLS = 0;
    tSMPLS_GOS1 = 0;
    tSMPLS_GOS2 = 0;
    tSMPLS_GOS3 = 0;
    tSTLDP = 0;
    tSGPSRP = 0;
    tDMPLS = 0;
    tDMPLS_GOS1 = 0;
    tDMPLS_GOS2 = 0;
    tDMPLS_GOS3 = 0;
    tDTLDP = 0;
    tDGPSRP = 0;
}

From source file:simMPLS.scenario.TSenderStats.java

/**
 * Este mtodo restaura las estadsticas del emisor a su valor original com osi
 * acabasen de se creadas por el cosntructor.
 * @since 1.0/*from w  w w .ja  v a2s . c  o m*/
 */
public void reset() {
    paquetesSalientes = new XYSeriesCollection();
    paquetesDescartados = new XYSeriesCollection();
    salientesIPv4 = new XYSeries(TStats.IPV4);
    salientesIPv4_GOS1 = new XYSeries(TStats.IPV4_GOS1);
    salientesIPv4_GOS2 = new XYSeries(TStats.IPV4_GOS2);
    salientesIPv4_GOS3 = new XYSeries(TStats.IPV4_GOS3);
    salientesMPLS = new XYSeries(TStats.MPLS);
    salientesMPLS_GOS1 = new XYSeries(TStats.MPLS_GOS1);
    salientesMPLS_GOS2 = new XYSeries(TStats.MPLS_GOS2);
    salientesMPLS_GOS3 = new XYSeries(TStats.MPLS_GOS3);
    descartadosIPv4 = new XYSeries(TStats.IPV4);
    descartadosIPv4_GOS1 = new XYSeries(TStats.IPV4_GOS1);
    descartadosIPv4_GOS2 = new XYSeries(TStats.IPV4_GOS2);
    descartadosIPv4_GOS3 = new XYSeries(TStats.IPV4_GOS3);
    descartadosMPLS = new XYSeries(TStats.MPLS);
    descartadosMPLS_GOS1 = new XYSeries(TStats.MPLS_GOS1);
    descartadosMPLS_GOS2 = new XYSeries(TStats.MPLS_GOS2);
    descartadosMPLS_GOS3 = new XYSeries(TStats.MPLS_GOS3);
    tSIPV4 = 0;
    tSIPV4_GOS1 = 0;
    tSIPV4_GOS2 = 0;
    tSIPV4_GOS3 = 0;
    tSMPLS = 0;
    tSMPLS_GOS1 = 0;
    tSMPLS_GOS2 = 0;
    tSMPLS_GOS3 = 0;
    tDIPV4 = 0;
    tDIPV4_GOS1 = 0;
    tDIPV4_GOS2 = 0;
    tDIPV4_GOS3 = 0;
    tDMPLS = 0;
    tDMPLS_GOS1 = 0;
    tDMPLS_GOS2 = 0;
    tDMPLS_GOS3 = 0;
}

From source file:ucar.unidata.idv.control.chart.VerticalProfileChart.java

/**
 * Update the charts with the appropriate data
 *
 * @throws RemoteException Java RMI Exception
 * @throws VisADException  VisAD problem
 *///from  w ww .  ja va2 s . co  m
private void updateCharts() throws VisADException, RemoteException {

    if (profiles == null) {
        return;
    }
    clearLineStates();
    startLoadingData();
    try {
        initCharts();
        if ((profiles != null) && !profiles.isEmpty()) {

            XYSeries speedSeries = null;
            XYSeries dirSeries = null;
            LineState speedLineState = null;
            LineState dirLineState = null;
            Unit speedUnit = null;
            boolean polarWind = true;
            int lineIdx = 0;
            for (int paramIdx = 0; paramIdx < profiles.size(); paramIdx++) {
                VerticalProfileInfo vpInfo = (VerticalProfileInfo) profiles.get(paramIdx);
                LineState lineState = vpInfo.getLineState();
                lineState.setUseVerticalPosition(false);
                addLineState(lineState);
                lineState.setName(vpInfo.getDataInstance().getParamName());
                lineState.unit = vpInfo.getUnit();
                FieldImpl profile = vpInfo.getProfile();
                if (profile == null) {
                    continue;
                }
                FlatField oneTime;
                boolean isTimeSequence = GridUtil.isTimeSequence(profile);
                if (isTimeSequence) {
                    if (time == null) {
                        oneTime = (FlatField) profile.getSample(0);
                    } else {
                        oneTime = (FlatField) profile.evaluate(time);
                    }
                } else {
                    oneTime = (FlatField) profile;
                }
                String canonical = DataAlias.aliasToCanonical(lineState.getName());
                float[] alts = oneTime.getDomainSet().getSamples(false)[0];
                float[][] values = oneTime.getFloats(true);
                Unit[] rawUnits = ucar.visad.Util.getDefaultRangeUnits(oneTime);
                boolean haveWinds = (values.length > 1)
                        && Unit.canConvert(rawUnits[0], CommonUnit.meterPerSecond)
                        && Unit.canConvert(rawUnits[1], CommonUnit.meterPerSecond);
                for (int j = 0; j < values.length; j++) {
                    // if not winds, don't process more than one param
                    if ((j > 0) && !haveWinds) {
                        continue;
                    }
                    // only handle U & V
                    if ((j > 1) && haveWinds) {
                        break;
                    }
                    if (haveWinds) {
                        canonical = (j == 0) ? "U" : "V";
                    }
                    XYSeries series = new XYSeries(lineState.getName());

                    //float[] vals = oneTime.getFloats(true)[0];
                    float[] vals = values[j];
                    Unit rawUnit = rawUnits[j];
                    //ucar.visad.Util.getDefaultRangeUnits(oneTime)[0];
                    if ((lineState.unit != null) && Unit.canConvert(lineState.unit, rawUnit)) {
                        vals = lineState.unit.toThis(vals, rawUnit);
                    }
                    for (int i = 0; i < alts.length; i++) {
                        series.add(alts[i], vals[i]);
                    }
                    if (series != null) {
                        synchronized (MUTEX) {
                            XYItemRenderer renderer = null;
                            if (Misc.equals(canonical, "SPEED")) {
                                speedUnit = lineState.unit;
                                speedSeries = series;
                                speedLineState = lineState;
                                continue;
                            }
                            if (Misc.equals(canonical, "DIR")) {
                                dirSeries = series;
                                dirLineState = lineState;
                                continue;
                            }
                            if (Misc.equals(canonical, "U") || Misc.equals(canonical, "UREL")) {
                                speedUnit = lineState.unit;
                                speedSeries = series;
                                polarWind = false;
                                speedLineState = lineState;
                                continue;
                            }
                            if (Misc.equals(canonical, "V") || Misc.equals(canonical, "VREL")) {
                                dirSeries = series;
                                dirLineState = lineState;
                                polarWind = false;
                                continue;
                            }
                            addSeries(series, lineState, lineIdx, renderer, true);
                        }
                        lineIdx++;
                    }
                    //addSeries(series, lineState, paramIdx, null, true);
                }
            }
            if ((speedSeries != null) && (dirSeries != null)) {
                XYItemRenderer renderer = new WindbarbRenderer(speedLineState, speedSeries, dirSeries,
                        speedUnit, polarWind);
                Axis axis = addSeries(speedSeries, speedLineState, lineIdx++, renderer, true);
                if (speedLineState.getVerticalPosition() != LineState.VPOS_NONE) {
                    axis.setVisible(false);
                }
                speedSeries = null;
                dirSeries = null;
            }
            if (speedSeries != null) {
                addSeries(speedSeries, speedLineState, lineIdx++, null, true);
            }
            if (dirSeries != null) {
                addSeries(dirSeries, dirLineState, lineIdx, null, true);
            }
        }
        updateContents();
    } finally {
        doneLoadingData();
    }

}

From source file:ucar.unidata.idv.control.chart.ScatterPlotChartWrapper.java

/**
 * Create the charts/*ww  w  .  ja  v  a  2 s .  c o m*/
 *
 * @throws RemoteException On badness
 * @throws VisADException On badness
 */
public void loadData() throws VisADException, RemoteException {

    try {
        createChart();
        for (int dataSetIdx = 0; dataSetIdx < plot.getDatasetCount(); dataSetIdx++) {
            XYSeriesCollection dataset = (XYSeriesCollection) plot.getDataset(dataSetIdx);
            dataset.removeAllSeries();
        }
        ((MyScatterPlot) plot).removeAllSeries();
        Hashtable props = new Hashtable();
        props.put(TrackDataSource.PROP_TRACKTYPE, TrackDataSource.ID_TIMETRACE);

        List dataChoiceWrappers = getDataChoiceWrappers();
        int dataSetCnt = 0;
        for (int paramIdx = 0; paramIdx < dataChoiceWrappers.size(); paramIdx += 2) {
            if (paramIdx + 1 >= dataChoiceWrappers.size()) {
                break;
            }
            DataChoiceWrapper wrapper1 = (DataChoiceWrapper) dataChoiceWrappers.get(paramIdx);
            DataChoiceWrapper wrapper2 = (DataChoiceWrapper) dataChoiceWrappers.get(paramIdx + 1);

            DataChoice dataChoice1 = wrapper1.getDataChoice();
            DataChoice dataChoice2 = wrapper2.getDataChoice();

            FlatField data1 = getFlatField((FieldImpl) dataChoice1.getData(null, props));
            FlatField data2 = getFlatField((FieldImpl) dataChoice2.getData(null, props));
            Unit unit1 = ucar.visad.Util.getDefaultRangeUnits((FlatField) data1)[0];
            Unit unit2 = ucar.visad.Util.getDefaultRangeUnits((FlatField) data2)[0];

            NumberAxis rangeAxis = new NumberAxis(wrapper2.getLabel(unit2));
            NumberAxis domainAxis = new NumberAxis(wrapper1.getLabel(unit1));

            domainAxis.setAutoRange(getAutoRange());

            Color c = wrapper1.getColor(paramIdx);
            MyRenderer renderer = new MyRenderer(wrapper1.getLineState().getShape());
            domainAxis.setLabelPaint(c);
            rangeAxis.setLabelPaint(c);
            renderer.setSeriesPaint(0, c);

            double[][] samples1 = data1.getValues(false);
            double[][] samples2 = data2.getValues(false);
            double[] timeValues1 = getTimeValues(samples1, data1);
            double[] timeValues2 = getTimeValues(samples2, data2);
            double[][] values1 = filterData(samples1[0], timeValues1);
            double[][] values2 = filterData(samples2[0], timeValues2);
            if (values1.length > 1) {
                this.timeValues1 = values1[1];
                this.timeValues2 = values2[1];
            }
            double[][] values = { values1[0], values2[0] };
            ((MyScatterPlot) plot).addSeries(values);

            //Add in a dummy dataset
            XYSeriesCollection dataset = new XYSeriesCollection(new XYSeries(""));

            if (!getAutoRange()) {
                NumberAxis oldRangeAxis = (NumberAxis) plot.getRangeAxis(dataSetCnt);
                NumberAxis oldDomainAxis = (NumberAxis) plot.getDomainAxis(dataSetCnt);
                if ((oldRangeAxis != null) && (oldDomainAxis != null)) {
                    rangeAxis.setRange(oldRangeAxis.getRange());
                    domainAxis.setRange(oldDomainAxis.getRange());
                }
            }

            plot.setDataset(dataSetCnt, dataset);
            plot.setRenderer(dataSetCnt, renderer);
            plot.setRangeAxis(dataSetCnt, rangeAxis, false);
            plot.setDomainAxis(dataSetCnt, domainAxis, false);
            plot.mapDatasetToRangeAxis(dataSetCnt, dataSetCnt);
            plot.mapDatasetToDomainAxis(dataSetCnt, dataSetCnt);

            if (!getAutoRange()) {
                rangeAxis.setAutoRange(false);
                domainAxis.setAutoRange(false);
            }

            dataSetCnt++;
        }
    } catch (Exception exc) {
        LogUtil.logException("Error creating data set", exc);
    }

}

From source file:simMPLS.scenario.TLSRAStats.java

/**
 * Este mtodo reinicia los atributos de la clase, dejando las instancia como si
 * acabase de ser creada por el constructor.
 * @since 1.0//from w  w w.j  ava 2  s.c  om
 */
public void reset() {
    paquetesEntrantes = new XYSeriesCollection();
    paquetesSalientes = new XYSeriesCollection();
    paquetesDescartados = new XYSeriesCollection();
    salientesMPLS = new XYSeries(TStats.MPLS);
    salientesMPLS_GOS1 = new XYSeries(TStats.MPLS_GOS1);
    salientesMPLS_GOS2 = new XYSeries(TStats.MPLS_GOS2);
    salientesMPLS_GOS3 = new XYSeries(TStats.MPLS_GOS3);
    salientesTLDP = new XYSeries(TStats.TLDP);
    salientesGPSRP = new XYSeries(TStats.GPSRP);
    entrantesMPLS = new XYSeries(TStats.MPLS);
    entrantesMPLS_GOS1 = new XYSeries(TStats.MPLS_GOS1);
    entrantesMPLS_GOS2 = new XYSeries(TStats.MPLS_GOS2);
    entrantesMPLS_GOS3 = new XYSeries(TStats.MPLS_GOS3);
    entrantesTLDP = new XYSeries(TStats.TLDP);
    entrantesGPSRP = new XYSeries(TStats.GPSRP);
    descartadosMPLS = new XYSeries(TStats.MPLS);
    descartadosMPLS_GOS1 = new XYSeries(TStats.MPLS_GOS1);
    descartadosMPLS_GOS2 = new XYSeries(TStats.MPLS_GOS2);
    descartadosMPLS_GOS3 = new XYSeries(TStats.MPLS_GOS3);
    descartadosTLDP = new XYSeries(TStats.TLDP);
    descartadosGPSRP = new XYSeries(TStats.GPSRP);
    tEMPLS = 0;
    tEMPLS_GOS1 = 0;
    tEMPLS_GOS2 = 0;
    tEMPLS_GOS3 = 0;
    tETLDP = 0;
    tEGPSRP = 0;
    tSMPLS = 0;
    tSMPLS_GOS1 = 0;
    tSMPLS_GOS2 = 0;
    tSMPLS_GOS3 = 0;
    tSTLDP = 0;
    tSGPSRP = 0;
    tDMPLS = 0;
    tDMPLS_GOS1 = 0;
    tDMPLS_GOS2 = 0;
    tDMPLS_GOS3 = 0;
    tDTLDP = 0;
    tDGPSRP = 0;
    retransmisionesAtendidas = new DefaultCategoryDataset();
    solicitudesRecibidas = 0;
    retransmisionesRealizadas = 0;
    retransmisionesNoRealizadas = 0;
    recuperacionesLocales = new DefaultCategoryDataset();
    paquetesGoSPerdido = 0;
    solicitudesEmitidas = 0;
    paquetesGoSRecuperados = 0;
    paquetesGoSNoRecuperados = 0;
}