Search in sources :

Example 6 with CgData

use of course_generator.CgData in project Course_Generator by patrovite.

the class JPanelAnalysisSpeed method RefreshInfo.

private void RefreshInfo(int i) {
    if ((track == null) || (settings == null))
        return;
    // -- Get the data
    CgData d = track.data.get(i);
    lbSpeedInfoStartSpeed.setText(" " + bundle.getString("JPanelAnalysisSpeed.lbSpeedInfoStartSpeed.text") + "=" + String.format("%2.1f", startSpeed) + "km/h ");
    lbSpeedInfoEndSpeed.setText(" " + bundle.getString("JPanelAnalysisSpeed.lbSpeedInfoEndSpeed.text") + "=" + String.format("%2.1f", endSpeed) + "km/h ");
    lbSpeedInfoSpeed.setText(" " + bundle.getString("JPanelAnalysisSpeed.lbSpeedInfoSpeed.text") + "=" + d.getSpeedString(settings.Unit, true) + " ");
    lbSpeedInfoDistance.setText(" " + bundle.getString("JPanelAnalysisSpeed.lbSpeedInfoDistance.text") + "=" + d.getTotalString(settings.Unit, true) + " ");
}
Also used : CgData(course_generator.CgData)

Example 7 with CgData

use of course_generator.CgData in project Course_Generator by patrovite.

the class JPanelAnalysisSpeedSlope method Refresh.

/**
 * Update the Slope/Speed chart
 */
