Translate (move) a Line2D object on the X and Y axes. - Android java.lang

Android examples for java.lang:Math Geometry

Description

Translate (move) a Line2D object on the X and Y axes.

Demo Code

/*******************************************************************************
 * Copyright (c) 2011 MadRobot.//  ww  w.  j av  a  2s. c  o m
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser Public License v2.1
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * 
 * Contributors:
 *  Elton Kent - initial API and implementation
 ******************************************************************************/
//package com.java2s;

import android.graphics.PointF;

public class Main {
    /**
     * Translate (move) a Line2D object on the X and Y axes.
     * 
     * @param line
     *            the line to translate
     * @param dx
     *            the X-axis offset
     * @param dy
     *            the Y-axis offset
     */
    public static void translate(PointF lineStart, PointF lineEnd,
            double dx, double dy) {
        lineStart.x += dx;
        lineStart.y += dy;
        lineEnd.x += dx;
        lineEnd.y += dy;
    }
}

Related Tutorials