width can be defined based on maximum width so far
[potlatch2.git] / net / systemeD / halcyon / styleparser / ShapeStyle.as
1 package net.systemeD.halcyon.styleparser {
2
3         import flash.display.Graphics;
4         
5         public class ShapeStyle extends Style {
6
7                 public var width:Number=0;
8                 public var color:Number;
9                 public var opacity:Number;
10                 public var dashes:Array=[];
11                 public var linecap:String;
12                 public var linejoin:String;
13                 
14                 public var fill_color:Number;
15                 public var fill_opacity:Number;
16                 public var fill_image:String;
17                 
18                 public var casing_width:Number;
19                 public var casing_color:Number;
20                 public var casing_opacity:Number;
21                 public var casing_dashes:Array=[];
22                 
23                 override public function get properties():Array {
24                         return [
25                                 'width','color','opacity','dashes','linecap','linejoin',
26                                 'fill_color','fill_opacity','fill_image',
27                                 'casing_width','casing_color','casing_opacity','casing_dashes'
28                         ];
29                 }
30                 
31                 override public function get drawn():Boolean {
32                         return (fill_image || fill_color || width || casing_width);
33                 }
34
35                 public function applyStrokeStyle(g:Graphics):void {
36                         g.lineStyle(width,
37                                                 color ? color : 0,
38                                                 opacity ? opacity : 1,
39                                                 false, "normal",
40                                                 linecap  ? linecap : "none",
41                                                 linejoin ? linejoin : "round");
42                 }
43                 
44                 public function applyCasingStyle(g:Graphics):void {
45                         g.lineStyle(casing_width,
46                                                 casing_color   ? casing_color : 0,
47                                                 casing_opacity ? casing_opacity : 1,
48                                                 false, "normal",
49                                                 linecap  ? linecap : "none",
50                                                 linejoin ? linejoin : "round");
51                 }
52                 
53                 public function applyFill(g:Graphics):void {
54                         g.beginFill(fill_color,
55                                                 fill_opacity ? fill_opacity : 1);
56                 }
57         }
58
59 }