better still...
[potlatch2.git] / net / systemeD / halcyon / styleparser / ShapeStyle.as
index 7df67b5ecc4625e9fde98a97a664111ee0942c8b..fe83ea1e2cd16f36be5016355a5c24ea6319d2bb 100644 (file)
@@ -1,13 +1,16 @@
 package net.systemeD.halcyon.styleparser {
 
+       import flash.display.Graphics;
+       
        public class ShapeStyle extends Style {
 
-               public var width:Number;
+               public var width:Number=0;
                public var color:Number;
                public var opacity:Number;
-               public var dashes:Array;
+               public var dashes:Array=[];
                public var linecap:String;
                public var linejoin:String;
+               public var line_style:String;
                
                public var fill_color:Number;
                public var fill_opacity:Number;
@@ -16,15 +19,43 @@ package net.systemeD.halcyon.styleparser {
                public var casing_width:Number;
                public var casing_color:Number;
                public var casing_opacity:Number;
-               public var casing_dashes:Array;
+               public var casing_dashes:Array=[];
                
                override public function get properties():Array {
                        return [
-                               'width','color','opacity','dashes','linecap','linejoin',
+                               'width','color','opacity','dashes','linecap','linejoin','line_style',
                                'fill_color','fill_opacity','fill_image',
                                'casing_width','casing_color','casing_opacity','casing_dashes'
                        ];
                }
+               
+               override public function get drawn():Boolean {
+                       return (fill_image || fill_color || width || casing_width);
+               }
+
+               public function applyStrokeStyle(g:Graphics):void {
+                       g.lineStyle(width,
+                                               color ? color : 0,
+                                               opacity ? opacity : 1,
+                                               false, "normal",
+                                               linecap  ? linecap : "none",
+                                               linejoin ? linejoin : "round");
+               }
+               
+               public function applyCasingStyle(g:Graphics):void {
+                       g.lineStyle(casing_width,
+                                               casing_color   ? casing_color : 0,
+                                               casing_opacity ? casing_opacity : 1,
+                                               false, "normal",
+                                               linecap  ? linecap : "none",
+                                               linejoin ? linejoin : "round");
+               }
+               
+               public function applyFill(g:Graphics):void {
+                       g.beginFill(fill_color,
+                                               fill_opacity ? fill_opacity : 1);
+               }
+               
        }
 
 }