Changeset 1452
- Timestamp:
- 11/04/08 07:51:37 (2 months ago)
- Location:
- branches/dev-brotecs-refactor/org.javarosa.polish.chatterbox.extensions/src/org/javarosa/formmanager/view/chatterbox/widget/chart
- Files:
-
- 4 modified
-
CurrentTemplate.java (modified) (1 diff)
-
IGraphTemplate.java (modified) (2 diffs)
-
LineChart.java (modified) (9 diffs)
-
WHOWeightTemplate.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/dev-brotecs-refactor/org.javarosa.polish.chatterbox.extensions/src/org/javarosa/formmanager/view/chatterbox/widget/chart/CurrentTemplate.java
r1253 r1452 33 33 * @see org.javarosa.formmanager.view.chatterbox.widget.chart.IGraphTemplate#getDataPoints() 34 34 */ 35 public Vector getLines(Vector data ) {35 public Vector getLines(Vector data,LineChart chart) { 36 36 37 37 Vector lines = new Vector(); -
branches/dev-brotecs-refactor/org.javarosa.polish.chatterbox.extensions/src/org/javarosa/formmanager/view/chatterbox/widget/chart/IGraphTemplate.java
r971 r1452 5 5 public interface IGraphTemplate { 6 6 7 7 8 /** 8 9 * @return The internal ID used to identify the template … … 23 24 * lines for the template. 24 25 */ 25 Vector getLines(Vector data); 26 Vector getLines(Vector data,LineChart chart); 27 //public void setIsUseTemplate(boolean isUseTemplate); 28 //public boolean getIsUseTemplate(); 26 29 } -
branches/dev-brotecs-refactor/org.javarosa.polish.chatterbox.extensions/src/org/javarosa/formmanager/view/chatterbox/widget/chart/LineChart.java
r1252 r1452 50 50 51 51 private boolean isDefaultColor; 52 52 53 private boolean defaulttemplate;//brotecs 54 private int templatemarginOne;//brotecs 55 private int templatexScaleFactor;//brotecs 56 53 57 public LineChart(String label, Style style) { 54 58 super(label,style); … … 59 63 pointsVector.addElement(currentPointVector); 60 64 yScaleFactor = 100; 61 xScaleFactor = 2 5;65 xScaleFactor = 26; 62 66 isDrawAxis = true; 63 67 marginOne = 1; … … 75 79 shadowColorThree = 100; 76 80 font = Font.getDefaultFont(); 81 defaulttemplate=false;//brotecs 82 templatemarginOne=36;//brotecs 83 templatexScaleFactor=13;//brotecs 77 84 // System.out.println("Brotecs::LineChart->LineChart(String label, Style style)"); 78 85 } … … 153 160 g1.setColor(0, 0, 0); 154 161 g1.drawLine(marginOne, this.height - marginFour, marginOne + width, this.height - marginFour); 162 //System.out.println("Line 1->X1:"+marginOne+" Y1:"+(this.height - marginFour)+" X2:"+(marginOne+width)+" Y2:"+(this.height - marginFour)); 155 163 g1.drawLine(marginOne, this.height - marginFour, marginOne, this.height - marginFour - height); 156 164 //System.out.println("Line 2->X1:"+marginOne+" Y1:"+(this.height - marginFour)+" X2:"+marginOne+" Y2:"+(this.height - marginFour - height)); 165 157 166 } 158 167 } … … 293 302 for(int i = 0; i <= height; i += 10) { 294 303 int j1 = this.height - fontSpaceHeight - i; 304 //System.out.println("Brotecs::LineChart->marginOne:"+marginOne+"j1:"+j1+"marginOne-2"+(marginOne-2)); 295 305 g.drawLine(marginOne, j1, marginOne - 2, j1); //draw Y axis "-" 296 306 int point = (yScaleFactor * i) / height; … … 306 316 } 307 317 } 318 308 319 Enumeration en = pointsVector.elements(); 309 320 while(en.hasMoreElements()) { … … 314 325 315 326 public void drawLine(Graphics g, Vector pointVector) { 316 327 //System.out.println("Brotecs::LineChart->drawLine:pointVector.size()="+pointVector.size()); 317 328 pointVector.size(); 318 329 int count = -1; … … 345 356 346 357 int pointY2 = this.height - fontSpaceHeight - (height * b1.yCordPt) / (yScaleFactor); 347 //System.out.println("Brotecs::LineChart->drawLine:"+height+" * " + b1.yCordPt + " / "+yScaleFactor); 348 int pointX2 = marginOne + (width * b1.xCordPt) / (xScaleFactor * scaleFactor); 358 359 //System.out.println("Brotecs::pointY2->this.height:"+this.height +"- fontSpaceHeight:"+fontSpaceHeight+" - (height:"+height+" * b1.yCordPt:" + b1.yCordPt + ") / yScaleFactor:"+yScaleFactor); 360 //int pointX2 = marginOne + (width * b1.xCordPt) / (xScaleFactor * scaleFactor); 361 /************Brotecs*************/ 362 int pointX2; 363 if(defaulttemplate){// 364 pointX2 = marginOne + (width * b1.xCordPt) / (templatexScaleFactor * scaleFactor); 365 } 366 else 367 { 368 pointX2 = marginOne + (width * b1.xCordPt) / (xScaleFactor * scaleFactor); 369 } 370 371 // System.out.println("Brotecs::pointX2->marginOne:"+marginOne+"+(width:"+width+"* b1.xCordPt:"+b1.xCordPt+") / (xScaleFactor:"+xScaleFactor+"* scaleFactor:"+scaleFactor+")"); 372 /************Brotecs*************/ 349 373 //System.out.println("pointX1 == " + pointX1 + " pointY1 == " + pointY1 + " pointX2 == " + pointX2 + " pointY2 == " + pointY2); 350 374 351 375 if(count > -1) { 352 376 g.drawLine(pointX1, pointY1, pointX2, pointY2); 377 //System.out.println("Brotecs::LineChart->pointX1:"+pointX1+" pointY1:"+pointY1+" pointX2:"+pointX2+" pointY2:"+pointY2); 353 378 } 354 379 pointX1 = pointX2; 355 380 pointY1 = pointY2; 356 381 if(isMarginTwoTrue) { 357 g.setColor(0, 0, 0); 358 if((count + 1) % ticker == 0) { 359 //g.drawLine(pointX2, this.height - fontSpaceHeight, pointX2, (this.height - fontSpaceHeight) + 2); 360 } 361 pointLabelWidth = font.stringWidth(b1.labelX); 362 if(isLabelXTrue && (count + 1) % (equalCoordTicker * ticker) == 0) { 363 g.drawString(b1.labelX, pointX2 - pointLabelWidth / 2, (this.height - fontSpaceHeight) + 1, 20); 364 365 } 382 g.setColor(0, 0, 0); 383 /************Brotecs*************/ 384 if(defaulttemplate){ 385 for(int i=1;i<5;i++){ 386 g.drawLine(marginOne+(templatemarginOne*i), this.height - fontSpaceHeight, marginOne+(templatemarginOne*i), (this.height - fontSpaceHeight) + 3); 387 g.drawString(i+" Year", marginOne+(templatemarginOne*i), (this.height - fontSpaceHeight) + 4, 20); 388 } 389 }/********Brotecs**********/ 390 else{ 391 if((count + 1) % ticker == 0) { 392 //g.drawLine(pointX2, this.height - fontSpaceHeight, pointX2, (this.height - fontSpaceHeight) + 4); 393 394 } 395 pointLabelWidth = font.stringWidth(b1.labelX); 396 if(isLabelXTrue && (count + 1) % (equalCoordTicker * ticker) == 0) { 397 //g.drawString(b1.labelX, pointX2 - pointLabelWidth / 2, (this.height - fontSpaceHeight) + 1, 20); 398 399 } 400 } 366 401 } 367 402 } while(true); … … 461 496 } 462 497 498 public void defaulttemplate(boolean defaulttemplate) { 499 this.defaulttemplate = defaulttemplate; 500 } 501 public boolean getdefaulttemplate() 502 { 503 return defaulttemplate; 504 } 463 505 } -
branches/dev-brotecs-refactor/org.javarosa.polish.chatterbox.extensions/src/org/javarosa/formmanager/view/chatterbox/widget/chart/WHOWeightTemplate.java
r1252 r1452 1 1 package org.javarosa.formmanager.view.chatterbox.widget.chart; 2 2 import java.util.Calendar; 3 import java.util.Date; 3 4 import java.util.Vector; 4 5 … … 45 46 * @see org.javarosa.formmanager.view.chatterbox.widget.chart.IGraphTemplate#getDataPoints() 46 47 */ 47 public Vector getLines(Vector data ) {48 public Vector getLines(Vector data,LineChart chart) { 48 49 //This function will give a number of days. We can use it to scale record dates 49 //DateUtils.getApproxDaysDifference(earlierDate, laterDate) 50 //DateUtils.getApproxDaysDifference(earlierDate, laterDate); 50 51 51 52 //TODO: Scale X axis from 0 to 5 years. Display the data from the website 52 53 Vector lines = new Vector(); 53 Vector points1 = new Vector(); 54 Vector points1 = new Vector();/*Brotecs*/ 54 55 Vector points2 = new Vector(); 55 56 Vector points3 = new Vector(); 56 57 57 lines.addElement(points1); 58 lines.addElement(points3); 58 lines.addElement(points1);/*Brotecs*/ 59 lines.addElement(points3);/*Brotecs*/ 59 60 lines.addElement(points2); 61 62 60 63 61 int [] chartX1PointsArray = {12, 20, 30, 40, 50, 60, 70, 80, 90}; 62 int [] chartY1PointsArray = {10, 10, 10, 10, 10, 10, 10, 10, 10}; 64 Date birthdate=patient.getBirthDate(); 65 66 Date today=new Date(); 67 Calendar calendar = Calendar.getInstance(); 68 calendar.setTime(today); 69 int thisYear = calendar.get(Calendar.YEAR); 70 System.out.println("towhid::::WHOWeightTemplate:thisYear="+thisYear); 71 calendar.setTime(birthdate); 72 int birthYear = calendar.get(Calendar.YEAR); 73 System.out.println("towhid::::WHOWeightTemplate:birthYear="+birthYear); 63 74 64 int [] chartX2PointsArray = {15, 20, 30, 35, 45, 55, 68, 79, 90}; 65 int [] chartY2PointsArray = {2, 8, 16, 32, 48, 55, 64, 70, 80}; 66 67 int [] chartX3PointsArray = {10, 10, 10, 10, 10, 10, 10, 10, 10}; 68 int [] chartY3PointsArray = {15, 20, 30, 40, 50, 60, 70, 80, 90}; 69 70 for(int i = 0; i < chartX2PointsArray.length; i++) { 71 points2.addElement(new LinePointsItem("", chartX2PointsArray[i], chartY2PointsArray[i], 0, 255, 255)); 72 } 73 74 for(int i = 0; i < chartX1PointsArray.length; i++) { 75 points1.addElement(new LinePointsItem("", chartX1PointsArray[i], chartY1PointsArray[i], 255, 0, 255)); 76 } 77 78 for(int i = 0; i < chartX3PointsArray.length; i++) { 79 points3.addElement(new LinePointsItem("", chartX3PointsArray[i], chartY3PointsArray[i], 0, 0, 0)); 80 } 75 int diff_year = thisYear-birthYear; 76 System.out.println("towhid::::WHOWeightTemplate:diff_year="+diff_year); 77 if(diff_year<5){ 78 if(patient.getGender()==patient.SEX_MALE){ 79 80 int [] chartY1PointsArray = {5, 6, 8, 12, 13, 15, 17, 19, 23}; 81 int [] chartX1PointsArray = {0, 1, 2, 12, 16, 23, 31, 39, 60}; 82 83 int [] chartX2PointsArray = {3, 5, 9, 10, 11, 13, 15, 17, 18}; 84 int [] chartY2PointsArray = {0, 2, 10, 14, 18, 28, 40, 52, 56}; 85 86 int [] chartX3PointsArray = {2, 4, 5, 8, 9, 10, 11, 12, 14}; 87 int [] chartY3PointsArray = {0, 2, 4, 11, 20, 26, 34, 42, 58}; 88 89 System.out.println("towhid::::WHOWeightTemplate:Gender=MALE"); 90 for(int i = 0; i < chartX2PointsArray.length; i++) { 91 points2.addElement(new LinePointsItem("", chartX2PointsArray[i], chartY2PointsArray[i], 0, 255, 255)); 92 } 93 94 for(int i = 0; i < chartX1PointsArray.length; i++) { 95 points1.addElement(new LinePointsItem("", chartY1PointsArray[i], chartX1PointsArray[i], 255, 0 , 255)); 96 } 97 98 for(int i = 0; i < chartX3PointsArray.length; i++) { 99 points3.addElement(new LinePointsItem("", chartX3PointsArray[i], chartY3PointsArray[i], 255, 0, 255)); 100 } 101 //this.isUseTemplate=true; 102 chart.defaulttemplate(true); 103 chart.setMaxYScaleFactor(30); 104 } 105 else if(patient.getGender()==patient.SEX_FEMALE) 106 { 107 int [] chartY1PointsArray = {4, 6, 9, 12, 13, 14, 19, 22, 25}; 108 int [] chartX1PointsArray = {0, 1, 5, 14, 16, 19, 39, 50, 60}; 109 110 int [] chartY2PointsArray = {3, 5, 7, 9, 11, 13, 15, 17, 18}; 111 int [] chartX2PointsArray = {0, 2, 5, 12, 20, 31, 42, 55, 59}; 112 113 int [] chartY3PointsArray = {2, 4, 5, 7, 8, 9, 10, 13, 14}; 114 int [] chartX3PointsArray = {0, 2, 4, 12, 17, 24, 30, 53, 59}; 115 116 System.out.println("towhid::::WHOWeightTemplate:Gender=FEMALE"); 117 for(int i = 0; i < chartX3PointsArray.length; i++) { 118 points3.addElement(new LinePointsItem("", chartY3PointsArray[i], chartX3PointsArray[i], 0, 255, 255)); 119 } 120 for(int i = 0; i < chartX1PointsArray.length; i++) { 121 points1.addElement(new LinePointsItem("", chartY1PointsArray[i], chartX1PointsArray[i], 255, 0, 255)); 122 } 123 for(int i = 0; i < chartX2PointsArray.length; i++) { 124 points2.addElement(new LinePointsItem("", chartY2PointsArray[i], chartX2PointsArray[i], 255, 0, 255)); 125 } 126 //this.isUseTemplate=true; 127 chart.defaulttemplate(true); 128 chart.setMaxYScaleFactor(30); 129 }/**************UNKNOWN************* 130 else 131 { 132 int [] chartX1PointsArray = {5, 6, 8, 12, 13, 15, 17, 19, 23}; 133 int [] chartY1PointsArray = {0, 1, 2, 12, 16, 23, 31, 39, 60}; 134 135 int [] chartX2PointsArray = {3, 5, 9, 10, 11, 13, 15, 17, 18}; 136 int [] chartY2PointsArray = {0, 2, 10, 14, 18, 28, 40, 52, 56}; 137 138 int [] chartX3PointsArray = {2, 4, 5, 8, 9, 10, 11, 12, 14}; 139 int [] chartY3PointsArray = {0, 2, 4, 11, 20, 26, 34, 42, 58}; 140 141 System.out.println("towhid::::WHOWeightTemplate:Gender=UNKNOWN"); 142 for(int i = 0; i < chartX3PointsArray.length; i++) { 143 points3.addElement(new LinePointsItem("", chartX3PointsArray[i], chartY3PointsArray[i], 255, 0, 255)); 144 } 145 for(int i = 0; i < chartX1PointsArray.length; i++) { 146 points1.addElement(new LinePointsItem("", chartX1PointsArray[i], chartY1PointsArray[i], 255, 0, 255)); 147 } 148 for(int i = 0; i < chartX2PointsArray.length; i++) { 149 points2.addElement(new LinePointsItem("", chartX2PointsArray[i], chartY2PointsArray[i], 255, 0, 255)); 150 } 151 }/**************************/ 152 153 } 154 else 155 { 156 this.isUseTemplate=false; 157 chart.defaulttemplate(false); 158 chart.setMaxYScaleFactor(100); 159 } 160 81 161 return lines; 82 162 } … … 88 168 this.patient = patient; 89 169 } 90 /*************Brotecs:add this********************** /91 public void setIsUseTemplate(boolean isUse Template)170 /*************Brotecs:add this********************** 171 public void setIsUseTemplate(boolean isUse) 92 172 { 93 this.isUseTemplate=isUseTemplate;173 isUseTemplate=isUse; 94 174 } 95 175
