Transform to flip Y axis and translate coords from screen coords system to cartesian one - Java 2D Graphics

Java examples for 2D Graphics:Screen

Description

Transform to flip Y axis and translate coords from screen coords system to cartesian one

Demo Code


//package com.java2s;

import java.awt.geom.*;

public class Main {
    public static final int scene_offset_x = 100;
    public static final int scene_offset_y = 500;

    /**/*from   www .  ja  v a 2s  .c o  m*/
     * Transform to flip Y axis and translate coords from
     * screen coords system to cartesian one
     */
    public static AffineTransform invertYAxisAffineTransform() {
        AffineTransform newAT = new AffineTransform();
        // Move center of coords by offset
        newAT.translate(scene_offset_x, scene_offset_y);
        // Flip Y axis
        newAT.scale(1.0, -1.0);
        return newAT;
    }
}

Related Tutorials