Hi, i'm trying to use an AffineTransform to transform a point to pixels on a 400x400 canvas. What kind of transform would you use?

For example:
given the points
(-1, 1) --transform--> (0, 0) (pixels)
(1, 1) --transform--> (400, 0) (pixels)
(-1, -1) --transform--> (0, 400) (pixels)
(1, -1) --transform--> (400, 400) (pixels)

What part of affine transform would I use?

translation?
scaling?
shearing?

The code i'm using to draw the points is as follows:

//paint method
AffineTransform at = new AffineTransform();
//at.translate(... ??
//at.scale(... ??
//at.shear(... ??
Graphics2D g2d = (Graphics2D)g;
g2d.setTransform(at);
//fill small point
g2d.fillRect(20, 50, 3, 3);

thanks.

Recommended Answers

All 2 Replies

It seems that you want to translate by (1, -1) and then scale by (200, -200). For example, (1, -1) would translate to (2, -2), and then scale to (400, 400).

Yea, thanks for the reply, but it doesn't work for the other points.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.