Java coordinate systems

hi! i am having a problem of figuring on how device coordinate system used by awt be converted to rectangular coordinates. Do you have any ideas? Thanks
[166 byte] By [chiwena] at [2007-11-26 17:02:26]
# 1
more details please.
TimSparqa at 2007-7-8 23:30:12 > top of Java-index,Java Essentials,Java Programming...
# 2

sorry.. here are the details.

I have a JPanel where the user draw points, just like a painter. I capture these points in pixels using mouse events. I want to convert this points(in pixels) into points in rectangular coordinate system where decimals are allowed.

i need those converted points to compute for an interpolation. Are all details above alright? thanks!!

chiwena at 2007-7-8 23:30:12 > top of Java-index,Java Essentials,Java Programming...
# 3
I think the origin of the AWT coordinate system is in the upper left corner of the screen. The extent of the (x, y) window depends on the resolution of your monitor (1024 x 768, etc.)%
duffymoa at 2007-7-8 23:30:12 > top of Java-index,Java Essentials,Java Programming...
# 4
how can i convert those pixels into coordinates?
chiwena at 2007-7-8 23:30:12 > top of Java-index,Java Essentials,Java Programming...
# 5
Just like any other affine transformation, right? You need a mapping.%
duffymoa at 2007-7-8 23:30:12 > top of Java-index,Java Essentials,Java Programming...
# 6
> how can i convert those pixels into coordinates?You could make your own method to convert it, but I would recommend just getting used to it.
CaptainMorgan08a at 2007-7-8 23:30:12 > top of Java-index,Java Essentials,Java Programming...
# 7
but rectangular coordinates do have decimals numbers while pixels do not have. so I really need to convert it.. huhu
chiwena at 2007-7-8 23:30:12 > top of Java-index,Java Essentials,Java Programming...
# 8
> but rectangular coordinates do have decimals numbers> while pixels do not have.What's your point? Do you want to draw a line that is 2.75 pixels long?
CaptainMorgan08a at 2007-7-8 23:30:12 > top of Java-index,Java Essentials,Java Programming...
# 9
you got it sir.. do you have any ideas?
chiwena at 2007-7-8 23:30:12 > top of Java-index,Java Essentials,Java Programming...
# 10
> but rectangular coordinates do have decimals numbers> while pixels do not have. so I really need to convert> it.. huhutruncate.%
duffymoa at 2007-7-8 23:30:12 > top of Java-index,Java Essentials,Java Programming...
# 11
or round. whatever is acceptable to you.%
duffymoa at 2007-7-8 23:30:12 > top of Java-index,Java Essentials,Java Programming...
# 12
> you got it sir.. do you have any ideas?Yes I do. Suck it up and use the AWT coordinate system.
CaptainMorgan08a at 2007-7-8 23:30:12 > top of Java-index,Java Essentials,Java Programming...
# 13
i cant round off, its decimals are very important.. it may distort what am i drawing because my goal is to smooth a curve through interpolation.. e.g. the user draws a curve a straight, i must smooth it to eliminate noise.. ty!
chiwena at 2007-7-8 23:30:12 > top of Java-index,Java Essentials,Java Programming...
# 14
> i cant round off, its decimals are very important..You can't draw part of a pixel.
CaptainMorgan08a at 2007-7-8 23:30:12 > top of Java-index,Java Essentials,Java Programming...
# 15
yep yep, that's another reason why should i convert it.
chiwena at 2007-7-21 16:56:22 > top of Java-index,Java Essentials,Java Programming...
# 16
> yep yep, that's another reason why should i convert> it.You aren't making any sense. Each coordinate represents one pixel on the screen. Why do you need more precision than that?
CaptainMorgan08a at 2007-7-21 16:56:22 > top of Java-index,Java Essentials,Java Programming...
# 17

> i cant round off, its decimals are very important..

> it may distort what am i drawing because my goal is

> to smooth a curve through interpolation..

> e.g. the user draws a curve a straight, i must smooth

> it to eliminate noise.. ty!

If you draw a straight line at a 45 degree angle along the screen, you're going to get a staircase effect no matter what you do, because that's the best a pixel screen can do.

Seems awfully low level. Ever thought about Java2D or a graphics package that would handle this drawing for you? They probably do a better job of it than you will.

%

duffymoa at 2007-7-21 16:56:22 > top of Java-index,Java Essentials,Java Programming...
# 18
You are asking for a method to convert a less precise system to a more precise system but thing can only be done the other way round.
MingHKa at 2007-7-21 16:56:22 > top of Java-index,Java Essentials,Java Programming...