public void Refresh(TrackData track, CgSettings settings) {
    if (track == null)
        return;
    if (track.data.isEmpty())
        return;
    this.track = track;
    this.settings = settings;
    // -- Clear all series
    if (datasetSpeedSlopePoint.getSeriesCount() > 0)
        datasetSpeedSlopePoint.removeAllSeries();
    if (datasetSpeedSlopeLine.getSeriesCount() > 0)
        datasetSpeedSlopeLine.removeAllSeries();
    XYPlot plot = chart.getXYPlot();
    plot.clearDomainMarkers();
    // -- Populate the series
    XYSeries serie1 = new XYSeries("Speed/Slope (points)");
    XYSeries serie2 = new XYSeries("Speed/Slope (line)");
    int[] nb;
    int j = 0;
    double[] fCurveSpeedSlope = new double[101];
    double[] fCurveSpeedSlope2 = new double[101];
    Double[] Average = new Double[101];
    Double[] Variance = new Double[101];
    Double[] StandardDeviation = new Double[101];
    nb = new int[101];
    // -- init calc
    for (j = 0; j < 101; j++) {
        fCurveSpeedSlope[j] = 0;
        fCurveSpeedSlope2[j] = 0;
        nb[j] = 0;
    }
    // -- Execute the speed filtering calculation
    SpeedFilter();
    /*
		 * -- Pass 1 We calculate the average, variance and standard deviation
		 * of each area (1% per area)
		 */
    int n = 0;
    double s = 0.0;
    double coeff = 0.0;
    double diff = 0.0;
    for (CgData r : track.data) {
        if (btSpeedSlopeFilter.isSelected())
            s = r.tmp1;
        else
            s = r.getSpeed(settings.Unit);
        if (btSpeedSlopeCorr.isSelected()) {
            coeff = r.getCoeff() / 100.0;
            diff = r.getDiff() / 100.0;
        } else {
            coeff = 1.00;
            diff = 1.00;
        }
        if (s > 1.5) {
            if (r.getSlope() < -49) {
                fCurveSpeedSlope[0] = fCurveSpeedSlope[0] + (s / coeff / diff);
                fCurveSpeedSlope2[0] = fCurveSpeedSlope2[0] + Math.pow((s / coeff / diff), 2);
                nb[0]++;
            } else if (r.getSlope() > 49) {
                fCurveSpeedSlope[100] = fCurveSpeedSlope[100] + (s / coeff / diff);
                fCurveSpeedSlope2[100] = fCurveSpeedSlope2[100] + Math.pow((s / coeff / diff), 2);
                nb[100]++;
            } else {
                n = (int) Math.floor(r.getSlope());
                fCurveSpeedSlope[n + 50] = fCurveSpeedSlope[n + 50] + (s / coeff / diff);
                fCurveSpeedSlope2[n + 50] = fCurveSpeedSlope2[n + 50] + Math.pow((s / coeff / diff), 2);
                nb[n + 50]++;
            }
        }
    }
    for (j = 0; j < 101; j++) {
        if ((nb[j] > 0)) {
            Average[j] = fCurveSpeedSlope[j] / nb[j];
            Variance[j] = fCurveSpeedSlope2[j] / nb[j] - Average[j] * Average[j];
            StandardDeviation[j] = Math.sqrt(Variance[j]);
        }
    }
    // -- Init calc
    for (j = 0; j < 101; j++) {
        fCurveSpeedSlope[j] = 0;
        fCurveSpeedSlope2[j] = 0;
        nb[j] = 0;
    }
    n = 0;
    s = 0.0;
    coeff = 0.0;
    diff = 0.0;
    for (CgData r : track.data) {
        {
            if (btSpeedSlopeFilter.isSelected())
                s = r.tmp1;
            else
                s = r.getSpeed(settings.Unit);
            if (btSpeedSlopeCorr.isSelected()) {
                coeff = r.getCoeff() / 100.0;
                diff = r.getDiff() / 100.0;
            } else {
                coeff = 1.00;
                diff = 1.00;
            }
            if (s > 1.5) {
                if (r.getSlope() < -49) {
                    if ((s <= Average[0] + StandardDeviation[0]) || (s >= Average[0] - StandardDeviation[0])) {
                        fCurveSpeedSlope[0] = fCurveSpeedSlope[0] + (s / coeff / diff);
                        fCurveSpeedSlope2[0] = fCurveSpeedSlope2[0] + Math.pow((s / coeff / diff), 2);
                        nb[0]++;
                    }
                } else if (r.getSlope() > 49) {
                    if ((s <= Average[100] + StandardDeviation[100]) || (s >= Average[100] - StandardDeviation[100])) {
                        fCurveSpeedSlope[100] = fCurveSpeedSlope[100] + (s / coeff / diff);
                        fCurveSpeedSlope2[100] = fCurveSpeedSlope2[100] + Math.pow((s / coeff / diff), 2);
                        nb[100]++;
                    }
                } else {
                    n = (int) Math.floor(r.getSlope());
                    if ((s <= Average[n + 50] + StandardDeviation[n + 50]) || (s >= Average[n + 50] - StandardDeviation[n + 50])) {
                        fCurveSpeedSlope[n + 50] = fCurveSpeedSlope[n + 50] + (s / coeff / diff);
                        fCurveSpeedSlope2[n + 50] = fCurveSpeedSlope2[n + 50] + Math.pow((s / coeff / diff), 2);
                        nb[n + 50]++;
                    }
                }
            }
        }
    }
    double maxspeed = 0.0;
    // -- Populate the first serie
    for (CgData r : track.data) {
        if (btSpeedSlopeFilter.isSelected())
            s = r.tmp1;
        else
            s = r.getSpeed(settings.Unit);
        if (s > maxspeed)
            maxspeed = s;
        serie1.add(r.getSlope(), s);
    }
    datasetSpeedSlopePoint.addSeries(serie1);
    // -- Populate the second serie
    double m = 0.0;
    for (j = 0; j < 101; j++) {
        if ((nb[j] > 0)) {
            m = fCurveSpeedSlope[j] / nb[j];
            if (m > maxspeed)
                maxspeed = m;
            serie2.add(j - 50, m);
        }
    }
    // -- If there is no speed the exit (not already calculated)
    if (maxspeed == 0)
        return;
    datasetSpeedSlopeLine.addSeries(serie2);
    // -- Set the range of the X axis
    ValueAxis axisX = plot.getDomainAxis();
    axisX.setRange(-50.0, 50.0);
    ValueAxis axisY = plot.getRangeAxis(0);
    axisY.setRange(0, Math.ceil(maxspeed / 5.0) * 5.0);
    axisY = plot.getRangeAxis(1);
    axisY.setRange(1, Math.ceil(maxspeed / 5.0) * 5.0);
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) XYPlot(org.jfree.chart.plot.XYPlot) ValueAxis(org.jfree.chart.axis.ValueAxis) CgData(course_generator.CgData)

Example 8 with CgData

use of course_generator.CgData in project Course_Generator by patrovite.

the class JPanelAnalysisSpeedSlope method RefreshInfo.

private void RefreshInfo(int i) {
    if ((track == null) || (settings == null))
        return;
    // -- Get the data
    CgData d = track.data.get(i);
    lbSpeedSlopeInfoSpeed.setText(" " + bundle.getString("JPanelAnalysisSpeedSlope.lbSpeedSlopeInfoSpeed.text") + "=" + d.getSpeedString(settings.Unit, true) + " ");
    lbSpeedSlopeInfoSlope.setText(" " + bundle.getString("JPanelAnalysisSpeedSlope.lbSpeedSlopeInfoSlope.text") + "=" + d.getSlopeString(true) + " ");
}
Also used : CgData(course_generator.CgData)

