Better support for MapCSS 0.2, including subparts
authorRichard Fairhurst <richard@systemeD.net>
Sun, 12 Jun 2011 18:55:39 +0000 (19:55 +0100)
committerRichard Fairhurst <richard@systemeD.net>
Sun, 12 Jun 2011 18:55:39 +0000 (19:55 +0100)
15 files changed:
net/systemeD/halcyon/EntityUI.as
net/systemeD/halcyon/MapPaint.as
net/systemeD/halcyon/MarkerUI.as
net/systemeD/halcyon/NodeUI.as
net/systemeD/halcyon/WayUI.as
net/systemeD/halcyon/styleparser/RuleChain.as
net/systemeD/halcyon/styleparser/RuleSet.as
net/systemeD/halcyon/styleparser/ShapeStyle.as
net/systemeD/halcyon/styleparser/StyleChooser.as
net/systemeD/halcyon/styleparser/StyleList.as
net/systemeD/potlatch2/controller/ControllerState.as
net/systemeD/potlatch2/controller/SelectedPOINode.as
resources/stylesheets/core_interactive.css
resources/stylesheets/core_relations.css
resources/stylesheets/core_ways.css

index 4a2c62d..bca513b 100644 (file)
@@ -139,13 +139,13 @@ package net.systemeD.halcyon {
 
                /** Add object (stroke/fill/roadname) to layer sprite*/
                
-               protected function addToLayer(s:DisplayObject,t:uint,sublayer:int=-1):void {
+               protected function addToLayer(s:DisplayObject,spritetype:uint,sublayer:int=-1):void {
                        var l:Sprite, o:Sprite;
                        if (sublayer!=-1) {
-                               o=paint.sublayer(layer,sublayer);
+                               o=paint.sublayer(layer,spritetype,sublayer);
                        } else {
                                l=paint.getPaintSpriteAt(layer);
-                               o=l.getChildAt(t) as Sprite;
+                               o=l.getChildAt(spritetype) as Sprite;
                        }
                        o.addChild(s);
                        if (sprites.indexOf(s)==-1) { sprites.push(s); }
@@ -155,7 +155,6 @@ package net.systemeD.halcyon {
             }
                }
 
-               // What does this do, could someone please document?
                protected function setListenSprite():void {
                        var l:Sprite=paint.getHitSpriteAt(layer);
                        var s:Sprite;
index 31b4808..8206aef 100644 (file)
@@ -75,7 +75,9 @@ package net.systemeD.halcyon {
                        // Add paint sprites
                        for (l=minlayer; l<=maxlayer; l++) {                    // each layer (10 is +5, 0 is -5)
                                s = getPaintSprite();                                           //      |
-                               s.addChild(getPaintSprite());                           //      | 0 fill
+                               var q:Sprite = getPaintSprite();                        //      | 0 fill
+                               q.addChild(getPaintSprite());                           //      |  | sublayer
+                               s.addChild(q);                                                          //  |  |
                                s.addChild(getPaintSprite());                           //      | 1 casing
                                var t:Sprite = getPaintSprite();                        //      | 2 stroke
                                t.addChild(getPaintSprite());                           //      |  | sublayer
@@ -110,7 +112,7 @@ package net.systemeD.halcyon {
                        return true;
                }
 
-               public function sublayer(layer:int,sublayer:Number):Sprite {
+               public function sublayer(layer:int,spritetype:uint,sublayer:Number):Sprite {
                        var l:DisplayObject;
                        var o:DisplayObject;
                        var index:String, ix:Number;
@@ -132,8 +134,8 @@ package net.systemeD.halcyon {
                                // add sprites
                                for (var i:int=minlayer; i<=maxlayer; i++) {
                                        l=getChildAt(i-minlayer);
-                                       o=(l as Sprite).getChildAt(2);
-                                       (o as Sprite).addChildAt(getPaintSprite(),lowestAbovePos);
+                                       o=(l as Sprite).getChildAt(0); (o as Sprite).addChildAt(getPaintSprite(),lowestAbovePos);       // fillsprite
+                                       o=(l as Sprite).getChildAt(2); (o as Sprite).addChildAt(getPaintSprite(),lowestAbovePos);       // strokesprite
                                }
                        
                                // update index
@@ -149,7 +151,7 @@ package net.systemeD.halcyon {
                        }
 
                        l=getChildAt(layer-minlayer);
-                       o=(l as Sprite).getChildAt(2);
+                       o=(l as Sprite).getChildAt(spritetype);
                        return ((o as Sprite).getChildAt(sublayerIndex[sublayer]) as Sprite);
                }
 
index e2b9f20..536a208 100644 (file)
@@ -14,7 +14,7 @@ package net.systemeD.halcyon {
     public class MarkerUI extends EntityUI {
 
         public var loaded:Boolean=false;
-        private var iconnames:Object={};            // name of icon on each sublayer
+        private var iconnames:Object={};            // name of icon on each subpart
         private var heading:Number=0;               // heading within way
         private var rotation:Number=0;              // rotation applied to this POI
         private static const NO_LAYER:int=-99999;
@@ -76,47 +76,47 @@ package net.systemeD.halcyon {
             var w:Number;
             var icon:Sprite;
             interactive=false;
-            for each (var sublayer:Number in styleList.sublayers) {
+            for each (var subpart:String in styleList.subparts) {
 
-                if (styleList.pointStyles[sublayer]) {
-                    var s:PointStyle=styleList.pointStyles[sublayer];
+                if (styleList.pointStyles[subpart]) {
+                    var s:PointStyle=styleList.pointStyles[subpart];
                     interactive||=s.interactive;
                     r=true;
                     if (s.rotation) { rotation=s.rotation; }
-                    if (s.icon_image!=iconnames[sublayer]) {
+                    if (s.icon_image!=iconnames[subpart]) {
                         if (s.icon_image=='square') {
                             // draw square
                             icon=new Sprite();
-                            addToLayer(icon,STROKESPRITE,sublayer);
-                            w=styleIcon(icon,sublayer);
+                            addToLayer(icon,STROKESPRITE,s.sublayer);
+                            w=styleIcon(icon,subpart);
                             icon.graphics.drawRect(0,0,w,w);
                             if (s.interactive) { maxwidth=Math.max(w,maxwidth); }
-                            iconnames[sublayer]='_square';
+                            iconnames[subpart]='_square';
 
                         } else if (s.icon_image=='circle') {
                             // draw circle
                             icon=new Sprite();
-                            addToLayer(icon,STROKESPRITE,sublayer);
-                            w=styleIcon(icon,sublayer);
+                            addToLayer(icon,STROKESPRITE,s.sublayer);
+                            w=styleIcon(icon,subpart);
                             icon.graphics.drawCircle(w,w,w);
                             if (s.interactive) { maxwidth=Math.max(w,maxwidth); }
-                            iconnames[sublayer]='_circle';
+                            iconnames[subpart]='_circle';
 
                         } else if (paint.ruleset.images[s.icon_image]) {
                             // 'load' icon (actually just from library)
                             var loader:ExtendedLoader = new ExtendedLoader();
-                            loader.info['sublayer']=sublayer;
+                            loader.info['sublayer']=s.sublayer;
                             loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadedIcon, false, 0, true);
                             loader.loadBytes(paint.ruleset.images[s.icon_image]);
-                            iconnames[sublayer]=s.icon_image;
+                            iconnames[subpart]=s.icon_image;
                         }
                     }
                 }
 
                 // name sprite
                 var a:String='', t:TextStyle;
-                if (styleList.textStyles[sublayer]) {
-                    t=styleList.textStyles[sublayer];
+                if (styleList.textStyles[subpart]) {
+                    t=styleList.textStyles[subpart];
                     interactive||=t.interactive;
                     a=tags[t.text];
                 }
@@ -135,12 +135,12 @@ package net.systemeD.halcyon {
         }
 
 
-        private function styleIcon(icon:Sprite, sublayer:Number):Number {
+        private function styleIcon(icon:Sprite, subpart:String):Number {
             loaded=true;
 
             // get colours
-            if (styleList.shapeStyles[sublayer]) {
-                var s:ShapeStyle=styleList.shapeStyles[sublayer];
+            if (styleList.shapeStyles[subpart]) {
+                var s:ShapeStyle=styleList.shapeStyles[subpart];
                 if (!isNaN(s.color)) { icon.graphics.beginFill(s.color);
                     }
                 if (s.casing_width || !isNaN(s.casing_color)) {
@@ -151,7 +151,7 @@ package net.systemeD.halcyon {
             }
 
             // return width
-            return styleList.pointStyles[sublayer].icon_width;
+            return styleList.pointStyles[subpart].icon_width;
         }
 
         private function addHitSprite(w:uint):void {
index 4f8431f..cf58a14 100644 (file)
@@ -15,7 +15,7 @@ package net.systemeD.halcyon {
        public class NodeUI extends EntityUI {
                
                public var loaded:Boolean=false;
-               private var iconnames:Object={};                        // name of icon on each sublayer
+               private var iconnames:Object={};                        // name of icon on each subpart
                private var heading:Number=0;                           // heading within way
                private var rotation:Number=0;                          // rotation applied to this POI
                private static const NO_LAYER:int=-99999;
@@ -96,47 +96,47 @@ package net.systemeD.halcyon {
                        var w:Number;
                        var icon:Sprite;
                        interactive=false;
-                       for each (var sublayer:Number in styleList.sublayers) {
+                       for each (var subpart:String in styleList.subparts) {
 
-                               if (styleList.pointStyles[sublayer]) {
-                                       var s:PointStyle=styleList.pointStyles[sublayer];
+                               if (styleList.pointStyles[subpart]) {
+                                       var s:PointStyle=styleList.pointStyles[subpart];
                                        interactive||=s.interactive;
                                        r=true;
                                        if (s.rotation) { rotation=s.rotation; }
-                                       if (s.icon_image!=iconnames[sublayer]) {
+                                       if (s.icon_image!=iconnames[subpart]) {
                                                if (s.icon_image=='square') {
                                                        // draw square
                                                        icon=new Sprite();
-                                                       addToLayer(icon,STROKESPRITE,sublayer);
-                                                       w=styleIcon(icon,sublayer);
+                                                       addToLayer(icon,STROKESPRITE,s.sublayer);
+                                                       w=styleIcon(icon,subpart);
                                                        icon.graphics.drawRect(0,0,w,w);
                                                        if (s.interactive) { maxwidth=Math.max(w,maxwidth); }
-                                                       iconnames[sublayer]='_square';
+                                                       iconnames[subpart]='_square';
 
                                                } else if (s.icon_image=='circle') {
                                                        // draw circle
                                                        icon=new Sprite();
-                                                       addToLayer(icon,STROKESPRITE,sublayer);
-                                                       w=styleIcon(icon,sublayer);
+                                                       addToLayer(icon,STROKESPRITE,s.sublayer);
+                                                       w=styleIcon(icon,subpart);
                                                        icon.graphics.drawCircle(w,w,w);
                                                        if (s.interactive) { maxwidth=Math.max(w,maxwidth); }
-                                                       iconnames[sublayer]='_circle';
+                                                       iconnames[subpart]='_circle';
 
                                                } else if (paint.ruleset.images[s.icon_image]) {
                                                        // 'load' icon (actually just from library)
                                                        var loader:ExtendedLoader = new ExtendedLoader();
-                                                       loader.info['sublayer']=sublayer;
+                                                       loader.info['sublayer']=s.sublayer;
                                                        loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadedIcon, false, 0, true);
                                                        loader.loadBytes(paint.ruleset.images[s.icon_image]);
-                                                       iconnames[sublayer]=s.icon_image;
+                                                       iconnames[subpart]=s.icon_image;
                                                }
                                        }
                                }
 
                                // name sprite
                                var a:String='', t:TextStyle;
-                               if (styleList.textStyles[sublayer]) {
-                                       t=styleList.textStyles[sublayer];
+                               if (styleList.textStyles[subpart]) {
+                                       t=styleList.textStyles[subpart];
                                        interactive||=t.interactive;
                                        a=tags[t.text];
                                }
@@ -155,12 +155,12 @@ package net.systemeD.halcyon {
                }
 
 
-               private function styleIcon(icon:Sprite, sublayer:Number):Number {
+               private function styleIcon(icon:Sprite, subpart:String):Number {
                        loaded=true;
 
                        // get colours
-                       if (styleList.shapeStyles[sublayer]) {
-                               var s:ShapeStyle=styleList.shapeStyles[sublayer];
+                       if (styleList.shapeStyles[subpart]) {
+                               var s:ShapeStyle=styleList.shapeStyles[subpart];
                                if (!isNaN(s.color)) { icon.graphics.beginFill(s.color, s.opacity ? s.opacity : 1);
                                        }
                                if (s.casing_width || !isNaN(s.casing_color)) {
@@ -171,7 +171,7 @@ package net.systemeD.halcyon {
                        }
 
                        // return width
-                       return styleList.pointStyles[sublayer].icon_width;
+                       return styleList.pointStyles[subpart].icon_width;
                }
 
                private function addHitSprite(w:uint):void {
index 0f5ebdd..fdec4d4 100644 (file)
@@ -259,7 +259,7 @@ package net.systemeD.halcyon {
                                indexEnd  =Math.min(drawOnly+2,Way(entity).length);
                        }
 
-                       // Iterate through each sublayer, drawing any styles on that layer
+                       // Iterate through each subpart, drawing any styles on that layer
                        var drawn:Boolean;
                        var multis:Array=entity.findParentRelationsOfType('multipolygon','outer');
                        var inners:Array=[];
@@ -267,9 +267,9 @@ package net.systemeD.halcyon {
                                inners=inners.concat(m.findMembersByRole('inner',Way));
                        }
 
-                       for each (var sublayer:Number in styleList.sublayers) {
-                               if (styleList.shapeStyles[sublayer]) {
-                                       var s:ShapeStyle=styleList.shapeStyles[sublayer];
+                       for each (var subpart:String in styleList.subparts) {
+                               if (styleList.shapeStyles[subpart]) {
+                                       var s:ShapeStyle=styleList.shapeStyles[subpart];
                                        var stroke:Shape, fill:Shape, casing:Shape, roadname:Sprite;
                                        var x0:Number=paint.map.lon2coord(Way(entity).getNode(0).lon);
                                        var y0:Number=paint.map.latp2coord(Way(entity).getNode(0).latp);
@@ -277,7 +277,7 @@ package net.systemeD.halcyon {
 
                                        // Stroke
                                        if (s.width)  {
-                                               stroke=new Shape(); addToLayer(stroke,STROKESPRITE,sublayer);
+                                               stroke=new Shape(); addToLayer(stroke,STROKESPRITE,s.sublayer);
                                                stroke.graphics.moveTo(x0,y0);
                                                s.applyStrokeStyle(stroke.graphics);
                                                if (s.dashes && s.dashes.length>0) {
@@ -290,7 +290,7 @@ package net.systemeD.halcyon {
 
                                        // Fill
                                        if ((!isNaN(s.fill_color) || s.fill_image) && entity.findParentRelationsOfType('multipolygon','inner').length==0 && isNaN(drawExcept)) {
-                                               fill=new Shape(); addToLayer(fill,FILLSPRITE);
+                                               fill=new Shape(); addToLayer(fill,FILLSPRITE,s.sublayer);
                                                fill.graphics.moveTo(x0,y0);
                                                if (s.fill_image) { new WayBitmapFiller(this,fill.graphics,s); }
                                                                         else { s.applyFill(fill.graphics); }
@@ -311,8 +311,8 @@ package net.systemeD.halcyon {
                                        }
                                }
                                
-                               if (styleList.textStyles[sublayer] && isNaN(drawExcept)) {
-                                       var t:TextStyle=styleList.textStyles[sublayer];
+                               if (styleList.textStyles[subpart] && isNaN(drawExcept)) {
+                                       var t:TextStyle=styleList.textStyles[subpart];
                                        interactive||=t.interactive;
                                        roadname=new Sprite(); addToLayer(roadname,NAMESPRITE);
                                        nameformat = t.getTextFormat();
index cd6c5b4..61bca34 100644 (file)
@@ -15,8 +15,8 @@ package net.systemeD.halcyon.styleparser {
        */
 
        public class RuleChain {
-               public var rules:Array=[];              // should eventually become a Vector of Rules
-               public var subpart:String='';   // subpart name, as in way[highway=primary]::centreline
+               public var rules:Array=[];                              // should eventually become a Vector of Rules
+               public var subpart:String='default';    // subpart name, as in way[highway=primary]::centreline
 
                // Test a ruleChain
                // - run a set of tests in the chain
@@ -27,8 +27,9 @@ package net.systemeD.halcyon.styleparser {
                // - if they succeed, and there's more in the chain, rerun this for each parent until success
                
                public function test(pos:int, obj:Entity, tags:Object, zoom:uint):Boolean {
+                       if (length==0) { return false; }
                        if (pos==-1) { pos=rules.length-1; }
-
+                       
                        var r:Rule=rules[pos];
                        if (!r.test(obj, tags, zoom)) { return false; }
                        if (pos==0) { return true; }
@@ -44,6 +45,10 @@ package net.systemeD.halcyon.styleparser {
                        return rules.length;
                }
                
+               public function setSubpart(s:String):void {
+                       subpart = s=='' ? 'default' : s;
+               }
+
                // ---------------------------------------------------------------------------------------------
                // Methods to add properties (used by parsers such as MapCSS)
 
@@ -60,6 +65,5 @@ package net.systemeD.halcyon.styleparser {
                        rules[rules.length-1].maxZoom=z2;
                }
 
-
        }
 }
index 0bf9923..1c9f6be 100644 (file)
@@ -43,7 +43,7 @@ package net.systemeD.halcyon.styleparser {
                private static const CONDITION:RegExp   =/^ \[(.+?)\] \s* /sx;
                private static const OBJECT:RegExp              =/^ (\w+) \s* /sx;
                private static const DECLARATION:RegExp =/^ \{(.+?)\} \s* /sx;
-               private static const SUBPART:RegExp             =/^ ::(\S+) \s* /sx;
+               private static const SUBPART:RegExp             =/^ ::(\w+) \s* /sx;
                private static const UNKNOWN:RegExp             =/^ (\S+) \s* /sx;
 
                private static const ZOOM_MINMAX:RegExp =/^ (\d+)\-(\d+) $/sx;
@@ -75,6 +75,7 @@ package net.systemeD.halcyon.styleparser {
                private static const oCONDITION:uint=4;
                private static const oOBJECT:uint=5;
                private static const oDECLARATION:uint=6;
+               private static const oSUBPART:uint=7;
 
                private static const DASH:RegExp=/\-/g;
                private static const COLOR:RegExp=/color$/;
@@ -288,7 +289,7 @@ package net.systemeD.halcyon.styleparser {
                                        else if (style is ShieldStyle && ShieldStyle(style).shield_image) { filename=ShieldStyle(style).shield_image; }
                                        else { continue; }
                                        if (filename=='square' || filename=='circle') { continue; }
-                               
+                       
                                        iconsToLoad++;
                                        var request:DebugURLRequest=new DebugURLRequest(filename);
                                        var loader:ExtendedURLLoader=new ExtendedURLLoader();
@@ -410,6 +411,13 @@ package net.systemeD.halcyon.styleparser {
                                        sc.currentChain.addRule(o[1]);
                                        previous=oOBJECT;
 
+                               // Subpart - ::centreline
+                               } else if ((o=SUBPART.exec(css))) {
+                                       if (previous==oDECLARATION) { saveChooser(sc); sc=new StyleChooser(); }
+                                       css=css.replace(SUBPART,'');
+                                       sc.currentChain.setSubpart(o[1]);
+                                       previous=oSUBPART;
+
                                // Declaration - {...}
                                } else if ((o=DECLARATION.exec(css))) {
                                        css=css.replace(DECLARATION,'');
index 03411fc..1ec9996 100644 (file)
@@ -45,7 +45,7 @@ package net.systemeD.halcyon.styleparser {
                }
                
                public function applyCasingStyle(g:Graphics):void {
-                       g.lineStyle(casing_width,
+                       g.lineStyle(width + casing_width,
                                                casing_color   ? casing_color : 0,
                                                casing_opacity ? casing_opacity : 1,
                                                false, "normal",
index 1a3f86f..c2d2980 100644 (file)
@@ -38,7 +38,7 @@ package net.systemeD.halcyon.styleparser {
                public function get currentChain():RuleChain {
                        return ruleChains[rcpos];
                }
-
+               
                // Update the current StyleList from this StyleChooser
 
                public function updateStyles(obj:Entity, tags:Object, sl:StyleList, imageWidths:Object, zoom:uint):void {
@@ -46,53 +46,50 @@ package net.systemeD.halcyon.styleparser {
 
                        // Are any of the ruleChains fulfilled?
                        var w:Number;
-                       var fulfilled:Boolean=false;
                        for each (var c:RuleChain in ruleChains) {
                                if (c.test(-1,obj,tags,zoom)) {
-                                       fulfilled=true; break;
-                               }
-                       }
-                       if (!fulfilled) { return; }
+                                       sl.addSubpart(c.subpart);
 
-                       // Update StyleList
-                       for each (var r:Style in styles) {
-                               var a:*;
-                               if (r is ShapeStyle) {
-                                       a=sl.shapeStyles;
-                                       if (ShapeStyle(r).width>sl.maxwidth && !r.evals['width']) { sl.maxwidth=ShapeStyle(r).width; }
-                               } else if (r is ShieldStyle) {
-                                       a=sl.shieldStyles;
-                               } else if (r is TextStyle) { 
-                                       a=sl.textStyles;
-                               } else if (r is PointStyle) { 
-                                       a=sl.pointStyles;
-                                       w=0;
-                                       if (PointStyle(r).icon_width && !PointStyle(r).evals['icon_width']) {
-                                               w=PointStyle(r).icon_width;
-                                       } else if (PointStyle(r).icon_image && imageWidths[PointStyle(r).icon_image]) {
-                                               w=imageWidths[PointStyle(r).icon_image];
-                                       }
-                                       if (w>sl.maxwidth) { sl.maxwidth=w; }
-                               } else if (r is InstructionStyle) {
-                                       if (InstructionStyle(r).breaker) { return; }
-                                       if (InstructionStyle(r).set_tags) {
-                                               for (var k:String in InstructionStyle(r).set_tags) { tags[k]=InstructionStyle(r).set_tags[k]; }
-                                       }
-                                       continue;
-                               }
-                               if (r.drawn) { tags[':drawn']='yes'; }
-                               tags['_width']=sl.maxwidth;
+                                       // Update StyleList
+                                       for each (var r:Style in styles) {
+                                               var a:Object;
+                                               if (r is ShapeStyle) {
+                                                       a=sl.shapeStyles;
+                                                       if (ShapeStyle(r).width>sl.maxwidth && !r.evals['width']) { sl.maxwidth=ShapeStyle(r).width; }
+                                               } else if (r is ShieldStyle) {
+                                                       a=sl.shieldStyles;
+                                               } else if (r is TextStyle) { 
+                                                       a=sl.textStyles;
+                                               } else if (r is PointStyle) { 
+                                                       a=sl.pointStyles;
+                                                       w=0;
+                                                       if (PointStyle(r).icon_width && !PointStyle(r).evals['icon_width']) {
+                                                               w=PointStyle(r).icon_width;
+                                                       } else if (PointStyle(r).icon_image && imageWidths[PointStyle(r).icon_image]) {
+                                                               w=imageWidths[PointStyle(r).icon_image];
+                                                       }
+                                                       if (w>sl.maxwidth) { sl.maxwidth=w; }
+                                               } else if (r is InstructionStyle) {
+                                                       if (InstructionStyle(r).breaker) { return; }
+                                                       if (InstructionStyle(r).set_tags) {
+                                                               for (var k:String in InstructionStyle(r).set_tags) { tags[k]=InstructionStyle(r).set_tags[k]; }
+                                                       }
+                                                       continue;
+                                               }
+                                               if (r.drawn) { tags[':drawn']='yes'; }
+                                               tags['_width']=sl.maxwidth;
                                
-                               r.runEvals(tags);
-                               sl.addSublayer(r.sublayer);
-                               if (a[r.sublayer]) {
-                                       // If there's already a style on this sublayer, then merge them
-                                       // (making a deep copy if necessary to avoid altering the root style)
-                                       if (!a[r.sublayer].merged) { a[r.sublayer]=a[r.sublayer].deepCopy(); }
-                                       a[r.sublayer].mergeWith(r);
-                               } else {
-                                       // Otherwise, just assign it
-                                       a[r.sublayer]=r;
+                                               r.runEvals(tags);
+                                               if (a[c.subpart]) {
+                                                       // If there's already a style on this sublayer, then merge them
+                                                       // (making a deep copy if necessary to avoid altering the root style)
+                                                       if (!a[c.subpart].merged) { a[c.subpart]=a[c.subpart].deepCopy(); }
+                                                       a[c.subpart].mergeWith(r);
+                                               } else {
+                                                       // Otherwise, just assign it
+                                                       a[c.subpart]=r;
+                                               }
+                                       }
                                }
                        }
                }
@@ -108,10 +105,9 @@ package net.systemeD.halcyon.styleparser {
                        }
                }
 
-               // addStyles    <- adds to this.styles
                public function addStyles(a:Array):void {
                        styles=styles.concat(a);
                }
-               
+
        }
 }
index c2fd02b..97bcd1a 100644 (file)
@@ -19,8 +19,8 @@ package net.systemeD.halcyon.styleparser {
                public var shieldStyles:Object={};
                public var maxwidth:Number=0;
 
-               /** List of sublayers used in this StyleList. */
-               public var sublayers:Array=[];
+               /** List of subparts used in this StyleList. */
+               public var subparts:Array=[];
 
         /** Zoom level this StyleList is valid at. If -1, valid at all styles (i.e. doesn't need to be recomputed
                        on zoom in/out); otherwise, specifies a single zoom level. */
@@ -47,9 +47,9 @@ package net.systemeD.halcyon.styleparser {
                        return NaN;
                }
                
-               /** Record that a sublayer is used in this StyleList. */
-               public function addSublayer(s:Number):void {
-                       if (sublayers.indexOf(s)==-1) { sublayers.push(s); }
+               /** Record that a subpart is used in this StyleList. */
+               public function addSubpart(s:String):void {
+                       if (subparts.indexOf(s)==-1) { subparts.push(s); }
                }
 
                /** Summarise StyleList as String - for debugging. */
index c9645ae..f6f00a9 100644 (file)
@@ -99,11 +99,11 @@ package net.systemeD.potlatch2.controller {
                                        var newEntity:Entity=paint.pullThrough(entity,editableLayer);
                                        if      (entity is Way ) { return new SelectedWay(newEntity as Way); }
                                        else if (entity is Node) { return new SelectedPOINode(newEntity as Node); }
+                } else if (event.type == MouseEvent.MOUSE_DOWN && entity is Marker) {
+                    return new SelectedMarker(entity as Marker, paint);
                 } else if (event.type == MouseEvent.MOUSE_DOWN) {
                     if      (entity is Way ) { return new SelectedBackgroundWay(entity as Way); }
                     else if (entity is Node) { return new SelectedBackgroundNode(entity as Node, paint); }
-                } else if (event.type == MouseEvent.MOUSE_DOWN && entity is Marker) {
-                    return new SelectedMarker(entity as Marker, paint);
                                } else if ( event.type == MouseEvent.MOUSE_UP ) {
                                        return (this is NoSelection) ? null : new NoSelection();
                                } else { return null; }
index 2710dc9..9b893cb 100644 (file)
@@ -63,6 +63,7 @@ package net.systemeD.potlatch2.controller {
                        editableLayer.setPurgable(selection,false);
         }
         override public function exitState(newState:ControllerState):void {
+trace("firstSelected is "+firstSelected);
             if(firstSelected.hasTags()) {
               controller.clipboards['node']=firstSelected.getTagsCopy();
             }
index 0e4ae87..402d86d 100644 (file)
@@ -20,5 +20,5 @@ node !:drawn :poi { z-index: 2; icon-image: circle; icon-width: 4; color: green;
 node !:drawn :hasTags { z-index: 9; icon-image: circle; icon-width: 4; color: black; }
 node :hasTags :selectedway { z-index: 9; icon-image: square; icon-width: 8; color: black; layer: 5; }
 node !:drawn :selectedway { z-index: 9; icon-image: square; icon-width: 8; color: red; casing-color: #cc0000; casing-width: 1; layer: 5; }
-node :selected { z-index: 1; icon-image: square; icon-width: eval('_width+10'); color: yellow; interactive: no; layer: 5; }
-node :junction :selectedway { z-index: 8; icon-image: square; icon-width: 12; casing-color: black; casing-width: 1; layer: 5; }
+node::selectedNode :selected { z-index: 1; icon-image: square; icon-width: eval('_width+10'); color: yellow; interactive: no; layer: 5; }
+node::junctionNode :junction :selectedway { z-index: 8; icon-image: square; icon-width: 12; casing-color: black; casing-width: 1; layer: 5; }
index d1b2d5f..7756abe 100644 (file)
@@ -1,7 +1,7 @@
 /* Route relations */
 
-relation[type=route] way { z-index: 1; width: 13; color: blue; opacity: 0.3; }
-relation[type=route][route=bicycle][network=ncn] way { z-index: 1; width: 12; color: red; opacity: 0.3; }
-relation[type=route][route=bicycle][network=rcn] way { z-index: 1; width: 12; color: cyan; opacity: 0.3; }
-relation[type=route][route=bicycle][network=lcn] way { z-index: 1; width: 12; color: blue; opacity: 0.3; }
-relation[type=route][route=foot] way { z-index: 1; width: 10; color: #80ff80; opacity: 0.6; }
+relation[type=route] way::route { z-index: 1; width: 13; color: blue; opacity: 0.3; }
+relation[type=route][route=bicycle][network=ncn] way::route { z-index: 1; width: 12; color: red; opacity: 0.3; }
+relation[type=route][route=bicycle][network=rcn] way::route { z-index: 1; width: 12; color: cyan; opacity: 0.3; }
+relation[type=route][route=bicycle][network=lcn] way::route { z-index: 1; width: 12; color: blue; opacity: 0.3; }
+relation[type=route][route=foot] way::route { z-index: 1; width: 10; color: #80ff80; opacity: 0.6; }
index 9e087f5..876c5b5 100644 (file)
@@ -112,14 +112,12 @@ way[leisure=sports_centre] :area { color: #66ddcc; fill-color: #66ddcc; set .are
 
 /* Physical decoration */
 
-way[bridge=yes], way[bridge=viaduct], way[bridge=suspension]
-    { z-index: 4; color: white; width: eval('_width+3'); }
-    { z-index: 3; color: black; width: eval('_width+6'); }
-way[tunnel=yes][!waterway]
-    { z-index: 4; color: white; width: eval('_width+2'); }
-    { z-index: 3; color: black; width: eval('_width+6'); dashes: 4,4; }
+way[bridge=yes]::bridge1, way[bridge=viaduct]::bridge1, way[bridge=suspension]::bridge1 { z-index: 4; color: white; width: eval('_width+3'); }
+way[bridge=yes]::bridge2, way[bridge=viaduct]::bridge2, way[bridge=suspension]::bridge2 { z-index: 3; color: black; width: eval('_width+6'); }
+way[tunnel=yes][!waterway]::bridge1 { z-index: 4; color: white; width: eval('_width+2'); }
+way[tunnel=yes][!waterway]::bridge2 { z-index: 3; color: black; width: eval('_width+6'); dashes: 4,4; }
 
 /* Attribute decoration */
 
-way[oneway=yes], way[junction=roundabout] { z-index: 15; color: #444444; width: 2; dashes: 15,35; line-style: arrows; }
-way[oneway=-1] { z-index: 15; color: #444444; width: 2; dashes: 15,35; line-style: arrows-reversed; }
+way[oneway=yes]::arrows, way[junction=roundabout]::arrows { z-index: 15; color: #444444; width: 2; dashes: 15,35; line-style: arrows; }
+way[oneway=-1]::arrows { z-index: 15; color: #444444; width: 2; dashes: 15,35; line-style: arrows-reversed; }