Package net.sourceforge.gpstools.plot

Examples of net.sourceforge.gpstools.plot.SvgPlot


    public void plot(Quantity x, Quantity y, OutputStream os, String title,
            Wpt[] pts) throws IOException {
        OutputStreamWriter ow = new OutputStreamWriter(os, "utf-8");
        try {
            SvgPlot plot = getPlot(x, y, title, pts);
            configurePlot(plot, x, y);
            plot.plot(ow);
            ow.flush();
        } catch (FunctionEvaluationException ex) {
            // should never happen.
            throw new Error(ex);
        }
View Full Code Here


        }
    }

    public SvgPlot getPlot(Quantity x, Quantity y, String title, Wpt[] pts)
            throws FunctionEvaluationException {
        SvgPlot plot = new SvgPlot();
        plot.setTitle(SvgPlot.PlotDesignation.GLOBAL, title);
        for (double[] xx : getSupportPoints()) {
            final int n = xx.length;
            double[] xdata = new double[n];
            double[] ydata = new double[n];
            for (int i = 0; i < n; i++) {
                Date d = new Date((long) xx[i]);
                xdata[i] = unitConversion(x, getQuantity(d, x));
                ydata[i] = unitConversion(y, getQuantity(d, y));
            }
            plot.addData(xdata, ydata);
        }
        for (Wpt wpt : pts) {
            for (Date d : timeWpt(wpt, 0.01)) {
                try {
                    plot.addPoint(unitConversion(x, getQuantity(d, x)),
                            unitConversion(y, getQuantity(d, y)), wpt.getName());
                } catch (Exception err) {
                    System.err.println("Warning: Cannot plot Wpt:");
                    System.err.println(wpt.getName());
                    System.err.println(wpt.getLon());
                    System.err.println(wpt.getLat());
                    DateFormat df = new SimpleDateFormat(GPSDings.ISO_DATE
                            + "'Z'");
                    df.setTimeZone(GPSDings.UTC);
                    System.err.println(df.format(d));
                    System.err.println(err);
                }
            }
        }
       
        plot.setTitle(SvgPlot.PlotDesignation.X, getAxisTitle(x));
        plot.setTitle(SvgPlot.PlotDesignation.Y, getAxisTitle(y));
       
        return plot;
    }
View Full Code Here

TOP

Related Classes of net.sourceforge.gpstools.plot.SvgPlot

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.