java - Working with data from table -
i wondering if advice on implementing algorithm creating jfreechart. basically, extracting data jtable contains information patients. there age categories patients such 20-26, 26-30, 31-35, 35-40, 50-55, 55-60 etc. there 30 of them , every patient belongs corresponding age category. there button on top of jtable opens frame containing age distribution graph. thinking of doing:
- create integer variable every category
- loop through age details patients in jtable
- compare variables jtable data , increment 1 if there match (lots of if statements go in loop)
- store categories names , amount of people registered under every category in hashmap
- pass map chartframe
i suppose might relatively way of doing wondering if possibly suggest way of avoiding having create variable every category , having comparisons using 30 if statements.
edit: not have patient's exact age - category belong to.
i've assumed you've got own class agerange
stores range of ages. can store age ranges in treemap<integer,agerange>
, key first number of range , value range itself.
when need find age range contains particular age, use
themap.lowerentry(age + 1)
to find it.
check treemap
javadoc @ http://docs.oracle.com/javase/7/docs/api/java/util/treemap.html
Comments
Post a Comment