]> git.openstreetmap.org Git - potlatch2.git/blob - net/systemeD/halcyon/styleparser/StyleList.as
allow layers to be overridden in MapCSS; this means we can bring selected nodes to...
[potlatch2.git] / net / systemeD / halcyon / styleparser / StyleList.as
1 package net.systemeD.halcyon.styleparser {
2
3         public class StyleList {
4
5                 /*
6                         A StyleList object is the full list of all styles applied to 
7                         a drawn entity (i.e. node/way).
8                         
9                         Each array element applies to that sublayer (z-index). If there
10                         is no element, nothing is drawn on that sublayer.
11
12                 */
13
14                 public var shapeStyles:Object={};
15                 public var textStyles:Object={};
16                 public var pointStyles:Object={};
17                 public var shieldStyles:Object={};
18                 public var maxwidth:Number=0;
19                 public var sublayers:Array=[];
20                 public var validAt:int=-1;                              // zoom level at which this StyleList is valid, or -1 for all
21
22                 public function hasStyles():Boolean {
23                         return ( hasShapeStyles() || hasTextStyles() || hasPointStyles() || hasShieldStyles() );
24                 }
25
26                 public function layerOverride():Number {
27                         for each (var ss:ShapeStyle in shapeStyles) {
28                                 if (ss['layer']) return ss['layer'];
29                         }
30                         return NaN;
31                 }
32                 
33                 public function addSublayer(s:Number):void {
34                         if (sublayers.indexOf(s)==-1) { sublayers.push(s); }
35                 }
36
37                 public function toString():String {
38                         var str:String='';
39                         var k:String;
40                         for (k in shapeStyles) { str+="- SS "+k+"="+shapeStyles[k]+"\n"; }
41                         for (k in textStyles) { str+="- TS "+k+"="+textStyles[k]+"\n"; }
42                         for (k in pointStyles) { str+="- PS "+k+"="+pointStyles[k]+"\n"; }
43                         for (k in shieldStyles) { str+="- sS "+k+"="+shieldStyles[k]+"\n"; }
44                         return str;
45                 }
46
47                 public function isValidAt(zoom:uint):Boolean {
48                         return (validAt==-1 || validAt==zoom);
49                 }
50
51                 private function hasShapeStyles():Boolean  { for (var a:String in shapeStyles ) { return true; }; return false; }
52                 private function hasTextStyles():Boolean   { for (var a:String in textStyles  ) { return true; }; return false; }
53                 private function hasPointStyles():Boolean  { for (var a:String in pointStyles ) { return true; }; return false; }
54                 private function hasShieldStyles():Boolean { for (var a:String in shieldStyles) { return true; }; return false; }
55         }
56 }