view gnv-artifacts/src/main/java/de/intevation/gnv/math/LinearMetrics.java @ 522:c896282c2601

Issue 156 solved. Added width, height and points as parameter to svg and pdf output mode. Width and height have an effact on the width and height of the export, points is a boolean property which enables/disables the drawing of data points. gnv-artifacts/trunk@616 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 25 Jan 2010 09:18:31 +0000
parents aec85d00d82c
children 6cff63d0c434
line wrap: on
line source
package de.intevation.gnv.math;

import com.vividsolutions.jts.geom.Coordinate;

/**
 *  @author Sascha L. Teichmann
 */
public final class LinearMetrics
implements         Metrics
{
    public static final Metrics INSTANCE =
        new LinearMetrics();

    public static final class LinearInterpolator
    implements                Interpolator
    {
        private double mx;
        private double bx;
        private double my;
        private double by;

        public LinearInterpolator(Coordinate p1, Coordinate p2) {

            /*
             I) p1.x = 0*m + bx
            II) p2.x = 1*m + bx

            bx = p1.x

            p2.x = m + p1.x

            mx = p2.x - p1.x
            */

            bx = p1.x;
            mx = p2.x - bx;

            by = p1.y;
            my = p2.y - by;
        }

        public void interpolate(double t, Coordinate v) {
            v.x = t*mx + bx;
            v.y = t*my + by;
        }
    } // class LinearInterpolator

    private LinearMetrics() {
    }

    public double distance(Coordinate p1, Coordinate p2) {
        return p1.distance(p2);
    }

    public Interpolator getInterpolator(Coordinate p1, Coordinate p2) {
        return new LinearInterpolator(p1, p2);
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:

http://dive4elements.wald.intevation.org