Translates a shape over the given distance. - Java 2D Graphics

Java examples for 2D Graphics:Shape

Description

Translates a shape over the given distance.

Demo Code


//package com.java2s;

import java.awt.Shape;
import java.awt.geom.AffineTransform;

public class Main {
    /**/*from ww  w  .ja  va2s . c om*/
     * Translates a shape over the given distance.
     * 
     * @param shape The shape being translated.
     * @param distance_x The distance on the x axis.
     * @param distance_y The distance on the y axis.
     * @return The translated shape.
     */
    public static final Shape translateShape(Shape shape,
            double distance_x, double distance_y) {
        AffineTransform transform = new AffineTransform();
        transform.translate(distance_x, distance_y);
        return transform.createTransformedShape(shape);
    }
}

Related Tutorials