Saturday, October 9, 2010

DRAWING SHAPES USING JAVA 2D





Java, as a programming language, has a standard class library which provides many classes that let us present and manipulate graphical information. Our priority is the Graphics class and the Color class which are defined in the java.awt package. They contain various methods that allow us to draw shapes, including lines, rectangles, and ovals. As you can see above, several shapes have been drawn using the Java language, particularly using the Graphics class and the Color class. These shapes were made in such an exciting way of which I am going to outline below the methods i used in coming up with the shapes drawn above.
As I have already mentioned, the package used is the java.awt package.
Shape 1
The first shape, a star, is an example of a polygon. It can be drawn filled or unfilled. The methods used to draw a polygon are drawPolygon and fillPolygon. Hence, the first shape was drawn using the fillPolygon method that takes parameters. The first is an array of integers representing the x coordinates of the points in the polygon, the second is an array of integers representing the y coordinates of the points in the polygon and the third is an integer that indicates how many points are used from each of the two arrays. The colors were filled using the method setColor().
Shape 2
This is a circle with a certain portion that has been cut from it. The method used to create this shape is the fillArc() method that takes parameters. Here are the parameters you need to specify:
·         The starting angle for the arc in degrees-0 is due east, or 3 o'clock as they say in the movies.
·         The extent, which is an angle that represents how much of the ellipse the arc spans. This too is specified in degrees. The important thing to know is that the arc travels counterclockwise from the starting point. So if you specify 0 as the starting point and 90 as the extent, the arc travels from 3 o'clock to 12 o'clock high.
 The method setColor(Color.GRAY) was specified for the color of the shape.
Shape 3
These are a set of semi-circles joined together in a line. The method used here is the same as the one above. So since there are 4 semi-circles, therefore the method will have to be used four times.

Shape 4
The fourth shape is that of the form that looks like a doughnut. The method used was that of fillOval () which draws circles. There are two circles drawn here. The first circle is the outer black-filled one and the second is the small inner white-filled circle which together with the black one produces the shape show-cased above.
Shape 5
This shape (consisting of flower petals) uses the same method as the one used to draw the fourth shape but with different rather smaller parameters
Shape 6.
This is the last shape and as you can see, it is some kind of a vehicle. The method used to draw this shape is the fillPolygon(). Just like with the first shape, this takes (x, y) as an array of parameters and n as an integer that indicates how many points are used from each of the two arrays. For the wheels, I used the method i used to draw shape 4, only with smaller parameters. It's really that simple!


I can not say i am an expect in Java programming but what i can tell is i have learnt a lot during my study of this program and it's more fun than i anticipated. I am really looking forward to my next project involving Java programming.

Sunday, October 3, 2010

Roles of men in safe motherhood

Men being principle decision makers in our society have very important roles to play in efforts to reduce maternal and neonatal mortality rate. However, our hospital setting seems to be unfriendly evidenced by very few men who attend antenatal clinic with their wives. This leaves them out of safe motherhood education.
To narrate the whole story, men are expected  to shoulder the responsibility to make sure that before a woman gets pregnant, the family should be ready with the following to mention but a few:
The decision maker to the wife’s family and the man as a father will not go away up to the time when the woman will deliver, offering support and care. This is to evade the situation whereby a woman delivers at home or on the way delayed by waiting for the husband to come and okay her going to the hospital. They should decide where the woman will deliver, prepare transport save enough money in case of emergency. He should also see that there is enough food to cater for the family’s nutritional needs; since the woman will need nutritious food for successful gestation period and puerperium.
They then should decide where they can get blood in case need be and prepare to go for HIV, VDRL, Hb tests beforehand. They should also discuss the family planning method they will use after delivery and their reproductive goals.
For this to materialize let us find men where they are and teach them. In this regard I call upon Policy Makers and all of us to make policies that ensure men are empowered to be in the forefront in this matter, and we all take pregnancy issues our issues too respectively.
To find men, we can forget their attending the clinics but use HAS’s, Peer Educators, Marriage Counselors, teachers, print and electronic media to teach the community about safe motherhood and reproductive goals. Emphasis should be if the family is unable to meet the above conditions to wait when they will be ready.