Example 9 with CgData

use of course_generator.CgData in project Course_Generator by patrovite.

the class JPanelAnalysisTimeDist method Refresh.

/**
 * Update the Time/Distance chart
 */
public void Refresh(TrackData track, CgSettings settings) {
    if (track == null)
        return;
    if (track.data.isEmpty())
        return;
    this.track = track;
    this.settings = settings;
    // -- Clear all series
    if (datasetElevDist.getSeriesCount() > 0)
        datasetElevDist.removeAllSeries();
    if (datasetTimeDist.getSeriesCount() > 0)
        datasetTimeDist.removeAllSeries();
    XYPlot plot = chart.getXYPlot();
    // -- Populate the serie
    XYSeries serie1 = new XYSeries("Elevation/Distance");
    XYSeries serie2 = new XYSeries("Time/Distance");
    for (CgData r : track.data) {
        double x = r.getTotal(settings.Unit) / 1000;
        double y = r.getElevation(settings.Unit);
        double t = r.getTime();
        serie1.add(x, y);
        serie2.add(x, t);
    }
    datasetElevDist.addSeries(serie1);
    datasetTimeDist.addSeries(serie2);
    if (track.getMaxElev(settings.Unit) > track.getMinElev(settings.Unit)) {
        ValueAxis axisYElev = plot.getRangeAxis(0);
        axisYElev.setRange(Math.floor(track.getMinElev(settings.Unit) / 100.0) * 100.0, Math.ceil(track.getMaxElev(settings.Unit) / 100.0) * 100.0);
    }
    chart = CreateChart(datasetElevDist, datasetTimeDist);
    RefreshInfo(0);
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) XYPlot(org.jfree.chart.plot.XYPlot) ValueAxis(org.jfree.chart.axis.ValueAxis) CgData(course_generator.CgData)

Example 10 with CgData

use of course_generator.CgData in project Course_Generator by patrovite.

the class JPanelAnalysisTimeDist method RefreshInfo.

private void RefreshInfo(int i) {
    if ((track == null) || (settings == null))
        return;
    // -- Get the data
    CgData d = track.data.get(i);
    lbTimeDistInfoDistance.setText(" " + bundle.getString("JPanelAnalysisTimeDist.lbTimeDistInfoDistance.text") + "=" + d.getTotalString(settings.Unit, true) + " ");
    lbTimeDistInfoElevation.setText(" " + bundle.getString("JPanelAnalysisTimeDist.lbTimeDistInfoElevation.text") + "=" + d.getElevationString(settings.Unit, true) + " ");
    lbTimeDistInfoTime.setText(" " + bundle.getString("JPanelAnalysisTimeDist.lbTimeDistInfoTime.text") + "=" + d.getTimeString() + " ");
    lbTimeDistInfoHour.setText(" " + bundle.getString("JPanelAnalysisTimeDist.lbTimeDistInfoHour.text") + "=" + d.getHourString() + " ");
    lbTimeDistSlope.setText(" " + bundle.getString("JPanelAnalysisTimeDist.lbTimeDistSlope.text") + "=" + d.getSlopeString(true) + " ");
}
Also used : CgData(course_generator.CgData)

Aggregations

CgData (course_generator.CgData)16 ValueAxis (org.jfree.chart.axis.ValueAxis)4 XYPlot (org.jfree.chart.plot.XYPlot)4 XYSeries (org.jfree.data.xy.XYSeries)4 CalcLineResult (course_generator.utils.Utils.CalcLineResult)3 Color (java.awt.Color)2 Font (java.awt.Font)2 BufferedImage (java.awt.image.BufferedImage)2 DateTime (org.joda.time.DateTime)2 CgResume (course_generator.CgResume)1 TrackData (course_generator.TrackData)1 CalcAvrSlopeResult (course_generator.TrackData.CalcAvrSlopeResult)1 CalcAvrSpeedResult (course_generator.TrackData.CalcAvrSpeedResult)1 CalcClimbResult (course_generator.TrackData.CalcClimbResult)1 CgSettings (course_generator.settings.CgSettings)1 DrawStringMultiLine (course_generator.utils.DrawStringMultiLine)1 BasicStroke (java.awt.BasicStroke)1 Dimension (java.awt.Dimension)1 Graphics (java.awt.Graphics)1 Graphics2D (java.awt.Graphics2D)1