AffineTransformGetScaleInstance.java Source code

Java tutorial

Introduction

Here is the source code for AffineTransformGetScaleInstance.java

Source

import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;

public class AffineTransformGetScaleInstance extends Frame {
    public static void main(String[] args) {
        (new AffineTransformGetScaleInstance()).setVisible(true);
    }

    public AffineTransformGetScaleInstance() {
        setSize(350, 300);
    }

    public void paint(Graphics g) {
        AffineTransform atrans = null;

        Graphics2D g2d = (Graphics2D) g;
        atrans = AffineTransform.getScaleInstance(2, 3);

        if (atrans != null)
            g2d.setTransform(atrans);

        g2d.fillRect(50, 50, 100, 50);
    }
}