refactor node stateClasses and stylelist calculation
[potlatch2.git] / net / systemeD / halcyon / styleparser / StyleList.as
index f00715f64855621d6e7eba6613abc4f9309ac4c0..a5ac01cd3c689d04c94141bff143c6458b044243 100755 (executable)
@@ -11,14 +11,39 @@ package net.systemeD.halcyon.styleparser {
 
                */
 
-               public var shapeStyles:Array=[];
-               public var textStyles:Array=[];
-               public var pointStyles:Array=[];
-               public var shieldStyles:Array=[];
+               public var shapeStyles:Object={};
+               public var textStyles:Object={};
+               public var pointStyles:Object={};
+               public var shieldStyles:Object={};
                public var maxwidth:Number=0;
+               public var sublayers:Array=[];
+               public var validAt:int=-1;                              // zoom level at which this StyleList is valid, or -1 for all
 
                public function hasStyles():Boolean {
-                       return ( (shapeStyles.length + textStyles.length + pointStyles.length + shieldStyles.length) > 0 );
+                       return ( hasShapeStyles() || hasTextStyles() || hasPointStyles() || hasShieldStyles() );
                }
+               
+               public function addSublayer(s:Number):void {
+                       if (sublayers.indexOf(s)==-1) { sublayers.push(s); }
+               }
+
+               public function toString():String {
+                       var str:String='';
+                       var k:String;
+                       for (k in shapeStyles) { str+="- SS "+k+"="+shapeStyles[k]+"\n"; }
+                       for (k in textStyles) { str+="- TS "+k+"="+textStyles[k]+"\n"; }
+                       for (k in pointStyles) { str+="- PS "+k+"="+pointStyles[k]+"\n"; }
+                       for (k in shieldStyles) { str+="- sS "+k+"="+shieldStyles[k]+"\n"; }
+                       return str;
+               }
+
+               public function isValidAt(zoom:uint):Boolean {
+                       return (validAt==-1 || validAt==zoom);
+               }
+
+               private function hasShapeStyles():Boolean  { for (var a:String in shapeStyles ) { return true; }; return false; }
+               private function hasTextStyles():Boolean   { for (var a:String in textStyles  ) { return true; }; return false; }
+               private function hasPointStyles():Boolean  { for (var a:String in pointStyles ) { return true; }; return false; }
+               private function hasShieldStyles():Boolean { for (var a:String in shieldStyles) { return true; }; return false; }
        }
-}
\ No newline at end of file
+}