Programming mission 4 in java problem

Put your programming skills to the test in these challenges.

Programming mission 4 in java problem

Post by eljonto on Sun Nov 02, 2008 3:28 pm
([msg=14393]see Programming mission 4 in java problem[/msg])

hey all,
i have the same problem that Nikousek had in php http://www.hackthissite.org/forums/viewtopic.php?f=19&t=1612&sid=ae6aec6b9c1b08476b1cc39dafbaf279 there- although since that was php and the thread was pretty much finished i though i should make a new one. For everyone that hasn't read that topis- my problem is that java's coordinate system has its origin at the top left hand corner of the screen- so positive y is down and and positive x is right- however for this mission they use the normal cartesian plane where the origin is at the bottom left hand corner of the screen- postive y is up and positive x is right.
My question is how would i go about changing this? is there a way to change the coordinate system or do i have to adjust each y value of the data? (x values would stay the same since positive x is always right)? and would you please sugest any feasible way of doing this. Thanks in advance
~ELJONTO
-Quis custodiet ipsos custodes?, Juvenal
_________________________________________________________________
User avatar
eljonto
Poster
Poster
 
Posts: 373
Joined: Thu Apr 17, 2008 1:16 am
Location: Australia
Blog: View Blog (0)


Re: Programming mission 4 in java problem

Post by eljonto on Sun Nov 02, 2008 3:51 pm
([msg=14394]see Re: Programming mission 4 in java problem[/msg])

Don't worry- i found out- guess i wasn't googling properley- but for anyone who has the same origin problem in java-
place these lines in your paint() method:

[User Edit: Code removed]-Think about the coordinate system used by java and the coordinate system used by the xml file and how you can change the java one accordingly, also pay attention to where the image will be painted with your new coordinate system and translate appropriately

EDIT: Ok, now i have finished the mission- surprising easy, a few things to note if you want to do this in java, firstly because you have float values you will nee to use the Graphics2D object you created earlier (to flip origin) to use it Line2D and Arc2D functions beacuse they can take double and floating values.
eg
[User Edit: Code removed]Use the Line2d and Arc2d to draw the appropriate lines and arcs, pay attention to what precision you want, Float or Double.
All the values given to you in the xml file for the arc are need to use in the Arc2D function- but not plain as they are, because the Arc2D x and y are in a different location to what the xml file specifies, they will need to be changed a little. Same goes with the width and height. You realise what changes need to be made to all the values in Arc2D, google to find out how Arc2D uses its values to draw arc then look at how the xml file uses values to create arc (see help page from the programming 4 page). A thing to note about the start and extend is make sure you know which way the arc draws if the values are positive or negative. -that stumped me for a good hour ;)

If you need help on anything to do with this mission in java, just reply here or if it involves me to check code or anything just pm me.

Good luck
~ELJONTO
-Quis custodiet ipsos custodes?, Juvenal
_________________________________________________________________
User avatar
eljonto
Poster
Poster
 
Posts: 373
Joined: Thu Apr 17, 2008 1:16 am
Location: Australia
Blog: View Blog (0)



Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests