Changeset 1451

Show
Ignore:
Timestamp:
11/04/08 07:51:04 (2 months ago)
Author:
amostafa
Message:
 
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/dev-brotecs-refactor/org.javarosa.polish.chatterbox.extensions/src/org/javarosa/formmanager/view/chatterbox/widget/GraphWidget.java

    r1251 r1451  
    3939         
    4040        /** Integer->IGraphTemplate */ 
    41         Map templates = new Map(); 
     41        private static Map templates = new Map(); 
    4242         
    4343        Vector data; 
     
    4545        //brotecs:add this; 
    4646        //CurrentTemplate currentTemplate=null; 
    47         WHOWeightTemplate currentTemplate=null; //Brotecs: for WHOWeightTemplate 
     47        IGraphTemplate currentTemplate=null; //Brotecs: for WHOWeightTemplate 
    4848         
    4949         
     
    7171 
    7272        chart.setMaxYScaleFactor(100); 
    73         chart.setMaxXScaleFactor(18); 
     73        chart.setMaxXScaleFactor(26); 
    7474        } 
    7575         
     
    8181                for(int i = 0; i < chartXPointsArray.length; i++) { 
    8282            chart.insertItem("", chartYPointsArray[i].intValue(), chartXPointsArray[i].intValue(), 0,  0,   255); 
    83            // System.out.println("Brotecs::GraphWidget->applyData():chartYPointsArray="+chartYPointsArray[i].intValue()+" chartXPointsArray="+chartXPointsArray[i].intValue()); 
     83            //System.out.println("Brotecs::GraphWidget->applyData():chartYPointsArray="+chartYPointsArray[i].intValue()+" chartXPointsArray="+chartXPointsArray[i].intValue()); 
    8484                } 
    8585         
     
    9393        private void applyTemplate(Vector data) { 
    9494        System.out.println("Brotecs::GraphWidget->applyTemplate");               
    95                 if(currentTemplate.getIsUseTemplate()) { 
     95                if(currentTemplate!=null) { 
    9696                        System.out.println("Brotecs::GraphWidget->applyTemplate:currentTemplate != null"); 
    97                         Vector lines = currentTemplate.getLines(data); 
     97                        Vector lines = currentTemplate.getLines(data,chart); 
    9898                        if(lines != null) { 
    99                                 System.out.println("Brotecs::GraphWidget->applyTemplate:lines != null"); 
     99                                //System.out.println("Brotecs::GraphWidget->applyTemplate:lines != null"); 
    100100                                Enumeration en = lines.elements(); 
    101101                                while(en.hasMoreElements()) { 
    102                                         System.out.println("Brotecs::GraphWidget->en.hasMoreElements()"); 
     102                                        //System.out.println("Brotecs::GraphWidget->en.hasMoreElements()"); 
    103103                                        Vector dataPoints = (Vector)en.nextElement(); 
    104104                                        //System.out.println("Brotecs::GraphWidget->datapoints.size()="+dataPoints.size()); 
     
    112112                } 
    113113                else{ 
    114                         //System.out.println("Brotecs::GraphWidget->applyTemplate:currentTemplate == null"); 
     114                        System.out.println("Brotecs::GraphWidget->applyTemplate:currentTemplate == null"); 
    115115                } 
    116116        } 
     
    123123        public void registerTemplate(IGraphTemplate template) { 
    124124        //System.out.println("Brotecs::GraphWidget->registerTemplate");          
    125                 templates.put(new Integer(template.getTemplateId()), template); 
     125                //System.out.println("Brotecs::GraphWidget->registerTemplate Length1; "+templates.size());               
     126        templates.put(new Integer(template.getTemplateId()), template); 
     127        //System.out.println("Brotecs::GraphWidget->registerTemplate Length2; "+templates.size()); 
    126128        } 
    127129         
     
    156158        protected void setWidgetValue(Object o) { 
    157159        //System.out.println("Brotecs::GraphWidget->setWidgetValue");            
    158                 if(o instanceof Vector /*Brotecs:add this*/ && !currentTemplate.getIsUseTemplate()/*brotecs:till*/) { 
     160                if(o instanceof Vector /*Brotecs:add this*/ && !chart.getdefaulttemplate()/*brotecs:till*/) { 
    159161                        try{//Brotecs: add this 
    160162                                data = (Vector)o; 
     
    243245                         
    244246                        chart.resetData(); 
    245                         applyTemplate(data); //Brotecs: block this 
     247                        //applyTemplate(data); //Brotecs: block this 
    246248                        applyData(); 
    247249                }         
     
    253255         */ 
    254256        protected void updateWidget(QuestionDef question) { 
    255         //System.out.println("Brotecs::GraphWidget->updateWidget");              
    256                 //currentTemplate = (WHOWeightTemplate)templates.get(new Integer(question.getDataType())); //Brotecs: block this 
    257                 currentTemplate = new WHOWeightTemplate(); //Brotecs: for WHOWeightTemplate 
    258                 //currentTemplate = new CurrentTemplate(); 
    259         currentTemplate.setIsUseTemplate(true); 
     257        System.out.println("Brotecs::GraphWidget->updateWidget"); 
     258                //currentTemplate = (IGraphTemplate)templates.get(new Integer(question.getDataType())); //Brotecs: for WHOWeightTemplate 
     259                currentTemplate = (IGraphTemplate)templates.get(new Integer(WHOWeightTemplate.WHO_WEIGHT_TEMPLATE_ID)); //Brotecs: for WHOWeightTemplate 
     260        /*********Brotecs********************* 
     261                if(currentTemplate!=null){ 
     262                currentTemplate.setIsUseTemplate(true); 
     263                chart.defaulttemplate(true); 
     264                chart.setMaxYScaleFactor(30); 
     265        } 
     266        else{ 
     267                currentTemplate.setIsUseTemplate(false); 
     268        }**************************************/ 
    260269        chart.resetData(); 
    261270                applyTemplate(data);