• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.awt.geom Help

 
Jason Newman
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We just finished a chapter in our book (http://www.amazon.com/Introduction-Computing-Programming-Java-Multimedia/dp/0131496980) and it dealt with drawing with the graphics class.And if you know, I'm still a beginner at this, and my brain doesn't exactly function like a 'programmers' should. At the end of the chapter there are questions we have to answer for a grade (blah blah blah) and I'm looking for the logical approach to some of these. Which, is why I'm back, once more for help. Some of the questions include
7.5 Using the drawing tools present here, draw a house - just go for the simple child's house with one door, two windows, walls and a roof.
I know how to do that, but they get more 'challenging' and require thinking in a pattern that I've yet to grasp. Another example would be
7.13 Draw glasses on someone who doesn't have glasses already on.
I feel stupid, because this all sounds so basic, but I just can't seem to develop the way of thinking yet. So, any help with the questions (An example on how to do it, or something along those lines) or any type of exercise to learn how to look at things in a more... Mathematical, logical way. Any type of help would be appreciated greatly.

-Jason



Edit: I had to remove the code, because people are lazy, and can cheat by copying and pasting the code. :/
 
Kevin Workman
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, without the code, it's going to be pretty hard to answer the question.

How is a person represented? How do you know whether or not a person has glasses on? What kinds of methods do you have to work with a person (is there a drawGlassOnPerson() method?)? Can you get the position of a person's eyes? How?

Edit- The best way to ask this question is to post an SSCCE that demonstrates what you've tried, tell us what's wrong about it, and we can go from there.
 
Campbell Ritchie
Sheriff
Pie
Posts: 48940
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the house, you are going to draw rectangles for the walls and doors, etc, and a triangle for the gable end (or look at the roof from the other wall, when it appears rectangular).
I would suggest you design a HousePicture class which can store the size of its parts, and place them appropriately, and store Wall objects, Window objects, etc in a List.
Give each of those objects a drawYourself() or similar method, and call them all in turn. You would of course create an interface for all those classes to implement.

I think this thread would sit better on our GUIs forum, so shall move it.
 
Jason Newman
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, that makes a lot more sense. I'll write the code for it at lunch, and when I get home I'll type it and put it into action. Thank you!
 
Campbell Ritchie
Sheriff
Pie
Posts: 48940
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good luck with it. I presume you have a laptop with you at lunch, so you can see the code running and get gravy between the keys and wreck the wiring
 
Jason Newman
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ha, no laptop. Even if I had one the school wouldn't allow it. I'm stuck to graph paper, lined paper and pens.
 
Campbell Ritchie
Sheriff
Pie
Posts: 48940
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can go one better than that. I had sandwiches and a Cornish Pastie for lunch.
 
Campbell Ritchie
Sheriff
Pie
Posts: 48940
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, you mean you use paper to sketch out your programming??
 
Jason Newman
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ha. Yeah, I wouldn't say it works amazingly, but it kind of gets the job done. And I finished the house.



Put THAT in your pipe and smoke it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic