Changeset 6900

Show
Ignore:
Timestamp:
02/19/08 03:33:37 (5 years ago)
Author:
gyuque
Message:

metro-map: deserialize and tipbox.

Location:
lang/actionscript/metro-map/mkmap
Files:
1 added
3 modified

Legend:

Unmodified
Added
Removed
  • lang/actionscript/metro-map/mkmap/AnchorButton.as

    r6839 r6900  
    1313                private var mSegBack:Segment; 
    1414                private var mSegMid:Segment; 
     15                 
     16                private var mCanvas:MCanvas; 
    1517                 
    1618                function AnchorButton(weak:Boolean) 
     
    3133                        mHitSprite = DragAnchorUtil.makeHitPanel(100); 
    3234                        addChild(mHitSprite); 
     35                } 
     36                 
     37                public function set ownerCanvas(c:MCanvas):void 
     38                { 
     39                        mCanvas = c; 
    3340                } 
    3441                 
  • lang/actionscript/metro-map/mkmap/MCanvas.as

    r6871 r6900  
    1414                private var mLayers:Array; 
    1515                private var mLayerDatas:Array; 
     16                private var mLineTipBox:TipBox; 
     17                private var mLineTipBox2:TipBox; 
    1618                 
    1719                function MCanvas(w:int, h:int) 
     
    1921                        mTitleBoxCtl = new MTitleBoxController(this); 
    2022                        createLayers(); 
     23                        mLineTipBox  = new TipBox(64, 20); 
     24                        mLineTipBox2 = new TipBox(64, 20); 
     25                        addChild(mLineTipBox); 
     26                        addChild(mLineTipBox2); 
    2127                         
    2228                        mWidth  = w; 
     
    8894                } 
    8995                 
     96                public function showLineTip(x:int, y:int, msg:String, index:int):void 
     97                { 
     98                        var t:TipBox = (index==0) ? mLineTipBox : mLineTipBox2; 
     99                         
     100                        t.show(); 
     101                        t.x = x - 32; 
     102                        t.y = y - 10; 
     103                         
     104                        t.text = msg; 
     105                } 
     106                 
    90107                private function deserializeLayer(lyr_elem:XML, idx:int):void 
    91108                { 
     
    135152                        s.y2 = xy[1]; 
    136153                         
    137                         p.lineColor = hexcolor; 
    138154                        s.updateAnchors(); 
    139155                         
     
    143159                                { 
    144160                                        xy = splitXY(coords[i]); 
     161                                        s = p.divideSegmentAt(xy[0], xy[1], s); 
    145162                                } 
    146163                        } 
     164                         
     165                        p.lineColor = hexcolor; 
    147166                } 
    148167                 
  • lang/actionscript/metro-map/mkmap/PolyLine.as

    r6871 r6900  
    5454                        tb.onMoved = onAnchorMove; 
    5555                        mb.onMoved = onAnchorMove; 
     56 
     57                        hb.ownerCanvas = mCanvas; 
     58                        tb.ownerCanvas = mCanvas; 
     59                        mb.ownerCanvas = mCanvas; 
    5660                         
    5761                        updateView(); 
     
    118122                } 
    119123                 
     124                private function makeRatioString(x:int, y:int):String 
     125                { 
     126                        if (x == 0 && y == 0) 
     127                                return "0 : 0"; 
     128                         
     129                        if (x<0) x = -x; 
     130                        if (y<0) y = -y; 
     131                         
     132                        if (x < y) 
     133                                return "60 : " + int(Number(x)/Number(y) * 60.0).toString(); 
     134 
     135                        return int(Number(y)/Number(x) * 60.0).toString() + " : 60"; 
     136                } 
     137                 
     138                private function showLineInfo(seg1:Segment, seg2:Segment):void 
     139                { 
     140                        var x:int; 
     141                        var y:int; 
     142                         
     143                        if (seg1) 
     144                        { 
     145                                mid_point(seg1.x2, seg1.y2, seg1.x1, seg1.y1, 20, _tmpPt1); 
     146                                mCanvas.showLineTip(_tmpPt1.x, _tmpPt1.y, makeRatioString(seg1.x1-seg1.x2, seg1.y1-seg1.y2), 0); 
     147                        } 
     148                         
     149                        if (seg2) 
     150                        { 
     151                                mid_point(seg2.x1, seg2.y1, seg2.x2, seg2.y2, 20, _tmpPt1); 
     152                                mCanvas.showLineTip(_tmpPt1.x, _tmpPt1.y, makeRatioString(seg2.x2-seg2.x1, seg2.y2-seg2.y1), 1); 
     153                        } 
     154                         
     155                } 
     156                 
    120157                private function onAnchorMove(anc:AnchorButton, e:MouseEvent):void 
    121158                { 
     
    157194                } 
    158195                 
    159                 private function divideSegmentAt(x:int, y:int, s:Segment):Segment 
     196                public function divideSegmentAt(x:int, y:int, s:Segment):Segment 
    160197                { 
    161198                        var oldNext:Segment = s.next; 
     
    164201                        var tb:AnchorButton = new AnchorButton(false); 
    165202                        var mb:AnchorButton = new AnchorButton(true); 
     203                         
     204                        tb.ownerCanvas = mCanvas; 
     205                        mb.ownerCanvas = mCanvas; 
     206                         
    166207                        addChild(tb); 
    167208                        addChild(mb); 
     
    286327                private function moveEndAnchor(seg1:Segment, seg2:Segment, x:int, y:int):void 
    287328                { 
     329                        showLineInfo(seg1, seg2); 
     330                         
    288331                        if (seg1 != null) 
    289332                        {