Changeset 4040

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

calendar, one-day display

Location:
ssme/trunk/flex
Files:
1 added
6 modified

Legend:

Unmodified
Added
Removed
  • ssme/trunk/flex/Calendar/src/Calendar.mxml

    r4037 r4040  
    155155                        width="100%" height="100%" minHeight="400" 
    156156                        outerBorderColor="0x000000" outerBorderAlpha="1.0" outerBorderThickness="1" 
    157                         innerBorderColors="[ 0x000000, 0x444444, 0x888888 ]" innerBorderAlphas="[ 0.5, 0.3, 0.3 ]" innerBorderThicknesses="[ 2, 1, 1 ]" 
    158                         backgroundColor="0xffffff" backgroundAlpha="0" 
    159                         rows="[ 24, 48, 96 ]" columns="[ 1 ]" 
     157                        innerBorderColors="[ 0x000000, 0x888888 ]" innerBorderAlphas="[ 0.5, 0.3 ]" innerBorderThicknesses="[ 2, 1 ]" 
     158                        backgroundColor="0xffffff" backgroundAlpha="0" 
     159                        rows="[ 24, 96 ]" columns="[ 1 ]" 
    160160                        visible="true" includeInLayout="true" 
    161161                        cornerRadius="0"> 
     
    166166                        width="100%" height="100%" minHeight="400" 
    167167                        outerBorderColor="0x000000" outerBorderAlpha="1.0" outerBorderThickness="1" 
    168                         innerBorderColors="[ 0x000000, 0x444444, 0x888888 ]" innerBorderAlphas="[ 0.5, 0.3, 0.3 ]" innerBorderThicknesses="[ 2, 1, 1 ]" 
    169                         backgroundColor="0xffffff" backgroundAlpha="0" 
    170                         rows="[ 24, 48, 96 ]" columns="[ 1 ]" 
     168                        innerBorderColors="[ 0x000000, 0x888888 ]" innerBorderAlphas="[ 0.5, 0.3 ]" innerBorderThicknesses="[ 2, 1 ]" 
     169                        backgroundColor="0xffffff" backgroundAlpha="0" 
     170                        rows="[ 24, 96 ]" columns="[ 1 ]" 
    171171                        showEffect="{ fadeIn }" hideEffect="{ fadeOut }" 
    172172                        cornerRadius="0"> 
     
    177177                        width="100%" height="100%" minHeight="400" 
    178178                        outerBorderColor="0x000000" outerBorderAlpha="1.0" outerBorderThickness="1" 
    179                         innerBorderColors="[ 0x000000, 0x444444, 0x888888 ]" innerBorderAlphas="[ 0.5, 0.3, 0.3 ]" innerBorderThicknesses="[ 2, 1, 1 ]" 
    180                         backgroundColor="0xffffff" backgroundAlpha="0" 
    181                         rows="[ 24, 48, 96 ]" columns="[ 1 ]" 
     179                        innerBorderColors="[ 0x000000, 0x888888 ]" innerBorderAlphas="[ 0.5, 0.3 ]" innerBorderThicknesses="[ 2, 1 ]" 
     180                        backgroundColor="0xffffff" backgroundAlpha="0" 
     181                        rows="[ 24, 96 ]" columns="[ 1 ]" 
    182182                        showEffect="{ fadeIn }" hideEffect="{ fadeOut }" 
    183183                        cornerRadius="0"> 
     
    188188                        width="100%" height="100%" minHeight="400" 
    189189                        outerBorderColor="0x000000" outerBorderAlpha="1.0" outerBorderThickness="1" 
    190                         innerBorderColors="[ 0x000000, 0x444444, 0x888888 ]" innerBorderAlphas="[ 0.5, 0.3, 0.3 ]" innerBorderThicknesses="[ 2, 1, 1 ]" 
    191                         backgroundColor="0xffffff" backgroundAlpha="0" 
    192                         rows="[ 24, 48, 96 ]" columns="[ 1 ]" 
     190                        innerBorderColors="[ 0x000000, 0x888888 ]" innerBorderAlphas="[ 0.5, 0.3 ]" innerBorderThicknesses="[ 2, 1 ]" 
     191                        backgroundColor="0xffffff" backgroundAlpha="0" 
     192                        rows="[ 24, 96 ]" columns="[ 1 ]" 
    193193                        showEffect="{ fadeIn }" hideEffect="{ fadeOut }" 
    194194                        cornerRadius="0"> 
     
    199199                        width="100%" height="100%" minHeight="400" 
    200200                        outerBorderColor="0x000000" outerBorderAlpha="1.0" outerBorderThickness="1" 
    201                         innerBorderColors="[ 0x000000, 0x444444, 0x888888 ]" innerBorderAlphas="[ 0.5, 0.3, 0.3 ]" innerBorderThicknesses="[ 2, 1, 1 ]" 
    202                         backgroundColor="0xffffff" backgroundAlpha="0" 
    203                         rows="[ 24, 48, 96 ]" columns="[ 1 ]" 
     201                        innerBorderColors="[ 0x000000, 0x888888 ]" innerBorderAlphas="[ 0.5, 0.3 ]" innerBorderThicknesses="[ 2, 1 ]" 
     202                        backgroundColor="0xffffff" backgroundAlpha="0" 
     203                        rows="[ 24, 96 ]" columns="[ 1 ]" 
    204204                        showEffect="{ fadeIn }" hideEffect="{ fadeOut }" 
    205205                        cornerRadius="0"> 
     
    210210                        width="100%" height="100%" minHeight="400" 
    211211                        outerBorderColor="0x000000" outerBorderAlpha="1.0" outerBorderThickness="1" 
    212                         innerBorderColors="[ 0x000000, 0x444444, 0x888888 ]" innerBorderAlphas="[ 0.5, 0.3, 0.3 ]" innerBorderThicknesses="[ 2, 1, 1 ]" 
    213                         backgroundColor="0xffffff" backgroundAlpha="0" 
    214                         rows="[ 24, 48, 96 ]" columns="[ 1 ]" 
     212                        innerBorderColors="[ 0x000000, 0x888888 ]" innerBorderAlphas="[ 0.5, 0.3 ]" innerBorderThicknesses="[ 2, 1 ]" 
     213                        backgroundColor="0xffffff" backgroundAlpha="0" 
     214                        rows="[ 24, 96 ]" columns="[ 1 ]" 
    215215                        showEffect="{ fadeIn }" hideEffect="{ fadeOut }" 
    216216                        cornerRadius="0"> 
     
    221221                        width="100%" height="100%" minHeight="400" 
    222222                        outerBorderColor="0x000000" outerBorderAlpha="1.0" outerBorderThickness="1" 
    223                         innerBorderColors="[ 0x000000, 0x444444, 0x888888 ]" innerBorderAlphas="[ 0.5, 0.3, 0.3 ]" innerBorderThicknesses="[ 2, 1, 1 ]" 
    224                         backgroundColor="0xffffff" backgroundAlpha="0" 
    225                         rows="[ 24, 48, 96 ]" columns="[ 1 ]" 
     223                        innerBorderColors="[ 0x000000, 0x888888 ]" innerBorderAlphas="[ 0.5, 0.3 ]" innerBorderThicknesses="[ 2, 1 ]" 
     224                        backgroundColor="0xffffff" backgroundAlpha="0" 
     225                        rows="[ 24, 96 ]" columns="[ 1 ]" 
    226226                        showEffect="{ fadeIn }" hideEffect="{ fadeOut }"                         
    227227                        cornerRadius="0"> 
     
    301301                calendarsList.push( { uuid:key, name:loggedUserEntity.calendarsNames[key] } ); 
    302302            } 
     303            calendarsList.sort( sortCalendars ); 
    303304            calendarsList.push( { uuid:null, name: "All" } ); 
    304             calendarCombo.selectedIndex = -1; 
     305            calendarCombo.selectedIndex = -1;                    
     306        } 
     307        private function sortCalendars(a:Object, b:Object):int { 
     308            return ( a.name < b.name ) ? -1 : (( a.name > b.name ) ? 1 : 0 ); 
    305309        } 
    306310 
     
    387391        private var dayCanvas:Array = [ canvas_1, canvas_2, canvas_3, canvas_4, canvas_5, canvas_6, canvas_7 ]; 
    388392        private function showDayEvents():void { 
     393            canvas_1.currentDay = chosenDate.selectedDate;  
    389394            canvas_1.dataProvider = calendarEntity.timeFramesEntitites; 
    390395        } 
  • 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(); 
  • ssme/trunk/flex/Calendar/src/com/kh/ssme/components/EventField.as

    r4031 r4040  
    2323package com.kh.ssme.components { 
    2424 
    25     import flash.display.DisplayObject; 
     25import com.kh.ssme.entity.TimeFrameEntity; 
     26 
     27import flash.display.DisplayObject; 
    2628 
    2729    import mx.binding.utils.BindingUtils; 
     
    5153                ( eventInfo_ as UIComponent ).x = ( eventInfo_ as UIComponent ).y = 0;   
    5254                container_.addChild( eventInfo_ as UIComponent ); 
    53 //                var a:TextArea = new TextArea(); 
    54 //                a.text = "[TEST]"; 
    55 //                a.width = 100; 
    56 //                a.height = 100; 
    57 //                container_.addChild( a ); 
    5855            } 
    5956        } 
     
    6158            return eventInfo_; 
    6259        } 
     60 
     61        public override function set data(value:Object):void{ 
     62            if(eventInfo_){ 
     63                eventInfo_.eventData = value as TimeFrameEntity; 
     64            } 
     65        }         
     66        public override function get data():Object{ 
     67            return (eventInfo_) ? eventInfo_.eventData : null;     
     68        } 
     69 
    6370 
    6471        protected override function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{ 
  • ssme/trunk/flex/Calendar/src/com/kh/ssme/components/SimpleEventDisplay.as

    r4031 r4040  
    4949                this.text += eventData_.from+"-"+eventData_.to+"\n"; 
    5050                this.text += eventData_.description+"\n"; 
     51 
     52                this.toolTip = this.text; 
    5153            } 
    5254        } 
  • ssme/trunk/flex/Common/src/com/kh/ssme/components/GridCanvas.as

    r4037 r4040  
    3939         * Number of columns 
    4040         */ 
    41         private var columns_:Array; 
     41        private var columns_:Array;   
    4242        public function get columns():Array{ 
    4343            return columns_; 
     
    4949            } 
    5050        } 
     51        public var columnsPosition:Array;               
     52 
    5153 
    5254        /** 
     
    6365            } 
    6466        } 
     67        public var rowsPosition:Array;           
    6568 
    6669 
     
    183186 
    184187            // inner border 
    185             var inBorderThickness:int; 
     188            var inBorderThickness:int, xTempPos:int, yTempPos:int; 
     189            columnsPosition = []; 
     190            rowsPosition = []; 
    186191            for (var i:int = 0; i<inBorderThicknesses.length; i++){ 
    187                 if (inBorderThicknesses[i] > 0) 
    188                 { 
     192                // for each border level 
     193                if (inBorderThicknesses[i] > 0){ 
    189194                    inBorderThickness = inBorderThicknesses[i]; 
    190195                    graphics.lineStyle(inBorderThickness,inBorderColors[i],inBorderAlphas[i], 
     
    193198                                       CapsStyle.NONE); 
    194199 
     200                    var tempColumnsPos:Array = [], tempRowsPos:Array = [];                       
    195201                    if(columns_.length>=i){ 
    196202                        var xstep:Number = (unscaledWidth - (2*outBorderThickness+leftHorizontalMargin+rightHorizontalMargin)  - (columns_[i] - 1)*inBorderThickness) / columns_[i]; 
     203                        // left border position 
    197204                        var x:Number = outBorderThickness+leftHorizontalMargin; 
    198                         for ( var col:int = 1; col < columns_[i]; col++ ) 
    199                         { 
     205                        xTempPos = x - inBorderThickness*0.5; 
     206                        tempColumnsPos.push( xTempPos ); 
     207                        // draw column lines 
     208                        for ( var col:int = 1; col < columns_[i]; col++ ){ 
    200209                            x += (xstep + inBorderThickness); 
    201                             graphics.moveTo(x - inBorderThickness*0.5, outBorderThickness + verticalMargin);// + inBorderThickness*0.5); 
    202                             graphics.lineTo(x - inBorderThickness*0.5, unscaledHeight - outBorderThickness - verticalMargin);// - inBorderThickness*0.5);                           
     210                            xTempPos = x - inBorderThickness*0.5; 
     211                            graphics.moveTo(xTempPos, outBorderThickness + verticalMargin); 
     212                            graphics.lineTo(xTempPos, unscaledHeight - outBorderThickness - verticalMargin); 
     213                            tempColumnsPos.push( xTempPos ); 
    203214                        } 
     215                        // right border position 
     216                        x += (xstep + inBorderThickness); 
     217                        xTempPos = x - inBorderThickness*0.5; 
     218                        tempColumnsPos.push( xTempPos ); 
    204219                    } 
    205220                    if(rows_.length>=i){ 
    206221                        var ystep:Number = (unscaledHeight - (2*outBorderThickness+2*verticalMargin) - (rows_[i] - 1)*inBorderThickness) / rows_[i]; 
     222                        // top border position                         
    207223                        var y:Number = outBorderThickness+verticalMargin; 
    208                         for (var row:int = 1; row < rows_[i]; row++ ) 
    209                         { 
     224                        yTempPos = y - inBorderThickness*0.5; 
     225                        tempRowsPos.push( yTempPos ); 
     226                        // draw rows lines 
     227                        for (var row:int = 1; row < rows_[i]; row++ ){ 
    210228                            y += (ystep + inBorderThickness); 
    211                             graphics.moveTo(outBorderThickness + leftHorizontalMargin,// + inBorderThickness*0.5, 
    212                                     y - inBorderThickness*0.5); 
    213                             graphics.lineTo(unscaledWidth - outBorderThickness - rightHorizontalMargin, // - inBorderThickness*0.5, 
    214                                     y - inBorderThickness*0.5); 
     229                            yTempPos = y - inBorderThickness*0.5; 
     230                            graphics.moveTo(outBorderThickness + leftHorizontalMargin, yTempPos); 
     231                            graphics.lineTo(unscaledWidth - outBorderThickness - rightHorizontalMargin, yTempPos); 
     232                            tempRowsPos.push( yTempPos );                             
    215233                        } 
     234                        // bottom border position 
     235                        y += (ystep + inBorderThickness); 
     236                        yTempPos = y - inBorderThickness*0.5; 
     237                        tempRowsPos.push( yTempPos ); 
    216238                    } 
    217  
     239                    columnsPosition.push( tempColumnsPos ); 
     240                    rowsPosition.push( tempRowsPos );                     
    218241                } 
    219242            } 
    220243 
    221  
    222  
    223244        } 
    224245 
  • ssme/trunk/flex/Common/src/com/kh/ssme/util/DateUtil.as

    r4037 r4040  
    109109        } 
    110110 
     111        /** 
     112         * Returns whether this DateUtil represents a time before the time represented by the specified date param 
     113         * @param date 
     114         * @return 
     115         */ 
     116        public function before(date:Date):Boolean{ 
     117            return date_.time < date.time; 
     118        } 
     119 
     120        /** 
     121         * Returns whether this DateUtil represents a time after the time represented by the specified date param 
     122         * @param date 
     123         * @return 
     124         */ 
     125        public function after(date:Date):Boolean{ 
     126            return date_.time < date.time; 
     127        } 
     128 
     129        /** 
     130         * Compares the time values (millisecond offsets from the Epoch) represented by this DateUtil and given Date. 
     131         * @param date 
     132         * @return the value 0 if the time represented by the argument is equal to the time represented by this DateUtil; 
     133         *      a value less than 0 if the time of this Calendar is before the time represented by the argument; 
     134         *      and a value greater than 0 if the time of this Calendar is after the time represented by the argument.  
     135         */ 
     136        public function compare(date:DateUtil):int{ 
     137            return (date_.time - date.timestamp) as int; 
     138        } 
     139 
     140        /** 
     141         * String representation of this DateUtil  
     142         * @return 
     143         */ 
     144        public function toString():String{ 
     145            return "[DateUtil: "+date_.toString()+"]"; 
     146        } 
    111147 
    112148        //----------------------------------------------