1//////////////////////////////////////////////////////////////////////////////// 2// 3// ADOBE SYSTEMS INCORPORATED 4// Copyright 2009 Adobe Systems Incorporated 5// All Rights Reserved. 6// 7// NOTICE: Adobe permits you to use, modify, and distribute this file 8// in accordance with the terms of the license agreement accompanying it. 9// 10//////////////////////////////////////////////////////////////////////////////// 11 12package mx.charts.styles 13{ 14 15import mx.core.mx_internal; 16import mx.graphics.IFill; 17import mx.graphics.IStroke; 18import mx.graphics.SolidColor; 19import mx.graphics.Stroke; 20import mx.styles.CSSStyleDeclaration; 21import mx.styles.IStyleManager2; 22 23use namespace mx_internal; 24 25/** 26 * Initializes the core default styles for the charts classes. Each chart and element is responsible for initializing their own 27 * style values, but they rely on the common values computed by the HaloDefaults class. 28 * 29 * @langversion 3.0 30 * @playerversion Flash 9 31 * @playerversion AIR 1.1 32 * @productversion Flex 3 33 */ 34public class HaloDefaults 35{ 36 include "../../core/Version.as"; 37 38 //-------------------------------------------------------------------------- 39 // 40 // Class variables 41 // 42 //-------------------------------------------------------------------------- 43 44 /** 45 * @private 46 */ 47 private static var inited:Boolean; 48 49 [Inspectable(environment="none")] 50 /** 51 * The default selectors applied to the individual series in a chart. 52 * 53 * @langversion 3.0 54 * @playerversion Flash 9 55 * @playerversion AIR 1.1 56 * @productversion Flex 3 57 */ 58 mx_internal static var chartBaseChartSeriesStyles:Array; 59 60 [Inspectable(environment="none")] 61 /** 62 * The default color values used by chart controls to color different series (or, in a PieSeries, different items). 63 * 64 * @langversion 3.0 65 * @playerversion Flash 9 66 * @playerversion AIR 1.1 67 * @productversion Flex 3 68 */ 69 mx_internal static var defaultColors:Array = 70 [ 71 0xE48701 72 ,0xA5BC4E 73 ,0x1B95D9 74 ,0xCACA9E 75 ,0x6693B0 76 ,0xF05E27 77 ,0x86D1E4 78 ,0xE4F9A0 79 ,0xFFD512 80 ,0x75B000 81 ,0x0662B0 82 ,0xEDE8C6 83 ,0xCC3300 84 ,0xD1DFE7 85 ,0x52D4CA 86 ,0xC5E05D 87 ,0xE7C174 88 ,0xFFF797 89 ,0xC5F68F 90 ,0xBDF1E6 91 ,0x9E987D 92 ,0xEB988D 93 ,0x91C9E5 94 ,0x93DC4A 95 ,0xFFB900 96 ,0x9EBBCD 97 ,0x009797 98 ,0x0DB2C2 99 ]; 100 101 [Inspectable(environment="none")] 102 /** 103 * The default SolidColor objects used as fills by chart controls to color different series (or, in a PieSeries, different items). 104 * These Fill objects correspond to the values in the <code>defaultColors</code> Array. 105 * 106 * @langversion 3.0 107 * @playerversion Flash 9 108 * @playerversion AIR 1.1 109 * @productversion Flex 3 110 */ 111 mx_internal static var defaultFills:Array = []; 112 113 [Inspectable(environment="none")] 114 mx_internal static var pointStroke:IStroke; 115 116 [Inspectable(environment="none")] 117 /** 118 * A pre-defined invisible Stroke that is used by several chart styles. 119 * 120 * @langversion 3.0 121 * @playerversion Flash 9 122 * @playerversion AIR 1.1 123 * @productversion Flex 3 124 */ 125 mx_internal static var emptyStroke:IStroke; 126 127 //-------------------------------------------------------------------------- 128 // 129 // Class methods 130 // 131 //-------------------------------------------------------------------------- 132 133 /** 134 * Creates a CSSStyleDeclaration object or returns an existing one. 135 * 136 * @param selectorName The name of the selector to return. If no existing CSSStyleDeclaration object matches 137 * this name, this method creates a new one and returns it. 138 * 139 * @param styleManager The styleManager instance to be used for getting and setting style declarations. 140 * 141 * @return The CSSStyleDeclaration object that matches the provided selector name. If no CSSStyleDeclaration object matches 142 * that name, this method creates a new one and returns it. 143 * 144 * @langversion 3.0 145 * @playerversion Flash 9 146 * @playerversion AIR 1.1 147 * @productversion Flex 3 148 */ 149 public static function createSelector( 150 selectorName:String, styleManager:IStyleManager2):CSSStyleDeclaration 151 { 152 var selector:CSSStyleDeclaration = 153 styleManager.getStyleDeclaration(selectorName); 154 155 if (!selector) 156 { 157 selector = new CSSStyleDeclaration(); 158 styleManager.setStyleDeclaration(selectorName, selector, false); 159 } 160 161 return selector; 162 } 163 164 /** 165 * Initializes the common values used by the default styles for the chart and element classes. 166 * 167 * @param styleManager The styleManager instance to be used for getting and setting style declarations. 168 * 169 * @langversion 3.0 170 * @playerversion Flash 9 171 * @playerversion AIR 1.1 172 * @productversion Flex 3 173 */ 174 public static function init(styleManager:IStyleManager2):void 175 { 176 if (inited) 177 return; 178 179 var seriesStyleCount:int = defaultColors.length; 180 181 for (var i:int = 0; i < seriesStyleCount; i++) 182 { 183 defaultFills[i] = new SolidColor(defaultColors[i]); 184 } 185 186 pointStroke = new Stroke(0, 0, 0.5); 187 emptyStroke = new Stroke(0, 0, 0); 188 chartBaseChartSeriesStyles = []; 189 190 var f:Function; 191 192 for (i = 0; i < seriesStyleCount; i++) 193 { 194 var styleName:String = "haloSeries" + i; 195 chartBaseChartSeriesStyles[i] = styleName; 196 197 var o:CSSStyleDeclaration = 198 HaloDefaults.createSelector("." + styleName, styleManager); 199 200 f = function (o:CSSStyleDeclaration, defaultFill:IFill,defaultStroke:IStroke):void 201 { 202 o.defaultFactory = function():void 203 { 204 this.fill = defaultFill; 205 this.areaFill = defaultFill; 206 this.areaStroke = emptyStroke; 207 this.lineStroke = defaultStroke; 208 } 209 } 210 211 f(o, HaloDefaults.defaultFills[i],new Stroke(defaultColors[i], 3, 1)); 212 } 213 214 } 215} 216 217} 218