Show
Ignore:
Timestamp:
08/11/10 12:55:02 (22 months ago)
Author:
mszopinski
Message:

calendar, one-day display

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • ssme/trunk/flex/Calendar/src/com/kh/ssme/components/DayCanvas.as

    r4037 r4040  
    2424 
    2525    import com.kh.ssme.entity.TimeFrameEntity; 
     26import com.kh.ssme.util.DateUtil; 
    2627import com.kh.ssme.util.HashArray; 
    2728 
     
    3839        } 
    3940 
    40 //        public var showHourLabels:Boolean = false; 
    41 // 
    42 //        private var hourLabels:HashArray = new HashArray(); 
    43 // 
    44 //        override protected function createChildren():void{ 
    45 //            super.createChildren(); 
    46 // 
    47 //            if(showHourLabels){ 
    48 //                var score:int; 
    49 //                var el:Label; 
    50 //                for(var i:int=0; i<=24; i++){ 
    51 //                    el = new Label(); 
    52 //                    el.id = el.text = ((i<10)?("0"+i):(i))+":00"; 
    53 // 
    54 //                    if( !hourLabels.containsKey(el.id) ){ 
    55 // 
    56 //                        this.addChild( el ); 
    57 // 
    58 //                        el.setStyle("textAlign","right"); 
    59 //                        el.setStyle("color", 0x000000); 
    60 //                        el.setStyle("fontSize", 11); 
    61 //                        el.visible = el.includeInLayout = false;//((i%24) == 0); 
    62 //                        score = 0x20; 
    63 //                        if(i%24 == 0)    score |= 0x01; 
    64 //                        if(i%12 == 0)    score |= 0x02; 
    65 //                        if(i%6 == 0)     score |= 0x04; 
    66 //                        if(i%3 == 0)     score |= 0x08; 
    67 //                        if(i%2 == 0)     score |= 0x10; 
    68 // 
    69 //                        hourLabels.put( el.id, { score:score, element:el } ); 
    70 // 
    71 //                    } 
    72 //                } 
    73 //            } 
    74 // 
    75 //        } 
     41        public var currentDay:Date; 
    7642 
    7743        override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{ 
    7844 
    79             // call first in order to get grid drawn correctly 
    80             super.updateDisplayList(unscaledWidth, unscaledHeight); 
    81  
    82             // do not erase old drawings! 
    83             //graphics.clear();    
    84              
    85 //            if(showHourLabels && hourLabels.size>0){ // added 
    86 // 
    87 //                var textHeight:int = (hourLabels.getValueAt(0).element as Label).textHeight;    // label text height 
    88 //                var count:int = Math.floor( unscaledHeight / (textHeight*1.5) );    // determine number of labels 
    89 //                var mark:int = 0x01; 
    90 //                if(count <= 3)              mark = 0x02; 
    91 //                else if (count <= 5)        mark = 0x04; 
    92 //                else if (count <= 9)        mark = 0x08; 
    93 //                else if (count <= 12)       mark = 0x10; 
    94 //                else /*if (count <= 24)*/   mark = 0x20; 
    95 // 
    96 //                var item:Object; 
    97 //                var inBorderThicknesses:Array = getStyle_("innerBorderThicknesses", [ 1 ]); 
    98 //                var ystep:Number = (unscaledHeight - (2*outerBorderThickness_+2*verticalMargin_) - (23*inBorderThicknesses[0])) / 24; 
    99 //                var y:Number = outerBorderThickness_+verticalMargin_; 
    100 //                //graphics.lineStyle(1, 0x0000ff, 0.7, true);   // debug 
    101 //                for (var row:int = 0; row <=24; row++ ){ 
    102 //                    //graphics.drawRoundRect(0, y - (textHeight*0.66), leftHorizontalMargin_, Math.min( Math.floor( ystep ), textHeight), 0, 0);// debug 
    103 // 
    104 //                    item = hourLabels.getValueAt(row); 
    105 //                    item.element.visible = item.element.includeInLayout = true;//(item.score & mark) > 0; 
    106 //                    item.element.x = 0; 
    107 //                    item.element.y = Math.floor( y - (textHeight*0.66) ); 
    108 //                    item.element.width = leftHorizontalMargin_; 
    109 //                    item.element.height = Math.min( Math.floor( ystep ), textHeight); 
    110 // 
    111 //                    y += (ystep + inBorderThicknesses[0]); 
    112 //                } 
    113 // 
    114 //            } 
    115  
     45            if(visible){    // repaint only if visible 
     46                // call first in order to get grid drawn correctly 
     47                super.updateDisplayList(unscaledWidth, unscaledHeight); 
     48            } 
    11649        } 
    11750 
     
    12053        public function set dataProvider(value:HashArray):void{ 
    12154            dataProvider_ = value; 
    122  
     55             
    12356            for(var i:int = 0; i<eventsMap.size; i++){ 
    124                 this.removeChild( eventsMap.getValueAt(i) ); 
     57                if( eventsMap.getValueAt(i) ){ 
     58                    this.removeChild( eventsMap.getValueAt(i) );                     
     59                    trace( "REMOVE : "+eventsMap.getValueAt(i).data+" - ["+eventsMap.getValueAt(i).data.UUID+"] " ); 
     60                } 
    12561            } 
     62            eventsMap.clear(); 
     63             
    12664            createEvents(); 
    12765            validateNow(); 
     
    14381                ev = new EventField(); 
    14482                eventsMap.put(json.UUID, ev); 
    145                 //ev.setStyle("backgroundColor", 0xffff00); 
     83                 
     84                ev.eventInfo = new SimpleEventDisplay(); 
     85                ev.data = json; 
     86                ev.name = json.UUID; 
    14687                ev.setStyle("borderThickness", 5); 
    14788                ev.setStyle("cornerRadius", 20); 
    148                 ev.name = json.UUID; 
    149  
    150                 ev.eventInfo = new SimpleEventDisplay(); 
    151                 ev.eventInfo.eventData = json;                 
     89                trace( "ADD : "+ev.data+" - ["+ev.data.UUID+"] " );                      
    15290 
    15391                addChild( ev ); 
    15492                sizeEvent( ev, i ); 
    15593                i += 100; 
    156  
    157 //                var c:Canvas = new Canvas(); 
    158 //                c.width = 100; 
    159 //                c.height = ev.height; 
    160 //                c.x = 300; 
    161 //                c.y = ev.y; 
    162 //                c.setStyle("backgroundColor", 0xff0000); 
    163 //                addChild( c ); 
    16494 
    16595            } 
     
    170100            var data:TimeFrameEntity = ev.eventInfo.eventData; 
    171101            if(data){ 
    172                 var stepY:Number = (this.height - 2*outerBorderThickness_); 
    173                 stepY /= 96;    // (24hours * 4quarters) 
     102                var timeBegin:int = (data.from.getHours() * 4) + ((data.from.getMinutes() as int)/15); 
     103                var timeEnd:int = (data.to.getHours() * 4) + ((data.to.getMinutes() as int)/15); 
    174104 
    175                 var timeBegin:int = ((data.from.getMinutes() as int)/15); 
    176                 var timeWidth:int = data.to.getHours() - data.from.getHours() + 1; 
    177                 timeWidth *= 4; 
    178                 timeWidth -= ( timeBegin + (4 -((data.to.getMinutes() as int)/15)) ); 
    179  
    180                 ev.height = stepY * timeWidth; 
     105                // if event exceed current day 
     106                var from:DateUtil = (new DateUtil(data.from)).dayBegin(); 
     107                var current:DateUtil = (new DateUtil(currentDay)).dayBegin(); 
     108                var to:DateUtil = (new DateUtil(data.to)).dayBegin(); 
     109            
     110                if( current.compare(from) > 0 ){ 
     111                    timeBegin = 0; 
     112                } 
     113                if( current.compare(to) < 0 ){ 
     114                    timeEnd = rowsPosition[1].length - 1; 
     115                } 
     116        
    181117                ev.width = 200;//XXX 
     118                ev.height = rowsPosition[1][timeEnd] - rowsPosition[1][timeBegin];                 
    182119                ev.x = 50+i;//XXX 
    183                 ev.y = (data.from.getHours()*4 + timeBegin)*stepY + outerBorderThickness_; 
     120                ev.y = rowsPosition[1][timeBegin]; 
    184121                ev.invalidateSize(); 
    185122                ev.invalidateDisplayList();