Add sublayers (stacking order) for stroke drawing
authorRichard Fairhurst <richard@systemed.net>
Mon, 1 Jun 2009 21:26:09 +0000 (21:26 +0000)
committerRichard Fairhurst <richard@systemed.net>
Mon, 1 Jun 2009 21:26:09 +0000 (21:26 +0000)
net/systemeD/halcyon/Map.as
net/systemeD/halcyon/WayUI.as
net/systemeD/halcyon/styleparser/ShapeStyle.as
test.yaml

index 36003a0b290c5edd1c5597414219fc29826a6572..ed136c3f6b38c5819c8f01f22a8822f548abde4a 100755 (executable)
@@ -66,12 +66,21 @@ package net.systemeD.halcyon {
 
         public function Map() {
 
+                       // Set up layering
+                       // [layer][2]                   - names
+                       // [layer][1][sublayer] - stroke
+                       // [layer][0]                   - fill
+
                        for (var l:int=0; l<13; l++) {                          // 11 layers (10 is +5, 0 is -5)
-                               var s:Sprite=new Sprite();
-                               s.addChild(new Sprite());                               // [layer][0]=fill, [1]=stroke, [2]=names
-                               s.addChild(new Sprite());
-                               s.addChild(new Sprite());
-                               addChild(s);
+                               var s:Sprite=new Sprite();                              //  |
+                               s.addChild(new Sprite());                               //      | 0 fill
+                               var t:Sprite=new Sprite();                              //  | 1 stroke
+                               for (var j:int=0; j<11; j++) {                  //      |  | ten sublayers
+                                       t.addChild(new Sprite());                       //  |  |  |
+                               }                                                                               //  |  |  |
+                               s.addChild(t);                                                  //  |  |
+                               s.addChild(new Sprite());                               //      | 2 names
+                               addChild(s);                                                    //  |
                        }
                        s=new Sprite(); addChild(s);                            // 11 - POIs
                        s=new Sprite(); addChild(s);                            // 12 - shields
index c9dfb937f6a708ff3b7eeee424e9a5cd473d92a9..6ceff854689bf0e087da3794f339ff9b9999f05b 100755 (executable)
@@ -64,11 +64,15 @@ package net.systemeD.halcyon {
                public function redraw():void {
             var tags:Object = way.getTagsCopy();
 
-                       // ** remove previous version from any layer
+                       // ** remove previous version from any layer/sublayer
                        layer=5;
                        if ( tags['layer'] )
                 layer=Math.min(Math.max(tags['layer']+5,-5),5)+5;
 
+                       // set style
+                       var styles:Array=map.ruleset.getStyle(false, tags, map.scale);
+                       var sublayer:uint=0; if (styles[0] && styles[0].sublayer) { sublayer=styles[0].sublayer; }
+
                        // find/create sprites
                        if (stroke) {
                                fill.graphics.clear(); 
@@ -77,15 +81,12 @@ package net.systemeD.halcyon {
                                while (roadname.numChildren) { roadname.removeChildAt(0); }
                        } else {
                                fill=new Sprite(); addToLayer(fill,0);
-                               stroke=new Sprite(); addToLayer(stroke,1); 
+                               stroke=new Sprite(); addToLayer(stroke,1,sublayer); 
                                roadname=new Sprite(); addToLayer(roadname,2); 
                        }
                        var g:Graphics=stroke.graphics;
                        var f:Graphics=fill.graphics;
 
-                       // set style
-                       var styles:Array=map.ruleset.getStyle(false, tags, map.scale);
-
                        // ShapeStyle
                        // ** do line-caps/joints
                        var doStroke:Boolean=false, doDashed:Boolean=false;
@@ -295,9 +296,10 @@ package net.systemeD.halcyon {
                
                // Add object (stroke/fill/roadname) to layer sprite
                
-               private function addToLayer(s:Sprite,sublayer:uint):void {
+               private function addToLayer(s:Sprite,t:uint,sublayer:int=-1):void {
                        var l:DisplayObject=Map(map).getChildAt(layer);
-                       var o:DisplayObject=Sprite(l).getChildAt(sublayer);
+                       var o:DisplayObject=Sprite(l).getChildAt(t);
+                       if (sublayer!=-1) { o=Sprite(o).getChildAt(sublayer); }
                        Sprite(o).addChild(s);
                }
        }
index bcf79b27c451f069d61f24db74d59eb857f81b64..e6319cd0ede9ec48f85e321dffe349a60af15e71 100644 (file)
@@ -9,6 +9,7 @@ package net.systemeD.halcyon.styleparser {
                public var stroke_dashArray:Array=[];
                public var stroke_linecap:String="none";
                public var stroke_linejoin:String="round";
+               public var sublayer:uint=0;
                
                public var isFilled:Boolean=false;
                public var fill_colour:uint=0xFFFFFF;
index d31587ae00159d88e0543f536b6b4ede5325618f..0c4a1e4e496c813fc0380502ec281a9825010b47 100644 (file)
--- a/test.yaml
+++ b/test.yaml
@@ -19,6 +19,7 @@
     isFilled: false
     isStroked: true
     isCased: true
+    sublayer: 6
     stroke_width: 4.5
     stroke_colour: 16777139
     casing_width: 6
@@ -39,6 +40,7 @@
     isFilled: false
     isStroked: true
     isCased: true
+    sublayer: 6
     stroke_width: 6
     stroke_colour: 16777139
     casing_width: 7.5
@@ -58,6 +60,7 @@
   shapeStyle: !actionscript/object:net.systemeD.halcyon.styleparser.ShapeStyle
     isFilled: false
     isStroked: true
+    sublayer: 6
     stroke_width: 9.4
     stroke_colour: 16777139
 
@@ -75,6 +78,7 @@
   shapeStyle: !actionscript/object:net.systemeD.halcyon.styleparser.ShapeStyle
     isFilled: false
     isStroked: true
+    sublayer: 6
     stroke_width: 13
     stroke_colour: 16777139
 
   shapeStyle: !actionscript/object:net.systemeD.halcyon.styleparser.ShapeStyle
     isFilled: false
     isStroked: true
+    sublayer: 7
     stroke_width: 1
     stroke_colour: 16698507
 
   shapeStyle: !actionscript/object:net.systemeD.halcyon.styleparser.ShapeStyle
     isFilled: false
     isStroked: true
+    sublayer: 7
     stroke_width: 2
     stroke_colour: 16698507
 
     isFilled: false
     isStroked: true
     isCased: true
+    sublayer: 7
     stroke_width: 2
     stroke_colour: 16701349
     casing_width: 2.5
     isFilled: false
     isStroked: true
     isCased: true
+    sublayer: 7
     stroke_width: 8
     stroke_colour: 16701349
     casing_width: 8.5
     isFilled: false
     isStroked: true
     isCased: true
+    sublayer: 7
     stroke_width: 11
     stroke_colour: 16701349
     casing_width: 11.5
     isFilled: false
     isStroked: true
     isCased: true
+    sublayer: 7
     stroke_width: 15.5
     stroke_colour: 16701349
     casing_width: 16
   shapeStyle: !actionscript/object:net.systemeD.halcyon.styleparser.ShapeStyle
     isFilled: false
     isStroked: true
+    sublayer: 10
     stroke_width: 1
     stroke_colour: 8428480
 
   shapeStyle: !actionscript/object:net.systemeD.halcyon.styleparser.ShapeStyle
     isFilled: false
     isStroked: true
+    sublayer: 10
     stroke_width: 1.5
     stroke_colour: 8428480
 
   shapeStyle: !actionscript/object:net.systemeD.halcyon.styleparser.ShapeStyle
     isFilled: false
     isStroked: true
+    sublayer: 10
     stroke_width: 2
     stroke_colour: 8428480
 
   shapeStyle: !actionscript/object:net.systemeD.halcyon.styleparser.ShapeStyle
     isFilled: false
     isStroked: true
+    sublayer: 10
     stroke_width: 2.5
     stroke_colour: 8428480
 
     isStroked: true
     isCased: true
     # link was originally 0.5 on 1.5
+    sublayer: 10
     stroke_width: 2
     stroke_colour: 8428480
     casing_width: 3
     isStroked: true
     isCased: true
     # link was originally 3 on 4.5
+    sublayer: 10
     stroke_width: 5
     stroke_colour: 8428480
     casing_width: 6.5
     isStroked: true
     isCased: true
     # link was originally 6.5 on 8
+    sublayer: 10
     stroke_width: 8.5
     stroke_colour: 8428480
     casing_width: 10
     isStroked: true
     isCased: true
     # link was originally 9 on 11
+    sublayer: 10
     stroke_width: 11
     stroke_colour: 8428480
     casing_width: 13
   shapeStyle: !actionscript/object:net.systemeD.halcyon.styleparser.ShapeStyle
     isFilled: false
     isStroked: true
+    sublayer: 8
     stroke_width: 0.7
     stroke_colour: 15505562
 
   shapeStyle: !actionscript/object:net.systemeD.halcyon.styleparser.ShapeStyle
     isFilled: false
     isStroked: true
+    sublayer: 8
     stroke_width: 1.6
     stroke_colour: 15505562
 
   shapeStyle: !actionscript/object:net.systemeD.halcyon.styleparser.ShapeStyle
     isFilled: false
     isStroked: true
+    sublayer: 8
     stroke_width: 2.5
     stroke_colour: 15505562
 
     isFilled: false
     isStroked: true
     isCased: true
+    sublayer: 8
     stroke_width: 2.5
     stroke_colour: 15505562
     casing_width: 3
     isFilled: false
     isStroked: true
     isCased: true
+    sublayer: 8
     stroke_width: 7
     stroke_colour: 15505562
     casing_width: 7.5
     isFilled: false
     isStroked: true
     isCased: true
+    sublayer: 8
     stroke_width: 11
     stroke_colour: 15505562
     casing_width: 11.5
     isFilled: false
     isStroked: true
     isCased: true
+    sublayer: 8
     stroke_width: 15.5
     stroke_colour: 15505562
     casing_width: 16
   shapeStyle: !actionscript/object:net.systemeD.halcyon.styleparser.ShapeStyle
     isFilled: false
     isStroked: true
+    sublayer: 9
     stroke_width: 1
     stroke_colour: 11131817
 
   shapeStyle: !actionscript/object:net.systemeD.halcyon.styleparser.ShapeStyle
     isFilled: false
     isStroked: true
+    sublayer: 9
     stroke_width: 1.7
     stroke_colour: 9950103
 
   shapeStyle: !actionscript/object:net.systemeD.halcyon.styleparser.ShapeStyle
     isFilled: false
     isStroked: true
+    sublayer: 9
     stroke_width: 2.5
     stroke_colour: 9950103
 
     isFilled: false
     isStroked: true
     isCased: true
+    sublayer: 9
     stroke_width: 2.5
     stroke_colour: 11131817
     casing_width: 3
     isFilled: false
     isStroked: true
     isCased: true
+    sublayer: 9
     stroke_width: 7
     stroke_colour: 11131817
     casing_width: 7.5
     isFilled: false
     isStroked: true
     isCased: true
+    sublayer: 9
     stroke_width: 11
     stroke_colour: 11131817
     casing_width: 11.5
     isFilled: false
     isStroked: true
     isCased: true
+    sublayer: 9
     stroke_width: 15.5
     stroke_colour: 11131817
     casing_width: 16
   shapeStyle: !actionscript/object:net.systemeD.halcyon.styleparser.ShapeStyle
     isFilled: false
     isStroked: true
+    sublayer: 5
     stroke_width: 1
     stroke_colour: 12303291
 
     isFilled: false
     isStroked: true
     isCased: true
+    sublayer: 5
     stroke_width: 2
     stroke_colour: 16777215
     casing_width: 3
     isFilled: false
     isStroked: true
     isCased: true
+    sublayer: 5
     stroke_width: 3
     stroke_colour: 16777215
     casing_width: 4.5
     isFilled: false
     isStroked: true
     isCased: true
+    sublayer: 5
     stroke_width: 9.4
     stroke_colour: 16777215
     casing_width: 11
     isFilled: false
     isStroked: true
     isCased: true
+    sublayer: 5
     stroke_width: 13
     stroke_colour: 16777215
     casing_width: 16